1
0
Fork 0
Commit Graph

1238 Commits (d6b09e754c23b657544f6e7f39fbf7de24c58aa2)

Author SHA1 Message Date
Jiri Kosina c062c4d1de Merge branch 'uhid' into for-linus
Conflicts:
	drivers/hid/Kconfig
2012-07-24 13:40:06 +02:00
Jiri Kosina 929bd380b7 Merge branches 'hidraw', 'magicmouse', 'multitouch', 'roccat', 'suspend-fixes' and 'upstream' into for-linus 2012-07-24 13:39:00 +02:00
Cyrus Lien 2d8767bb42 HID: add ASUS AIO keyboard model AK1D
Add Asus All-In-One PC keyboard model AK1D.

BugLink: https://bugs.launchpad.net/bugs/1027789

Signed-off-by: Cyrus Lien <cyrus.lien@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-23 12:10:21 +02:00
Lionel Vaux 76c9d8fe2c HID: add support for Cypress barcode scanner 04B4:ED81
Add yet another device to the list of Cypress barcode scanners
needing the CP_RDESC_SWAPPED_MIN_MAX quirk.

Signed-off-by: Lionel Vaux (iouri) <lionel.vaux@free.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-22 11:32:24 +02:00
David Herrmann 4bc19f62c5 HID: Allow drivers to be their own listener
hid-picolcd and hid-wiimote do not allow any of hidinput, hiddev or hidraw
to claim the device but still want to remain on the bus. Hence, if a
driver uses the raw_event callback but no other listener claimed the
device, we still leave it on the bus as the driver handles everything by
itself. It thus becomes its own listener.

Under some circumstances (eg., hidinput_connect() fails and raw_event set)
a device may be left on the bus even though it requires external
listeners. But then if hidinput_connect() fails there are bigger issues
than a device that is left unhandled. So we can safely use this heuristic
to avoid adding another flag for special devices like hid-picolcd and
hid-wiimote.

This also removes the ugly hack from hid-picolcd as this is no longer
required.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 14:32:00 +02:00
Alan Stern eb055fd056 HID: usbhid: fix error paths in suspend
This patch (as1597) fixes some of the error paths in usbhid's suspend
routine.  The driver was not careful to restart everything that might
have been stopped, in cases where a suspend failed.

For example, once the HID_SUSPENDED flag is set, an output report
submission would not restart the corresponding URB queue.  If a
suspend fails, it's therefore necessary to check whether the queues
need to be restarted.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 11:24:25 +02:00
Alan Stern d4150c8f3d HID: usbhid: check for suspend or reset before restarting
This patch (as1596) improves the queue-restart logic in usbhid by
checking to see if the device is suspended or a reset is about to
occur.  There's no point submitting an URB if either of those is
true.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 11:24:25 +02:00
Alan Stern f2b5264d4f HID: usbhid: replace HID_REPORTED_IDLE with HID_SUSPENDED
This patch (as1595) improves the usbhid driver by using the
HID_SUSPENDED bitflag to indicate that the device is suspended rather
than using HID_REPORTED_IDLE, which the patch removes.

Since HID_SUSPENDED was not being used for anything, and since the
name "HID_REPORTED_IDLE" doesn't convey much meaning, the end result
is easier to read and understand.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 11:24:24 +02:00
Alan Stern 93101af31b HID: usbhid: inline some simple routines
This patch (as1594) simplifies the usbhid driver by inlining a couple
of routines.  As a result of an earlier patch, irq_out_pump_restart()
and ctrl_pump_restart() are each used in only one place.  Since they
don't really do what their names say, and since they each involve only
about two lines of actual code, there's no reason to keep them as
separate functions.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 11:24:24 +02:00
Alan Stern 01a7c984e8 HID: usbhid: fix autosuspend calls
This patch (as1593) fixes some logic errors in the usbhid driver
relating to runtime PM.  The driver does not balance its calls to
usb_autopm_get_interface_async() and usb_autopm_put_interface_async().

For example, when the control queue is restarted the driver does a
_get.  But the resume won't happen immediately, so the driver leaves
the queue stopped.  When the resume does occur, the queue is restarted
and a second _get occurs, with no balancing _put.

The patch fixes the problem by rearranging the logic for restarting
the queues.  All the _get/_put calls and bitflag settings in
__usbhid_submit_report() are moved into the queue-restart routines.  A
balancing _put call is added for the case where the queue is still
suspended.  A call to irq_out_pump_restart(), which doesn't take all
the right actions for restarting the irq-OUT queue, is replaced by a
call to usbhid_restart_out_queue(), which does.  Similarly for
ctrl_pump_restart().

