Changeset a81a1d09 in mainline for uspace/lib/usb/src


Ignore:
Timestamp:
2011-05-11T16:49:28Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19387b61
Parents:
e1dbcbc (diff), 9212f8a (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 development/ changes

Location:
uspace/lib/usb/src
Files:
1 deleted
2 edited
2 moved

Legend:

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

    re1dbcbc ra81a1d09  
    3737#include <async.h>
    3838#include <usb/ddfiface.h>
     39#include <usb/driver.h>
    3940#include <usb/debug.h>
    4041#include <errno.h>
  • uspace/lib/usb/src/driver.c

    re1dbcbc ra81a1d09  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <stdio.h>
    30 #include <stdlib.h>
    31 #include <usb/addrkeep.h>
     29/** @addtogroup libusb
     30 * @{
     31 */
     32/** @file
     33 *
     34 */
     35#include <devman.h>
     36#include <dev_iface.h>
     37#include <usb_iface.h>
     38#include <usb/driver.h>
    3239#include <errno.h>
    33 #include "../tester.h"
    34 
    35 #define MAX_ADDRESS 5
    3640
    3741
    38 const char *test_usbaddrkeep(void)
     42/** Find host controller handle that is ancestor of given device.
     43 *
     44 * @param[in] device_handle Device devman handle.
     45 * @param[out] hc_handle Where to store handle of host controller
     46 *      controlling device with @p device_handle handle.
     47 * @return Error code.
     48 */
     49int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
    3950{
    40         int rc;
    41         usb_address_keeping_t addresses;
    42 
    43         TPRINTF("Initializing addresses keeping structure...\n");
    44         usb_address_keeping_init(&addresses, MAX_ADDRESS);
    45        
    46         TPRINTF("Requesting address...\n");
    47         usb_address_t addr = usb_address_keeping_request(&addresses);
    48         TPRINTF("Address assigned: %d\n", (int) addr);
    49         if (addr != 1) {
    50                 return "have not received expected address 1";
     51        int parent_phone = devman_parent_device_connect(device_handle,
     52            IPC_FLAG_BLOCKING);
     53        if (parent_phone < 0) {
     54                return parent_phone;
    5155        }
    5256
    53         TPRINTF("Releasing not assigned address...\n");
    54         rc = usb_address_keeping_release(&addresses, 2);
    55         if (rc != ENOENT) {
    56                 return "have not received expected ENOENT";
     57        devman_handle_t h;
     58        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     59            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
     60
     61        async_hangup(parent_phone);
     62
     63        if (rc != EOK) {
     64                return rc;
    5765        }
    5866
    59         TPRINTF("Releasing acquired address...\n");
    60         rc = usb_address_keeping_release(&addresses, addr);
    61         if (rc != EOK) {
    62                 return "have not received expected EOK";
     67        if (hc_handle != NULL) {
     68                *hc_handle = h;
    6369        }
    6470
    65         return NULL;
     71        return EOK;
    6672}
     73
     74/**
     75 * @}
     76 */
  • uspace/lib/usb/src/dump.c

    re1dbcbc ra81a1d09  
    4141#include <usb/descriptor.h>
    4242#include <usb/classes/classes.h>
    43 #include <usb/classes/hid.h>
    4443
    4544/** Mapping between descriptor id and dumping function. */
  • uspace/lib/usb/src/host.c

    re1dbcbc ra81a1d09  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * @brief Keyboard configuration.
     34 * Host controller common functions (implementation).
    3535 */
     36#include <stdio.h>
     37#include <str_error.h>
    3638#include <errno.h>
     39#include <assert.h>
     40#include <bool.h>
     41#include <usb/host.h>
    3742#include <usb/descriptor.h>
    38 #include "stdreq.h"
    39 #include "kbdconfig.h"
     43#include <devman.h>
    4044
    41 int req_get_descriptor(usbvirt_device_t *device,
    42     const usb_device_request_setup_packet_t *setup_packet,
    43     uint8_t *data, size_t *act_size)
     45/** Get host controller handle by its class index.
     46 *
     47 * @param class_index Class index for the host controller.
     48 * @param hc_handle Where to store the HC handle
     49 *      (can be NULL for existence test only).
     50 * @return Error code.
     51 */
     52int usb_ddf_get_hc_handle_by_class(size_t class_index,
     53    devman_handle_t *hc_handle)
    4454{
    45         if (setup_packet->value_high == USB_DESCTYPE_HID_REPORT) {
    46                 /*
    47                  * For simplicity, always return the same
    48                  * report descriptor.
    49                  */
    50                 usbvirt_control_reply_helper(setup_packet,
    51                     data, act_size,
    52                     report_descriptor, report_descriptor_size);
     55        char *class_index_str;
     56        devman_handle_t hc_handle_tmp;
     57        int rc;
    5358
    54                 return EOK;
     59        rc = asprintf(&class_index_str, "%zu", class_index);
     60        if (rc < 0) {
     61                return ENOMEM;
    5562        }
    56        
    57         /* Let the framework handle all the rest. */
    58         return EFORWARD;
     63        rc = devman_device_get_handle_by_class("usbhc", class_index_str,
     64            &hc_handle_tmp, 0);
     65        free(class_index_str);
     66        if (rc != EOK) {
     67                return rc;
     68        }
     69
     70        if (hc_handle != NULL) {
     71                *hc_handle = hc_handle_tmp;
     72        }
     73
     74        return EOK;
    5975}
    60 
    61 
    6276
    6377/** @}
Note: See TracChangeset for help on using the changeset viewer.