Page MenuHomeFreeBSD

Support post-2015 Lenovo models in acpi_ibm / support keyboard backlight (also led(4)) / support micmute led(4)
Needs ReviewPublic

Authored by grembo on Jan 29 2018, 2:22 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 28, 8:05 PM
Unknown Object (File)
Jan 28 2024, 3:04 PM
Unknown Object (File)
Jan 28 2024, 2:53 PM
Unknown Object (File)
Jan 28 2024, 2:53 PM
Unknown Object (File)
Jan 23 2024, 8:53 PM
Unknown Object (File)
Jan 10 2024, 6:46 AM
Unknown Object (File)
Jan 5 2024, 7:43 AM
Unknown Object (File)
Jan 3 2024, 3:31 PM
Tokens
"Like" token, awarded by jason_corrupted.io.

Details

Summary

More recent Lenovos like the T460s, T470s, T560s etc.
provide new hotkeys ids (LEN0268 instead of LEN0068)
and a newer version of the HKEY interface (0x200
instead of 0x100, as provided over the MHKV function).

This change allows detection and initialization of these
machines. It doesn't add support for the lenovo adaptive
keyboard, but allows this as a future change.

Tested on a T470s, some of the features work, e.g.
key events for most fn+Fx combinations over devd
and mute sound/detect mute. Other features
like lcd_brightness don't work, but are supported
over acpi_video anyway.

This also adds support for controlling the keyboard backlight found in newer lenovo models,
including support for the led(4) interface.

Test Plan
kldload acpi_ibm
# try various features...

sysctl dev.acpi_ibm.0.kbd_backlight=2
morse -l "SOS" >/dev/led/kbd_backlight
sysctl dev.acpi_ibm.0.kbd_backlight_ledon=2

sysctl dev.acpi_ibm.0.micmute_led=1
sysctl dev.acpi_ibm.0.micmute_led=2
morse -l "SOS" >/dev/led/micmute
echo "0" >/dev/led/micmute

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 14666
Build 14795: arc lint + arc unit

Event Timeline

Add support for controlling the keyboard backlight found in newer lenovo models.

Backlight can be read/set using

dev.acpi_ibm.0.kbd_backlight

Support the led(4) interface to control the keyboard
backlight

/dev/led/kbd_backlight

Backlight levels to be applied by on and off states when using the led
interface can be configured by setting

dev.acpi_ibm.0.kbd_backlight_ledoff
dev.acpi_ibm.0.kbd_backlight_ledon

Example use:

echo "f1" >/dev/led/kbd_backlight
echo "1" >/dev/led/kbd_backlight 
echo "0" >/dev/led/kbd_backlight
grembo retitled this revision from Support post-2015 Lenovo models in acpi_ibm to Support post-2015 Lenovo models in acpi_ibm / support keyboard backlight (also led(4)).Jan 30 2018, 1:25 AM
grembo edited the summary of this revision. (Show Details)
grembo edited the test plan for this revision. (Show Details)

Please note that man page changes are pending, but will be added to the review before committing any changes.

I've tested the patch on a Lenovo x260 and according to the testplan. It works nicely.

Tested interfaces:
dev.acpi_ibm.0.kbd_backlight_ledoff {0,1,2}
dev.acpi_ibm.0.kbd_backlight_ledon {0,1,2}
dev.acpi_ibm.0.kbd_backlight {0,1,2}
/dev/led/kbd_backlight {0,1}

This revision is now accepted and ready to land.Feb 3 2018, 6:19 PM

Looks and works OK for old (0x100 protocol) ThinkPad.
No new regression on my T420. (Known-not-working and dangerous functions like suspend/resume are untested.)
Not marking as "Accepted" as I don't have newer ThinkPads having 0x200 protocol and no knowledges for 0x200 protocol.
So I just reviewed and tested fallback (to 0x100 protocol) codes.

No regression on an old (0x100 protocol) ThinkPad S440 (produced around 2013). Only volume, keyboard backlight and Pause Fn keys were working before the patch and still do.

grembo edited the summary of this revision. (Show Details)
grembo edited the test plan for this revision. (Show Details)

Add support for controlling micmute LED

This revision now requires review to proceed.Feb 9 2018, 11:21 AM
grembo retitled this revision from Support post-2015 Lenovo models in acpi_ibm / support keyboard backlight (also led(4)) to Support post-2015 Lenovo models in acpi_ibm / support keyboard backlight (also led(4)) / support micmute led(4).Feb 9 2018, 11:23 AM
grembo edited the test plan for this revision. (Show Details)
grembo edited the test plan for this revision. (Show Details)

I'll test this on old and hopefully new thinkpads

sys/dev/acpi_support/acpi_ibm.c
957

