Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Keyboard backlight for the Lenovo Legion Pro 7 Gen 10
@ 2026-11-27  1:11 Ciro Pedrini via B4 Relay
  2026-11-27  1:11 ` [PATCH v3 1/2] platform/x86: ideapad-laptop: Ignore keyboard backlight hotkeys Ciro Pedrini via B4 Relay
  2026-11-27  1:11 ` [PATCH v3 2/2] HID: lenovo-legion: Add keyboard backlight driver for Legion Gen 10 Ciro Pedrini via B4 Relay
  0 siblings, 2 replies; 4+ messages in thread
From: Ciro Pedrini via B4 Relay @ 2026-11-27  1:11 UTC (permalink / raw)
  To: Mark Pearson, Derek J. Clark, Rong Zhang, Ike Panhc,
	Hans de Goede, Ilpo Järvinen, Jiri Kosina,
	Benjamin Tissoires
  Cc: David Cemin, Werner Sembach, Aaron Erhardt, platform-driver-x86,
	linux-kernel, linux-input, Ciro Pedrini

Hi,

This is v3 of the Legion keyboard backlight series. It has the changes
Ilpo and Rong asked for on v2, and one fix I found while testing them.

Short background: on my laptop the keyboard backlight never turned on
under Linux. The keyboard controller (048d:c197) stores a brightness from
0 to 9 behind a vendor feature report (0x07), it was 0 from the factory,
and nothing on Linux could change it. That brightness dims every LED of
the machine. Fn+Up/Down/Space are handled by the firmware, which sends
the new level on a vendor input report.

Patch 1 stops ideapad-laptop from sending KEY_UNKNOWN for those three
keys. Patch 2 is the driver: the brightness as a kbd_backlight LED, plus
brightness_hw_changed for the hotkeys so the desktop OSD works.

The fix: while testing v3 I found that the controller sends the same
"brightness is now B" report after every brightness set, the host's
own ones too, and also when the level doesn't change (Fn+Space sends
it as well). v2 passed all of those to brightness_hw_changed, so the
host's writes looked like hardware changes. v3 only reports a level
that differs from the last one the driver knows.

David: patch 1 adds three KE_IGNORE entries to the ideapad WMI keymap,
which your "architecture independent home for the Lenovo WMI drivers"
series moves to wmi-fn-keys.c. Whichever goes first, I'm happy to
rebase mine on yours; it's the same three lines in the new file.

I tested it on my 16IAX10H (83F5, BIOS Q7CN77WW) with 7.3 as a module:
brightness from sysfs and KDE, the hotkeys and the OSD, Fn+Space,
suspend/resume, unbind and rebind, and the vendor report on the wire
while doing that. It's based on pdx86 for-next and builds with W=1.

About how this was made: I found the protocol with usbmon captures and
by looking at Lenovo's Windows software. I wrote the code with help from
Claude Code (Claude Opus 5.5). I went through all of it and tested it
myself, and each patch has a short note about it below the ---.

Thanks,
Ciro

---
Changes in v3:
- Short reports: send only the request bytes and read only the answer
  bytes, right after the request; no more 100 ms wait (Rong).
- The buffer is allocated per exchange. Not on the stack as Rong
  suggested: usbhid hands it to the USB core for DMA.
- legion_raw_command() and legion_simple_command(), and the request
  length checked against the 960-byte report with a static_assert
  (Rong).
- Out-of-range values and failed reads return errors instead of being
  clamped or replaced; dbg messages, no hex dump (Ilpo, Rong).
- devm for hid_hw_start()/hid_hw_open() and the LED; .remove stays,
  empty, so hid-core doesn't stop the device twice (Ilpo, Rong).
- Dropped the (int) casts and the "(2025)"; comments trimmed, the one
  about HID_QUIRK_INPUT_PER_APP now says why; Kconfig help about what
  the driver does (Ilpo, Rong).
- New: only report a level change to brightness_hw_changed (see above).
- Rebased on current pdx86 for-next; Rong's Acked-by on patch 1.
- Link to v2: https://lore.kernel.org/r/20261110-legion-lighting-rfc-v2-0-845726afb71c@gmail.com

Changes in v2:
- Only the keyboard controller (c197) now, as Rong suggested. No
  LampArray, no colours, no lighting_mode, just a kbd_backlight LED.
- Ilpo's comments: struct with __le16 for the request, guard(),
  devm_mutex_init(), no magic numbers, includes.
- Removed the "ready" flag, its spinlock and the work item. raw_event
  can't run during probe/remove, so it notifies the LED directly.
- Keep led_cdev.brightness in sync with the hotkeys (from the Sashiko
  review).
- Moved the note about the AI tool out of the changelogs, below the ---.
- Link to v1: https://lore.kernel.org/r/20261109-legion-lighting-rfc-v1-0-a87e1db8c5e3@gmail.com

---
Ciro Pedrini (2):
      platform/x86: ideapad-laptop: Ignore keyboard backlight hotkeys
      HID: lenovo-legion: Add keyboard backlight driver for Legion Gen 10

 MAINTAINERS                                  |   1 +
 drivers/hid/Kconfig                          |  12 ++
 drivers/hid/Makefile                         |   1 +
 drivers/hid/hid-ids.h                        |   1 +
 drivers/hid/hid-lenovo-legion.c              | 293 +++++++++++++++++++++++++++
 drivers/platform/x86/lenovo/ideapad-laptop.c |   4 +
 6 files changed, 312 insertions(+)
---
base-commit: 61c0dac952b9308884936d05cce97565a5c89af4
change-id: 20261109-legion-lighting-rfc-dc32165df52d

Best regards,
-- 
Ciro Pedrini <ciro.pedrini@gmail.com>



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

end of thread, other threads:[~2026-11-27  1:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  1:11 [PATCH v3 0/2] Keyboard backlight for the Lenovo Legion Pro 7 Gen 10 Ciro Pedrini via B4 Relay
2026-11-27  1:11 ` [PATCH v3 1/2] platform/x86: ideapad-laptop: Ignore keyboard backlight hotkeys Ciro Pedrini via B4 Relay
2026-11-27  1:11 ` [PATCH v3 2/2] HID: lenovo-legion: Add keyboard backlight driver for Legion Gen 10 Ciro Pedrini via B4 Relay
2026-11-27  1:20   ` sashiko-bot

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