Changes in / [deb4ba7:92b41f33] in mainline


Ignore:
Location:
uspace/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhc.c

    rdeb4ba7 r92b41f33  
    5555static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5656static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     57static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     58static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5759//static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5860
     
    7375
    7476        remote_usbhc_control_write,
    75         remote_usbhc_control_read
     77        remote_usbhc_control_read,
     78
     79        remote_usbhc_register_endpoint,
     80        remote_usbhc_unregister_endpoint
    7681};
    7782
     
    522527
    523528
     529void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
     530    ipc_callid_t callid, ipc_call_t *call)
     531{
     532        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     533
     534        if (!usb_iface->register_endpoint) {
     535                async_answer_0(callid, ENOTSUP);
     536                return;
     537        }
     538
     539#define INIT_FROM_HIGH_DATA(type, var, arg_no) \
     540        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256
     541#define INIT_FROM_LOW_DATA(type, var, arg_no) \
     542        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256
     543
     544        INIT_FROM_HIGH_DATA(usb_address_t, address, 1);
     545        INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1);
     546        INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2);
     547        INIT_FROM_LOW_DATA(usb_direction_t, direction, 2);
     548
     549#undef INIT_FROM_HIGH_DATA
     550#undef INIT_FROM_LOW_DATA
     551
     552        size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call);
     553        unsigned int interval  = (unsigned int) DEV_IPC_GET_ARG4(*call);
     554
     555        int rc = usb_iface->register_endpoint(fun, address, endpoint,
     556            transfer_type, direction, max_packet_size, interval);
     557
     558        async_answer_0(callid, rc);
     559}
     560
     561
     562void remote_usbhc_unregister_endpoint(ddf_fun_t *fun, void *iface,
     563    ipc_callid_t callid, ipc_call_t *call)
     564{
     565        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     566
     567        if (!usb_iface->unregister_endpoint) {
     568                async_answer_0(callid, ENOTSUP);
     569                return;
     570        }
     571
     572        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
     573        usb_endpoint_t endpoint = (usb_endpoint_t) DEV_IPC_GET_ARG2(*call);
     574        usb_direction_t direction = (usb_direction_t) DEV_IPC_GET_ARG3(*call);
     575
     576        int rc = usb_iface->unregister_endpoint(fun,
     577            address, endpoint, direction);
     578
     579        async_answer_0(callid, rc);
     580}
     581
    524582
    525583/**
  • uspace/lib/drv/include/usbhc_iface.h

    rdeb4ba7 r92b41f33  
    167167        IPC_M_USBHC_CONTROL_READ,
    168168
    169         /* IPC_M_USB_ */
     169        /** Register endpoint attributes at host controller.
     170         * This is used to reserve portion of USB bandwidth.
     171         * Parameters:
     172         * - USB address + endpoint number (ADDR * 256 + EP)
     173         * - transfer type + direction (TYPE * 256 + DIR)
     174         * - maximum packet size
     175         * - interval (in milliseconds)
     176         * Answer:
     177         * - EOK - reservation successful
     178         * - ELIMIT - not enough bandwidth to satisfy the request
     179         */
     180        IPC_M_USBHC_REGISTER_ENDPOINT,
     181
     182        /** Revert endpoint registration.
     183         * Parameters:
     184         * - USB address
     185         * - endpoint number
     186         * - data direction
     187         * Answer:
     188         * - EOK - endpoint unregistered
     189         * - ENOENT - unknown endpoint
     190         */
     191        IPC_M_USBHC_UNREGISTER_ENDPOINT
    170192} usbhc_iface_funcs_t;
    171193
     
    200222        int (*release_address)(ddf_fun_t *, usb_address_t);
    201223
     224        int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
     225            usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
     226        int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
     227            usb_direction_t);
     228
    202229        usbhc_iface_transfer_out_t interrupt_out;
    203230        usbhc_iface_transfer_in_t interrupt_in;
  • uspace/lib/usb/include/usb/pipes.h

    rdeb4ba7 r92b41f33  
    131131int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    132132    size_t, uint8_t *, size_t, usb_device_connection_t *);
    133 
     133int usb_endpoint_pipe_register(usb_endpoint_pipe_t *, unsigned int,
     134    usb_hc_connection_t *);
     135int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *, usb_hc_connection_t *);
    134136
    135137int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *);
  • uspace/lib/usb/src/devdrv.c

    rdeb4ba7 r92b41f33  
    155155        }
    156156
     157        /* Register the endpoints. */
     158        usb_hc_connection_t hc_conn;
     159        rc = usb_hc_connection_initialize_from_device(&hc_conn, dev->ddf_dev);
     160        if (rc != EOK) {
     161                usb_log_error(
     162                    "Failed initializing connection to host controller: %s.\n",
     163                    str_error(rc));
     164                goto rollback;
     165        }
     166        rc = usb_hc_connection_open(&hc_conn);
     167        if (rc != EOK) {
     168                usb_log_error("Failed to connect to host controller: %s.\n",
     169                    str_error(rc));
     170                goto rollback;
     171        }
     172        for (i = 0; i < pipe_count; i++) {
     173                if (dev->pipes[i].present) {
     174                        rc = usb_endpoint_pipe_register(dev->pipes[i].pipe,
     175                            dev->pipes[i].descriptor->poll_interval,
     176                            &hc_conn);
     177                        /* Ignore error when operation not supported by HC. */
     178                        if ((rc != EOK) && (rc != ENOTSUP)) {
     179                                /* FIXME: what shall we do? */
     180                                dev->pipes[i].present = false;
     181                                free(dev->pipes[i].pipe);
     182                                dev->pipes[i].pipe = NULL;
     183                        }
     184                }
     185        }
     186        /* Ignoring errors here. */
     187        usb_hc_connection_close(&hc_conn);
     188
    157189        return EOK;
    158190
  • uspace/lib/usb/src/pipesinit.c

    rdeb4ba7 r92b41f33  
    3838#include <usb/dp.h>
    3939#include <usb/request.h>
     40#include <usbhc_iface.h>
    4041#include <errno.h>
    4142#include <assert.h>
     
    393394}
    394395
     396/** Register endpoint with the host controller.
     397 *
     398 * @param pipe Pipe to be registered.
     399 * @param interval Polling interval.
     400 * @param hc_connection Connection to the host controller (must be opened).
     401 * @return Error code.
     402 */
     403int usb_endpoint_pipe_register(usb_endpoint_pipe_t *pipe,
     404    unsigned int interval,
     405    usb_hc_connection_t *hc_connection)
     406{
     407        assert(pipe);
     408        assert(hc_connection);
     409
     410        if (!usb_hc_connection_is_opened(hc_connection)) {
     411                return EBADF;
     412        }
     413
     414#define _PACK(high, low) ((high) * 256 + (low))
     415
     416        return async_req_5_0(hc_connection->hc_phone,
     417            DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_REGISTER_ENDPOINT,
     418            _PACK(pipe->wire->address, pipe->endpoint_no),
     419            _PACK(pipe->transfer_type, pipe->direction),
     420            pipe->max_packet_size, interval);
     421
     422#undef _PACK
     423}
     424
     425/** Revert endpoint registration with the host controller.
     426 *
     427 * @param pipe Pipe to be unregistered.
     428 * @param hc_connection Connection to the host controller (must be opened).
     429 * @return Error code.
     430 */
     431int usb_endpoint_pipe_unregister(usb_endpoint_pipe_t *pipe,
     432    usb_hc_connection_t *hc_connection)
     433{
     434        assert(pipe);
     435        assert(hc_connection);
     436
     437        if (!usb_hc_connection_is_opened(hc_connection)) {
     438                return EBADF;
     439        }
     440
     441        return async_req_4_0(hc_connection->hc_phone,
     442            DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_UNREGISTER_ENDPOINT,
     443            pipe->wire->address, pipe->endpoint_no, pipe->direction);
     444}
     445
    395446/**
    396447 * @}
Note: See TracChangeset for help on using the changeset viewer.