From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.112 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796486923; b=IItyhuTxscno6M+gwMGLyN5FULLMKlJ1wRx93ZJCBMzqketzpfaVSPJ1+MYLNc4FhLvs HvxiFblKLfaSWrcE36bmQ+Io46YSxVovm1M1NmHpomQaKMmMMr/gL0h3o0GgUfe5FPMxS Ll71y3bjmdZMcImyExL6K+KN6aAb7qttNkmr5iDIkNKBoDgZLmxkxonVLEtme0A4wvgas EZkdOtM0QOC9Jej5EmHMDI1k5bwqH3bjiF94S/81YgHKc8E0yuk3SP1+MJRUPz3Y+Fd88 1KTdYm8EPhpXWElVQSdCyraxcsaCpJK1q0BTh0oe4ruSGi5Fbr5cgQifdUGcboCYAGg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796486923; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Subject:From:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date: MIME-Version:User-Agent:X-ZohoMailClient; bh=AJrHG1NFUmMYKMxzuSH8Ov3EwB9CX5urYo/LNQ8PUtI=; b=FqWpsDMnimYbr7WeFQ9Lh1PQSXTdgLIh/HALyh3TapVv8KtCsjKbsmZszhtIY/FWUsrL wqFTCWH7z59vCkkKX48iBs8IBXvN2vx8hMI5h8lMtvT0NBFucpX4atGWjUKWYiFaSieJQ uIZH9YglphU2LfUaL86OgH1k1lbP8aj48PT8GTzkVN6+xdQKKugHA42L9pbI4D3OlygGo jFWpupeG9XLCdpxSxa7my9DreRWlU1ac+F+PtYxY9jJqkdWhAv1L0SBsJB/9bi2Oyyhlz 7y2IYXL28LoIFRzOyCPxBB0pTEz123gezf1xhipGd9vi0Bj4QikrnriFZpHobEXDE5Q== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=rong.moe; spf=pass smtp.mailfrom=rong.moe; dkim=pass header.d=rong.moe header.i=@rong.moe header.a=rsa-sha256 header.s=zmail2048 header.b=XK0KC+0E; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.112 Received: from sender6-pp-f112.zoho.com (sender6-pp-f112.zoho.com [165.173.180.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CF4A606A31F; Sat, 5 Dec 2026 16:08:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2CF4A606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rong.moe Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rong.moe Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=rong.moe header.i=@rong.moe header.a=rsa-sha256 header.s=zmail2048 header.b=XK0KC+0E ARC-Seal: i=1; a=rsa-sha256; t=1796486882; cv=none; d=zohomail.com; s=zohoarc; b=ZQUwawvfehkyAtLuPgtBOdjscLtzCHU/Mkvo3T35o4Dtryjz3kH0iYgT1gQ1cYtoQspDEjf3dyoLxjPAeLtaJoOfZIl8+T+YQCttOxge5kT4ZiGMqb55Gx2qcixMuMvCs/Vf7lLrMmusI1hRAiiATsH8yDjMMa8R9HwVEXSFUyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796486882; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=AJrHG1NFUmMYKMxzuSH8Ov3EwB9CX5urYo/LNQ8PUtI=; b=lzHyQABmQCBqgB6D4vFbepLa53+SI4bBAen1GFGGphM/shPGqq6DN4jiAliZJF3eUwCLb6LpKv0nrxjstTtG3jekrFexX8TKcmjXh+bHjs91QB5Gz0tSBkzascoA+FuoAO3i6YHLzLF+AOLwQ3M6Oc4puCneboC8cior+QUSvfw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rong.moe; spf=pass smtp.mailfrom=i@rong.moe; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=XK0KC+0ERho3sD93uF28tlL1f9+L4HhGJ6BucH/Gq4yzJkdt0mtzYPh47Ry8IyKcUqD7iljnAk56OLOu9aHNlyiPdHAgElPtJtoMlndNut7gsB+/7eiOrrinR7We2SDONhNxnqcA2hP9qcxFRh4I6Rb8S53rrLe7ZMil2JaFsq5U4gYkQSMbJivmiaE0kIhvJxSe0EF4kiBSGXBKOw9Dd/C8+KyW5VHqHOA+DkR40ei4c7526Piq2vNdVRrNtpNskNdkB0PU1nFmmHIkFMEV29zF/FDV7pw5LyvGRBGUW92NJiD5Jj20dWNvsO0ATP77N8V7ucEmuqHSmyucSVFv+Q==; c=relaxed/relaxed; s=zmail2048; d=rong.moe; v=1; bh=AJrHG1NFUmMYKMxzuSH8Ov3EwB9CX5urYo/LNQ8PUtI=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1796486880403196.3264344241012; Sat, 5 Dec 2026 08:08:00 -0800 (PST) Message-ID: <50428398bebbcbbde79f4abba2fde26dcb600dd3.camel@rong.moe> Subject: Re: [PATCH v6] platform/x86: asus-wmi: Add support for ASUS_WMI_DEVID_CAMERA_LED_NEG From: Rong Zhang To: git@turtledev.nz, Corentin Chary , "Luke D. Jones" , Denis Benato , Hans de Goede , Ilpo =?ISO-8859-1?Q?J=E4rvinen?= , platform-driver-x86@vger.kernel.org Cc: =?ISO-8859-1?Q?Jos=E9?= Guilherme de Castro Rodrigues , Devin Bayer , Mia Herkt , linux-kernel@vger.kernel.org In-Reply-To: <20261204-asus-wmi-camera-led-v6-1-ba06c19c81bc@turtledev.nz> References: <20261204-asus-wmi-camera-led-v6-1-ba06c19c81bc@turtledev.nz> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 00:02:51 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Evolution 3.62.2-1 X-ZohoMailClient: External Hi Zane, On Fri, 2026-12-04 at 18:42 +1300, Zane Hunt via B4 Relay wrote: > From: Zane Hunt >=20 > On some newer Zenbooks (Zenbook S 14 UX5406SA, Zenbook S 16 UM5606WA) the > camera key turns the camera off in firmware, but the LED on the key never > lights up under Linux. These machines don't have > ASUS_WMI_DEVID_CAMERA_LED, so asus-wmi never registers asus::camera. The > firmware exposes the state through ASUS_WMI_DEVID_CAMERA_LED_NEG instead. >=20 > Reading CAMERA_LED_NEG is what drives the LED: the DSTS handler reads the > camera state from the EC and writes it to the LED GPIO before returning > it. The set side can't be used, the firmware only accepts DEVS on this > device once per boot. >=20 > When CAMERA_LED is missing but CAMERA_LED_NEG is there, register > asus::camera as a read-only LED backed by CAMERA_LED_NEG, and read it > after every camera key event, sending a brightness_hw_changed event. > Do the same on resume: on some models the camera key still works in > s2idle but sends no event, which left the LED showing the old state. > Registering the LED reads it as well, which fixes the LED being dark afte= r > a cold boot with the camera disabled. There is no brightness_set > callback, so writes to the brightness attribute are ignored, as with > other get-only LEDs. >=20 > While at it, include , which this file already > relied on. >=20 > Link: https://lore.kernel.org/r/adg6GzkykThAB_4u@djouze-zen > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D221752 > Assisted-by: Claude:claude-opus-5-5 iasl > Co-developed-by: Jos=C3=A9 Guilherme de Castro Rodrigues > Signed-off-by: Jos=C3=A9 Guilherme de Castro Rodrigues > Signed-off-by: Zane Hunt > --- > Changes in v6: > - Also resync the LED on resume and restore. Mia found that on the > Zenbook S 16 the camera key still toggles the camera in s2idle without > sending an event, so after disable -> s2idle -> enable -> resume the > LED stayed on with the camera enabled > (https://lore.kernel.org/r/nHv94wFvQJyCt2jjVWdO5A@0x0.st) > - Move the read + brightness_hw_changed into camera_neg_led_update(), > used by the key event and both PM callbacks > - Dropped the Reviewed-by tags from v5 since the resume path is new > - Rebased on pdx86 for-next, fixed the conflict with the user-status LED > - Link to v5: https://patch.msgid.link/20261117-asus-wmi-camera-led-v5-1-= 41c47653758b@turtledev.nz >=20 > platform/x86: asus-wmi: Add support for ASUS_WMI_DEVID_CAMERA_LED_NEG >=20 > Changes in v5: > - Rebased on pdx86 for-next, asus-wmi.c has moved to > drivers/platform/asus/ > - Change the subject, this adds support for CAMERA_LED_NEG rather than > fixing a bug in the driver (Rong) > - Drop camera_neg_led_set(), so asus::camera has no brightness_set now. > The key event already resyncs the LED, and skyedryv's s2idle test > showed nothing gets missed while suspended (Jos=C3=A9, Rong) > - "Returns" -> "Returns:" in the camera_neg_led_sync() comment (Ilpo) > - Kept Ilpo's Reviewed-by since the only code change is dropping the > set callback > - Rong's idea of also sending brightness_hw_changed on machines that > have both CAMERA_LED and CAMERA_LED_NEG is left for a follow-up, I > only have the UX5406SA to test with > - Link to v4: https://patch.msgid.link/20261019-asus-wmi-camera-led-v4-1-= 7744c125bcc9@turtledev.nz >=20 > Changes in v4: > - Keep Jos=C3=A9's Signed-off-by from v2 and add his Co-developed-by > - Use my full name in the tags > - Include > - Reuse the existing asus::camera registration block, only the > handlers and flags differ > - camera_neg_led_available is now only set when CAMERA_LED is missing, > so asus::camera is always the CAMERA_LED_NEG one when it's set. That > makes the LED_BRIGHT_HW_CHANGED check in the event handler unneeded, > so it's gone > - Drop the explicit read at probe, led_classdev_register() already > reads the state through brightness_get > - Link to v3: https://patch.msgid.link/20261017-asus-wmi-camera-led-v3-1-= 845a82373997@turtledev.nz >=20 > Changes in v3 (picking up Jos=C3=A9's v2, which had stalled): > - Rebased on pdx86 for-next > - Also read CAMERA_LED_NEG at probe, so the LED is right after a cold boo= t > - Register a read-only asus::camera LED when only CAMERA_LED_NEG exists, > with brightness_hw_changed on key presses (Ilpo's suggestion on v2) > - Comment on why the read is what updates the LED (also from v2 review) > - v2: https://lore.kernel.org/r/adg6GzkykThAB_4u@djouze-zen >=20 > Tested v6 on the Zenbook S 14 UX5406SA (BIOS 309), on Fedora's 7.3.4 > kernel with the same change applied. On this model the firmware updates > the LED by itself when the camera key is pressed in s2idle, so it > doesn't show the problem Mia hit. After disable -> s2idle -> enable -> > resume the LED, asus::camera, brightness_hw_changed and the camera output > all agree, and resuming with the extra read caused no errors. Mia, could > you check v6 on the S 16? >=20 > I used Claude while working on this. It helped > me read through the DSDT, drafted the changes on top of v2 and wrote the > test scripts. I went through the patch myself and ran the tests on my > laptop. > --- > drivers/platform/asus/asus-wmi.c | 76 ++++++++++++++++++++++++= ++++-- > include/linux/platform_data/x86/asus-wmi.h | 2 +- > 2 files changed, 74 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/platform/asus/asus-wmi.c b/drivers/platform/asus/asu= s-wmi.c > index d42efc6521a..317fc2b5004 100644 > --- a/drivers/platform/asus/asus-wmi.c > +++ b/drivers/platform/asus/asus-wmi.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -72,6 +73,8 @@ module_param(fnlock_default, bool, 0444); > #define NOTIFY_KBD_TTP=09=09=090xae > #define NOTIFY_LID_FLIP=09=09=090xfa > #define NOTIFY_LID_FLIP_ROG=09=090xbd > +#define NOTIFY_CAMERA_TOGGLE_1=09=090x82 > +#define NOTIFY_CAMERA_TOGGLE_2=09=090x85 > #define NOTIFY_KEYSTONE=09=09=090xb4 > =20 > #define ASUS_WMI_FNLOCK_BIOS_DISABLED=09BIT(0) > @@ -313,6 +316,7 @@ struct asus_wmi { > =09u32 kbd_rgb_dev; > =09bool kbd_rgb_state_available; > =09bool oobe_state_available; > +=09bool camera_neg_led_available; > =20 > =09u8 throttle_thermal_policy_mode; > =09u32 throttle_thermal_policy_dev; > @@ -2124,6 +2128,56 @@ static int user_status_led_set(struct led_classdev= *led_cdev, > =09return err < 0 ? err : 0; > } > =20 > +static bool is_camera_toggle(int code) > +{ > +=09return code =3D=3D NOTIFY_CAMERA_TOGGLE_1 || code =3D=3D NOTIFY_CAMER= A_TOGGLE_2; > +} > + > +/* > + * Some models (e.g. Zenbook S 14 UX5406SA, Zenbook S 16 UM5606WA) have = no > + * ASUS_WMI_DEVID_CAMERA_LED. The firmware handles the camera key itself= and > + * only exposes the state through ASUS_WMI_DEVID_CAMERA_LED_NEG, and rea= ding > + * that has a side effect: the firmware copies the state to the LED GPIO= . > + * Nothing else updates the LED, so read it after every camera key event= , > + * and on resume, since the key can be pressed while suspended without s= ending > + * an event. Registering asus::camera reads it too (via brightness_get),= which > + * sets the LED at probe. Setting it is no use, the firmware accepts DEV= S on this > + * device only once per boot. > + * > + * Returns: 1 if the camera is disabled (LED lit), 0 if enabled, or -err= no. > + */ > +static int camera_neg_led_sync(struct asus_wmi *asus) > +{ > +=09u32 result; > +=09int err; > + > +=09err =3D asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CAMERA_LED_NEG, &r= esult); > +=09if (err) > +=09=09return err; > + > +=09return !(result & ASUS_WMI_DSTS_STATUS_BIT); > +} > + > +static enum led_brightness camera_neg_led_get(struct led_classdev *led_c= dev) > +{ > +=09struct asus_wmi *asus =3D container_of(led_cdev, struct asus_wmi, cam= era_led); > +=09int state =3D camera_neg_led_sync(asus); > + > +=09return state < 0 ? LED_OFF : state; > +} > + > +static void camera_neg_led_update(struct asus_wmi *asus) > +{ > +=09int state; > + > +=09if (!asus->camera_neg_led_available) > +=09=09return; > + > +=09state =3D camera_neg_led_sync(asus); > +=09if (state >=3D 0) > +=09=09led_classdev_notify_brightness_hw_changed(&asus->camera_led, state= ); Whenever the device is restored or resumed, a brightness_hw_changed event is always emitted even if nothing is changed. Is this behavior intentional? It'd be better to cache the last brightness and only emit an event when the brightness is really updated. In this manner, camera_neg_led_get() can also return the last brightness instead of 0 when camera_neg_led_sync() fails. Hint: caching the last brightness needs serialization. Thanks, Rong > +} > + > static void asus_wmi_led_exit(struct asus_wmi *asus) > { > =09scoped_guard(spinlock_irqsave, &asus_ref.lock) > @@ -2257,11 +2311,17 @@ static int asus_wmi_led_init(struct asus_wmi *asu= s) > =09=09=09goto error; > =09} > =20 > -=09if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED)) { > +=09if (asus->camera_neg_led_available || > +=09 asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED)) { > =09=09asus->camera_led.name =3D "asus::camera"; > =09=09asus->camera_led.max_brightness =3D 1; > -=09=09asus->camera_led.brightness_get =3D camera_led_get; > -=09=09asus->camera_led.brightness_set_blocking =3D camera_led_set; > +=09=09if (asus->camera_neg_led_available) { > +=09=09=09asus->camera_led.flags =3D LED_BRIGHT_HW_CHANGED; > +=09=09=09asus->camera_led.brightness_get =3D camera_neg_led_get; > +=09=09} else { > +=09=09=09asus->camera_led.brightness_get =3D camera_led_get; > +=09=09=09asus->camera_led.brightness_set_blocking =3D camera_led_set; > +=09=09} > =20 > =09=09rv =3D led_classdev_register(&asus->platform_device->dev, > =09=09=09=09=09=09&asus->camera_led); > @@ -4780,6 +4840,9 @@ static void asus_wmi_handle_event_code(int code, st= ruct asus_wmi *asus) > =09if (is_display_toggle(code) && asus->driver->quirks->no_display_toggl= e) > =09=09return; > =20 > +=09if (is_camera_toggle(code)) > +=09=09camera_neg_led_update(asus); > + > =09if (!sparse_keymap_report_event(asus->inputdev, code, > =09=09=09=09=09key_value, autorelease)) > =09=09pr_info("Unknown key code 0x%x\n", code); > @@ -5257,6 +5320,9 @@ static int asus_wmi_add(struct platform_device *pde= v) > #endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ > =20 > =09asus->oobe_state_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI= _DEVID_OOBE); > +=09asus->camera_neg_led_available =3D > +=09=09!asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED) && > +=09=09asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED_NEG); > =20 > =09if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_THROTTLE_THERMAL_POL= ICY)) > =09=09asus->throttle_thermal_policy_dev =3D ASUS_WMI_DEVID_THROTTLE_THER= MAL_POLICY; > @@ -5432,6 +5498,8 @@ static int asus_hotk_resume(struct device *device) > =09if (asus_wmi_has_fnlock_key(asus)) > =09=09asus_wmi_fnlock_update(asus); > =20 > +=09camera_neg_led_update(asus); > + > =09asus_wmi_tablet_mode_get_state(asus); > =20 > =09return 0; > @@ -5480,6 +5548,8 @@ static int asus_hotk_restore(struct device *device) > =09if (asus_wmi_has_fnlock_key(asus)) > =09=09asus_wmi_fnlock_update(asus); > =20 > +=09camera_neg_led_update(asus); > + > =09asus_wmi_tablet_mode_get_state(asus); > =09return 0; > } > diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/p= latform_data/x86/asus-wmi.h > index c4eec69db78..71f9583a7c3 100644 > --- a/include/linux/platform_data/x86/asus-wmi.h > +++ b/include/linux/platform_data/x86/asus-wmi.h > @@ -58,7 +58,7 @@ > #define ASUS_WMI_DEVID_MUTE_LED=090x0004001C > =20 > /* Disable Camera LED */ > -#define ASUS_WMI_DEVID_CAMERA_LED_NEG=090x00060078 /* 0 =3D on (unused) = */ > +#define ASUS_WMI_DEVID_CAMERA_LED_NEG=090x00060078 /* 0 =3D on */ > #define ASUS_WMI_DEVID_CAMERA_LED=090x00060079 /* 1 =3D on */ > =20 > /* Backlight and Brightness */ >=20 > --- > base-commit: 6fc627bda235ac5b6f43b5f784b81d6c2450ae5a > change-id: 20261017-asus-wmi-camera-led-06a6e05f01e2 >=20 > Best regards, > -- =20 > Zane Hunt >=20