1
0
Fork 0
Commit Graph

196 Commits (hifive-unleashed-5.2)

Author SHA1 Message Date
Frank Praznik 077147a305 HID: sony: Update file header and correct comments
Update the file header and correct an outdated comment block.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-09-15 13:34:53 +02:00
Frank Praznik fb291cbd3f HID: sony: Corrections for the DualShock 4 HID descriptor
Fix a few minor issues in the HID descriptor:
 - A 6 bit entry had a logical maximum of 255 when the largest it can be is 63.
 - A logical max value was incorrectly being set to -1 instead of 255.
 - Set the min/max of the gyroscopes to -8192/8191 as that is the range of
   values which represent the true controller orientation.  Any values beyond
   those extents are just noise.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-09-15 13:34:53 +02:00
Frank Praznik 9fddd74a23 HID: sony: Set the Sixaxis cable state correctly
Bit 3 in byte 31 of the Sixaxis report indicates whether the battery is
charging or not charging as opposed to whether or not the cable is plugged in.
As a result, when connected via USB and fully charged, the power_supply status
is wrongly reported as 'Discharging' instead of 'Full'.

Use the battery level value to set the cable state so that the power status
is reported correctly as that seems to be the only reliable way to determine the
cable status on the Sixaxis.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-09-01 11:20:52 +02:00
Frank Praznik 5607c89a11 HID: sony: Default initialize all elements of the LED max_brightness array to 1
Previously only the first element of the array was initialized to 1
leading to potential incorrect max brightness values for the LEDs
on the Dualshock 3 and buzzer controllers.

Use a designated initializer to initialize the whole array to the
correct value.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-07-30 11:25:22 +02:00
Antonio Ospite ab030726b6 HID: sony: Remove an old and redundant comment
Remove an old redundant comment before sony_report_fixup(), it must have
been a leftover from the first version of the driver:
sony_report_fixup() now handles all the supported devices, not only the
Sony Vaio VGX.

The comment is also redundant as the same information provided by it is
also present in the body of the function.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-06-25 21:21:19 +02:00
Antonio Ospite fb705a6dc8 HID: sony: Format and comment sixaxis_rdesc
Reformat sixaxis_rdesc to reflect its HID structure, and comment each
field. This will make it easier to validate changes to the descriptor in
the future.

No functional changes are introduced, the descriptor is exactly the same
as before byte by byte.

The heavy lifting has been done with the help of hidrd-convert:
https://github.com/DIGImend/hidrd

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-06-25 21:21:18 +02:00
Antonio Ospite c607fb8d67 HID: sony: Always override the Sixaxis descriptor
Simplify the logic of overriding the Sixaxis HID descriptor, this will
make it easier to amend the descriptor in future commits.

The current code does this:

	if (original sixaxis via USB or BT)
		fixup only a part of the descriptor
	else if (sixaxis compatible controller)
		override the _whole_ descriptor

but the end result is exactly the same, except for the trailing zero in
the case of original BT controllers.

So let's just regularize the process, and always override the HID
descriptor.

Always overriding the descriptor changes the current semantic a little
bit, before this change the BT descriptor still had the trailing zero
byte, while now it is exactly the same as the descriptor of the
controller via USB, but that does not affect proper operation of the
device.

Note that overriding the whole descriptor for original devices is not
strictly necessary for now, but it simplifies the code and in the future
the report descriptor will be patched further and keys will be remapped,
so it's handy to have only one place to patch.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-06-25 21:21:18 +02:00
Antonio Ospite 50764650c9 HID: sony: Use the SIXAXIS_CONTROLLER constant when possible
Instead of checking for SIXAXIS_CONTROLLER_USB and SIXAXIS_CONTROLLER_BT
separately, a check on SIXAXIS_CONTROLLER can be used when setting
connect_mask.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-06-25 21:21:17 +02:00
Simon Wood 88f6576fa1 HID: hid-sony - allow 3rd party INTEC controller to turn off all leds
Without this patch the 3rd party INTEC (PS3) controller will blink all
leds when user turns them off, it appears to require an extra flag set.

Signed-off-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:42 +02:00
Frank Praznik b3ed458c1c HID: sony: Add blink support to the Sixaxis and DualShock 4 LEDs
Add support for setting the blink rate of the LEDs.  The Sixaxis allows control
over each individual LED, but the Dualshock 4 only has one global control for
controlling the hardware blink rate so individual colors will fall back to
software timers.

Setting the brightness cancels the blinking as per the LED class specifications.

The Sixaxis and Dualshock 4 controllers accept delays in decisecond increments
from 0 to 255 (2550 milliseconds).

