HID: quirks: add quirk to always keep device open
PATCH 1/2 HID: quirks: add quirk to always keep device open
Some devices expect the host to open the device shortly after it is connected. If this does not occur, they may freeze or disconnect. A quirk allows these devices to function properly without userspace hacks.
The existing hid-axff driver solves this problem for some generic controllers. This implementation is modelled after that driver, which still needs to exist for force feedback on the controllers that use it.
--- drivers/hid/hid-generic.c | 23 ++++++++++++++++++++++- include/linux/hid.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-)
drivers/hid/hid-generic.c +22 -1
@@ -67,7 +67,27 @@ static int hid_generic_probe(struct hid_device *hdev,if (ret)return ret; -return hid_hw_start (hdev,HID_CONNECT_DEFAULT ); + ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT ); +if (ret) +return ret; + +if (hdev->quirks &HID_QUIRK_KEEP_OPEN ) { + ret =hid_hw_open (hdev); +if (ret) { +hid_hw_stop (hdev); +return ret; + } + } + +return 0 ; +} + +static void hid_generic_remove (struct hid_device *hdev) +{ +if (hdev->quirks &HID_QUIRK_KEEP_OPEN ) +hid_hw_close (hdev); + +hid_hw_stop (hdev); }static int hid_generic_reset_resume (struct hid_device *hdev)
@@ -89,6 +109,7 @@ static struct hid_driver hid_generic = { .id_table = hid_table, .match = hid_generic_match, .probe = hid_generic_probe, + .remove = hid_generic_remove, .reset_resume = hid_generic_reset_resume, };module_hid_driver (hid_generic);
include/linux/hid.h +2 -0
@@ -388,6 +388,7 @@ struct hid_item {* | @HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE: * | @HID_QUIRK_IGNORE_SPECIAL_DRIVER * | @HID_QUIRK_POWER_ON_AFTER_BACKLIGHT +* | @HID_QUIRK_KEEP_OPEN: * | @HID_QUIRK_FULLSPEED_INTERVAL: * | @HID_QUIRK_NO_INIT_REPORTS: * | @HID_QUIRK_NO_IGNORE:
@@ -416,6 +417,7 @@ struct hid_item {#define HID_QUIRK_NOINVERT BIT(21)#define HID_QUIRK_IGNORE_SPECIAL_DRIVER BIT(22)#define HID_QUIRK_POWER_ON_AFTER_BACKLIGHT BIT(23) +#define HID_QUIRK_KEEP_OPEN BIT(24)#define HID_QUIRK_FULLSPEED_INTERVAL BIT(28)#define HID_QUIRK_NO_INIT_REPORTS BIT(29)#define HID_QUIRK_NO_IGNORE BIT(30)
Signature · 1 line
2.53.0
PATCH 2/2 HID: quirks: add HID_QUIRK_KEEP_OPEN for 8BitDo Pro 3
According to a mailing list report [1], this controller's predecessor has the same issue. However, it uses the xpad driver instead of HID, so this quirk wouldn't apply.
[1]: https://lore.kernel.org/linux-input/[email protected]/
--- drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+)
drivers/hid/hid-ids.h +3 -0
@@ -22,6 +22,9 @@#define USB_DEVICE_ID_3M2256 0x0502#define USB_DEVICE_ID_3M3266 0x0506 +#define USB_VENDOR_ID_8BITDO 0x2dc8 +#define USB_DEVICE_ID_8BITDO_PRO_3 0x6009 +#define USB_VENDOR_ID_A4TECH 0x09da#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a
drivers/hid/hid-quirks.c +1 -0
@@ -25,6 +25,7 @@*/ static const struct hid_device_id hid_quirks[] = { + {HID_USB_DEVICE (USB_VENDOR_ID_8BITDO ,USB_DEVICE_ID_8BITDO_PRO_3 ),HID_QUIRK_KEEP_OPEN }, {HID_USB_DEVICE (USB_VENDOR_ID_AASHIMA ,USB_DEVICE_ID_AASHIMA_GAMEPAD ),HID_QUIRK_BADPAD }, {HID_USB_DEVICE (USB_VENDOR_ID_AASHIMA ,USB_DEVICE_ID_AASHIMA_PREDATOR ),HID_QUIRK_BADPAD }, {HID_USB_DEVICE (USB_VENDOR_ID_ADATA_XPG ,USB_VENDOR_ID_ADATA_XPG_WL_GAMING_MOUSE ),HID_QUIRK_ALWAYS_POLL },
Signature · 1 line
2.53.0
Benjamin Tissoires
maintainerQuoted 7 lines · leo vriska
Some devices expect the host to open the device shortly after it is connected. If this does not occur, they may freeze or disconnect. A quirk allows these devices to function properly without userspace hacks.
The existing hid-axff driver solves this problem for some generic controllers. This implementation is modelled after that driver, which still needs to exist for force feedback on the controllers that use it.
It seems 2/2 is dealing with a USB device. So why not simply make use of HID_QUIRK_ALWAYS_POLL?
Cheers,
Benjamin
Quoted 71 lines
Signed-off-by leo vriska <[email protected]>--- drivers/hid/hid-generic.c | 23 ++++++++++++++++++++++- include/linux/hid.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-)drivers/hid/hid-generic.c +22
-1@@ -67,7 +67,27 @@ static int hid_generic_probe(struct hid_device *hdev,if (ret)return ret; -return hid_hw_start (hdev,HID_CONNECT_DEFAULT ); + ret =hid_hw_start (hdev,HID_CONNECT_DEFAULT ); +if (ret) +return ret; + +if (hdev->quirks &HID_QUIRK_KEEP_OPEN ) { + ret =hid_hw_open (hdev); +if (ret) { +hid_hw_stop (hdev); +return ret; + } + } + +return 0 ; +} + +static void hid_generic_remove (struct hid_device *hdev) +{ +if (hdev->quirks &HID_QUIRK_KEEP_OPEN ) +hid_hw_close (hdev); + +hid_hw_stop (hdev); }static int hid_generic_reset_resume (struct hid_device *hdev)@@ -89,6 +109,7 @@ static struct hid_driver hid_generic = { .id_table = hid_table, .match = hid_generic_match, .probe = hid_generic_probe, + .remove = hid_generic_remove, .reset_resume = hid_generic_reset_resume, };module_hid_driver (hid_generic);include/linux/hid.h +2
-0@@ -388,6 +388,7 @@ struct hid_item {* | @HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE: * | @HID_QUIRK_IGNORE_SPECIAL_DRIVER * | @HID_QUIRK_POWER_ON_AFTER_BACKLIGHT +* | @HID_QUIRK_KEEP_OPEN: * | @HID_QUIRK_FULLSPEED_INTERVAL: * | @HID_QUIRK_NO_INIT_REPORTS: * | @HID_QUIRK_NO_IGNORE: @@ -416,6 +417,7 @@ struct hid_item {#define HID_QUIRK_NOINVERT BIT(21)#define HID_QUIRK_IGNORE_SPECIAL_DRIVER BIT(22)#define HID_QUIRK_POWER_ON_AFTER_BACKLIGHT BIT(23) +#define HID_QUIRK_KEEP_OPEN BIT(24)#define HID_QUIRK_FULLSPEED_INTERVAL BIT(28)#define HID_QUIRK_NO_INIT_REPORTS BIT(29)#define HID_QUIRK_NO_IGNORE BIT(30)Signature · 1 line
2.53.0
Hi,
Quoted 2 lines
It seems 2/2 is dealing with a USB device. So why not simply make use of
HID_QUIRK_ALWAYS_POLL?
It seems like I misunderstood what HID_QUIRK_ALWAYS_POLL did when I was reading the code before writing this patch. Sorry about that! It does seem like a cleaner solution to this problem, and I'll send an updated patch that just enables it for this device.
Thanks,
leo vriska