Finally, new code is added to prevent an autosuspend from happening
every time an URB is cancelled, and the comments explaining what
happens when an URB needs to be cancelled are expanded and clarified.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 11:24:24 +02:00
Alan Stern 668160e5a8 HID: usbhid: fix use-after-free bug
This patch (as1592) fixes an obscure problem in the usbhid driver.
Under some circumstances, a control or interrupt-OUT URB can be
submitted twice.  This will happen if the first submission fails; the
queue pointers aren't updated, so the next time the queue is restarted
the same URB will be submitted again.

The problem is that raw_report gets deallocated during the first
submission.  The second submission will then dereference and try to
free an already-freed region of memory.  The patch fixes the problem
by setting raw_report to NULL when it is deallocated and checking for
NULL before dereferencing it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 11:24:23 +02:00
Matthieu CASTET b94e3c94aa HID: hid-core: optimize in case of hidraw
When using hidraw, hid buffer can be big and take lot's of
time to process (interrupt) kernel context.
Don't try to parse report if we are only interrested in hidraw.

Also don't prepare data for debug stuff if no debugfs file
are opened.

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 10:02:24 +02:00
Matthieu CASTET 4c7b417ecb HID: hidraw: fix list->buffer memleak
If we don't read fast enough hidraw device, hidraw_report_event
will cycle and we will leak list->buffer.
Also list->buffer are not free on release.
After this patch, kmemleak report nothing.

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 10:02:23 +02:00
Vinicius Costa Gomes adefb69b1b HID: uhid: Fix sending events with invalid data
This was detected because events with invalid types were arriving
to userspace.

The code before this patch would only work for the first event in the
queue (when uhid->tail is 0).

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Reviewed-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 09:53:45 +02:00
Stefan Achatz 11a5c818ae HID: roccat: added sensor sysfs attribute for Savu
The sensor attr can be used to tweak the optical sensor of the Savu.

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-20 09:50:42 +02:00
Linus Torvalds 61c901c569 Merge branch 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID update from Jiri Kosina:
 "A final round of changes for HID for 3.5: just device ID additions."

* 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid:
  HID: hid-multitouch: add support for Zytronic panels
  HID: add Sennheiser BTD500USB device support
  HID: add battery quirk for Apple Wireless ANSI
2012-07-19 08:15:55 -07:00
Benjamin Tissoires e9a09aed3e HID: hid-multitouch: add support for Zytronic panels
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-19 13:56:16 +02:00
Linus Torvalds 39ea32ca7e Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input layer fixes from Dmitry Torokhov:
 "The changes are limited to adding new VID/PID combinations to drivers
  to enable support for new versions of hardware, most notably hardware
  found in new MacBook Pro Retina boxes."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: xpad - add Andamiro Pump It Up pad
  Input: xpad - add signature for Razer Onza Tournament Edition
  Input: xpad - handle all variations of Mad Catz Beat Pad
  Input: bcm5974 - Add support for 2012 MacBook Pro Retina
  HID: add support for 2012 MacBook Pro Retina
2012-07-13 10:33:18 -07:00
Tom Harwood ff9bf5a2ef HID: Add driver for Holtek based keyboards with broken HID
Corrects two HID descriptor issues, which prevent some Holtek based
(USB ID 04d9:a055) keyboards from working. The error when not using
the driver is: generic-usb: probe ... failed with error -22 .

Signed-off-by: Tom Harwood <tomharwood@fastmail.fm>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-12 12:34:43 +02:00
Yuri Khan 3ffb62cb9a Input: xpad - handle all variations of Mad Catz Beat Pad
The device should be handled by xpad driver instead of generic HID driver.

Signed-off-by: Yuri Khan <yurivkhan@gmail.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-07-11 00:54:49 -07:00
Ryan Bourgeois b2e6ad7dfe HID: add support for 2012 MacBook Pro Retina
Add support for the 15'' MacBook Pro Retina. The keyboard is
the same as recent models.

The patch needs to be synchronized with the bcm5974 patch for
the trackpad - as usual.

Patch originally written by clipcarl (forums.opensuse.org).

