Changeset 3e4f2e0 in mainline for uspace/lib/usb


Ignore:
Timestamp:
2011-05-08T20:00:07Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
55054db0, 9212f8a
Parents:
19065c7
Message:

libusb divided into sublibraries

Also removed address keeper test from tester as it is useless.

Directory reorganization of the include/ will follow.

Location:
uspace/lib/usb
Files:
1 added
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/Makefile

    r19065c7 r3e4f2e0  
    2929USPACE_PREFIX = ../..
    3030LIBRARY = libusb
    31 LIBS = $(LIBDRV_PREFIX)/libdrv.a
    32 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -Iinclude
     31EXTRA_CFLAGS += \
     32        -I$(LIBDRV_PREFIX)/include \
     33        -Iinclude
    3334
    3435SOURCES = \
    35         src/addrkeep.c \
    36         src/altiface.c \
    3736        src/class.c \
    3837        src/ddfiface.c \
    3938        src/debug.c \
    40         src/devdrv.c \
    41         src/devpoll.c \
    42         src/dp.c \
     39        src/driver.c \
    4340        src/dump.c \
    44         src/hidiface.c \
    45         src/hidpath.c \
    46         src/hidparser.c \
    47         src/hiddescriptor.c \
    4841        src/host.c \
    49         src/hub.c \
    50         src/pipepriv.c \
    51         src/pipes.c \
    52         src/pipesinit.c \
    53         src/pipesio.c \
    54         src/recognise.c \
    55         src/request.c \
    56         src/usb.c \
    57         src/usbdevice.c \
    58         src/hidreq.c \
    59         src/hidreport.c \
    60         src/host/device_keeper.c \
    61         src/host/batch.c \
    62         src/host/endpoint.c \
    63         src/host/usb_endpoint_manager.c
     42        src/usb.c
    6443
    6544include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/usb/include/usb/ddfiface.h

    r19065c7 r3e4f2e0  
    3737
    3838#include <sys/types.h>
    39 #include <usb/usbdevice.h>
    4039#include <usb_iface.h>
    4140
  • uspace/lib/usb/include/usb/descriptor.h

    r19065c7 r3e4f2e0  
    167167} __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
    168168
     169/** Part of standard USB HID descriptor specifying one class descriptor.
     170 *
     171 * (See HID Specification, p.22)
     172 */
     173typedef struct {
     174        /** Type of class-specific descriptor (Report or Physical). */
     175        uint8_t type;
     176        /** Length of class-specific descriptor in bytes. */
     177        uint16_t length;
     178} __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
     179
     180/** Standard USB HID descriptor.
     181 *
     182 * (See HID Specification, p.22)
     183 *
     184 * It is actually only the "header" of the descriptor, it does not contain
     185 * the last two mandatory fields (type and length of the first class-specific
     186 * descriptor).
     187 */
     188typedef struct {
     189        /** Total size of this descriptor in bytes.
     190         *
     191         * This includes all class-specific descriptor info - type + length
     192         * for each descriptor.
     193         */
     194        uint8_t length;
     195        /** Descriptor type (USB_DESCTYPE_HID). */
     196        uint8_t descriptor_type;
     197        /** HID Class Specification release. */
     198        uint16_t spec_release;
     199        /** Country code of localized hardware. */
     200        uint8_t country_code;
     201        /** Total number of class-specific (i.e. Report and Physical)
     202         * descriptors.
     203         *
     204         * @note There is always only one Report descriptor.
     205         */
     206        uint8_t class_desc_count;
     207        /** First mandatory class descriptor (Report) info. */
     208        usb_standard_hid_class_descriptor_info_t report_desc_info;
     209} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
     210
    169211#endif
    170212/**
  • uspace/lib/usb/src/ddfiface.c

    r19065c7 r3e4f2e0  
    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

    r19065c7 r3e4f2e0  
    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

    r19065c7 r3e4f2e0  
    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. */
Note: See TracChangeset for help on using the changeset viewer.