Changeset ad4562c2 in mainline


Ignore:
Timestamp:
2011-02-26T23:48:57Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
882f8b1
Parents:
3a1aa20
Message:

Changed API for getting descriptors.

  • Changed usb_request_get_descriptor() and usb_request_get_descriptor_alloc().
  • Added parameter recipient, specifying if the descriptor is associated with device, interface, endpoint or other.
  • Modified all calls to it accordingly.

TODO not done in usbhid driver yet, but should not be used now.

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/usbhub.c

    r3a1aa20 rad4562c2  
    253253        usb_endpoint_pipe_start_session(&result->endpoints.control);
    254254        opResult = usb_request_get_descriptor(&result->endpoints.control,
    255                         USB_REQUEST_TYPE_CLASS,
    256                         USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
     255                        USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
     256                        USB_DESCTYPE_HUB,
     257                        0, 0, serialized_descriptor,
    257258                        USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
    258259        usb_endpoint_pipe_end_session(&result->endpoints.control);
  • uspace/lib/usb/include/usb/request.h

    r3a1aa20 rad4562c2  
    9696int usb_request_set_address(usb_endpoint_pipe_t *, usb_address_t);
    9797int usb_request_get_descriptor(usb_endpoint_pipe_t *, usb_request_type_t,
    98     uint8_t, uint8_t, uint16_t, void *, size_t, size_t *);
     98    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t,
     99    size_t *);
    99100int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t *, usb_request_type_t,
    100     uint8_t, uint8_t, uint16_t, void **, size_t *);
     101    usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
    101102int usb_request_get_device_descriptor(usb_endpoint_pipe_t *,
    102103    usb_standard_device_descriptor_t *);
  • uspace/lib/usb/src/hidparser.c

    r3a1aa20 rad4562c2  
    144144int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size)
    145145{
    146         if(size < 2){
     146        if (size < 1){
    147147                return -1;
    148148        }
    149149
    150         data[1] = leds;
     150        data[0] = leds;
    151151        return EOK;
    152152}
  • uspace/lib/usb/src/request.c

    r3a1aa20 rad4562c2  
    3636#include <errno.h>
    3737#include <assert.h>
     38#include <usb/debug.h>
    3839
    3940#define MAX_DATA_LENGTH ((size_t)(0xFFFF))
     
    209210 */
    210211int usb_request_get_descriptor(usb_endpoint_pipe_t *pipe,
    211     usb_request_type_t request_type,
     212    usb_request_type_t request_type, usb_request_recipient_t recipient,
    212213    uint8_t descriptor_type, uint8_t descriptor_index,
    213214    uint16_t language,
     
    224225
    225226        return usb_control_request_get(pipe,
    226             request_type, USB_REQUEST_RECIPIENT_DEVICE,
     227            request_type, recipient,
    227228            USB_DEVREQ_GET_DESCRIPTOR,
    228229            wValue, language,
     
    242243 */
    243244int usb_request_get_descriptor_alloc(usb_endpoint_pipe_t * pipe,
    244     usb_request_type_t request_type,
     245    usb_request_type_t request_type, usb_request_recipient_t recipient,
    245246    uint8_t descriptor_type, uint8_t descriptor_index,
    246247    uint16_t language,
     
    258259        uint8_t tmp_buffer[1];
    259260        size_t bytes_transfered;
    260         rc = usb_request_get_descriptor(pipe, request_type,
     261        rc = usb_request_get_descriptor(pipe, request_type, recipient,
    261262            descriptor_type, descriptor_index, language,
    262263            &tmp_buffer, 1, &bytes_transfered);
     
    283284        }
    284285
    285         rc = usb_request_get_descriptor(pipe, request_type,
     286        rc = usb_request_get_descriptor(pipe, request_type, recipient,
    286287            descriptor_type, descriptor_index, language,
    287288            buffer, size, &bytes_transfered);
     
    320321        usb_standard_device_descriptor_t descriptor_tmp;
    321322        int rc = usb_request_get_descriptor(pipe,
    322             USB_REQUEST_TYPE_STANDARD, USB_DESCTYPE_DEVICE,
    323             0, 0,
     323            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
     324            USB_DESCTYPE_DEVICE, 0, 0,
    324325            &descriptor_tmp, sizeof(descriptor_tmp),
    325326            &actually_transferred);
     
    366367        usb_standard_configuration_descriptor_t descriptor_tmp;
    367368        int rc = usb_request_get_descriptor(pipe,
    368             USB_REQUEST_TYPE_STANDARD, USB_DESCTYPE_CONFIGURATION,
    369             index, 0,
     369            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
     370            USB_DESCTYPE_CONFIGURATION, index, 0,
    370371            &descriptor_tmp, sizeof(descriptor_tmp),
    371372            &actually_transferred);
     
    406407
    407408        return usb_request_get_descriptor(pipe,
    408             USB_REQUEST_TYPE_STANDARD, USB_DESCTYPE_CONFIGURATION,
    409             index, 0,
     409            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
     410            USB_DESCTYPE_CONFIGURATION, index, 0,
    410411            descriptor, descriptor_size, actual_size);
    411412}
     
    452453        size_t string_descriptor_size = 0;
    453454        rc = usb_request_get_descriptor_alloc(pipe,
    454             USB_REQUEST_TYPE_STANDARD, USB_DESCTYPE_STRING, 0, 0,
     455            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
     456            USB_DESCTYPE_STRING, 0, 0,
    455457            (void **) &string_descriptor, &string_descriptor_size);
    456458        if (rc != EOK) {
     
    531533        size_t string_size;
    532534        rc = usb_request_get_descriptor_alloc(pipe,
    533             USB_REQUEST_TYPE_STANDARD, USB_DESCTYPE_STRING,
    534             index, uint16_host2usb(lang),
     535            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
     536            USB_DESCTYPE_STRING, index, uint16_host2usb(lang),
    535537            (void **) &string, &string_size);
    536538        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.