[rydberg@euromail.se: Amended mouse ignore lines]
Signed-off-by: Ryan Bourgeois <bluedragonx@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2012-07-10 09:44:59 -07:00
Keng-Yu Lin 929578ab03 HID: Add suport for the brightness control keys on HP keyboards
The keys are found on the keyboards bundled with HP All-In-One machines
with USB VID/PID of 04ca:004d and 04f2:1061.

Signed-off-by: Keng-Yu Lin <kengyu@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-09 16:23:33 +02:00
Frank Kunz 0e050923a7 HID: add Sennheiser BTD500USB device support
The Sennheiser BTD500USB composit device requires the
HID_QUIRK_NOGET flag to be set for working proper. Without the
flag the device crashes during hid intialization.

Signed-off-by: Frank Kunz <xxxxxmichl@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-09 16:21:32 +02:00
Yufeng Shen a6d1bc1d5f HID: magicmouse: Implement Multi-touch Protocol B (MT-B)
The driver for Apple Magic Trackpad/Mouse currently uses
Multi-touch Protocol A (MT-A) to report touch events and uses
ABS_MT_TRACKING_ID to do finger tracking. The fact of the device
being able to track individual finger makes it possible to
report touch events using MT-B. This patch converts the driver
to use MT-B as it is preferred to MT-A.

V4: Removed BTN_TOUCH evnet.
V3: Removed the single touch related logic.
V2: Converting entirely to MT-B as Henrik Rydberg suggested.

Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-and-tested-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-04 20:58:48 +02:00
Yufeng Shen 6264307ed0 HID: magicmouse: Removing report_touches switch
Remove the report_touches switch as it is not so useful to turn
off reporting touch events for a touch device. Let the userspace
to do the filtering if the turning off is needed.

V2: Remove report_touches as suggeted by Chase Douglas

Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-and-tested-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-04 20:58:48 +02:00
Daniel Nicoletti 0c47935c5b HID: add battery quirk for Apple Wireless ANSI
Add USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, to the quirk list since it report
wrong feature type and wrong percentage range.

Signed-off-by: Daniel Nicoletti <dantti12@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-07-04 15:46:25 +02:00
Stefan Achatz 7392d73be2 HID: roccat: rename roccat_common functions to roccat_common2
Did this to illustrate my understanding of the firmware generations:
Valo and Kone were 1st generation
Arvo was externaly developed and lies in the middle
All others until now are considered 2nd generation

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-28 10:34:01 +02:00
Stefan Achatz 4ec141ad4e HID: roccat: fix wrong hid_err usage on struct usb_device
Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-28 10:34:01 +02:00
Stefan Achatz 4728f2dc9f HID: roccat: move functionality to roccat-common
Reduced code duplication by moving functions from individual drivers
to roccat-common module.

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-28 10:34:01 +02:00
Stefan Achatz 6a2a6390cf HID: roccat: add support for Roccat Savu
This patch adds rupport for Roccat Savu gaming mouse.

In comparison to the other Roccat modules I tried to move even more
functionality to userland.

Userland tools can soon be found at http://sourceforge.net/projects/roccat

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-28 10:34:01 +02:00
Benjamin Tissoires 82d069822f HID: hid-multitouch: add support for Zytronic panels
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-28 10:29:55 +02:00
Benjamin Tissoires 4aceed37e3 HID: hid-multitouch: fix input mode feature command
Zytronic panels shows a new way of setting the Input Mode feature.
This feature is put in the second usage in the HID feature, instead
of the first, as the majority of the multitouch devices.

This patch adds a detection step when the feature is presented to know
where the feature is located in the report. We can then trigger the right
command to the device. This removes the magic number "0" in the function
mt_set_input_mode.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-28 10:29:38 +02:00
Linus Torvalds 60d2c25251 Merge branch 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID fixes from Jiri Kosina:
 "The most important one is a purification of Kconfig for CONFIG_HID;
  the inclusion of HID groups and autoloading didn't leave the Kconfig
  in a really consistent state.  Henrik's patch fixes that.  In addition
  to that, there are two small fixes for logitech and magicmouse
  drivers."

* 'upstream-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid:
  HID: Fix the generic Kconfig options
  HID: magicmouse: Correct report range of major / minor axes
  HID: logitech: don't use stack based dj_report structures
2012-06-26 11:23:41 -07:00
Linus Torvalds aace99e57c Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab.

