Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2a5a7711 in mainline


Ignore:
Timestamp:
2013-02-08T16:08:51Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
603a0a4
Parents:
81da273b
Message:

libusbvirt, virthub: Allow drivers to set endpoint number and port count.

Using smaller max_packet_size reduces bandwidth requirements.

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/uhci_rh.c

    r81da273b r2a5a7711  
    7878        instance->reset_changed[1] = false;
    7979        return virthub_base_init(&instance->base, name, &ops, instance,
    80             NULL, &hub_descriptor.header);
     80            NULL, &hub_descriptor.header, HUB_STATUS_CHANGE_PIPE, 2);
    8181}
    8282
     
    376376
    377377/** UHCI root hub request handlers */
    378 static usbvirt_control_request_handler_t control_transfer_handlers[] = {
     378static const usbvirt_control_request_handler_t control_transfer_handlers[] = {
    379379        {
    380380                STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
  • uspace/lib/usbvirt/include/usbvirt/virthub_base.h

    r81da273b r2a5a7711  
    4242enum {
    4343        VIRTHUB_EXTR_DESC = 3,
    44         HUB_STATUS_CHANGE_PIPE = 1,
    4544};
    4645
    4746typedef struct {
    4847        usb_standard_configuration_descriptor_t config_descriptor;
     48        usb_standard_endpoint_descriptor_t endpoint_descriptor;
    4949        usbvirt_device_configuration_extras_t extra[VIRTHUB_EXTR_DESC];
    5050        usbvirt_device_configuration_t configuration;
     
    5959    const char *name, usbvirt_device_ops_t *ops, void *data,
    6060    const usb_standard_device_descriptor_t *device_desc,
    61     const usb_hub_descriptor_header_t *hub_desc);
     61    const usb_hub_descriptor_header_t *hub_desc,
     62    usb_endpoint_t ep, unsigned port_count);
    6263
    6364usb_address_t virthub_base_get_address(virthub_base_t *instance);
  • uspace/lib/usbvirt/src/virthub_base.c

    r81da273b r2a5a7711  
    4242extern const usb_standard_device_descriptor_t virthub_device_descriptor;
    4343extern const usb_standard_configuration_descriptor_t virthub_configuration_descriptor_without_hub_size;
     44extern const usb_standard_endpoint_descriptor_t virthub_endpoint_descriptor;
    4445extern const usbvirt_device_configuration_extras_t virthub_interface_descriptor_ex;
    45 extern const usbvirt_device_configuration_extras_t virthub_endpoint_descriptor_ex;
    4646
    4747void *virthub_get_data(usbvirt_device_t *dev)
     
    5353}
    5454
    55 int virthub_base_init(virthub_base_t *instance,
    56     const char *name, usbvirt_device_ops_t *ops, void *data,
     55int virthub_base_init(virthub_base_t *instance, const char *name,
     56    usbvirt_device_ops_t *ops, void *data,
    5757    const usb_standard_device_descriptor_t *device_desc,
    58     const usb_hub_descriptor_header_t *hub_desc)
     58    const usb_hub_descriptor_header_t *hub_desc,
     59    usb_endpoint_t ep, unsigned port_count)
    5960{
    6061        assert(instance);
    6162        assert(hub_desc);
    6263        assert(name);
     64       
     65        if (!usb_endpoint_is_valid(ep) || (ep == USB_ENDPOINT_DEFAULT_CONTROL))
     66                return EINVAL;
    6367
    6468        instance->config_descriptor =
    6569            virthub_configuration_descriptor_without_hub_size;
    6670        instance->config_descriptor.total_length += hub_desc->length;
     71
     72        instance->endpoint_descriptor = virthub_endpoint_descriptor;
     73        instance->endpoint_descriptor.endpoint_address = 128 | ep;
     74        instance->endpoint_descriptor.max_packet_size =
     75            (1 + port_count + 7) / 8;
    6776
    6877        instance->descriptors.device =
     
    7887        instance->extra[1].data = (void *)hub_desc;
    7988        instance->extra[1].length = hub_desc->length;
    80         instance->extra[2] = virthub_endpoint_descriptor_ex;
     89        instance->extra[2].data = (void*)&instance->endpoint_descriptor;
     90        instance->extra[2].length = sizeof(instance->endpoint_descriptor);
    8191
    8292        instance->device.ops = ops;
  • uspace/lib/usbvirt/src/virthub_descriptors.c

    r81da273b r2a5a7711  
    7474        .length = sizeof(usb_standard_endpoint_descriptor_t),
    7575        .descriptor_type = USB_DESCTYPE_ENDPOINT,
    76         .endpoint_address = HUB_STATUS_CHANGE_PIPE | 128,
     76        .endpoint_address = 1 | 128,
    7777        .attributes = USB_TRANSFER_INTERRUPT,
    7878        .max_packet_size = 8,
     
    101101};
    102102
    103 const usbvirt_device_configuration_extras_t virthub_endpoint_descriptor_ex = {
    104         .data = (uint8_t *) &virthub_endpoint_descriptor,
    105         .length = sizeof(virthub_endpoint_descriptor),
    106 };
    107 
    108103
    109104/**
Note: See TracChangeset for help on using the changeset viewer.