Changeset e69f10b in mainline for uspace/drv/usbhid/hiddev.c


Ignore:
Timestamp:
2011-03-10T19:07:11Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
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.
Message:

Merged changes from lelian/hidd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/hiddev.c

    r7351dc3 re69f10b  
    5353/* Non-API functions                                                          */
    5454/*----------------------------------------------------------------------------*/
    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 */
    5679static int usbhid_dev_get_report_descriptor(usbhid_dev_t *hid_dev,
    5780    uint8_t *config_desc, size_t config_desc_size, uint8_t *iface_desc)
     
    143166
    144167/*----------------------------------------------------------------------------*/
    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 */
    146189static int usbhid_dev_process_descriptors(usbhid_dev_t *hid_dev,
    147190    usb_endpoint_description_t *poll_ep_desc)
     
    242285/* API functions                                                              */
    243286/*----------------------------------------------------------------------------*/
    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 */
    245292usbhid_dev_t *usbhid_dev_new(void)
    246293{
     
    269316
    270317/*----------------------------------------------------------------------------*/
    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 */
    272326void usbhid_dev_free(usbhid_dev_t **hid_dev)
    273327{
     
    292346
    293347/*----------------------------------------------------------------------------*/
    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 */
    295367int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev,
    296368    usb_endpoint_description_t *poll_ep_desc)
     
    352424         * Get descriptors, parse descriptors and save endpoints.
    353425         */
    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        }
    355432       
    356433        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?? */
    360436                usb_log_error("Failed to process descriptors: %s.\n",
    361437                    str_error(rc));
     
    363439        }
    364440       
     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       
    365448        hid_dev->initialized = 1;
    366449        usb_log_info("HID device structure initialized.\n");
Note: See TracChangeset for help on using the changeset viewer.