Bug 229120 - acpi_ibm: Add support for newer Thinkpad models with id LEN0268
Summary: acpi_ibm: Add support for newer Thinkpad models with id LEN0268
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 11.0-STABLE
Hardware: amd64 Any
: --- Affects Many People
Assignee: Oleksandr Tymoshenko
URL:
Keywords: feature
Depends on:
Blocks: 240778
  Show dependency treegraph
 
Reported: 2018-06-18 18:16 UTC by Ali Abdallah
Modified: 2019-10-16 15:55 UTC (History)
13 users (show)

See Also:
koobs: mfc-stable12+
koobs: mfc-stable11+


Attachments
Support newer thinkpads with LEN0268 id (2.58 KB, patch)
2018-06-18 18:16 UTC, Ali Abdallah
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Abdallah 2018-06-18 18:16:19 UTC
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.
Comment 1 Poul-Henning Kamp freebsd_committer freebsd_triage 2018-08-07 08:48:04 UTC
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...)
Comment 2 Ali Abdallah 2018-08-09 09:11:33 UTC
- 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...
Comment 3 Poul-Henning Kamp freebsd_committer freebsd_triage 2018-08-10 06:40:45 UTC
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 :-)
Comment 4 Matías Pizarro 2018-11-24 13:55:45 UTC
Hi Ali,

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

https://github.com/freebsd/freebsd/compare/stable/12...rebost:feature/acpi_ibm?expand=1#diff-6fc15f69014ba3e0dabd0b064d3f592e

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,

-- matías

mpizarro@lenovo01:/usr/src $ sudo sysctl dev.acpi_ibm
dev.acpi_ibm.0.handlerevents: NONE
dev.acpi_ibm.0.mic_led: 0
dev.acpi_ibm.0.fan: 1
dev.acpi_ibm.0.fan_level: 0
dev.acpi_ibm.0.fan_speed: 0
dev.acpi_ibm.0.wlan: 1
dev.acpi_ibm.0.bluetooth: 0
dev.acpi_ibm.0.thinklight: 0
dev.acpi_ibm.0.mute: 0
dev.acpi_ibm.0.volume: 0
dev.acpi_ibm.0.lcd_brightness: 0
dev.acpi_ibm.0.hotkey: 2
dev.acpi_ibm.0.eventmask: -5
dev.acpi_ibm.0.events: 1
dev.acpi_ibm.0.availmask: 4294967291
dev.acpi_ibm.0.initialmask: 2056
dev.acpi_ibm.0.%parent: acpi0
dev.acpi_ibm.0.%pnpinfo: _HID=LEN0268 _UID=0
dev.acpi_ibm.0.%location: handle=\_SB_.PCI0.LPCB.EC__.HKEY
dev.acpi_ibm.0.%driver: acpi_ibm
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
dev.acpi_ibm.0.lcd_brightness: 7
sysctl: dev.acpi_ibm.0.lcd_brightness=8: Invalid argument
Comment 5 Ali Abdallah 2018-12-10 13:55:06 UTC
Hi Matías,

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.
Comment 6 Matías Pizarro 2018-12-10 22:09:12 UTC
Hi Ali,

Thanks for the clarifications and all your great work, that's definitely something I can build upon.
Comment 7 Bojan Petrovic 2019-01-05 12:06:19 UTC
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.
Comment 8 Diego Casati 2019-01-15 05:53:49 UTC
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.

