Bug 219470

Summary: Add support for Apple USB-C Magic Trackpad 2
Product: Drivers Reporter: Callahan Kovacs (callahankovacs)
Component: Input DevicesAssignee: drivers_input-devices
Status: RESOLVED CODE_FIX    
Severity: enhancement CC: ilya
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description Callahan Kovacs 2024-11-05 15:04:35 UTC
In October 2024, Apple released a USB-C model of the Magic Trackpad 2.

As far as I know, the design is identical to the Trackpad 2 except for:

1. USB-C connector replaces the lightning connector
2. New hardware ID of 0324


The new hardware ID prevents the hid-magicmouse driver from being used.  This means the trackpad doesn't handle features such as scrolling and right clicking.

I believe this requires adding the HID to drivers/hid/hid-ids.h and handling it in drivers/hid/hid-magicmouse.c.

I'm happy to submit a patch, thanks!
Comment 1 gregkh 2024-11-05 15:32:36 UTC
On Tue, Nov 05, 2024 at 03:04:35PM +0000, bugzilla-daemon@kernel.org wrote:
> I'm happy to submit a patch, thanks!

Please just send a patch as documented and we will be glad to apply it.

thanks,

greg k-h
Comment 3 Ilya Zverev 2024-11-12 22:01:00 UTC
I've installed the driver from the github (by running ./install.sh), but alas it did not work - or I missed something?

uname -a says "Linux fedora 6.11.6-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov  1 16:09:34 UTC 2024 x86_64 GNU/Linux"

dmesg says:

$ sudo dmesg|grep '0324\|pple'
[    5.134846] usb 7-1.3.4: New USB device found, idVendor=05ac, idProduct=0324, bcdDevice= 4.10
[    5.134853] usb 7-1.3.4: Manufacturer: Apple Inc.
[    5.331979] hid-generic 0003:05AC:0324.0002: unknown main item tag 0x0
[    5.331983] hid-generic 0003:05AC:0324.0002: unknown main item tag 0x0
[    5.331985] hid-generic 0003:05AC:0324.0002: unknown main item tag 0x0
[    5.331987] hid-generic 0003:05AC:0324.0002: unknown main item tag 0x0
[    5.332089] hid-generic 0003:05AC:0324.0002: hiddev96,hidraw1: USB HID v1.10 Device [Apple Inc. Magic Trackpad] on usb-0000:c6:00.4-1.3.4/input0
[    5.343148] input: Apple Inc. Magic Trackpad Mouse as /devices/pci0000:00/0000:00:08.3/0000:c6:00.4/usb7/7-1/7-1.3/7-1.3.4/7-1.3.4:1.1/0003:05AC:0324.0003/input/input13
[    5.343386] hid-generic 0003:05AC:0324.0003: input,hiddev97,hidraw2: USB HID v1.10 Mouse [Apple Inc. Magic Trackpad] on usb-0000:c6:00.4-1.3.4/input1
[    5.354036] hid-generic 0003:05AC:0324.0004: hiddev98,hidraw3: USB HID v1.10 Device [Apple Inc. Magic Trackpad] on usb-0000:c6:00.4-1.3.4/input2
[    5.365636] hid-generic 0003:05AC:0324.0005: hiddev99,hidraw4: USB HID v1.10 Device [Apple Inc. Magic Trackpad] on usb-0000:c6:00.4-1.3.4/input3
[    5.535629] usbcore: registered new device driver apple-mfi-fastcharge

I've rebooted after updating the kernel, and once more after installing the driver. Still it detects as a mouse, with no right click and no scrolling. I understand it's not a support channel and I'm sorry, but on a slight chance it might be a bug I'm posting here.
Comment 4 Callahan Kovacs 2024-11-13 02:33:09 UTC
For what it's worth, I see reports of 'unknown main item tag 0x0' prior to this patch and I also see this warning with or without this patch.  Here's an example with a Magic Mouse from Feb 2024: https://bugzilla.kernel.org/show_bug.cgi?id=86931#c11

