Merge branch 'for-7.1/pidff' into for-linus

- various new per-device(-group) type quirks for pidff driver (Tomasz Pakuła)
This commit is contained in:
Jiri Kosina 2026-04-16 21:05:37 +02:00
commit 38d76018bb
3 changed files with 56 additions and 27 deletions

View File

@ -11364,14 +11364,6 @@ F: drivers/hid/hid-sensor-*
F: drivers/iio/*/hid-*
F: include/linux/hid-sensor-*
HID UNIVERSAL PIDFF DRIVER
M: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
M: Oleg Makarenko <oleg@makarenk.ooo>
L: linux-input@vger.kernel.org
S: Maintained
B: https://github.com/JacKeTUs/universal-pidff/issues
F: drivers/hid/hid-universal-pidff.c
HID VRC-2 CAR CONTROLLER DRIVER
M: Marcus Folkesson <marcus.folkesson@gmail.com>
L: linux-input@vger.kernel.org
@ -27279,6 +27271,15 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git
F: Documentation/hid/hiddev.rst
F: drivers/hid/usbhid/
USB HID PID DRIVERS (USB WHEELBASES, JOYSTICKS, RUDDERS, ...)
M: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
M: Oleg Makarenko <oleg@makarenk.ooo>
L: linux-input@vger.kernel.org
S: Maintained
B: https://github.com/JacKeTUs/universal-pidff/issues
F: drivers/hid/usbhid/hid-pidff*
F: drivers/hid/hid-universal-pidff.c
USB INTEL XHCI ROLE MUX DRIVER
M: Hans de Goede <hansg@kernel.org>
L: linux-usb@vger.kernel.org

View File

@ -13,6 +13,7 @@
#include <linux/input.h>
#include <linux/minmax.h>
#include <linux/slab.h>
#include <linux/stringify.h>
#include <linux/usb.h>
#define PID_EFFECTS_MAX 64
@ -81,7 +82,7 @@ static const u8 pidff_set_envelope[] = { 0x22, 0x5b, 0x5c, 0x5d, 0x5e };
#define PID_NEG_COEFFICIENT 4
#define PID_POS_SATURATION 5
#define PID_NEG_SATURATION 6
#define PID_DEAD_BAND 7
#define PID_DEADBAND 7
static const u8 pidff_set_condition[] = {
0x22, 0x23, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65
};
@ -618,14 +619,24 @@ static void pidff_set_condition_report(struct pidff_device *pidff,
effect->u.condition[i].center);
pidff_set_signed(&pidff->set_condition[PID_POS_COEFFICIENT],
effect->u.condition[i].right_coeff);
pidff_set_signed(&pidff->set_condition[PID_NEG_COEFFICIENT],
effect->u.condition[i].left_coeff);
pidff_set(&pidff->set_condition[PID_POS_SATURATION],
effect->u.condition[i].right_saturation);
pidff_set(&pidff->set_condition[PID_NEG_SATURATION],
effect->u.condition[i].left_saturation);
pidff_set(&pidff->set_condition[PID_DEAD_BAND],
effect->u.condition[i].deadband);
/* Omit Negative Coefficient if missing */
if (!(pidff->quirks & HID_PIDFF_QUIRK_MISSING_NEG_COEFFICIENT))
pidff_set_signed(&pidff->set_condition[PID_NEG_COEFFICIENT],
effect->u.condition[i].left_coeff);
/* Omit Negative Saturation if missing */
if (!(pidff->quirks & HID_PIDFF_QUIRK_MISSING_NEG_SATURATION))
pidff_set_signed(&pidff->set_condition[PID_NEG_SATURATION],
effect->u.condition[i].left_saturation);
/* Omit Deadband field if missing */
if (!(pidff->quirks & HID_PIDFF_QUIRK_MISSING_DEADBAND))
pidff_set(&pidff->set_condition[PID_DEADBAND],
effect->u.condition[i].deadband);
hid_hw_request(pidff->hid, pidff->reports[PID_SET_CONDITION],
HID_REQ_SET_REPORT);
}
@ -1053,6 +1064,11 @@ static int pidff_find_field_with_usage(int *usage_index,
return -1;
}
#define PIDFF_MISSING_FIELD(name, quirks) \
({ pr_debug("%s field not found, but that's OK\n", __stringify(name)); \
pr_debug("Setting MISSING_%s quirk\n", __stringify(name)); \
*quirks |= HID_PIDFF_QUIRK_MISSING_ ## name; })
/*
* Find fields from a report and fill a pidff_usage
*/
@ -1060,9 +1076,6 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
struct hid_report *report, int count, int strict,
u32 *quirks)
{
const u8 block_offset = pidff_set_condition[PID_PARAM_BLOCK_OFFSET];
const u8 delay = pidff_set_effect[PID_START_DELAY];
if (!report) {
pr_debug("%s, null report\n", __func__);
return -1;
@ -1080,17 +1093,23 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
continue;
}
if (table[i] == delay) {
pr_debug("Delay field not found, but that's OK\n");
pr_debug("Setting MISSING_DELAY quirk\n");
*quirks |= HID_PIDFF_QUIRK_MISSING_DELAY;
/* Field quirks auto-detection */
if (table[i] == pidff_set_effect[PID_START_DELAY])
PIDFF_MISSING_FIELD(DELAY, quirks);
} else if (table[i] == block_offset) {
pr_debug("PBO field not found, but that's OK\n");
pr_debug("Setting MISSING_PBO quirk\n");
*quirks |= HID_PIDFF_QUIRK_MISSING_PBO;
else if (table[i] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET])
PIDFF_MISSING_FIELD(PBO, quirks);
} else if (strict) {
else if (table[i] == pidff_set_condition[PID_NEG_COEFFICIENT])
PIDFF_MISSING_FIELD(NEG_COEFFICIENT, quirks);
else if (table[i] == pidff_set_condition[PID_NEG_SATURATION])
PIDFF_MISSING_FIELD(NEG_SATURATION, quirks);
else if (table[i] == pidff_set_condition[PID_DEADBAND])
PIDFF_MISSING_FIELD(DEADBAND, quirks);
else if (strict) {
pr_debug("failed to locate %d\n", i);
return -1;
}

View File

@ -21,6 +21,15 @@
/* Force all periodic effects to be uploaded as SINE */
#define HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY BIT(4)
/* Allow devices with missing negative coefficient in the set condition usage */
#define HID_PIDFF_QUIRK_MISSING_NEG_COEFFICIENT BIT(5)
/* Allow devices with missing negative saturation in the set condition usage */
#define HID_PIDFF_QUIRK_MISSING_NEG_SATURATION BIT(6)
/* Allow devices with missing deadband in the set condition usage */
#define HID_PIDFF_QUIRK_MISSING_DEADBAND BIT(7)
#ifdef CONFIG_HID_PID
int hid_pidff_init(struct hid_device *hid);
int hid_pidff_init_with_quirks(struct hid_device *hid, u32 initial_quirks);