Changeset c9399c0 in mainline


Ignore:
Timestamp:
2013-01-05T17:05:37Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2a6e2358
Parents:
d1974966
Message:

libusbvirt: Drop custom request type format.

use the one provided by libusb.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/vuhid/main.c

    rd1974966 rc9399c0  
    5757static usbvirt_control_request_handler_t endpoint_zero_handlers[] = {
    5858        {
    59                 .req_direction = USB_DIRECTION_IN,
    60                 .req_type = USB_REQUEST_TYPE_STANDARD,
    61                 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE,
     59                .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD,  USB_REQUEST_RECIPIENT_INTERFACE),
    6260                .request = USB_DEVREQ_GET_DESCRIPTOR,
    6361                .name = "Get_Descriptor",
     
    6563        },
    6664        {
    67                 .req_direction = USB_DIRECTION_OUT,
    68                 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE,
    69                 .req_type = USB_REQUEST_TYPE_CLASS,
     65                .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE),
    7066                .request = USB_HIDREQ_SET_PROTOCOL,
    7167                .name = "Set_Protocol",
     
    7369        },
    7470        {
    75                 .req_direction = USB_DIRECTION_OUT,
    76                 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE,
    77                 .req_type = USB_REQUEST_TYPE_CLASS,
     71                .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE),
    7872                .request = USB_HIDREQ_SET_REPORT,
    7973                .name = "Set_Report",
  • uspace/drv/bus/usb/vhc/hub/virthubops.c

    rd1974966 rc9399c0  
    340340
    341341
    342 /** IN class request. */
    343 #define CLASS_REQ_IN(recipient) \
    344         USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_IN, \
    345         USBVIRT_REQUEST_TYPE_CLASS, recipient)
    346 /** OUT class request. */
    347 #define CLASS_REQ_OUT(recipient) \
    348         USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_OUT, \
    349         USBVIRT_REQUEST_TYPE_CLASS, recipient)
    350342
    351343/** Recipient: other. */
     
    353345/** Recipient: device. */
    354346#define REC_DEVICE USB_REQUEST_RECIPIENT_DEVICE
    355 /** Direction: in. */
    356 #define DIR_IN USB_DIRECTION_IN
    357 /** Direction: out. */
    358 #define DIR_OUT USB_DIRECTION_OUT
    359 
    360 
    361 /** Create a class request.
    362  *
    363  * @param direction Request direction.
    364  * @param recipient Request recipient.
     347
     348
     349/** Create a class request to get data from device
     350 *
     351 * @param rec Request recipient.
    365352 * @param req Request code.
    366353 */
    367 #define CLASS_REQ(direction, recipient, req) \
    368         .req_direction = direction, \
    369         .req_recipient = recipient, \
    370         .req_type = USB_REQUEST_TYPE_CLASS, \
     354#define CLASS_REQ_IN(rec, req) \
     355        .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_CLASS, rec), \
    371356        .request = req
    372357
    373 /** Create a standard request.
    374  *
    375  * @param direction Request direction.
    376  * @param recipient Request recipient.
     358/** Create a class request to send data to device
     359 *
     360 * @param rec Request recipient.
    377361 * @param req Request code.
    378362 */
    379 #define STD_REQ(direction, recipient, req) \
    380         .req_direction = direction, \
    381         .req_recipient = recipient, \
    382         .req_type = USB_REQUEST_TYPE_STANDARD, \
     363#define CLASS_REQ_OUT(rec, req) \
     364        .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_CLASS, rec), \
    383365        .request = req
    384366
     
    386368static usbvirt_control_request_handler_t endpoint_zero_handlers[] = {
    387369        {
    388                 STD_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
     370                .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
     371                .request = USB_DEVREQ_GET_DESCRIPTOR,
    389372                .name = "GetDescriptor",
    390373                .callback = req_get_descriptor
    391374        },
    392375        {
    393                 CLASS_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
     376                CLASS_REQ_IN(REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
    394377                .name = "GetDescriptor",
    395378                .callback = req_get_descriptor
    396379        },
    397380        {
    398                 CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
     381                CLASS_REQ_IN(REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
    399382                .name = "GetPortStatus",
    400383                .callback = req_get_port_status
    401384        },
    402385        {
    403                 CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
     386                CLASS_REQ_OUT(REC_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
    404387                .name = "ClearHubFeature",
    405388                .callback = req_clear_hub_feature
    406389        },
    407390        {
    408                 CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
     391                CLASS_REQ_OUT(REC_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
    409392                .name = "ClearPortFeature",
    410393                .callback = req_clear_port_feature
    411394        },
    412395        {
    413                 CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATE),
     396                CLASS_REQ_IN(REC_OTHER, USB_HUB_REQUEST_GET_STATE),
    414397                .name = "GetBusState",
    415398                .callback = req_get_bus_state
    416399        },
    417400        {
    418                 CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
     401                CLASS_REQ_IN(REC_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
    419402                .name = "GetHubDescriptor",
    420403                .callback = req_get_descriptor
    421404        },
    422405        {
    423                 CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_STATUS),
     406                CLASS_REQ_IN(REC_DEVICE, USB_HUB_REQUEST_GET_STATUS),
    424407                .name = "GetHubStatus",
    425408                .callback = req_get_hub_status
    426409        },
    427410        {
    428                 CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
     411                CLASS_REQ_IN(REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
    429412                .name = "GetPortStatus",
    430413                .callback = req_get_port_status
    431414        },
    432415        {
    433                 CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
     416                CLASS_REQ_OUT(REC_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
    434417                .name = "SetHubFeature",
    435418                .callback = req_set_hub_feature
    436419        },
    437420        {
    438                 CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_SET_FEATURE),
     421                CLASS_REQ_OUT(REC_OTHER, USB_HUB_REQUEST_SET_FEATURE),
    439422                .name = "SetPortFeature",
    440423                .callback = req_set_port_feature
  • uspace/lib/usbvirt/include/usbvirt/device.h

    rd1974966 rc9399c0  
    9494 */
    9595typedef struct {
    96         /** Request direction (in or out). */
    97         usb_direction_t req_direction;
    98         /** Request recipient (device, interface or endpoint). */
    99         usb_request_recipient_t req_recipient;
    100         /** Request type (standard, class or vendor). */
    101         usb_request_type_t req_type;
     96        /* Request type. See usb/request.h */
     97        uint8_t request_type;
    10298        /** Actual request code. */
    10399        uint8_t request;
  • uspace/lib/usbvirt/src/ctrltransfer.c

    rd1974966 rc9399c0  
    6060                return EFORWARD;
    6161        }
    62 
    63         usb_direction_t direction = setup->request_type & 128 ?
    64             USB_DIRECTION_IN : USB_DIRECTION_OUT;
    65         usb_request_recipient_t req_recipient = setup->request_type & 31;
    66         usb_request_type_t req_type = (setup->request_type >> 5) & 3;
    67 
    6862        usbvirt_control_request_handler_t *handler = control_handlers;
    69         while (handler->callback != NULL) {
    70                 if (handler->req_direction != direction) {
    71                         goto next;
    72                 }
    73                 if (handler->req_recipient != req_recipient) {
    74                         goto next;
    75                 }
    76                 if (handler->req_type != req_type) {
    77                         goto next;
    78                 }
    79                 if (handler->request != setup->request) {
    80                         goto next;
     63        for (;handler->callback != NULL; ++handler) {
     64                if (handler->request != setup->request ||
     65                    handler->request_type != setup->request_type) {
     66                        continue;
    8167                }
    8268
     
    8470                    usb_debug_str_buffer((uint8_t*) setup, sizeof(*setup), 0));
    8571                int rc = handler->callback(dev, setup, data, data_sent_size);
    86                 if (rc == EFORWARD) {
    87                         goto next;
     72                if (rc != EFORWARD) {
     73                        return rc;
    8874                }
    8975
    90                 return rc;
    91 
    92 next:
    93                 handler++;
    9476        }
    9577
  • uspace/lib/usbvirt/src/stdreq.c

    rd1974966 rc9399c0  
    192192usbvirt_control_request_handler_t library_handlers[] = {
    193193        {
    194                 .req_direction = USB_DIRECTION_OUT,
    195                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    196                 .req_type = USB_REQUEST_TYPE_STANDARD,
     194                .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
    197195                .request = USB_DEVREQ_SET_ADDRESS,
    198196                .name = "SetAddress",
     
    200198        },
    201199        {
    202                 .req_direction = USB_DIRECTION_IN,
    203                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    204                 .req_type = USB_REQUEST_TYPE_STANDARD,
     200                .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
    205201                .request = USB_DEVREQ_GET_DESCRIPTOR,
    206202                .name = "GetDescriptor",
     
    208204        },
    209205        {
    210                 .req_direction = USB_DIRECTION_OUT,
    211                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    212                 .req_type = USB_REQUEST_TYPE_STANDARD,
     206                .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
    213207                .request = USB_DEVREQ_SET_CONFIGURATION,
    214208                .name = "SetConfiguration",
    215209                .callback = req_set_configuration
    216210        },
    217 
    218211        { .callback = NULL }
    219212};
Note: See TracChangeset for help on using the changeset viewer.