Commit graph

1801 commits

Author SHA1 Message Date
Jiri Kosina
c16527cdcc Merge branch 'for-3.15/hid-cp2112' into for-3.15/hid-core-ll-transport-cleanup 2014-03-14 15:27:36 +01:00
Benjamin Tissoires
3a75b24949 HID: hidraw: replace hid_output_raw_report() calls by appropriates ones
Remove hid_output_raw_report() call as it is not a ll_driver callbacj,
and switch to the hid_hw_* implementation. USB-HID used to fallback
into SET_REPORT when there were no output interrupt endpoint,
so emulating this if hid_hw_output_report() returns -ENOSYS.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-24 17:23:15 +01:00
Benjamin Tissoires
3c86726cfe HID: make .raw_request mandatory
SET_REPORT and GET_REPORT are mandatory in the HID specification.
Make the corresponding API in hid-core mandatory too, which removes the
need to test against it in some various places.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-24 17:23:15 +01:00
Benjamin Tissoires
2ebaebcf31 HID: input: hid-input remove hid_output_raw_report call
hid_output_raw_report() is not a ll_driver callback and should not be used.
To keep the same code path than before, we are forced to play with the
different hid_hw_* calls: if the usb or i2c device does not support
direct output reports, then we will rely on the SET_REPORT HID call.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-24 17:23:14 +01:00
Jiri Kosina
0438ee7080 HID: cp2112: fix incorrect error propagation in cp2112_xfer()
Both cp2112_read_req() and cp2112_write_req() are returning negative
value in cases of error, but cp2112_xfer() is storing the return
value into unsigned size_t-typed 'count'.

Fix this by making 'count' signed type.

Reported-by: fengguang.wu@intel.com
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-18 09:43:53 +01:00
Jiri Kosina
a47dc4d8cf HID: cp2112: can't be used without gpio support
Add Kconfig driver dependency on GPIOLIB.

Reported-by: fengguang.wu@intel.com
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-18 09:40:17 +01:00
Jiri Kosina
490051ad16 HID: cp2112: convert to use hid_hw_raw_request()
Commit cafebc0 ("HID: remove hid_get_raw_report in struct hid_device")
obsoletes the use of hdev->hid_get_raw_report(), as calling
hid_hw_raw_request() is functionally equivalent.

Convert cp2112 to use this notation.

Reported-by: fengguang.wu@intel.com
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-18 00:39:39 +01:00
Jiri Kosina
d6a611f5e3 Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-3.15/hid-cp2112 2014-02-18 00:37:07 +01:00
Jiri Kosina
5a673fce04 HID: cp2112: use proper specifier for size_t
%zd is a proper format string specifier for size_t

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 23:44:54 +01:00
Jiri Kosina
c3c041ba4c HID: cp2112: make sysfs attributes static
No need to pollute namespace with dev_attr_*.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 23:40:20 +01:00
David Barksdale
e932d81786 HID: add hid-cp2112 driver
This patch adds support for the Silicon Labs CP2112 "Single-Chip HID USB to
SMBus Master Bridge."

This is a HID device driver which registers as an i2c adapter and gpiochip to
expose these functions of the CP2112. The customizable USB descriptor fields
are exposed as sysfs attributes.  The SMBus byte-read, byte-data-read/write,
and word-data-read transfer modes have been tested by talking to an i2c
sensor.  The GPIO functions and USB descriptor field programming have also
been tested.

Signed-off-by: David Barksdale <dbarksdale@uplogix.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 23:33:17 +01:00
Benjamin Tissoires
5318251744 HID: core: check parameters when sending/receiving data from the device
It is better to check them soon enough before triggering any kernel panic.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:58:59 +01:00
Benjamin Tissoires
7e0bc880fc HID: wiimote: replace hid_output_raw_report with hid_hw_output_report for output requests
For BT transport layer,
  ret = hid_output_raw_report(A, B, C, HID_OUTPUT_REPORT);
is equivalent to
  ret = hid_hw_output_report(A, B, C);

