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=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796362978; b=E8AGmTz1qP/hfwfZea0GZRfh7/wvvdR/ZkUJ/jVChIGjqF/WBhBzfug+aNaO/HwUzABY +wIsXu9A8lFDTgrkJgkY/lVmSotZsvr2jheU3jsU2KJh/zYrTskJSc2pmTt+dWA4JSIK2 9fdKgChYyGck1cCiFYCelZX7Etwb5QVKuBPWB6v7/IA+cmlyDULFpjP10+1p4qeiK98mB PXEYP+kIC5UWR8XkwKMjKmjE7gT/DX+JqRz6K1rgMXvGhAjj3IiOAQmMDwsnmEOKG6aWB BBoLPpE8dO7Q0E2NwKgYfSPfd4ubue/3u/YUHiAeDn6uO+4jI44IkGGzvfZU7wKlNWA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796362978; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=j0RexE7KgK4S8wQESD7g3Op6A4VfExz3/gc/wHK1Zow=; b=jfDw7ApxcauAp15M56IS0TnHkQ/MgkShRHlyRY3A7ceAiprQf6qMNmiZwEeAxYeUr/L3 4Dv+5Px5b85Cvg77A2NsK9vXCZIUxVcrIPEVQClMj45Ys3g8f/j6//HpGupH4r1Hdz5/I zHnIfANRJphSnWmAZTmlyNjBts0H++nTtagCEwLo2o2D/RU9Hg6ydNn/gnez41S3Q9b4J qNA52X/lEhzqaGYImVbk8k2dzt7hCNy02N0FO9rz04bOjj+FPFJxKRhcn0lws7/vAIq78 M75RXf8e4h8K+RQvLpAFM4IL+GSYJvsDamOmO2pwysuKzU4YhBegnrdXisbfrxFspng== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="h7n+/64O"; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6084B606A33A; Fri, 4 Dec 2026 05:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h7n+/64O Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796362977; b=g/zuDOUAg8C3yZvmHwJVE86lfX8OVDDGMg9HNREp4W/mtN1xldGDNbnUj0XITpPcr8l9 TMNGls7busP+tKkSBwbOe2EL4vAGTA7GSiYg4qipZ60TPhv/nS0QvCEUDhUrX2AYeYNK/ 1LejLNHgPLOU3hB3/wU998TM0HHlHnqX7KvOq2uX/mzotVnoJMV1Jyl8avgTkxE6RwU8r Ol0ih05w7MV7zH7MKCrfjVJhViWSDaSWkxOrPxJUOu5FZmIzjFhtTArQImjS6J7pPGoHK LWNscGr3x6RMG4SGYp4qM6lG0nHFapcJ0PauOH/+qEWqZO0OSOaBSy3UwliCpI10Yxg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796362977; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=j0RexE7KgK4S8wQESD7g3Op6A4VfExz3/gc/wHK1Zow=; b=DHMXWOzy+eqkzF19/Zna7LYLr3Q9vVWyVXU2JZLwG9P1Vr3MH2TQVySCb/nX17gw1mGD N7kWF+0s2FrIg+zei9uUd3s5CHx3yDhA5x9GYlpdzV+iuYeZbdDVEwuHb2epcHdXGTntE Sw3jpBFg2TZ0sZYVEwmD5ngZAwBscgQHjLlff5HVjRx80L23UkyP8jMMoAIkU1caoh0UY TaKg71HdA1y72Hf7zSnKZI/54dUR4AgQbhuhtgDM+8Hq66uzuxaHLOqHFXlEnAoG62uvz 0a5BITq3xsANCDIlG0/dtOX0YMElOGjbh87ci/l9IHM7SyQd2+AGCMsT+7PMF/KOhBQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (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.kernel.org (Postfix) with ESMTPS id AD7421F00931; Fri, 4 Dec 2026 05:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796362977; bh=j0RexE7KgK4S8wQESD7g3Op6A4VfExz3/gc/wHK1Zow=; h=From:Date:Subject:To:Cc:Reply-To; b=h7n+/64O2K8QqO3ZmlyFT9sDZtjbAgrIDNWrPvq/+A3z4yVv+pAGdgua/05U069RS R3HceJTf9VUUjZ499Rgb2SxkhEcnG/Goo5WDrzlqqtj8SpwYc//esKyvG13MsmA6X7 O9GG2jGcnuWT6uaMvKKhvaGkZQVk5j9whjk4sKijiy5JJXvYF+aIaN/kkzY6B39P4q yoNCEJUk3WKuVlKmgKFNEDIRueNA8j7pnkDC18XQNuUxOax+HfR5ALLLrbuRezLs+U ao+I2TbzLxlSm28W8Q7PkJeHgBL7g/5lju/aDWjL/qCKFtXbL3J36LWHudKxsCSHoL i5JKZEOt57w6g== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 0D82E4D924; Fri, 4 Dec 2026 05:42:56 +0000 (UTC) From: Zane Hunt via B4 Relay Date: Fri, 04 Dec 2026 18:42:26 +1300 Subject: [PATCH v6] platform/x86: asus-wmi: Add support for ASUS_WMI_DEVID_CAMERA_LED_NEG 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 Content-Type: text/plain; charset="utf-8" Message-Id: <20261204-asus-wmi-camera-led-v6-1-ba06c19c81bc@turtledev.nz> X-B4-Tracking: v=1; b=H4sIAAAAAAAA/33OTU7DMBCG4atYs+4gj3+TrLgHYuE4U2rUpshOD G2Vu6O0iyJUWI706XnnAoVz4gKduEDmmko6jtAJtxEQd2F8Y0wDdAKUVI4keQxlLvh5SBjDgXP APQ8oXXAs7VYSK9gI+Mi8TV9X9eX1dpe5f+c4rdS62KUyHfPpmq163f1fqBoJG2NDo7TXbeufp zlPex64Po1nWCPV/GTax4xBQu+NiaRsH2P7gLF3hv76xiKhoWi8s9rbpv/FLMvyDZ1OLX9ZAQA A X-Change-ID: 20261017-asus-wmi-camera-led-06a6e05f01e2 To: Corentin Chary , "Luke D. Jones" , Denis Benato , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , platform-driver-x86@vger.kernel.org Cc: =?utf-8?q?Jos=C3=A9_Guilherme_de_Castro_Rodrigues?= , Rong Zhang , Devin Bayer , Mia Herkt , linux-kernel@vger.kernel.org, Zane Hunt X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796362974; l=11140; i=git@turtledev.nz; s=20261016; h=from:subject:message-id; bh=YoHmkGBSdKHjMghYHp3JFYBfOAo8diFs3Po+l8NTF/E=; b=IFELWlgLDrHS8i+qNpUim9NdMtCiG0xGwTgCg05N/cJGhDUdfCzhqY+D29Z49nQhDUuUoN/Ki j3F9oEhFReEAKr5MVHUQ6+2uuVRPZBOjbi77ly051+OllfvXNLvZ8sA X-Developer-Key: i=git@turtledev.nz; a=ed25519; pk=7P3HBZD1ukp3nMYpf+9Dcl3ryKIU5pYgOUKe/HOox6c= X-Endpoint-Received: by B4 Relay for git@turtledev.nz/20261016 with auth_id=1217 X-Original-From: Zane Hunt Reply-To: git@turtledev.nz Content-Transfer-Encoding: 8bit From: Zane Hunt 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. 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. 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 after 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. While at it, include , which this file already relied on. Link: https://lore.kernel.org/r/adg6GzkykThAB_4u@djouze-zen Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221752 Assisted-by: Claude:claude-opus-5-5 iasl Co-developed-by: José Guilherme de Castro Rodrigues Signed-off-by: José 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 platform/x86: asus-wmi: Add support for ASUS_WMI_DEVID_CAMERA_LED_NEG 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é, 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 Changes in v4: - Keep José'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 Changes in v3 (picking up José'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 boot - 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 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? 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(-) diff --git a/drivers/platform/asus/asus-wmi.c b/drivers/platform/asus/asus-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 0xae #define NOTIFY_LID_FLIP 0xfa #define NOTIFY_LID_FLIP_ROG 0xbd +#define NOTIFY_CAMERA_TOGGLE_1 0x82 +#define NOTIFY_CAMERA_TOGGLE_2 0x85 #define NOTIFY_KEYSTONE 0xb4 #define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0) @@ -313,6 +316,7 @@ struct asus_wmi { u32 kbd_rgb_dev; bool kbd_rgb_state_available; bool oobe_state_available; + bool camera_neg_led_available; u8 throttle_thermal_policy_mode; u32 throttle_thermal_policy_dev; @@ -2124,6 +2128,56 @@ static int user_status_led_set(struct led_classdev *led_cdev, return err < 0 ? err : 0; } +static bool is_camera_toggle(int code) +{ + return code == NOTIFY_CAMERA_TOGGLE_1 || code == NOTIFY_CAMERA_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 reading + * 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 sending + * 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 DEVS on this + * device only once per boot. + * + * Returns: 1 if the camera is disabled (LED lit), 0 if enabled, or -errno. + */ +static int camera_neg_led_sync(struct asus_wmi *asus) +{ + u32 result; + int err; + + err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CAMERA_LED_NEG, &result); + if (err) + return err; + + return !(result & ASUS_WMI_DSTS_STATUS_BIT); +} + +static enum led_brightness camera_neg_led_get(struct led_classdev *led_cdev) +{ + struct asus_wmi *asus = container_of(led_cdev, struct asus_wmi, camera_led); + int state = camera_neg_led_sync(asus); + + return state < 0 ? LED_OFF : state; +} + +static void camera_neg_led_update(struct asus_wmi *asus) +{ + int state; + + if (!asus->camera_neg_led_available) + return; + + state = camera_neg_led_sync(asus); + if (state >= 0) + led_classdev_notify_brightness_hw_changed(&asus->camera_led, state); +} + static void asus_wmi_led_exit(struct asus_wmi *asus) { scoped_guard(spinlock_irqsave, &asus_ref.lock) @@ -2257,11 +2311,17 @@ static int asus_wmi_led_init(struct asus_wmi *asus) goto error; } - if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED)) { + if (asus->camera_neg_led_available || + asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED)) { asus->camera_led.name = "asus::camera"; asus->camera_led.max_brightness = 1; - asus->camera_led.brightness_get = camera_led_get; - asus->camera_led.brightness_set_blocking = camera_led_set; + if (asus->camera_neg_led_available) { + asus->camera_led.flags = LED_BRIGHT_HW_CHANGED; + asus->camera_led.brightness_get = camera_neg_led_get; + } else { + asus->camera_led.brightness_get = camera_led_get; + asus->camera_led.brightness_set_blocking = camera_led_set; + } rv = led_classdev_register(&asus->platform_device->dev, &asus->camera_led); @@ -4780,6 +4840,9 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) return; + if (is_camera_toggle(code)) + camera_neg_led_update(asus); + if (!sparse_keymap_report_event(asus->inputdev, code, key_value, autorelease)) pr_info("Unknown key code 0x%x\n", code); @@ -5257,6 +5320,9 @@ static int asus_wmi_add(struct platform_device *pdev) #endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ asus->oobe_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_OOBE); + asus->camera_neg_led_available = + !asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED) && + asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED_NEG); if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY)) asus->throttle_thermal_policy_dev = ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY; @@ -5432,6 +5498,8 @@ static int asus_hotk_resume(struct device *device) if (asus_wmi_has_fnlock_key(asus)) asus_wmi_fnlock_update(asus); + camera_neg_led_update(asus); + asus_wmi_tablet_mode_get_state(asus); return 0; @@ -5480,6 +5548,8 @@ static int asus_hotk_restore(struct device *device) if (asus_wmi_has_fnlock_key(asus)) asus_wmi_fnlock_update(asus); + camera_neg_led_update(asus); + asus_wmi_tablet_mode_get_state(asus); return 0; } diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_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 0x0004001C /* Disable Camera LED */ -#define ASUS_WMI_DEVID_CAMERA_LED_NEG 0x00060078 /* 0 = on (unused) */ +#define ASUS_WMI_DEVID_CAMERA_LED_NEG 0x00060078 /* 0 = on */ #define ASUS_WMI_DEVID_CAMERA_LED 0x00060079 /* 1 = on */ /* Backlight and Brightness */ --- base-commit: 6fc627bda235ac5b6f43b5f784b81d6c2450ae5a change-id: 20261017-asus-wmi-camera-led-06a6e05f01e2 Best regards, -- Zane Hunt