forked from Plippo/asus-wmi-screenpad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch-ux8406-tablet-switch
89 lines (82 loc) · 3.51 KB
/
patch-ux8406-tablet-switch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
diff -up orig/asus-nb-wmi.c new/asus-nb-wmi.c
--- orig/asus-nb-wmi.c 2024-12-16 11:27:32.803195780 +0100
+++ new/asus-nb-wmi.c 2024-12-16 11:27:42.677271276 +0100
@@ -146,7 +146,12 @@ static struct quirk_entry quirk_asus_ign
};
static struct quirk_entry quirk_asus_zenbook_duo_kbd = {
- .ignore_key_wlan = true,
+ /* ignore_key_wlan = true, */
+ .tablet_switch_mode = asus_wmi_kbd_dock_devid,
+ .tablet_switch_devid = 0x00050051,
+ .tablet_switch_event_code = 0x5e,
+ .tablet_switch_not_inverted = true,
+ .ignore_screenpad = true,
};
static int dmi_matched(const struct dmi_system_id *dmi)
diff -up orig/asus-wmi.c new/asus-wmi.c
--- orig/asus-wmi.c 2024-12-16 11:27:32.803195780 +0100
+++ new/asus-wmi.c 2024-12-16 11:27:42.677271276 +0100
@@ -642,8 +642,10 @@ static int asus_wmi_input_init(struct as
case asus_wmi_no_tablet_switch:
break;
case asus_wmi_kbd_dock_devid:
- asus->tablet_switch_inverted = true;
- asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_KBD_DOCK, NOTIFY_KBD_DOCK_CHANGE);
+ pr_info("asus_wmi_kbd_dock_devid: %x %x\n", asus->driver->quirks->tablet_switch_devid, asus->driver->quirks->tablet_switch_event_code);
+ /* asus->tablet_switch_inverted = true; */
+ asus->tablet_switch_inverted = !asus->driver->quirks->tablet_switch_not_inverted;
+ asus_wmi_tablet_sw_init(asus, asus->driver->quirks->tablet_switch_devid ? asus->driver->quirks->tablet_switch_devid : ASUS_WMI_DEVID_KBD_DOCK, asus->driver->quirks->tablet_switch_event_code ? asus->driver->quirks->tablet_switch_event_code : NOTIFY_KBD_DOCK_CHANGE);
break;
case asus_wmi_lid_flip_devid:
asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_LID_FLIP, NOTIFY_LID_FLIP);
@@ -2462,6 +2464,25 @@ static ssize_t available_mini_led_mode_s
static DEVICE_ATTR_RO(available_mini_led_mode);
+static ssize_t tablet_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+ bool value = false;
+
+ if (asus->tablet_switch_dev_id) {
+ int result = asus_wmi_get_devstate_simple(asus, asus->tablet_switch_dev_id);
+ if (result < 0)
+ return result;
+
+ value = asus->tablet_switch_inverted ? !result : result;
+ }
+
+ return sysfs_emit(buf, "%d\n", value);
+}
+
+static DEVICE_ATTR_RO(tablet);
+
/* Quirks *********************************************************************/
static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
@@ -4431,6 +4452,7 @@ static struct attribute *platform_attrib
&dev_attr_panel_od.attr,
&dev_attr_mini_led_mode.attr,
&dev_attr_available_mini_led_mode.attr,
+ &dev_attr_tablet.attr,
NULL
};
@@ -4817,7 +4839,7 @@ static int asus_wmi_add(struct platform_
} else if (asus->driver->quirks->wmi_backlight_set_devstate)
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 2, NULL);
- if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT)) {
+ if (!asus->driver->quirks->ignore_screenpad && asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT)) {
err = asus_screenpad_init(asus);
if (err && err != -ENODEV)
goto fail_screenpad;
diff -up orig/asus-wmi.h new/asus-wmi.h
--- orig/asus-wmi.h 2024-12-16 11:27:32.803195780 +0100
+++ new/asus-wmi.h 2024-12-16 11:27:42.677271276 +0100
@@ -42,6 +42,9 @@ struct quirk_entry {
bool filter_i8042_e1_extended_codes;
bool ignore_key_wlan;
enum asus_wmi_tablet_switch_mode tablet_switch_mode;
+ int tablet_switch_devid, tablet_switch_event_code;
+ bool tablet_switch_not_inverted;
+ bool ignore_screenpad;
int wapf;
/*
* For machines with AMD graphic chips, it will send out WMI event