From 23255595f7630a1b4925f62bd08b596cf88a5ce1 Mon Sep 17 00:00:00 2001 From: Oleg Date: Wed, 29 May 2024 23:38:38 +0300 Subject: [PATCH] Small changes to initialization of quirks --- hid-pidff.c | 30 ++---------------------------- hid-pidff.h | 13 +++++++++---- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/hid-pidff.c b/hid-pidff.c index 608c15e..c0493b6 100644 --- a/hid-pidff.c +++ b/hid-pidff.c @@ -1250,7 +1250,7 @@ static int pidff_check_autocenter(struct pidff_device *pidff, /* * Check if the device is PID and initialize it */ -int hid_pidff_init(struct hid_device *hid) +int hid_pidff_init(struct hid_device *hid, const struct hid_device_id *id) { struct pidff_device *pidff; struct hid_input *hidinput = list_entry(hid->inputs.next, @@ -1272,7 +1272,7 @@ int hid_pidff_init(struct hid_device *hid) return -ENOMEM; pidff->hid = hid; - pidff->quirks = 0; + pidff->quirks |= id->device_data; hid_device_io_start(hid); @@ -1350,29 +1350,3 @@ int hid_pidff_init(struct hid_device *hid) kfree(pidff); return error; } - -/* - * Check if the device is PID and initialize it - * Add quirks after initialisation - */ -int hid_pidff_init_with_quirks(struct hid_device *hid, unsigned quirks) -{ - int error = hid_pidff_init(hid); - - if (error) - return error; - - struct hid_input *hidinput = list_entry(hid->inputs.next, - struct hid_input, list); - struct input_dev *dev = hidinput->input; - struct pidff_device *pidff = dev->ff->private; - - /* set quirks on the pidff device */ - hid_device_io_start(hid); - pidff->quirks |= quirks; - hid_device_io_stop(hid); - - hid_dbg(dev, "Device quirks: %d\n", pidff->quirks); - - return 0; -} diff --git a/hid-pidff.h b/hid-pidff.h index 90eab45..1690f47 100644 --- a/hid-pidff.h +++ b/hid-pidff.h @@ -8,15 +8,20 @@ * Substitute 0 length with 0xffff to resolve issues with * infinite effects coming from windows API */ -#define PIDFF_QUIRK_FIX_0_INFINITE_LENGTH BIT(0) +#define PIDFF_QUIRK_FIX_0_INFINITE_LENGTH BIT(0) /* * Ignore direction for spring/damping/friction/inertia effects * and always set 16384 */ -#define PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(1) +#define PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(1) -int hid_pidff_init(struct hid_device *hid); -int hid_pidff_init_with_quirks(struct hid_device *hid, unsigned quirks); +/* + * Skip initialization of 0xA7 descriptor (Delay effect) +*/ +#define PIDFF_QUIRK_NO_DELAY_EFFECT BIT(2) + + +int hid_pidff_init(struct hid_device *hid, const struct hid_device_id *id); #endif