summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-playstation.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-6.3/sony' into for-linusBenjamin Tissoires2023-02-221-19/+22
|\ | | | | | | | | - enforce DS4 controllers to use hid-playstation (Roderick Colenbrander) - various hid-playstation gyro fixes (Roderick Colenbrander)
| * HID: playstation: correct DualSense gyro bias handling.Roderick Colenbrander2023-01-181-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | The bias for the gyroscope is not used correctly. The sensor bias needs to be used in calculation of the 'sensivity' instead of being an offset. In practice this has little input on the values as the bias values tends to be small (+/- 20). Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| * HID: playstation: correct DualShock4 gyro bias handling.Roderick Colenbrander2023-01-181-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | The bias for the gyroscope is not used correctly. The sensor bias needs to be used in calculation of the 'sensivity' instead of being an offset. In practice this has little input on the values as the bias values tends to be small (+/- 20). Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| * HID: playstation: fix DualShock4 unreachable calibration code.Roderick Colenbrander2023-01-181-3/+2
| | | | | | | | | | | | | | | | | | Reported-by: Abaci Robot <abaci@linux.alibaba.com> Reported-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* | HID: playstation: sanity check DualSense calibration data.Roderick Colenbrander2023-01-181-0/+32
| | | | | | | | | | | | | | | | | | Make sure calibration values are defined to prevent potential kernel crashes. This fixes a hypothetical issue for virtual or clone devices inspired by a similar fix for DS4. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* | HID: playstation: sanity check DualShock4 calibration data.Roderick Colenbrander2023-01-181-0/+31
|/ | | | | | | | | | | | | | | | | Some DualShock4 devices report invalid calibration data resulting in kernel oopses due to division by zero during report handling. The devices affected generally appear to be clone devices, which don't implement all reports properly and don't populate proper calibration data. The issue may have been seen on an official device with erased calibration reports. This patch prevents the crashes by essentially disabling calibration when invalid values are detected. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Tested-by: Alain Carlucci <alain.carlucci@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: fix free of uninialized pointer for DS4 in Bluetooth.Roderick Colenbrander2022-12-191-1/+1
| | | | | | | | | | | The 'buf' variable is only used in the USB (if-path) and not in the Bluetooth else-path. Since it is not set to NULL. this results in freeing an uninitialized pointer. Since the else code-path doesn't need buf, just return 0. Fixes: 2d77474a2392 ("HID: playstation: add DualShock4 bluetooth support.") Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20221213044935.1775499-2-roderick.colenbrander@sony.com
* HID: playstation: fix DualShock4 bluetooth CRC endian issue.Roderick Colenbrander2022-11-171-1/+2
| | | | | | | | | | The driver was by accident reading the CRC directly from a hardware structure instead of using get_unaligned_le32. Fixes: 2d77474a2392 ("HID: playstation: add DualShock4 bluetooth support.") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: fix DualShock4 bluetooth memory corruption bug.Roderick Colenbrander2022-11-171-1/+1
| | | | | | | | | | | The size of the output buffer used for output reports was not updated to the larger size needed for Bluetooth. This ultimately resulted in memory corruption of surrounding structures e.g. due to memsets. Fixes: 2d77474a2392 ("HID: playstation: add DualShock4 bluetooth support.") Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add DualShock4 dongle support.Roderick Colenbrander2022-11-111-6/+140
| | | | | | | | | | | | | | | | | | This patch adds support for the DualShock4 dongle in a very similar way we contributed to hid-sony before. The dongle is a USB to Bluetooth bridge and uses the same HID reports as a USB device. It reports data through the DS4's main USB input report independent on whether a Bluetooth controller is connected. For this reason there is custom dongle report parsing code to detect controller hotplug and kick of calibration work until we are ready to process actual input reports. The logic also incorporates a workaround needed for Steam in which hid-playstation and Steam using hidraw can fight. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: set default DualShock4 BT poll interval to 4ms.Roderick Colenbrander2022-11-111-0/+29
| | | | | | | | | The poll interval for DualShock4 in Bluetooth mode is adjustable through the main output report. Configure it to 4ms, which is similar to USB. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add DualShock4 bluetooth support.Roderick Colenbrander2022-11-111-26/+144
| | | | | | | | | | | Add support for DualShock4 in Bluetooth mode. In Bluetooth, the device is a bit strange in that after 'calibration' it switches sending all its input data from a basic report (only containing buttons/sticks) to an extended report, which also contains touchpad, motion sensors and other data. The overall design of this code is similar to the DualSense code. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add option to ignore CRC in ps_get_report.Roderick Colenbrander2022-11-111-8/+9
| | | | | | | | This patch adds a parameter to ps_get_report to ignore CRC checks. This prepares for DualShock4, which has some HID reports, which lack CRC. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: support DualShock4 lightbar blink.Roderick Colenbrander2022-11-111-1/+46
| | | | | | | Support lightbar blink through LEDs framework. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: support DualShock4 lightbar.Roderick Colenbrander2022-11-111-3/+138
| | | | | | | | | | | | | Expose the lightbar LEDs in the same manner as hid-sony through individual LEDs for backwards compatibility reasons. There is a slight change in LED naming to use the input device name as opposed to the MAC address like hid-sony did. This is expected to not cause any issues and should make the naming more compliant. In addition set a default lightbar color based on player ID. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: make LED brightness adjustable in ps_led_register.Roderick Colenbrander2022-11-111-6/+7
| | | | | | | | | Make the max_brightness adjustable through ps_led_info struct. This paves the way for a next DualShock4 patch to allow larger brightness values. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: Add DualShock4 rumble support.Roderick Colenbrander2022-11-111-1/+147
| | | | | | | | | | This patch implements DualShock4 rumble support in a similar manner as the DualSense implementation. It adds an output worker with granular control of different features of the main DualShock4 output report. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add DualShock4 accelerometer and gyroscope support.Roderick Colenbrander2022-11-111-2/+168
| | | | | | | | Support accelerometer and gyroscope as separate input devices similar how DualSense and hid-sony do it. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add DualShock4 touchpad support.Roderick Colenbrander2022-11-111-3/+63
| | | | | | | | | Support the DualShock4 touchpad as a separate input device. The code describes the touchpad input reports through structures similar a bit to the DualSense code. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add DualShock4 battery support.Roderick Colenbrander2022-11-111-4/+66
| | | | | | | Provide DualShock4 battery support through powersupply framework. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: report DualShock4 hardware and firmware version.Roderick Colenbrander2022-11-111-0/+38
| | | | | | | | Report DualShock4 hardware and firmware version info through sysfs. It uses the same sysfs nodes as the DualSense did (and hid-sony). Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: initial DualShock4 USB support.Roderick Colenbrander2022-11-111-2/+172
| | | | | | | Add basic support for DualShock4 USB controller with buttons and sticks. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: support updated DualSense rumble mode.Roderick Colenbrander2022-10-141-1/+36
| | | | | | | | | | | | Newer DualSense firmware supports a revised classic rumble mode, which feels more similar to rumble as supported on previous PlayStation controllers. It has been made the default on PlayStation and non-PlayStation devices now (e.g. iOS and Windows). Default to this new mode when supported. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20221010212313.78275-4-roderick.colenbrander@sony.com
* HID: playstation: add initial DualSense Edge controller supportRoderick Colenbrander2022-10-141-1/+4
| | | | | | | | | | | Provide initial support for the DualSense Edge controller. The brings support up to the level of the original DualSense, but won't yet provide support for new features (e.g. reprogrammable buttons). Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> CC: stable@vger.kernel.org Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20221010212313.78275-3-roderick.colenbrander@sony.com
* HID: playstation: stop DualSense output work on remove.Roderick Colenbrander2022-10-141-5/+36
| | | | | | | | | | | Ensure we don't schedule any new output work on removal and wait for any existing work to complete. If we don't do this e.g. rumble work can get queued during deletion and we trigger a kernel crash. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> CC: stable@vger.kernel.org Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20221010212313.78275-2-roderick.colenbrander@sony.com
* HID: playstation: convert to use dev_groupsGreg Kroah-Hartman2022-08-251-11/+5
| | | | | | | | | | | | | | | | | There is no need for a driver to individually add/create device groups, the driver core will do it automatically for you. Convert the hid-playstation driver to use the dev_groups pointer instead of manually calling the driver core to create the group and have it be cleaned up later on by the devm core. Cc: Roderick Colenbrander <roderick.colenbrander@sony.com> Cc: Jiri Kosina <jikos@kernel.org> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: fix return from dualsense_player_led_set_brightness()Jiri Kosina2021-10-271-0/+2
| | | | | | | | | | | | brightness_set_blocking() callback expects function returning int. This fixes the follwoing build failure: drivers/hid/hid-playstation.c: In function ‘dualsense_player_led_set_brightness’: drivers/hid/hid-playstation.c:885:1: error: no return statement in function returning non-void [-Werror=return-type] } ^ Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: expose DualSense player LEDs through LED class.Roderick Colenbrander2021-10-271-1/+84
| | | | | | | | | | The DualSense player LEDs were so far not adjustable from user-space. This patch exposes each LED individually through the LED class. Each LED uses the new 'player' function resulting in a name like: 'inputX:white:player-1' for the first LED. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: expose DualSense lightbar through a multi-color LED.Roderick Colenbrander2021-10-271-0/+72
| | | | | | | | | The DualSense lightbar has so far been supported, but it was not yet adjustable from user space. This patch exposes it through a multi-color LED. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* HID: playstation: add DualSense player LED support.Roderick Colenbrander2021-02-181-1/+82
| | | | | | | | | | | | | | | | The DualSense features 5 player LEDs below its touchpad, which are meant as player id indications. The LEDs are configured with a player ID determined by an ID allocator, which assign player ids to ps_device instances. This patch is a combination of the following original patches minus use of LED framework APIs: - HID: playstation: add DualSense player LEDs support. - HID: playstation: DualSense set LEDs to default player id. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add microphone mute support for DualSense.Roderick Colenbrander2021-02-181-0/+44
| | | | | | | | | | | | | | The DualSense controller has a built-in microphone exposed as an audio device over USB (or HID using Bluetooth). A dedicated button on the controller handles mute, but software has to configure the device to mute the audio stream. This patch captures the mute button and schedules an output report to mute/unmute the audio stream as well as toggle the mute LED. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add initial DualSense lightbar support.Roderick Colenbrander2021-02-181-0/+65
| | | | | | | | | Provide initial support for the DualSense lightbar and configure it with a default PlayStation blue color. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: fix array size comparison (off-by-one)Colin Ian King2021-02-171-1/+1
| | | | | | | | | | | The comparison of value with the array size ps_gamepad_hat_mapping appears to be off-by-one. Fix this by using >= rather than > for the size comparison. Addresses-Coverity: ("Out-of-bounds read") Fixes: bc2e15a9a022 ("HID: playstation: initial DualSense USB support.") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: fix unused variable in ps_battery_get_property.Roderick Colenbrander2021-02-171-2/+2
| | | | | | | | | The ret variable in ps_battery_get_property is set in an error path, but never actually returned. Change the function to return ret. Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: report DualSense hardware and firmware version.Roderick Colenbrander2021-02-171-0/+81
| | | | | | | | | | | Retrieve DualSense hardware and firmware information using a vendor specific feature report. Report the data through sysfs and also report using hid_info as there can be signficant differences between versions. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add DualSense classic rumble support.Roderick Colenbrander2021-02-111-2/+206
| | | | | | | | | | | | The DualSense features a haptics system based on voicecoil motors, which requires PCM data (or special HID packets using Bluetooth). There is no appropriate API yet in the Linux kernel to expose these. The controller also provides a classic rumble feature for backwards compatibility. Expose this classic rumble feature using the FF framework. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add DualSense Bluetooth support.Roderick Colenbrander2021-02-111-0/+41
| | | | | | | | | | | | This patch adds support for the DualSense when operating in Bluetooth mode. The device has the same behavior as the DualShock 4 in that by default it sends a limited input report (0x1), but after requesting calibration data, it switches to an extended input report (report 49), which adds data for touchpad, motion sensors, battery and more. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: track devices in list.Roderick Colenbrander2021-02-111-0/+46
| | | | | | | | | Track devices in a list, so we can detect when a device is connected twice when using Bluetooth and USB. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add DualSense accelerometer and gyroscope support.Roderick Colenbrander2021-02-111-0/+203
| | | | | | | | | | The DualSense features an accelerometer and gyroscope. The data is embedded into the main HID input reports. Expose both sensors through through a separate evdev node. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add DualSense touchpad support.Roderick Colenbrander2021-02-111-0/+66
| | | | | | | | Implement support for DualSense touchpad as a separate input device. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: add DualSense battery support.Roderick Colenbrander2021-02-111-3/+137
| | | | | | | | Report DualSense battery status information through power_supply class. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: use DualSense MAC address as unique identifier.Roderick Colenbrander2021-02-111-0/+58
| | | | | | | | Use the DualSense MAC address as a unique identifier for the HID device. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
* HID: playstation: initial DualSense USB support.Roderick Colenbrander2021-02-111-0/+328
Implement support for PlayStation DualSense gamepad in USB mode. Support features include buttons and sticks, which adhere to the Linux gamepad spec. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>