aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorXing Wei <weixing@hanwang.com.cn>2010-09-29 21:25:20 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-09-29 21:25:47 -0400
commit727eeb7dbeac8a7ecd2ad943eb27a5566ab83601 (patch)
tree6846095784092e72e9c6c75af67bf1d2755ac770 /drivers/input
parentf5854fad395b93071292bff27c0121b6e32215e0 (diff)
Input: hanwang - add support for Art Master HD 5012 tablet
This adds support for hanwang Art Master HD 5012 electromagnetic tablet. Signed-off-by: Xing Wei <weixing@hanwang.com.cn> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/tablet/hanwang.c94
1 files changed, 73 insertions, 21 deletions
diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c
index 0701d948cdf3..6504b627b234 100644
--- a/drivers/input/tablet/hanwang.c
+++ b/drivers/input/tablet/hanwang.c
@@ -42,7 +42,7 @@ MODULE_LICENSE(DRIVER_LICENSE);
42#define HANWANG_TABLET_INT_SUB_CLASS 0x0001 42#define HANWANG_TABLET_INT_SUB_CLASS 0x0001
43#define HANWANG_TABLET_INT_PROTOCOL 0x0002 43#define HANWANG_TABLET_INT_PROTOCOL 0x0002
44 44
45#define ART_MASTERIII_PKGLEN_MAX 10 45#define ART_MASTER_PKGLEN_MAX 10
46 46
47/* device IDs */ 47/* device IDs */
48#define STYLUS_DEVICE_ID 0x02 48#define STYLUS_DEVICE_ID 0x02
@@ -60,6 +60,11 @@ MODULE_LICENSE(DRIVER_LICENSE);
60 .bInterfaceSubClass = (sc), \ 60 .bInterfaceSubClass = (sc), \
61 .bInterfaceProtocol = (pr) 61 .bInterfaceProtocol = (pr)
62 62
63enum hanwang_tablet_type {
64 HANWANG_ART_MASTER_III,
65 HANWANG_ART_MASTER_HD,
66};
67
63struct hanwang { 68struct hanwang {
64 unsigned char *data; 69 unsigned char *data;
65 dma_addr_t data_dma; 70 dma_addr_t data_dma;
@@ -76,6 +81,7 @@ struct hanwang {
76struct hanwang_features { 81struct hanwang_features {
77 unsigned short pid; 82 unsigned short pid;
78 char *name; 83 char *name;
84 enum hanwang_tablet_type type;
79 int pkg_len; 85 int pkg_len;
80 int max_x; 86 int max_x;
81 int max_y; 87 int max_y;
@@ -85,12 +91,14 @@ struct hanwang_features {
85}; 91};
86 92
87static const struct hanwang_features features_array[] = { 93static const struct hanwang_features features_array[] = {
88 { 0x8528, "Hanwang Art Master III 0906", 94 { 0x8528, "Hanwang Art Master III 0906", HANWANG_ART_MASTER_III,
89 ART_MASTERIII_PKGLEN_MAX, 0x5757, 0x3692, 0x3f, 0x7f, 2048 }, 95 ART_MASTER_PKGLEN_MAX, 0x5757, 0x3692, 0x3f, 0x7f, 2048 },
90 { 0x8529, "Hanwang Art Master III 0604", 96 { 0x8529, "Hanwang Art Master III 0604", HANWANG_ART_MASTER_III,
91 ART_MASTERIII_PKGLEN_MAX, 0x3d84, 0x2672, 0x3f, 0x7f, 2048 }, 97 ART_MASTER_PKGLEN_MAX, 0x3d84, 0x2672, 0x3f, 0x7f, 2048 },
92 { 0x852a, "Hanwang Art Master III 1308", 98 { 0x852a, "Hanwang Art Master III 1308", HANWANG_ART_MASTER_III,
93 ART_MASTERIII_PKGLEN_MAX, 0x7f00, 0x4f60, 0x3f, 0x7f, 2048 }, 99 ART_MASTER_PKGLEN_MAX, 0x7f00, 0x4f60, 0x3f, 0x7f, 2048 },
100 { 0x8401, "Hanwang Art Master HD 5012", HANWANG_ART_MASTER_HD,
101 ART_MASTER_PKGLEN_MAX, 0x678e, 0x4150, 0x3f, 0x7f, 1024 },
94}; 102};
95 103
96static const int hw_eventtypes[] = { 104static const int hw_eventtypes[] = {
@@ -99,7 +107,7 @@ static const int hw_eventtypes[] = {
99 107
100static const int hw_absevents[] = { 108static const int hw_absevents[] = {
101 ABS_X, ABS_Y, ABS_TILT_X, ABS_TILT_Y, ABS_WHEEL, 109 ABS_X, ABS_Y, ABS_TILT_X, ABS_TILT_Y, ABS_WHEEL,
102 ABS_PRESSURE, ABS_MISC, 110 ABS_RX, ABS_RY, ABS_PRESSURE, ABS_MISC,
103}; 111};
104 112
105static const int hw_btnevents[] = { 113static const int hw_btnevents[] = {
@@ -117,7 +125,9 @@ static void hanwang_parse_packet(struct hanwang *hanwang)
117 unsigned char *data = hanwang->data; 125 unsigned char *data = hanwang->data;
118 struct input_dev *input_dev = hanwang->dev; 126 struct input_dev *input_dev = hanwang->dev;
119 struct usb_device *dev = hanwang->usbdev; 127 struct usb_device *dev = hanwang->usbdev;
128 enum hanwang_tablet_type type = hanwang->features->type;
120 int i; 129 int i;
130 u16 x, y, p;
121 131
122 switch (data[0]) { 132 switch (data[0]) {
123 case 0x02: /* data packet */ 133 case 0x02: /* data packet */
@@ -129,12 +139,14 @@ static void hanwang_parse_packet(struct hanwang *hanwang)
129 139
130 case 0xc2: /* first time tool prox in */ 140 case 0xc2: /* first time tool prox in */
131 switch (data[3] & 0xf0) { 141 switch (data[3] & 0xf0) {
132 case 0x20: 142 case 0x20: /* art_master III */
143 case 0x30: /* art_master_HD */
133 hanwang->current_id = STYLUS_DEVICE_ID; 144 hanwang->current_id = STYLUS_DEVICE_ID;
134 hanwang->current_tool = BTN_TOOL_PEN; 145 hanwang->current_tool = BTN_TOOL_PEN;
135 input_report_key(input_dev, BTN_TOOL_PEN, 1); 146 input_report_key(input_dev, BTN_TOOL_PEN, 1);
136 break; 147 break;
137 case 0xa0: 148 case 0xa0: /* art_master III */
149 case 0xb0: /* art_master_HD */
138 hanwang->current_id = ERASER_DEVICE_ID; 150 hanwang->current_id = ERASER_DEVICE_ID;
139 hanwang->current_tool = BTN_TOOL_RUBBER; 151 hanwang->current_tool = BTN_TOOL_RUBBER;
140 input_report_key(input_dev, BTN_TOOL_RUBBER, 1); 152 input_report_key(input_dev, BTN_TOOL_RUBBER, 1);
@@ -148,14 +160,31 @@ static void hanwang_parse_packet(struct hanwang *hanwang)
148 break; 160 break;
149 161
150 default: /* tool data packet */ 162 default: /* tool data packet */
163 x = (data[2] << 8) | data[3];
164 y = (data[4] << 8) | data[5];
165
166 switch (type) {
167 case HANWANG_ART_MASTER_III:
168 p = (data[6] << 3) |
169 ((data[7] & 0xc0) >> 5) |
170 (data[1] & 0x01);
171 break;
172
173 case HANWANG_ART_MASTER_HD:
174 p = (data[7] >> 6) | (data[6] << 2);
175 break;
176
177 default:
178 p = 0;
179 break;
180 }
181
151 input_report_abs(input_dev, ABS_X, 182 input_report_abs(input_dev, ABS_X,
152 (data[2] << 8) | data[3]); 183 le16_to_cpup((__le16 *)&x));
153 input_report_abs(input_dev, ABS_Y, 184 input_report_abs(input_dev, ABS_Y,
154 (data[4] << 8) | data[5]); 185 le16_to_cpup((__le16 *)&y));
155 input_report_abs(input_dev, ABS_PRESSURE, 186 input_report_abs(input_dev, ABS_PRESSURE,
156 (data[6] << 3) | 187 le16_to_cpup((__le16 *)&p));
157 ((data[7] & 0xc0) >> 5) |
158 (data[1] & 0x01));
159 input_report_abs(input_dev, ABS_TILT_X, data[7] & 0x3f); 188 input_report_abs(input_dev, ABS_TILT_X, data[7] & 0x3f);
160 input_report_abs(input_dev, ABS_TILT_Y, data[8] & 0x7f); 189 input_report_abs(input_dev, ABS_TILT_Y, data[8] & 0x7f);
161 input_report_key(input_dev, BTN_STYLUS, data[1] & 0x02); 190 input_report_key(input_dev, BTN_STYLUS, data[1] & 0x02);
@@ -170,13 +199,36 @@ static void hanwang_parse_packet(struct hanwang *hanwang)
170 case 0x0c: 199 case 0x0c:
171 /* roll wheel */ 200 /* roll wheel */
172 hanwang->current_id = PAD_DEVICE_ID; 201 hanwang->current_id = PAD_DEVICE_ID;
173 input_report_key(input_dev, BTN_TOOL_FINGER, data[1] || 202
174 data[2] || data[3]); 203 switch (type) {
175 input_report_abs(input_dev, ABS_WHEEL, data[1]); 204 case HANWANG_ART_MASTER_III:
176 input_report_key(input_dev, BTN_0, data[2]); 205 input_report_key(input_dev, BTN_TOOL_FINGER, data[1] ||
177 for (i = 0; i < 8; i++) 206 data[2] || data[3]);
178 input_report_key(input_dev, 207 input_report_abs(input_dev, ABS_WHEEL, data[1]);
208 input_report_key(input_dev, BTN_0, data[2]);
209 for (i = 0; i < 8; i++)
210 input_report_key(input_dev,
179 BTN_1 + i, data[3] & (1 << i)); 211 BTN_1 + i, data[3] & (1 << i));
212 break;
213
214 case HANWANG_ART_MASTER_HD:
215 input_report_key(input_dev, BTN_TOOL_FINGER, data[1] ||
216 data[2] || data[3] || data[4] ||
217 data[5] || data[6]);
218 input_report_abs(input_dev, ABS_RX,
219 ((data[1] & 0x1f) << 8) | data[2]);
220 input_report_abs(input_dev, ABS_RY,
221 ((data[3] & 0x1f) << 8) | data[4]);
222 input_report_key(input_dev, BTN_0, data[5] & 0x01);
223 for (i = 0; i < 4; i++) {
224 input_report_key(input_dev,
225 BTN_1 + i, data[5] & (1 << i));
226 input_report_key(input_dev,
227 BTN_5 + i, data[6] & (1 << i));
228 }
229 break;
230 }
231
180 input_report_abs(input_dev, ABS_MISC, hanwang->current_id); 232 input_report_abs(input_dev, ABS_MISC, hanwang->current_id);
181 input_event(input_dev, EV_MSC, MSC_SERIAL, 0xffffffff); 233 input_event(input_dev, EV_MSC, MSC_SERIAL, 0xffffffff);
182 break; 234 break;