-
Notifications
You must be signed in to change notification settings - Fork 23
/
patch6.11
153 lines (149 loc) · 4.75 KB
/
patch6.11
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
diff --git a/asus-nb-wmi.c b/asus-nb-wmi.c
index ed3633c..af95bb9 100644
--- a/asus-nb-wmi.c
+++ b/asus-nb-wmi.c
@@ -584,6 +584,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = {
{ 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 */
@@ -608,6 +609,8 @@ static const struct key_entry asus_nb_wmi_keymap[] = {
{ 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 */
diff --git a/asus-wmi.c b/asus-wmi.c
index 321a658..fc9e208 100644
--- a/asus-wmi.c
+++ b/asus-wmi.c
@@ -31,6 +31,7 @@
#include <linux/pci.h>
#include <linux/pci_hotplug.h>
#include <linux/platform_data/x86/asus-wmi.h>
+#include "inc/asus-wmi.h"
#include <linux/platform_device.h>
#include <linux/platform_profile.h>
#include <linux/power_supply.h>
@@ -251,12 +252,15 @@ 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 led_classdev micmute_led;
struct led_classdev camera_led;
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;
@@ -1682,6 +1686,74 @@ static int camera_led_set(struct led_classdev *led_cdev,
return err < 0 ? err : 0;
}
+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 & 0x21) != 0)
+ {
+ // 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);
@@ -1689,6 +1761,7 @@ static void asus_wmi_led_exit(struct asus_wmi *asus)
led_classdev_unregister(&asus->wlan_led);
led_classdev_unregister(&asus->lightbar_led);
led_classdev_unregister(&asus->micmute_led);
+ led_classdev_unregister(&asus->screenpad_led);
led_classdev_unregister(&asus->camera_led);
if (asus->led_workqueue)
@@ -1803,6 +1876,20 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
goto error;
}
+ 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)
asus_wmi_led_exit(asus);