History log of /linux-master/drivers/hid/hid-playstation.c
Revision Date Author Comments
# 6f7dbbd5 05-Jan-2023 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: correct DualSense gyro bias handling.

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>


# 12b18bc2 05-Jan-2023 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: correct DualShock4 gyro bias handling.

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>


# 5e25a8cd 05-Jan-2023 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: fix DualShock4 unreachable calibration code.

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>


# ccf1e162 05-Jan-2023 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: sanity check DualSense calibration data.

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>


# 74cb485f 05-Jan-2023 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: sanity check DualShock4 calibration data.

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>


# 0ee29814 12-Dec-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: fix free of uninialized pointer for DS4 in Bluetooth.

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


# da03e502 16-Nov-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: fix DualShock4 bluetooth CRC endian issue.

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>


# 54980d30 16-Nov-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: fix DualShock4 bluetooth memory corruption bug.

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>


# c64ed0cd 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add DualShock4 dongle support.

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>


# 58feecb4 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: set default DualShock4 BT poll interval to 4ms.

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>


# 2d77474a 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add DualShock4 bluetooth support.

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>


# a23b063b 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add option to ignore CRC in ps_get_report.

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>


# 82d93f64 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: support DualShock4 lightbar blink.

Support lightbar blink through LEDs framework.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 4521109a 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: support DualShock4 lightbar.

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>


# 316f57fb 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: make LED brightness adjustable in ps_led_register.

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>


# 4e463ec4 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: Add DualShock4 rumble support.

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>


# 12882ed8 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add DualShock4 accelerometer and gyroscope support.

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>


# 75203824 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add DualShock4 touchpad support.

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>


# 8871ed30 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add DualShock4 battery support.

Provide DualShock4 battery support through powersupply framework.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 9a62280a 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: report DualShock4 hardware and firmware version.

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>


# f55b9b56 29-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: initial DualShock4 USB support.

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>


# 9fecab24 10-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: support updated DualSense rumble mode.

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


# b8a968ef 10-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: add initial DualSense Edge controller support

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


# 182934a1 10-Oct-2022 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: stop DualSense output work on remove.

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


# b4a9af9b 04-Aug-2022 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

HID: playstation: convert to use dev_groups

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>


# 3c92cb4c 27-Oct-2021 Jiri Kosina <jkosina@suse.cz>

HID: playstation: fix return from dualsense_player_led_set_brightness()

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>


# 8c0ab553 08-Sep-2021 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: expose DualSense player LEDs through LED class.

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>


# fc97b4d6 08-Sep-2021 Roderick Colenbrander <roderick@gaikai.com>

HID: playstation: expose DualSense lightbar through a multi-color LED.

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>


# 949aaccd 16-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add DualSense player LED support.

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>


# c26e48b1 16-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add microphone mute support for DualSense.

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>


# 8e5198a1 16-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add initial DualSense lightbar support.

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>


# 50ab1ffd 15-Feb-2021 Colin Ian King <colin.king@canonical.com>

HID: playstation: fix array size comparison (off-by-one)

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>


# 5fb52551 11-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: fix unused variable in ps_battery_get_property.

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>


# 0b25b55d 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: report DualSense hardware and firmware version.

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>


# 51151098 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add DualSense classic rumble support.

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>


# 799b2b53 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add DualSense Bluetooth support.

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>


# 53f04e83 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: track devices in list.

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>


# 402987c5 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add DualSense accelerometer and gyroscope support.

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>


# f6bb05fc 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add DualSense touchpad support.

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>


# d30bca44 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: add DualSense battery support.

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>


# b99dcefd 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: use DualSense MAC address as unique identifier.

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>


# bc2e15a9 07-Feb-2021 Roderick Colenbrander <roderick.colenbrander@sony.com>

HID: playstation: initial DualSense USB support.

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>