The vendor and device ID match, so the kernel should load the driver but I don't see your system loading it. Those logs would begin with 'magicmouse' instead of 'hidgeneric'. Could be worth exploring with dkms and modprobe - I haven't tried the install script on fedora
Comment 5 Ilya Zverev 2024-11-13 06:13:27 UTC
There is no lines with the word "magic" in the dmesg output. I get that the 0x0 message is some other thing — but thanks for the hint that it should show "magicmouse". Some other outputs:

$ dkms status -m hid-magicmouse-dkms -v 6.11+magicmouse2
Deprecated feature: REMAKE_INITRD (/var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/source/dkms.conf)
hid-magicmouse-dkms/6.11+magicmouse2, 6.11.6-200.fc40.x86_64, x86_64: installed

$ cat /var/lib/dkms/hid-magicmouse-dkms/kernel-6.11.6-200.fc40.x86_64-x86_64/log/make.log
DKMS make.log for hid-magicmouse-dkms-6.11+magicmouse2 for kernel 6.11.6-200.fc40.x86_64 (x86_64)
Вт 12 ноя 2024 22:22:32 EET
make -C /lib/modules/6.11.6-200.fc40.x86_64/build M=/var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build modules
make[1]: вход в каталог «/usr/src/kernels/6.11.6-200.fc40.x86_64»
  CC [M]  /var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build/hid-magicmouse.o
  MODPOST /var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build/Module.symvers
  CC [M]  /var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build/hid-magicmouse.mod.o
  LD [M]  /var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build/hid-magicmouse.ko
  BTF [M] /var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build/hid-magicmouse.ko
Skipping BTF generation for /var/lib/dkms/hid-magicmouse-dkms/6.11+magicmouse2/build/hid-magicmouse.ko due to unavailability of vmlinux
make[1]: выход из каталога «/usr/src/kernels/6.11.6-200.fc40.x86_64»

$ modprobe -c|grep magic
alias hid:b0003g*v000005ACp00000265 hid_magicmouse
alias hid:b0003g*v000005ACp00000269 hid_magicmouse
alias hid:b0003g*v000005ACp00000324 hid_magicmouse
alias hid:b0005g*v0000004Cp00000265 hid_magicmouse
alias hid:b0005g*v0000004Cp00000269 hid_magicmouse
alias hid:b0005g*v0000004Cp00000324 hid_magicmouse
alias hid:b0005g*v000005ACp0000030D hid_magicmouse
alias hid:b0005g*v000005ACp0000030E hid_magicmouse
Comment 6 Ilya Zverev 2024-11-13 06:16:25 UTC
Ah, also two entries in hwinfo:

77: USB 00.3: 0000 Unclassified device
  [Created at usb.122]
  Unique ID: n9DR.fYzjMeLrJg6
  Parent ID: yW5O.6PsYjp2DE8F
  SysFS ID: /devices/pci0000:00/0000:00:08.3/0000:c6:00.4/usb7/7-1/7-1.3/7-1.3.4/7-1.3.4:1.3
  SysFS BusID: 7-1.3.4:1.3
  Hardware Class: unknown
  Model: "Apple Magic Trackpad"
  Hotplug: USB
  Vendor: usb 0x05ac "Apple, Inc."
  Device: usb 0x0324 "Magic Trackpad"
  Revision: "4.10"
  Serial ID: "CC2H8A01MEA000050A"
  Driver: "usbhid"
  Speed: 12 Mbps
  Module Alias: "usb:v05ACp0324d0410dc00dsc00dp00ic03isc00ip00in03"
  Driver Info #0:
    Driver Status: apple_mfi_fastcharge is active
    Driver Activation Cmd: "modprobe apple_mfi_fastcharge"
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #84 (Hub)

