Changeset 4a7a8d4 in mainline for uspace/lib/usbdev


Ignore:
Timestamp:
2011-05-13T10:31:54Z (15 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aca3489
Parents:
05e21ffc (diff), c372e03 (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 usb/development

Location:
uspace/lib/usbdev
Files:
1 added
21 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/hub.h

    r05e21ffc r4a7a8d4  
    6363    const usb_hc_attached_device_t *);
    6464int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
     65int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
     66    devman_handle_t *);
    6567
    6668#endif
  • uspace/lib/usbdev/include/usb/request.h

    r05e21ffc r4a7a8d4  
    142142
    143143int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
     144int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
     145int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
    144146
    145147#endif
  • uspace/lib/usbdev/include/usb/usbdevice.h

    r05e21ffc r4a7a8d4  
    5050} usb_hc_connection_t;
    5151
    52 int usb_hc_find(devman_handle_t, devman_handle_t *);
    53 
    5452int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
    5553    ddf_dev_t *);
  • uspace/lib/usbdev/src/hub.c

    r05e21ffc r4a7a8d4  
    117117            DEV_IFACE_ID(USBHC_DEV_IFACE),
    118118            IPC_M_USBHC_RELEASE_ADDRESS, address);
     119}
     120
     121/** Get handle of USB device with given address.
     122 *
     123 * @param[in] connection Opened connection to host controller.
     124 * @param[in] address Address of device in question.
     125 * @param[out] handle Where to write the device handle.
     126 * @return Error code.
     127 */
     128int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
     129    usb_address_t address, devman_handle_t *handle)
     130{
     131        CHECK_CONNECTION(connection);
     132
     133        sysarg_t tmp;
     134        int rc = async_req_2_1(connection->hc_phone,
     135            DEV_IFACE_ID(USBHC_DEV_IFACE),
     136            IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
     137            address, &tmp);
     138        if ((rc == EOK) && (handle != NULL)) {
     139                *handle = tmp;
     140        }
     141
     142        return rc;
    119143}
    120144
  • uspace/lib/usbdev/src/pipes.c

    r05e21ffc r4a7a8d4  
    3636#include <usb/pipes.h>
    3737#include <usb/debug.h>
     38#include <usb/driver.h>
    3839#include <usbhc_iface.h>
    3940#include <usb_iface.h>
  • uspace/lib/usbdev/src/request.c

    r05e21ffc r4a7a8d4  
    885885}
    886886
     887/** Clear halt bit of an endpoint pipe (after pipe stall).
     888 *
     889 * @param ctrl_pipe Control pipe.
     890 * @param target_pipe Which pipe is halted and shall be cleared.
     891 * @return Error code.
     892 */
     893int usb_pipe_clear_halt(usb_pipe_t *ctrl_pipe, usb_pipe_t *target_pipe)
     894{
     895        if ((ctrl_pipe == NULL) || (target_pipe == NULL)) {
     896                return EINVAL;
     897        }
     898        return usb_request_clear_endpoint_halt(ctrl_pipe,
     899            target_pipe->endpoint_no);
     900}
     901
     902/** Get endpoint status.
     903 *
     904 * @param[in] ctrl_pipe Control pipe.
     905 * @param[in] pipe Of which pipe the status shall be received.
     906 * @param[out] status Where to store pipe status (in native endianness).
     907 * @return Error code.
     908 */
     909int usb_request_get_endpoint_status(usb_pipe_t *ctrl_pipe, usb_pipe_t *pipe,
     910    uint16_t *status)
     911{
     912        uint16_t status_tmp;
     913        uint16_t pipe_index = (uint16_t) pipe->endpoint_no;
     914        int rc = usb_request_get_status(ctrl_pipe,
     915            USB_REQUEST_RECIPIENT_ENDPOINT, uint16_host2usb(pipe_index),
     916            &status_tmp);
     917        if (rc != EOK) {
     918                return rc;
     919        }
     920
     921        if (status != NULL) {
     922                *status = uint16_usb2host(status_tmp);
     923        }
     924
     925        return EOK;
     926}
     927
    887928/**
    888929 * @}
  • uspace/lib/usbdev/src/usbdevice.c

    r05e21ffc r4a7a8d4  
    3737#include <usb_iface.h>
    3838#include <usb/usbdevice.h>
     39#include <usb/driver.h>
    3940#include <usb/debug.h>
    4041#include <errno.h>
    4142#include <assert.h>
    42 
    43 /** Find host controller handle that is ancestor of given device.
    44  *
    45  * @param[in] device_handle Device devman handle.
    46  * @param[out] hc_handle Where to store handle of host controller
    47  *      controlling device with @p device_handle handle.
    48  * @return Error code.
    49  */
    50 int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
    51 {
    52         int parent_phone = devman_parent_device_connect(device_handle,
    53             IPC_FLAG_BLOCKING);
    54         if (parent_phone < 0) {
    55                 return parent_phone;
    56         }
    57 
    58         devman_handle_t h;
    59         usb_log_debug("asking for HC handle (my handle is %zu).\n", device_handle);
    60         int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
    61             IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
    62 
    63         async_hangup(parent_phone);
    64 
    65         if (rc != EOK) {
    66                 return rc;
    67         }
    68 
    69         if (hc_handle != NULL) {
    70                 *hc_handle = h;
    71         }
    72 
    73         return EOK;
    74 }
    7543
    7644/** Initialize connection to USB host controller.
Note: See TracChangeset for help on using the changeset viewer.