Re: [RFC PATCH 0/1] platform/x86: thinkpad_acpi: Add support for auto keyboard backlight
From: Vishnu Sankar
Date: Tue Nov 03 2026 - 23:58:22 EST
Hi Qiling,
Thanks a lot for the patches.
On Mon, Nov 2, 2026 at 3:02 AM Rong Zhang <i@xxxxxxxx> wrote:
>
> Hi Qiling,
>
> Thanks for working on this.
>
> On Sun, 2026-11-01 at 18:01 +0800, Qiling Zhu wrote:
> > Hi Mark, Ilpo, Rong,
> >
> > Recent ThinkPads with an ambient light sensor (ALS) support an auto
> > mode for the keyboard backlight: the EC picks the backlight level
> > according to ambient light. The mode is EC keyboard backlight level 3,
> > above the two fixed levels exposed so far, and it is reachable only
> > through the Fn+Space shortcut, which is handled entirely by the
> > firmware. Userspace can neither select the mode nor observe whether it
> > is active.
> >
> > This series wires the auto mode up as a private hardware control
> > trigger, "tpacpi-kbd-auto", on top of the hw control trigger framework
> > that recently landed in mainline [1]. With it:
> >
> > - selecting the trigger writes EC level 3 (auto mode on); writing
> > "none" turns the backlight off
> > - the trigger state (bracketed in the trigger sysfs attribute, and
> > the new trigger_may_offload_to_hw attribute) is the userspace
> > view of auto mode; reading brightness returns -ENODATA while
> > auto mode is active, per the framework semantics
> > - Fn+Space keeps cycling through levels and auto mode as before,
> > and the trigger state now follows hardware-initiated transitions
> > automatically
> >
> > This is the thinkpad_acpi counterpart of the ideapad-laptop wiring
> > from the same framework series, which is still queued; this patch
> > depends only on the LED core parts already in mainline and can be
> > applied independently.
> >
> > For background: the February discussion settled that auto mode must
> > not be exposed as a brightness value [2], but no agreement was
> > reached back then on how to expose it instead; the hardware control
> > trigger approach was established later by the framework series [1].
> >
> > Tested on a ThinkPad X1 Carbon Gen 14 (MT 21V8) running linux-next
> > next-20261030: 61 scripted user-visible assertions covering the
> > software paths, the Fn+Space event chain and the unchanged legacy
> > behavior, plus manual exercising of both the Fn+Space cycling and
> > desktop-environment brightness controls; checkpatch --strict clean.
> >
> > Deliberately unchanged (details in the commit message):
> >
> > - max_brightness stays 2; auto mode is not multiplexed into the
> > brightness value
> > - writing 3 to /proc/acpi/ibm/kbdlight keeps returning -EINVAL
> > - module unload still turns the keyboard backlight off
> >
> > Two open questions, the main reason for the RFC tag:
> >
> > 1. MLCG returns capability bits in the upper 16 bits; does one of
> > them indicate auto mode support? If yes, I would gate trigger
> > registration on it. Mark, does the EC documentation say?
> > 2. On models without an ALS, the EC behavior when asked for level 3
> > via MLCS is unknown to me. If it is undefined rather than
> > rejected, optimistic registration would need a rethink (e.g.
> > DMI whitelisting).
> >
> > Rong, happy to rebase this on top of your series or fold it in, if
> > you prefer to keep both wirings together.
>
> (+CC Vishnu)
>
> AFAIK, Vishnu is also working on adding the same support using the hw
> control trigger framework. Maybe they can answer your questions or
> integrate your patch into theirs.
Thanks, Rong.
Mark and I discussed this, and we are happy to go ahead with Qiling's
implementation rather than duplicate the work.
For some background, we had previously implemented the ThinkPad side
in thinkpad_acpi against Rong's hardware-control-trigger series and
tested it successfully on our hardware. We had been waiting for the
common LED infrastructure before taking that work further, so it is
good to see this moving forward now.
Regarding the open capability question, I checked the Lenovo
keyboard-backlight firmware definitions. MLCG provides an explicit
Auto-mode capability indication:
bit 20 = 0: Manual mode only
bit 20 = 1: Auto mode is available
So I think MLCG bit 20 is the appropriate indication to use when
deciding whether tpacpi-kbd-auto should be registered, rather than
probing level 3 or relying on ALS presence.
One clarification regarding "AUTO" mode: Auto mode on newer ThinkPads
is not necessarily ALS-dependent. Some systems use the ambient light
sensor as part of the automatic keyboard-backlight behavior, while
there is also an activity-only based Auto behavior where the backlight
turns on following keyboard activity and turns off after a period of
inactivity. Therefore, absence of ALS does not by itself mean that
Auto mode is unsupported. The firmware-reported Auto capability should
be the better discriminator.
Regarding MLCS bit 31 discussed earlier, please ignore that bit for
Auto-mode capability detection. The explicit capability indication is
MLCG bit 20.
Based on this, my suggestion would be to gate Auto-trigger
registration on MLCG bit 20 and leave the actual Auto behavior to the
firmware.
I am happy to test the next revision on additional ThinkPad hardware as well.
>
> Thanks,
> Rong
>
> >
> > Comments welcome.
> >
> > Regards,
> > Qiling Zhu
> >
> > This patch was developed with LLM assistance; I reviewed every design
> > decision against the framework sources and validated the behavior on
> > real hardware myself.
> >
> > [1] https://lore.kernel.org/r/20260618-leds-trigger-hw-changed-v2-0-c28c44053cf3@xxxxxxxx/
> > [2] https://lore.kernel.org/r/20260203232219.11683-1-vishnuocv@xxxxxxxxx/
> >
> > Qiling Zhu (1):
> > platform/x86: thinkpad_acpi: Add support for auto keyboard backlight
> >
> > drivers/platform/x86/lenovo/Kconfig | 1 +
> > drivers/platform/x86/lenovo/thinkpad_acpi.c | 104 ++++++++++++++++----
> > 2 files changed, 88 insertions(+), 17 deletions(-)
--
Regards,
Vishnu Sankar