Changeset 73301a0 in mainline
- Timestamp:
- 2010-10-15T12:57:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 47e3a8e
- Parents:
- cbc00a4d
- Location:
- uspace
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/Makefile
rcbc00a4d r73301a0 38 38 kbdconfig.c \ 39 39 keys.c \ 40 stdreq.c \ 40 41 virtusbkbd.c 41 42 -
uspace/app/virtusbkbd/virtusbkbd.c
rcbc00a4d r73301a0 54 54 #include "kbdconfig.h" 55 55 #include "keys.h" 56 #include "stdreq.h" 56 57 57 58 #define LOOPS 5 … … 76 77 static int on_class_request(struct usbvirt_device *dev, 77 78 usb_device_request_setup_packet_t *request, uint8_t *data) 78 { 79 { 79 80 printf("%s: class request (%d)\n", NAME, (int) request->request); 80 81 … … 86 87 */ 87 88 static usbvirt_device_ops_t keyboard_ops = { 88 .on_devreq_class = on_class_request, 89 .standard_request_ops = &standard_request_ops, 90 .on_class_device_request = on_class_request, 89 91 .on_data = on_incoming_data 90 92 }; -
uspace/lib/usb/descriptor.h
rcbc00a4d r73301a0 45 45 USB_DESCTYPE_STRING = 3, 46 46 USB_DESCTYPE_INTERFACE = 4, 47 USB_DESCTYPE_ENDPOINT = 5 47 USB_DESCTYPE_ENDPOINT = 5, 48 USB_DESCTYPE_HID = 0x21, 49 USB_DESCTYPE_HID_REPORT = 0x22, 50 USB_DESCTYPE_HID_PHYSICAL = 0x23, 51 /* USB_DESCTYPE_ = */ 48 52 } usb_descriptor_type_t; 49 53 -
uspace/lib/usbvirt/ctrlpipe.c
rcbc00a4d r73301a0 68 68 break; 69 69 case REQUEST_TYPE_CLASS: 70 if (DEVICE_HAS_OP(device, on_ devreq_class)) {71 return device->ops->on_ devreq_class(device,70 if (DEVICE_HAS_OP(device, on_class_device_request)) { 71 return device->ops->on_class_device_request(device, 72 72 request, remaining_data); 73 73 } -
uspace/lib/usbvirt/device.h
rcbc00a4d r73301a0 46 46 uint8_t *data); 47 47 48 /** Callbacks for standard device requests. 49 * When these functions are NULL or return EFORWARD, this 50 * framework will try to satisfy the request by itself. 51 */ 52 typedef struct { 53 usbvirt_on_device_request_t on_get_status; 54 usbvirt_on_device_request_t on_clear_feature; 55 usbvirt_on_device_request_t on_set_feature; 56 usbvirt_on_device_request_t on_set_address; 57 usbvirt_on_device_request_t on_get_descriptor; 58 usbvirt_on_device_request_t on_set_descriptor; 59 usbvirt_on_device_request_t on_get_configuration; 60 usbvirt_on_device_request_t on_set_configuration; 61 usbvirt_on_device_request_t on_get_interface; 62 usbvirt_on_device_request_t on_set_interface; 63 usbvirt_on_device_request_t on_synch_frame; 64 } usbvirt_standard_device_request_ops_t; 65 48 66 /** Device operations. */ 49 67 typedef struct { 50 /** Callback for standard USB request. 51 * Called only when the request could not be handled by this 52 * framework. 53 */ 54 usbvirt_on_device_request_t on_devreq_std; 68 /** Callbacks for standard deivce requests. */ 69 usbvirt_standard_device_request_ops_t *standard_request_ops; 55 70 /** Callback for class-specific USB request. */ 56 usbvirt_on_device_request_t on_ devreq_class;71 usbvirt_on_device_request_t on_class_device_request; 57 72 /** Callback for all other incoming data. */ 58 73 int (*on_data)(struct usbvirt_device *dev, -
uspace/lib/usbvirt/stdreq.c
rcbc00a4d r73301a0 123 123 } 124 124 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 125 142 int handle_std_request(usb_device_request_setup_packet_t *request, uint8_t *data) 126 143 { 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)); 128 148 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)); 145 153 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; 158 155 } 159 156
Note:
See TracChangeset
for help on using the changeset viewer.