Linux kernel patch to reduce HID(keyboard, joystick, etc.) input latency. [message #2705] |
Tue, 16 October 2012 11:10 |
|
This patch will decrease the USB HID polling interval to 1 millisecond, reducing latency by up to 7ms with most(hopefully) USB gamepads/joysticks.
Tested to work fine with an old "Logitech Dual Action", at least. You can confirm that it's working properly by running "evtest" on the joystick event device before the patch, and after, rapidly spinning the sticks on the joystick/gamepad, and noting the minimum times between events.
Use at your own risk. May cause button bounce issues with certain programs(especially if the keyboard's internal controller doesn't do any debouncing of its own, and relies on a relatively high USB polling interval to achieve the same sort of effect). Will probably reduce throughput of any bandwidth-hungry devices like USB flash drives. May cause problems if you have a ton of HID devices going through the same hub at some point. Will increase CPU load a bit.
--- linux-3.4.14.orig/drivers/hid/usbhid/hid-core.c 2012-10-12 13:44:59.000000000 -0700
+++ linux-3.4.14/drivers/hid/usbhid/hid-core.c 2012-10-16 01:30:58.000000000 -0700
@@ -1124,6 +1124,8 @@ static int usbhid_start(struct hid_devic
if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
interval = hid_mousepoll_interval;
+ interval = 1;
+
ret = -ENOMEM;
if (usb_endpoint_dir_in(endpoint)) {
if (usbhid->urbin)
[Updated on: Tue, 16 October 2012 11:14]
|
|
Re: Linux kernel patch to reduce HID(keyboard, joystick, etc.) input latency. [message #5329 is a reply to message #2705 ] |
Sat, 16 December 2017 13:33 |
|
No need to patch the kernel for that.
I think the kernel parameter usbhid.mousepoll should do the same. Just set it in /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="usbhid.mousepoll=1"
edit:
oh sorry, now I see it - you want the increased pollrate also for gamepads, not just for the mouse. Well, looks like the patch is needed in the end.
edit2:
I just had a look at a recent 4.x kernel and there is a new kernel parameters usbhid.jspoll (js for joystick) but I'm not sure if gamepads are joysticks.
switch (hid->collection->usage) {
case HID_GD_MOUSE:
if (hid_mousepoll_interval > 0)
interval = hid_mousepoll_interval;
break;
case HID_GD_JOYSTICK:
if (hid_jspoll_interval > 0)
interval = hid_jspoll_interval;
break;
}
[Updated on: Sat, 16 December 2017 17:19]
|
|
Re: Linux kernel patch to reduce HID(keyboard, joystick, etc.) input latency. [message #5580 is a reply to message #2705 ] |
Fri, 22 June 2018 07:45 |
|
this patch can be modified to interval=2 will help to reduce that problems with fully bloabed hubs?
|
|