Changeset 5079242 in mainline for uspace/drv/usbhid/hidreq.c


Ignore:
Timestamp:
2011-03-06T00:15:00Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
40a5d40
Parents:
eae83aa (diff), d20f211 (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:

Development branch changes

File:
1 edited

Legend:

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

    reae83aa r5079242  
    143143/*----------------------------------------------------------------------------*/
    144144
     145int usbhid_req_set_idle(usbhid_dev_t *hid_dev, uint8_t duration)
     146{
     147        if (hid_dev == NULL) {
     148                usb_log_error("usbhid_req_set_idle(): no HID device "
     149                    "structure given.\n");
     150                return EINVAL;
     151        }
     152       
     153        /*
     154         * No need for checking other parameters, as they are checked in
     155         * the called function (usb_control_request_set()).
     156         */
     157       
     158        int rc, sess_rc;
     159       
     160        sess_rc = usb_endpoint_pipe_start_session(&hid_dev->ctrl_pipe);
     161        if (sess_rc != EOK) {
     162                usb_log_warning("Failed to start a session: %s.\n",
     163                    str_error(sess_rc));
     164                return sess_rc;
     165        }
     166
     167        usb_log_debug("Sending Set_Idle request to the device ("
     168            "duration: %u, iface: %d).\n", duration, hid_dev->iface);
     169       
     170        uint16_t value = duration << 8;
     171       
     172        rc = usb_control_request_set(&hid_dev->ctrl_pipe,
     173            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     174            USB_HIDREQ_SET_IDLE, value, hid_dev->iface, NULL, 0);
     175
     176        sess_rc = usb_endpoint_pipe_end_session(&hid_dev->ctrl_pipe);
     177
     178        if (rc != EOK) {
     179                usb_log_warning("Error sending output report to the keyboard: "
     180                    "%s.\n", str_error(rc));
     181                return rc;
     182        }
     183
     184        if (sess_rc != EOK) {
     185                usb_log_warning("Error closing session: %s.\n",
     186                    str_error(sess_rc));
     187                return sess_rc;
     188        }
     189       
     190        return EOK;
     191}
     192
     193/*----------------------------------------------------------------------------*/
     194
    145195/**
    146196 * @}
Note: See TracChangeset for help on using the changeset viewer.