roadrunner2 / macbook12-spi-driver

Input driver for the SPI touchpad / keyboard found in the 12" MacBook (MacBook8,1 + MacBook9,1) and 2016 through 2018 Macbook Pro's (MacBookPro13,* and 14,*); a Touch Bar driver is also available.
GNU General Public License v2.0
251 stars 49 forks source link

Looking for support to kernel 6.0+ #67

Open Sjd-Risca opened 1 year ago

Sjd-Risca commented 1 year ago

Trying to compile on Debian testing I get the following trace:

DKMS make.log for applespi-0.1 for kernel 6.0.0-2-amd64 (x86_64)
Fri Nov  4 14:58:20 UTC 2022
make -C /lib/modules/6.0.0-2-amd64/build M=/var/lib/dkms/applespi/0.1/build modules
make[1]: Entering directory '/usr/src/linux-headers-6.0.0-2-amd64'
  CC [M]  /var/lib/dkms/applespi/0.1/build/applespi.o
  CC [M]  /var/lib/dkms/applespi/0.1/build/apple-ibridge.o
  CC [M]  /var/lib/dkms/applespi/0.1/build/apple-ib-tb.o
  CC [M]  /var/lib/dkms/applespi/0.1/build/apple-ib-als.o
/var/lib/dkms/applespi/0.1/build/applespi.c: In function 'applespi_get_saved_bl_level':
/var/lib/dkms/applespi/0.1/build/applespi.c:1810:38: error: invalid application of 'sizeof' to incomplete type 'struct efivar_entry'
 1810 |         efivar_entry = kmalloc(sizeof(*efivar_entry), GFP_KERNEL);
      |                                      ^
In file included from /usr/src/linux-headers-6.0.0-2-common/include/linux/string.h:253,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/bitmap.h:11,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/cpumask.h:12,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/smp.h:13,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/lockdep.h:14,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/mutex.h:17,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/kernfs.h:11,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/sysfs.h:16,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/kobject.h:20,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/of.h:17,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/irqdomain.h:35,
                 from /usr/src/linux-headers-6.0.0-2-common/include/linux/acpi.h:13,
                 from /var/lib/dkms/applespi/0.1/build/applespi.c:44:
/var/lib/dkms/applespi/0.1/build/applespi.c:1814:28: error: invalid use of undefined type 'struct efivar_entry'
 1814 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |                            ^~