The value at index 1 of the DualShock 4 USB output report must be 0xFF or the
light bar won't blink.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:41 +02:00
Frank Praznik 8025087acf HID: sony: Initialize the controller LEDs with a device ID value
Add an IDA id allocator to assign unique, sequential device ids to Sixaxis and
DualShock 4 controllers.

Use the device ID to initialize the Sixaxis and DualShock 4 controller LEDs to
default values.  The number or color of the controller is set relative to other
connected Sony controllers.

Set the LED class brightness values to the initial values and add the new led to
the array before calling led_classdev_register so that the correct brightness
value shows up in the LED sysfs entry.

Use explicit module init and exit functions since the IDA allocator must be
manually destroyed when the module is unloaded.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:41 +02:00
Frank Praznik 314531f18d HID: sony: Use the controller Bluetooth MAC address as the unique value in the battery name string
Use the controller Bluetooth MAC address as the unique identifier in the
battery name string instead of the atomic integer that was used before.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:12 +02:00
Frank Praznik fa57a8107b HID: sony: Convert startup and shutdown functions to use a uniform parameter type
Convert all of the local initialization and shutdown functions to take a
parameter type of struct sony_sc* instead of using a mix of struct sony_sc* and
struct hid_device*.

Allows for the removal of some calls to hid_get_drvdata().

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:12 +02:00
Frank Praznik 55d3b664d4 HID: sony: Use a struct for the Sixaxis output report.
Use a struct for the Sixaxis output report that uses named members to set the
report fields.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:12 +02:00
Frank Praznik 4626204743 HID: sony: Use inliners for work queue initialization and cancellation
Use inliners to make sure that the work queue initialization flag is always
checked and set correctly when initializing or cancelling the work queue.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-24 18:53:11 +02:00
Frank Praznik 2cf8ee9044 HID: sony: Fix cancel_work_sync mismerge
Remove redundant cancel_work_sync() call caused by mismerge.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-03 14:23:49 +02:00
Jiri Kosina 3ae821effd HID: sony: fix force feedback mismerge
Fix unfortunate mismerge between the fixes and sony branch causing
code duplication and unterminated basic block.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-01 19:11:09 +02:00
Jiri Kosina fa1054a29b Merge branches 'for-3.15/multitouch', 'for-3.15/sony' and 'for-3.15/uhid' into for-linus 2014-04-01 19:06:50 +02:00
Jiri Kosina ad295b6d57 Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-linus
Conflicts:
	drivers/hid/hid-ids.h
	drivers/hid/hid-sony.c
	drivers/hid/i2c-hid/i2c-hid.c
2014-04-01 19:05:09 +02:00
Jiri Kosina b95dd3ca03 Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-3.15/sony 2014-04-01 18:45:27 +02:00
Frank Praznik 2078b9bb24 HID: sony: Set the quriks flag for Bluetooth controllers
The Sixaxis and DualShock 4 want HID output reports sent on the control
endpoint when connected via Bluetooth.  Set the
HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP flag for these devices so hidraw write()
works properly.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-01 18:44:06 +02:00
Frank Praznik 914c578391 HID: sony: Fix Sixaxis cable state detection
Byte 31 of the Sixaxis report can change depending on whether or not the
controller is rumbling.  Using bit 3 is the only reliable way to detect the
state of the cable regardless of rumble activity.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-01 18:44:06 +02:00
Benjamin Tissoires e534a93522 HID: sony: do not rely on hid_output_raw_report
hid_out_raw_report is going to be obsoleted as it is not part of the
unified HID low level transport documentation
(Documentation/hid/hid-transport.txt)

To do so, we need to introduce two new quirks:
* HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP: this quirks prevents the
  transport driver to use the interrupt channel to send output report
  (and thus force to use HID_REQ_SET_REPORT command)
* HID_QUIRK_SKIP_OUTPUT_REPORT_ID: this one forces usbhid to not
  include the report ID in the buffer it sends to the device through
  HID_REQ_SET_REPORT in case of an output report

This also fixes a regression introduced in commit 3a75b24949
(HID: hidraw: replace hid_output_raw_report() calls by appropriates ones).
The hidraw API was not able to communicate with the PS3 SixAxis
controllers in USB mode.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-03-14 15:30:20 +01:00
Jiri Kosina 65ab2fc479 Merge branch 'for-3.15/sony' into for-3.15/hid-core-ll-transport-cleanup 2014-03-14 15:30:16 +01:00
Frank Praznik d2d782fcce HID: sony: Prevent duplicate controller connections.
If a Sixaxis or Dualshock 4 controller is connected via USB while already
connected via Bluetooth it will cause duplicate devices to be added to the
input device list.

To prevent this a global list of controllers and their MAC addresses is
maintained and new controllers are checked against this list.  If a duplicate
is found, the probe function will exit with -EEXIST.

