Re: [PATCH v2 2/2] HID: lenovo-legion: Add keyboard backlight driver for Legion Gen 10

From: Rong Zhang

Date: Wed Nov 11 2026 - 12:46:05 EST


Hi Ciro,

On Wed, 2026-11-11 at 14:12 -0300, Ciro Pedrini wrote:
> Hi Rong,
>
> Thanks for the review. I'll fix the rest in v3, but before I go on with
> it I would like to hear from you on these.
>
> On Wed, 2026-11-11 at 20:09 +0800, Rong Zhang wrote:
> > On Tue, 2026-11-10 at 20:29 +0000, Ciro Pedrini via B4 Relay wrote:
> > > Its hardware brightness, 0..9, is stored in the controller and applies to
> > > every LED of the machine (keys, front strip, rear vents, lid logo).
> >
> > I don't know if it's appropriate to represent so many things with the
> > name "legion::kbd_backlight".
>
> I gave splitting it some thought, and looked (with the help of an LLM)
> at how other drivers handle this. We could register one LED per zone,
> but that seems to be usually rejected, because they would not be
> independent: the controller has a single brightness for all zones, so
> writing any of them would change all of them.

My opinion is that we'd better figure out another representative name, as
it actually affects other things...

>
> Per-zone control is only possible through the LampArray (c193). It has
> 319 lamps, each with its own colour, and they are grouped by zone (keys,
> front strip, rear vents, lid logo), so a LampArray driver could light
> or dim each zone on its own. That needs c197 to hand the LEDs over
> first, as discussed in the other thread.
>
> Also, going with kbd_backlight seems like a good idea so that UPower
> and the desktops pick it up automatically.
>
> Thoughts? I'd like a confirmation from someone who knows how this is
> usually handled in Linux, as I don't have much experience with it.

...though I won't insist if you still prefer kbd_backlight, as long as
others are not opposed to it.

>
> > Just curious, can the software select which effect to use, or listen to
> > an event when Fn+Space is pressed?
>
> Yes. 0xCA reads the current effect and 0xC8 sets it. On Fn+Space the
> controller sends report 5 as 05 01 P (P = the new effect), then
> 05 02 B (B = the brightness).

Got it. We can figure out a way to coordinate LampArray autonomous mode
with it in the future.

>
> > I wonder, what if we set the report with a short report size, say,
> > struct_size(msg, params, len)? Could the device handle it properly in
> > this case? If so, there is a chance that we don't need to sleep for 100ms
> > later (I guess the device is processing too much data, causing the
> > massive delay).
>
> You were right. I tried it on the laptop: it takes the short request,
> and it only ever answers 5 bytes anyway, even when asked for 960. The
> answer is there right away, I read it with delays from 100 ms down to 0
> and it was always correct. So a brightness read goes from ~115 ms to
> ~2 ms.
>
> Setting the brightness with a short request works too, and reading it
> right after returns the new value.

In this case you don't need the pre-allocated buffer, too. Let's allocate
a tiny buffer on stack.

>
> In v3 I'll send and read short reports and drop the msleep().
>
> > Ditto, what if we get the report with struct_size(msg, params, 1)?
>
> Same, that works.

Great :-)

Thanks,
Rong

>
> Thanks,
> Ciro