Changeset e69f10b in mainline for uspace/drv/usbhid/hiddev.c
- Timestamp:
- 2011-03-10T19:07:11Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a8def7d
- Parents:
- 7351dc3 (diff), 45dd8bf (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hiddev.c
r7351dc3 re69f10b 53 53 /* Non-API functions */ 54 54 /*----------------------------------------------------------------------------*/ 55 55 /** 56 * Retreives HID Report descriptor from the device. 57 * 58 * This function first parses the HID descriptor from the Interface descriptor 59 * to get the size of the Report descriptor and then requests the Report 60 * descriptor from the device. 61 * 62 * @param hid_dev HID device structure. 63 * @param config_desc Full configuration descriptor (including all nested 64 * descriptors). 65 * @param config_desc_size Size of the full configuration descriptor (in bytes). 66 * @param iface_desc Pointer to the interface descriptor inside the full 67 * configuration descriptor (@a config_desc) for the interface 68 * assigned with this device (@a hid_dev). 69 * 70 * @retval EOK if successful. 71 * @retval ENOENT if no HID descriptor could be found. 72 * @retval EINVAL if the HID descriptor or HID report descriptor have different 73 * size than expected. 74 * @retval ENOMEM if some allocation failed. 75 * @return Other value inherited from function usb_request_get_descriptor(). 76 * 77 * @sa usb_request_get_descriptor() 78 */ 56 79 static int usbhid_dev_get_report_descriptor(usbhid_dev_t *hid_dev, 57 80 uint8_t *config_desc, size_t config_desc_size, uint8_t *iface_desc) … … 143 166 144 167 /*----------------------------------------------------------------------------*/ 145 168 /** 169 * Retreives descriptors from the device, initializes pipes and stores 170 * important information from descriptors. 171 * 172 * Initializes the polling pipe described by the given endpoint description 173 * (@a poll_ep_desc). 174 * 175 * Information retreived from descriptors and stored in the HID device structure: 176 * - Assigned interface number (the interface controlled by this instance of 177 * the driver) 178 * - Polling interval (from the interface descriptor) 179 * - Report descriptor 180 * 181 * @param hid_dev HID device structure to be initialized. 182 * @param poll_ep_desc Description of the polling (Interrupt In) endpoint 183 * that has to be present in the device in order to 184 * successfuly initialize the structure. 185 * 186 * @sa usb_endpoint_pipe_initialize_from_configuration(), 187 * usbhid_dev_get_report_descriptor() 188 */ 146 189 static int usbhid_dev_process_descriptors(usbhid_dev_t *hid_dev, 147 190 usb_endpoint_description_t *poll_ep_desc) … … 242 285 /* API functions */ 243 286 /*----------------------------------------------------------------------------*/ 244 287 /** 288 * Creates new uninitialized HID device structure. 289 * 290 * @return Pointer to the new HID device structure, or NULL if an error occured. 291 */ 245 292 usbhid_dev_t *usbhid_dev_new(void) 246 293 { … … 269 316 270 317 /*----------------------------------------------------------------------------*/ 271 318 /** 319 * Properly destroys the HID device structure. 320 * 321 * @note Currently does not clean-up the used pipes, as there are no functions 322 * offering such functionality. 323 * 324 * @param hid_dev Pointer to the structure to be destroyed. 325 */ 272 326 void usbhid_dev_free(usbhid_dev_t **hid_dev) 273 327 { … … 292 346 293 347 /*----------------------------------------------------------------------------*/ 294 348 /** 349 * Initializes HID device structure. 350 * 351 * @param hid_dev HID device structure to be initialized. 352 * @param dev DDF device representing the HID device. 353 * @param poll_ep_desc Description of the polling (Interrupt In) endpoint 354 * that has to be present in the device in order to 355 * successfuly initialize the structure. 356 * 357 * @retval EOK if successful. 358 * @retval EINVAL if some argument is missing. 359 * @return Other value inherited from one of functions 360 * usb_device_connection_initialize_from_device(), 361 * usb_endpoint_pipe_initialize_default_control(), 362 * usb_endpoint_pipe_start_session(), usb_endpoint_pipe_end_session(), 363 * usbhid_dev_process_descriptors(). 364 * 365 * @sa usbhid_dev_process_descriptors() 366 */ 295 367 int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev, 296 368 usb_endpoint_description_t *poll_ep_desc) … … 352 424 * Get descriptors, parse descriptors and save endpoints. 353 425 */ 354 usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe); 426 rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe); 427 if (rc != EOK) { 428 usb_log_error("Failed to start session on the control pipe: %s" 429 ".\n", str_error(rc)); 430 return rc; 431 } 355 432 356 433 rc = usbhid_dev_process_descriptors(hid_dev, poll_ep_desc); 357 358 usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe); 359 if (rc != EOK) { 434 if (rc != EOK) { 435 /* TODO: end session?? */ 360 436 usb_log_error("Failed to process descriptors: %s.\n", 361 437 str_error(rc)); … … 363 439 } 364 440 441 rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe); 442 if (rc != EOK) { 443 usb_log_warning("Failed to start session on the control pipe: " 444 "%s.\n", str_error(rc)); 445 return rc; 446 } 447 365 448 hid_dev->initialized = 1; 366 449 usb_log_info("HID device structure initialized.\n");
Note:
See TracChangeset
for help on using the changeset viewer.