Changeset 357a302 in mainline for uspace/lib/usb/src


Ignore:
Timestamp:
2011-02-20T14:17:40Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b68b279
Parents:
3ae93a8
Message:

USB interfaces reorganization

The most important change is that getting USB address of a device
is an operation of generic USB interface, not USB-HC interface.
That is needed for proper functionality of a MID driver.

Also added sample implementation of USB interface operations as is
needed by most drivers (sample does not mean unfunctional or partially
implemented here).
They are stored in libusb/ddfiface.h

Updated UHCI, UHCI-RH, hub, VHC drivers to use these sample
implementations.

Updated libusb device recognition routines to route get_address requests
through USB interface.

Location:
uspace/lib/usb/src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/hub.c

    r3ae93a8 r357a302  
    301301}
    302302
    303 
    304303/**
    305304 * @}
  • uspace/lib/usb/src/pipes.c

    r3ae93a8 r357a302  
    3636#include <usb/pipes.h>
    3737#include <usbhc_iface.h>
     38#include <usb_iface.h>
    3839#include <errno.h>
    3940#include <assert.h>
     
    4142/** Tell USB address assigned to given device.
    4243 *
    43  * @param phone Phone to my HC.
     44 * @param phone Phone to parent device.
    4445 * @param dev Device in question.
    4546 * @return USB address or error code.
     
    4849{
    4950        sysarg_t address;
    50         int rc = async_req_2_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
    51             IPC_M_USBHC_GET_ADDRESS,
     51        int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE),
     52            IPC_M_USB_GET_ADDRESS,
    5253            dev->handle, &address);
    5354
     
    8081        }
    8182
    82         int hc_phone = devman_device_connect(hc_handle, 0);
    83         if (hc_phone < 0) {
    84                 return hc_phone;
    85         }
    86 
    87         my_address = get_my_address(hc_phone, device);
     83        int parent_phone = devman_parent_device_connect(device->handle,
     84            IPC_FLAG_BLOCKING);
     85        if (parent_phone < 0) {
     86                return parent_phone;
     87        }
     88
     89        my_address = get_my_address(parent_phone, device);
    8890        if (my_address < 0) {
    8991                rc = my_address;
     
    9597
    9698leave:
    97         async_hangup(hc_phone);
     99        async_hangup(parent_phone);
    98100        return rc;
    99101}
  • uspace/lib/usb/src/recognise.c

    r3ae93a8 r357a302  
    3434 */
    3535#include <sys/types.h>
    36 #include <usb_iface.h>
    3736#include <usb/usbdrv.h>
    3837#include <usb/pipes.h>
    3938#include <usb/recognise.h>
     39#include <usb/ddfiface.h>
    4040#include <usb/request.h>
    4141#include <usb/classes/classes.h>
     
    4646static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
    4747
    48 /** Callback for getting host controller handle.
    49  *
    50  * @param dev Device in question.
    51  * @param[out] handle Devman handle of the host controller.
    52  * @return Error code.
    53  */
    54 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
    55 {
    56         assert(dev);
    57         assert(dev->parent != NULL);
    58 
    59         device_t *parent = dev->parent;
    60 
    61         if (parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    62                 usb_iface_t *usb_iface
    63                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    64                 assert(usb_iface != NULL);
    65                 if (usb_iface->get_hc_handle) {
    66                         int rc = usb_iface->get_hc_handle(parent, handle);
    67                         return rc;
    68                 }
    69         }
    70 
    71         return ENOTSUP;
    72 }
    73 
    74 static usb_iface_t usb_iface = {
    75         .get_hc_handle = usb_iface_get_hc_handle
    76 };
    77 
    7848device_ops_t child_ops = {
    79         .interfaces[USB_DEV_IFACE] = &usb_iface
     49        .interfaces[USB_DEV_IFACE] = &usb_iface_hub_child_impl
    8050};
    8151
Note: See TracChangeset for help on using the changeset viewer.