Changeset 41e645c in mainline for uspace/lib/usb/src/pipes.c


Ignore:
Timestamp:
2011-02-20T21:43:50Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
070f11e, ace12560
Parents:
423e8c81 (diff), 063ead6f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Add simple USB multi interface device driver

The MID driver serves as a mini bus driver for devices with several
interfaces or for devices with classes defined at interface level.

The keyboard driver is working with this driver with the same problems
as before introduction of USB MID driver.

The merge also includes addition of bulk transfers.

File:
1 edited

Legend:

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

    r423e8c81 r41e645c  
    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
     
    5758
    5859        return (usb_address_t) address;
     60}
     61
     62/** Tell USB interface assigned to given device.
     63 *
     64 * @param device Device in question.
     65 * @return Interface number (negative code means any).
     66 */
     67int usb_device_get_assigned_interface(device_t *device)
     68{
     69        int parent_phone = devman_parent_device_connect(device->handle,
     70            IPC_FLAG_BLOCKING);
     71        if (parent_phone < 0) {
     72                return -1;
     73        }
     74
     75        sysarg_t iface_no;
     76        int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     77            IPC_M_USB_GET_INTERFACE,
     78            device->handle, &iface_no);
     79
     80        async_hangup(parent_phone);
     81
     82        if (rc != EOK) {
     83                return -1;
     84        }
     85
     86        return (int) iface_no;
    5987}
    6088
     
    80108        }
    81109
    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);
     110        int parent_phone = devman_parent_device_connect(device->handle,
     111            IPC_FLAG_BLOCKING);
     112        if (parent_phone < 0) {
     113                return parent_phone;
     114        }
     115
     116        my_address = get_my_address(parent_phone, device);
    88117        if (my_address < 0) {
    89118                rc = my_address;
     
    95124
    96125leave:
    97         async_hangup(hc_phone);
     126        async_hangup(parent_phone);
    98127        return rc;
    99128}
Note: See TracChangeset for help on using the changeset viewer.