Changeset 45019865 in mainline


Ignore:
Timestamp:
2011-01-14T13:35:14Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0a9ea4a
Parents:
f401312
Message:

Fixed descriptor parsing.

  • Properly parses standard descriptors.
  • Properly gets report descriptor.
Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbkbd/descdump.c

    rf401312 r45019865  
    125125        printf(INDENT "bCountryCode = %d\n", d->country_code);
    126126        printf(INDENT "bNumDescriptors = %d\n", d->class_desc_count);
     127        printf(INDENT "bDescriptorType = %d\n", d->report_desc_info.type);
     128        printf(INDENT "wDescriptorLength = %d\n", d->report_desc_info.length);
    127129}
    128130
  • uspace/drv/usbkbd/descparser.c

    rf401312 r45019865  
    5252                        free(config->interfaces[i].endpoints);
    5353                }
    54                 if (iface->class_desc_info != NULL) {
     54                /*if (iface->class_desc_info != NULL) {
    5555                        free(iface->class_desc_info);
    5656                }
     
    6464                                }
    6565                        }
    66                 }
     66                }*/
    6767        }
    6868       
     
    152152                        }
    153153                        ep_i = 0;
     154
     155                        printf("Remaining size: %d\n", size - (size_t)(pos - data));
    154156                       
    155157                        break;
     
    184186                        break;
    185187                case USB_DESCTYPE_HID:
    186                         if (desc_size < sizeof(usb_standard_hid_descriptor_t)
    187                            + sizeof(usb_standard_hid_class_descriptor_info_t)) {
     188                        if (desc_size < sizeof(usb_standard_hid_descriptor_t)) {
     189                                printf("Wrong size of descriptor: %d (should be %d)\n",
     190                                    desc_size, sizeof(usb_standard_hid_descriptor_t));
    188191                                ret = EINVAL;
    189192                                goto end;
     
    195198                        pos += sizeof(usb_standard_hid_descriptor_t);
    196199                       
    197                         if (actual_iface->hid_desc.class_desc_count
     200                        /*if (actual_iface->hid_desc.class_desc_count
    198201                            * sizeof(usb_standard_hid_class_descriptor_info_t)
    199202                            != desc_size
     
    203206                                ret = EINVAL;
    204207                                goto end;
    205                         }
     208                        }*/
    206209
    207210                        printf("Parsed HID descriptor header: \n");
     
    209212                       
    210213                        // allocate space for all class-specific descriptor info
    211                         actual_iface->class_desc_info =
     214                        /*actual_iface->class_desc_info =
    212215                            (usb_standard_hid_class_descriptor_info_t *)malloc(
    213216                            actual_iface->hid_desc.class_desc_count
     
    216219                                ret = ENOMEM;
    217220                                goto end;
    218                         }
     221                        }*/
    219222                       
    220223                        // allocate space for all class-specific descriptors
     
    317320                dump_standard_hid_descriptor_header(&iface_d->hid_desc);
    318321                printf("\n");
     322                dump_hid_class_descriptor(0, USB_DESCTYPE_HID_REPORT,
     323                    iface_d->report_desc, iface_d->hid_desc.report_desc_info.length);
     324                printf("\n");
    319325//              printf("%d class-specific descriptors\n",
    320326//                  iface_d->hid_desc.class_desc_count);
    321                 for (j = 0; j < iface_d->hid_desc.class_desc_count; ++j) {
     327                /*for (j = 0; j < iface_d->hid_desc.class_desc_count; ++j) {
    322328                        dump_standard_hid_class_descriptor_info(
    323329                            &iface_d->class_desc_info[j]);
     
    329335                            iface_d->class_descs[j],
    330336                            iface_d->class_desc_info[j].length);
    331                 }
     337                }*/
    332338        }
    333339}
  • uspace/drv/usbkbd/main.c

    rf401312 r45019865  
    3939#include <usb/descriptor.h>
    4040#include "descparser.h"
     41#include "descdump.h"
    4142
    4243#define BUFFER_SIZE 32
     
    109110        unsigned i;
    110111        for (i = 0; i < kbd_dev->conf->config_descriptor.interface_count; ++i) {
    111                 uint8_t type =
    112                     kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.type;
    113112                // TODO: endianness
    114113                uint16_t length =
    115114                    kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.length;
     115                size_t actual_size = 0;
    116116
    117117                // allocate space for the report descriptor
    118118                kbd_dev->conf->interfaces[i].report_desc = (uint8_t *)malloc(length);
     119               
    119120                // get the descriptor from the device
    120                
    121         }
     121                int rc = usb_drv_req_get_descriptor(kbd_dev->device->parent_phone,
     122                    kbd_dev->address, USB_REQUEST_TYPE_CLASS, USB_DESCTYPE_HID_REPORT,
     123                    0, i, kbd_dev->conf->interfaces[i].report_desc, length,
     124                    &actual_size);
     125
     126                if (rc != EOK) {
     127                        return rc;
     128                }
     129
     130                assert(actual_size == length);
     131
     132                dump_hid_class_descriptor(0, USB_DESCTYPE_HID_REPORT,
     133                    kbd_dev->conf->interfaces[i].report_desc, length);
     134        }
     135
     136        return EOK;
    122137}
    123138
     
    162177        rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);
    163178        free(descriptors);
     179        if (rc != EOK) {
     180                printf("Problem with parsing standard descriptors.\n");
     181                return rc;
     182        }
    164183
    165184        // get and report descriptors
    166185        rc = usbkbd_get_report_descriptor(kbd_dev);
     186        if (rc != EOK) {
     187                printf("Problem with parsing HID REPORT descriptor.\n");
     188                return rc;
     189        }
    167190       
    168191        usbkbd_print_config(kbd_dev->conf);
    169192       
    170         return rc;
     193        return EOK;
    171194}
    172195
  • uspace/lib/usb/include/usb/classes/hid.h

    rf401312 r45019865  
    9898        uint8_t class_desc_count;
    9999        /** First mandatory class descriptor (Report) info. */
    100         usb_standard_hid_descriptor_class_item_t report_desc_info;
     100        usb_standard_hid_class_descriptor_info_t report_desc_info;
    101101} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
    102102
Note: See TracChangeset for help on using the changeset viewer.