mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rong Zhang <i@rong.moe>
To: Ciro Pedrini <ciro.pedrini@gmail.com>
Cc: "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>,
	"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 RFC 0/2] Keyboard lighting for the Lenovo Legion Pro 7 Gen 10
Date: Wed, 11 Nov 2026 20:10:28 +0800	[thread overview]
Message-ID: <db41708e7676697fda99573a31d7747dee112403.camel@rong.moe> (raw)
In-Reply-To: <CAPKD0HduW_atYsz47Nv-9A_88K1B33xENUnZgQAKcH4VHqV9PA@mail.gmail.com>

Hi Ciro,

On Tue, 2026-11-10 at 17:34 -0300, Ciro Pedrini wrote:
> Hi Rong,
> 
> On Tue, 2026-11-10 at 22:56 +0800, Rong Zhang wrote:
> > Thanks for working on this.
> 
> Thanks for looking at it (and for the clear direction, it helped a lot).
> 
> [...]
> 
> > Let's take it step by step, and submit a driver for 048d:c197 first. As
> > far as I understood, the driver should be able to handle "hardware
> > brightness (0..9, stored), the controller's own effects (stored
> > profiles)," and "Fn+Up/Down/Space" by its own. (Please correct me if I
> > misunderstood your words.)
> 
> Makes sense. v2 only does c197, and it doesn't depend on any LampArray
> work:
> https://lore.kernel.org/r/20261110-legion-lighting-rfc-v2-0-845726afb71c@gmail.com
> 
> About your question: yes, the firmware does all of that by itself.
> Fn+Up/Down change the brightness (in steps of 3, and it's stored) and
> the controller sends the new level on a vendor input report. The driver
> only exposes the brightness as kbd_backlight and forwards the hotkey
> changes as brightness_hw_changed. Fn+Space switches between the stored
> effects (6 states counting off). The controller can also read and set
> the active effect, but I left that out of v2.
> 
> > I am also working on a independent hid-lamparray implementation that is
> > far more generic than Aaron and Werner's series.
> 
> Something you may want to know for your driver: on this laptop c193
> doesn't show anything on its own. c197 has to hand the LEDs over first,
> with its vendor command 0xAA (07 AA 02 00 00 00 gives them to the
> LampArray, 07 AA 02 00 01 00 gives them back). The controller remembers
> it after power-off, but it only matters while the LampArray is in host
> mode. In autonomous mode you see the controller's effects anyway. So a
> generic driver on c193 alone would register lamps that do nothing until
> c197 is switched.

What if (four permutations):

- c197 sends 07 AA 02 00 00/01 00
- c193 sends autonomous_mode=on/off

And what if the sequence is reversed (another four permutations)?

> 
> v2 doesn't touch 0xAA. How would you like to handle it with your
> driver? A sysfs attribute on c197, something with your autonomous mode
> trigger, the component framework? 
> 

I expect 07 AA 02 00 01 00 acts like a hardware control trigger. It may
be able to reuse the autonomous mode trigger, but it depends on the
answer to the previous question.

In either way, the handover is controlled by the lamparray LED classdev's
hardware control trigger.

My implementation connects the LampArray application to hid-input, so any
HID driver with hid_hw_start(HID_CONNECT_DEFAULT) or
hid_hw_start(HID_CONNECT_HIDINPUT | ...) will initialize the LampArray
application. Therefore, I suppose the only thing we need is a simple glue
driver[1] for c193. The glue driver binds to the component master[2],
pre-allocates[3] the hid_lamparray struct with some necessary
callbacks[4] registered, and call hid_hw_start() to wire things up.

In this manner, you can get rid of the one-driver-two-device nightmare.
The component master and the component can be located in different
drivers and coordinate using the component framework.

Does that make sense to you?

[1]: I will call it hid-lenovo-legion-la

[2]: hid-lenovo-legion (c197)

[3]: Usually it's allocated by hid-input when hid_hw_start() is called.
Pre-allocate it with prefilled callbacks is sufficient to provide extra
functionalities to the HID LampArray application helper

[4]: hid-lenovo-legion passes a device handle along with several
callbacks to hid-lenovo-legion-la. hid-lenovo-legion-la passes some
wrapper callbacks that calls the former's callbacks with the device
handle to hid-lamparray

> Once your series is out I'm happy to
> write that part and test it here.

I will CC you when I submit it. For now let's focus on the driver for
c197 first.

Thanks,
Rong

> 
> > Please use the component framework (not in your next revision, it should
> > only add support for 048d:c197).
> 
> OK, noted.
> 
> Thanks,
> Ciro

      reply	other threads:[~2026-11-11 12:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 22:50 Ciro Pedrini via B4 Relay
2026-11-09 22:50 ` [PATCH RFC 1/2] platform/x86: ideapad-laptop: Ignore keyboard backlight hotkeys Ciro Pedrini via B4 Relay
2026-11-10 18:44   ` Rong Zhang
2026-11-09 22:50 ` [PATCH RFC 2/2] HID: lenovo-legion: Add keyboard lighting driver for Legion Gen 10 Ciro Pedrini via B4 Relay
2026-11-10 10:28   ` Ilpo Järvinen
2026-11-10 20:34     ` Ciro Pedrini
2026-11-10 14:56 ` [PATCH RFC 0/2] Keyboard lighting for the Lenovo Legion Pro 7 " Rong Zhang
2026-11-10 20:34   ` Ciro Pedrini
2026-11-11 12:10     ` Rong Zhang [this message]

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=db41708e7676697fda99573a31d7747dee112403.camel@rong.moe \
    --to=i@rong.moe \
    --cc=aer@tuxedocomputers.com \
    --cc=bentiss@kernel.org \
    --cc=ciro.pedrini@gmail.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®