diff options
author | Jiri Kosina <jkosina@suse.cz> | 2007-05-14 03:54:30 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2007-10-14 08:47:26 -0400 |
commit | efc493f9d5463d933a64a2758fbe6d9bb8300cbb (patch) | |
tree | 09f787fde23300b3b332cd2d1f352b677af28460 /drivers/hid/usbhid | |
parent | d773b33972a663cfaf066e966f87922a74088a1e (diff) |
USB HID: provide hook for hidraw write()
Add hook in usbhid for write() callback from hidraw. Sends the
report to the device through control pipe.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 0a1f2b52a12f..74b817d7968d 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -628,6 +628,28 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | |||
628 | return 0; | 628 | return 0; |
629 | } | 629 | } |
630 | 630 | ||
631 | static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count) | ||
632 | { | ||
633 | struct usbhid_device *usbhid = hid->driver_data; | ||
634 | struct usb_device *dev = hid_to_usb_dev(hid); | ||
635 | struct usb_interface *intf = usbhid->intf; | ||
636 | struct usb_host_interface *interface = intf->cur_altsetting; | ||
637 | int ret; | ||
638 | |||
639 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
640 | HID_REQ_SET_REPORT, | ||
641 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
642 | cpu_to_le16(((HID_OUTPUT_REPORT + 1) << 8) | *buf), | ||
643 | interface->desc.bInterfaceNumber, buf + 1, count - 1, | ||
644 | USB_CTRL_SET_TIMEOUT); | ||
645 | |||
646 | /* count also the report id */ | ||
647 | if (ret > 0) | ||
648 | ret++; | ||
649 | |||
650 | return ret; | ||
651 | } | ||
652 | |||
631 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | 653 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) |
632 | { | 654 | { |
633 | struct usbhid_device *usbhid = hid->driver_data; | 655 | struct usbhid_device *usbhid = hid->driver_data; |
@@ -871,6 +893,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
871 | hid->hiddev_hid_event = hiddev_hid_event; | 893 | hid->hiddev_hid_event = hiddev_hid_event; |
872 | hid->hiddev_report_event = hiddev_report_event; | 894 | hid->hiddev_report_event = hiddev_report_event; |
873 | #endif | 895 | #endif |
896 | hid->hid_output_raw_report = usbhid_output_raw_report; | ||
874 | return hid; | 897 | return hid; |
875 | 898 | ||
876 | fail: | 899 | fail: |