On USB the MAC is retrieved via a feature report.  On Bluetooth neither
controller reports the MAC address in a feature report so the MAC is parsed from
the uniq string.  As uniq cannot be guaranteed to be a MAC address in every case
(uHID or the behavior of HIDP changing) a parsing failure will not prevent the
connection.

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-02-24 17:38:46 +01:00
Frank Praznik ac3c9a9409 HID: sony: Perform a boundry check on the sixaxis battery level index.
Make sure that an out-of-bounds read doesn't occur in the Sixaxis battery level
lookup table in the event that the controller sends an invalid battery status
value in the report.

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-02-24 17:38:46 +01:00
Frank Praznik c8de9dbb35 HID: sony: Fix work queue issues
Only initialize force feedback for devices that actually support it (Sixaxis and
Dualshock 4) to prevent calls to schedule_work() with an uninitialized work
queue.

Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
is used for the LEDs even when force-feedback is disabled.

Remove the sony_destroy_ff() function since it is no longer used.

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-02-24 17:38:45 +01:00
Frank Praznik ad142b9e44 HID: sony: Fix multi-line comment styling
Convert multi-line comments to comply with the kernel coding style.

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-02-24 17:38:45 +01:00
Frank Praznik 5f5750d2e4 HID: sony: Fix work queue issues.
Don't initialize force-feedback for devices that don't support it to avoid calls
to schedule_work() with an uninitialized work_struct.

Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
is used for the LEDs even when force-feedback is disabled.

Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-20 14:14:03 +01:00
Frank Praznik fee4e2d526 HID: sony: Enable LED controls and rumble for the Sixaxis on Bluetooth.
Add a SIXAXIS_CONTROLLER macro to simplify conditionals where the
connection type is irrelevant.

Enable the LED and force feedback controls for Sixaxis controllers connected via
Bluetooth.

Send Sixaxis Bluetooth output reports on the control channel.

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-02-20 14:10:22 +01:00
Frank Praznik a43e94a38b HID: sony: Correct Sixaxis battery reporting
The battery_charging and cable_state flags were backwards on the Sixaxis.
The low bit of report byte 30 is 0 when charging and 1 when not.
Bit 5 of byte 31 is 0 when a USB cable is connected and 1 when not.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-17 23:17:36 +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
Frank Praznik 68330d83c0 HID: sony: Add conditionals to enable all features in Bluetooth mode
Add the conditionals to enable rumble, battery reporting, LED and touchpad
support for the Dualshock 4 in Bluetooth mode.

Add dualshock4_set_operational_bt to initialize the controller to the proper
operational state.

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-02-17 14:11:21 +01:00
Frank Praznik d9a293a951 HID: sony: Set initial battery level to 100% to avoid false low battery warnings
Set the initial battery level to 100% to avoid false low battery warnings if
the battery state is polled before a report with the actual battery level is
received.

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-02-17 14:11:07 +01:00
Frank Praznik 6c5f860d3f HID: sony: Add Dualshock 4 Bluetooth battery and touchpad parsing
Add Dualshock 4 battery and touchpad parsing for Bluetooth reports.

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-02-17 14:11:07 +01:00
Frank Praznik fdcf105d3d HID: sony: Add Dualshock 4 Bluetooth output report formatting
Add formating for the Dualshock 4 output report data in Bluetooth mode.

In Bluetooth mode the Dualshock 4 wants output reports sent on the control
channel.

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-02-17 14:11:07 +01:00
Frank Praznik d829674d29 HID: sony: Add modified Dualshock 4 Bluetooth HID descriptor
By default, the Dualshock 4 sends controller data via report 1. Once a valid
output report 0x11 is received or a feature report of type 0x02 is requested the
controller changes from sending data in report 1 to sending data in report 17,
which is unmapped in the default descriptor. The mappings have to be moved to
report 17 to let the HID driver properly process the incoming reports.

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-02-17 14:11:06 +01:00
Frank Praznik 48220237ba HID: sony: Use low-level transport driver functions
Switch to the low-level transport driver functions.

sony_set_output_report is removed since it is no longer used.

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-02-17 14:11:06 +01:00
Jiri Kosina 3371ac4b3b Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-3.15/sony 2014-02-17 14:07:35 +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
Simon Wood 7db7504a49 HID: hid-sony: report actual brightness value when reading LED
The Dualshock4 controller contains a RGB LED, which is enabled via
the '/sys/class/leds' interface. At present the driver only returns
whether each of the RGB LEDs is lit (ie not off), but no indication
of it's brightness.

This patch fixes the reading of the current brightnes so that it
returns the value (rather than just off=0, on=LED_FULL).

Tested on the DS4 and SixAxis (for compatibility).