extra whitespace here

964

and here

No regressions observed on my Thinkpad X220 with this change.
Changing dev.acpi_ibm.0.volume has no effect, but did not work before either.

Testing with this change on X260 (LEN0068, MHKV 0x0200 AFAICT) I see warnings like:

# sysctl dev.acpi_ibm.0.kbd_backlight=0
ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
dev.acpi_ibm.0.kbd_backlight: 1ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
 -> ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
0
#

Keyboard backlight control works despite the warnings. I haven't tested this machine on an unpatched kernel. echo 1 > /dev/led/micmute has no effect.

sys/dev/acpi_support/acpi_ibm.c
504

s/MKHV/MHKV/

Testing with this change on X260 (LEN0068, MHKV 0x0200 AFAICT) I see warnings like:

# sysctl dev.acpi_ibm.0.kbd_backlight=0
ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
dev.acpi_ibm.0.kbd_backlight: 1ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
 -> ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
ACPI Warning: \_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20180209/nsarguments-383)
0
#

Keyboard backlight control works despite the warnings. I haven't tested this machine on an unpatched kernel. echo 1 > /dev/led/micmute has no effect.

@emaste Thanks for testing, that's quite interesting. Could you please send me your DSDT (acpidump -dt | gzip -c9 > foo.asl.gz)?

On my T470S the following commands work (I changed LPCB to LPC, as this seems to be correct on your machine), maybe you could test those too to verify:

kldload acpi_call
# mute sound
/usr/local/sbin/acpi_call -p \\_SB.PCI0.LPC.EC.HKEY.SSMS -i1
# set mic led (on F4 on my machine, i2 == on, i3 == blink)
/usr/local/sbin/acpi_call -p \\_SB.PCI0.LPC.EC.HKEY.MMTS -i2
# set keyboard backlight
/usr/local/sbin/acpi_call -p \\_SB.PCI0.LPC.EC.HKEY.MLCS -i2

Also, it would be interesting to see the output of

# get kbd backlight level
/usr/local/sbin/acpi_call -p \\_SB.PCI0.LPC.EC.HKEY.MLCG
# as your machine probably complains about that one, try this
/usr/local/sbin/acpi_call -p \\_SB.PCI0.LPC.EC.HKEY.MLCG -i1
grembo marked 3 inline comments as done.

Fix typo and extra whitespace

Here's the acpidump -dt:

I'm just booting this machine off a FreeBSD image on a USB stick and don't have any packages on here at the moment, but will try to test with acpi_call at some point.

Quick info, this works also fine on t480 (2018 model), btw this patch needs a rebase after rev: 300421 and rev: 335304.

/* Old pre-0x100 versions of the hkey interface (MHKV)

  • take no parameter to determine the hotkey mask. Newer models
  • (post-2015, like T460, T470s, Carbon X1) take one integer parameter

Does that mean that this patch also adds support for older keyboard LEDs like on the T430 / X230?

Can someone summarize what's preventing this patch from being committed?

Can someone summarize what's preventing this patch from being committed?

@seanc It's been a while... so basically I hacked this together (I don't think I ever managed to get the man page changes into review or even done). It works totally fine on my T470S, but if I remember correctly something was wrong with detecting if certain features are supported - my suspicion was that @emaste's Lenovo provided an ACPI function with the same name, but different parameters.

In other words: This works, but it sometimes detects a feature where it shouldn't be, which also leads to (harmless) error messages. We could still commit it, I'm happy to write some documentation. We can then refine it for older models based on input from users.

There's Bugzilla PR 229120 ("Add support for newer Thinkpad models with id LEN0268") and a commit rS346647 which overlaps with this patch.

I tried this patch on 12.1-RELEASE on a Thinkpad T450s.

To apply the patch, I changed the defines to this:

[...]
#define ACPI_IBM_METHOD_HANDLEREVENTS   14
#define ACPI_IBM_METHOD_MIC_LED         15
#define ACPI_IBM_METHOD_KBD_BACKLIGHT   16
#define ACPI_IBM_METHOD_KBD_BL_LEDON    17
#define ACPI_IBM_METHOD_KBD_BL_LEDOFF   18
#define ACPI_IBM_METHOD_MICMUTE_LED     19

Parts of the patch then applied, most had to be patched manually to match the version of acpi_ibm.c in 12.1

After building the module and loading it, I'm getting a warning from time to time

ACPI Warning: \134_SB.PCI0.LPC.EC.HKEY.MLCG: Insufficient arguments - Caller passed 0, method requires 1 (20181213/nsarguments-383)

Apart from this the patch works as expected. I can access the LEDs via sysctl and /dev/led.

Hi all, any updates on this patch getting merged? Whats the blocking issue ATM?