Changes in uspace/drv/bus/usb/usbhid/usbhid.c [e2dfa86:ad22fa4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/usbhid.c
re2dfa86 rad22fa4 41 41 #include <usb/hid/hidreport.h> 42 42 #include <usb/hid/request.h> 43 44 43 #include <errno.h> 45 #include <macros.h>46 44 #include <str_error.h> 47 45 … … 116 114 const usb_hid_subdriver_mapping_t *mapping) 117 115 { 118 assert(hid_dev); 119 assert(hid_dev->usb_dev); 120 assert(mapping); 121 const usb_standard_device_descriptor_t *d = 122 &usb_device_descriptors(hid_dev->usb_dev)->device; 123 124 return (d->vendor_id == mapping->vendor_id) 125 && (d->product_id == mapping->product_id); 116 assert(hid_dev != NULL); 117 assert(hid_dev->usb_dev != NULL); 118 119 return (hid_dev->usb_dev->descriptors.device.vendor_id 120 == mapping->vendor_id 121 && hid_dev->usb_dev->descriptors.device.product_id 122 == mapping->product_id); 126 123 } 127 124 … … 267 264 } 268 265 269 static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, usb_device_t *dev)266 static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, const usb_device_t *dev) 270 267 { 271 268 assert(hid_dev); … … 273 270 274 271 static const struct { 275 const usb_endpoint_description_t *desc;272 unsigned ep_number; 276 273 const char* description; 277 274 } endpoints[] = { 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"},275 {USB_HID_KBD_POLL_EP_NO, "Keyboard endpoint"}, 276 {USB_HID_MOUSE_POLL_EP_NO, "Mouse endpoint"}, 277 {USB_HID_GENERIC_POLL_EP_NO, "Generic HID endpoint"}, 281 278 }; 282 279 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) { 280 for (unsigned i = 0; i < sizeof(endpoints)/sizeof(endpoints[0]); ++i) { 281 if (endpoints[i].ep_number >= dev->pipes_count) { 282 return EINVAL; 283 } 284 if (dev->pipes[endpoints[i].ep_number].present) { 287 285 usb_log_debug("Found: %s.\n", endpoints[i].description); 288 hid_dev->poll_pipe_ mapping = epm;286 hid_dev->poll_pipe_index = endpoints[i].ep_number; 289 287 return EOK; 290 288 } … … 353 351 /* The USB device should already be initialized, save it in structure */ 354 352 hid_dev->usb_dev = dev; 355 hid_dev->poll_pipe_ mapping = NULL;353 hid_dev->poll_pipe_index = -1; 356 354 357 355 int rc = usb_hid_check_pipes(hid_dev, dev); … … 383 381 "boot protocol.\n"); 384 382 385 switch (hid_dev->poll_pipe_ mapping->interface->interface_protocol) {386 case USB_HID_ PROTOCOL_KEYBOARD:383 switch (hid_dev->poll_pipe_index) { 384 case USB_HID_KBD_POLL_EP_NO: 387 385 usb_log_info("Falling back to kbd boot protocol.\n"); 388 386 rc = usb_kbd_set_boot_protocol(hid_dev); … … 391 389 } 392 390 break; 393 case USB_HID_ PROTOCOL_MOUSE:391 case USB_HID_MOUSE_POLL_EP_NO: 394 392 usb_log_info("Falling back to mouse boot protocol.\n"); 395 393 rc = usb_mouse_set_boot_protocol(hid_dev); … … 399 397 break; 400 398 default: 399 assert(hid_dev->poll_pipe_index 400 == USB_HID_GENERIC_POLL_EP_NO); 401 401 usb_log_info("Falling back to generic HID driver.\n"); 402 402 usb_hid_set_generic_hid_subdriver(hid_dev); … … 415 415 } 416 416 417 /* 418 * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da 419 * do nej. 420 * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi 421 * vyplnenu strukturu usbhid_iface_t. 422 * 3) klientska aplikacia - musi si rucne vytvorit telefon 423 * (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az 424 * k tej fcii. 425 * pouzit usb/classes/hid/iface.h - prvy int je telefon 426 */ 417 /* Initialize subdrivers */ 427 418 bool ok = false; 428 419 for (unsigned i = 0; i < hid_dev->subdriver_count; ++i) { … … 485 476 &hid_dev->report, buffer, buffer_size, &hid_dev->report_id); 486 477 if (rc != EOK) { 487 usb_log_warning(" Failurein usb_hid_parse_report():"478 usb_log_warning("Error in usb_hid_parse_report():" 488 479 "%s\n", str_error(rc)); 489 480 }
Note:
See TracChangeset
for help on using the changeset viewer.