2024-04-02 06:02:31

by Luke D. Jones

[permalink] [raw]
Subject: [PATCH v2 1/9] platform/x86: asus-wmi: add support for 2024 ROG Mini-LED

Support the 2024 mini-led backlight and adjust the related functions
to select the relevant dev-id. Also add `available_mini_led_mode` to the
platform sysfs since the available mini-led levels can be different.

Signed-off-by: Luke D. Jones <[email protected]>
---
.../ABI/testing/sysfs-platform-asus-wmi | 8 ++
drivers/platform/x86/asus-wmi.c | 80 ++++++++++++++++---
include/linux/platform_data/x86/asus-wmi.h | 1 +
3 files changed, 78 insertions(+), 11 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
index 8a7e25bde085..ef1ac1a20a71 100644
--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
+++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
@@ -126,6 +126,14 @@ Description:
Change the mini-LED mode:
* 0 - Single-zone,
* 1 - Multi-zone
+ * 2 - Multi-zone strong (available on newer generation mini-led)
+
+What: /sys/devices/platform/<platform>/available_mini_led_mode
+Date: Apr 2024
+KernelVersion: 6.10
+Contact: "Luke Jones" <[email protected]>
+Description:
+ List the available mini-led modes.

What: /sys/devices/platform/<platform>/ppt_pl1_spl
Date: Jun 2023
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f07bbf809ef..2330f02ff76f 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -288,7 +288,7 @@ struct asus_wmi {
bool battery_rsoc_available;

bool panel_overdrive_available;
- bool mini_led_mode_available;
+ u32 mini_led_dev_id;

struct hotplug_slot hotplug_slot;
struct mutex hotplug_lock;
@@ -2108,13 +2108,30 @@ static ssize_t mini_led_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct asus_wmi *asus = dev_get_drvdata(dev);
- int result;
+ u32 value;

- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
- if (result < 0)
- return result;
+ asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value);
+ value = value & 0x03; // only 3 modes on 2024 version

- return sysfs_emit(buf, "%d\n", result);
+ /* Remap the mode values to match previous generation mini-led.
+ * Some BIOSes return -19 instead of 2, which is "mini-LED off", this
+ * appears to be a BIOS bug.
+ */
+ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
+ switch (value) {
+ case 0:
+ value = 1;
+ break;
+ case 1:
+ value = 2;
+ break;
+ case 2:
+ value = 0;
+ }
+ } else if (value < 0) {
+ return value;
+ }
+ return sysfs_emit(buf, "%d\n", value);
}

static ssize_t mini_led_mode_store(struct device *dev,
@@ -2130,11 +2147,28 @@ static ssize_t mini_led_mode_store(struct device *dev,
if (result)
return result;

- if (mode > 1)
+ if (mode > 1 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE)
return -EINVAL;
+ if (mode > 2 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2)
+ return -EINVAL;
+ /*
+ * Remap the mode values so expected behaviour is the same as the last
+ * generation of mini-LED
+ */
+ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
+ switch (mode) {
+ case 0:
+ mode = 2;
+ break;
+ case 1:
+ mode = 0;
+ break;
+ case 2:
+ mode = 1;
+ }
+ }

- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result);
-
+ err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result);
if (err) {
pr_warn("Failed to set mini-LED: %d\n", err);
return err;
@@ -2151,6 +2185,23 @@ static ssize_t mini_led_mode_store(struct device *dev,
}
static DEVICE_ATTR_RW(mini_led_mode);

+static ssize_t available_mini_led_mode_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ switch (asus->mini_led_dev_id) {
+ case ASUS_WMI_DEVID_MINI_LED_MODE:
+ return sysfs_emit(buf, "0 1\n");
+ case ASUS_WMI_DEVID_MINI_LED_MODE2:
+ return sysfs_emit(buf, "0 1 2\n");
+ }
+
+ return sysfs_emit(buf, "0\n");
+}
+
+static DEVICE_ATTR_RO(available_mini_led_mode);
+
/* Quirks *********************************************************************/

static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
@@ -4139,6 +4190,7 @@ static struct attribute *platform_attributes[] = {
&dev_attr_nv_temp_target.attr,
&dev_attr_panel_od.attr,
&dev_attr_mini_led_mode.attr,
+ &dev_attr_available_mini_led_mode.attr,
NULL
};

