Changeset 933b0d7 in mainline


Ignore:
Timestamp:
2011-09-07T11:38:57Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d394f1b8
Parents:
7099861
Message:

USB: make bandwidth count function changeable

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r7099861 r933b0d7  
    188188        list_initialize(&instance->pending_batches);
    189189
    190         ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11);
     190        ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11,
     191            bandwidth_count_usb11);
    191192        CHECK_RET_RETURN(ret, "Failed to initialize generic driver: %s.\n",
    192193            str_error(ret));
  • uspace/drv/bus/usb/uhci/hc.c

    r7099861 r933b0d7  
    192192            "Device registers at %p (%zuB) accessible.\n", io, reg_size);
    193193
    194         ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11);
     194        ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11,
     195            bandwidth_count_usb11);
    195196        CHECK_RET_RETURN(ret, "Failed to initialize HCD generic driver: %s.\n",
    196197            str_error(ret));
  • uspace/drv/bus/usb/vhc/main.c

    r7099861 r933b0d7  
    7373        }
    7474        data->magic = 0xDEADBEEF;
    75         rc = usb_endpoint_manager_init(&data->ep_manager, (size_t) -1);
     75        rc = usb_endpoint_manager_init(&data->ep_manager, (size_t) -1,
     76            bandwidth_count_usb11);
    7677        if (rc != EOK) {
    7778                usb_log_fatal("Failed to initialize endpoint manager.\n");
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r7099861 r933b0d7  
    5353};
    5454/*----------------------------------------------------------------------------*/
    55 static inline int hcd_init(hcd_t *hcd, size_t bandwidth)
     55static inline int hcd_init(hcd_t *hcd, size_t bandwidth,
     56    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t))
    5657{
    5758        assert(hcd);
    5859        usb_device_keeper_init(&hcd->dev_manager);
    59         return usb_endpoint_manager_init(&hcd->ep_manager, bandwidth);
     60        return usb_endpoint_manager_init(&hcd->ep_manager, bandwidth, bw_count);
    6061}
    6162/*----------------------------------------------------------------------------*/
  • uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h

    r7099861 r933b0d7  
    5353        fibril_mutex_t guard;
    5454        size_t free_bw;
     55        size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t);
    5556} usb_endpoint_manager_t;
    5657
     
    5960
    6061int usb_endpoint_manager_init(usb_endpoint_manager_t *instance,
    61     size_t available_bandwidth);
     62    size_t available_bandwidth,
     63    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t));
    6264
    6365void usb_endpoint_manager_destroy(usb_endpoint_manager_t *instance);
  • uspace/lib/usbhost/src/usb_endpoint_manager.c

    r7099861 r933b0d7  
    140140/*----------------------------------------------------------------------------*/
    141141int usb_endpoint_manager_init(usb_endpoint_manager_t *instance,
    142     size_t available_bandwidth)
     142    size_t available_bandwidth,
     143    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t))
    143144{
    144145        assert(instance);
    145146        fibril_mutex_initialize(&instance->guard);
    146147        instance->free_bw = available_bandwidth;
     148        instance->bw_count = bw_count;
    147149        const bool ht =
    148150            hash_table_create(&instance->ep_table, BUCKET_COUNT, MAX_KEYS, &op);
     
    158160    endpoint_t *ep, size_t data_size)
    159161{
     162        assert(instance);
     163        assert(instance->bw_count);
    160164        assert(ep);
    161         const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
     165        const size_t bw = instance->bw_count(ep->speed, ep->transfer_type,
    162166            data_size, ep->max_packet_size);
    163         assert(instance);
    164167
    165168        fibril_mutex_lock(&instance->guard);
Note: See TracChangeset for help on using the changeset viewer.