blob: ba9af470bea06fe4bbcf1f7e0c0724c75f613dae [file] [log] [blame]
Ping Cheng3bea7332006-07-13 18:01:36 -07001/*
Dmitry Torokhov4104d132007-05-07 16:16:29 -04002 * drivers/input/tablet/wacom_sys.c
Ping Cheng3bea7332006-07-13 18:01:36 -07003 *
Ping Cheng232f5692009-12-15 00:35:24 -08004 * USB Wacom tablet support - system specific code
Ping Cheng3bea7332006-07-13 18:01:36 -07005 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
Ping Cheng3bea7332006-07-13 18:01:36 -070014#include "wacom_wac.h"
Dmitry Torokhov51269fe2010-03-19 22:18:15 -070015#include "wacom.h"
Jason Gereckeb58ba1b2014-12-05 13:37:32 -080016#include <linux/input/mt.h>
Ping Cheng3bea7332006-07-13 18:01:36 -070017
Ping Chenga417ea42011-08-16 00:17:56 -070018#define WAC_MSG_RETRIES 5
Ping Cheng3bea7332006-07-13 18:01:36 -070019
Ping Cheng912ca212014-09-10 12:41:31 -070020#define WAC_CMD_WL_LED_CONTROL 0x03
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070021#define WAC_CMD_LED_CONTROL 0x20
22#define WAC_CMD_ICON_START 0x21
23#define WAC_CMD_ICON_XFER 0x23
Benjamin Tissoires849e2f02014-08-06 13:58:25 -070024#define WAC_CMD_ICON_BT_XFER 0x26
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070025#define WAC_CMD_RETRIES 10
26
Ping Chenge0984bc2014-09-10 12:40:05 -070027#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
28#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
29
Ping Chengc64d8832014-09-10 12:41:04 -070030static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
31 size_t size, unsigned int retries)
Ping Cheng3bea7332006-07-13 18:01:36 -070032{
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070033 int retval;
34
35 do {
Ping Chengc64d8832014-09-10 12:41:04 -070036 retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
Benjamin Tissoires27b20a92014-07-24 12:56:22 -070037 HID_REQ_GET_REPORT);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070038 } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
39
40 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -070041}
42
Przemo Firszt296b7372014-08-06 14:00:38 -070043static int wacom_set_report(struct hid_device *hdev, u8 type, u8 *buf,
44 size_t size, unsigned int retries)
Ping Cheng3bea7332006-07-13 18:01:36 -070045{
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070046 int retval;
47
48 do {
Przemo Firszt296b7372014-08-06 14:00:38 -070049 retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
Benjamin Tissoires27b20a92014-07-24 12:56:22 -070050 HID_REQ_SET_REPORT);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070051 } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
52
53 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -070054}
55
Benjamin Tissoires29b47392014-07-24 12:52:23 -070056static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
57 u8 *raw_data, int size)
Ping Cheng3bea7332006-07-13 18:01:36 -070058{
Benjamin Tissoires29b47392014-07-24 12:52:23 -070059 struct wacom *wacom = hid_get_drvdata(hdev);
Ping Cheng3bea7332006-07-13 18:01:36 -070060
Benjamin Tissoires29b47392014-07-24 12:52:23 -070061 if (size > WACOM_PKGLEN_MAX)
62 return 1;
Ping Cheng3bea7332006-07-13 18:01:36 -070063
Benjamin Tissoires29b47392014-07-24 12:52:23 -070064 memcpy(wacom->wacom_wac.data, raw_data, size);
Ping Cheng3bea7332006-07-13 18:01:36 -070065
Benjamin Tissoires29b47392014-07-24 12:52:23 -070066 wacom_wac_irq(&wacom->wacom_wac, size);
67
68 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -070069}
70
Ping Cheng3bea7332006-07-13 18:01:36 -070071static int wacom_open(struct input_dev *dev)
72{
Dmitry Torokhov7791bda2007-04-12 01:34:39 -040073 struct wacom *wacom = input_get_drvdata(dev);
Ping Cheng3bea7332006-07-13 18:01:36 -070074
Benjamin Tissoiresdff67412014-12-01 11:52:40 -050075 return hid_hw_open(wacom->hdev);
Ping Cheng3bea7332006-07-13 18:01:36 -070076}
77
78static void wacom_close(struct input_dev *dev)
79{
Dmitry Torokhov7791bda2007-04-12 01:34:39 -040080 struct wacom *wacom = input_get_drvdata(dev);
Ping Cheng3bea7332006-07-13 18:01:36 -070081
Benjamin Tissoires29b47392014-07-24 12:52:23 -070082 hid_hw_close(wacom->hdev);
Ping Cheng3bea7332006-07-13 18:01:36 -070083}
84
Chris Bagwell16bf2882012-03-25 23:26:20 -070085/*
Benjamin Tissoires198fdee2014-07-24 13:03:05 -070086 * Calculate the resolution of the X or Y axis using hidinput_calc_abs_res.
Jason Gerecke115d5e12012-10-03 17:24:32 -070087 */
88static int wacom_calc_hid_res(int logical_extents, int physical_extents,
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -070089 unsigned unit, int exponent)
Jason Gerecke115d5e12012-10-03 17:24:32 -070090{
Benjamin Tissoires198fdee2014-07-24 13:03:05 -070091 struct hid_field field = {
92 .logical_maximum = logical_extents,
93 .physical_maximum = physical_extents,
94 .unit = unit,
95 .unit_exponent = exponent,
96 };
Jason Gerecke115d5e12012-10-03 17:24:32 -070097
Benjamin Tissoires198fdee2014-07-24 13:03:05 -070098 return hidinput_calc_abs_res(&field, ABS_X);
Jason Gerecke115d5e12012-10-03 17:24:32 -070099}
100
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700101static void wacom_feature_mapping(struct hid_device *hdev,
102 struct hid_field *field, struct hid_usage *usage)
Chris Bagwell41343612011-10-26 22:32:52 -0700103{
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700104 struct wacom *wacom = hid_get_drvdata(hdev);
105 struct wacom_features *features = &wacom->wacom_wac.features;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -0400106 struct hid_data *hid_data = &wacom->wacom_wac.hid_data;
Benjamin Tissoires8ffffd52014-09-16 16:56:39 -0400107 u8 *data;
108 int ret;
Chris Bagwell41343612011-10-26 22:32:52 -0700109
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700110 switch (usage->hid) {
111 case HID_DG_CONTACTMAX:
112 /* leave touch_max as is if predefined */
Benjamin Tissoires8ffffd52014-09-16 16:56:39 -0400113 if (!features->touch_max) {
114 /* read manually */
115 data = kzalloc(2, GFP_KERNEL);
116 if (!data)
117 break;
118 data[0] = field->report->id;
119 ret = wacom_get_report(hdev, HID_FEATURE_REPORT,
120 data, 2, 0);
121 if (ret == 2)
122 features->touch_max = data[1];
123 kfree(data);
124 }
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700125 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -0400126 case HID_DG_INPUTMODE:
127 /* Ignore if value index is out of bounds. */
128 if (usage->usage_index >= field->report_count) {
129 dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n");
130 break;
131 }
132
133 hid_data->inputmode = field->report->id;
134 hid_data->inputmode_index = usage->usage_index;
135 break;
Ping Chengf393ee22012-04-29 21:09:17 -0700136 }
137}
138
Chris Bagwell428f8582011-10-26 22:26:59 -0700139/*
140 * Interface Descriptor of wacom devices can be incomplete and
141 * inconsistent so wacom_features table is used to store stylus
142 * device's packet lengths, various maximum values, and tablet
143 * resolution based on product ID's.
144 *
145 * For devices that contain 2 interfaces, wacom_features table is
146 * inaccurate for the touch interface. Since the Interface Descriptor
147 * for touch interfaces has pretty complete data, this function exists
148 * to query tablet for this missing information instead of hard coding in
149 * an additional table.
150 *
151 * A typical Interface Descriptor for a stylus will contain a
152 * boot mouse application collection that is not of interest and this
153 * function will ignore it.
154 *
155 * It also contains a digitizer application collection that also is not
156 * of interest since any information it contains would be duplicate
157 * of what is in wacom_features. Usually it defines a report of an array
158 * of bytes that could be used as max length of the stylus packet returned.
159 * If it happens to define a Digitizer-Stylus Physical Collection then
160 * the X and Y logical values contain valid data but it is ignored.
161 *
162 * A typical Interface Descriptor for a touch interface will contain a
163 * Digitizer-Finger Physical Collection which will define both logical
164 * X/Y maximum as well as the physical size of tablet. Since touch
165 * interfaces haven't supported pressure or distance, this is enough
166 * information to override invalid values in the wacom_features table.
Chris Bagwell41343612011-10-26 22:32:52 -0700167 *
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700168 * Intuos5 touch interface and 3rd gen Bamboo Touch do not contain useful
169 * data. We deal with them after returning from this function.
Chris Bagwell428f8582011-10-26 22:26:59 -0700170 */
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700171static void wacom_usage_mapping(struct hid_device *hdev,
172 struct hid_field *field, struct hid_usage *usage)
173{
174 struct wacom *wacom = hid_get_drvdata(hdev);
175 struct wacom_features *features = &wacom->wacom_wac.features;
Benjamin Tissoiresd97a5522015-01-05 16:32:12 -0500176 bool finger = WACOM_FINGER_FIELD(field);
177 bool pen = WACOM_PEN_FIELD(field);
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700178
179 /*
180 * Requiring Stylus Usage will ignore boot mouse
181 * X/Y values and some cases of invalid Digitizer X/Y
182 * values commonly reported.
183 */
184 if (!pen && !finger)
185 return;
186
Ping Cheng30ebc1a2014-11-18 13:29:16 -0800187 /*
188 * Bamboo models do not support HID_DG_CONTACTMAX.
189 * And, Bamboo Pen only descriptor contains touch.
190 */
191 if (features->type != BAMBOO_PT) {
192 /* ISDv4 touch devices at least supports one touch point */
193 if (finger && !features->touch_max)
194 features->touch_max = 1;
195 }
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700196
197 switch (usage->hid) {
198 case HID_GD_X:
199 features->x_max = field->logical_maximum;
200 if (finger) {
201 features->device_type = BTN_TOOL_FINGER;
202 features->x_phy = field->physical_maximum;
203 if (features->type != BAMBOO_PT) {
204 features->unit = field->unit;
205 features->unitExpo = field->unit_exponent;
206 }
207 } else {
208 features->device_type = BTN_TOOL_PEN;
209 }
210 break;
211 case HID_GD_Y:
212 features->y_max = field->logical_maximum;
213 if (finger) {
214 features->y_phy = field->physical_maximum;
215 if (features->type != BAMBOO_PT) {
216 features->unit = field->unit;
217 features->unitExpo = field->unit_exponent;
218 }
219 }
220 break;
221 case HID_DG_TIPPRESSURE:
222 if (pen)
223 features->pressure_max = field->logical_maximum;
224 break;
225 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -0400226
227 if (features->type == HID_GENERIC)
228 wacom_wac_usage_mapping(hdev, field, usage);
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700229}
230
Jason Gereckeb58ba1b2014-12-05 13:37:32 -0800231static void wacom_post_parse_hid(struct hid_device *hdev,
232 struct wacom_features *features)
233{
234 struct wacom *wacom = hid_get_drvdata(hdev);
235 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
236
237 if (features->type == HID_GENERIC) {
238 /* Any last-minute generic device setup */
239 if (features->touch_max > 1) {
240 input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max,
241 INPUT_MT_DIRECT);
242 }
243 }
244}
245
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700246static void wacom_parse_hid(struct hid_device *hdev,
Ping Chengec67bbe2009-12-15 00:35:24 -0800247 struct wacom_features *features)
Ping Cheng545f4e92008-11-24 11:44:27 -0500248{
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700249 struct hid_report_enum *rep_enum;
250 struct hid_report *hreport;
251 int i, j;
Ping Cheng545f4e92008-11-24 11:44:27 -0500252
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700253 /* check features first */
254 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
255 list_for_each_entry(hreport, &rep_enum->report_list, list) {
256 for (i = 0; i < hreport->maxfield; i++) {
257 /* Ignore if report count is out of bounds. */
258 if (hreport->field[i]->report_count < 1)
259 continue;
Ping Cheng545f4e92008-11-24 11:44:27 -0500260
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700261 for (j = 0; j < hreport->field[i]->maxusage; j++) {
262 wacom_feature_mapping(hdev, hreport->field[i],
263 hreport->field[i]->usage + j);
Ping Cheng545f4e92008-11-24 11:44:27 -0500264 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500265 }
266 }
267
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700268 /* now check the input usages */
269 rep_enum = &hdev->report_enum[HID_INPUT_REPORT];
270 list_for_each_entry(hreport, &rep_enum->report_list, list) {
271
272 if (!hreport->maxfield)
273 continue;
274
275 for (i = 0; i < hreport->maxfield; i++)
276 for (j = 0; j < hreport->field[i]->maxusage; j++)
277 wacom_usage_mapping(hdev, hreport->field[i],
278 hreport->field[i]->usage + j);
279 }
Jason Gereckeb58ba1b2014-12-05 13:37:32 -0800280
281 wacom_post_parse_hid(hdev, features);
Ping Cheng545f4e92008-11-24 11:44:27 -0500282}
283
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -0400284static int wacom_hid_set_device_mode(struct hid_device *hdev)
285{
286 struct wacom *wacom = hid_get_drvdata(hdev);
287 struct hid_data *hid_data = &wacom->wacom_wac.hid_data;
288 struct hid_report *r;
289 struct hid_report_enum *re;
290
291 if (hid_data->inputmode < 0)
292 return 0;
293
294 re = &(hdev->report_enum[HID_FEATURE_REPORT]);
295 r = re->report_id_hash[hid_data->inputmode];
296 if (r) {
297 r->field[0]->value[hid_data->inputmode_index] = 2;
298 hid_hw_request(hdev, r, HID_REQ_SET_REPORT);
299 }
300 return 0;
301}
302
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700303static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
304 int length, int mode)
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700305{
306 unsigned char *rep_data;
Jason Gereckefe494bc2012-10-03 17:25:35 -0700307 int error = -ENOMEM, limit = 0;
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700308
Jason Gereckefe494bc2012-10-03 17:25:35 -0700309 rep_data = kzalloc(length, GFP_KERNEL);
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700310 if (!rep_data)
Ping Chengec67bbe2009-12-15 00:35:24 -0800311 return error;
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700312
Jason Gereckefe494bc2012-10-03 17:25:35 -0700313 do {
Chris Bagwell9937c022013-01-23 19:37:34 -0800314 rep_data[0] = report_id;
315 rep_data[1] = mode;
316
Przemo Firszt296b7372014-08-06 14:00:38 -0700317 error = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data,
318 length, 1);
Benjamin Tissoires3cb83152014-07-24 12:47:47 -0700319 if (error >= 0)
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700320 error = wacom_get_report(hdev, HID_FEATURE_REPORT,
Ping Chengc64d8832014-09-10 12:41:04 -0700321 rep_data, length, 1);
Jason Gereckefe494bc2012-10-03 17:25:35 -0700322 } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700323
324 kfree(rep_data);
325
326 return error < 0 ? error : 0;
327}
328
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -0700329static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
330 struct wacom_features *features)
331{
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700332 struct wacom *wacom = hid_get_drvdata(hdev);
333 int ret;
334 u8 rep_data[2];
335
336 switch (features->type) {
337 case GRAPHIRE_BT:
338 rep_data[0] = 0x03;
339 rep_data[1] = 0x00;
Przemo Firszt296b7372014-08-06 14:00:38 -0700340 ret = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 2,
341 3);
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700342
343 if (ret >= 0) {
344 rep_data[0] = speed == 0 ? 0x05 : 0x06;
345 rep_data[1] = 0x00;
346
347 ret = wacom_set_report(hdev, HID_FEATURE_REPORT,
Przemo Firszt296b7372014-08-06 14:00:38 -0700348 rep_data, 2, 3);
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700349
350 if (ret >= 0) {
351 wacom->wacom_wac.bt_high_speed = speed;
352 return 0;
353 }
354 }
355
356 /*
357 * Note that if the raw queries fail, it's not a hard failure
358 * and it is safe to continue
359 */
360 hid_warn(hdev, "failed to poke device, command %d, err %d\n",
361 rep_data[0], ret);
362 break;
Benjamin Tissoires81af7e62014-08-06 13:55:56 -0700363 case INTUOS4WL:
364 if (speed == 1)
365 wacom->wacom_wac.bt_features &= ~0x20;
366 else
367 wacom->wacom_wac.bt_features |= 0x20;
368
369 rep_data[0] = 0x03;
370 rep_data[1] = wacom->wacom_wac.bt_features;
371
Przemo Firszt296b7372014-08-06 14:00:38 -0700372 ret = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 2,
373 1);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -0700374 if (ret >= 0)
375 wacom->wacom_wac.bt_high_speed = speed;
376 break;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700377 }
378
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -0700379 return 0;
380}
381
Jason Gereckefe494bc2012-10-03 17:25:35 -0700382/*
383 * Switch the tablet into its most-capable mode. Wacom tablets are
384 * typically configured to power-up in a mode which sends mouse-like
385 * reports to the OS. To get absolute position, pressure data, etc.
386 * from the tablet, it is necessary to switch the tablet out of this
387 * mode and into one which sends the full range of tablet data.
388 */
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700389static int wacom_query_tablet_data(struct hid_device *hdev,
390 struct wacom_features *features)
Jason Gereckefe494bc2012-10-03 17:25:35 -0700391{
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -0700392 if (hdev->bus == BUS_BLUETOOTH)
393 return wacom_bt_query_tablet_data(hdev, 1, features);
394
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -0400395 if (features->type == HID_GENERIC)
396 return wacom_hid_set_device_mode(hdev);
397
Jason Gereckefe494bc2012-10-03 17:25:35 -0700398 if (features->device_type == BTN_TOOL_FINGER) {
399 if (features->type > TABLETPC) {
400 /* MT Tablet PC touch */
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700401 return wacom_set_device_mode(hdev, 3, 4, 4);
Jason Gereckefe494bc2012-10-03 17:25:35 -0700402 }
Jason Gerecke36d3c512013-09-20 09:47:35 -0700403 else if (features->type == WACOM_24HDT || features->type == CINTIQ_HYBRID) {
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700404 return wacom_set_device_mode(hdev, 18, 3, 2);
Jason Gereckeb1e42792012-10-21 00:38:04 -0700405 }
Ping Cheng500d4162015-01-27 13:30:03 -0800406 else if (features->type == WACOM_27QHDT) {
407 return wacom_set_device_mode(hdev, 131, 3, 2);
408 }
Jason Gereckefe494bc2012-10-03 17:25:35 -0700409 } else if (features->device_type == BTN_TOOL_PEN) {
410 if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700411 return wacom_set_device_mode(hdev, 2, 2, 2);
Jason Gereckefe494bc2012-10-03 17:25:35 -0700412 }
413 }
414
415 return 0;
416}
417
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700418static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
Ping Cheng19635182012-04-29 21:09:18 -0700419 struct wacom_features *features)
Ping Chengec67bbe2009-12-15 00:35:24 -0800420{
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700421 struct wacom *wacom = hid_get_drvdata(hdev);
422 struct usb_interface *intf = wacom->intf;
Ping Chengec67bbe2009-12-15 00:35:24 -0800423
Henrik Rydbergfed87e62010-09-05 12:25:11 -0700424 /* default features */
Ping Chengec67bbe2009-12-15 00:35:24 -0800425 features->device_type = BTN_TOOL_PEN;
Henrik Rydbergfed87e62010-09-05 12:25:11 -0700426 features->x_fuzz = 4;
427 features->y_fuzz = 4;
428 features->pressure_fuzz = 0;
429 features->distance_fuzz = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -0800430
Chris Bagwelld3825d52012-03-25 23:26:11 -0700431 /*
432 * The wireless device HID is basic and layout conflicts with
433 * other tablets (monitor and touch interface can look like pen).
434 * Skip the query for this type and modify defaults based on
435 * interface number.
436 */
437 if (features->type == WIRELESS) {
438 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
439 features->device_type = 0;
440 } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) {
Ping Chengadad0042012-06-28 16:48:17 -0700441 features->device_type = BTN_TOOL_FINGER;
Chris Bagwelld3825d52012-03-25 23:26:11 -0700442 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
443 }
444 }
445
Ping Cheng19635182012-04-29 21:09:18 -0700446 /* only devices that support touch need to retrieve the info */
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700447 if (features->type < BAMBOO_PT)
448 return;
Ping Chengec67bbe2009-12-15 00:35:24 -0800449
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -0700450 wacom_parse_hid(hdev, features);
Ping Chengec67bbe2009-12-15 00:35:24 -0800451}
452
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700453struct wacom_hdev_data {
Ping Cheng4492eff2010-03-19 22:18:15 -0700454 struct list_head list;
455 struct kref kref;
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700456 struct hid_device *dev;
Ping Cheng4492eff2010-03-19 22:18:15 -0700457 struct wacom_shared shared;
458};
459
460static LIST_HEAD(wacom_udev_list);
461static DEFINE_MUTEX(wacom_udev_list_lock);
462
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700463static bool wacom_are_sibling(struct hid_device *hdev,
464 struct hid_device *sibling)
Jason Gereckeaea2bf62012-10-21 00:38:03 -0700465{
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700466 struct wacom *wacom = hid_get_drvdata(hdev);
467 struct wacom_features *features = &wacom->wacom_wac.features;
468 int vid = features->oVid;
469 int pid = features->oPid;
470 int n1,n2;
Jason Gereckeaea2bf62012-10-21 00:38:03 -0700471
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700472 if (vid == 0 && pid == 0) {
473 vid = hdev->vendor;
474 pid = hdev->product;
Jason Gereckeaea2bf62012-10-21 00:38:03 -0700475 }
476
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700477 if (vid != sibling->vendor || pid != sibling->product)
478 return false;
479
480 /* Compare the physical path. */
481 n1 = strrchr(hdev->phys, '.') - hdev->phys;
482 n2 = strrchr(sibling->phys, '.') - sibling->phys;
483 if (n1 != n2 || n1 <= 0 || n2 <= 0)
484 return false;
485
486 return !strncmp(hdev->phys, sibling->phys, n1);
Jason Gereckeaea2bf62012-10-21 00:38:03 -0700487}
488
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700489static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev)
Ping Cheng4492eff2010-03-19 22:18:15 -0700490{
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700491 struct wacom_hdev_data *data;
Ping Cheng4492eff2010-03-19 22:18:15 -0700492
493 list_for_each_entry(data, &wacom_udev_list, list) {
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700494 if (wacom_are_sibling(hdev, data->dev)) {
Ping Cheng4492eff2010-03-19 22:18:15 -0700495 kref_get(&data->kref);
496 return data;
497 }
498 }
499
500 return NULL;
501}
502
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700503static int wacom_add_shared_data(struct hid_device *hdev)
Ping Cheng4492eff2010-03-19 22:18:15 -0700504{
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700505 struct wacom *wacom = hid_get_drvdata(hdev);
506 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
507 struct wacom_hdev_data *data;
Ping Cheng4492eff2010-03-19 22:18:15 -0700508 int retval = 0;
509
510 mutex_lock(&wacom_udev_list_lock);
511
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700512 data = wacom_get_hdev_data(hdev);
Ping Cheng4492eff2010-03-19 22:18:15 -0700513 if (!data) {
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700514 data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
Ping Cheng4492eff2010-03-19 22:18:15 -0700515 if (!data) {
516 retval = -ENOMEM;
517 goto out;
518 }
519
520 kref_init(&data->kref);
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700521 data->dev = hdev;
Ping Cheng4492eff2010-03-19 22:18:15 -0700522 list_add_tail(&data->list, &wacom_udev_list);
523 }
524
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700525 wacom_wac->shared = &data->shared;
Ping Cheng4492eff2010-03-19 22:18:15 -0700526
527out:
528 mutex_unlock(&wacom_udev_list_lock);
529 return retval;
530}
531
532static void wacom_release_shared_data(struct kref *kref)
533{
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700534 struct wacom_hdev_data *data =
535 container_of(kref, struct wacom_hdev_data, kref);
Ping Cheng4492eff2010-03-19 22:18:15 -0700536
537 mutex_lock(&wacom_udev_list_lock);
538 list_del(&data->list);
539 mutex_unlock(&wacom_udev_list_lock);
540
541 kfree(data);
542}
543
544static void wacom_remove_shared_data(struct wacom_wac *wacom)
545{
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700546 struct wacom_hdev_data *data;
Ping Cheng4492eff2010-03-19 22:18:15 -0700547
548 if (wacom->shared) {
Benjamin Tissoires4451e082014-07-24 13:01:05 -0700549 data = container_of(wacom->shared, struct wacom_hdev_data, shared);
Ping Cheng4492eff2010-03-19 22:18:15 -0700550 kref_put(&data->kref, wacom_release_shared_data);
551 wacom->shared = NULL;
552 }
553}
554
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700555static int wacom_led_control(struct wacom *wacom)
556{
557 unsigned char *buf;
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700558 int retval;
Ping Cheng912ca212014-09-10 12:41:31 -0700559 unsigned char report_id = WAC_CMD_LED_CONTROL;
560 int buf_size = 9;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700561
Ping Cheng912ca212014-09-10 12:41:31 -0700562 if (wacom->wacom_wac.pid) { /* wireless connected */
563 report_id = WAC_CMD_WL_LED_CONTROL;
564 buf_size = 13;
565 }
566 buf = kzalloc(buf_size, GFP_KERNEL);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700567 if (!buf)
568 return -ENOMEM;
569
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700570 if (wacom->wacom_wac.features.type >= INTUOS5S &&
Ping Cheng9a35c412013-09-20 09:51:56 -0700571 wacom->wacom_wac.features.type <= INTUOSPL) {
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700572 /*
573 * Touch Ring and crop mark LED luminance may take on
574 * one of four values:
575 * 0 = Low; 1 = Medium; 2 = High; 3 = Off
576 */
577 int ring_led = wacom->led.select[0] & 0x03;
578 int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03;
579 int crop_lum = 0;
Ping Cheng912ca212014-09-10 12:41:31 -0700580 unsigned char led_bits = (crop_lum << 4) | (ring_lum << 2) | (ring_led);
Ping Cheng09e7d942011-10-04 23:51:14 -0700581
Ping Cheng912ca212014-09-10 12:41:31 -0700582 buf[0] = report_id;
583 if (wacom->wacom_wac.pid) {
584 wacom_get_report(wacom->hdev, HID_FEATURE_REPORT,
585 buf, buf_size, WAC_CMD_RETRIES);
586 buf[0] = report_id;
587 buf[4] = led_bits;
588 } else
589 buf[1] = led_bits;
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700590 }
591 else {
592 int led = wacom->led.select[0] | 0x4;
Ping Cheng09e7d942011-10-04 23:51:14 -0700593
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700594 if (wacom->wacom_wac.features.type == WACOM_21UX2 ||
595 wacom->wacom_wac.features.type == WACOM_24HD)
596 led |= (wacom->led.select[1] << 4) | 0x40;
597
Ping Cheng912ca212014-09-10 12:41:31 -0700598 buf[0] = report_id;
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700599 buf[1] = led;
600 buf[2] = wacom->led.llv;
601 buf[3] = wacom->led.hlv;
602 buf[4] = wacom->led.img_lum;
603 }
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700604
Ping Cheng912ca212014-09-10 12:41:31 -0700605 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size,
Przemo Firszt296b7372014-08-06 14:00:38 -0700606 WAC_CMD_RETRIES);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700607 kfree(buf);
608
609 return retval;
610}
611
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700612static int wacom_led_putimage(struct wacom *wacom, int button_id, u8 xfer_id,
613 const unsigned len, const void *img)
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700614{
615 unsigned char *buf;
616 int i, retval;
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700617 const unsigned chunk_len = len / 4; /* 4 chunks are needed to be sent */
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700618
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700619 buf = kzalloc(chunk_len + 3 , GFP_KERNEL);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700620 if (!buf)
621 return -ENOMEM;
622
623 /* Send 'start' command */
624 buf[0] = WAC_CMD_ICON_START;
625 buf[1] = 1;
Przemo Firszt296b7372014-08-06 14:00:38 -0700626 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2,
627 WAC_CMD_RETRIES);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700628 if (retval < 0)
629 goto out;
630
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700631 buf[0] = xfer_id;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700632 buf[1] = button_id & 0x07;
633 for (i = 0; i < 4; i++) {
634 buf[2] = i;
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700635 memcpy(buf + 3, img + i * chunk_len, chunk_len);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700636
Benjamin Tissoires27b20a92014-07-24 12:56:22 -0700637 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT,
Przemo Firszt296b7372014-08-06 14:00:38 -0700638 buf, chunk_len + 3, WAC_CMD_RETRIES);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700639 if (retval < 0)
640 break;
641 }
642
643 /* Send 'stop' */
644 buf[0] = WAC_CMD_ICON_START;
645 buf[1] = 0;
Przemo Firszt296b7372014-08-06 14:00:38 -0700646 wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2,
647 WAC_CMD_RETRIES);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700648
649out:
650 kfree(buf);
651 return retval;
652}
653
Ping Cheng09e7d942011-10-04 23:51:14 -0700654static ssize_t wacom_led_select_store(struct device *dev, int set_id,
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700655 const char *buf, size_t count)
656{
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700657 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
Benjamin Tissoires29b47392014-07-24 12:52:23 -0700658 struct wacom *wacom = hid_get_drvdata(hdev);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700659 unsigned int id;
660 int err;
661
662 err = kstrtouint(buf, 10, &id);
663 if (err)
664 return err;
665
666 mutex_lock(&wacom->lock);
667
Ping Cheng09e7d942011-10-04 23:51:14 -0700668 wacom->led.select[set_id] = id & 0x3;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700669 err = wacom_led_control(wacom);
670
671 mutex_unlock(&wacom->lock);
672
673 return err < 0 ? err : count;
674}
675
Ping Cheng09e7d942011-10-04 23:51:14 -0700676#define DEVICE_LED_SELECT_ATTR(SET_ID) \
677static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
678 struct device_attribute *attr, const char *buf, size_t count) \
679{ \
680 return wacom_led_select_store(dev, SET_ID, buf, count); \
681} \
Ping Cheng04c59ab2011-10-04 23:51:49 -0700682static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
683 struct device_attribute *attr, char *buf) \
684{ \
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700685 struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
Benjamin Tissoires29b47392014-07-24 12:52:23 -0700686 struct wacom *wacom = hid_get_drvdata(hdev); \
Ping Cheng37449ad2014-09-10 12:40:30 -0700687 return scnprintf(buf, PAGE_SIZE, "%d\n", \
688 wacom->led.select[SET_ID]); \
Ping Cheng04c59ab2011-10-04 23:51:49 -0700689} \
Ping Chenge0984bc2014-09-10 12:40:05 -0700690static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
Ping Cheng04c59ab2011-10-04 23:51:49 -0700691 wacom_led##SET_ID##_select_show, \
Ping Cheng09e7d942011-10-04 23:51:14 -0700692 wacom_led##SET_ID##_select_store)
693
694DEVICE_LED_SELECT_ATTR(0);
695DEVICE_LED_SELECT_ATTR(1);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700696
697static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
698 const char *buf, size_t count)
699{
700 unsigned int value;
701 int err;
702
703 err = kstrtouint(buf, 10, &value);
704 if (err)
705 return err;
706
707 mutex_lock(&wacom->lock);
708
709 *dest = value & 0x7f;
710 err = wacom_led_control(wacom);
711
712 mutex_unlock(&wacom->lock);
713
714 return err < 0 ? err : count;
715}
716
717#define DEVICE_LUMINANCE_ATTR(name, field) \
718static ssize_t wacom_##name##_luminance_store(struct device *dev, \
719 struct device_attribute *attr, const char *buf, size_t count) \
720{ \
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700721 struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
Benjamin Tissoires29b47392014-07-24 12:52:23 -0700722 struct wacom *wacom = hid_get_drvdata(hdev); \
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700723 \
724 return wacom_luminance_store(wacom, &wacom->led.field, \
725 buf, count); \
726} \
Ping Cheng37449ad2014-09-10 12:40:30 -0700727static ssize_t wacom_##name##_luminance_show(struct device *dev, \
728 struct device_attribute *attr, char *buf) \
729{ \
730 struct wacom *wacom = dev_get_drvdata(dev); \
731 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
732} \
Ping Chenge0984bc2014-09-10 12:40:05 -0700733static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
Ping Cheng37449ad2014-09-10 12:40:30 -0700734 wacom_##name##_luminance_show, \
735 wacom_##name##_luminance_store)
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700736
737DEVICE_LUMINANCE_ATTR(status0, llv);
738DEVICE_LUMINANCE_ATTR(status1, hlv);
739DEVICE_LUMINANCE_ATTR(buttons, img_lum);
740
741static ssize_t wacom_button_image_store(struct device *dev, int button_id,
742 const char *buf, size_t count)
743{
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700744 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
Benjamin Tissoires29b47392014-07-24 12:52:23 -0700745 struct wacom *wacom = hid_get_drvdata(hdev);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700746 int err;
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700747 unsigned len;
748 u8 xfer_id;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700749
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700750 if (hdev->bus == BUS_BLUETOOTH) {
751 len = 256;
752 xfer_id = WAC_CMD_ICON_BT_XFER;
753 } else {
754 len = 1024;
755 xfer_id = WAC_CMD_ICON_XFER;
756 }
757
758 if (count != len)
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700759 return -EINVAL;
760
761 mutex_lock(&wacom->lock);
762
Benjamin Tissoires849e2f02014-08-06 13:58:25 -0700763 err = wacom_led_putimage(wacom, button_id, xfer_id, len, buf);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700764
765 mutex_unlock(&wacom->lock);
766
767 return err < 0 ? err : count;
768}
769
770#define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
771static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
772 struct device_attribute *attr, const char *buf, size_t count) \
773{ \
774 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
775} \
Ping Chenge0984bc2014-09-10 12:40:05 -0700776static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700777 NULL, wacom_btnimg##BUTTON_ID##_store)
778
779DEVICE_BTNIMG_ATTR(0);
780DEVICE_BTNIMG_ATTR(1);
781DEVICE_BTNIMG_ATTR(2);
782DEVICE_BTNIMG_ATTR(3);
783DEVICE_BTNIMG_ATTR(4);
784DEVICE_BTNIMG_ATTR(5);
785DEVICE_BTNIMG_ATTR(6);
786DEVICE_BTNIMG_ATTR(7);
787
Ping Cheng09e7d942011-10-04 23:51:14 -0700788static struct attribute *cintiq_led_attrs[] = {
789 &dev_attr_status_led0_select.attr,
790 &dev_attr_status_led1_select.attr,
791 NULL
792};
793
794static struct attribute_group cintiq_led_attr_group = {
795 .name = "wacom_led",
796 .attrs = cintiq_led_attrs,
797};
798
799static struct attribute *intuos4_led_attrs[] = {
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700800 &dev_attr_status0_luminance.attr,
801 &dev_attr_status1_luminance.attr,
Ping Cheng09e7d942011-10-04 23:51:14 -0700802 &dev_attr_status_led0_select.attr,
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700803 &dev_attr_buttons_luminance.attr,
804 &dev_attr_button0_rawimg.attr,
805 &dev_attr_button1_rawimg.attr,
806 &dev_attr_button2_rawimg.attr,
807 &dev_attr_button3_rawimg.attr,
808 &dev_attr_button4_rawimg.attr,
809 &dev_attr_button5_rawimg.attr,
810 &dev_attr_button6_rawimg.attr,
811 &dev_attr_button7_rawimg.attr,
812 NULL
813};
814
Ping Cheng09e7d942011-10-04 23:51:14 -0700815static struct attribute_group intuos4_led_attr_group = {
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700816 .name = "wacom_led",
Ping Cheng09e7d942011-10-04 23:51:14 -0700817 .attrs = intuos4_led_attrs,
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700818};
819
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700820static struct attribute *intuos5_led_attrs[] = {
821 &dev_attr_status0_luminance.attr,
822 &dev_attr_status_led0_select.attr,
823 NULL
824};
825
826static struct attribute_group intuos5_led_attr_group = {
827 .name = "wacom_led",
828 .attrs = intuos5_led_attrs,
829};
830
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700831static int wacom_initialize_leds(struct wacom *wacom)
832{
833 int error;
834
Ping Cheng09e7d942011-10-04 23:51:14 -0700835 /* Initialize default values */
836 switch (wacom->wacom_wac.features.type) {
Jason Gereckea19fc982012-06-12 00:27:53 -0700837 case INTUOS4S:
Ping Cheng09e7d942011-10-04 23:51:14 -0700838 case INTUOS4:
Benjamin Tissoires81af7e62014-08-06 13:55:56 -0700839 case INTUOS4WL:
Ping Cheng09e7d942011-10-04 23:51:14 -0700840 case INTUOS4L:
841 wacom->led.select[0] = 0;
842 wacom->led.select[1] = 0;
Ping Chengf4fa9a62011-10-04 23:49:42 -0700843 wacom->led.llv = 10;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700844 wacom->led.hlv = 20;
845 wacom->led.img_lum = 10;
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700846 error = sysfs_create_group(&wacom->hdev->dev.kobj,
Ping Cheng09e7d942011-10-04 23:51:14 -0700847 &intuos4_led_attr_group);
848 break;
849
Jason Gerecke246835f2011-12-12 00:12:04 -0800850 case WACOM_24HD:
Ping Cheng09e7d942011-10-04 23:51:14 -0700851 case WACOM_21UX2:
852 wacom->led.select[0] = 0;
853 wacom->led.select[1] = 0;
854 wacom->led.llv = 0;
855 wacom->led.hlv = 0;
856 wacom->led.img_lum = 0;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700857
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700858 error = sysfs_create_group(&wacom->hdev->dev.kobj,
Ping Cheng09e7d942011-10-04 23:51:14 -0700859 &cintiq_led_attr_group);
860 break;
861
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700862 case INTUOS5S:
863 case INTUOS5:
864 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -0700865 case INTUOSPS:
866 case INTUOSPM:
867 case INTUOSPL:
Ping Chengc2b0c272013-09-20 09:50:14 -0700868 if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) {
869 wacom->led.select[0] = 0;
870 wacom->led.select[1] = 0;
871 wacom->led.llv = 32;
872 wacom->led.hlv = 0;
873 wacom->led.img_lum = 0;
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700874
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700875 error = sysfs_create_group(&wacom->hdev->dev.kobj,
Ping Chengc2b0c272013-09-20 09:50:14 -0700876 &intuos5_led_attr_group);
877 } else
878 return 0;
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700879 break;
880
Ping Cheng09e7d942011-10-04 23:51:14 -0700881 default:
882 return 0;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700883 }
884
Ping Cheng09e7d942011-10-04 23:51:14 -0700885 if (error) {
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700886 hid_err(wacom->hdev,
Ping Cheng09e7d942011-10-04 23:51:14 -0700887 "cannot create sysfs group err: %d\n", error);
888 return error;
889 }
890 wacom_led_control(wacom);
Benjamin Tissoiresc757cba2014-07-24 13:16:17 -0700891 wacom->led_initialized = true;
Ping Cheng09e7d942011-10-04 23:51:14 -0700892
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700893 return 0;
894}
895
896static void wacom_destroy_leds(struct wacom *wacom)
897{
Benjamin Tissoiresc757cba2014-07-24 13:16:17 -0700898 if (!wacom->led_initialized)
899 return;
900
901 wacom->led_initialized = false;
902
Ping Cheng09e7d942011-10-04 23:51:14 -0700903 switch (wacom->wacom_wac.features.type) {
Jason Gereckea19fc982012-06-12 00:27:53 -0700904 case INTUOS4S:
Ping Cheng09e7d942011-10-04 23:51:14 -0700905 case INTUOS4:
Benjamin Tissoires81af7e62014-08-06 13:55:56 -0700906 case INTUOS4WL:
Ping Cheng09e7d942011-10-04 23:51:14 -0700907 case INTUOS4L:
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700908 sysfs_remove_group(&wacom->hdev->dev.kobj,
Ping Cheng09e7d942011-10-04 23:51:14 -0700909 &intuos4_led_attr_group);
910 break;
911
Jason Gerecke246835f2011-12-12 00:12:04 -0800912 case WACOM_24HD:
Ping Cheng09e7d942011-10-04 23:51:14 -0700913 case WACOM_21UX2:
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700914 sysfs_remove_group(&wacom->hdev->dev.kobj,
Ping Cheng09e7d942011-10-04 23:51:14 -0700915 &cintiq_led_attr_group);
916 break;
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700917
918 case INTUOS5S:
919 case INTUOS5:
920 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -0700921 case INTUOSPS:
922 case INTUOSPM:
923 case INTUOSPL:
Ping Chengc2b0c272013-09-20 09:50:14 -0700924 if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN)
Benjamin Tissoiresc31a4082014-07-24 12:59:45 -0700925 sysfs_remove_group(&wacom->hdev->dev.kobj,
Ping Chengc2b0c272013-09-20 09:50:14 -0700926 &intuos5_led_attr_group);
Jason Gerecke9b5b95d2012-04-03 15:50:37 -0700927 break;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700928 }
929}
930
Chris Bagwella1d552c2012-03-25 23:26:30 -0700931static enum power_supply_property wacom_battery_props[] = {
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -0700932 POWER_SUPPLY_PROP_STATUS,
Bastien Nocera6e2a6e82013-10-15 23:33:00 -0700933 POWER_SUPPLY_PROP_SCOPE,
Chris Bagwella1d552c2012-03-25 23:26:30 -0700934 POWER_SUPPLY_PROP_CAPACITY
935};
936
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -0700937static enum power_supply_property wacom_ac_props[] = {
938 POWER_SUPPLY_PROP_PRESENT,
939 POWER_SUPPLY_PROP_ONLINE,
940 POWER_SUPPLY_PROP_SCOPE,
941};
942
Chris Bagwella1d552c2012-03-25 23:26:30 -0700943static int wacom_battery_get_property(struct power_supply *psy,
944 enum power_supply_property psp,
945 union power_supply_propval *val)
946{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100947 struct wacom *wacom = power_supply_get_drvdata(psy);
Chris Bagwella1d552c2012-03-25 23:26:30 -0700948 int ret = 0;
949
950 switch (psp) {
Bastien Nocera6e2a6e82013-10-15 23:33:00 -0700951 case POWER_SUPPLY_PROP_SCOPE:
952 val->intval = POWER_SUPPLY_SCOPE_DEVICE;
953 break;
Chris Bagwella1d552c2012-03-25 23:26:30 -0700954 case POWER_SUPPLY_PROP_CAPACITY:
955 val->intval =
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -0700956 wacom->wacom_wac.battery_capacity;
957 break;
958 case POWER_SUPPLY_PROP_STATUS:
959 if (wacom->wacom_wac.bat_charging)
960 val->intval = POWER_SUPPLY_STATUS_CHARGING;
961 else if (wacom->wacom_wac.battery_capacity == 100 &&
962 wacom->wacom_wac.ps_connected)
963 val->intval = POWER_SUPPLY_STATUS_FULL;
964 else
965 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
Chris Bagwella1d552c2012-03-25 23:26:30 -0700966 break;
967 default:
968 ret = -EINVAL;
969 break;
970 }
971
972 return ret;
973}
974
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -0700975static int wacom_ac_get_property(struct power_supply *psy,
976 enum power_supply_property psp,
977 union power_supply_propval *val)
978{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100979 struct wacom *wacom = power_supply_get_drvdata(psy);
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -0700980 int ret = 0;
981
982 switch (psp) {
983 case POWER_SUPPLY_PROP_PRESENT:
984 /* fall through */
985 case POWER_SUPPLY_PROP_ONLINE:
986 val->intval = wacom->wacom_wac.ps_connected;
987 break;
988 case POWER_SUPPLY_PROP_SCOPE:
989 val->intval = POWER_SUPPLY_SCOPE_DEVICE;
990 break;
991 default:
992 ret = -EINVAL;
993 break;
994 }
995 return ret;
996}
997
Chris Bagwella1d552c2012-03-25 23:26:30 -0700998static int wacom_initialize_battery(struct wacom *wacom)
999{
Benjamin Tissoiresd70420b2014-07-25 17:31:51 -07001000 static atomic_t battery_no = ATOMIC_INIT(0);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001001 struct power_supply_config psy_cfg = { .drv_data = wacom, };
Benjamin Tissoiresd70420b2014-07-25 17:31:51 -07001002 unsigned long n;
Chris Bagwella1d552c2012-03-25 23:26:30 -07001003
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001004 if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001005 struct power_supply_desc *bat_desc = &wacom->battery_desc;
1006 struct power_supply_desc *ac_desc = &wacom->ac_desc;
Benjamin Tissoiresd70420b2014-07-25 17:31:51 -07001007 n = atomic_inc_return(&battery_no) - 1;
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -07001008
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001009 bat_desc->properties = wacom_battery_props;
1010 bat_desc->num_properties = ARRAY_SIZE(wacom_battery_props);
1011 bat_desc->get_property = wacom_battery_get_property;
Benjamin Tissoiresd70420b2014-07-25 17:31:51 -07001012 sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001013 bat_desc->name = wacom->wacom_wac.bat_name;
1014 bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
1015 bat_desc->use_for_apm = 0;
Chris Bagwella1d552c2012-03-25 23:26:30 -07001016
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001017 ac_desc->properties = wacom_ac_props;
1018 ac_desc->num_properties = ARRAY_SIZE(wacom_ac_props);
1019 ac_desc->get_property = wacom_ac_get_property;
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -07001020 sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001021 ac_desc->name = wacom->wacom_wac.ac_name;
1022 ac_desc->type = POWER_SUPPLY_TYPE_MAINS;
1023 ac_desc->use_for_apm = 0;
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -07001024
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001025 wacom->battery = power_supply_register(&wacom->hdev->dev,
1026 &wacom->battery_desc, &psy_cfg);
1027 if (IS_ERR(wacom->battery))
1028 return PTR_ERR(wacom->battery);
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001029
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001030 power_supply_powers(wacom->battery, &wacom->hdev->dev);
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -07001031
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001032 wacom->ac = power_supply_register(&wacom->hdev->dev,
1033 &wacom->ac_desc,
1034 &psy_cfg);
1035 if (IS_ERR(wacom->ac)) {
1036 power_supply_unregister(wacom->battery);
1037 return PTR_ERR(wacom->ac);
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -07001038 }
1039
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001040 power_supply_powers(wacom->ac, &wacom->hdev->dev);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001041 }
1042
Benjamin Tissoires7dbd2292014-07-25 17:32:41 -07001043 return 0;
Chris Bagwella1d552c2012-03-25 23:26:30 -07001044}
1045
1046static void wacom_destroy_battery(struct wacom *wacom)
1047{
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001048 if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +01001049 wacom->battery) {
1050 power_supply_unregister(wacom->battery);
1051 wacom->battery = NULL;
1052 power_supply_unregister(wacom->ac);
1053 wacom->ac = NULL;
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001054 }
Chris Bagwella1d552c2012-03-25 23:26:30 -07001055}
1056
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001057static ssize_t wacom_show_speed(struct device *dev,
1058 struct device_attribute
1059 *attr, char *buf)
1060{
1061 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1062 struct wacom *wacom = hid_get_drvdata(hdev);
1063
1064 return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed);
1065}
1066
1067static ssize_t wacom_store_speed(struct device *dev,
1068 struct device_attribute *attr,
1069 const char *buf, size_t count)
1070{
1071 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1072 struct wacom *wacom = hid_get_drvdata(hdev);
1073 u8 new_speed;
1074
1075 if (kstrtou8(buf, 0, &new_speed))
1076 return -EINVAL;
1077
1078 if (new_speed != 0 && new_speed != 1)
1079 return -EINVAL;
1080
1081 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features);
1082
1083 return count;
1084}
1085
Ping Chenge0984bc2014-09-10 12:40:05 -07001086static DEVICE_ATTR(speed, DEV_ATTR_RW_PERM,
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001087 wacom_show_speed, wacom_store_speed);
1088
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001089static struct input_dev *wacom_allocate_input(struct wacom *wacom)
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001090{
1091 struct input_dev *input_dev;
Benjamin Tissoiresb6c79f22014-07-24 13:00:03 -07001092 struct hid_device *hdev = wacom->hdev;
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001093 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001094
1095 input_dev = input_allocate_device();
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001096 if (!input_dev)
1097 return NULL;
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001098
1099 input_dev->name = wacom_wac->name;
Benjamin Tissoiresb6c79f22014-07-24 13:00:03 -07001100 input_dev->phys = hdev->phys;
1101 input_dev->dev.parent = &hdev->dev;
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001102 input_dev->open = wacom_open;
1103 input_dev->close = wacom_close;
Benjamin Tissoiresb6c79f22014-07-24 13:00:03 -07001104 input_dev->uniq = hdev->uniq;
1105 input_dev->id.bustype = hdev->bus;
1106 input_dev->id.vendor = hdev->vendor;
Benjamin Tissoires12969e32014-09-11 13:14:04 -04001107 input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product;
Benjamin Tissoiresb6c79f22014-07-24 13:00:03 -07001108 input_dev->id.version = hdev->version;
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001109 input_set_drvdata(input_dev, wacom);
1110
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001111 return input_dev;
1112}
1113
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001114static void wacom_free_inputs(struct wacom *wacom)
Benjamin Tissoires008f4d92014-07-24 12:51:26 -07001115{
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001116 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1117
1118 if (wacom_wac->input)
1119 input_free_device(wacom_wac->input);
1120 if (wacom_wac->pad_input)
1121 input_free_device(wacom_wac->pad_input);
1122 wacom_wac->input = NULL;
1123 wacom_wac->pad_input = NULL;
1124}
1125
1126static int wacom_allocate_inputs(struct wacom *wacom)
1127{
1128 struct input_dev *input_dev, *pad_input_dev;
1129 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1130
1131 input_dev = wacom_allocate_input(wacom);
1132 pad_input_dev = wacom_allocate_input(wacom);
1133 if (!input_dev || !pad_input_dev) {
1134 wacom_free_inputs(wacom);
1135 return -ENOMEM;
1136 }
1137
1138 wacom_wac->input = input_dev;
1139 wacom_wac->pad_input = pad_input_dev;
1140 wacom_wac->pad_input->name = wacom_wac->pad_name;
1141
1142 return 0;
1143}
1144
1145static void wacom_clean_inputs(struct wacom *wacom)
1146{
1147 if (wacom->wacom_wac.input) {
1148 if (wacom->wacom_wac.input_registered)
1149 input_unregister_device(wacom->wacom_wac.input);
1150 else
1151 input_free_device(wacom->wacom_wac.input);
1152 }
1153 if (wacom->wacom_wac.pad_input) {
Ping Cheng954df6a2014-11-20 16:31:12 -08001154 if (wacom->wacom_wac.pad_registered)
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001155 input_unregister_device(wacom->wacom_wac.pad_input);
1156 else
1157 input_free_device(wacom->wacom_wac.pad_input);
1158 }
Benjamin Tissoires008f4d92014-07-24 12:51:26 -07001159 wacom->wacom_wac.input = NULL;
1160 wacom->wacom_wac.pad_input = NULL;
Ping Cheng912ca212014-09-10 12:41:31 -07001161 wacom_destroy_leds(wacom);
Benjamin Tissoires008f4d92014-07-24 12:51:26 -07001162}
1163
1164static int wacom_register_inputs(struct wacom *wacom)
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001165{
1166 struct input_dev *input_dev, *pad_input_dev;
1167 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1168 int error;
1169
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001170 input_dev = wacom_wac->input;
1171 pad_input_dev = wacom_wac->pad_input;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001172
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001173 if (!input_dev || !pad_input_dev)
1174 return -EINVAL;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001175
Ping Cheng30ebc1a2014-11-18 13:29:16 -08001176 error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac);
1177 if (!error) {
1178 error = input_register_device(input_dev);
1179 if (error)
1180 return error;
Ping Cheng954df6a2014-11-20 16:31:12 -08001181 wacom_wac->input_registered = true;
Ping Cheng30ebc1a2014-11-18 13:29:16 -08001182 }
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001183
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001184 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
1185 if (error) {
1186 /* no pad in use on this interface */
1187 input_free_device(pad_input_dev);
1188 wacom_wac->pad_input = NULL;
1189 pad_input_dev = NULL;
1190 } else {
1191 error = input_register_device(pad_input_dev);
1192 if (error)
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001193 goto fail_register_pad_input;
Ping Cheng954df6a2014-11-20 16:31:12 -08001194 wacom_wac->pad_registered = true;
Ping Cheng912ca212014-09-10 12:41:31 -07001195
1196 error = wacom_initialize_leds(wacom);
1197 if (error)
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001198 goto fail_leds;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001199 }
1200
Ping Cheng19635182012-04-29 21:09:18 -07001201 return 0;
1202
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001203fail_leds:
Ping Cheng912ca212014-09-10 12:41:31 -07001204 input_unregister_device(pad_input_dev);
1205 pad_input_dev = NULL;
Ping Cheng954df6a2014-11-20 16:31:12 -08001206 wacom_wac->pad_registered = false;
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001207fail_register_pad_input:
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001208 input_unregister_device(input_dev);
Ping Cheng19635182012-04-29 21:09:18 -07001209 wacom_wac->input = NULL;
Ping Cheng954df6a2014-11-20 16:31:12 -08001210 wacom_wac->input_registered = false;
Chris Bagwell3aac0ef2012-03-25 23:25:45 -07001211 return error;
1212}
1213
Chris Bagwell16bf2882012-03-25 23:26:20 -07001214static void wacom_wireless_work(struct work_struct *work)
1215{
1216 struct wacom *wacom = container_of(work, struct wacom, work);
1217 struct usb_device *usbdev = wacom->usbdev;
1218 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001219 struct hid_device *hdev1, *hdev2;
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001220 struct wacom *wacom1, *wacom2;
1221 struct wacom_wac *wacom_wac1, *wacom_wac2;
1222 int error;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001223
1224 /*
1225 * Regardless if this is a disconnect or a new tablet,
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001226 * remove any existing input and battery devices.
Chris Bagwell16bf2882012-03-25 23:26:20 -07001227 */
1228
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001229 wacom_destroy_battery(wacom);
1230
Chris Bagwell16bf2882012-03-25 23:26:20 -07001231 /* Stylus interface */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001232 hdev1 = usb_get_intfdata(usbdev->config->interface[1]);
1233 wacom1 = hid_get_drvdata(hdev1);
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001234 wacom_wac1 = &(wacom1->wacom_wac);
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001235 wacom_clean_inputs(wacom1);
Chris Bagwell16bf2882012-03-25 23:26:20 -07001236
1237 /* Touch interface */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001238 hdev2 = usb_get_intfdata(usbdev->config->interface[2]);
1239 wacom2 = hid_get_drvdata(hdev2);
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001240 wacom_wac2 = &(wacom2->wacom_wac);
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001241 wacom_clean_inputs(wacom2);
Chris Bagwell16bf2882012-03-25 23:26:20 -07001242
1243 if (wacom_wac->pid == 0) {
Benjamin Tissoirese2114ce2014-07-24 13:01:56 -07001244 hid_info(wacom->hdev, "wireless tablet disconnected\n");
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001245 wacom_wac1->shared->type = 0;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001246 } else {
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001247 const struct hid_device_id *id = wacom_ids;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001248
Benjamin Tissoirese2114ce2014-07-24 13:01:56 -07001249 hid_info(wacom->hdev, "wireless tablet connected with PID %x\n",
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -07001250 wacom_wac->pid);
Chris Bagwell16bf2882012-03-25 23:26:20 -07001251
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001252 while (id->bus) {
1253 if (id->vendor == USB_VENDOR_ID_WACOM &&
1254 id->product == wacom_wac->pid)
Chris Bagwell16bf2882012-03-25 23:26:20 -07001255 break;
1256 id++;
1257 }
1258
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001259 if (!id->bus) {
Benjamin Tissoirese2114ce2014-07-24 13:01:56 -07001260 hid_info(wacom->hdev, "ignoring unknown PID.\n");
Chris Bagwell16bf2882012-03-25 23:26:20 -07001261 return;
1262 }
1263
1264 /* Stylus interface */
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001265 wacom_wac1->features =
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001266 *((struct wacom_features *)id->driver_data);
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001267 wacom_wac1->features.device_type = BTN_TOOL_PEN;
Ping Cheng57bcfce2013-10-15 23:44:00 -07001268 snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen",
1269 wacom_wac1->features.name);
Benjamin Tissoires008f4d92014-07-24 12:51:26 -07001270 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1271 wacom_wac1->features.name);
Ping Cheng961794a2013-12-05 12:54:53 -08001272 wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
1273 wacom_wac1->shared->type = wacom_wac1->features.type;
Ping Cheng912ca212014-09-10 12:41:31 -07001274 wacom_wac1->pid = wacom_wac->pid;
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001275 error = wacom_allocate_inputs(wacom1) ||
1276 wacom_register_inputs(wacom1);
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001277 if (error)
Ping Cheng57bcfce2013-10-15 23:44:00 -07001278 goto fail;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001279
1280 /* Touch interface */
Ping Chengb5fd2a32013-11-25 18:44:55 -08001281 if (wacom_wac1->features.touch_max ||
1282 wacom_wac1->features.type == INTUOSHT) {
Ping Cheng57bcfce2013-10-15 23:44:00 -07001283 wacom_wac2->features =
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001284 *((struct wacom_features *)id->driver_data);
Ping Cheng57bcfce2013-10-15 23:44:00 -07001285 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1286 wacom_wac2->features.device_type = BTN_TOOL_FINGER;
1287 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1288 if (wacom_wac2->features.touch_max)
1289 snprintf(wacom_wac2->name, WACOM_NAME_MAX,
1290 "%s (WL) Finger",wacom_wac2->features.name);
1291 else
1292 snprintf(wacom_wac2->name, WACOM_NAME_MAX,
1293 "%s (WL) Pad",wacom_wac2->features.name);
Benjamin Tissoires008f4d92014-07-24 12:51:26 -07001294 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1295 "%s (WL) Pad", wacom_wac2->features.name);
Ping Cheng912ca212014-09-10 12:41:31 -07001296 wacom_wac2->pid = wacom_wac->pid;
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001297 error = wacom_allocate_inputs(wacom2) ||
1298 wacom_register_inputs(wacom2);
Ping Cheng57bcfce2013-10-15 23:44:00 -07001299 if (error)
1300 goto fail;
Ping Cheng961794a2013-12-05 12:54:53 -08001301
1302 if (wacom_wac1->features.type == INTUOSHT &&
1303 wacom_wac1->features.touch_max)
1304 wacom_wac->shared->touch_input = wacom_wac2->input;
Ping Cheng57bcfce2013-10-15 23:44:00 -07001305 }
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001306
1307 error = wacom_initialize_battery(wacom);
1308 if (error)
Ping Cheng57bcfce2013-10-15 23:44:00 -07001309 goto fail;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001310 }
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001311
1312 return;
1313
Ping Cheng57bcfce2013-10-15 23:44:00 -07001314fail:
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001315 wacom_clean_inputs(wacom1);
1316 wacom_clean_inputs(wacom2);
Chris Bagwellb7af2bb2012-06-12 00:25:23 -07001317 return;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001318}
1319
Ping Cheng401d7d12013-07-28 00:38:54 -07001320/*
1321 * Not all devices report physical dimensions from HID.
1322 * Compute the default from hardcoded logical dimension
1323 * and resolution before driver overwrites them.
1324 */
1325static void wacom_set_default_phy(struct wacom_features *features)
1326{
1327 if (features->x_resolution) {
1328 features->x_phy = (features->x_max * 100) /
1329 features->x_resolution;
1330 features->y_phy = (features->y_max * 100) /
1331 features->y_resolution;
1332 }
1333}
1334
1335static void wacom_calculate_res(struct wacom_features *features)
1336{
1337 features->x_resolution = wacom_calc_hid_res(features->x_max,
1338 features->x_phy,
1339 features->unit,
1340 features->unitExpo);
1341 features->y_resolution = wacom_calc_hid_res(features->y_max,
1342 features->y_phy,
1343 features->unit,
1344 features->unitExpo);
1345}
1346
Benjamin Tissoires01c846f2014-07-24 12:59:11 -07001347static size_t wacom_compute_pktlen(struct hid_device *hdev)
1348{
1349 struct hid_report_enum *report_enum;
1350 struct hid_report *report;
1351 size_t size = 0;
1352
1353 report_enum = hdev->report_enum + HID_INPUT_REPORT;
1354
1355 list_for_each_entry(report, &report_enum->report_list, list) {
Mathieu Magnaudetdabb05c62014-11-27 16:02:36 +01001356 size_t report_size = hid_report_len(report);
Benjamin Tissoires01c846f2014-07-24 12:59:11 -07001357 if (report_size > size)
1358 size = report_size;
1359 }
1360
1361 return size;
1362}
1363
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001364static int wacom_probe(struct hid_device *hdev,
1365 const struct hid_device_id *id)
Ping Cheng3bea7332006-07-13 18:01:36 -07001366{
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001367 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
Ping Cheng3bea7332006-07-13 18:01:36 -07001368 struct usb_device *dev = interface_to_usbdev(intf);
Ping Cheng3bea7332006-07-13 18:01:36 -07001369 struct wacom *wacom;
1370 struct wacom_wac *wacom_wac;
Jason Childse33da8a2010-02-17 22:38:31 -08001371 struct wacom_features *features;
Jason Childse33da8a2010-02-17 22:38:31 -08001372 int error;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001373 unsigned int connect_mask = HID_CONNECT_HIDRAW;
Ping Cheng3bea7332006-07-13 18:01:36 -07001374
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001375 if (!id->driver_data)
Bastian Blankb036f6f2010-02-10 23:06:23 -08001376 return -EINVAL;
1377
Benjamin Tissoires8ffffd52014-09-16 16:56:39 -04001378 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
1379
Ping Cheng3bea7332006-07-13 18:01:36 -07001380 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
Dan Carpenterf1823942012-03-29 22:38:11 -07001381 if (!wacom)
1382 return -ENOMEM;
Ping Cheng3bea7332006-07-13 18:01:36 -07001383
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001384 hid_set_drvdata(hdev, wacom);
1385 wacom->hdev = hdev;
1386
Benjamin Tissoiresba9a3542014-07-24 12:58:45 -07001387 /* ask for the report descriptor to be loaded by HID */
1388 error = hid_parse(hdev);
1389 if (error) {
1390 hid_err(hdev, "parse failed\n");
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001391 goto fail_parse;
Benjamin Tissoiresba9a3542014-07-24 12:58:45 -07001392 }
1393
Dmitry Torokhov51269fe2010-03-19 22:18:15 -07001394 wacom_wac = &wacom->wacom_wac;
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001395 wacom_wac->features = *((struct wacom_features *)id->driver_data);
Jason Childse33da8a2010-02-17 22:38:31 -08001396 features = &wacom_wac->features;
Benjamin Tissoires01c846f2014-07-24 12:59:11 -07001397 features->pktlen = wacom_compute_pktlen(hdev);
Jason Childse33da8a2010-02-17 22:38:31 -08001398 if (features->pktlen > WACOM_PKGLEN_MAX) {
1399 error = -EINVAL;
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001400 goto fail_pktlen;
Jason Childse33da8a2010-02-17 22:38:31 -08001401 }
1402
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001403 if (features->check_for_hid_type && features->hid_type != hdev->type) {
1404 error = -ENODEV;
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001405 goto fail_type;
Jason Childse33da8a2010-02-17 22:38:31 -08001406 }
Ping Cheng3bea7332006-07-13 18:01:36 -07001407
Ping Cheng3bea7332006-07-13 18:01:36 -07001408 wacom->usbdev = dev;
Oliver Neukume7224092008-04-15 01:31:57 -04001409 wacom->intf = intf;
1410 mutex_init(&wacom->lock);
Chris Bagwell16bf2882012-03-25 23:26:20 -07001411 INIT_WORK(&wacom->work, wacom_wireless_work);
Ping Cheng3bea7332006-07-13 18:01:36 -07001412
Benjamin Tissoires494078b2014-09-23 12:08:07 -04001413 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
1414 error = wacom_allocate_inputs(wacom);
1415 if (error)
1416 goto fail_allocate_inputs;
1417 }
1418
Ping Cheng401d7d12013-07-28 00:38:54 -07001419 /* set the default size in case we do not get them from hid */
1420 wacom_set_default_phy(features);
1421
Ping Chengf393ee22012-04-29 21:09:17 -07001422 /* Retrieve the physical and logical size for touch devices */
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -07001423 wacom_retrieve_hid_descriptor(hdev, features);
Ping Cheng545f4e92008-11-24 11:44:27 -05001424
Jason Gereckeae584ca2012-04-03 15:50:40 -07001425 /*
1426 * Intuos5 has no useful data about its touch interface in its
Benjamin Tissoires01c846f2014-07-24 12:59:11 -07001427 * HID descriptor. If this is the touch interface (PacketSize
Jason Gereckeae584ca2012-04-03 15:50:40 -07001428 * of WACOM_PKGLEN_BBTOUCH3), override the table values.
1429 */
Ping Chengb5fd2a32013-11-25 18:44:55 -08001430 if (features->type >= INTUOS5S && features->type <= INTUOSHT) {
Benjamin Tissoires01c846f2014-07-24 12:59:11 -07001431 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
Jason Gereckeae584ca2012-04-03 15:50:40 -07001432 features->device_type = BTN_TOOL_FINGER;
Jason Gereckeae584ca2012-04-03 15:50:40 -07001433
Jason Gereckeae584ca2012-04-03 15:50:40 -07001434 features->x_max = 4096;
1435 features->y_max = 4096;
1436 } else {
1437 features->device_type = BTN_TOOL_PEN;
1438 }
1439 }
1440
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -07001441 /*
1442 * Same thing for Bamboo 3rd gen.
1443 */
1444 if ((features->type == BAMBOO_PT) &&
1445 (features->pktlen == WACOM_PKGLEN_BBTOUCH3) &&
1446 (features->device_type == BTN_TOOL_PEN)) {
1447 features->device_type = BTN_TOOL_FINGER;
1448
1449 features->x_max = 4096;
1450 features->y_max = 4096;
1451 }
1452
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001453 if (hdev->bus == BUS_BLUETOOTH)
1454 features->quirks |= WACOM_QUIRK_BATTERY;
1455
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001456 wacom_setup_device_quirks(features);
1457
Ping Cheng401d7d12013-07-28 00:38:54 -07001458 /* set unit to "100th of a mm" for devices not reported by HID */
1459 if (!features->unit) {
1460 features->unit = 0x11;
Benjamin Tissoiresc669fb22014-07-24 13:02:14 -07001461 features->unitExpo = -3;
Ping Cheng401d7d12013-07-28 00:38:54 -07001462 }
1463 wacom_calculate_res(features);
1464
Ping Cheng49b764a2010-02-20 00:53:49 -08001465 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001466 snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name),
1467 "%s Pad", features->name);
Ping Cheng49b764a2010-02-20 00:53:49 -08001468
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001469 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
Ping Cheng49b764a2010-02-20 00:53:49 -08001470 /* Append the device type to the name */
Ping Cheng57bcfce2013-10-15 23:44:00 -07001471 if (features->device_type != BTN_TOOL_FINGER)
1472 strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX);
1473 else if (features->touch_max)
1474 strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX);
1475 else
1476 strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX);
Ping Cheng4492eff2010-03-19 22:18:15 -07001477
Benjamin Tissoires4451e082014-07-24 13:01:05 -07001478 error = wacom_add_shared_data(hdev);
Ping Cheng4492eff2010-03-19 22:18:15 -07001479 if (error)
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001480 goto fail_shared_data;
Ping Cheng49b764a2010-02-20 00:53:49 -08001481 }
1482
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001483 if (!(features->quirks & WACOM_QUIRK_MONITOR) &&
1484 (features->quirks & WACOM_QUIRK_BATTERY)) {
1485 error = wacom_initialize_battery(wacom);
1486 if (error)
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001487 goto fail_battery;
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001488 }
1489
Chris Bagwelld3825d52012-03-25 23:26:11 -07001490 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
Benjamin Tissoires494078b2014-09-23 12:08:07 -04001491 error = wacom_register_inputs(wacom);
Chris Bagwelld3825d52012-03-25 23:26:11 -07001492 if (error)
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001493 goto fail_register_inputs;
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001494 }
1495
1496 if (hdev->bus == BUS_BLUETOOTH) {
1497 error = device_create_file(&hdev->dev, &dev_attr_speed);
1498 if (error)
1499 hid_warn(hdev,
1500 "can't create sysfs speed attribute err: %d\n",
1501 error);
Chris Bagwelld3825d52012-03-25 23:26:11 -07001502 }
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -07001503
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001504 if (features->type == HID_GENERIC)
1505 connect_mask |= HID_CONNECT_DRIVER;
1506
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001507 /* Regular HID work starts now */
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001508 error = hid_hw_start(hdev, connect_mask);
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001509 if (error) {
1510 hid_err(hdev, "hw start failed\n");
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001511 goto fail_hw_start;
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001512 }
1513
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001514 /* Note that if query fails it is not a hard failure */
1515 wacom_query_tablet_data(hdev, features);
1516
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001517 if (features->quirks & WACOM_QUIRK_MONITOR)
1518 error = hid_hw_open(hdev);
1519
Ping Cheng961794a2013-12-05 12:54:53 -08001520 if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) {
1521 if (wacom_wac->features.device_type == BTN_TOOL_FINGER)
1522 wacom_wac->shared->touch_input = wacom_wac->input;
1523 }
1524
Ping Cheng3bea7332006-07-13 18:01:36 -07001525 return 0;
1526
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001527fail_hw_start:
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001528 if (hdev->bus == BUS_BLUETOOTH)
1529 device_remove_file(&hdev->dev, &dev_attr_speed);
1530fail_register_inputs:
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001531 wacom_clean_inputs(wacom);
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001532 wacom_destroy_battery(wacom);
1533fail_battery:
1534 wacom_remove_shared_data(wacom_wac);
1535fail_shared_data:
Benjamin Tissoires494078b2014-09-23 12:08:07 -04001536 wacom_clean_inputs(wacom);
1537fail_allocate_inputs:
Benjamin Tissoires7fefeec2014-09-23 12:08:05 -04001538fail_type:
1539fail_pktlen:
1540fail_parse:
1541 kfree(wacom);
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001542 hid_set_drvdata(hdev, NULL);
Dmitry Torokhov50141862007-04-12 01:33:39 -04001543 return error;
Ping Cheng3bea7332006-07-13 18:01:36 -07001544}
1545
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001546static void wacom_remove(struct hid_device *hdev)
Ping Cheng3bea7332006-07-13 18:01:36 -07001547{
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001548 struct wacom *wacom = hid_get_drvdata(hdev);
Ping Cheng3bea7332006-07-13 18:01:36 -07001549
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001550 hid_hw_stop(hdev);
Oliver Neukume7224092008-04-15 01:31:57 -04001551
Chris Bagwell16bf2882012-03-25 23:26:20 -07001552 cancel_work_sync(&wacom->work);
Benjamin Tissoires2546dac2014-09-23 12:08:06 -04001553 wacom_clean_inputs(wacom);
Benjamin Tissoiresf81a1292014-08-06 13:48:01 -07001554 if (hdev->bus == BUS_BLUETOOTH)
1555 device_remove_file(&hdev->dev, &dev_attr_speed);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001556 wacom_destroy_battery(wacom);
Dmitry Torokhov51269fe2010-03-19 22:18:15 -07001557 wacom_remove_shared_data(&wacom->wacom_wac);
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001558
1559 hid_set_drvdata(hdev, NULL);
Oliver Neukume7224092008-04-15 01:31:57 -04001560 kfree(wacom);
1561}
1562
Geert Uytterhoeven41a74582014-08-11 11:03:19 -07001563#ifdef CONFIG_PM
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001564static int wacom_resume(struct hid_device *hdev)
Oliver Neukume7224092008-04-15 01:31:57 -04001565{
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001566 struct wacom *wacom = hid_get_drvdata(hdev);
1567 struct wacom_features *features = &wacom->wacom_wac.features;
Oliver Neukume7224092008-04-15 01:31:57 -04001568
1569 mutex_lock(&wacom->lock);
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001570
1571 /* switch to wacom mode first */
Benjamin Tissoires27b20a92014-07-24 12:56:22 -07001572 wacom_query_tablet_data(hdev, features);
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001573 wacom_led_control(wacom);
1574
Oliver Neukume7224092008-04-15 01:31:57 -04001575 mutex_unlock(&wacom->lock);
1576
1577 return 0;
1578}
1579
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001580static int wacom_reset_resume(struct hid_device *hdev)
Oliver Neukume7224092008-04-15 01:31:57 -04001581{
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001582 return wacom_resume(hdev);
Oliver Neukume7224092008-04-15 01:31:57 -04001583}
Geert Uytterhoeven41a74582014-08-11 11:03:19 -07001584#endif /* CONFIG_PM */
Oliver Neukume7224092008-04-15 01:31:57 -04001585
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001586static struct hid_driver wacom_driver = {
Ping Cheng3bea7332006-07-13 18:01:36 -07001587 .name = "wacom",
Bastian Blankb036f6f2010-02-10 23:06:23 -08001588 .id_table = wacom_ids,
Ping Cheng3bea7332006-07-13 18:01:36 -07001589 .probe = wacom_probe,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001590 .remove = wacom_remove,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001591 .event = wacom_wac_event,
1592 .report = wacom_wac_report,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001593#ifdef CONFIG_PM
Oliver Neukume7224092008-04-15 01:31:57 -04001594 .resume = wacom_resume,
1595 .reset_resume = wacom_reset_resume,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001596#endif
1597 .raw_event = wacom_raw_event,
Ping Cheng3bea7332006-07-13 18:01:36 -07001598};
Benjamin Tissoires29b47392014-07-24 12:52:23 -07001599module_hid_driver(wacom_driver);
Benjamin Tissoiresf2e0a7d2014-08-06 14:07:49 -07001600
1601MODULE_VERSION(DRIVER_VERSION);
1602MODULE_AUTHOR(DRIVER_AUTHOR);
1603MODULE_DESCRIPTION(DRIVER_DESC);
1604MODULE_LICENSE(DRIVER_LICENSE);