@@ -4191,7 +4243,9 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_panel_od.attr)
ok = asus->panel_overdrive_available;
else if (attr == &dev_attr_mini_led_mode.attr)
- ok = asus->mini_led_mode_available;
+ ok = asus->mini_led_dev_id != 0;
+ else if (attr == &dev_attr_available_mini_led_mode.attr)
+ ok = asus->mini_led_dev_id != 0;

if (devid != -1)
ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
@@ -4444,10 +4498,14 @@ static int asus_wmi_add(struct platform_device *pdev)
asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST);
asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);
asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);
- asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
&& dmi_match(DMI_BOARD_NAME, "RC71L");

+ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE))
+ asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE;
+ else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2))
+ asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2;
+
err = fan_boost_mode_check_present(asus);
if (err)
goto fail_fan_boost_mode;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index ab1c7deff118..9cadce10ad9a 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -71,6 +71,7 @@
#define ASUS_WMI_DEVID_LID_FLIP 0x00060062
#define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077
#define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E
+#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E

/* Storage */
#define ASUS_WMI_DEVID_CARDREADER 0x00080013
--
2.44.0



2024-04-02 10:43:48

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v2 1/9] platform/x86: asus-wmi: add support for 2024 ROG Mini-LED

On Tue, 2 Apr 2024, Luke D. Jones wrote:

> Support the 2024 mini-led backlight and adjust the related functions
> to select the relevant dev-id. Also add `available_mini_led_mode` to the
> platform sysfs since the available mini-led levels can be different.
>
> Signed-off-by: Luke D. Jones <[email protected]>
> ---
> .../ABI/testing/sysfs-platform-asus-wmi | 8 ++
> drivers/platform/x86/asus-wmi.c | 80 ++++++++++++++++---
> include/linux/platform_data/x86/asus-wmi.h | 1 +
> 3 files changed, 78 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> index 8a7e25bde085..ef1ac1a20a71 100644
> --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> @@ -126,6 +126,14 @@ Description:
> Change the mini-LED mode:
> * 0 - Single-zone,
> * 1 - Multi-zone
> + * 2 - Multi-zone strong (available on newer generation mini-led)
> +
> +What: /sys/devices/platform/<platform>/available_mini_led_mode
> +Date: Apr 2024
> +KernelVersion: 6.10
> +Contact: "Luke Jones" <[email protected]>
> +Description:
> + List the available mini-led modes.
>
> What: /sys/devices/platform/<platform>/ppt_pl1_spl
> Date: Jun 2023
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 3f07bbf809ef..2330f02ff76f 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -288,7 +288,7 @@ struct asus_wmi {
> bool battery_rsoc_available;
>
> bool panel_overdrive_available;
> - bool mini_led_mode_available;
> + u32 mini_led_dev_id;
>
> struct hotplug_slot hotplug_slot;
> struct mutex hotplug_lock;
> @@ -2108,13 +2108,30 @@ static ssize_t mini_led_mode_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> struct asus_wmi *asus = dev_get_drvdata(dev);
> - int result;
> + u32 value;
>
> - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
> - if (result < 0)
> - return result;
> + asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value);

Error handling missing.

> + value = value & 0x03; // only 3 modes on 2024 version

Add #define XX GENMASK(1, 0) for this.