-dcasati
Comment 9 Alexey Dokuchaev freebsd_committer freebsd_triage 2019-01-22 06:25:24 UTC
(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.
Comment 10 Alexander Sieg 2019-04-12 08:31:19 UTC
Hi Ali -

I've applied this patch on 12 STABLE r346130 running on a T480s. 

Can confirm the same information as Bojan.

-xanderio
Comment 11 Alexander Sieg 2019-04-12 14:14:22 UTC
After a bit more testing it seem that fn-f5 (backlight lower) and  fn-f12 (star) send the same notify to devd.

backlight lower:
Processing event '!system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11'
setting *=!system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11
setting _=system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11
setting subsystem=IBM
Testing subsystem=IBM against ^ACAD$, invert=0
Testing subsystem=IBM against ^Thermal$, invert=0
Testing subsystem=IBM against ^Suspend$, invert=0
Testing subsystem=IBM against ^Resume$, invert=0
Testing subsystem=IBM against ^ASUS$, invert=0
Testing subsystem=IBM against ^ASUS$, invert=0
Testing subsystem=IBM against ^ASUS$, invert=0
Testing subsystem=IBM against ^ASUS-Eee$, invert=0
Testing subsystem=IBM against ^ASUS-Eee$, invert=0
Testing subsystem=IBM against ^ASUS-Eee$, invert=0

star:
Processing event '!system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11'
setting *=!system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11
setting _=system=ACPI subsystem=IBM type=\_SB_.PCI0.LPCB.EC__.HKEY notify=0x11
setting subsystem=IBM
Testing subsystem=IBM against ^ACAD$, invert=0
Testing subsystem=IBM against ^Thermal$, invert=0
Testing subsystem=IBM against ^Suspend$, invert=0
Testing subsystem=IBM against ^Resume$, invert=0
Testing subsystem=IBM against ^ASUS$, invert=0
Testing subsystem=IBM against ^ASUS$, invert=0
Testing subsystem=IBM against ^ASUS$, invert=0
Testing subsystem=IBM against ^ASUS-Eee$, invert=0
Testing subsystem=IBM against ^ASUS-Eee$, invert=0
Testing subsystem=IBM against ^ASUS-Eee$, invert=0
Comment 12 commit-hook freebsd_committer freebsd_triage 2019-04-24 23:10:56 UTC
A commit references this bug:

Author: gonzo
Date: Wed Apr 24 23:10:20 UTC 2019
New revision: 346647
URL: https://svnweb.freebsd.org/changeset/base/346647

Log:
  [acpi_ibm] Add support for newer Thinkpad models

  Add support for newer Thinkpad models with id LEN0268. Was tested on
  Thinkpad T480 and ThinkPad X1 Yoga 2nd gen.

  PR:		229120
  Submitted by:	Ali Abdallah <aliovx@gmail.com>
  MFC after:	1 week

Changes:
  head/sys/dev/acpi_support/acpi_ibm.c
Comment 13 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-04-25 19:01:59 UTC
Thanks for submitting the patch, Ali. I committed it with some minor changes: fixed couple of style(9) issue and made it more compatible with previous behavior to reduce risk of breaking stuff.
Comment 14 Bojan Petrovic 2019-05-09 13:55:06 UTC
A related Phabricator patch and discussion: "Support post-2015 Lenovo models in acpi_ibm / support keyboard backlight (also led(4)) / support micmute led(4)" - https://reviews.freebsd.org/D14103
Comment 15 commit-hook freebsd_committer freebsd_triage 2019-05-15 21:53:34 UTC
A commit references this bug:

Author: gonzo
Date: Wed May 15 21:52:43 UTC 2019
New revision: 347634
URL: https://svnweb.freebsd.org/changeset/base/347634

Log:
  MFC r346647:

  [acpi_ibm] Add support for newer Thinkpad models

  Add support for newer Thinkpad models with id LEN0268. Was tested on
  Thinkpad T480 and ThinkPad X1 Yoga 2nd gen.

  PR:		229120
  Submitted by:	Ali Abdallah <aliovx@gmail.com>

Changes:
_U  stable/12/
  stable/12/sys/dev/acpi_support/acpi_ibm.c
Comment 16 commit-hook freebsd_committer freebsd_triage 2019-05-16 00:51:53 UTC
A commit references this bug:

Author: gonzo
Date: Thu May 16 00:51:30 UTC 2019
New revision: 347636
URL: https://svnweb.freebsd.org/changeset/base/347636

Log:
  MFC r346647:

  [acpi_ibm] Add support for newer Thinkpad models

  Add support for newer Thinkpad models with id LEN0268. Was tested on
  Thinkpad T480 and ThinkPad X1 Yoga 2nd gen.

  PR:		229120
  Submitted by:	Ali Abdallah <aliovx@gmail.com>

Changes:
_U  stable/11/
  stable/11/sys/dev/acpi_support/acpi_ibm.c
Comment 17 Ulrich Spörlein freebsd_committer freebsd_triage 2019-08-27 20:08:34 UTC
Hey Ali,
foolishly I bought a new T490, thinking that FreeBSD works well on Thinkpads. Oh well ...

So wireless doesn't work, but there's an open PR for that. acpi_ibm(4) does not attach, so I don't have any of the usual events, snd_hda is wonky, too. But one thing at a time.

This is on 12.0-RELEASE, what sort of debugging should I try or where are PCI IDs required to have acpi_ibm attach for this model?
Comment 18 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-09-18 23:51:59 UTC
(In reply to Ulrich Spoerlein from comment #17)

Hi Urlich,

Please open new PR for T490 support and attach the output of acpidump -dt to it. I'm going to close this PR as fixed since the original patch was committed and MFCed
Comment 19 Kubilay Kocak freebsd_committer freebsd_triage 2019-09-24 02:07:39 UTC
^Triage: Track MFC's to stable branches

@Ulrich Could you add the wireless support issue ID to this issue's See Also field please