diff options
author | Atahan Acar | 2022-09-20 14:34:48 +0300 |
---|---|---|
committer | Atahan Acar | 2022-09-20 14:34:48 +0300 |
commit | 8afc9b5755ec84f9c3a2341805dabe7baf25bcca (patch) | |
tree | eee56a8061f9ae8eabbd10b84682fa64f22f25df | |
download | aur-8afc9b5755ec84f9c3a2341805dabe7baf25bcca.tar.gz |
Initial commit
-rw-r--r-- | .SRCINFO | 19 | ||||
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | PKGBUILD | 46 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | hid-sony-blacklist.modprobe | 1 | ||||
-rw-r--r-- | hid-sony-panic-fix-dkms.dkms | 7 | ||||
-rw-r--r-- | hid-sony-panic-fix.patch | 43 |
8 files changed, 135 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..9940cca7ebe5 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,19 @@ +pkgbase = hid-sony-panic-fix-dkms + pkgdesc = A quick hack to the hid-sony driver meant for the third party / clone DS4 controllers that do not support HID feature report 0x81. + pkgver = 5.19.8 + pkgrel = 1 + arch = x86_64 + license = GPL2 + depends = dkms + source = hid-sony.c::https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/drivers/hid/hid-sony.c?h=v5.19.8 + source = hid-ids.h::https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/drivers/hid/hid-ids.h?h=v5.19.8 + source = Makefile + source = hid-sony-panic-fix-dkms.dkms + source = hid-sony-blacklist.modprobe + sha256sums = d06b36d69f723777a4cba2fcae34523002e39a9549e2e67136e520627f1a173f + sha256sums = 788bfdc38373898038b62e75f6a939105105843fcf0409fe39d0f2ea490f1642 + sha256sums = 72ee83c2a199afb5e30e8a6fb71c73667d86845284c2b6ca760e9d7b7b6a65d6 + sha256sums = 04a25acef8059630188ebbf398115c87bf27f97a8e37ce9a10d1d30387800610 + sha256sums = f4ab0b6941e353e861007a0bb6c468b4a7d027c56d530056fa686ad837616635 + +pkgname = hid-sony-panic-fix-dkms diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..1703f277d5af --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +src +pkg +hid-sony-panic-fix-dkms-*.pkg.tar.zst +hid-sony.c +hid-ids.h diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..5fdfed3eabd1 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +obj-m = hid-sony-panic-fix.o + +KVERSION = $(shell uname -r) +all: + make -C /lib/modules/$(KVERSION)/build V=1 M=$(PWD) modules +clean: + test ! -d /lib/modules/$(KVERSION) || make -C /lib/modules/$(KVERSION)/build V=1 M=$(PWD) clean diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..943d9b66efa0 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,46 @@ +# Maintainer: Atahan Acar <atahan at acar dot pw> +# pkgbuild based on https://github.com/Kyuunex/hid-sony-clone-fix-dkms + +_pkgbase='hid-sony-panic-fix' +pkgname=${_pkgbase}-dkms +pkgver=5.19.8 +pkgrel=1 +pkgdesc="A quick hack to the hid-sony driver meant for the third party / clone DS4 controllers that do not support HID feature report 0x81." +_srctag=v${pkgver} +license=('GPL2') +arch=('x86_64') +depends=('dkms') +source=("hid-sony.c::https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/drivers/hid/hid-sony.c?h=${_srctag}" + "hid-ids.h::https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/drivers/hid/hid-ids.h?h=${_srctag}" + "Makefile" + "hid-sony-panic-fix-dkms.dkms" + "hid-sony-blacklist.modprobe") +sha256sums=('d06b36d69f723777a4cba2fcae34523002e39a9549e2e67136e520627f1a173f' + '788bfdc38373898038b62e75f6a939105105843fcf0409fe39d0f2ea490f1642' + '72ee83c2a199afb5e30e8a6fb71c73667d86845284c2b6ca760e9d7b7b6a65d6' + '04a25acef8059630188ebbf398115c87bf27f97a8e37ce9a10d1d30387800610' + 'f4ab0b6941e353e861007a0bb6c468b4a7d027c56d530056fa686ad837616635') + +prepare(){ + local workdir="${srcdir}/workdir" + mkdir -p "${workdir}" + cp "${srcdir}/hid-sony.c" "${workdir}" + patch -d "${workdir}" -Np3 -i "${srcdir}/../hid-sony-panic-fix.patch" +} + +package() { + local dest="${pkgdir}/usr/src/${_pkgbase}-${pkgver}" + install -d "${dest}" + install -m 644 -T "${srcdir}/workdir/hid-sony.c" "${dest}/${_pkgbase}.c" + install -m 644 -T "${srcdir}/hid-ids.h" "${dest}/hid-ids.h" + install -m 644 -T "${srcdir}/Makefile" "${dest}/Makefile" + install -m 644 -T "${srcdir}/hid-sony-panic-fix-dkms.dkms" "${dest}/dkms.conf" + + sed -e "s/@_PKGBASE@/${_pkgbase}/" \ + -e "s/@PKGVER@/${pkgver}/" \ + -i "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf" + + # Blacklist the original hid_sony module + install -dm755 "${pkgdir}/usr/lib/modprobe.d" + install -Dm644 "${srcdir}/hid-sony-blacklist.modprobe" "${pkgdir}/usr/lib/modprobe.d/hid-sony-blacklist.conf" +} diff --git a/README b/README new file mode 100644 index 000000000000..773af1d106d6 --- /dev/null +++ b/README @@ -0,0 +1,7 @@ +hid-sony-panic-fix-dkms +======================= +This hack is based on https://github.com/Kyuunex/hid-sony-clone-fix-dkms +but it also adds a check to avoid a divide by zero. It removes the unused code +instead of just changing the value of the variable. + +Use at your own risk. diff --git a/hid-sony-blacklist.modprobe b/hid-sony-blacklist.modprobe new file mode 100644 index 000000000000..e6910aafcbbd --- /dev/null +++ b/hid-sony-blacklist.modprobe @@ -0,0 +1 @@ +blacklist hid_sony diff --git a/hid-sony-panic-fix-dkms.dkms b/hid-sony-panic-fix-dkms.dkms new file mode 100644 index 000000000000..8abb6f27d87d --- /dev/null +++ b/hid-sony-panic-fix-dkms.dkms @@ -0,0 +1,7 @@ +PACKAGE_NAME="@_PKGBASE@" +PACKAGE_VERSION="@PKGVER@" +MAKE[0]="make KVERSION=$kernelver" +CLEAN="make clean" +BUILT_MODULE_NAME[0]="@_PKGBASE@" +DEST_MODULE_LOCATION[0]="/kernel/drivers/hid" +AUTOINSTALL="yes" diff --git a/hid-sony-panic-fix.patch b/hid-sony-panic-fix.patch new file mode 100644 index 000000000000..c8060b3a363e --- /dev/null +++ b/hid-sony-panic-fix.patch @@ -0,0 +1,43 @@ +--- a/drivers/hid/hid-sony.c 2022-09-15 20:19:32.729266754 +0300 ++++ b/drivers/hid/hid-sony.c 2022-09-15 20:35:35.081264397 +0300 +@@ -1132,11 +1132,14 @@ + * Note: we swap numerator 'x' and 'numer' in mult_frac for + * precision reasons so we don't need 64-bit. + */ +- int calib_data = mult_frac(calib->sens_numer, +- raw_data - calib->bias, +- calib->sens_denom); ++ if (calib->sens_denom != 0) { ++ int calib_data = mult_frac(calib->sens_numer, ++ raw_data - calib->bias, ++ calib->sens_denom); ++ ++ input_report_abs(sc->sensor_dev, calib->abs_code, calib_data); ++ } + +- input_report_abs(sc->sensor_dev, calib->abs_code, calib_data); + offset += 2; + } + input_sync(sc->sensor_dev); +@@ -2617,21 +2620,6 @@ + if (!buf) + return -ENOMEM; + +- /* +- * The MAC address of a DS4 controller connected via USB can be +- * retrieved with feature report 0x81. The address begins at +- * offset 1. +- */ +- ret = hid_hw_raw_request(sc->hdev, 0x81, buf, +- DS4_FEATURE_REPORT_0x81_SIZE, HID_FEATURE_REPORT, +- HID_REQ_GET_REPORT); +- +- if (ret != DS4_FEATURE_REPORT_0x81_SIZE) { +- hid_err(sc->hdev, "failed to retrieve feature report 0x81 with the DualShock 4 MAC address\n"); +- ret = ret < 0 ? ret : -EINVAL; +- goto out_free; +- } +- + memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address)); + + snprintf(sc->hdev->uniq, sizeof(sc->hdev->uniq), |