Changes in uspace/drv/usbmouse/init.c [489c3e7:bc1c6fb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/init.c
r489c3e7 rbc1c6fb 42 42 43 43 /** Mouse polling endpoint description for boot protocol subclass. */ 44 usb_endpoint_description_t poll_endpoint_description = {44 static usb_endpoint_description_t poll_endpoint_description = { 45 45 .transfer_type = USB_TRANSFER_INTERRUPT, 46 46 .direction = USB_DIRECTION_IN, … … 51 51 }; 52 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 } 101 53 102 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 54 103 /** Device ops for USB mouse. */ … … 94 143 * @return Error code. 95 144 */ 96 int usb_mouse_create( usb_device_t *dev)145 int usb_mouse_create(ddf_dev_t *dev) 97 146 { 98 147 usb_mouse_t *mouse = malloc(sizeof(usb_mouse_t)); … … 100 149 return ENOMEM; 101 150 } 102 mouse->dev = dev;151 mouse->device = dev; 103 152 mouse->console_phone = -1; 104 153 105 154 int rc; 106 155 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 107 183 /* Create DDF function. */ 108 mouse->mouse_fun = ddf_fun_create(dev ->ddf_dev, fun_exposed, "mouse");184 mouse->mouse_fun = ddf_fun_create(dev, fun_exposed, "mouse"); 109 185 if (mouse->mouse_fun == NULL) { 110 186 rc = ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.