Changeset bb70637 in mainline for uspace/drv/bus
- Timestamp:
- 2013-01-26T23:35:12Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 35bc430
- Parents:
- 3e23316
- Location:
- uspace/drv/bus/usb
- Files:
- 
      - 6 edited
 
 - 
          
  usbhid/main.c (modified) (1 diff)
- 
          
  usbhid/usbhid.c (modified) (7 diffs)
- 
          
  usbhid/usbhid.h (modified) (2 diffs)
- 
          
  usbhub/main.c (modified) (1 diff)
- 
          
  usbhub/usbhub.c (modified) (2 diffs)
- 
          
  usbhub/usbhub.h (modified) (1 diff)
 
Legend:
- Unmodified
- Added
- Removed
- 
      uspace/drv/bus/usb/usbhid/main.cr3e23316 rbb70637 89 89 * This will create a separate fibril that will query the device 90 90 * for the data continuously. */ 91 rc = usb_device_auto_poll(dev,91 rc = usb_device_auto_poll_desc(dev, 92 92 /* Index of the polling pipe. */ 93 hid_dev->poll_pipe_ index,93 hid_dev->poll_pipe_mapping->description, 94 94 /* Callback when data arrives. */ 95 95 usb_hid_polling_callback, 96 96 /* How much data to request. */ 97 dev->pipes[hid_dev->poll_pipe_index].pipe.max_packet_size,97 hid_dev->poll_pipe_mapping->pipe.max_packet_size, 98 98 /* Delay */ 99 0,99 -1, 100 100 /* Callback when the polling ends. */ 101 101 usb_hid_polling_ended_callback, 
- 
      uspace/drv/bus/usb/usbhid/usbhid.cr3e23316 rbb70637 41 41 #include <usb/hid/hidreport.h> 42 42 #include <usb/hid/request.h> 43 43 44 #include <errno.h> 45 #include <macros.h> 44 46 #include <str_error.h> 45 47 … … 265 267 } 266 268 267 static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, constusb_device_t *dev)269 static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, usb_device_t *dev) 268 270 { 269 271 assert(hid_dev); … … 271 273 272 274 static const struct { 273 unsigned ep_number;275 const usb_endpoint_description_t *desc; 274 276 const char* description; 275 277 } endpoints[] = { 276 { USB_HID_KBD_POLL_EP_NO, "Keyboard endpoint"},277 { USB_HID_MOUSE_POLL_EP_NO, "Mouse endpoint"},278 { USB_HID_GENERIC_POLL_EP_NO, "Generic HID endpoint"},278 {&usb_hid_kbd_poll_endpoint_description, "Keyboard endpoint"}, 279 {&usb_hid_mouse_poll_endpoint_description, "Mouse endpoint"}, 280 {&usb_hid_generic_poll_endpoint_description, "Generic HID endpoint"}, 279 281 }; 280 282 281 for (unsigned i = 0; i < sizeof(endpoints)/sizeof(endpoints[0]); ++i) { 282 if (endpoints[i].ep_number >= dev->pipes_count) { 283 return EINVAL; 284 } 285 if (dev->pipes[endpoints[i].ep_number].present) { 283 for (unsigned i = 0; i < ARRAY_SIZE(endpoints); ++i) { 284 usb_endpoint_mapping_t *epm = 285 usb_device_get_mapped_ep_desc(dev, endpoints[i].desc); 286 if (epm && epm->present) { 286 287 usb_log_debug("Found: %s.\n", endpoints[i].description); 287 hid_dev->poll_pipe_ index = endpoints[i].ep_number;288 hid_dev->poll_pipe_mapping = epm; 288 289 return EOK; 289 290 } … … 352 353 /* The USB device should already be initialized, save it in structure */ 353 354 hid_dev->usb_dev = dev; 354 hid_dev->poll_pipe_ index = -1;355 hid_dev->poll_pipe_mapping = NULL; 355 356 356 357 int rc = usb_hid_check_pipes(hid_dev, dev); … … 382 383 "boot protocol.\n"); 383 384 384 switch (hid_dev->poll_pipe_ index) {385 case USB_HID_ KBD_POLL_EP_NO:385 switch (hid_dev->poll_pipe_mapping->interface->interface_protocol) { 386 case USB_HID_PROTOCOL_KEYBOARD: 386 387 usb_log_info("Falling back to kbd boot protocol.\n"); 387 388 rc = usb_kbd_set_boot_protocol(hid_dev); … … 390 391 } 391 392 break; 392 case USB_HID_ MOUSE_POLL_EP_NO:393 case USB_HID_PROTOCOL_MOUSE: 393 394 usb_log_info("Falling back to mouse boot protocol.\n"); 394 395 rc = usb_mouse_set_boot_protocol(hid_dev); … … 398 399 break; 399 400 default: 400 assert(hid_dev->poll_pipe_index401 == USB_HID_GENERIC_POLL_EP_NO);402 401 usb_log_info("Falling back to generic HID driver.\n"); 403 402 usb_hid_set_generic_hid_subdriver(hid_dev); 
- 
      uspace/drv/bus/usb/usbhid/usbhid.hr3e23316 rbb70637 103 103 usb_device_t *usb_dev; 104 104 105 /** Index of the polling pipe in usb_hid_endpoints array. */106 u nsigned poll_pipe_index;105 /** Endpont mapping of the polling pipe. */ 106 usb_endpoint_mapping_t *poll_pipe_mapping; 107 107 108 108 /** Subdrivers. */ … … 132 132 }; 133 133 134 135 136 enum {137 USB_HID_KBD_POLL_EP_NO = 0,138 USB_HID_MOUSE_POLL_EP_NO = 1,139 USB_HID_GENERIC_POLL_EP_NO = 2,140 USB_HID_POLL_EP_COUNT = 3141 };142 143 134 extern const usb_endpoint_description_t *usb_hid_endpoints[]; 144 145 146 135 147 136 int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev); 