Signed-off-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-02-06 09:44:39 +01:00
Frank Praznik e560623050 HID: sony: add output events for the multi-touch pad on the Dualshock 4
Add output events for the multi-touch pad on the Dualshock 4.

The touchpad has a resolution of 1920x940 and is capable of 2 simultaneous
touches. A 'Type B' stateful slot protocol is implemented as defined in
Documentation/input/multi-touch-protocol.txt

Applications can use the touchpad data by processing the ABS_MT_SLOT,
ABS_MT_TRACKING_ID, ABS_MT_POSITION_X and ABS_MT_POSITION_Y events.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-28 20:37:45 +01:00
Frank Praznik d902f4724c HID: sony: add battery status reporting for the Sixaxis and Dualshock 4
Add battery status reporting for the Sixaxis and Dualshock 4 controllers.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-01-28 20:37:45 +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
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
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
Sven Eckelmann 0a286ef278 HID: sony: Add LED support for Sixaxis/Dualshock3 USB
The PS3 Sixaxis controller has 4 LEDs which can be controlled using the same
command as the rumble functionality. It seems not to be possible to only change
the LED without modifying the rumble motor state. Thus both have to be stored
on the host and retransmitted when either the LED or rumble state is changed.

Third party controllers may not support to disable all LEDs at once. These
controllers automatically switch to blinking of all LEDs when no LED is active
anymore.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Tested-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-20 09:59:19 +01:00
Sven Eckelmann 2251b85f3d HID: sony: Move LED data to the main structure
It is not necessary to keep the LED information in an extra struct which is
only used by the Buzz device. It can also be used by other devices.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-20 09:59:18 +01:00
Sven Eckelmann c53825190a HID: sony: Rename buzz_* functions to sony_led_*
More controllers managed by the hid-sony module have 4 LEDs. These can share
most of the functionality provided by the buzz functions.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-20 09:59:18 +01:00
Sven Eckelmann f1c458caa1 HID: sony: Use BIT(x) macro to define quirks constants
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-20 09:59:17 +01:00
Sven Eckelmann 92b5c411ab HID: sony: Rename rumble_* functions/variables to state_*
The commands used to modify the rumble motor state also modifies the LEDs at
the same time. The functionality used to modify this state in the driver has to
be shared between the rumble and LED part. It is therefore better to replace
the "rumble" part of the names with "state".

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-20 09:59:17 +01:00
Sven Eckelmann 9f323b6811 HID: sony: Send FF commands in non-atomic context
The ff_memless has a timer running which gets run in an atomic context and
calls the play_effect callback. The callback function for sony uses the
hid_output_raw_report (overwritten by sixaxis_usb_output_raw_report) function
to handle differences in the control message format. It is not safe for an
atomic context because it may sleep later in usb_start_wait_urb.

This "scheduling while atomic" can cause the system to lock up. A workaround is
to make the force feedback state update using work_queues and use the
play_effect function only to enqueue the work item.

Reported-by: Simon Wood <simon@mungewell.org>
Reported-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-19 09:37:45 +01:00
Sven Eckelmann a08c22c0df HID: sony: Add force feedback support for Dualshock3 USB
Sony Dualshock 3 controllers have two motors which can be used to provide
simple force feedback rumble effects. The right motor is can be used to create
a weak rumble effect but does not allow to set the force. The left motor is
used to create a strong rumble effect with adjustable intensity.

The state of both motors can be changed using HID_OUTPUT_REPORT packets and
have no timing information. FF memless is used to keep track of the timing and
the sony driver just generates the necessary URBs.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-11 11:25:46 +01:00
Benjamin Tissoires f204828a11 HID: sony: use hid_get_raw_report() instead of a direct call to usb
The usb packets are exactly the same, but it makes it a little bit more
independent of the transport layer.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-09-24 11:47:48 +02:00
Kees Cook 9446edb9a1 HID: sony: validate HID output report details
This driver must validate the availability of the HID output report and
its size before it can write LED states via buzz_set_leds(). This stops
a heap overflow that is possible if a device provides a malicious HID
output report:

[  108.171280] usb 1-1: New USB device found, idVendor=054c, idProduct=0002
...
[  117.507877] BUG kmalloc-192 (Not tainted): Redzone overwritten

CVE-2013-2890

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org #3.11
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-09-13 15:12:12 +02:00
Jiri Kosina 63faf15dba Merge branches 'for-3.12/devm', 'for-3.12/i2c-hid', 'for-3.12/i2c-hid-dt', 'for-3.12/logitech', 'for-3.12/multitouch-win8', 'for-3.12/trasnport-driver-cleanup', 'for-3.12/uhid', 'for-3.12/upstream' and 'for-3.12/wiimote' into for-linus 2013-09-06 11:58:37 +02:00
Benjamin Tissoires abf832bfc3 HID: trivial devm conversion for special hid drivers
It is safe to use devres allocation within the hid subsystem:
- the devres release is called _after_ the call to .remove(), meaning
  that no freed pointers will exists while removing the device