78: USB 00.1: 10503 USB Mouse
  [Created at usb.122]
  Unique ID: toiI.t4urSKPi8iE
  Parent ID: yW5O.6PsYjp2DE8F
  SysFS ID: /devices/pci0000:00/0000:00:08.3/0000:c6:00.4/usb7/7-1/7-1.3/7-1.3.4/7-1.3.4:1.1
  SysFS BusID: 7-1.3.4:1.1
  Hardware Class: mouse
  Model: "Apple Magic Trackpad"
  Hotplug: USB
  Vendor: usb 0x05ac "Apple, Inc."
  Device: usb 0x0324 "Magic Trackpad"
  Revision: "4.10"
  Serial ID: "CC2H8A01MEA000050A"
  Compatible to: int 0x0210 0x0003
  Driver: "usbhid"
  Device File: /dev/input/mice (/dev/input/mouse3)
  Device Files: /dev/input/mice, /dev/input/mouse3, /dev/input/event8, /dev/input/by-id/usb-Apple_Inc._Magic_Trackpad_CC2H8A01MEA000050A-if01-event-mouse, /dev/input/by-path/pci-0000:c6:00.4-usbv2-0:1.3.4:1.1-event-mouse, /dev/input/by-path/pci-0000:c6:00.4-usb-0:1.3.4:1.1-event-mouse, /dev/input/by-path/pci-0000:c6:00.4-usb-0:1.3.4:1.1-mouse, /dev/input/by-path/pci-0000:c6:00.4-usbv2-0:1.3.4:1.1-mouse, /dev/input/by-id/usb-Apple_Inc._Magic_Trackpad_CC2H8A01MEA000050A-if01-mouse
  Device Number: char 13:63 (char 13:35)
  Speed: 12 Mbps
  Module Alias: "usb:v05ACp0324d0410dc00dsc00dp00ic03isc01ip02in01"
  Driver Info #0:
    Buttons: 3
    Wheels: 0
    XFree86 Protocol: explorerps/2
    GPM Protocol: exps2
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #84 (Hub)
Comment 7 Callahan Kovacs 2024-11-13 14:43:12 UTC
Interesting, I'm not sure why the driver isn't loading for you. Everything looks good compared to my installations. The modprobe entry even shows 'alias hid:b0003g*v000005ACp00000324 hid_magicmouse', which should pick up the driver.  What about 'modinfo hid_magicmouse'?

Any udev rules or is secure boot enabled? Any warnings about unsigned drivers or a tainted kernel?

The 2 entries in hwinfo look fine.  I get those same two entries when connected via usb but not bluetooth, which makes sense given the first interface is for 'apple_mfi_fastcharge'.  I am curious - is the behavior different when connected via bluetooth?

What version of fedora are you using?  I can try this on a clean install
Comment 8 Ilya Zverev 2024-11-13 15:07:57 UTC
I'm using a KDE spin of Fedora 40, with packages all updated to latest versions. For some reason I get only one Bluetooth device when I disconnect the trackpad from USB, and that's neither the trackpad, nor my Bluetooth mouse. Maybe hwinfo is broken in that way?..

No relevant warnings in dmesg, and I do have secure boot enabled. Grepping for "tainted", only one line:

[    8.234042] CPU: 7 UID: 0 PID: 216 Comm: kworker/7:4 Not tainted 6.11.6-200.fc40.x86_64 #1


Here's what dmesg appends when I disconnect from USB, turn it off and then on again:

$ sudo dmesg | tail
[66630.597969] hid-generic 0005:004C:0324.0013: unknown main item tag 0x0
[66630.598379] input: Magic Trackpad Mouse as /devices/virtual/misc/uhid/0005:004C:0324.0013/input/input73
[66630.598840] input: Magic Trackpad as /devices/virtual/misc/uhid/0005:004C:0324.0013/input/input74
[66630.598999] hid-generic 0005:004C:0324.0013: input,hidraw1: BLUETOOTH HID v3.14 Mouse [Magic Trackpad] on 8c:3b:4a:50:ef:d5

$ sudo modinfo hid_magicmouse
filename:       /lib/modules/6.11.6-200.fc40.x86_64/extra/hid-magicmouse.ko.xz
license:        GPL
file:           drivers/hid/hid-magicmouse
description:    Apple "Magic" Wireless Mouse driver
parm:           emulate_3button:Emulate a middle button (bool)
parm:           emulate_scroll_wheel:Emulate a scroll wheel (bool)
parm:           scroll_speed:Scroll speed, value from 0 (slow) to 63 (fast)
parm:           scroll_acceleration:Accelerate sequential scroll events (bool)
parm:           report_undeciphered:Report undeciphered multi-touch state field using a MSC_RAW event (bool)
Comment 9 Callahan Kovacs 2024-11-13 15:50:06 UTC
That's the first notable difference I've seen so far. Here's what I get:

