1 |
From 9b5b95dd516a13d53ecf9217672d2116f05097bc Mon Sep 17 00:00:00 2001 |
2 |
From: Jason Gerecke <killertofu@gmail.com> |
3 |
Date: Tue, 3 Apr 2012 15:50:37 -0700 |
4 |
Subject: [PATCH 3/4] Input: wacom - add Intuos5 Touch Ring LED support |
5 |
|
6 |
The Touch Ring LEDs on Intuos5 tablets use a different report |
7 |
format which supports only 4 levels of brightness. We remap |
8 |
the 7-bit value obtained from sysfs to an appropriate value |
9 |
for the tablet. Control of the crop mark LEDs (new to the I5) |
10 |
is left for a later patch. |
11 |
|
12 |
Signed-off-by: Jason Gerecke <killertofu@gmail.com> |
13 |
Reviewed-by: Ping Cheng <pingc@wacom.com> |
14 |
Signed-off-by: Dmitry Torokhov <dtor@mail.ru> |
15 |
--- |
16 |
Documentation/ABI/testing/sysfs-driver-wacom | 15 +++--- |
17 |
drivers/input/tablet/wacom_sys.c | 71 +++++++++++++++++++++++----- |
18 |
2 files changed, 67 insertions(+), 19 deletions(-) |
19 |
|
20 |
diff --git a/Documentation/ABI/testing/sysfs-driver-wacom b/Documentation/ABI/testing/sysfs-driver-wacom |
21 |
index 0130d66..5e9cbdc 100644 |
22 |
--- a/Documentation/ABI/testing/sysfs-driver-wacom |
23 |
+++ b/Documentation/ABI/testing/sysfs-driver-wacom |
24 |
@@ -15,9 +15,10 @@ Contact: linux-input@vger.kernel.org |
25 |
Description: |
26 |
Attribute group for control of the status LEDs and the OLEDs. |
27 |
This attribute group is only available for Intuos 4 M, L, |
28 |
- and XL (with LEDs and OLEDs) and Cintiq 21UX2 and Cintiq 24HD |
29 |
- (LEDs only). Therefore its presence implicitly signifies the |
30 |
- presence of said LEDs and OLEDs on the tablet device. |
31 |
+ and XL (with LEDs and OLEDs), Intuos 5 (LEDs only), and Cintiq |
32 |
+ 21UX2 and Cintiq 24HD (LEDs only). Therefore its presence |
33 |
+ implicitly signifies the presence of said LEDs and OLEDs on the |
34 |
+ tablet device. |
35 |
|
36 |
What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/status0_luminance |
37 |
Date: August 2011 |
38 |
@@ -40,10 +41,10 @@ What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/status_led0 |
39 |
Date: August 2011 |
40 |
Contact: linux-input@vger.kernel.org |
41 |
Description: |
42 |
- Writing to this file sets which one of the four (for Intuos 4) |
43 |
- or of the right four (for Cintiq 21UX2 and Cintiq 24HD) status |
44 |
- LEDs is active (0..3). The other three LEDs on the same side are |
45 |
- always inactive. |
46 |
+ Writing to this file sets which one of the four (for Intuos 4 |
47 |
+ and Intuos 5) or of the right four (for Cintiq 21UX2 and Cintiq |
48 |
+ 24HD) status LEDs is active (0..3). The other three LEDs on the |
49 |
+ same side are always inactive. |
50 |
|
51 |
What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/status_led1_select |
52 |
Date: September 2011 |
53 |
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c |
54 |
index 19ba586..d771338 100644 |
55 |
--- a/drivers/input/tablet/wacom_sys.c |
56 |
+++ b/drivers/input/tablet/wacom_sys.c |
57 |
@@ -574,23 +574,39 @@ static void wacom_remove_shared_data(struct wacom_wac *wacom) |
58 |
static int wacom_led_control(struct wacom *wacom) |
59 |
{ |
60 |
unsigned char *buf; |
61 |
- int retval, led = 0; |
62 |
+ int retval; |
63 |
|
64 |
buf = kzalloc(9, GFP_KERNEL); |
65 |
if (!buf) |
66 |
return -ENOMEM; |
67 |
|
68 |
- if (wacom->wacom_wac.features.type == WACOM_21UX2 || |
69 |
- wacom->wacom_wac.features.type == WACOM_24HD) |
70 |
- led = (wacom->led.select[1] << 4) | 0x40; |
71 |
- |
72 |
- led |= wacom->led.select[0] | 0x4; |
73 |
- |
74 |
- buf[0] = WAC_CMD_LED_CONTROL; |
75 |
- buf[1] = led; |
76 |
- buf[2] = wacom->led.llv; |
77 |
- buf[3] = wacom->led.hlv; |
78 |
- buf[4] = wacom->led.img_lum; |
79 |
+ if (wacom->wacom_wac.features.type >= INTUOS5S && |
80 |
+ wacom->wacom_wac.features.type <= INTUOS5L) { |
81 |
+ /* |
82 |
+ * Touch Ring and crop mark LED luminance may take on |
83 |
+ * one of four values: |
84 |
+ * 0 = Low; 1 = Medium; 2 = High; 3 = Off |
85 |
+ */ |
86 |
+ int ring_led = wacom->led.select[0] & 0x03; |
87 |
+ int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; |
88 |
+ int crop_lum = 0; |
89 |
+ |
90 |
+ buf[0] = WAC_CMD_LED_CONTROL; |
91 |
+ buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); |
92 |
+ } |
93 |
+ else { |
94 |
+ int led = wacom->led.select[0] | 0x4; |
95 |
+ |
96 |
+ if (wacom->wacom_wac.features.type == WACOM_21UX2 || |
97 |
+ wacom->wacom_wac.features.type == WACOM_24HD) |
98 |
+ led |= (wacom->led.select[1] << 4) | 0x40; |
99 |
+ |
100 |
+ buf[0] = WAC_CMD_LED_CONTROL; |
101 |
+ buf[1] = led; |
102 |
+ buf[2] = wacom->led.llv; |
103 |
+ buf[3] = wacom->led.hlv; |
104 |
+ buf[4] = wacom->led.img_lum; |
105 |
+ } |
106 |
|
107 |
retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL, |
108 |
buf, 9, WAC_CMD_RETRIES); |
109 |
@@ -783,6 +799,17 @@ static struct attribute_group intuos4_led_attr_group = { |
110 |
.attrs = intuos4_led_attrs, |
111 |
}; |
112 |
|
113 |
+static struct attribute *intuos5_led_attrs[] = { |
114 |
+ &dev_attr_status0_luminance.attr, |
115 |
+ &dev_attr_status_led0_select.attr, |
116 |
+ NULL |
117 |
+}; |
118 |
+ |
119 |
+static struct attribute_group intuos5_led_attr_group = { |
120 |
+ .name = "wacom_led", |
121 |
+ .attrs = intuos5_led_attrs, |
122 |
+}; |
123 |
+ |
124 |
static int wacom_initialize_leds(struct wacom *wacom) |
125 |
{ |
126 |
int error; |
127 |
@@ -812,6 +839,19 @@ static int wacom_initialize_leds(struct wacom *wacom) |
128 |
&cintiq_led_attr_group); |
129 |
break; |
130 |
|
131 |
+ case INTUOS5S: |
132 |
+ case INTUOS5: |
133 |
+ case INTUOS5L: |
134 |
+ wacom->led.select[0] = 0; |
135 |
+ wacom->led.select[1] = 0; |
136 |
+ wacom->led.llv = 32; |
137 |
+ wacom->led.hlv = 0; |
138 |
+ wacom->led.img_lum = 0; |
139 |
+ |
140 |
+ error = sysfs_create_group(&wacom->intf->dev.kobj, |
141 |
+ &intuos5_led_attr_group); |
142 |
+ break; |
143 |
+ |
144 |
default: |
145 |
return 0; |
146 |
} |
147 |
@@ -840,6 +880,13 @@ static void wacom_destroy_leds(struct wacom *wacom) |
148 |
sysfs_remove_group(&wacom->intf->dev.kobj, |
149 |
&cintiq_led_attr_group); |
150 |
break; |
151 |
+ |
152 |
+ case INTUOS5S: |
153 |
+ case INTUOS5: |
154 |
+ case INTUOS5L: |
155 |
+ sysfs_remove_group(&wacom->intf->dev.kobj, |
156 |
+ &intuos5_led_attr_group); |
157 |
+ break; |
158 |
} |
159 |
} |
160 |
|
161 |
-- |
162 |
1.7.12.2 |
163 |
|