Changes in / [82122f3:11658b64] in mainline
- Location:
- uspace
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/Makefile
r82122f3 r11658b64 33 33 34 34 SOURCES = \ 35 main.c \ 36 descparser.c 35 main.c 37 36 38 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/usbkbd/main.c
r82122f3 r11658b64 35 35 #include <usb/devreq.h> 36 36 #include <usb/descriptor.h> 37 #include "descparser.h"38 37 39 38 #define BUFFER_SIZE 32 … … 48 47 void *arg) 49 48 { 50 printf("Got keys: "); 51 unsigned i; 52 for (i = 0; i < count; ++i) { 53 printf("%d ", key_codes[i]); 54 } 55 printf("\n"); 49 56 50 } 57 51 … … 59 53 * Kbd functions 60 54 */ 61 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 62 { 63 // get the first configuration descriptor (TODO: parse also other!) 55 static int usbkbd_parse_descriptors(usb_hid_dev_kbd_t *kbd_dev, 56 const uint8_t *data, size_t size) 57 { 58 // const uint8_t *pos = data; 59 60 // // get the configuration descriptor (should be first) 61 // if (*pos != sizeof(usb_standard_configuration_descriptor_t) 62 // || *(pos + 1) != USB_DESCTYPE_CONFIGURATION) { 63 // fprintf(stderr, "Wrong format of configuration descriptor"); 64 // return EINVAL; 65 // } 66 67 // usb_standard_configuration_descriptor_t config_descriptor; 68 // memcpy(&config_descriptor, pos, 69 // sizeof(usb_standard_configuration_descriptor_t)); 70 // pos += sizeof(usb_standard_configuration_descriptor_t); 71 72 // // parse other descriptors 73 // while (pos - data < size) { 74 // //uint8_t desc_size = *pos; 75 // uint8_t desc_type = *(pos + 1); 76 // switch (desc_type) { 77 // case USB_DESCTYPE_INTERFACE: 78 // break; 79 // case USB_DESCTYPE_ENDPOINT: 80 // break; 81 // case USB_DESCTYPE_HID: 82 // break; 83 // case USB_DESCTYPE_HID_REPORT: 84 // break; 85 // case USB_DESCTYPE_HID_PHYSICAL: 86 // break; 87 // } 88 // } 89 90 return EOK; 91 } 92 93 static int usbkbd_get_descriptors(usb_hid_dev_kbd_t *kbd_dev) 94 { 95 // get the first configuration descriptor (TODO: or some other??) 64 96 usb_standard_configuration_descriptor_t config_desc; 65 97 … … 90 122 } 91 123 92 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 93 sizeof(usb_hid_configuration_t)); 94 if (kbd_dev->conf == NULL) { 95 free(descriptors); 96 return ENOMEM; 97 } 98 99 rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf); 124 rc = usbkbd_parse_descriptors(kbd_dev, descriptors, transferred); 100 125 free(descriptors); 101 126 … … 105 130 static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev) 106 131 { 107 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *) calloc(1,108 132 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)malloc( 133 sizeof(usb_hid_dev_kbd_t)); 109 134 110 135 if (kbd_dev == NULL) { … … 139 164 */ 140 165 141 // TODO: get descriptors, parse descriptors and save endpoints 142 usbkbd_process_descriptors(kbd_dev); 166 // TODO: get descriptors 167 usbkbd_get_descriptors(kbd_dev); 168 // TODO: parse descriptors and save endpoints 143 169 144 170 return kbd_dev; -
uspace/lib/usb/include/usb/classes/hid.h
r82122f3 r11658b64 39 39 #include <driver.h> 40 40 #include <usb/classes/hidparser.h> 41 #include <usb/descriptor.h>42 41 43 42 /** USB/HID device requests. */ … … 64 63 */ 65 64 typedef struct { 66 /** Type of class -specificdescriptor (Report or Physical). */67 uint8_t type;68 /** Length of class -specific descriptor in bytes. */69 uint16_t length;70 } __attribute__ ((packed)) usb_standard_hid_ class_descriptor_info_t;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; 71 70 72 71 /** Standard USB HID descriptor. … … 74 73 * (See HID Specification, p.22) 75 74 * 76 * It is actually only the "header" of the descriptor, it does not contain 77 * the last two mandatory fields (type and length of the first class-specific 78 * descriptor). 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. 79 77 */ 80 78 typedef struct { 81 /** Total size of this descriptor in bytes. 82 * 83 * This includes all class-specific descriptor info - type + length 84 * for each descriptor. 85 */ 79 /** Size of this descriptor in bytes. */ 86 80 uint8_t length; 87 81 /** Descriptor type (USB_DESCTYPE_HID). */ … … 91 85 /** Country code of localized hardware. */ 92 86 uint8_t country_code; 93 /** Total number of class-specific (i.e. Report and Physical) 94 * descriptors. 95 */ 96 uint8_t class_desc_count; 97 // /** First mandatory class descriptor info. */ 98 // usb_standard_hid_descriptor_class_item_t class_descriptor; 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; 99 91 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 100 92 101 /**102 *103 */104 typedef struct {105 usb_standard_interface_descriptor_t iface_desc;106 usb_standard_endpoint_descriptor_t *endpoints;107 usb_standard_hid_descriptor_t hid_desc;108 usb_standard_hid_class_descriptor_info_t *class_desc_info;109 uint8_t **class_descs;110 } usb_hid_iface_t;111 112 /**113 *114 */115 typedef struct {116 usb_standard_configuration_descriptor_t config_descriptor;117 usb_hid_iface_t *interfaces;118 } usb_hid_configuration_t;119 93 120 94 /** … … 125 99 typedef struct { 126 100 device_t *device; 127 usb_hid_configuration_t *conf;128 101 usb_address_t address; 129 102 usb_endpoint_t poll_endpoint;
Note:
See TracChangeset
for help on using the changeset viewer.