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

Changeset 56bd6f11 in mainline


Ignore:
Timestamp:
2013-01-07T16:38:17Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
c8c758d
Parents:
e938fa6
Message:

libusbhost: Implement new usb interface functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/ddf_helpers.c

    re938fa6 r56bd6f11  
    7777} usb_dev_t;
    7878
     79static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
     80{
     81        assert(fun);
     82        hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
     83        usb_dev_t *dev = ddf_fun_data_get(fun);
     84        assert(hcd);
     85        assert(dev);
     86
     87        usb_log_debug("Device %d requested default address at %s speed\n",
     88            dev->address, usb_str_speed(speed));
     89        return hcd_reserve_default_address(hcd, speed);
     90}
     91
     92static int release_default_address(ddf_fun_t *fun)
     93{
     94        assert(fun);
     95        hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
     96        usb_dev_t *dev = ddf_fun_data_get(fun);
     97        assert(hcd);
     98        assert(dev);
     99
     100        usb_log_debug("Device %d released default address\n", dev->address);
     101        return hcd_release_default_address(hcd);
     102}
     103
     104static int device_enumerate(ddf_fun_t *fun, usb_device_handle_t *handle)
     105{
     106        assert(fun);
     107        ddf_dev_t *ddf_dev = ddf_fun_get_dev(fun);
     108        usb_dev_t *dev = ddf_fun_data_get(fun);
     109        assert(ddf_dev);
     110        assert(dev);
     111        usb_address_t address;
     112        usb_log_debug("Device %d reported a new USB device\n", dev->address);
     113        const int ret = hcd_ddf_new_device(ddf_dev, &address);
     114        if (ret == EOK && handle)
     115                *handle = address;
     116        return ret;
     117}
     118
     119static int device_remove(ddf_fun_t *fun, usb_device_handle_t handle)
     120{
     121        assert(fun);
     122        ddf_dev_t *ddf_dev = ddf_fun_get_dev(fun);
     123        usb_dev_t *dev = ddf_fun_data_get(fun);
     124        assert(ddf_dev);
     125        assert(dev);
     126        usb_log_debug("Device %d reported removal of device %d\n",
     127            dev->address, (int)handle);
     128        return hcd_ddf_remove_device(ddf_dev, (usb_address_t)handle);
     129}
     130
    79131/** Get USB address assigned to root hub.
    80132 *
     
    114166        .get_hc_handle = get_hc_handle,
    115167        .get_my_address = get_my_address,
     168
     169        .reserve_default_address = reserve_default_address,
     170        .release_default_address = release_default_address,
     171        .device_enumerate = device_enumerate,
     172        .device_remove = device_remove,
    116173};
    117174/** Standard USB RH options (RH interface) */
Note: See TracChangeset for help on using the changeset viewer.