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

Changeset 84439d7 in mainline for uspace/lib/usb/src/usbdrv.c


Ignore:
Timestamp:
2010-12-05T09:34:46Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
75732da
Parents:
56b962d (diff), 35537a7 (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:

Merge with development/

File:
1 edited

Legend:

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

    r56b962d r84439d7  
    5555/** Connect to host controller the device is physically attached to.
    5656 *
    57  * @param handle Device handle.
     57 * @param dev Device asking for connection.
    5858 * @param flags Connection flags (blocking connection).
    5959 * @return Phone to corresponding HC or error code.
     
    6464         * Call parent hub to obtain device handle of respective HC.
    6565         */
    66         return ENOTSUP;
     66
     67        /*
     68         * FIXME: currently we connect always to virtual host controller.
     69         */
     70        int rc;
     71        devman_handle_t handle;
     72
     73        rc = devman_device_get_handle("/vhc", &handle, 0);
     74        if (rc != EOK) {
     75                return rc;
     76        }
     77       
     78        int phone = devman_device_connect(handle, 0);
     79
     80        return phone;
    6781}
    6882
     
    7589usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
    7690{
    77         return ENOTSUP;
     91        ipcarg_t address;
     92        int rc = async_req_1_1(phone, IPC_M_USBHC_GET_ADDRESS,
     93            dev->handle, &address);
     94
     95        if (rc != EOK) {
     96                return rc;
     97        }
     98
     99        return (usb_address_t) address;
     100}
     101
     102/** Tell HC to reserve default address.
     103 *
     104 * @param phone Open phone to host controller driver.
     105 * @return Error code.
     106 */
     107int usb_drv_reserve_default_address(int phone)
     108{
     109        return async_req_0_0(phone, IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS);
     110}
     111
     112/** Tell HC to release default address.
     113 *
     114 * @param phone Open phone to host controller driver.
     115 * @return Error code.
     116 */
     117int usb_drv_release_default_address(int phone)
     118{
     119        return async_req_0_0(phone, IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);
     120}
     121
     122/** Ask HC for free address assignment.
     123 *
     124 * @param phone Open phone to host controller driver.
     125 * @return Assigned USB address or negative error code.
     126 */
     127usb_address_t usb_drv_request_address(int phone)
     128{
     129        ipcarg_t address;
     130        int rc = async_req_0_1(phone, IPC_M_USBHC_REQUEST_ADDRESS, &address);
     131        if (rc != EOK) {
     132                return rc;
     133        } else {
     134                return (usb_address_t) address;
     135        }
     136}
     137
     138/** Inform HC about binding address with devman handle.
     139 *
     140 * @param phone Open phone to host controller driver.
     141 * @param address Address to be binded.
     142 * @param handle Devman handle of the device.
     143 * @return Error code.
     144 */
     145int usb_drv_bind_address(int phone, usb_address_t address,
     146    devman_handle_t handle)
     147{
     148        int rc = async_req_2_0(phone, IPC_M_USBHC_BIND_ADDRESS,
     149            address, handle);
     150
     151        return rc;
     152}
     153
     154/** Inform HC about address release.
     155 *
     156 * @param phone Open phone to host controller driver.
     157 * @param address Address to be released.
     158 * @return Error code.
     159 */
     160int usb_drv_release_address(int phone, usb_address_t address)
     161{
     162        return async_req_1_0(phone, IPC_M_USBHC_RELEASE_ADDRESS, address);
    78163}
    79164
     
    323408}
    324409
     410/** Start control write transfer. */
     411int usb_drv_async_control_write_setup(int phone, usb_target_t target,
     412    void *buffer, size_t size,
     413    usb_handle_t *handle)
     414{
     415        return async_send_buffer(phone,
     416            IPC_M_USBHC_CONTROL_WRITE_SETUP,
     417            target,
     418            buffer, size,
     419            handle);
     420}
     421
     422/** Send data during control write transfer. */
     423int usb_drv_async_control_write_data(int phone, usb_target_t target,
     424    void *buffer, size_t size,
     425    usb_handle_t *handle)
     426{
     427        return async_send_buffer(phone,
     428            IPC_M_USBHC_CONTROL_WRITE_DATA,
     429            target,
     430            buffer, size,
     431            handle);
     432}
     433
     434/** Finalize control write transfer. */
     435int usb_drv_async_control_write_status(int phone, usb_target_t target,
     436    usb_handle_t *handle)
     437{
     438        return async_recv_buffer(phone,
     439            IPC_M_USBHC_CONTROL_WRITE_STATUS,
     440            target,
     441            NULL, 0, NULL,
     442            handle);
     443}
     444
     445/** Start control read transfer. */
     446int usb_drv_async_control_read_setup(int phone, usb_target_t target,
     447    void *buffer, size_t size,
     448    usb_handle_t *handle)
     449{
     450        return async_send_buffer(phone,
     451            IPC_M_USBHC_CONTROL_READ_SETUP,
     452            target,
     453            buffer, size,
     454            handle);
     455}
     456
     457/** Read data during control read transfer. */
     458int usb_drv_async_control_read_data(int phone, usb_target_t target,
     459    void *buffer, size_t size, size_t *actual_size,
     460    usb_handle_t *handle)
     461{
     462        return async_recv_buffer(phone,
     463            IPC_M_USBHC_CONTROL_READ_DATA,
     464            target,
     465            buffer, size, actual_size,
     466            handle);
     467}
     468
     469/** Finalize control read transfer. */
     470int usb_drv_async_control_read_status(int phone, usb_target_t target,
     471    usb_handle_t *handle)
     472{
     473        return async_send_buffer(phone,
     474            IPC_M_USBHC_CONTROL_READ_STATUS,
     475            target,
     476            NULL, 0,
     477            handle);
     478}
     479
    325480/**
    326481 * @}
Note: See TracChangeset for help on using the changeset viewer.