> sudo modinfo hid_magicmouse
filename:       /lib/modules/6.8.0-48-generic/updates/dkms/hid-magicmouse.ko.zst
license:        GPL
description:    Apple "Magic" Wireless Mouse driver
srcversion:     C637D83F623DE1D3A49CAAC
alias:          hid:b0003g*v000005ACp00000324
alias:          hid:b0005g*v0000004Cp00000324
alias:          hid:b0003g*v000005ACp00000265
alias:          hid:b0005g*v0000004Cp00000265
alias:          hid:b0005g*v000005ACp0000030E
alias:          hid:b0003g*v000005ACp00000269
alias:          hid:b0005g*v0000004Cp00000269
alias:          hid:b0005g*v000005ACp0000030D
depends:        hid
retpoline:      Y
name:           hid_magicmouse
vermagic:       6.8.0-48-generic SMP preempt mod_unload modversions
sig_id:         PKCS#7
signer:         kubuntu Secure Boot Module Signature key
sig_key:        0C:C4:1C:5B:F1:81:B6:3B:E3:26:EB:54:41:11:07:66:9B:90:D0:11
sig_hashalgo:   sha512
signature:      18:78:B9:F7:11:C4:81:5D:AF:1D:82:7E:39:17:C4:E4:2C:32:0B:A7:
		96:20:08:7D:95:CF:AC:49:43:B8:F9:A6:65:81:69:13:93:B2:1A:60:
		E3:68:AF:73:51:1A:96:43:AC:7F:B4:83:D0:B1:36:BB:22:89:3C:2B:
		49:F6:C3:3A:F4:5B:22:27:13:6D:D7:9F:52:02:E7:53:D7:10:F6:07:
		B1:89:E9:74:96:C6:62:EC:A0:5B:2C:F7:B7:B8:DC:67:7A:80:48:C4:
		C1:F1:88:9B:F1:06:F3:94:FC:3B:C5:1D:7F:90:4B:B1:58:0F:D2:85:
		55:98:70:E2:4A:EF:37:68:16:E4:73:8D:E0:EE:48:5B:CD:F4:C2:0D:
		36:94:D2:50:1E:6F:2E:76:0F:60:5C:AE:3A:D9:C0:E3:A3:17:0F:2C:
		75:5C:40:C4:C8:60:B1:20:8F:20:1A:9D:98:16:AC:29:D4:52:35:85:
		C3:3B:20:29:18:C4:72:B9:DC:CB:CB:C4:63:A8:1E:36:C9:63:FF:96:
		51:89:4C:DF:DA:E7:E9:B5:95:3A:00:25:AE:85:59:05:A5:04:1C:E4:
		8E:D6:73:C5:A0:7C:E6:28:37:62:05:19:B6:8A:13:71:4B:60:B0:56:
		88:A5:B8:9E:FE:59:8C:57:88:23:12:DB:2B:19:68:B8
parm:           emulate_3button:Emulate a middle button (bool)
parm:           emulate_scroll_wheel:Emulate a scroll wheel (bool)
parm:           scroll_speed:Scroll speed, value from 0 (slow) to 63 (fast)
parm:           scroll_acceleration:Accelerate sequential scroll events (bool)
parm:           report_undeciphered:Report undeciphered multi-touch state field using a MSC_RAW event (bool)

The path to the driver is different and I'm not sure what to make of that. Admittedly I don't know much about secure boot but I've been testing with it turned off.
Comment 10 Ilya Zverev 2024-11-13 19:02:26 UTC
Okay something weird happens on Fedora, so I guess I'll take this to Fedora forums.

$ modprobe -n --first-time hid_magicmouse && echo "Not loaded" || echo "Loaded"
modprobe: ERROR: could not insert 'hid_magicmouse': Module already in kernel
Loaded

$ sudo modprobe -v hid_magicmouse
$ sudo lsmod|grep magi
$ sudo lsmod|grep hid
uhid                   24576  2
hid_multitouch         36864  0
i2c_hid_acpi           12288  0
i2c_hid                45056  1 i2c_hid_acpi

Thanks for writing the module, Callahan! I hope it gets into the kernel soon :)