- if a .probe() fails, devres releases all the allocated ressources
  before going to the next driver: there will not be ghost ressources
  attached to a hid device if several drivers are probed.

Given that, we can clean up a little some of the HID drivers. These ones
are trivial:
- there is only one kzalloc in the driver
- the .remove() callback contains only one kfree on top of hid_hw_stop()
- the error path in the probe is easy enough to be manually checked

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-07-31 10:12:28 +02:00
Benjamin Tissoires 6f49801827 HID: sony: fix HID mapping for PS3 sixaxis controller
Commit f04d51404f (HID: driver for PS2/3 Buzz controllers) introduced
an input_mapping() callback, but set the return value to -1 to all devices
except the Buzz controllers. The result of this is that the Sixaxis input
device is not populated, making it useless.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-07-24 16:57:09 +02:00
Jiri Kosina 078328da5d HID: fold ps3remote driver into generic Sony driver
Let's follow the structure we are trying to keep for most of the
specific HID drivers, and let the separation follow the producing
vendor.
Merge functionality provided by ps3remote driver into hid-sony.

Tested-by: David Dillow <dave@thedillows.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-06-13 12:03:49 +02:00
Jiri Kosina 40e32ee6e4 HID: sony: fix leds dependency
The newly added support for Buzz controller

- introduced Kconfig selection of LEDS_CLASS
- introduced conditional preprocessor checking for CONFIG_LEDS_CLASS

This has multiple problems -- namely select doesn't work transitively,
so it shouldn't be used. On the other hand the code assumed that LEDS_CLASS
is enabled in some places, but not everywhere.

Put LEDS_CLASS as a Kconfig dependency for hid-sony and remove all the
CONFIG_LEDS_CLASS conditionals from hid-sony.

Reported-by: fengguang.wu@intel.com
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-05-28 11:22:09 +02:00
Colin Leitner f04d51404f HID: driver for PS2/3 Buzz controllers
This patch adds support for PS2/3 Buzz controllers into hid-sony

It has been tested on Debian 7 with kernel version 3.10.0-rc2. Unfortunately
I can't test the patch with a regular six-axis controller myself.

Signed-off-by: Colin Leitner <colin.leitner@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-05-28 10:16:49 +02:00
Jiri Kosina 0d69a3c731 Merge branches 'for-3.9/sony' and 'for-3.9/steelseries' into for-linus
Conflicts:
	drivers/hid/hid-core.c
2013-02-21 10:45:52 +01:00
Fernando Luis Vázquez Cao 99d249021a HID: clean up quirk for Sony RF receivers
Document what the fix-up is does and make it more robust by ensuring
that it is only applied to the USB interface that corresponds to the
mouse (sony_report_fixup() is called once per interface during probing).

Cc: linux-input@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-01-22 11:06:24 +01:00
Fernando Luis Vázquez Cao a464918419 HID: add support for Sony RF receiver with USB product id 0x0374
Some Vaio desktop computers, among them the VGC-LN51JGB multimedia PC, have
a RF receiver, multi-interface USB device 054c:0374, that is used to connect
a wireless keyboard and a wireless mouse.

The keyboard works flawlessly, but the mouse (VGP-WMS3 in my case) does not
seem to be generating any pointer events. The problem is that the mouse pointer
is wrongly declared as a constant non-data variable in the report descriptor
(see lsusb and usbhid-dump output below), with the consequence that it is
ignored by the HID code.

Add this device to the have-special-driver list and fix up the report
descriptor in the Sony-specific driver which happens to already have a fixup
for a similar firmware bug.

# lsusb -vd 054C:0374
Bus 003 Device 002: ID 054c:0374 Sony Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x054c Sony Corp.
  idProduct          0x0374
  iSerial                 0
[...]
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              2 RF Receiver
[...]
          Report Descriptor: (length is 100)
[...]
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Logical Minimum, data= [ 0x81 ] 129
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Main  ): Input, data= [ 0x07 ] 7
                            Constant Variable Relative No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield

# usbhid-dump
003:002:001:DESCRIPTOR         1357910009.758544
 05 01 09 02 A1 01 05 01 09 02 A1 02 85 01 09 01
 A1 00 05 09 19 01 29 05 95 05 75 01 15 00 25 01
 81 02 75 03 95 01 81 01 05 01 09 30 09 31 95 02
 75 08 15 81 25 7F 81 07 A1 02 85 01 09 38 35 00
 45 00 15 81 25 7F 95 01 75 08 81 06 C0 A1 02 85
 01 05 0C 15 81 25 7F 95 01 75 08 0A 38 02 81 06
 C0 C0 C0 C0