Trivial conflict due to new USB HID ID's being added next to each other
(Baanto vs Axentia).

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (44 commits)
  [media] smia: Fix compile failures
  [media]  Fix VIDIOC_DQEVENT docbook entry
  [media] s5p-fimc: Fix control creation function
  [media] s5p-mfc: Fix checkpatch error in s5p_mfc_shm.h file
  [media] s5p-mfc: Fix setting controls
  [media] v4l/s5p-mfc: added image size align in VIDIOC_TRY_FMT
  [media] v4l/s5p-mfc: corrected encoder v4l control definitions
  [media] v4l: mem2mem_testdev: Fix race conditions in driver
  [media] s5p-mfc: Bug fix of timestamp/timecode copy mechanism
  [media] cxd2820r: Fix an incorrect modulation type bitmask
  [media] em28xx: Show a warning if the board does not support remote controls
  [media] em28xx: Add remote control support for Terratec's Cinergy HTC Stick HD
  [media] USB: Staging: media: lirc: initialize spinlocks before usage
  [media] Revert "[media] media: mx2_camera: Fix mbus format handling"
  [media] bw-qcam: driver and pixfmt documentation fixes
  [media] cx88: fix firmware load on big-endian systems
  [media] cx18: support big-endian systems
  [media] ivtv: fix support for big-endian systems
  [media] tuner-core: return the frequency range of the correct tuner
  [media] v4l2-dev.c: fix g_parm regression in determine_valid_ioctls()
  ...
2012-06-25 14:53:09 -07:00
Henrik Rydberg 1f41a6a994 HID: Fix the generic Kconfig options
The generic HID driver is obviously not a special driver, so move it
outside of the special drivers menu. Explain the usage and make the
default follow the HID setting. This should simplify migration from
older kernels. While at it, remove the redundant HID_SUPPORT option
and modify the HID and USB_HID entries to better explain the bus
structure.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-25 17:25:00 +02:00
Yufeng Shen e75561b3d2 HID: magicmouse: Correct report range of major / minor axes
In patch "HID: magicmouse: Adjust major / minor axes to scale",
touch_major and touch_minor axes are scaled by a factor of
four when reported but the max touch_major/minor is not scaled
accordingly. This patch scales the max touch_major/minor to
be consistent with the reported value.

Signed-off-by: Yufeng Shen <miletus@chromium.org>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-25 15:30:15 +02:00
Jiri Kosina 1a8b294ce6 HID: uhid: silence gcc warning
gcc is giving me:

drivers/hid/uhid.c: In function ‘uhid_hid_get_raw’:
drivers/hid/uhid.c:157: warning: ‘len’ may be used uninitialized in this function

which is clearly bogus, as

- when used as memcpy() argument, it's initialized properly
- the code is structured in a way that either 'ret' or 'len'
  is always initialized, so the return statement always has
  an initialized value.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 17:08:30 +02:00
Bryan Wu 25976a796c HID: select NEW_LEDS for driver of Lenovo ThinkPad USB Keyboard with TrackPoint
commit 'HID: Driver for Lenovo Keyboard with Trackpoint'
(c1dcad2d32) introduced a compiling error due to
unmetting dependency of CONFIG_LEDS_CLASS.

on i386:

ERROR: "led_brightness_set" [drivers/leds/led-class.ko] undefined!
ERROR: "leds_list" [drivers/leds/led-class.ko] undefined!
ERROR: "leds_list_lock" [drivers/leds/led-class.ko] undefined!

Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 15:28:05 +02:00
David Herrmann fcfcf0deb8 HID: uhid: implement feature requests
HID standard allows sending a feature request to the device which is
answered by an HID report. uhid implements this by sending a UHID_FEATURE
event to user-space which then must answer with UHID_FEATURE_ANSWER. If it
doesn't do this in a timely manner, the request is discarded silently.

We serialize the feature requests, that is, there is always only a single
active feature-request sent to user-space, other requests have to wait.
HIDP and USB-HID do it the same way.

Because we discard feature-requests silently, we must make sure to match
a response to the corresponding request. We use sequence-IDs for this so
user-space must copy the ID from the request into the answer.
Feature-answers are ignored if they do not contain the same ID as the
currently pending feature request.

Internally, we must make sure that feature-requests are synchronized with
UHID_DESTROY and close() events. We must not dead-lock when closing the
HID device, either, so we have to use separate locks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:03 +02:00
David Herrmann 3b3baa82e4 HID: uhid: forward raw output reports to user-space
Some drivers that use non-standard HID features require raw output reports
sent to the device. We now forward these requests directly to user-space
so the transport-level driver can correctly send it to the device or
handle it correspondingly.

