Changeset 72af8da in mainline for uspace/drv/usbmouse/init.c
- Timestamp:
- 2011-03-16T18:50:17Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42a3a57
- Parents:
- 3e7b7cd (diff), fcf07e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/init.c
r3e7b7cd r72af8da 42 42 43 43 /** Mouse polling endpoint description for boot protocol subclass. */ 44 staticusb_endpoint_description_t poll_endpoint_description = {44 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_interface81 }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 102 53 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 54 /** Device ops for USB mouse. */ 103 55 static ddf_dev_ops_t mouse_ops = { 104 56 .default_handler = default_connection_handler … … 107 59 /** Default handler for IPC methods not handled by DDF. 108 60 * 109 * @param dev Devicehandling the call.61 * @param fun Device function handling the call. 110 62 * @param icallid Call id. 111 63 * @param icall Call data. … … 135 87 } 136 88 137 138 int usb_mouse_create(ddf_dev_t *dev) 89 /** Create USB mouse device. 90 * 91 * The mouse device is stored into <code>dev->driver_data</code>. 92 * 93 * @param dev Generic device. 94 * @return Error code. 95 */ 96 int usb_mouse_create(usb_device_t *dev) 139 97 { 140 98 usb_mouse_t *mouse = malloc(sizeof(usb_mouse_t)); … … 142 100 return ENOMEM; 143 101 } 144 mouse->dev ice= dev;102 mouse->dev = dev; 145 103 mouse->console_phone = -1; 146 104 147 105 int rc; 148 106 149 /* Initialize the backing connection. */150 rc = usb_device_connection_initialize_from_device(&mouse->wire, dev);151 if (rc != EOK) {152 goto leave;153 }154 155 /* Initialize the default control pipe. */156 rc = usb_endpoint_pipe_initialize_default_control(&mouse->ctrl_pipe,157 &mouse->wire);158 if (rc != EOK) {159 goto leave;160 }161 162 rc = usb_endpoint_pipe_start_session(&mouse->ctrl_pipe);163 if (rc != EOK) {164 goto leave;165 }166 167 rc = intialize_poll_pipe(mouse, usb_device_get_assigned_interface(dev));168 169 /* We can ignore error here. */170 usb_endpoint_pipe_end_session(&mouse->ctrl_pipe);171 172 if (rc != EOK) {173 goto leave;174 }175 176 107 /* Create DDF function. */ 177 mouse->mouse_fun = ddf_fun_create(dev , fun_exposed, "mouse");108 mouse->mouse_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "mouse"); 178 109 if (mouse->mouse_fun == NULL) { 179 110 rc = ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.