Cc: linux-input@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-01-15 17:01:11 +01:00
Mauro Carvalho Chehab e57a67da60 HID: hid-sony: fix troubles with Sony remote clones
There are some Sony clone gamepads that are incompatible
with PS3 since firmware 3.50, as they decided to prevent those
devices to work, without any good technical reason. I was one of those
'blessed' people affected by their niceness with their customers.

Marcelo also has another device with a similar problem.

Perhaps due to Sony's way to block the device, damaging the device's
eeprom, or perhaps because they just have a different, broken Report
descriptor, there are 3 buttons that don't work on both devices
(the ones equivalent to square, round and X).

What it happens is that the descriptor generate weird EV_ABS events
to those buttons, instead of EV_MSC/EV_KEY.

A fix that seems to be enough for them is to return the original
sixaxis table instead of the broken one. That's what this patch
does.

Yet, there are some missing entries at the used keytable. On my
tests, all keys are now producing the right events, but the reported
keycodes look weird:

"square" key: (Button.0010 = 1)

1355524363.460835: event type EV_MSC(0x04): scancode = 0x90010
1355524363.460835: event type EV_KEY(0x01) key_up: BTN_DEAD(0x0001)

"round" key: (Button.000e = 1)

1355524410.908705: event type EV_MSC(0x04): scancode = 0x9000e
1355524410.908705: event type EV_KEY(0x01) key_down: (0x0001)
1355524410.971788: event type EV_MSC(0x04): scancode = 0x9000e
1355524410.971788: event type EV_KEY(0x01) key_up: (0x0001)

"X" key: (Button.000f = 1)
1355524384.880813: event type EV_MSC(0x04): scancode = 0x9000f
1355524384.880813: event type EV_KEY(0x01) key_down: (0x0001)
1355524384.979815: event type EV_MSC(0x04): scancode = 0x9000f
1355524384.979815: event type EV_KEY(0x01) key_up: (0x0001)

The rationale is likely due to those entries at rdesc table, where the
Kernel were not likely able to parse:

Button.000d ---> Key.?
Button.000e ---> Key.?
Button.000f ---> Key.?
Button.0010 ---> Key.BtnDead
Button.0011 ---> Key.?
Button.0012 ---> Key.?
Button.0013 ---> Key.?

As a reference, this is the rdisc used on my clone (a Mad Catz
model 8846):

05 01 09 04 a1 01 a1 02 85 01 75 08 95 01 15 00 26 ff 00 81 03 75 01 95 0d 15 00 25 01 35 00 45 01 05 09 19 01 29 0d 81 02 75 01 95 03 06 00 ff 81 03 05 01 25 07 46 3b 01 75 04 95 01 65 14 09 39 81 42 65 00 75 01 95 0c 06 00 ff 81 03 15 00 26 ff 00 05 01 09 01 a1 00 75 08 95 04 15 00 15 00 15 00 35 00 35 00 46 ff 00 09 30 09 31 09 32 09 35 81 02 c0 05 01 75 08 95 27 09 01 81 02 75 08 95 30 09 01 91 02 75 08 95 30 09 01 b1 02 c0 a1 02 85 02 75 08 95 30 09 01 b1 02 c0 a1 02 85 ee 75 08 95 30 09 01 b1 02 c0 a1 02 85 ef 75 08 95 30 09 01 b1 02 c0 c0

This is what's returned on Marcelo's device (not sure what is
the brand name of his device):

05 01 09 04 a1 01 a1 02 85 01 75 08 95 01 15 00 26 ff 00 81 03 75 01 95 13 15 00 25 01 35 00 45 01 05 09 19 01 29 13 81 02 75 01 95 0d 06 00 ff 81 03 15 00 26 ff 00 05 01 09 01 a1 00 75 08 95 04 35 00 46 ff 00 09 30 09 31 09 32 09 35 81 02 c0 05 01 95 13 09 01 81 02 95 0c 81 01 75 10 95 04 26 ff 03 46 ff 03 09 01 81 02 c0 a1 02 85 02 75 08 95 30 09 01 b1 02 c0 a1 02 85 ee 75 08 95 30 09 01 b1 02 c0 a1 02 85 ef 75 08 95 30 09 01 b1 02 c0 c0

Reported-by: Marcelo Leitner <mleitner@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Tested-by: Marcelo Leitner <mleitner@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-01-03 10:47:58 +01:00
H Hartley Sweeten f425458eaf HID: Use module_hid_driver macro
Use the new module_hid_driver macro in all HID drivers that have
a simple register/unregister init/exit.