>
> - return sysfs_emit(buf, "%d\n", result);
> + /* Remap the mode values to match previous generation mini-led.
> + * Some BIOSes return -19 instead of 2, which is "mini-LED off", this
> + * appears to be a BIOS bug.

Is this comment still 100% valid now or should it be removed completely?
There's no handling for -19 in ASUS_WMI_DEVID_MINI_LED_MODE2 block?

There's also a double space in the comment.

> + */
> + if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
> + switch (value) {
> + case 0:
> + value = 1;
> + break;
> + case 1:
> + value = 2;
> + break;
> + case 2:
> + value = 0;

Add break here too.

These literals 0-2 should be named with #defines as it would make the code
readable, current way of the mapping between literal numbers
unintelligible magic.

> + }
> + } else if (value < 0) {

This will never be true because value is u32 and also because of & 0x03
even if you'd change the type.

I don't quite follow what you're trying to do here. Why this only applies
to cases != ASUS_WMI_DEVID_MINI_LED_MODE2?

> + return value;
> + }
> + return sysfs_emit(buf, "%d\n", value);
> }
>
> static ssize_t mini_led_mode_store(struct device *dev,
> @@ -2130,11 +2147,28 @@ static ssize_t mini_led_mode_store(struct device *dev,
> if (result)
> return result;
>
> - if (mode > 1)
> + if (mode > 1 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE)
> return -EINVAL;
> + if (mode > 2 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2)
> + return -EINVAL;
> + /*
> + * Remap the mode values so expected behaviour is the same as the last
> + * generation of mini-LED

Missing .

--
i.

> + */
> + if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
> + switch (mode) {
> + case 0:
> + mode = 2;
> + break;
> + case 1:
> + mode = 0;
> + break;
> + case 2:
> + mode = 1;
> + }
> + }
>
> - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result);
> -
> + err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result);
> if (err) {
> pr_warn("Failed to set mini-LED: %d\n", err);
> return err;
> @@ -2151,6 +2185,23 @@ static ssize_t mini_led_mode_store(struct device *dev,
> }
> static DEVICE_ATTR_RW(mini_led_mode);
>
> +static ssize_t available_mini_led_mode_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct asus_wmi *asus = dev_get_drvdata(dev);
> +
> + switch (asus->mini_led_dev_id) {
> + case ASUS_WMI_DEVID_MINI_LED_MODE:
> + return sysfs_emit(buf, "0 1\n");
> + case ASUS_WMI_DEVID_MINI_LED_MODE2:
> + return sysfs_emit(buf, "0 1 2\n");
> + }
> +
> + return sysfs_emit(buf, "0\n");
> +}
> +
> +static DEVICE_ATTR_RO(available_mini_led_mode);
> +
> /* Quirks *********************************************************************/
>
> static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
> @@ -4139,6 +4190,7 @@ static struct attribute *platform_attributes[] = {
> &dev_attr_nv_temp_target.attr,
> &dev_attr_panel_od.attr,
> &dev_attr_mini_led_mode.attr,
> + &dev_attr_available_mini_led_mode.attr,
> NULL
> };
>
> @@ -4191,7 +4243,9 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
> else if (attr == &dev_attr_panel_od.attr)
> ok = asus->panel_overdrive_available;
> else if (attr == &dev_attr_mini_led_mode.attr)
> - ok = asus->mini_led_mode_available;
> + ok = asus->mini_led_dev_id != 0;
> + else if (attr == &dev_attr_available_mini_led_mode.attr)
> + ok = asus->mini_led_dev_id != 0;
>
> if (devid != -1)
> ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
> @@ -4444,10 +4498,14 @@ static int asus_wmi_add(struct platform_device *pdev)
> asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST);
> asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);
> asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);
> - asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
> asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
> && dmi_match(DMI_BOARD_NAME, "RC71L");
>
> + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE))
> + asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE;
> + else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2))
> + asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2;
> +
> err = fan_boost_mode_check_present(asus);
> if (err)
> goto fail_fan_boost_mode;
> diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
> index ab1c7deff118..9cadce10ad9a 100644
> --- a/include/linux/platform_data/x86/asus-wmi.h
> +++ b/include/linux/platform_data/x86/asus-wmi.h
> @@ -71,6 +71,7 @@
> #define ASUS_WMI_DEVID_LID_FLIP 0x00060062
> #define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077
> #define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E
> +#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E
>
> /* Storage */
> #define ASUS_WMI_DEVID_CARDREADER 0x00080013
>

2024-04-03 01:55:22

by Luke D. Jones

[permalink] [raw]
Subject: Re: [PATCH v2 1/9] platform/x86: asus-wmi: add support for 2024 ROG Mini-LED

