Skip to content

Commit 4bf1ea3

Browse files
akvadrakoij-intel
authored andcommitted
platform/x86: asus-wmi: support the disable camera LED on F10 of Zenbook 2023
Adds a sysfs entry for the LED on F10 above the crossed out camera icon on 2023 Zenbooks. Signed-off-by: Devin Bayer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent cf25477 commit 4bf1ea3

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

drivers/platform/x86/asus-wmi.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ struct asus_wmi {
238238
struct led_classdev lightbar_led;
239239
int lightbar_led_wk;
240240
struct led_classdev micmute_led;
241+
struct led_classdev camera_led;
241242
struct workqueue_struct *led_workqueue;
242243
struct work_struct tpd_led_work;
243244
struct work_struct wlan_led_work;
@@ -1642,13 +1643,35 @@ static int micmute_led_set(struct led_classdev *led_cdev,
16421643
return err < 0 ? err : 0;
16431644
}
16441645

1646+
static enum led_brightness camera_led_get(struct led_classdev *led_cdev)
1647+
{
1648+
struct asus_wmi *asus;
1649+
u32 result;
1650+
1651+
asus = container_of(led_cdev, struct asus_wmi, camera_led);
1652+
asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_CAMERA_LED, &result);
1653+
1654+
return result & ASUS_WMI_DSTS_BRIGHTNESS_MASK;
1655+
}
1656+
1657+
static int camera_led_set(struct led_classdev *led_cdev,
1658+
enum led_brightness brightness)
1659+
{
1660+
int state = brightness != LED_OFF;
1661+
int err;
1662+
1663+
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_CAMERA_LED, state, NULL);
1664+
return err < 0 ? err : 0;
1665+
}
1666+
16451667
static void asus_wmi_led_exit(struct asus_wmi *asus)
16461668
{
16471669
led_classdev_unregister(&asus->kbd_led);
16481670
led_classdev_unregister(&asus->tpd_led);
16491671
led_classdev_unregister(&asus->wlan_led);
16501672
led_classdev_unregister(&asus->lightbar_led);
16511673
led_classdev_unregister(&asus->micmute_led);
1674+
led_classdev_unregister(&asus->camera_led);
16521675

16531676
if (asus->led_workqueue)
16541677
destroy_workqueue(asus->led_workqueue);
@@ -1740,6 +1763,18 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
17401763
goto error;
17411764
}
17421765

1766+
if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CAMERA_LED)) {
1767+
asus->camera_led.name = "asus::camera";
1768+
asus->camera_led.max_brightness = 1;
1769+
asus->camera_led.brightness_get = camera_led_get;
1770+
asus->camera_led.brightness_set_blocking = camera_led_set;
1771+
1772+
rv = led_classdev_register(&asus->platform_device->dev,
1773+
&asus->camera_led);
1774+
if (rv)
1775+
goto error;
1776+
}
1777+
17431778
error:
17441779
if (rv)
17451780
asus_wmi_led_exit(asus);

include/linux/platform_data/x86/asus-wmi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
#define ASUS_WMI_DEVID_LED6 0x00020016
5252
#define ASUS_WMI_DEVID_MICMUTE_LED 0x00040017
5353

54+
/* Disable Camera LED */
55+
#define ASUS_WMI_DEVID_CAMERA_LED_NEG 0x00060078 /* 0 = on (unused) */
56+
#define ASUS_WMI_DEVID_CAMERA_LED 0x00060079 /* 1 = on */
57+
5458
/* Backlight and Brightness */
5559
#define ASUS_WMI_DEVID_ALS_ENABLE 0x00050001 /* Ambient Light Sensor */
5660
#define ASUS_WMI_DEVID_BACKLIGHT 0x00050011

0 commit comments

Comments
 (0)