So use the new API where available

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:57:17 +01:00
Benjamin Tissoires
b0dd72aafd HID: replace hid_output_raw_report with hid_hw_raw_request for feature requests
ret = hid_output_raw_report(A, B, C, HID_FEATURE_REPORT);
is equivalent to
  ret = hid_hw_raw_request(A, B[0], B, C, HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
whatever the transport layer is.

So use the new API where available

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:56:50 +01:00
Benjamin Tissoires
bd27e202c6 HID: logitech-dj: remove hid_output_raw_report call
hid-input do not use anymore hid_output_raw_report() to set the LEDs.
Use the correct implementation now and make them working again.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:55:52 +01:00
Benjamin Tissoires
ddea1af9d9 HID: usbhid: change return error of usbhid_output_report
If there is no urbout when sending a output report, ENOSYS (Function
not implemented) is a better error than EIO (I/O error).

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:55:00 +01:00
Benjamin Tissoires
649f947903 HID: i2c-hid: use generic .request() implementation
Having our own .request() implementation does not give anything,
so use the generic binding.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:54:20 +01:00
Benjamin Tissoires
9b5a9ae885 HID: i2c-hid: implement ll_driver transport-layer callbacks
Add output_report and raw_request to i2c-hid.
The current implementation of i2c_hid_output_raw_report decides
by itself if it should use a direct send of the output report
or use the data register (SET_REPORT). Split that by reimplement
the logic in __i2c_hid_output_raw_report() which will be dropped
soon.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:53:09 +01:00
Benjamin Tissoires
4fa5a7f76c HID: core: implement generic .request()
.request() can be emulated through .raw_request()
we can implement this emulation in hid-core, and make .request
not mandatory for transport layer drivers.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:52:51 +01:00
Benjamin Tissoires
706daeffaf HID: uHID: implement .raw_request
uHID is missing a SET_REPORT protocol implementation, but as
.hid_get_raw_report() as been removed from struct hid_device,
there were no means to access GET_REPORT in uhid.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:51:41 +01:00
Jiri Kosina
289a716217 HID: uhid: reintroduce uhid_hid_get_raw()
This reverts commit 4a76d370f0. Removing
it was a mistake, as we need a means to access GET_REPORT.

Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:49:34 +01:00
Benjamin Tissoires
41abfb3600 HID: uHID: remove duplicated code
uhid_hid_output_report() can be implemented through a simple call
to uhid_hid_output_raw().

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:49:22 +01:00
Jiri Kosina
4a76d370f0 HID: uhid: remove uhid_hid_get_raw()
This function is now unused since cafebc058b ("HID: remove
hid_get_raw_report in struct hid_device").

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:15:48 +01:00
Benjamin Tissoires
7e845d46b1 HID: introduce helper to access hid_output_raw_report()
Add a helper to access hdev->hid_output_raw_report().

To convert the drivers, use the following snippets:

for i in drivers/hid/*.c
do
  sed -i.bak "s/[^ \t]*->hid_output_raw_report(/hid_output_raw_report(/g" $i
done

Then manually fix for checkpatch.pl

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:05:59 +01:00
Benjamin Tissoires
cafebc058b HID: remove hid_get_raw_report in struct hid_device
dev->hid_get_raw_report(X) and hid_hw_raw_request(X, HID_REQ_GET_REPORT)
are strictly equivalent. Switch the hid subsystem to the hid_hw notation
and remove the field .hid_get_raw_report in struct hid_device.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:05:58 +01:00
Benjamin Tissoires
f9bcca4056 HID: usbhid: remove duplicated code
Well, no use to keep twice the same code.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:05:57 +01:00
Benjamin Tissoires
b40272e4d0 HID: remove hidinput_input_event handler
All the different transport drivers use now the generic event handling
in hid-input. We can remove the handler definitively now.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:05:56 +01:00
Benjamin Tissoires
0e40d35637 HID: logitech-dj: remove hidinput_input_event
hid-logitech-dj uses its own ->hidinput_input_event() instead of
the generic binding in hid-input.
Moving the handling of LEDs towards logi_dj_output_hidraw_report()
allows two things:
- remove hidinput_input_event in struct hid_device
- hidraw user space programs can also set the LEDs

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 14:05:55 +01:00
Frank Praznik
596cfdd80a HID: Add the transport-driver function to the uhid driver
Add the uhid_output_report transport-driver function to the uhid driver.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Acked-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-29 14:23:42 +01:00
Frank Praznik
975a683271 HID: Add transport-driver functions to the USB HID interface.
Add raw_request, set_raw_report and output_report transport-driver functions to
the USB HID driver.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Acked-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-29 14:23:42 +01:00
Jiri Kosina
62813858fb Merge branches 'for-3.13/upstream-fixes', 'for-3.14/i2c-hid', 'for-3.14/sensor-hub', 'for-3.14/sony' and 'for-3.14/upstream' into for-linus 2014-01-22 15:40:14 +01:00
Frank Praznik
61ebca937f HID: sony: Use colors for the Dualshock 4 LED names
Use the naming scheme 'devicename:colour' for the Dualshock 4
LED lightbar controls as specified in Documentation/leds/leds-class.txt

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-21 07:59:17 +01:00
Frank Praznik
58d7027b7f HID: sony: Add annotated HID descriptor for the Dualshock 4
Add annotated HID descriptor for the Dualshock 4.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-21 07:59:16 +01:00
Frank Praznik
c4e1ddf268 HID: sony: Cache the output report for the Dualshock 4
Retrieve and cache the output report for the Dualshock 4 in sony_probe()
instead of repeatedly walking the report list in the worker function.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-20 13:01:31 +01:00
Frank Praznik
ed19d8cf28 HID: sony: Map gyroscopes and accelerometers to axes
Use a modified HID descriptor for the Dualshock 4 to assign the gyroscope
sensors and accelerometers to axes.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-17 10:47:41 +01:00
Frank Praznik
6c79c18c97 HID: sony: Fix spacing in the device definitions.
Fix cosmetic spacing in the device definitions.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-17 10:47:41 +01:00
Frank Praznik
0da8ea6581 HID: sony: Use standard output reports instead of raw reports to send data to the Dualshock 4.
Use regular HID output reports instead of raw reports in the
dualshock4_state_worker function.  (Thanks Simon Mungewell)

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-17 10:47:41 +01:00
Frank Praznik
8ab1676b61 HID: sony: Use separate identifiers for USB and Bluetooth connected Dualshock 4 controllers.
Use separate identifiers for Dualshock 4 controllers connected via USB and
Bluetooth.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-17 10:47:40 +01:00
Kharlamov Alexey
274be3eb65 HID: hid-holtek-mouse: add new a070 mouse
Added support of RITMIX ROM-316 mouse to hid-holtek-mouse workaround module

Signed-off-by: Alexey Kharlamov <derlafff@ya.ru>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-16 22:58:43 +01:00
Srinivas Pandruvada
875e36f8a2 HID: hid-sensor-hub: Fix buggy report descriptors
This addresses regression caused by commit id "751d17e23a9f7"
 iio: hid-sensors: Fix power and report state.
This commit removed a quirk, to change the enumeration base
to 1 from 0 based on an CONFIG paramter. There was objection to
add more changes under this quirk, instead suggested to add an
HID quirk. But there is no easy way to add HID qurik as the
reports are not properly using collection class.

The solution was to use logical minimum, which is a correct way.
There were changes done in firmware to address this.

Unfortunately some devices, still use old FW and can't be upgraded
to newer version on Linux devices as there is no FW upgrade tool
available for Linux devices. So we need to fix report descriptors,
for such devices. This will not have any impact, if the FW uses
logical 1 as minimum.

In this patch we look for usage id for "power and report state", and
modify logical minimum value to 1.

Background on enum:
In the original HID sensor hub firmwares all Named array enums were
to 0-based. But the most recent hub implemented as 1-based,
because of the implementation by one of the major OS vendor.
Using logical minimum for the field as the base of enum. So we add
logical minimum to the selector values before setting those fields.
Some sensor hub FWs already changed logical minimum from 0 to 1
to reflect this and hope every other vendor will follow.
There is no easy way to add a common HID quirk for NAry elements,
even if the standard specifies these field as NAry, the collection
used to describe selectors is still just "logical".

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-16 22:52:34 +01:00
Benjamin Tisssoires
42c22dbf81 HID: logitech-dj: Fix USB 3.0 issue
This fix (not very clean though) should fix the long time USB3
issue that was spotted last year. The rational has been given by
Hans de Goede:

 ----

I think the most likely cause for this is a firmware bug
in the unifying receiver, likely a race condition.

The most prominent difference between having a USB-2 device
plugged into an EHCI (so USB-2 only) port versus an XHCI
port will be inter packet timing. Specifically if you
send packets (ie hid reports) one at a time, then with
the EHCI controller their will be a significant pause
between them, where with XHCI they will be very close
together in time.

The reason for this is the difference in EHCI / XHCI
controller OS <-> driver interfaces.

For non periodic endpoints (control, bulk) the EHCI uses a
circular linked-list of commands in dma-memory, which it
follows to execute commands, if the list is empty, it
will go into an idle state and re-check periodically.

The XHCI uses a ring of commands per endpoint, and if the OS
places anything new on the ring it will do an ioport write,
waking up the XHCI making it send the new packet immediately.

For periodic transfers (isoc, interrupt) the delay between
packets when sending one at a time (rather then queuing them
up) will be even larger, because they need to be inserted into
the EHCI schedule 2 ms in the future so the OS driver can be
sure that the EHCI driver does not try to start executing the
time slot in question before the insertion has completed.

So a possible fix may be to insert a delay between packets
being send to the receiver.

 ----

I tested this on a buggy Haswell USB 3.0 motherboard, and I always
get the notification after adding the msleep.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-16 22:48:21 +01:00
Frank Praznik
cad665a2a9 HID: sony: Rename worker function
Rename sony_state_worker to sixaxis_state_worker since the function is now
sixaxis specific.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-16 22:44:35 +01:00
Frank Praznik
60781cf487 HID: sony: Add LED controls for the Dualshock 4
Add LED lightbar controls for the Dualshock 4.

The Dualshock 4 light bar has 3 separate RGB LEDs that can range in
brightness from 0 to 255 so a full byte is now needed to store each LED's
state

Changed the module to support an arbitrary number of LEDs instead of being
hardcoded to 4.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-16 22:44:35 +01:00
Frank Praznik
0bd88dd3dd HID: sony: Add force-feedback support for the Dualshock 4
Adds the Dualshock 4 to the HID device list and enables force-feedback.

Adds a Dualshock 4 specific worker function since the Dualshock 4 needs a
different report than the Sixaxis.

The right motor in the Dualshock 4 is variable so the full rumble value
is now passed to the worker function and clamped there if necessary.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-16 22:44:35 +01:00
Jiri Kosina
618345359e HID: hidraw: make comment more accurate and nicer
Reformat and reword some of the comments to make them more understandable.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-06 16:43:27 +01:00
Julia Lawall
8cd5fcda24 HID: sony: fix error return code
Currently the return variable ret is always 0.  Set it to other values in
error cases, as used in the direct return.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-02 13:50:36 +01:00
Benjamin Tissoires
bbe3175408 HID: input: fix input sysfs path for hid devices
we used to set the parent of the input device as the parent of
the hid bus. This was introduced when we created hid as a real bus, and
to keep backward compatibility. Now, it's time to proper set the parent
so that sysfs has an idea of which input device is attached to
which hid device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-12-20 23:24:40 +01:00
Antonio Ospite
a443255c3e HID: debug: add labels for some new buttons
Add labels for BTN_DPAD_UP, BTN_DPAD_DOWN, BTN_DPAD_LEFT, BTN_DPAD_RIGHT and
BTN_TOOL_QUADTAP.

[jkosina@suse.cz: make changelog more verbose]
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-12-17 13:54:40 +01:00
Jiri Kosina
7a5d49a33c HID: remove SIS entries from hid_have_special_driver[]
The entries are not needed, as hid-multitouch gets bound correctly
automatically by contact ID.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-12-16 13:23:26 +01:00
Jiri Kosina
b2b98ea87a HID: microsoft: no fallthrough in MS ergonomy 0xff05 usage
For 0xff05 usage in MS ergonomy keyboard quirk, we are falling through
and returning 0 instread of properly (because we've performed new mapping)
returning 1. Fix that.

Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-12-15 18:25:26 +01:00