History

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.

Luke D. Jones committed 2 years ago

Commit f81d13d1 parent a582a433 files · +95 −10Browse files

Unified · Split

3 files
  1. Documentation/ABI/testing/sysfs-platform-asus-wmi +8 −0
  2. drivers/platform/x86/asus-wmi.c +86 −10
  3. include/linux/platform_data/x86/asus-wmi.h +1 −0
Documentation/ABI/testing/sysfs-platform-asus-wmi+8−0
@@ -126,6 +126,14 @@ Description: · 125 unmodified lines
126126 Change the mini-LED mode:
127127 * 0 - Single-zone,
128128 * 1 - Multi-zone
129+ * 2 - Multi-zone strong (available on newer generation mini-led)
130+
131+What: /sys/devices/platform/<platform>/available_mini_led_mode
132+Date: Apr 2024
133+KernelVersion: 6.10
134+Contact: "Luke Jones" <luke@ljones.dev>
135+Description:
136+ List the available mini-led modes.
129137
130138 What: /sys/devices/platform/<platform>/ppt_pl1_spl
131139 Date: Jun 2023
drivers/platform/x86/asus-wmi.c+86−10
@@ -126,6 +126,17 @@ module_param(fnlock_default, bool, 0444); · 125 unmodified lines
126126 #define ASUS_SCREENPAD_BRIGHT_MAX 255
127127 #define ASUS_SCREENPAD_BRIGHT_DEFAULT 60
128128
129+#define ASUS_MINI_LED_MODE_MASK 0x03
130+/* Standard modes for devices with only on/off */
131+#define ASUS_MINI_LED_OFF 0x00
132+#define ASUS_MINI_LED_ON 0x01
133+/* New mode on some devices, define here to clarify remapping later */
134+#define ASUS_MINI_LED_STRONG_MODE 0x02
135+/* New modes for devices with 3 mini-led mode types */
136+#define ASUS_MINI_LED_2024_WEAK 0x00
137+#define ASUS_MINI_LED_2024_STRONG 0x01
138+#define ASUS_MINI_LED_2024_OFF 0x02
139+
129140 /* Controls the power state of the USB0 hub on ROG Ally which input is on */
130141 #define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE"
131142 /* 300ms so far seems to produce a reliable result on AC and battery */
@@ -288,7 +299,7 @@ struct asus_wmi { · 156 unmodified lines
288299 bool battery_rsoc_available;
289300
290301 bool panel_overdrive_available;
291− bool mini_led_mode_available;
302+ u32 mini_led_dev_id;
292303
293304 struct hotplug_slot hotplug_slot;
294305 struct mutex hotplug_lock;
@@ -2108,13 +2119,33 @@ static ssize_t mini_led_mode_show(struct device *dev, · 1813 unmodified lines
21082119 struct device_attribute *attr, char *buf)
21092120 {
21102121 struct asus_wmi *asus = dev_get_drvdata(dev);
2111− int result;
2122+ u32 value;
2123+ int err;
21122124
2113− result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
2114− if (result < 0)
2115− return result;
2125+ err = asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value);
2126+ if (err < 0)
2127+ return err;
2128+ value = value & ASUS_MINI_LED_MODE_MASK;
21162129
2117− return sysfs_emit(buf, "%d\n", result);
2130+ /*
2131+ * Remap the mode values to match previous generation mini-led. The last gen
2132+ * WMI 0 == off, while on this version WMI 2 ==off (flipped).
2133+ */
2134+ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
2135+ switch (value) {
2136+ case ASUS_MINI_LED_2024_WEAK:
2137+ value = ASUS_MINI_LED_ON;
2138+ break;
2139+ case ASUS_MINI_LED_2024_STRONG:
2140+ value = ASUS_MINI_LED_STRONG_MODE;
2141+ break;
2142+ case ASUS_MINI_LED_2024_OFF:
2143+ value = ASUS_MINI_LED_OFF;
2144+ break;
2145+ }
2146+ }
2147+
2148+ return sysfs_emit(buf, "%d\n", value);
21182149 }
21192150
21202151 static ssize_t mini_led_mode_store(struct device *dev,
@@ -2130,11 +2161,32 @@ static ssize_t mini_led_mode_store(struct device *dev, · 9 unmodified lines
21302161 if (result)
21312162 return result;
21322163
2133− if (mode > 1)
2164+ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE &&
2165+ mode > ASUS_MINI_LED_ON)
2166+ return -EINVAL;
2167+ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2 &&
2168+ mode > ASUS_MINI_LED_STRONG_MODE)
21342169 return -EINVAL;
21352170
2136− err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result);
2171+ /*
2172+ * Remap the mode values so expected behaviour is the same as the last
2173+ * generation of mini-LED with 0 == off, 1 == on.
2174+ */
2175+ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) {
2176+ switch (mode) {
2177+ case ASUS_MINI_LED_OFF:
2178+ mode = ASUS_MINI_LED_2024_OFF;
2179+ break;
2180+ case ASUS_MINI_LED_ON:
2181+ mode = ASUS_MINI_LED_2024_WEAK;
2182+ break;
2183+ case ASUS_MINI_LED_STRONG_MODE:
2184+ mode = ASUS_MINI_LED_2024_STRONG;
2185+ break;
2186+ }
2187+ }
21372188
2189+ err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result);
21382190 if (err) {
21392191 pr_warn("Failed to set mini-LED: %d\n", err);
21402192 return err;
@@ -2151,6 +2203,23 @@ static ssize_t mini_led_mode_store(struct device *dev, · 10 unmodified lines
21512203 }
21522204 static DEVICE_ATTR_RW(mini_led_mode);
21532205
2206+static ssize_t available_mini_led_mode_show(struct device *dev,
2207+ struct device_attribute *attr, char *buf)
2208+{
2209+ struct asus_wmi *asus = dev_get_drvdata(dev);
2210+
2211+ switch (asus->mini_led_dev_id) {
2212+ case ASUS_WMI_DEVID_MINI_LED_MODE:
2213+ return sysfs_emit(buf, "0 1\n");
2214+ case ASUS_WMI_DEVID_MINI_LED_MODE2:
2215+ return sysfs_emit(buf, "0 1 2\n");
2216+ }
2217+
2218+ return sysfs_emit(buf, "0\n");
2219+}
2220+
2221+static DEVICE_ATTR_RO(available_mini_led_mode);
2222+
21542223 /* Quirks *********************************************************************/
21552224
21562225 static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
@@ -4139,6 +4208,7 @@ static struct attribute *platform_attributes[] = { · 1982 unmodified lines
41394208 &dev_attr_nv_temp_target.attr,
41404209 &dev_attr_panel_od.attr,
41414210 &dev_attr_mini_led_mode.attr,
4211+ &dev_attr_available_mini_led_mode.attr,
41424212 NULL
41434213 };
41444214
@@ -4191,7 +4261,9 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, · 46 unmodified lines
41914261 else if (attr == &dev_attr_panel_od.attr)
41924262 ok = asus->panel_overdrive_available;
41934263 else if (attr == &dev_attr_mini_led_mode.attr)
4194− ok = asus->mini_led_mode_available;
4264+ ok = asus->mini_led_dev_id != 0;
4265+ else if (attr == &dev_attr_available_mini_led_mode.attr)
4266+ ok = asus->mini_led_dev_id != 0;
41954267
41964268 if (devid != -1)
41974269 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
@@ -4444,10 +4516,14 @@ static int asus_wmi_add(struct platform_device *pdev) · 246 unmodified lines
44444516 asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST);
44454517 asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);
44464518 asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);
4447− asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
44484519 asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
44494520 && dmi_match(DMI_BOARD_NAME, "RC71L");
44504521
4522+ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE))
4523+ asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE;
4524+ else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2))
4525+ asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2;
4526+
44514527 err = fan_boost_mode_check_present(asus);
44524528 if (err)
44534529 goto fail_fan_boost_mode;
include/linux/platform_data/x86/asus-wmi.h+1−0
@@ -71,6 +71,7 @@ · 70 unmodified lines
7171 #define ASUS_WMI_DEVID_LID_FLIP 0x00060062
7272 #define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077
7373 #define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E
74+#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E
7475
7576 /* Storage */
7677 #define ASUS_WMI_DEVID_CARDREADER 0x00080013

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t