Created attachment 194370 [details]
Support newer thinkpads with LEN0268 id
The attached patch adds support for newer Thinkpad models. The patch has been tested on a Thinkpad T480, but should work on other models as well.
I tried this patch on my T480 running r336962.
I have not tried the event handling, but the sysctl variables do not seem to report reality (mute, lcd_brightness, thinklight etc...)
- Thinklight is reported by the firmware to be present, but turning it on does nothing, probably is a reminiscence of old good Thinkpads! BTW, it behaves the same under Linux.
- lcd_brightness is assumed to be controllable by the driver (the patch does not change that). For instance it fails already to control the brightness on my corebooted x230. This can be adjusted.
- Sound mute works fine for me. However, mic mute does not mute the microphone, it does only turn on its led. On Linux, if you mute the microphone via the sound card driver, it checks if there is a thinkpad_set_led registered function (by the thinkpad_acpi), and it does turn off/on the mic led for you.
Event handling works fine for me.
The acpi_ibm driver is clearly unmaintained on FreeBSD. I can make a lot of improvements to it, but unfortunately I have no access to its repository, and going with patches takes ages...
Improvements are most welcome, and yeah, we're a bit slow on the tickets thing, I'll try to keep an eye on it though, seeing that I have a T480 now :-)
FYI, I included your patch on top of stable/12 and rololed out this kernel on my T480. You can see what I rolled out at https://github.com/rebost/freebsd/tree/feature/acpi_ibm
Sadly, both Fn buttons and sysctl modification via console have no effect.
Neither are the values reported by sysctl dev.acpi_ibm correct
If there is anything I can do to help you fix this, just let me know. Thanks for what you have already done.
All the best,
mpizarro@lenovo01:/usr/src $ sudo sysctl dev.acpi_ibm
dev.acpi_ibm.0.%pnpinfo: _HID=LEN0268 _UID=0
dev.acpi_ibm.0.%desc: IBM ThinkPad ACPI Extras
mpizarro@lenovo01:/usr/src $ sudo sysctl dev.acpi_ibm.0.thinklight=1
dev.acpi_ibm.0.thinklight: 0 -> 0
mpizarro@lenovo01:/usr/src $ sudo sysctl dev.acpi_ibm.0.lcd_brightness=7
dev.acpi_ibm.0.lcd_brightness: 6 -> 7
mpizarro@lenovo01:/usr/src $ sudo sysctl dev.acpi_ibm.0.lcd_brightness=8
sysctl: dev.acpi_ibm.0.lcd_brightness=8: Invalid argument
The Fn buttons never changed the brightness automatically (even on old already supported Thinkpad models), instead it sends a userspace event to devctl, that is populated by devd. The user typically runs a devd action to change the brightness, and my patch does not change that, see man(4) acpi_ibm.
Instead, with the patch applied now you get devd events for FN-brightness up/down.
!system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x10
!system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11
then you can, via a devd action, change the brightness using for example hw.acpi.video.lcd0.brightness. Other keys, which did not work without the patch, now send devd events, such as FN-Wireless, FN-Mic.
For the brightness part, yes I think something should be done to make the dev.acpi_ibm.0.lcd_brightness syscalls work again, will post here any progress.
Thanks for the clarifications and all your great work, that's definitely something I can build upon.
Hi, I applied your patch to CURRENT (r342776) on a T480.
- The Fn + keys from F4 to F12, TAB, p, 4 and MENU send events to devd.
- dev.acpi_ibm.0.mute state reflects the state of F1 LED
- dev.acpi_ibm.0.fan can actually be used to turn the fan on and off
- dev.acpi_ibm.0.fan_speed seems to be measuring fan speed correctly
- dev.acpi_ibm.0.mic_led works as you described.
Thanks for your work, let me know if I can help with this patch in any way.
Hi Ali -
I've applied on a ThinkPad X1 Yoga 2nd gen on 12 RELEASE.
Can confirm the same information as Bojan.
Awesome work ! Happy to test more as you go along.
(In reply to Ali Abdallah from comment #2)
> The acpi_ibm driver is clearly unmaintained on FreeBSD. I can make a lot of
> improvements to it, but unfortunately I have no access to its repository, and
> going with patches takes ages...
Unfortunately, most if not all acpi_XXX(4) drivers are unmaintained; FreeBSD definitely needs people like you to help in this area, one of our weakest. Going with patches (if they are good) would only last until you'd be punished with commit bit for your great work. :-) Until then, I'm sure existing src committers would gladly help to expedite your patches.