There is no way to signal back whether the transmission was successful,
moreover, there might be lots of messages coming out from the driver
flushing the output-queue. However, there is currently no driver that
causes this so we are safe. If some drivers need to transmit lots of data
this way, we need a method to synchronize this and can implement another
UHID_OUTPUT_SYNC event.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:02 +02:00
David Herrmann f80e13601c HID: uhid: forward output request to user-space
If the hid-driver wants to send standardized data to the device it uses a
linux input_event. We forward this to the user-space transport-level
driver so they can perform the requested action on the device.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:02 +02:00
David Herrmann e7191474a5 HID: uhid: forward open/close events to user-space
HID core notifies us with *_open/*_close callbacks when there is an actual
user of our device. We forward these to user-space so they can react on
this. This allows user-space to skip I/O unless they receive an OPEN
event. When they receive a CLOSE event they can stop I/O again to save
energy.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:02 +02:00
David Herrmann ec4b7dea45 HID: uhid: add UHID_START and UHID_STOP events
We send UHID_START and UHID_STOP events to user-space when the HID core
starts/stops the device. This notifies user-space about driver readiness
and data-I/O can start now.

This directly forwards the callbacks from hid-core to user-space.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:01 +02:00
David Herrmann 037c061bca HID: uhid: forward hid report-descriptor to hid core
When the uhid_hid_parse callback is called we simply forward it to
hid_parse_report() with the data that we got in the UHID_CREATE event.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:01 +02:00
David Herrmann 5e87a36ae3 HID: uhid: allow feeding input data into uhid devices
This adds a new event type UHID_INPUT which allows user-space to feed raw
HID reports into the HID subsystem. We copy the data into kernel memory
and directly feed it into the HID core.

There is no error handling of the events couldn't be parsed so user-space
should consider all events successfull unless read() returns an error.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:01 +02:00
David Herrmann d365c6cfd3 HID: uhid: add UHID_CREATE and UHID_DESTROY events
UHID_CREATE and UHID_DESTROY are used to create and destroy a device on an
open uhid char-device. Internally, we allocate and register an HID device
with the HID core and immediately start the device. From now on events may
be received or sent to the device.

The UHID_CREATE event has a payload similar to the data used by
Bluetooth-HIDP when creating a new connection.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:01 +02:00
David Herrmann 6664ef72a4 HID: uhid: implement write() on uhid devices
Similar to read() you can only write() a single event with one call to an
uhid device. To write multiple events use writev() which is supported by
uhid.

We currently always return -EOPNOTSUPP but other events will be added in
later patches.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:00 +02:00
David Herrmann d937ae5fae HID: uhid: implement read() on uhid devices
User-space can use read() to get a single event from uhid devices. read()
does never return multiple events. This allows us to extend the event
structure and still keep backwards compatibility.

If user-space wants to get multiple events in one syscall, they should use
the readv()/writev() syscalls which are supported by uhid.

This introduces a new lock which helps us synchronizing simultaneous reads
from user-space. We also correctly return -EINVAL/-EFAULT only on errors
and retry the read() when some other thread captured the event faster than
we did.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:00 +02:00
David Herrmann 1f9dec1e01 HID: uhid: allow poll()'ing on uhid devices
As long as the internal buffer is not empty, we return POLLIN to
user-space.

uhid->head and uhid->tail are no atomics so the comparison may return
inexact results. However, this doesn't matter here as user-space would
need to poll() in two threads simultaneously to trigger this. And in this
case it doesn't matter if a cached result is returned or the exact new
result as user-space does not know which thread returns first from poll()
and the following read(). So it is safe to compare the values without
locking.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:00 +02:00
David Herrmann ace3d8614a HID: uhid: add internal message buffer
When receiving messages from the HID subsystem, we need to process them
and store them in an internal buffer so user-space can read() on the char
device to retrieve the messages.

This adds a static buffer for 32 messages to each uhid device. Each
message is dynamically allocated so the uhid_device structure does not get
too big.

uhid_queue() adds a message to the buffer. If the buffer is full, the
message is discarded. uhid_queue_event() is an helper for messages without
payload.

This also adds a public header: uhid.h. It contains the declarations for
the user-space API. It is built around "struct uhid_event" which contains
a type field which specifies the event type and each event can then add a
variable-length payload. For now, there is only a dummy event but later
patches will add new event types and payloads.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-06-18 13:42:00 +02:00