Changeset 16ecc28 in mainline
- Timestamp:
- 2010-12-12T14:48:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 39c3d95d, 3b9f1fd
- Parents:
- 4c74ac3 (diff), 1f3158c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.ma
r4c74ac3 r16ecc28 1 1 10 usb&hub 2 10 usb&class=hub -
uspace/drv/usbkbd/usbkbd.ma
r4c74ac3 r16ecc28 1 1 10 usb&class=hid 2 10 usb&class=HID 3 10 usb&interface&class=HID 2 4 10 usb&hid -
uspace/lib/usb/src/recognise.c
r4c74ac3 r16ecc28 101 101 } 102 102 103 /** Add match ids based on configuration descriptor. 104 * 105 * @param hc Open phone to host controller. 106 * @param matches Match ids list to add matches to. 107 * @param address USB address of the attached device. 108 * @return Error code. 109 */ 110 static int usb_add_config_descriptor_match_ids(int hc, 111 match_id_list_t *matches, usb_address_t address, 112 int config_count) 113 { 114 int final_rc = EOK; 115 116 int config_index; 117 for (config_index = 0; config_index < config_count; config_index++) { 118 int rc; 119 usb_standard_configuration_descriptor_t config_descriptor; 120 rc = usb_drv_req_get_bare_configuration_descriptor(hc, 121 address, config_index, &config_descriptor); 122 if (rc != EOK) { 123 final_rc = rc; 124 continue; 125 } 126 127 size_t full_config_descriptor_size; 128 void *full_config_descriptor 129 = malloc(config_descriptor.total_length); 130 rc = usb_drv_req_get_full_configuration_descriptor(hc, 131 address, config_index, 132 full_config_descriptor, config_descriptor.total_length, 133 &full_config_descriptor_size); 134 if (rc != EOK) { 135 final_rc = rc; 136 continue; 137 } 138 if (full_config_descriptor_size 139 != config_descriptor.total_length) { 140 final_rc = ERANGE; 141 continue; 142 } 143 144 /* 145 * Iterate through config descriptor to find the interface 146 * descriptors. 147 */ 148 size_t position = sizeof(config_descriptor); 149 while (position + 1 < full_config_descriptor_size) { 150 uint8_t *current_descriptor 151 = ((uint8_t *) full_config_descriptor) + position; 152 uint8_t cur_descr_len = current_descriptor[0]; 153 uint8_t cur_descr_type = current_descriptor[1]; 154 155 position += cur_descr_len; 156 157 if (cur_descr_type != USB_DESCTYPE_INTERFACE) { 158 continue; 159 } 160 /* 161 * Finally, we found an interface descriptor. 162 */ 163 usb_standard_interface_descriptor_t *interface 164 = (usb_standard_interface_descriptor_t *) 165 current_descriptor; 166 167 rc = usb_add_match_id(matches, 50, 168 "usb&interface&class=%s", 169 usb_str_class(interface->interface_class)); 170 if (rc != EOK) { 171 final_rc = rc; 172 break; 173 } 174 } 175 } 176 177 return final_rc; 178 } 179 103 180 /** Create match ids describing attached device. 104 181 * … … 149 226 150 227 /* 151 * If the device class does not point to interface, 152 * it is added immediatelly, otherwise full configuration 153 * descriptor must be obtained and parsed. 228 * If the device class points to interface we skip adding 229 * class directly. 154 230 */ 155 231 if (device_descriptor.device_class != USB_CLASS_USE_INTERFACE) { … … 159 235 return rc; 160 236 } 161 } else { 162 /* TODO */ 237 } 238 /* 239 * Go through all configurations and add matches 240 * based on interface class. 241 */ 242 rc = usb_add_config_descriptor_match_ids(hc, matches, 243 address, device_descriptor.configuration_count); 244 if (rc != EOK) { 245 return rc; 163 246 } 164 247
Note:
See TracChangeset
for help on using the changeset viewer.