Changes in uspace/lib/usb/src/usbdrvreq.c [9b95dbcf:82783b0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/usbdrvreq.c
r9b95dbcf r82783b0 73 73 } 74 74 75 /** Retrieve USB descriptor of connected USB device.76 *77 * @param[in] hc_phone Open phone to HC driver.78 * @param[in] address Device USB address.79 * @param[in] request_type Request type (standard/class/vendor).80 * @param[in] descriptor_type Descriptor type (device/configuration/HID/...).81 * @param[in] descriptor_index Descriptor index.82 * @param[in] langauge Language index.83 * @param[out] buffer Buffer where to store the retrieved descriptor.84 * @param[in] size Size of the @p buffer.85 * @param[out] actual_size Number of bytes actually transferred.86 * @return Error code.87 */88 int usb_drv_req_get_descriptor(int hc_phone, usb_address_t address,89 usb_request_type_t request_type,90 uint8_t descriptor_type, uint8_t descriptor_index,91 uint16_t language,92 void *buffer, size_t size, size_t *actual_size)93 {94 /* Prepare the target. */95 usb_target_t target = {96 .address = address,97 .endpoint = 098 };99 100 /* Prepare the setup packet. */101 usb_device_request_setup_packet_t setup_packet = {102 .request_type = 128 | (request_type << 5),103 .request = USB_DEVREQ_GET_DESCRIPTOR,104 .index = language,105 .length = (uint16_t) size,106 };107 setup_packet.value_high = descriptor_type;108 setup_packet.value_low = descriptor_index;109 110 /* Perform CONTROL READ */111 int rc = usb_drv_psync_control_read(hc_phone, target,112 &setup_packet, sizeof(setup_packet),113 buffer, size, actual_size);114 115 return rc;116 }117 118 75 /** Retrieve device descriptor of connected USB device. 119 76 * … … 130 87 return EBADMEM; 131 88 } 132 89 90 /* Prepare the target. */ 91 usb_target_t target = { 92 .address = address, 93 .endpoint = 0 94 }; 95 96 /* Prepare the setup packet. */ 97 usb_device_request_setup_packet_t setup_packet = { 98 .request_type = 128, 99 .request = USB_DEVREQ_GET_DESCRIPTOR, 100 .index = 0, 101 .length = sizeof(usb_standard_device_descriptor_t) 102 }; 103 setup_packet.value_high = USB_DESCTYPE_DEVICE; 104 setup_packet.value_low = 0; 105 106 /* Prepare local descriptor. */ 133 107 size_t actually_transferred = 0; 134 108 usb_standard_device_descriptor_t descriptor_tmp; 135 int rc = usb_drv_req_get_descriptor(phone, address, 136 USB_REQUEST_TYPE_STANDARD, 137 USB_DESCTYPE_DEVICE, 0, 138 0, 139 &descriptor_tmp, sizeof(descriptor_tmp), 140 &actually_transferred); 109 110 /* Perform the control read transaction. */ 111 int rc = usb_drv_psync_control_read(phone, target, 112 &setup_packet, sizeof(setup_packet), 113 &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred); 141 114 142 115 if (rc != EOK) { … … 177 150 return EBADMEM; 178 151 } 179 152 153 /* Prepare the target. */ 154 usb_target_t target = { 155 .address = address, 156 .endpoint = 0 157 }; 158 159 /* Prepare the setup packet. */ 160 usb_device_request_setup_packet_t setup_packet = { 161 .request_type = 128, 162 .request = USB_DEVREQ_GET_DESCRIPTOR, 163 .index = 0, 164 .length = sizeof(usb_standard_configuration_descriptor_t) 165 }; 166 setup_packet.value_high = USB_DESCTYPE_CONFIGURATION; 167 setup_packet.value_low = index; 168 169 /* Prepare local descriptor. */ 180 170 size_t actually_transferred = 0; 181 171 usb_standard_configuration_descriptor_t descriptor_tmp; 182 int rc = usb_drv_req_get_descriptor(phone, address, 183 USB_REQUEST_TYPE_STANDARD, 184 USB_DESCTYPE_CONFIGURATION, 0, 185 0, 186 &descriptor_tmp, sizeof(descriptor_tmp), 187 &actually_transferred); 172 173 /* Perform the control read transaction. */ 174 int rc = usb_drv_psync_control_read(phone, target, 175 &setup_packet, sizeof(setup_packet), 176 &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred); 188 177 189 178 if (rc != EOK) { … … 225 214 } 226 215 227 int rc = usb_drv_req_get_descriptor(phone, address, 228 USB_REQUEST_TYPE_STANDARD, 229 USB_DESCTYPE_CONFIGURATION, 0, 230 0, 231 buffer, buffer_size, 232 actual_buffer_size); 216 /* Prepare the target. */ 217 usb_target_t target = { 218 .address = address, 219 .endpoint = 0 220 }; 221 222 /* Prepare the setup packet. */ 223 usb_device_request_setup_packet_t setup_packet = { 224 .request_type = 128, 225 .request = USB_DEVREQ_GET_DESCRIPTOR, 226 .index = 0, 227 .length = buffer_size 228 }; 229 setup_packet.value_high = USB_DESCTYPE_CONFIGURATION; 230 setup_packet.value_low = index; 231 232 /* Perform the control read transaction. */ 233 int rc = usb_drv_psync_control_read(phone, target, 234 &setup_packet, sizeof(setup_packet), 235 buffer, buffer_size, actual_buffer_size); 233 236 234 237 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.