Skip to content

Commit

Permalink
Fix multicolor problem on 5.9 or older kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
mob41 committed Mar 16, 2022
1 parent 054f5e8 commit d7d4262
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE=playstation-joy-dkms
VERSION=20220316-1
VERSION=20220317-1-multicolor
DEB_BUILD_PATH=build/$(PACKAGE)_$(VERSION)
DKMS_SRC_PATH=build/$(PACKAGE)_$(VERSION)/usr/src/$(PACKAGE)-$(VERSION)

Expand All @@ -25,14 +25,26 @@ prepare:
mkdir -p $(DEB_BUILD_PATH)/DEBIAN
mkdir -p $(DKMS_SRC_PATH)
# generate config and scripts from templates
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" dkms-template.conf > $(DKMS_SRC_PATH)/dkms.conf
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" control-template > $(DEB_BUILD_PATH)/DEBIAN/control
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" pre-uninstall-template.sh > $(DEB_BUILD_PATH)/DEBIAN/prerm
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" dkms-template.conf > $(DKMS_SRC_PATH)/dkms.conf; \
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" control-template > $(DEB_BUILD_PATH)/DEBIAN/control; \
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" pre-uninstall-template.sh > $(DEB_BUILD_PATH)/DEBIAN/prerm; \
sed -e "s/@@PACKAGE@@/$(PACKAGE)/g" -e "s/@@VERSION@@/$(VERSION)/g" post-install-template.sh > $(DEB_BUILD_PATH)/DEBIAN/postinst
chmod 0555 $(DEB_BUILD_PATH)/DEBIAN/prerm
chmod 0555 $(DEB_BUILD_PATH)/DEBIAN/postinst
# copy src
cp -v src/playstation-joy-dkms/* $(DKMS_SRC_PATH)/
if [ "$$INCLUDE_LED_CLASS_MULTICOLOR" = true ] ; then \
echo Applying LED class multicolor patches; \
patch -u src/linux/drivers/hid/hid-playstation.c patches/0091-hid-playstation-use-our-multicolor.patch; \
patch -u src/linux/include/linux/led-class-multicolor.h patches/0092-enable-led-class-multicolor.patch; \
patch -u src/linux/drivers/leds/led-class-multicolor.c patches/0093-led-class-multicolor-source-fix-header.patch; \
echo Copying led-class-multicolor files; \
cp -v src/playstation-joy-dkms/leds.h $(DKMS_SRC_PATH)/; \
cp -v src/playstation-joy-dkms/led-class-multicolor.* $(DKMS_SRC_PATH)/; \
cp -v src/playstation-joy-dkms/Makefile.multicolor $(DKMS_SRC_PATH)/Makefile; \
else \
cp -v src/playstation-joy-dkms/Makefile.default $(DKMS_SRC_PATH)/Makefile; \
fi
cp -v src/playstation-joy-dkms/hid-* $(DKMS_SRC_PATH)/
# copy modprobe config
mkdir -p $(DEB_BUILD_PATH)/etc/modprobe.d
cp -v playstation-joy-dkms.conf $(DEB_BUILD_PATH)/etc/modprobe.d/
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ sudo apt-get update
sudo apt-get build-dep linux linux-image-$(uname -r)
```

> ::warning:: If you are using a kernel version below `5.9`, you must use the deb package ending with `-multicolor`.
> `5.9` kernels or older has no support for the LED class multicolor. This flag includes the patches and kernels for that.
> ::warning:: If you are using a kernel version higher or equal to `5.9`, you must **NOT** use the `-multicolor` package to avoid conflicts with the existing `led-class-multicolor` module.
> You can check by doing `modinfo led-class-multicolor`
4. Download latest release from [here](https://github.com/m2robocon/playstation-joy-dkms/releases/latest), or build it yourself using the instructions below.

5. Install required `playstation-joy-dkms` dependencies
Expand Down Expand Up @@ -95,6 +101,8 @@ PACKAGE=playstation-joy-dkms
VERSION=20220314-1
```

If you used the `INCLUDE_LED_CLASS_MULTICOLOR=true` flag, make sure to add `-multicolor` to the back of the version string to indicate it.

4. Package it with `make`

```bash
Expand All @@ -104,7 +112,11 @@ make deb # package into deb

# or simply:

# normal packaging without led-class-multicolor
make all

# package with led-class-multicolor
INCLUDE_LED_CLASS_MULTICOLOR=true make all
```

## What files are they?
Expand Down
11 changes: 11 additions & 0 deletions patches/0091-hid-playstation-use-our-multicolor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- hid-playstation-joy-old.c 2022-03-16 19:32:42.637553700 +0000
+++ hid-playstation-joy.c 2022-03-16 19:07:41.529202002 +0000
@@ -12,7 +12,7 @@
#include <linux/idr.h>
#include <linux/input/mt.h>
#include <linux/leds.h>
-#include <linux/led-class-multicolor.h>
+#include "led-class-multicolor.h"
#include <linux/module.h>

#include <asm/unaligned.h>
12 changes: 12 additions & 0 deletions patches/0092-enable-led-class-multicolor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- led-class-multicolor-old.h 2022-03-16 19:06:09.468540801 +0000
+++ led-class-multicolor.h 2022-03-16 19:33:18.023039699 +0000
@@ -30,7 +30,7 @@
return container_of(led_cdev, struct led_classdev_mc, led_cdev);
}

-#if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR)
+#if 1
/**
* led_classdev_multicolor_register_ext - register a new object of led_classdev
* class with support for multicolor LEDs

11 changes: 11 additions & 0 deletions patches/0093-led-class-multicolor-source-fix-header.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- led-class-multicolor-old.c 2022-03-16 19:06:04.611023929 +0000
+++ led-class-multicolor.c 2022-03-16 19:08:24.118355092 +0000
@@ -5,7 +5,7 @@

#include <linux/device.h>
#include <linux/init.h>
-#include <linux/led-class-multicolor.h>
+#include "led-class-multicolor.h"
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
File renamed without changes.
14 changes: 14 additions & 0 deletions src/playstation-joy-dkms/Makefile.multicolor
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CONFIG_MODULE_SIG=n

obj-m += hid-playstation-joy.o hid-sony-joy.o led-class-multicolor.o

KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build

all:
$(MAKE) -C $(KERNEL_SRC) V=0 M=$$PWD

install:
cp -v *.ko $(DESTDIR)/

clean:
rm -rf deps.h *.o *.ko *.mod.c *.symvers *.order .*.cmd .tmp_versions
1 change: 1 addition & 0 deletions src/playstation-joy-dkms/led-class-multicolor.c
1 change: 1 addition & 0 deletions src/playstation-joy-dkms/led-class-multicolor.h
1 change: 1 addition & 0 deletions src/playstation-joy-dkms/leds.h

0 comments on commit d7d4262

Please sign in to comment.