forked from Plippo/asus-wmi-screenpad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch5.8
158 lines (154 loc) · 5.23 KB
/
patch5.8
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
diff --color -up orig/asus-nb-wmi.c new/asus-nb-wmi.c
--- orig/asus-nb-wmi.c 2020-11-05 22:28:37.856683616 +0200
+++ new/asus-nb-wmi.c 2020-11-05 22:29:00.888684638 +0200
@@ -578,6 +578,7 @@ static const struct key_entry asus_nb_wm
{ KE_KEY, 0x65, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV */
{ KE_KEY, 0x66, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV */
{ KE_KEY, 0x67, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV */
+ { KE_KEY, 0x6A, { KEY_F16 } }, /* Toggle ScreenPad key */
{ KE_KEY, 0x6B, { KEY_TOUCHPAD_TOGGLE } },
{ KE_IGNORE, 0x6E, }, /* Low Battery notification */
{ KE_KEY, 0x71, { KEY_F13 } }, /* General-purpose button */
@@ -587,6 +588,8 @@ static const struct key_entry asus_nb_wm
{ KE_KEY, 0x7D, { KEY_BLUETOOTH } }, /* Bluetooth Enable */
{ KE_KEY, 0x7E, { KEY_BLUETOOTH } }, /* Bluetooth Disable */
{ KE_KEY, 0x82, { KEY_CAMERA } },
+ { KE_KEY, 0x85, { KEY_CAMERA } },
+ { KE_KEY, 0x86, { KEY_F13 } }, /* Key containing "A" logo */
{ KE_KEY, 0x88, { KEY_RFKILL } }, /* Radio Toggle Key */
{ KE_KEY, 0x8A, { KEY_PROG1 } }, /* Color enhancement mode */
{ KE_KEY, 0x8C, { KEY_SWITCHVIDEOMODE } }, /* SDSP DVI only */
@@ -599,6 +602,8 @@ static const struct key_entry asus_nb_wm
{ KE_KEY, 0x93, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + DVI */
{ KE_KEY, 0x95, { KEY_MEDIA } },
{ KE_KEY, 0x99, { KEY_PHONE } }, /* Conflicts with fan mode switch */
+ { KE_KEY, 0x9C, { KEY_F15 } }, /* Zenbook Duo Swap Windows */
+ { KE_KEY, 0x9D, { KEY_F14 } }, /* Zenbook Duo Power mode */
{ KE_KEY, 0xA0, { KEY_SWITCHVIDEOMODE } }, /* SDSP HDMI only */
{ KE_KEY, 0xA1, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + HDMI */
{ KE_KEY, 0xA2, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + HDMI */
Only in new: asus-nb-wmi.c.orig
diff --color -up orig/asus-wmi.c new/asus-wmi.c
--- orig/asus-wmi.c 2020-11-05 22:28:37.856683616 +0200
+++ new/asus-wmi.c 2020-11-05 22:32:06.404692870 +0200
@@ -32,6 +32,7 @@
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/platform_data/x86/asus-wmi.h>
+#include "inc/asus-wmi.h"
#include <linux/platform_device.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
@@ -186,10 +187,13 @@ struct asus_wmi {
int kbd_led_wk;
struct led_classdev lightbar_led;
int lightbar_led_wk;
+ struct led_classdev screenpad_led;
+ int screenpad_led_wk;
struct workqueue_struct *led_workqueue;
struct work_struct tpd_led_work;
struct work_struct wlan_led_work;
struct work_struct lightbar_led_work;
+ struct work_struct screenpad_led_work;
struct asus_rfkill wlan;
struct asus_rfkill bluetooth;
@@ -688,12 +692,81 @@ static enum led_brightness lightbar_led_
return result & ASUS_WMI_DSTS_LIGHTBAR_MASK;
}
+static int screenpad_led_read(struct asus_wmi *asus, int *level)
+{
+ int value, retval;
+ retval = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD, &value);
+ if (retval == 0 && (value & 0x1) == 0x1)
+ {
+ // screen is activated, so read backlight
+ retval = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &value);
+ if (retval == 0)
+ {
+ *level = value & ASUS_WMI_DSTS_BRIGHTNESS_MASK;
+ }
+ }
+ else
+ {
+ *level = 0;
+ }
+
+ if (retval < 0)
+ return retval;
+ return 0;
+}
+
+static void screenpad_led_update(struct work_struct *work)
+{
+ struct asus_wmi *asus;
+ int ctrl_param;
+
+ asus = container_of(work, struct asus_wmi, screenpad_led_work);
+
+ ctrl_param = asus->screenpad_led_wk;
+ if (ctrl_param == 0x00)
+ {
+ // turn off screen
+ asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD, ctrl_param, NULL);
+ }
+ else
+ {
+ // set backlight (also turns on screen if is off)
+ asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
+ }
+}
+
+static void screenpad_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ struct asus_wmi *asus;
+
+ asus = container_of(led_cdev, struct asus_wmi, screenpad_led);
+
+ asus->screenpad_led_wk = value;
+ queue_work(asus->led_workqueue, &asus->screenpad_led_work);
+}
+
+static enum led_brightness screenpad_led_get(struct led_classdev *led_cdev)
+{
+ struct asus_wmi *asus;
+ int retval, value;
+
+ asus = container_of(led_cdev, struct asus_wmi, screenpad_led);
+
+ retval = screenpad_led_read(asus, &value);
+ if (retval < 0)
+ return retval;
+
+ return value;
+}
+
static void asus_wmi_led_exit(struct asus_wmi *asus)
{
led_classdev_unregister(&asus->kbd_led);
led_classdev_unregister(&asus->tpd_led);
led_classdev_unregister(&asus->wlan_led);
led_classdev_unregister(&asus->lightbar_led);
+ led_classdev_unregister(&asus->screenpad_led);
if (asus->led_workqueue)
destroy_workqueue(asus->led_workqueue);
@@ -764,6 +837,20 @@ static int asus_wmi_led_init(struct asus
rv = led_classdev_register(&asus->platform_device->dev,
&asus->lightbar_led);
}
+
+ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_SCREENPAD)
+ && !screenpad_led_read(asus, &led_val)) {
+ asus->screenpad_led_wk = led_val;
+ INIT_WORK(&asus->screenpad_led_work, screenpad_led_update);
+
+ asus->screenpad_led.name = "asus::screenpad";
+ asus->screenpad_led.brightness_set = screenpad_led_set;
+ asus->screenpad_led.brightness_get = screenpad_led_get;
+ asus->screenpad_led.max_brightness = 0xff;
+
+ rv = led_classdev_register(&asus->platform_device->dev,
+ &asus->screenpad_led);
+ }
error:
if (rv)