This also converts the hid drivers that test for a failure of
hid_register_driver() and report the failure. Using module_hid_driver
in those drivers removes the failure message.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-01-03 10:27:31 +01:00
Jiri Kosina 2f43f8749e HID: remove Paul Walmsley's copyright from places where it shouldn't be
Paul Walmsley has implemented dynamic quirk handling back in 2007 through
commits:

2eb5dc30eb ("USB HID: encapsulate quirk handling into hid-quirks.c")
8222fbe67c ("USB HID: clarify static quirk handling as squirks")
8cef908235 ("USB HID: add support for dynamically-created quirks")
876b9276b9 ("USB HID: add 'quirks' module parameter")

and as such, his copyright rightly belongs to
drivers/hid/usbhid/hid-quirks.c file.

However when generic HID code has been converted to bus and individual
quirks separated out to individual drivers on the bus, the copyright has
been blindly transfered into all the tiny drivers, which actually don't
contain any of Pauls' copyrighted code.

Remove the copyright from those sub-drivers.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Paul Walmsley <paul@pwsan.com>
2012-09-05 10:46:36 +02:00
Simon Wood c9e4d87758 HID: hid-sony: fix endiannes of Sixaxis accel/gyro values
The accelerometers/gyro on the Sixaxis are reported in the wrong
endianness (ie. not compatible with HID), so this patch intercepts
the report and swaps the appropriate bytes over.

Accelerometers are scaled with a nominal value of +/-4000 = 1G,
maximum value would be around +/-32768 = 8G.

Gyro on my device always reports -32768, might need some calibration
set within the controller.

Fix extracted from previous patch submission:
https://patchwork.kernel.org/patch/95212/

Signed-off-by: Marcin Tolysz <tolysz@gmail.com>
Signed-off-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-06-13 13:21:30 +02:00
Simon Wood 61ab44bebd HID: hid-sony: amend Sixaxis descriptor to enable accelerometers
Modify the HID descriptor of the Sixaxis controller to allow the
reporting of the accelerometers and gyro via a joystick axis.

Rewrite section from offset 83:
--
0x75, 0x08,         /* Report Size (8),         */
/* all the other data lumped together */
0x95, 0x27,         /* Report Count (39),       */
0x09, 0x01,         /* Usage (Pointer),         */
0x81, 0x02,         /* Input (Variable),        */
0x75, 0x08,         /* Report Size (8),         */
0x95, 0x30,         /* Report Count (48),       */
0x09, 0x01,         /* Usage (Pointer),         */
/* Note Output */
0x91, 0x02,         /* Output (Variable),       */
0x75, 0x08,         /* Report Size (8),         */
0x95, 0x30,         /* Report Count (48),       */
0x09, 0x01,         /* Usage (Pointer),         */
/* Note Feature */
0xB1, 0x02,         /* Feature (Variable),      */
--
with
--
/* last 2 not used... */
0x95, 0x13,         /* Report Count (19),       */
0x09, 0x01,         /* Usage (Pointer),         */
0x81, 0x02,         /* Input (Variable),        */
/* Padding */
0x95, 0x0C,         /* Report Count (12),       */
0x81, 0x01,         /* Input (Constant),        */
0x75, 0x10,         /* Report Size (16),        */
0x95, 0x04,         /* Report Count (4),        */
0x26, 0xFF, 0x03,   /* Logical Maximum (1023),  */
0x46, 0xFF, 0x03,   /* Physical Maximum (1023), */
0x09, 0x01,         /* Usage (Pointer),         */
0x81, 0x02,         /* Input (Variable),        */
--

Signed-off-by: Simon Wood <simon@mungewell.org>
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-06-13 13:20:06 +02:00
Jiri Kosina 35dca5b4a6 HID: add support for Sony Navigation Controller
Sony Navigation Controller needs a special report to be sent to it
before it is able to operate, the same way as other Sony controllers
do.

Tested-by: Jacek Lukas Wotka <jlw@team-fatal.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-04-28 15:43:13 +02:00
Antonio Ospite 5710fabf31 HID: hid-sony.c: Fix sending Output reports to the Sixaxis
The Sixaxis does not want the report_id as part of the data packet in
Output reports, so we have to discard buf[0] when sending the actual
control message.

Add also some documentation about that and about why
hdev->hid_output_raw_report needs to be overridden.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-02-21 13:48:50 +01:00
Joe Perches 4291ee305e HID: Add and use hid_<level>: dev_<level> equivalents
Neaten current uses of dev_<level> by adding and using
hid specific hid_<level> macros.

Convert existing uses of dev_<level> uses to hid_<level>.
Convert hid-pidff printk uses to hid_<level>.

Remove err_hid and use hid_err instead.

