summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-sony.c
AgeCommit message (Collapse)Author
2014-04-03HID: sony: Fix cancel_work_sync mismergeFrank Praznik
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-01HID: sony: fix force feedback mismergeJiri Kosina
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-01Merge branches 'for-3.15/multitouch', 'for-3.15/sony' and 'for-3.15/uhid' ↵Jiri Kosina
into for-linus
2014-04-01Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-linusJiri Kosina
Conflicts: drivers/hid/hid-ids.h drivers/hid/hid-sony.c drivers/hid/i2c-hid/i2c-hid.c
2014-04-01Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-3.15/sonyJiri Kosina
2014-04-01HID: sony: Set the quriks flag for Bluetooth controllersFrank Praznik
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-01HID: sony: Fix Sixaxis cable state detectionFrank Praznik
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-03-14HID: sony: do not rely on hid_output_raw_reportBenjamin Tissoires
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 3a75b24949a8 (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-14Merge branch 'for-3.15/sony' into for-3.15/hid-core-ll-transport-cleanupJiri Kosina
2014-02-24HID: sony: Prevent duplicate controller connections.Frank Praznik
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-24HID: sony: Perform a boundry check on the sixaxis battery level index.Frank Praznik
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-24HID: sony: Fix work queue issuesFrank Praznik
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-24HID: sony: Fix multi-line comment stylingFrank Praznik
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-20HID: sony: Fix work queue issues.Frank Praznik
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-20HID: sony: Enable LED controls and rumble for the Sixaxis on Bluetooth.Frank Praznik
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-17HID: sony: Correct Sixaxis battery reportingFrank Praznik
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-17HID: replace hid_output_raw_report with hid_hw_raw_request for feature requestsBenjamin Tissoires
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-17HID: sony: Add conditionals to enable all features in Bluetooth modeFrank Praznik
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-17HID: sony: Set initial battery level to 100% to avoid false low battery warningsFrank Praznik
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-17HID: sony: Add Dualshock 4 Bluetooth battery and touchpad parsingFrank Praznik
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-17HID: sony: Add Dualshock 4 Bluetooth output report formattingFrank Praznik
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-17HID: sony: Add modified Dualshock 4 Bluetooth HID descriptorFrank Praznik
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-17HID: sony: Use low-level transport driver functionsFrank Praznik
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-17Merge branch 'for-3.15/hid-core-ll-transport-cleanup' into for-3.15/sonyJiri Kosina
2014-02-17HID: introduce helper to access hid_output_raw_report()Benjamin Tissoires
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-17HID: remove hid_get_raw_report in struct hid_deviceBenjamin Tissoires
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-06HID: hid-sony: report actual brightness value when reading LEDSimon Wood
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-01-28HID: sony: add output events for the multi-touch pad on the Dualshock 4Frank Praznik
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-28HID: sony: add battery status reporting for the Sixaxis and Dualshock 4Frank Praznik
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-21HID: sony: Use colors for the Dualshock 4 LED namesFrank Praznik
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-21HID: sony: Add annotated HID descriptor for the Dualshock 4Frank Praznik
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-20HID: sony: Cache the output report for the Dualshock 4Frank Praznik
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-17HID: sony: Map gyroscopes and accelerometers to axesFrank Praznik
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-17HID: sony: Fix spacing in the device definitions.Frank Praznik
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-17HID: sony: Use standard output reports instead of raw reports to send data ↵Frank Praznik
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-17HID: sony: Use separate identifiers for USB and Bluetooth connected ↵Frank Praznik
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-16HID: sony: Rename worker functionFrank Praznik
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-16HID: sony: Add LED controls for the Dualshock 4Frank Praznik
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-16HID: sony: Add force-feedback support for the Dualshock 4Frank Praznik
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-02HID: sony: fix error return codeJulia Lawall
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>
2013-11-20HID: sony: Add LED support for Sixaxis/Dualshock3 USBSven Eckelmann
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-20HID: sony: Move LED data to the main structureSven Eckelmann
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-20HID: sony: Rename buzz_* functions to sony_led_*Sven Eckelmann
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-20HID: sony: Use BIT(x) macro to define quirks constantsSven Eckelmann
Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-20HID: sony: Rename rumble_* functions/variables to state_*Sven Eckelmann
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-19HID: sony: Send FF commands in non-atomic contextSven Eckelmann
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-11HID: sony: Add force feedback support for Dualshock3 USBSven Eckelmann
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-09-24HID: sony: use hid_get_raw_report() instead of a direct call to usbBenjamin Tissoires
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-13HID: sony: validate HID output report detailsKees Cook
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-06Merge branches 'for-3.12/devm', 'for-3.12/i2c-hid', 'for-3.12/i2c-hid-dt', ↵Jiri Kosina
'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