On Tuesday, 2 April 2024 11:43:25 PM NZDT Ilpo Järvinen wrote:
> On Tue, 2 Apr 2024, Luke D. Jones wrote:
> > Support the 2024 mini-led backlight and adjust the related functions
> > to select the relevant dev-id. Also add `available_mini_led_mode` to the
> > platform sysfs since the available mini-led levels can be different.
> >
> > Signed-off-by: Luke D. Jones <[email protected]>
> > ---
> >
> > .../ABI/testing/sysfs-platform-asus-wmi | 8 ++
> > drivers/platform/x86/asus-wmi.c | 80 ++++++++++++++++---
> > include/linux/platform_data/x86/asus-wmi.h | 1 +
> > 3 files changed, 78 insertions(+), 11 deletions(-)
> >
> > diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > b/Documentation/ABI/testing/sysfs-platform-asus-wmi index
> > 8a7e25bde085..ef1ac1a20a71 100644
> > --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> >
> > @@ -126,6 +126,14 @@ Description:
> > Change the mini-LED mode:
> > * 0 - Single-zone,
> > * 1 - Multi-zone
> >
> > + * 2 - Multi-zone strong (available on newer
generation mini-led)
> > +
> > +What: /sys/devices/platform/<platform>/available_mini_led_mode
> > +Date: Apr 2024
> > +KernelVersion: 6.10
> > +Contact: "Luke Jones" <[email protected]>
> > +Description:
> > + List the available mini-led modes.
> >
> > What: /sys/devices/platform/<platform>/ppt_pl1_spl
> > Date: Jun 2023
> >
> > diff --git a/drivers/platform/x86/asus-wmi.c
> > b/drivers/platform/x86/asus-wmi.c index 3f07bbf809ef..2330f02ff76f 100644
> > --- a/drivers/platform/x86/asus-wmi.c
> > +++ b/drivers/platform/x86/asus-wmi.c
> > @@ -288,7 +288,7 @@ struct asus_wmi {
> >
> > bool battery_rsoc_available;
> >
> > bool panel_overdrive_available;
> >
> > - bool mini_led_mode_available;
> > + u32 mini_led_dev_id;
> >
> > struct hotplug_slot hotplug_slot;
> > struct mutex hotplug_lock;
> >
> > @@ -2108,13 +2108,30 @@ static ssize_t mini_led_mode_show(struct device
> > *dev,>
> > struct device_attribute *attr,
char *buf)
> >
> > {
> >
> > struct asus_wmi *asus = dev_get_drvdata(dev);
> >
> > - int result;
> > + u32 value;
> >
> > - result = asus_wmi_get_devstate_simple(asus,
> > ASUS_WMI_DEVID_MINI_LED_MODE); - if (result < 0)
> > - return result;
> > + asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value);
>
> Error handling missing.

I omitted it because other uses of this function also ignore it. Might need to
do another patch to add handling everywhere else.

For now I will add here, and later in the week fix the other cases.

>
> > + value = value & 0x03; // only 3 modes on 2024 version
>
> Add #define XX GENMASK(1, 0) for this.

Done. I should have done so before, I know.
There are also spots where a mask is explicitly 0xFFFF while there is a define
for that also. Maybe another patch to do here?

>
> > - return sysfs_emit(buf, "%d\n", result);
> > + /* Remap the mode values to match previous generation mini-led.
> > + * Some BIOSes return -19 instead of 2, which is "mini-LED off",
this
> > + * appears to be a BIOS bug.
>
> Is this comment still 100% valid now or should it be removed completely?
> There's no handling for -19 in ASUS_WMI_DEVID_MINI_LED_MODE2 block?
>
> There's also a double space in the comment.

Yay, adhd coding :)
Done.

>
> > + */
> > + if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
> > + switch (value) {
> > + case 0:
> > + value = 1;
> > + break;
> > + case 1:
> > + value = 2;
> > + break;
> > + case 2:
> > + value = 0;
>
> Add break here too.

Wasn't sure it needed it due to being last statement? In either case, done.

>
> These literals 0-2 should be named with #defines as it would make the code
> readable, current way of the mapping between literal numbers
> unintelligible magic.

Honestly with the block below it reversing them I thought it was easier. I'll
try and come up with some decent define names.

>
> > + }
> > + } else if (value < 0) {
>
> This will never be true because value is u32 and also because of & 0x03
> even if you'd change the type.
>
> I don't quite follow what you're trying to do here. Why this only applies
> to cases != ASUS_WMI_DEVID_MINI_LED_MODE2?

Ah.. yes I'll write that comment much better, and the defines hopefully help

>
> > + return value;
> > + }
> > + return sysfs_emit(buf, "%d\n", value);
> >
> > }
> >
> > static ssize_t mini_led_mode_store(struct device *dev,
> >
> > @@ -2130,11 +2147,28 @@ static ssize_t mini_led_mode_store(struct device
> > *dev,>
> > if (result)
> >
> > return result;
> >
> > - if (mode > 1)
> > + if (mode > 1 && asus->mini_led_dev_id ==
ASUS_WMI_DEVID_MINI_LED_MODE)
> >
> > return -EINVAL;
> >
> > + if (mode > 2 && asus->mini_led_dev_id ==
ASUS_WMI_DEVID_MINI_LED_MODE2)
> > + return -EINVAL;
> > + /*
> > + * Remap the mode values so expected behaviour is the same as the
last
> > + * generation of mini-LED
>
> Missing .

Done

I think everything is in good shape now. Thank you so much for your thorough
reviews.

>
> > + */
> > + if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
> > + switch (mode) {
> > + case 0:
> > + mode = 2;
> > + break;
> > + case 1:
> > + mode = 0;
> > + break;
> > + case 2:
> > + mode = 1;
> > + }
> > + }
> >
> > - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode,
> > &result);
> > -
> > + err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result);
> >
> > if (err) {
> >
> > pr_warn("Failed to set mini-LED: %d\n", err);
> > return err;
> >
> > @@ -2151,6 +2185,23 @@ static ssize_t mini_led_mode_store(struct device
> > *dev,>
> > }
> > static DEVICE_ATTR_RW(mini_led_mode);
> >
> > +static ssize_t available_mini_led_mode_show(struct device *dev,
> > + struct device_attribute *attr,
char *buf)
> > +{
> > + struct asus_wmi *asus = dev_get_drvdata(dev);
> > +
> > + switch (asus->mini_led_dev_id) {
> > + case ASUS_WMI_DEVID_MINI_LED_MODE:
> > + return sysfs_emit(buf, "0 1\n");
> > + case ASUS_WMI_DEVID_MINI_LED_MODE2:
> > + return sysfs_emit(buf, "0 1 2\n");
> > + }
> > +
> > + return sysfs_emit(buf, "0\n");
> > +}
> > +
> > +static DEVICE_ATTR_RO(available_mini_led_mode);
> > +
> >
> > /* Quirks
> > *********************************************************************/
> >
> > static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
> >
> > @@ -4139,6 +4190,7 @@ static struct attribute *platform_attributes[] = {
> >
> > &dev_attr_nv_temp_target.attr,
> > &dev_attr_panel_od.attr,
> > &dev_attr_mini_led_mode.attr,
> >
> > + &dev_attr_available_mini_led_mode.attr,
> >
> > NULL
> >
> > };
> >
> > @@ -4191,7 +4243,9 @@ static umode_t asus_sysfs_is_visible(struct kobject
> > *kobj,>
> > else if (attr == &dev_attr_panel_od.attr)
> >
> > ok = asus->panel_overdrive_available;
> >
> > else if (attr == &dev_attr_mini_led_mode.attr)
> >
> > - ok = asus->mini_led_mode_available;
> > + ok = asus->mini_led_dev_id != 0;
> > + else if (attr == &dev_attr_available_mini_led_mode.attr)
> > + ok = asus->mini_led_dev_id != 0;
> >
> > if (devid != -1)
> >
> > ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
> >
> > @@ -4444,10 +4498,14 @@ static int asus_wmi_add(struct platform_device
> > *pdev)>
> > asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus,
> > ASUS_WMI_DEVID_NV_DYN_BOOST); asus->nv_temp_tgt_available =
> > asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);
> > asus->panel_overdrive_available = asus_wmi_dev_is_present(asus,
> > ASUS_WMI_DEVID_PANEL_OD);>
> > - asus->mini_led_mode_available = asus_wmi_dev_is_present(asus,
> > ASUS_WMI_DEVID_MINI_LED_MODE);>
> > asus->ally_mcu_usb_switch = acpi_has_method(NULL,
> > ASUS_USB0_PWR_EC0_CSEE)
> >
> > &&
dmi_match(DMI_BOARD_NAME, "RC71L");
> >
> > + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE))
> > + asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE;
> > + else if (asus_wmi_dev_is_present(asus,
ASUS_WMI_DEVID_MINI_LED_MODE2))
> > + asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2;
> > +
> >
> > err = fan_boost_mode_check_present(asus);
> > if (err)
> >
> > goto fail_fan_boost_mode;
> >
> > diff --git a/include/linux/platform_data/x86/asus-wmi.h
> > b/include/linux/platform_data/x86/asus-wmi.h index
> > ab1c7deff118..9cadce10ad9a 100644
> > --- a/include/linux/platform_data/x86/asus-wmi.h
> > +++ b/include/linux/platform_data/x86/asus-wmi.h
> > @@ -71,6 +71,7 @@
> >
> > #define ASUS_WMI_DEVID_LID_FLIP 0x00060062
> > #define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077
> > #define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E
> >
> > +#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E
> >
> > /* Storage */
> > #define ASUS_WMI_DEVID_CARDREADER 0x00080013