mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rong Zhang <i@rong.moe>
To: ciro.pedrini@gmail.com,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Ike Panhc" <ikepanhc@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <bentiss@kernel.org>
Cc: David Cemin <dcemin@nvidia.com>,
	Werner Sembach <wse@tuxedocomputers.com>,
	 Aaron Erhardt <aer@tuxedocomputers.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,  linux-input@vger.kernel.org
Subject: Re: [PATCH v3 0/2] Keyboard backlight for the Lenovo Legion Pro 7 Gen 10
Date: Sat, 28 Nov 2026 20:00:53 +0800	[thread overview]
Message-ID: <3468fb09e97e129fd11dfa334da1af289a96d31d.camel@rong.moe> (raw)
In-Reply-To: <20261127-legion-lighting-rfc-v3-0-15c55d9f15b7@gmail.com>

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

  parent reply	other threads:[~2026-11-28 12:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2026-11-28 12:01   ` Rong Zhang
2026-11-28 12:00 ` Rong Zhang [this message]
2026-11-28 17:46 ` [PATCH v3 0/2] Keyboard backlight for the Lenovo Legion Pro 7 " Marco Giunta
2026-11-28 18:43   ` Rong Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3468fb09e97e129fd11dfa334da1af289a96d31d.camel@rong.moe \
    --to=i@rong.moe \
    --cc=aer@tuxedocomputers.com \
    --cc=bentiss@kernel.org \
    --cc=ciro.pedrini@gmail.com \
    --cc=dcemin@nvidia.com \
    --cc=derekjohn.clark@gmail.com \
    --cc=hansg@kernel.org \
    --cc=ikepanhc@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=wse@tuxedocomputers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®