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
126 Change the mini-LED mode:126 Change the mini-LED mode:
127 * 0 - Single-zone,127 * 0 - Single-zone,
128 * 1 - Multi-zone128 * 1 - Multi-zone
129 * 2 - Multi-zone strong (available on newer generation mini-led)
130
131What: /sys/devices/platform/<platform>/available_mini_led_mode
132Date: Apr 2024
133KernelVersion: 6.10
134Contact: "Luke Jones" <luke@ljones.dev>
135Description:
136 List the available mini-led modes.
129 137
130What: /sys/devices/platform/<platform>/ppt_pl1_spl138What: /sys/devices/platform/<platform>/ppt_pl1_spl
131Date: Jun 2023139Date: Jun 2023
drivers/platform/x86/asus-wmi.c+86−10
@@ -126,6 +126,17 @@ module_param(fnlock_default, bool, 0444); · 125 unmodified lines
126#define ASUS_SCREENPAD_BRIGHT_MAX 255126#define ASUS_SCREENPAD_BRIGHT_MAX 255
127#define ASUS_SCREENPAD_BRIGHT_DEFAULT 60127#define ASUS_SCREENPAD_BRIGHT_DEFAULT 60
128 128
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
129/* Controls the power state of the USB0 hub on ROG Ally which input is on */140/* Controls the power state of the USB0 hub on ROG Ally which input is on */
130#define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE"141#define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE"
131/* 300ms so far seems to produce a reliable result on AC and battery */142/* 300ms so far seems to produce a reliable result on AC and battery */
@@ -288,7 +299,7 @@ struct asus_wmi { · 156 unmodified lines
288 bool battery_rsoc_available;299 bool battery_rsoc_available;
289 300
290 bool panel_overdrive_available;301 bool panel_overdrive_available;
291 bool mini_led_mode_available;302 u32 mini_led_dev_id;
292 303
293 struct hotplug_slot hotplug_slot;304 struct hotplug_slot hotplug_slot;
294 struct mutex hotplug_lock;305 struct mutex hotplug_lock;
@@ -2108,13 +2119,33 @@ static ssize_t mini_led_mode_show(struct device *dev, · 1813 unmodified lines
2108 struct device_attribute *attr, char *buf)2119 struct device_attribute *attr, char *buf)
2109{2120{
2110 struct asus_wmi *asus = dev_get_drvdata(dev);2121 struct asus_wmi *asus = dev_get_drvdata(dev);
2111 int result;2122 u32 value;
2123 int err;
2112 2124
2113 result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE);2125 err = asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value);
2114 if (result < 0)2126 if (err < 0)
2115 return result;2127 return err;
2128 value = value & ASUS_MINI_LED_MODE_MASK;
2116 2129
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);
2118}2149}
2119 2150
2120static ssize_t mini_led_mode_store(struct device *dev,2151static 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
2130 if (result)2161 if (result)
2131 return result;2162 return result;
2132 2163
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)
2134 return -EINVAL;2169 return -EINVAL;
2135 2170
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 }
2137 2188
2189 err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result);
2138 if (err) {2190 if (err) {
2139 pr_warn("Failed to set mini-LED: %d\n", err);2191 pr_warn("Failed to set mini-LED: %d\n", err);
2140 return err;2192 return err;
@@ -2151,6 +2203,23 @@ static ssize_t mini_led_mode_store(struct device *dev, · 10 unmodified lines
2151}2203}
2152static DEVICE_ATTR_RW(mini_led_mode);2204static DEVICE_ATTR_RW(mini_led_mode);
2153 2205
2206static 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
2221static DEVICE_ATTR_RO(available_mini_led_mode);
2222
2154/* Quirks *********************************************************************/2223/* Quirks *********************************************************************/
2155 2224
2156static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)2225static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
@@ -4139,6 +4208,7 @@ static struct attribute *platform_attributes[] = { · 1982 unmodified lines
4139 &dev_attr_nv_temp_target.attr,4208 &dev_attr_nv_temp_target.attr,
4140 &dev_attr_panel_od.attr,4209 &dev_attr_panel_od.attr,
4141 &dev_attr_mini_led_mode.attr,4210 &dev_attr_mini_led_mode.attr,
4211 &dev_attr_available_mini_led_mode.attr,
4142 NULL4212 NULL
4143};4213};
4144 4214
@@ -4191,7 +4261,9 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, · 46 unmodified lines
4191 else if (attr == &dev_attr_panel_od.attr)4261 else if (attr == &dev_attr_panel_od.attr)
4192 ok = asus->panel_overdrive_available;4262 ok = asus->panel_overdrive_available;
4193 else if (attr == &dev_attr_mini_led_mode.attr)4263 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;
4195 4267
4196 if (devid != -1)4268 if (devid != -1)
4197 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);4269 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
4444 asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST);4516 asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST);
4445 asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);4517 asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);
4446 asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);4518 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);
4448 asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)4519 asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
4449 && dmi_match(DMI_BOARD_NAME, "RC71L");4520 && dmi_match(DMI_BOARD_NAME, "RC71L");
4450 4521
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
4451 err = fan_boost_mode_check_present(asus);4527 err = fan_boost_mode_check_present(asus);
4452 if (err)4528 if (err)
4453 goto fail_fan_boost_mode;4529 goto fail_fan_boost_mode;
include/linux/platform_data/x86/asus-wmi.h+1−0
@@ -71,6 +71,7 @@ · 70 unmodified lines
71#define ASUS_WMI_DEVID_LID_FLIP 0x0006006271#define ASUS_WMI_DEVID_LID_FLIP 0x00060062
72#define ASUS_WMI_DEVID_LID_FLIP_ROG 0x0006007772#define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077
73#define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E73#define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E
74#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E
74 75
75/* Storage */76/* Storage */
76#define ASUS_WMI_DEVID_CARDREADER 0x0008001377#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