Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmouse/init.c

    rbc1c6fb r489c3e7  
    4242
    4343/** Mouse polling endpoint description for boot protocol subclass. */
    44 static usb_endpoint_description_t poll_endpoint_description = {
     44usb_endpoint_description_t poll_endpoint_description = {
    4545        .transfer_type = USB_TRANSFER_INTERRUPT,
    4646        .direction = USB_DIRECTION_IN,
     
    5050        .flags = 0
    5151};
    52 
    53 /** Initialize poll pipe.
    54  *
    55  * Expects that session is already started on control pipe zero.
    56  *
    57  * @param mouse Mouse device.
    58  * @param my_interface Interface number.
    59  * @return Error code.
    60  */
    61 static int intialize_poll_pipe(usb_mouse_t *mouse, int my_interface)
    62 {
    63         assert(usb_endpoint_pipe_is_session_started(&mouse->ctrl_pipe));
    64 
    65         int rc;
    66 
    67         void *config_descriptor;
    68         size_t config_descriptor_size;
    69 
    70         rc = usb_request_get_full_configuration_descriptor_alloc(
    71             &mouse->ctrl_pipe, 0, &config_descriptor, &config_descriptor_size);
    72         if (rc != EOK) {
    73                 return rc;
    74         }
    75 
    76         usb_endpoint_mapping_t endpoint_mapping[1] = {
    77                 {
    78                         .pipe = &mouse->poll_pipe,
    79                         .description = &poll_endpoint_description,
    80                         .interface_no = my_interface
    81                 }
    82         };
    83 
    84         rc = usb_endpoint_pipe_initialize_from_configuration(endpoint_mapping,
    85             1, config_descriptor, config_descriptor_size, &mouse->wire);
    86         if (rc != EOK) {
    87                 return rc;
    88         }
    89 
    90         if (!endpoint_mapping[0].present) {
    91                 return ENOENT;
    92         }
    93 
    94         mouse->poll_interval_us = 1000 * endpoint_mapping[0].descriptor->poll_interval;
    95 
    96         usb_log_debug("prepared polling endpoint %d (interval %zu).\n",
    97             mouse->poll_pipe.endpoint_no, mouse->poll_interval_us);
    98 
    99         return EOK;
    100 }
    10152
    10253static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
     
    14394 * @return Error code.
    14495 */
    145 int usb_mouse_create(ddf_dev_t *dev)
     96int usb_mouse_create(usb_device_t *dev)
    14697{
    14798        usb_mouse_t *mouse = malloc(sizeof(usb_mouse_t));
     
    149100                return ENOMEM;
    150101        }
    151         mouse->device = dev;
     102        mouse->dev = dev;
    152103        mouse->console_phone = -1;
    153104
    154105        int rc;
    155106
    156         /* Initialize the backing connection. */
    157         rc = usb_device_connection_initialize_from_device(&mouse->wire, dev);
    158         if (rc != EOK) {
    159                 goto leave;
    160         }
    161 
    162         /* Initialize the default control pipe. */
    163         rc = usb_endpoint_pipe_initialize_default_control(&mouse->ctrl_pipe,
    164             &mouse->wire);
    165         if (rc != EOK) {
    166                 goto leave;
    167         }
    168 
    169         rc = usb_endpoint_pipe_start_session(&mouse->ctrl_pipe);
    170         if (rc != EOK) {
    171                 goto leave;
    172         }
    173 
    174         rc = intialize_poll_pipe(mouse, usb_device_get_assigned_interface(dev));
    175 
    176         /* We can ignore error here. */
    177         usb_endpoint_pipe_end_session(&mouse->ctrl_pipe);
    178 
    179         if (rc != EOK) {
    180                 goto leave;
    181         }
    182 
    183107        /* Create DDF function. */
    184         mouse->mouse_fun = ddf_fun_create(dev, fun_exposed, "mouse");
     108        mouse->mouse_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "mouse");
    185109        if (mouse->mouse_fun == NULL) {
    186110                rc = ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.