Changeset 73301a0 in mainline for uspace/lib/usbvirt/stdreq.c


Ignore:
Timestamp:
2010-10-15T12:57:35Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
47e3a8e
Parents:
cbc00a4d
Message:

Virtual USB keyboard sends its report

Also, the virtual USB framework now handles the standard requests
differently. First, all requests has standalone callbacks and the
user callbacks are always called first. If they return EFORWARD,
the framework will try to satisfy the request by itself.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/stdreq.c

    rcbc00a4d r73301a0  
    123123}
    124124
     125#define HANDLE_REQUEST(request, data, type, dev, user_callback, default_handler) \
     126        do { \
     127                if ((request)->request == (type)) { \
     128                        int _rc = EFORWARD; \
     129                        if (((dev)->ops) && ((dev)->ops->standard_request_ops) \
     130                            && ((dev)->ops->standard_request_ops->user_callback)) { \
     131                                _rc = (dev)->ops->standard_request_ops->\
     132                                    user_callback(dev, request, data); \
     133                        } \
     134                        if (_rc == EFORWARD) { \
     135                                default_handler; \
     136                        } \
     137                        return _rc; \
     138                } \
     139        } while (false)
     140
     141
    125142int handle_std_request(usb_device_request_setup_packet_t *request, uint8_t *data)
    126143{
    127         int rc;
     144        HANDLE_REQUEST(request, data, USB_DEVREQ_GET_DESCRIPTOR,
     145            device, on_get_descriptor,
     146            handle_get_descriptor(request->value_low, request->value_high,
     147                request->index, request->length));
    128148       
    129         switch (request->request) {
    130                 case USB_DEVREQ_GET_DESCRIPTOR:
    131                         rc = handle_get_descriptor(
    132                             request->value_low, request->value_high,
    133                             request->index, request->length);
    134                         break;
    135                
    136                 case USB_DEVREQ_SET_ADDRESS:
    137                         rc = handle_set_address(request->value,
    138                             request->index, request->length);
    139                         break;
    140                
    141                 default:
    142                         rc = EFORWARD;
    143                         break;
    144         }
     149        HANDLE_REQUEST(request, data, USB_DEVREQ_SET_ADDRESS,
     150            device, on_set_address,
     151            handle_set_address(request->value,
     152                request->index, request->length));
    145153       
    146         /*
    147          * We preprocessed all we could.
    148          * If it was not enough, pass the request to the actual driver.
    149          */
    150         if (rc == EFORWARD) {
    151                 if (DEVICE_HAS_OP(device, on_devreq_std)) {
    152                         return device->ops->on_devreq_std(device,
    153                             request, data);
    154                 }
    155         }
    156        
    157         return EOK;
     154        return ENOTSUP;
    158155}
    159156
Note: See TracChangeset for help on using the changeset viewer.