- 
      uspace/drv/bus/usb/usbhub/main.cr3e23316 rbb70637 43 43 #include "usbhub.h" 44 44 45 /** Hub status-change endpoint description.46 *47 * For more information see section 11.15.1 of USB 1.1 specification.48 */49 static const usb_endpoint_description_t hub_status_change_endpoint_description =50 {51 .transfer_type = USB_TRANSFER_INTERRUPT,52 .direction = USB_DIRECTION_IN,53 .interface_class = USB_CLASS_HUB,54 .interface_subclass = 0,55 .interface_protocol = 0,56 .flags = 057 };58 45 59 46 /** USB hub driver operations. */ 
- 
      uspace/drv/bus/usb/usbhub/usbhub.cr3e23316 rbb70637 57 57 58 58 #define HUB_FNC_NAME "hub" 59 /** Hub status-change endpoint description. 60 * 61 * For more information see section 11.15.1 of USB 1.1 specification. 62 */ 63 const usb_endpoint_description_t hub_status_change_endpoint_description = 64 { 65 .transfer_type = USB_TRANSFER_INTERRUPT, 66 .direction = USB_DIRECTION_IN, 67 .interface_class = USB_CLASS_HUB, 68 .interface_subclass = 0, 69 .interface_protocol = 0, 70 .flags = 0 71 }; 59 72 60 73 /** Standard get hub global status request */ … … 147 160 148 161 /* Start hub operation. */ 149 opResult = usb_device_auto_poll(hub_dev->usb_device, 0, 162 opResult = usb_device_auto_poll_desc(hub_dev->usb_device, 163 &hub_status_change_endpoint_description, 150 164 hub_port_changes_callback, ((hub_dev->port_count + 1 + 7) / 8), 151 255000, 152 usb_hub_polling_terminated_callback, hub_dev); 165 -1, usb_hub_polling_terminated_callback, hub_dev); 153 166 if (opResult != EOK) { 154 167 usb_pipe_end_long_transfer(control_pipe); 
- 
      uspace/drv/bus/usb/usbhub/usbhub.hr3e23316 rbb70637 80 80 }; 81 81 82 extern const usb_endpoint_description_t hub_status_change_endpoint_description; 83 82 84 int usb_hub_device_add(usb_device_t *usb_dev); 83 85 int usb_hub_device_remove(usb_device_t *usb_dev); 
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  
