Changeset ca038b4 in mainline for uspace/drv/usbkbd/main.c
- Timestamp:
- 2010-12-12T16:50:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 692f13e4
- Parents:
- c694b7e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbkbd/main.c
rc694b7e rca038b4 35 35 #include <usb/devreq.h> 36 36 #include <usb/descriptor.h> 37 #include "descparser.h" 37 38 38 39 #define BUFFER_SIZE 32 … … 53 54 * Kbd functions 54 55 */ 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??) 56 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 57 { 58 // get the first configuration descriptor (TODO: parse also other!) 96 59 usb_standard_configuration_descriptor_t config_desc; 97 60 … … 122 85 } 123 86 124 rc = usbkbd_parse_descriptors(kbd_dev, descriptors, transferred); 87 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 88 sizeof(usb_hid_configuration_t)); 89 if (kbd_dev->conf == NULL) { 90 free(descriptors); 91 return ENOMEM; 92 } 93 94 rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf); 125 95 free(descriptors); 126 96 … … 130 100 static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev) 131 101 { 132 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *) malloc(133 102 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)calloc(1, 103 sizeof(usb_hid_dev_kbd_t)); 134 104 135 105 if (kbd_dev == NULL) { … … 164 134 */ 165 135 166 // TODO: get descriptors 167 usbkbd_get_descriptors(kbd_dev); 168 // TODO: parse descriptors and save endpoints 136 // TODO: get descriptors, parse descriptors and save endpoints 137 usbkbd_process_descriptors(kbd_dev); 169 138 170 139 return kbd_dev;
Note:
See TracChangeset
for help on using the changeset viewer.