Changeset 8d7552c in mainline
- Timestamp:
- 2015-07-04T01:24:53Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a799708
- Parents:
- d2e66bf
- Location:
- uspace/lib/usbhost
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
rd2e66bf r8d7552c 45 45 #include <device/hw_res_parsed.h> 46 46 47 typedef int (*driver_init_t)(hcd_t *, const hw_res_list_parsed_t *, bool); 48 typedef void (*driver_fini_t)(hcd_t *); 49 typedef int (*claim_t)(ddf_dev_t *); 50 typedef int (*irq_code_gen_t)(irq_code_t *, const hw_res_list_parsed_t *); 51 52 typedef struct { 53 hc_driver_t ops; 54 claim_t claim; 55 usb_speed_t hc_speed; 56 driver_init_t init; 57 driver_fini_t fini; 58 interrupt_handler_t *irq_handler; 59 irq_code_gen_t irq_code_gen; 60 const char *name; 61 } ddf_hc_driver_t; 62 63 int hcd_ddf_add_hc(ddf_dev_t *device, const ddf_hc_driver_t *driver); 64 47 65 int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed, 48 66 size_t bw, bw_count_func_t bw_count); -
uspace/lib/usbhost/src/ddf_helpers.c
rd2e66bf r8d7552c 49 49 #include <errno.h> 50 50 #include <fibril_synch.h> 51 #include <macros.h> 51 52 #include <stdio.h> 52 53 #include <stdlib.h> … … 608 609 } 609 610 611 int hcd_ddf_add_hc(ddf_dev_t *device, const ddf_hc_driver_t *driver) 612 { 613 assert(driver); 614 static const struct { size_t bw; bw_count_func_t bw_count; }bw[] = { 615 [USB_SPEED_FULL] = { .bw = BANDWIDTH_AVAILABLE_USB11, 616 .bw_count = bandwidth_count_usb11 }, 617 [USB_SPEED_HIGH] = { .bw = BANDWIDTH_AVAILABLE_USB11, 618 .bw_count = bandwidth_count_usb11 }, 619 }; 620 621 int ret = EOK; 622 const usb_speed_t speed = driver->hc_speed; 623 if (speed >= ARRAY_SIZE(bw) || bw[speed].bw == 0) { 624 usb_log_error("Driver `%s' reported unsupported speed: %s", 625 driver->name, usb_str_speed(speed)); 626 return ENOTSUP; 627 } 628 629 if (driver->claim) 630 ret = driver->claim(device); 631 if (ret != EOK) { 632 usb_log_error("Failed to claim `%s' for driver `%s'", 633 ddf_dev_get_name(device), driver->name); 634 return ret; 635 } 636 interrupt_handler_t *irq_handler = 637 driver->irq_handler ? driver->irq_handler : ddf_hcd_gen_irq_handler; 638 639 ret = ddf_hcd_device_setup_all(device, speed, bw[speed].bw, 640 bw[speed].bw_count, irq_handler, driver->irq_code_gen, 641 driver->init, driver->fini); 642 if (ret != EOK) { 643 usb_log_error("Failed to setup `%s' for driver `%s'", 644 ddf_dev_get_name(device), driver->name); 645 return ret; 646 } 647 648 usb_log_info("Controlling new `%s' device `%s'.\n", 649 driver->name, ddf_dev_get_name(device)); 650 return EOK; 651 } 652 610 653 /** Initialize hc structures. 611 654 *
Note:
See TracChangeset
for help on using the changeset viewer.