The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: matan@svgalib.org, Hans de Goede <hansg@kernel.org>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/5] platform/x86: lg-laptop: Fix keyboard backlight support on LG Gram 16T90SP
Date: Fri, 3 Jul 2026 16:22:13 +0300 (EEST)	[thread overview]
Message-ID: <6d134940-9dba-cc0d-dfb0-a375c4071310@linux.intel.com> (raw)
In-Reply-To: <20260622193914.116999-6-W_Armin@gmx.de>

On Mon, 22 Jun 2026, Armin Wolf wrote:

> On the LG Gram 16T90SP, the ACPI firmware will only accept the values
> 0x80, 0xA2 and 0xA4 when setting the keyboard backlight. After a bit
> of research using ACPI tables from older models it seems that bit 8
> is supposed to be always written as 1.
> 
> Fix the keyboard backlight support on this model by always setting
> bit 8 inside the argument passed to the WMAB ACPI control method.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>  drivers/platform/x86/lg-laptop.c | 47 ++++++++++++++++++++++++--------
>  1 file changed, 36 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
> index d1b33a6b5206..22f8a6368f7c 100644
> --- a/drivers/platform/x86/lg-laptop.c
> +++ b/drivers/platform/x86/lg-laptop.c
> @@ -86,6 +86,18 @@ MODULE_PARM_DESC(fw_debug, "Enable printing of firmware debug messages");
>  #define WMBB_USB_CHARGE 0x10B
>  #define WMBB_BATT_LIMIT 0x10C
>  
> +#define KBD_LED_BRIGHTNESS_MASK GENMASK(4, 0)
> +#define KBD_LED_BRIGHTNESS_OFF	0x0
> +#define KBD_LED_BRIGHTNESS_HALF 0x2
> +#define KBD_LED_BRIGHTNESS_FULL 0x4
> +#define KBD_LED_MODE_MASK	GENMASK(6, 5)

bits.h needed.

> +#define KBD_LED_MODE_OFF	0x0
> +#define KBD_LED_MODE_ON		0x1
> +#define KBD_LED_STATUS		BIT(7)
> +#define KBD_LED_MAGIC_MASK	GENMASK(15, 8)
> +/* Exact purpose is unknown, maybe some sort of brightness limit? */
> +#define KBD_LED_MAGIC		0x05
> +
>  #define FAN_MODE_LOWER GENMASK(1, 0)
>  #define FAN_MODE_UPPER GENMASK(5, 4)
>  
> @@ -601,15 +613,25 @@ static LED_DEVICE(tpad_led, 1, 0);
>  static void kbd_backlight_set(struct led_classdev *cdev,
>  			      enum led_brightness brightness)
>  {
> -	u32 val;
> +	/* Must always be written */
> +	u32 value = KBD_LED_STATUS;
> +	u32 mode, bright;
> +
> +	if (brightness <= LED_OFF) {
> +		mode = KBD_LED_MODE_OFF;
> +		bright = KBD_LED_BRIGHTNESS_OFF;
> +	} else {
> +		mode = KBD_LED_MODE_ON;
> +		if (brightness >= LED_FULL)
> +			bright = KBD_LED_BRIGHTNESS_FULL;
> +		else
> +			bright = KBD_LED_BRIGHTNESS_HALF;
> +	}
>  
> -	val = 0x22;
> -	if (brightness <= LED_OFF)
> -		val = 0;
> -	if (brightness >= LED_FULL)
> -		val = 0x24;
> +	value |= FIELD_PREP(KBD_LED_BRIGHTNESS_MASK, bright);
> +	value |= FIELD_PREP(KBD_LED_MODE_MASK, mode);
>  
> -	lg_wmab_set(cdev->dev->parent, WM_KEY_LIGHT, val);
> +	lg_wmab_set(cdev->dev->parent, WM_KEY_LIGHT, value);
>  }
>  
>  static enum led_brightness get_kbd_backlight_level(struct device *dev)
> @@ -621,13 +643,16 @@ static enum led_brightness get_kbd_backlight_level(struct device *dev)
>  	if (ret < 0)
>  		return LED_OFF;
>  
> -	if ((value & 0xFF00) != 0x0500)
> +	if (FIELD_GET(KBD_LED_MAGIC_MASK, value) != KBD_LED_MAGIC)
> +		return LED_OFF;
> +
> +	if (FIELD_GET(KBD_LED_MODE_MASK, value) == KBD_LED_MODE_OFF)
>  		return LED_OFF;
>  
> -	switch (value & 0x27) {
> -	case 0x24:
> +	switch (FIELD_GET(KBD_LED_BRIGHTNESS_MASK, value)) {
> +	case KBD_LED_BRIGHTNESS_FULL:
>  		return LED_FULL;
> -	case 0x22:
> +	case KBD_LED_BRIGHTNESS_HALF:
>  		return LED_HALF;
>  	default:
>  		return LED_OFF;

Superb, I was already wanting to see this in patch 4 but had enough 
patience to look the subsequent patch first. Thanks for naming them!

-- 
 i.


  reply	other threads:[~2026-07-03 13:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 19:39 [PATCH 0/5] platform/x86: lg-laptop: Improve support for modern devices Armin Wolf
2026-06-22 19:39 ` [PATCH 1/5] platform/x86: lg-laptop: Fix LED resource handling Armin Wolf
2026-06-22 19:39 ` [PATCH 2/5] platform/x86: lg-laptop: Add support for native ACPI events Armin Wolf
2026-07-03 13:14   ` Ilpo Järvinen
2026-07-03 17:59     ` Armin Wolf
2026-06-22 19:39 ` [PATCH 3/5] platform/x86: lg-laptop: Add support for additional events Armin Wolf
2026-06-22 19:39 ` [PATCH 4/5] platform/x86: lg-laptop: Improve WMAB control method support Armin Wolf
2026-06-22 19:39 ` [PATCH 5/5] platform/x86: lg-laptop: Fix keyboard backlight support on LG Gram 16T90SP Armin Wolf
2026-07-03 13:22   ` Ilpo Järvinen [this message]
2026-07-03 18:05     ` Armin Wolf

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=6d134940-9dba-cc0d-dfb0-a375c4071310@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=W_Armin@gmx.de \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matan@svgalib.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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