Changeset 19a1800 in mainline for uspace/lib/usb/include
- Timestamp:
- 2011-03-01T22:20:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e24e7b1
- Parents:
- 976f546 (diff), ac8285d (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. - Location:
- uspace/lib/usb/include/usb
- Files:
-
- 6 added
- 2 deleted
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/addrkeep.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief HC driver.33 * USB address keeping for host controller drivers. 34 34 */ 35 #ifndef LIBUSB_ HCD_H_36 #define LIBUSB_ HCD_H_35 #ifndef LIBUSB_ADDRKEEP_H_ 36 #define LIBUSB_ADDRKEEP_H_ 37 37 38 38 #include <usb/usb.h> … … 81 81 devman_handle_t); 82 82 83 84 83 #endif 84 /** 85 * @} 86 */ -
uspace/lib/usb/include/usb/classes/classes.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hid.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <usb/usb.h> 39 #include <driver.h>40 39 #include <usb/classes/hidparser.h> 40 #include <usb/descriptor.h> 41 41 42 42 /** USB/HID device requests. */ … … 51 51 } usb_hid_request_t; 52 52 53 typedef enum { 54 USB_HID_REPORT_TYPE_INPUT = 1, 55 USB_HID_REPORT_TYPE_OUTPUT = 2, 56 USB_HID_REPORT_TYPE_FEATURE = 3 57 } usb_hid_report_type_t; 58 59 typedef enum { 60 USB_HID_PROTOCOL_BOOT = 0, 61 USB_HID_PROTOCOL_REPORT = 1 62 } usb_hid_protocol_t; 63 64 /** USB/HID subclass constants. */ 65 typedef enum { 66 USB_HID_SUBCLASS_NONE = 0, 67 USB_HID_SUBCLASS_BOOT = 1 68 } usb_hid_subclass_t; 69 53 70 /** USB/HID interface protocols. */ 54 71 typedef enum { … … 56 73 USB_HID_PROTOCOL_KEYBOARD = 1, 57 74 USB_HID_PROTOCOL_MOUSE = 2 58 } usb_hid_ protocol_t;75 } usb_hid_iface_protocol_t; 59 76 60 77 /** Part of standard USB HID descriptor specifying one class descriptor. … … 63 80 */ 64 81 typedef struct { 65 /** Type of class descriptor (Report or Physical). */66 uint8_t class_descriptor_type;67 /** Length of class descriptor. */68 uint16_t class_descriptor_length;69 } __attribute__ ((packed)) usb_standard_hid_ descriptor_class_item_t;82 /** Type of class-specific descriptor (Report or Physical). */ 83 uint8_t type; 84 /** Length of class-specific descriptor in bytes. */ 85 uint16_t length; 86 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t; 70 87 71 88 /** Standard USB HID descriptor. … … 73 90 * (See HID Specification, p.22) 74 91 * 75 * It is actually only the "header" of the descriptor, as it may have arbitrary 76 * length if more than one class descritor is provided. 92 * It is actually only the "header" of the descriptor, it does not contain 93 * the last two mandatory fields (type and length of the first class-specific 94 * descriptor). 77 95 */ 78 96 typedef struct { 79 /** Size of this descriptor in bytes. */ 97 /** Total size of this descriptor in bytes. 98 * 99 * This includes all class-specific descriptor info - type + length 100 * for each descriptor. 101 */ 80 102 uint8_t length; 81 103 /** Descriptor type (USB_DESCTYPE_HID). */ … … 85 107 /** Country code of localized hardware. */ 86 108 uint8_t country_code; 87 /** Total number of class (i.e. Report and Physical) descriptors. */ 88 uint8_t class_count; 89 /** First mandatory class descriptor info. */ 90 usb_standard_hid_descriptor_class_item_t class_descriptor; 109 /** Total number of class-specific (i.e. Report and Physical) 110 * descriptors. 111 * 112 * @note There is always only one Report descriptor. 113 */ 114 uint8_t class_desc_count; 115 /** First mandatory class descriptor (Report) info. */ 116 usb_standard_hid_class_descriptor_info_t report_desc_info; 91 117 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 92 118 93 94 /**95 * @brief USB/HID keyboard device type.96 *97 * Quite dummy right now.98 */99 typedef struct {100 device_t *device;101 usb_address_t address;102 usb_endpoint_t poll_endpoint;103 usb_hid_report_parser_t *parser;104 } usb_hid_dev_kbd_t;105 119 106 120 #endif -
uspace/lib/usb/include/usb/classes/hidparser.h
r976f546 r19a1800 37 37 38 38 #include <stdint.h> 39 #include <adt/list.h>40 41 #include <hid_report_items.h>42 39 43 40 /** 44 * Item sprefix41 * Item prefix 45 42 */ 46 43 #define USB_HID_ITEM_SIZE(data) ((uint8_t)(data & 0x3)) … … 62 59 #define USB_HID_ITEM_FLAG_VOLATILE(flags) (flags & 0x80) 63 60 #define USB_HID_ITEM_FLAG_BUFFERED(flags) (flags & 0x100) 64 65 66 /**67 * Collection Item Types68 */69 #define USB_HID_COLLECTION_TYPE_PHYSICAL 0x0070 #define USB_HID_COLLECTION_TYPE_APPLICATION 0x0171 #define USB_HID_COLLECTION_TYPE_LOGICAL 0x0272 #define USB_HID_COLLECTION_TYPE_REPORT 0x0373 #define USB_HID_COLLECTION_TYPE_NAMED_ARRAY 0x0474 #define USB_HID_COLLECTION_TYPE_USAGE_SWITCH 0x0575 76 /*77 * modifiers definitions78 */79 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x0180 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x0281 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x0482 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x0883 #define USB_HID_BOOT_KEYBOARD_KANA 0x1084 61 85 62 … … 128 105 129 106 107 130 108 /** HID parser callbacks for IN items. */ 131 109 typedef struct { … … 139 117 } usb_hid_report_in_callbacks_t; 140 118 119 120 typedef enum { 121 USB_HID_MOD_LCTRL = 0x01, 122 USB_HID_MOD_LSHIFT = 0x02, 123 USB_HID_MOD_LALT = 0x04, 124 USB_HID_MOD_LGUI = 0x08, 125 USB_HID_MOD_RCTRL = 0x10, 126 USB_HID_MOD_RSHIFT = 0x20, 127 USB_HID_MOD_RALT = 0x40, 128 USB_HID_MOD_RGUI = 0x80, 129 USB_HID_MOD_COUNT = 8 130 } usb_hid_modifiers_t; 131 132 typedef enum { 133 USB_HID_LED_NUM_LOCK = 0x1, 134 USB_HID_LED_CAPS_LOCK = 0x2, 135 USB_HID_LED_SCROLL_LOCK = 0x4, 136 USB_HID_LED_COMPOSE = 0x8, 137 USB_HID_LED_KANA = 0x10, 138 USB_HID_LED_COUNT = 5 139 } usb_hid_led_t; 140 141 static const usb_hid_modifiers_t 142 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = { 143 USB_HID_MOD_LCTRL, 144 USB_HID_MOD_LSHIFT, 145 USB_HID_MOD_LALT, 146 USB_HID_MOD_LGUI, 147 USB_HID_MOD_RCTRL, 148 USB_HID_MOD_RSHIFT, 149 USB_HID_MOD_RALT, 150 USB_HID_MOD_RGUI 151 }; 152 153 //static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = { 154 // USB_HID_LED_NUM_LOCK, 155 // USB_HID_LED_CAPS_LOCK, 156 // USB_HID_LED_SCROLL_LOCK, 157 // USB_HID_LED_COMPOSE, 158 // USB_HID_LED_KANA 159 //}; 160 161 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 162 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 163 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 164 //#define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 165 //#define USB_HID_BOOT_KEYBOARD_KANA 0x10 166 167 /* 168 * modifiers definitions 169 */ 170 141 171 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 142 172 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 143 173 144 174 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 145 146 175 147 176 int usb_hid_parser_init(usb_hid_report_parser_t *parser); … … 157 186 158 187 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser); 188 159 189 #endif 160 190 /** -
uspace/lib/usb/include/usb/classes/hidut.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hidutkbd.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hub.h
r976f546 r19a1800 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010 Matus Dekanek 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 33 33 * @brief USB hub related structures. 34 34 */ 35 #ifndef LIBUSB_ HUB_H_36 #define LIBUSB_ HUB_H_35 #ifndef LIBUSB_CLASS_HUB_H_ 36 #define LIBUSB_CLASS_HUB_H_ 37 37 38 38 #include <sys/types.h> 39 #include <usb/hcdhubd.h>40 41 39 42 40 /** Hub class feature selector. … … 68 66 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2 69 67 */ 70 typedef struct hub_descriptor_type{68 typedef struct usb_hub_descriptor_type { 71 69 /** Number of bytes in this descriptor, including this byte */ 72 70 //uint8_t bDescLength; … … 80 78 /** 81 79 D1...D0: Logical Power Switching Mode 82 00: Ganged power switching (all ports ’power at80 00: Ganged power switching (all ports power at 83 81 once) 84 82 01: Individual port power switching … … 91 89 00: Global Over-current Protection. The hub 92 90 reports over-current as a summation of all 93 ports ’current draw, without a breakdown of91 ports current draw, without a breakdown of 94 92 individual port over-current status. 95 93 01: Individual Port Over-current Protection. The … … 198 196 extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE; 199 197 200 /**201 * @brief create uint8_t array with serialized descriptor202 *203 * @param descriptor204 */205 void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);206 207 /**208 * @brief create deserialized desriptor structure out of serialized descriptor209 *210 * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.211 *212 * @param sdescriptor serialized descriptor213 */214 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);215 198 216 199 -
uspace/lib/usb/include/usb/debug.h
r976f546 r19a1800 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010-2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 35 35 #ifndef LIBUSB_DEBUG_H_ 36 36 #define LIBUSB_DEBUG_H_ 37 #include <stdio.h> 38 #include <usb/usb.h> 39 #include <assert.h> 37 40 38 41 void usb_dprintf(const char *tag, int level, const char *format, ...); 39 42 void usb_dprintf_enable(const char *tag, int level); 40 43 44 void usb_dump_standard_descriptor(FILE *, const char *, const char *, 45 const uint8_t *, size_t); 46 47 /** Logging level. */ 48 typedef enum { 49 USB_LOG_LEVEL_FATAL, 50 USB_LOG_LEVEL_ERROR, 51 USB_LOG_LEVEL_WARNING, 52 USB_LOG_LEVEL_INFO, 53 USB_LOG_LEVEL_DEBUG, 54 USB_LOG_LEVEL_DEBUG2, 55 USB_LOG_LEVEL_MAX 56 } usb_log_level_t; 57 58 59 void usb_log_enable(usb_log_level_t, const char *); 60 61 void usb_log_printf(usb_log_level_t, const char *, ...); 62 63 #define usb_log_fatal(format, ...) \ 64 usb_log_printf(USB_LOG_LEVEL_FATAL, format, ##__VA_ARGS__) 65 66 #define usb_log_error(format, ...) \ 67 usb_log_printf(USB_LOG_LEVEL_ERROR, format, ##__VA_ARGS__) 68 69 #define usb_log_warning(format, ...) \ 70 usb_log_printf(USB_LOG_LEVEL_WARNING, format, ##__VA_ARGS__) 71 72 #define usb_log_info(format, ...) \ 73 usb_log_printf(USB_LOG_LEVEL_INFO, format, ##__VA_ARGS__) 74 75 #define usb_log_debug(format, ...) \ 76 usb_log_printf(USB_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__) 77 78 #define usb_log_debug2(format, ...) \ 79 usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__) 80 81 41 82 42 83 #endif 84 /** 85 * @} 86 */ 87 -
uspace/lib/usb/include/usb/descriptor.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 36 36 #define LIBUSB_DESCRIPTOR_H_ 37 37 38 #include <ipc/ipc.h>39 38 #include <async.h> 40 39 -
uspace/lib/usb/include/usb/dp.h
r976f546 r19a1800 45 45 } usb_dp_descriptor_nesting_t; 46 46 47 extern usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[]; 48 47 49 typedef struct { 48 50 usb_dp_descriptor_nesting_t *nesting; -
uspace/lib/usb/include/usb/request.h
r976f546 r19a1800 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief Standard USB devicerequests.33 * Standard USB requests. 34 34 */ 35 #ifndef LIBUSB_ DEVREQ_H_36 #define LIBUSB_ DEVREQ_H_35 #ifndef LIBUSB_REQUEST_H_ 36 #define LIBUSB_REQUEST_H_ 37 37 38 #include < ipc/ipc.h>39 #include < async.h>38 #include <sys/types.h> 39 #include <l18n/langs.h> 40 40 #include <usb/usb.h> 41 #include <usb/pipes.h> 41 42 #include <usb/descriptor.h> 42 43 … … 70 71 /** Main parameter to the request. */ 71 72 union { 73 uint16_t value; 72 74 /* FIXME: add #ifdefs according to host endianess */ 73 75 struct { … … 75 77 uint8_t value_high; 76 78 }; 77 uint16_t value;78 79 }; 79 80 /** Auxiliary parameter to the request. … … 85 86 } __attribute__ ((packed)) usb_device_request_setup_packet_t; 86 87 88 int usb_control_request_set(usb_endpoint_pipe_t *, 89 usb_request_type_t, usb_request_recipient_t, uint8_t, 90 uint16_t, uint16_t, void *, size_t); 87 91 88 int usb_drv_req_get_status(int, usb_address_t, usb_request_recipient_t, 89 uint16_t, uint16_t *); 90 int usb_drv_req_clear_feature(int, usb_address_t, usb_request_recipient_t, 91 uint16_t, uint16_t); 92 int usb_drv_req_set_feature(int, usb_address_t, usb_request_recipient_t, 93 uint16_t, uint16_t); 94 int usb_drv_req_set_address(int, usb_address_t, usb_address_t); 95 int usb_drv_req_get_descriptor(int, usb_address_t, usb_request_type_t, 96 uint8_t, uint8_t, uint16_t, void *, size_t, size_t *); 97 int usb_drv_req_get_device_descriptor(int, usb_address_t, 92 int usb_control_request_get(usb_endpoint_pipe_t *, 93 usb_request_type_t, usb_request_recipient_t, uint8_t, 94 uint16_t, uint16_t, void *, size_t, size_t *); 95 96 int usb_request_set_address(usb_endpoint_pipe_t *, usb_address_t); 97 int usb_request_get_descriptor(usb_endpoint_pipe_t *, usb_request_type_t, 98 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t, 99 size_t *); 100 int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t *, usb_request_type_t, 101 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *); 102 int usb_request_get_device_descriptor(usb_endpoint_pipe_t *, 98 103 usb_standard_device_descriptor_t *); 99 int usb_ drv_req_get_bare_configuration_descriptor(int, usb_address_t, int,104 int usb_request_get_bare_configuration_descriptor(usb_endpoint_pipe_t *, int, 100 105 usb_standard_configuration_descriptor_t *); 101 int usb_ drv_req_get_full_configuration_descriptor(int, usb_address_t, int,106 int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *, int, 102 107 void *, size_t, size_t *); 103 int usb_ drv_req_set_descriptor(int, usb_address_t, uint8_t, uint8_t, uint16_t,104 void *, size_t); 105 int usb_ drv_req_get_configuration(int, usb_address_t, uint8_t *);106 int usb_drv_req_set_configuration(int, usb_address_t, uint8_t);107 int usb_ drv_req_get_interface(int, usb_address_t, uint16_t, uint8_t *);108 int usb_drv_req_set_interface(int, usb_address_t, uint16_t, uint8_t);108 int usb_request_set_configuration(usb_endpoint_pipe_t *, uint8_t); 109 110 int usb_request_get_supported_languages(usb_endpoint_pipe_t *, 111 l18_win_locales_t **, size_t *); 112 int usb_request_get_string(usb_endpoint_pipe_t *, size_t, l18_win_locales_t, 113 char **); 109 114 110 115 #endif -
uspace/lib/usb/include/usb/usb.h
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 37 37 38 38 #include <sys/types.h> 39 #include <ipc/ipc.h> 39 #include <byteorder.h> 40 41 /** Convert 16bit value from native (host) endianness to USB endianness. */ 42 #define uint16_host2usb(n) host2uint16_t_le((n)) 43 44 /** Convert 32bit value from native (host) endianness to USB endianness. */ 45 #define uint32_host2usb(n) host2uint32_t_le((n)) 46 47 /** Convert 16bit value from USB endianness into native (host) one. */ 48 #define uint16_usb2host(n) uint16_t_le2host((n)) 49 50 /** Convert 32bit value from USB endianness into native (host) one. */ 51 #define uint32_usb2host(n) uint32_t_le2host((n)) 52 40 53 41 54 /** USB transfer type. */ … … 52 65 typedef enum { 53 66 USB_DIRECTION_IN, 54 USB_DIRECTION_OUT 67 USB_DIRECTION_OUT, 68 USB_DIRECTION_BOTH 55 69 } usb_direction_t; 70 71 /** USB speeds. */ 72 typedef enum { 73 /** USB 1.1 low speed (1.5Mbits/s). */ 74 USB_SPEED_LOW, 75 /** USB 1.1 full speed (12Mbits/s). */ 76 USB_SPEED_FULL, 77 /** USB 2.0 high speed (480Mbits/s). */ 78 USB_SPEED_HIGH 79 } usb_speed_t; 56 80 57 81 /** USB request type target. */ … … 68 92 USB_REQUEST_RECIPIENT_ENDPOINT = 2 69 93 } usb_request_recipient_t; 70 71 /** USB transaction outcome. */72 typedef enum {73 USB_OUTCOME_OK,74 USB_OUTCOME_CRCERROR,75 USB_OUTCOME_BABBLE76 } usb_transaction_outcome_t;77 78 const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);79 94 80 95 /** USB address type.
Note:
See TracChangeset
for help on using the changeset viewer.