Add missing newlines to logging messages where necessary.
Coalesce format strings.

Add and use pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Other miscellaneous changes:

Add const struct hid_device * argument to hid-core functions
extract() and implement() so hid_<level> can be used by them.
Fix bad indentation in hid-core hid_input_field function
that calls extract() function above.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-12-10 15:10:38 +01:00
Jiri Kosina 8b66a16f25 Merge branch 'uc-logic' into for-linus
Conflicts:
	drivers/hid/hid-ids.h
	drivers/hid/hid-lg.c
	drivers/hid/usbhid/hid-quirks.c
2010-10-23 22:49:32 +02:00
Antonio Ospite 569b10a506 HID: hid-sony: override usbhid_output_raw_report for Sixaxis
Override usbhid_output_raw_report in order to force output reports (sent
via hidraw_write, for instance) on the control endpoint.

The Sony Sixaxis (PS3 Controller) accepts output reports only on the
control endpoint, it silently discards them when they arrive over the
interrupt endpoint where usbhid would normally deliver them.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-10-20 16:50:24 +02:00
Antonio Ospite 816651a7d4 HID: sony: Apply sixaxis quirks only to sixaxis
Be more explicit and avoid calling sony_set_operational_usb() when we
have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.

While at it, rename the sony_set_operational routines to
sixaxis_set_operational as they are sixaxis specific.

This is also in preparation for the sysfs interface to set and get bdaddr
over usb and for some other Sixaxis report fixup.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-09-02 09:40:40 +02:00
Nikolai Kondrashov 73e4008ddd HID: allow resizing and replacing report descriptors
Update hid_driver's report_fixup prototype to allow changing report
descriptor size and/or returning completely different report descriptor.
Update existing usage accordingly.

This is to give more freedom in descriptor fixup and to allow having a whole
fixed descriptor in the code for the sake of readability.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-08-09 19:52:42 +02:00
Antonio Ospite fddb33f2e8 HID: sony: fix sony_set_operational_bt
Don't send the report type as part of the data, this prevents the
controller from going into the operational state at all.

This is completely equivalent to what the code originally meant to accomplish:
as per in net/bluetooth/hidp/core.c::hidp_output_raw_report(), by using
HID_FEATURE_REPORT here, what will be actually sent is
(HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE) which is exactly 0x53.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-05-03 17:19:03 +02:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Jiri Kosina 14ef2b0c02 Merge branches 'upstream', 'raw_report_modifications' and 'apple_magic_mouse' into for-linus
Conflicts:
	drivers/hid/Kconfig
2010-02-25 17:39:16 +01:00
Bastien Nocera eabe5c9058 HID: fix typo in error message
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-09 11:43:19 +01:00
Bastien Nocera f9ce7c283c HID: Enable Sixaxis controller over Bluetooth
Now that hid_output_raw_report works, port the PS3 Sixaxis
Bluetooth quirk from user-space, into kernel-space.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-03 15:47:53 +01:00
Peter Huewe a24f423bdf HID: adding __init/__exit macros to module init/exit functions
Trivial patch which adds the __init and __exit macros to the module_init /
module_exit functions of several HID drivers from drivers/hid/

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-07-23 01:28:01 +02:00
Jiri Slaby afa5eb7c68 HID: remove compat stuff
This removal was scheduled and there is no problem with later
distros to adapt for the new bus, thanks to aliases.

module-init-tools map files are deprecated nowadays, so that
the patch which introduced hid ones into the m-i-t won't be
accepted and hence there is no reason for leaving compat stuff in.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-30 15:12:54 +02:00
Jiri Kosina 4dfdc46468 HID: fix error condition propagation in hid-sony driver
sony_set_operational() only propagates return value from
usb_control_msg(), which returns negative on error and number
of transferred bytes otherwise.

Reported-by: Marcin Tolysz <tolysz@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04 01:01:43 +01:00
Jiri Kosina cc6e0bbb47 HID: Add support for Sony Vaio VGX-TP1E
The Sony Vaio VGX-TP1E multimedia PC has a wireless keyboard with
a touchpad.

The mouse pointer is wrongly declared as constant non-data variable, which make
HID code to completely ignore all the "Pointer" usages.
Fix the report descriptor before it enters the parser to contain touchpad
pointer description that is correctly parsable (declaring data rather than
constant).

Reported-by: Stefan Hundhammer <sh@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-23 12:58:38 +02:00
Jiri Slaby 93c10132a7 HID: move connect quirks
Move connecting from usbhid to the hid layer and fix also hidp in
that manner.
This removes all the ignore/force hidinput/hiddev connecting quirks.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14 23:50:56 +02:00
Jiri Slaby bd28ce008b HID: move sony quirks
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14 23:50:55 +02:00