emilyst / hid-nx-dkms

Alternative Linux kernel HID driver for Nintendo Switch controllers
GNU General Public License v2.0
37 stars 4 forks source link

compilation for older kernels #1

Closed dmanlfc closed 2 years ago

dmanlfc commented 2 years ago

it would be great to allow older kernels used with arm boards to leverage the hid-nx driver. here is an example with the 5.10.128 kernel used with amlogic boards (s922x). the error is the same with the RPi4 using the 5.15.x kernel.

PATH="/s922x/host/bin:/s922x/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" PKG_CONFIG="/s922x/host/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="/s922x/host/lib/pkgconfig:/s922x/host/share/pkgconfig" BR_BINARIES_DIR=/s922x/images KCFLAGS=-Wno-attribute-alias /usr/bin/make -j17 -C /s922x/build/linux-5.10.128 HOSTCC="/s922x/host/bin/ccache /usr/bin/gcc -O2 -I/s922x/host/include -L/s922x/host/lib -Wl,-rpath,/s922x/host/lib" ARCH=arm64 INSTALL_MOD_PATH=/s922x/target CROSS_COMPILE="/s922x/host/bin/aarch64-buildroot-linux-gnu-" WERROR=0 DEPMOD=/s922x/host/sbin/depmod INSTALL_MOD_STRIP=1  PWD=/s922x/build/hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/. M=/s922x/build/hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/. modules
make[1]: Entering directory '/s922x/build/linux-5.10.128'
  CC [M]  /s922x/build/hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/./hid-nx.o
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c:546:9: error: ‘LED_FUNCTION_PLAYER1’ undeclared here (not in a function); did you mean ‘LED_FUNCTION_POWER’?
  546 |         LED_FUNCTION_PLAYER1,
      |         ^~~~~~~~~~~~~~~~~~~~
      |         LED_FUNCTION_POWER
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c:547:9: error: ‘LED_FUNCTION_PLAYER2’ undeclared here (not in a function); did you mean ‘LED_FUNCTION_POWER’?
  547 |         LED_FUNCTION_PLAYER2,
      |         ^~~~~~~~~~~~~~~~~~~~
      |         LED_FUNCTION_POWER
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c:548:9: error: ‘LED_FUNCTION_PLAYER3’ undeclared here (not in a function); did you mean ‘LED_FUNCTION_POWER’?
  548 |         LED_FUNCTION_PLAYER3,
      |         ^~~~~~~~~~~~~~~~~~~~
      |         LED_FUNCTION_POWER
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c:549:9: error: ‘LED_FUNCTION_PLAYER4’ undeclared here (not in a function); did you mean ‘LED_FUNCTION_POWER’?
  549 |         LED_FUNCTION_PLAYER4,
      |         ^~~~~~~~~~~~~~~~~~~~
      |         LED_FUNCTION_POWER
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c: In function ‘nx_con_leds_create’:
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c:2210:39: error: ‘LED_FUNCTION_PLAYER5’ undeclared (first use in this function); did you mean ‘LED_FUNCTION_POWER’?
 2210 |                                       LED_FUNCTION_PLAYER5);
      |                                       ^~~~~~~~~~~~~~~~~~~~
      |                                       LED_FUNCTION_POWER
../hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/hid-nx.c:2210:39: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [scripts/Makefile.build:280: /s922x/build/hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/./hid-nx.o] Error 1
make[1]: *** [Makefile:1822: /s922x/build/hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/.] Error 2
make[1]: Leaving directory '/s922x/build/linux-5.10.128'
make: *** [package/pkg-generic.mk:294: /s922x/build/hid-nx-20e330a33aba1f1fc00287278ad31ca98ede383a/.stamp_built] Error 2
make: Leaving directory '/build/buildroot'
make: *** [Makefile:105: s922x-build] Error 2
emilyst commented 2 years ago

Ah, interesting. So it looks like the LED_FUNCTION_PLAYER* constants landed in the kernel only about ten months ago.

It would be possible to use an #ifdef to define these constants if they're not already defined. That would resolve this issue.

I'll try to update when this is done.

emilyst commented 2 years ago

I released version 1.12 which addresses this most immediate compilation error. I do not know if you'll encounter others trying to build on your version of Linux, but if so, please do open a new issue. (If this fix doesn't work for some reason, reopen this issue.)

Hope it works well for you!

dmanlfc commented 2 years ago

thanks @emilyst I will check it out & confirm.

dmanlfc commented 2 years ago

Emily, it works well, tested RPi4 with pro controller & joycons with joycond - all worked as expected.

emilyst commented 2 years ago

Wonderful! Thank you for the confirmation.