Re: [PATCH v3 0/2] Keyboard backlight for the Lenovo Legion Pro 7 Gen 10

From: Rong Zhang

Date: Sat Nov 28 2026 - 07:06:29 EST


Hi Ciro, David,

On Fri, 2026-11-27 at 01:11 +0000, Ciro Pedrini via B4 Relay wrote:
> 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.

David, could you integrate PATCH 1 into your series when you resubmit it?
I.e., append a PATCH 4.

I believe this is the easiest way to solve the collision. The hid-lenovo-
legion driver (PATCH 2) does not depend on PATCH 1 per se, so they can be
applied in an arbitrary order.

Thanks,
Rong

>
> 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@xxxxxxxxx
>
> 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@xxxxxxxxx
>
> ---
> 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,