/usr/src/linux-headers-6.0.0-2-common/include/linux/fortify-string.h:377:44: note: in definition of macro '__fortify_memcpy_chk'
  377 |         fortify_memcpy_chk(__fortify_size, p_size, q_size,              \
      |                                            ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1814:9: note: in expansion of macro 'memcpy'
 1814 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1814:28: error: invalid use of undefined type 'struct efivar_entry'
 1814 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |                            ^~
/usr/src/linux-headers-6.0.0-2-common/include/linux/fortify-string.h:378:28: note: in definition of macro '__fortify_memcpy_chk'
  378 |                            p_size_field, q_size_field, #op);            \
      |                            ^~~~~~~~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1814:9: note: in expansion of macro 'memcpy'
 1814 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1814:28: error: invalid use of undefined type 'struct efivar_entry'
 1814 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |                            ^~
/usr/src/linux-headers-6.0.0-2-common/include/linux/fortify-string.h:379:27: note: in definition of macro '__fortify_memcpy_chk'
  379 |         __underlying_##op(p, q, __fortify_size);                        \
      |                           ^
/var/lib/dkms/applespi/0.1/build/applespi.c:1814:9: note: in expansion of macro 'memcpy'
 1814 |         memcpy(efivar_entry->var.VariableName, EFI_BL_LEVEL_NAME,
      |         ^~~~~~
/var/lib/dkms/applespi/0.1/build/applespi.c:1816:21: error: invalid use of undefined type 'struct efivar_entry'
 1816 |         efivar_entry->var.VendorGuid = EFI_BL_LEVEL_GUID;
      |                     ^~
/var/lib/dkms/applespi/0.1/build/applespi.c:1819:15: error: implicit declaration of function 'efivar_entry_get'; did you mean 'efi_mokvar_entry_next'? [-Werror=implicit
-function-declaration]
 1819 |         sts = efivar_entry_get(efivar_entry, NULL, &efi_data_len, &efi_data);
      |               ^~~~~~~~~~~~~~~~
      |               efi_mokvar_entry_next
/var/lib/dkms/applespi/0.1/build/applespi.c: In function 'applespi_save_bl_level':
/var/lib/dkms/applespi/0.1/build/applespi.c:1846:15: error: implicit declaration of function 'efivar_entry_set_safe' [-Werror=implicit-function-declaration]
 1846 |         sts = efivar_entry_set_safe((efi_char16_t *)EFI_BL_LEVEL_NAME, efi_guid,
      |               ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [/usr/src/linux-headers-6.0.0-2-common/scripts/Makefile.build:254: /var/lib/dkms/applespi/0.1/build/applespi.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/usr/src/linux-headers-6.0.0-2-common/Makefile:1876: /var/lib/dkms/applespi/0.1/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.0.0-2-amd64'
make: *** [Makefile:16: all] Error 2

Here some details about local setup on Debian testing (bookworm):

# uname -a
Linux mac 6.0.0-2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.0.5-1 (2022-10-28) x86_64 GNU/Linux
#  apt install linux-headers-amd64 dkms git make wget curl
#  git clone https://github.com/roadrunner2/macbook12-spi-driver.git /usr/src/applespi-0.1
#  pushd /usr/src/applespi-0.1/
#  wget https://patch-diff.githubusercontent.com/raw/roadrunner2/macbook12-spi-driver/pull/65.patch
#  patch --dry-run < 65.patch
#  patch  < 65.patch
eado commented 1 year ago

Would also love this. Experiencing the same thing on:

Linux machine 6.0.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 10 Nov 2022 21:14:24 +0000 x86_64 GNU/Linux
flavian112 commented 1 year ago

Hi, i've noticed the same problem since updating to Linux Kernel 6. I don't have much in-depth knowledge of Linux, so my "quick, dirty workaround" is the following: As some of the efivar API doesn't seem to be available anymore (don't know if it's been deprecated or was internal), the compilation fails with the 'applespi_get_saved_bl_level' and the 'applespi_save_bl_level' function. Since it is not a big deal-breaker for me if the backlight levels don't get saved in between boots, I just changed them into dummy functions for now ;)

eado commented 1 year ago

Great to hear you got it working. I tried your method and loaded the modules using dkms. Doesn't load on boot because it's asking for it to be signed?

kernel: applespi: module verification failed: signature and/or required key missing - tainting kernel
flavian112 commented 1 year ago

Weird, I have the same kernel version installed and I'm also on Arch. I just did: make all && make install, this worked for me.

eado commented 1 year ago

Looks like it did work! I just had to disable usbmuxd for the Touch Bar to activate. Very odd.

flavian112 commented 1 year ago

Great to hear that you got it to work and yes I think it's a known problem that the device rules of usbmuxd interfere with the touchbar driver. (see https://github.com/roadrunner2/macbook12-spi-driver/issues/42)

almas commented 4 months ago

You can try https://github.com/almas/macbook12-spi-driver/tree/touchbar-driver-hid-driver I have successfully installed this driver with kernel 6.5.0-28-generic.

crocco95 commented 3 months ago

You can try https://github.com/almas/macbook12-spi-driver/tree/touchbar-driver-hid-driver I have successfully installed this driver with kernel 6.5.0-28-generic.

It worked perfectly for me, thanks a lot

RamtinKosari commented 2 weeks ago

Hi, im on Ubuntu with 6.8.0-40-generic Kernel and i have same issue, it has error like this :

dkms install -m applespi -v 0.1
Creating symlink /var/lib/dkms/applespi/0.1/source -> /usr/src/applespi-0.1

Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
make -j16 KERNELRELEASE=6.8.0-40-generic...(bad exit status: 2)
ERROR (dkms apport): binary package for applespi: 0.1 not found
Error! Bad return status for module build on kernel: 6.8.0-40-generic (x86_64)
Consult /var/lib/dkms/applespi/0.1/build/make.log for more information.
Bandito11 commented 2 weeks ago

I have the same error.

You can try https://github.com/almas/macbook12-spi-driver/tree/touchbar-driver-hid-driver I have successfully installed this driver with kernel 6.5.0-28-generic.

This is didn't work for me for 6.10.6-200.fc40.x86_64 (x86_64)