Could we get USB polling for DS4 gamepad OC to 1000Hz when wired?

So it seems that for some reason my polling rate is even lower than normal with DS4 gamepad. It’s 5ms instead of 4ms which would mean that it’s 200Hz instead of 250Hz that it should be.

I would actually like the 1000Hz polling rate with wired that is used with BT anyway, but for some stupid reason not for wired. I have the DS4 V2 controller and it would be nice to have less input lag with it.

I think that Bazzite and Nobara already patches it to work with 1000Hz and it would be very nice if Manjaro could jump to the same bandwagon cause otherwise i would need to start patching a kernel etc. which is not really my forte.

What is also weird is that the polling rate is just 200Hz for me for some reason unknown.

There is some discussion linked to the subject on reddit. They recommend to use the out-of-tree Linux kernel module usb-hid-oc, see here:

If you want to use it you need the kernel-headers, dkms, base-devel and git, they could be installed all together via:

$ sudo pacman -Syu base-devel dkms git $(pacman -Qsq "^linux" | grep "^linux[0-9]*[-rt]*$" | awk '{print $1"-headers"}' ORS=' ')

The module itself could be installed by installing usb_oc-dkms from AUR, if you have for example yay as AUR helpfer then:

$ yay -S usb_oc-dkms

To load it:

$ sudo insmod usb_hid_oc.ko

You need to configure it. Create the file /etc/modprobe.d/usb_oc.conf with the content

options usb_oc interrupt_interval_override=XXXX:YYYY:Z

where XXXX is the vendor ID of your USB device and YYYY is the product ID. When the gamepad is connected this information can be gained by

$ lsusb

The first 4 characters before the colon is the vendor ID, the 4 characters after the colon is the product ID.

Z needs to be replaced by the rate. If you choose 1 to replace Z then you should achieve 1000Hz (2: 500Hz, 4: 250Hz)

It could be helpful - if you use grub - to modifiy your /etc/default/grub and to add a kernel command line argument, for example usb_hid_oc.rate=1 (1 for 1000Hz) - but probably not needed.

To verify if the module is loaed and parameters have been set properly you could run:

$ lsmod | grep usb_oc

If all this works you could load the module at each boot via:

$ echo "usb_oc" | sudo tee /etc/modules-load.d/usb_oc.conf

Thanks, but due to the AUR incidents i don’t think that AUR is personally an option for me.

I can understand this very well. In this case - the C-source code of usb_oc.c is only about 80 lines, so if you really suffer from the polling rate you could built the module easily yourself from scratch.

Source code of usb_oc.c

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/usb.h>

MODULE_LICENSE(“GPL”);
MODULE_AUTHOR(“p0358”);
MODULE_DESCRIPTION(“USB HID Overclock via USB Descriptor override”);
MODULE_VERSION(“1.1”);

static ushort vid = 0;
module_param(vid, ushort, 0444);
MODULE_PARM_DESC(vid, “Vendor ID of the device to overclock”);

static ushort pid = 0;
module_param(pid, ushort, 0444);
MODULE_PARM_DESC(pid, “Product ID of the device to overclock”);

static byte bInterval = 1;
module_param(bInterval, byte, 0444);
MODULE_PARM_DESC(bInterval, “bInterval value to force (1 = 1ms/1000Hz for USB 1.1, 4 = 1ms/1000Hz for USB 2.0+)”);

static int usb_oc_notify(struct notifier_block *self, unsigned long action, void *dev)
{
struct usb_device *udev = dev;
int i, j, k;

if (action != USB_DEVICE_ADD)
    return NOTIFY_DONE;

if (le16_to_cpu(udev->descriptor.idVendor) != vid || le16_to_cpu(udev->descriptor.idProduct) != pid)
    return NOTIFY_DONE;

dev_info(&udev->dev, "usb_oc: Target device detected (%04x:%04x), patching bInterval to %d...\n", vid, pid, bInterval);

for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
    struct usb_interface *intf = udev->actconfig->interface[i];
    for (j = 0; j < intf->num_altsetting; j++) {
        struct usb_host_interface *alts = &intf->altsetting[j];
        for (k = 0; k < alts->desc.bNumEndpoints; k++) {
            struct usb_host_endpoint *ep = &alts->endpoint[k];
            if (usb_endpoint_xfer_int(&ep->desc)) {
                dev_info(&udev->dev, "usb_oc: Patching endpoint %d (was bInterval=%d)\n", k, ep->desc.bInterval);
                ep->desc.bInterval = bInterval;
            }
        }
    }
}

return NOTIFY_OK;

}

static struct notifier_block usb_oc_nb = {
.notifier_call = usb_oc_notify,
};

static int __init usb_oc_init(void)
{
if (vid == 0 || pid == 0) {
pr_err(“usb_oc: vid and pid parameters are required!\n”);
return -EINVAL;
}
usb_register_notify(&usb_oc_nb);
pr_info(“usb_oc: Module loaded. Watching for device %04x:%04x\n”, vid, pid);
return 0;
}

static void __exit usb_oc_exit(void)
{
usb_unregister_notify(&usb_oc_nb);
pr_info(“usb_oc: Module unloaded.\n”);
}

module_init(usb_oc_init);
module_exit(usb_oc_exit);