Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 99-custom-device-pollrates.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable custom-device-pollrates.service
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ git apply ../Linux-Pollrate-Patch/pollrate.patch

The way to compile and install the kernel is distribution specific.


File locations:

/etc/custom-device-pollrates/custom-device-pollrates.conf
/usr/bin/custom-device-pollrates.sh
/usr/lib/systemd/system/custom-device-pollrates.service
/usr/lib/systemd/system-presets/99-custom-device-pollrates.preset

Start the service:

# systemctl daemon-reload
# systemctl enable --now custom-device-pollrates.service

Add devices here:
/etc/custom-device-pollrates/custom-device-pollrates.conf

Fedora rpm build spec sheet included for custom-device-pollrates patch.


# Legalese

This program is provided under the terms and condiditions of the GNU General Public License version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand Down
25 changes: 25 additions & 0 deletions custom-device-pollrates.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Format:
# vendorid:deviceid:rate
#
# Polling Rates:
# 1=1000Hz,2=500Hz,4=250Hz,8=125Hz
#
# Ex (PS5 DualSense, 1000Mhz polling rate):
# 054c:0ce6:1
#
# One entry per line
#
#
# To allow these devices to have custom
# pollrates, uncomment the device or alternatively
# add a new device configuration line, then restart
# the service with:
#
# sudo systemctl restart custom-device-pollrates.service
# -------------SONY-------------
# DS4
#054c:09cc:1
# DS5
#054c:0ce6:1
# -------------SONY-------------

10 changes: 10 additions & 0 deletions custom-device-pollrates.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Set custom polling rates for specific devices

[Service]
Type=simple
ExecStart=/usr/bin/bash /usr/bin/custom-device-pollrates.sh

[Install]
WantedBy=multi-user.target

29 changes: 29 additions & 0 deletions custom-device-pollrates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -m

# Gather device poll rate settings from /etc/custom-device-pollrates/custom-device-pollrates.conf
DEVICES=$(grep -v '^\s*$\|^\s*\#' /etc/custom-device-pollrates/custom-device-pollrates.conf | paste -sd, -)

# Set new polling rate for devices
echo "$DEVICES" | sudo tee /sys/module/usbcore/parameters/interrupt_interval_override > /dev/null


# Reload all USB devices

for xhci in /sys/bus/pci/drivers/?hci_hcd ; do

if ! cd $xhci ; then
echo Failed to change directory to $xhci
exit 1
fi

echo Resetting devices from $xhci...

for i in ????:??:??.? ; do
echo -n "$i" > unbind
echo -n "$i" > bind
done
sleep 1
done


57 changes: 57 additions & 0 deletions custom-device-pollrates.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
%global _default_patch_fuzz 2
%global baserelease 4


Name: custom-device-pollrates
Version: 1.0.0
Release: %{baserelease}%{?dist}
Summary: Allows setting custom polling rates for USB devices, requires kernel patch.

License: GPLv2+
URL: https://github.com/GloriousEggroll/Linux-Pollrate-Patch


# Sources for custom-device-pollrates
Source0: custom-device-pollrates.sh
Source1: 99-custom-device-pollrates.preset
Source2: custom-device-pollrates.service
Source3: custom-device-pollrates.conf

BuildRequires: systemd-rpm-macros

%description
This is a service that is built around the following kernel patch from:
https://github.com/KarsMulder/Linux-Pollrate-Patch
It allows to create a list of USB devices in
/etc/custom-device-pollrates/custom-device-pollrates.conf
with different poll rate values. Once entries are added simply restart
the service with `systemctl restart custom-device-pollrates.service`
You can use a tool such as evhz (https://git.sr.ht/~iank/evhz) to check polling rates.

%install
# custom-device-pollrates
mkdir -p %{buildroot}%{_bindir}/
mkdir -p %{buildroot}%{_presetdir}/
mkdir -p %{buildroot}%{_unitdir}/
mkdir -p %{buildroot}%{_sysconfdir}/custom-device-pollrates
install -Dm755 %{SOURCE0} %{buildroot}%{_bindir}/custom-device-pollrates.sh
install -Dm644 %{SOURCE1} %{buildroot}%{_prefix}/lib/systemd/system-preset/99-custom-device-pollrates.preset
install -Dm644 %{SOURCE2} %{buildroot}%{_prefix}/lib/systemd/system/custom-device-pollrates.service
install -Dm644 %{SOURCE3} %{buildroot}%{_sysconfdir}/custom-device-pollrates/custom-device-pollrates.conf

%post
%systemd_post custom-device-pollrates.service

%preun
%systemd_preun custom-device-pollrates.service

%postun
%systemd_postun custom-device-pollrates.service

%files
%{_bindir}/custom-device-pollrates.sh
%{_prefix}/lib/systemd/system/custom-device-pollrates.service
%{_prefix}/lib/systemd/system-preset/99-custom-device-pollrates.preset
%{_sysconfdir}/custom-device-pollrates/custom-device-pollrates.conf

%changelog