mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/6] platform/x86: thinkpad_acpi: Add a keyboard backlight auto-mode trigger
@ 2026-11-25  8:46 Qiling Zhu
  2026-11-25  8:46 ` [PATCH v4 1/6] platform/x86: thinkpad_acpi: Report auto keyboard backlight mode as off Qiling Zhu
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Qiling Zhu @ 2026-11-25  8:46 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Rong Zhang, Hans de Goede,
	Ilpo Järvinen, Henrique de Moraes Holschuh
  Cc: platform-driver-x86, linux-kernel, ibm-acpi-devel, Lee Jones,
	Pavel Machek, Griffin Kroah-Hartman, linux-leds, vishnuocv,
	vsankar, Andrea Rabbaglietti

Hi all,

On supported ThinkPads, Fn+Space can select automatic keyboard
backlight control.  This series exposes that mode through the private
LED trigger "tpacpi-kbd-auto".  The first patch fixes an out-of-range
brightness value that was reported to make UPower stop tracking hotkey
changes on a ThinkPad X9-14 Gen 1.

This is v4 of the thinkpad_acpi keyboard backlight auto mode series.
Many thanks to Rong, Mark and Vishnu for the reviews and the firmware
side answers so far, and to Andrea for the report behind the first
patch.  I have tried to follow the v3 comments one by one; where I was
not sure how to read a comment, I say so below and would be glad to be
corrected.

As Rong asked, this version starts a new thread.  For reference, v3
is here:

  https://lore.kernel.org/r/20261114174814.62153-1-kmatzkaczor244@gmail.com/

and my reply with the sleep test data is here:

  https://lore.kernel.org/r/av14Sp6_nKwU5F-i@ThinkPad/

The series went from seven patches to six: the two suspend/resume
patches of v3 are replaced by one, which now sits before the trigger
patch.

  1/6  Report auto keyboard backlight mode as off          (stable)
  2/6  Extract kbdlight notify helpers                  (refactor)
  3/6  Don't poke keyboard backlight's LED core brightness (writes)
  4/6  Restore keyboard backlight level ourselves       (sleep/wake)
  5/6  Detect auto-mode capability via MLCG             (groundwork)
  6/6  Add a keyboard backlight auto-mode trigger         (feature)

Changes since v3, by comment:

- 1/6 does the mapping in a small helper with an int return type, as
  Rong suggested while reviewing the trigger patch; 4/6 reuses the
  helper for brightness notifications.  With 1/6 on its own, on kernels
  that still use the LED core suspend/resume path, a backlight that
  went to sleep in auto mode comes back off after resume, where the
  unmapped value used to be written back; 4/6 restores the level the EC
  had.  I kept 1/6 small so that it can go to stable on its own, and
  would like to hear if this trade-off looks wrong for stable.

- 2/6 takes the title Rong suggested, states the locking contract with
  lockdep_assert_held() instead of a comment, and drops the braces.
  The helpers are placed where the later patches need them, in the
  hope that no later patch has to add a forward declaration.

- 3/6 takes Rong's title.  Of the two software write paths, only the
  proc path reports changes through brightness_hw_changed; the sysfs
  path just writes the level and updates the cached one.  Fn+Space
  changes continue to be reported.  The text after the --- line is my
  attempt to explain why leaving the LED core's cached brightness alone
  seems acceptable to me; if the reasoning there falls short, please
  tell me.

- 4/6 replaces v3 5/7 and 7/7.  With the driver unloaded on my
  machine, the backlight went out when entering s2idle and
  hibernation; on wake from s2idle the EC was back at its previous
  level, and on wake from hibernation it was at 0 for each of the four
  starting levels.  So kbdlight_suspend() is gone and kbdlight_resume()
  writes the cached EC level back on resume, for every model rather
  than only auto mode ones.  The cached level becomes the raw EC level
  in this patch, so that resume treats the auto mode like any other
  level.  I did not add a check on LED_SUSPENDED: this LED does not set
  LED_CORE_SUSPENDRESUME, and with the suspend callback gone I do not
  see what would set the flag for it; my understanding of Rong's reply
  was that such a gate might not be needed.  The patch comes before the
  trigger patch so that no intermediate commit has the trigger together
  with the old LED core suspend/resume path.

- 5/6 uses a symbolic name for bit 20, as Rong asked.

- 6/6 routes trigger activation through the helper that also updates
  the cached level, which I believe addresses the stale cache Sashiko
  reported.  It also skips the trigger notification when the trigger
  could not be registered, pulls the registration into a small helper,
  and still makes the trigger the default one at init when the EC is
  already in auto mode, now with a comment on the case this is meant
  for, as Rong suggested on Nov 19.  The title was changed to say more
  precisely what the patch adds.

On the Reviewed-by tags: the changes to 1/6 and 5/6 are small, but the
diffs are no longer the ones Mark reviewed, so I dropped his tags there
and noted it under the --- line.  Mark, when you have the time, could
you take another look at these two?

I could only test on a ThinkPad X1 Carbon Gen 14 (linux-next
next-20261030): the software paths (selecting and dropping the trigger,
brightness returning -ENODATA in auto mode), the trigger following
Fn+Space in and out of auto mode, and suspend/resume from manual
levels and from auto mode, with s2idle and with S4.  No S3-capable
machine and no other model was available to me, so testing elsewhere
would be very welcome.  Vishnu, Mark, thank you for offering.

One observation from testing with a desktop session, since it can look
like a driver bug at first: the level restored on wake was sometimes
overwritten again a few seconds later.  KDE's power management writes
back the keyboard brightness it last knew about after resume, and a
level written directly through sysfs does not appear to reach it;
changes made with Fn+Space or through the desktop itself did not seem
affected.  I do not think there is anything for this series to do
about it, but I wanted to mention it.

One naming note: kbdlight_brightness now holds the raw EC level,
including the auto mode, rather than a brightness; a comment above the
variable says so, and the name is unchanged.

The only checkpatch.pl --strict warnings I see are for three commit
IDs that are missing from my shallow clone.

This series was developed with LLM assistance; I reviewed every design
decision against the framework sources and validated the behavior on
real hardware myself.

Regards,
Qiling Zhu

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-11-25 13:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25  8:46 [PATCH v4 0/6] platform/x86: thinkpad_acpi: Add a keyboard backlight auto-mode trigger Qiling Zhu
2026-11-25  8:46 ` [PATCH v4 1/6] platform/x86: thinkpad_acpi: Report auto keyboard backlight mode as off Qiling Zhu
2026-11-25  8:46 ` [PATCH v4 2/6] platform/x86: thinkpad_acpi: Extract kbdlight notify helpers Qiling Zhu
2026-11-25  8:46 ` [PATCH v4 3/6] platform/x86: thinkpad_acpi: Don't poke keyboard backlight's LED core brightness Qiling Zhu
2026-11-25 13:11   ` Rong Zhang
2026-11-25  8:46 ` [PATCH v4 4/6] platform/x86: thinkpad_acpi: Restore keyboard backlight level ourselves Qiling Zhu
2026-11-25 13:16   ` Rong Zhang
2026-11-25  8:46 ` [PATCH v4 5/6] platform/x86: thinkpad_acpi: Detect auto-mode capability via MLCG Qiling Zhu
2026-11-25 13:17   ` Rong Zhang
2026-11-25  8:46 ` [PATCH v4 6/6] platform/x86: thinkpad_acpi: Add a keyboard backlight auto-mode trigger Qiling Zhu
2026-11-25 13:17   ` Rong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®