Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1 | /* |
Dmitry Torokhov | 4104d13 | 2007-05-07 16:16:29 -0400 | [diff] [blame] | 2 | * drivers/input/tablet/wacom_sys.c |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3 | * |
Ping Cheng | 232f569 | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 4 | * USB Wacom tablet support - system specific code |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 5 | */ |
| 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 Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 14 | #include "wacom_wac.h" |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 15 | #include "wacom.h" |
Benjamin Tissoires | f54bc61 | 2014-07-24 12:52:00 -0700 | [diff] [blame] | 16 | #include <linux/hid.h> |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 17 | |
Ping Cheng | a417ea4 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 18 | #define WAC_MSG_RETRIES 5 |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 19 | |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 20 | #define WAC_CMD_LED_CONTROL 0x20 |
| 21 | #define WAC_CMD_ICON_START 0x21 |
| 22 | #define WAC_CMD_ICON_XFER 0x23 |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 23 | #define WAC_CMD_ICON_BT_XFER 0x26 |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 24 | #define WAC_CMD_RETRIES 10 |
| 25 | |
Ping Cheng | e0984bc | 2014-09-10 12:40:05 -0700 | [diff] [blame] | 26 | #define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP) |
| 27 | #define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP) |
| 28 | |
Ping Cheng | c64d883 | 2014-09-10 12:41:04 -0700 | [diff] [blame^] | 29 | static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf, |
| 30 | size_t size, unsigned int retries) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 31 | { |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 32 | int retval; |
| 33 | |
| 34 | do { |
Ping Cheng | c64d883 | 2014-09-10 12:41:04 -0700 | [diff] [blame^] | 35 | retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 36 | HID_REQ_GET_REPORT); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 37 | } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); |
| 38 | |
| 39 | return retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 42 | static int wacom_set_report(struct hid_device *hdev, u8 type, u8 *buf, |
| 43 | size_t size, unsigned int retries) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 44 | { |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 45 | int retval; |
| 46 | |
| 47 | do { |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 48 | retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 49 | HID_REQ_SET_REPORT); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 50 | } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); |
| 51 | |
| 52 | return retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 55 | static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, |
| 56 | u8 *raw_data, int size) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 57 | { |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 58 | struct wacom *wacom = hid_get_drvdata(hdev); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 59 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 60 | if (size > WACOM_PKGLEN_MAX) |
| 61 | return 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 62 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 63 | memcpy(wacom->wacom_wac.data, raw_data, size); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 64 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 65 | wacom_wac_irq(&wacom->wacom_wac, size); |
| 66 | |
| 67 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 70 | static int wacom_open(struct input_dev *dev) |
| 71 | { |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 72 | struct wacom *wacom = input_get_drvdata(dev); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 73 | int retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 74 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 75 | mutex_lock(&wacom->lock); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 76 | retval = hid_hw_open(wacom->hdev); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 77 | mutex_unlock(&wacom->lock); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 78 | |
Dmitry Torokhov | f6cd378 | 2010-10-04 21:46:11 -0700 | [diff] [blame] | 79 | return retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static void wacom_close(struct input_dev *dev) |
| 83 | { |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 84 | struct wacom *wacom = input_get_drvdata(dev); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 85 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 86 | mutex_lock(&wacom->lock); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 87 | hid_hw_close(wacom->hdev); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 88 | mutex_unlock(&wacom->lock); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 91 | /* |
Benjamin Tissoires | 198fdee | 2014-07-24 13:03:05 -0700 | [diff] [blame] | 92 | * Calculate the resolution of the X or Y axis using hidinput_calc_abs_res. |
Jason Gerecke | 115d5e1 | 2012-10-03 17:24:32 -0700 | [diff] [blame] | 93 | */ |
| 94 | static int wacom_calc_hid_res(int logical_extents, int physical_extents, |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 95 | unsigned unit, int exponent) |
Jason Gerecke | 115d5e1 | 2012-10-03 17:24:32 -0700 | [diff] [blame] | 96 | { |
Benjamin Tissoires | 198fdee | 2014-07-24 13:03:05 -0700 | [diff] [blame] | 97 | struct hid_field field = { |
| 98 | .logical_maximum = logical_extents, |
| 99 | .physical_maximum = physical_extents, |
| 100 | .unit = unit, |
| 101 | .unit_exponent = exponent, |
| 102 | }; |
Jason Gerecke | 115d5e1 | 2012-10-03 17:24:32 -0700 | [diff] [blame] | 103 | |
Benjamin Tissoires | 198fdee | 2014-07-24 13:03:05 -0700 | [diff] [blame] | 104 | return hidinput_calc_abs_res(&field, ABS_X); |
Jason Gerecke | 115d5e1 | 2012-10-03 17:24:32 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 107 | static void wacom_feature_mapping(struct hid_device *hdev, |
| 108 | struct hid_field *field, struct hid_usage *usage) |
Chris Bagwell | 4134361 | 2011-10-26 22:32:52 -0700 | [diff] [blame] | 109 | { |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 110 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 111 | struct wacom_features *features = &wacom->wacom_wac.features; |
Chris Bagwell | 4134361 | 2011-10-26 22:32:52 -0700 | [diff] [blame] | 112 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 113 | switch (usage->hid) { |
| 114 | case HID_DG_CONTACTMAX: |
| 115 | /* leave touch_max as is if predefined */ |
| 116 | if (!features->touch_max) |
| 117 | features->touch_max = field->value[0]; |
| 118 | break; |
Ping Cheng | f393ee2 | 2012-04-29 21:09:17 -0700 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | |
Chris Bagwell | 428f858 | 2011-10-26 22:26:59 -0700 | [diff] [blame] | 122 | /* |
| 123 | * Interface Descriptor of wacom devices can be incomplete and |
| 124 | * inconsistent so wacom_features table is used to store stylus |
| 125 | * device's packet lengths, various maximum values, and tablet |
| 126 | * resolution based on product ID's. |
| 127 | * |
| 128 | * For devices that contain 2 interfaces, wacom_features table is |
| 129 | * inaccurate for the touch interface. Since the Interface Descriptor |
| 130 | * for touch interfaces has pretty complete data, this function exists |
| 131 | * to query tablet for this missing information instead of hard coding in |
| 132 | * an additional table. |
| 133 | * |
| 134 | * A typical Interface Descriptor for a stylus will contain a |
| 135 | * boot mouse application collection that is not of interest and this |
| 136 | * function will ignore it. |
| 137 | * |
| 138 | * It also contains a digitizer application collection that also is not |
| 139 | * of interest since any information it contains would be duplicate |
| 140 | * of what is in wacom_features. Usually it defines a report of an array |
| 141 | * of bytes that could be used as max length of the stylus packet returned. |
| 142 | * If it happens to define a Digitizer-Stylus Physical Collection then |
| 143 | * the X and Y logical values contain valid data but it is ignored. |
| 144 | * |
| 145 | * A typical Interface Descriptor for a touch interface will contain a |
| 146 | * Digitizer-Finger Physical Collection which will define both logical |
| 147 | * X/Y maximum as well as the physical size of tablet. Since touch |
| 148 | * interfaces haven't supported pressure or distance, this is enough |
| 149 | * information to override invalid values in the wacom_features table. |
Chris Bagwell | 4134361 | 2011-10-26 22:32:52 -0700 | [diff] [blame] | 150 | * |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 151 | * Intuos5 touch interface and 3rd gen Bamboo Touch do not contain useful |
| 152 | * data. We deal with them after returning from this function. |
Chris Bagwell | 428f858 | 2011-10-26 22:26:59 -0700 | [diff] [blame] | 153 | */ |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 154 | static void wacom_usage_mapping(struct hid_device *hdev, |
| 155 | struct hid_field *field, struct hid_usage *usage) |
| 156 | { |
| 157 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 158 | struct wacom_features *features = &wacom->wacom_wac.features; |
| 159 | bool finger = (field->logical == HID_DG_FINGER) || |
| 160 | (field->physical == HID_DG_FINGER); |
| 161 | bool pen = (field->logical == HID_DG_STYLUS) || |
| 162 | (field->physical == HID_DG_STYLUS); |
| 163 | |
| 164 | /* |
| 165 | * Requiring Stylus Usage will ignore boot mouse |
| 166 | * X/Y values and some cases of invalid Digitizer X/Y |
| 167 | * values commonly reported. |
| 168 | */ |
| 169 | if (!pen && !finger) |
| 170 | return; |
| 171 | |
| 172 | if (finger && !features->touch_max) |
| 173 | /* touch device at least supports one touch point */ |
| 174 | features->touch_max = 1; |
| 175 | |
| 176 | switch (usage->hid) { |
| 177 | case HID_GD_X: |
| 178 | features->x_max = field->logical_maximum; |
| 179 | if (finger) { |
| 180 | features->device_type = BTN_TOOL_FINGER; |
| 181 | features->x_phy = field->physical_maximum; |
| 182 | if (features->type != BAMBOO_PT) { |
| 183 | features->unit = field->unit; |
| 184 | features->unitExpo = field->unit_exponent; |
| 185 | } |
| 186 | } else { |
| 187 | features->device_type = BTN_TOOL_PEN; |
| 188 | } |
| 189 | break; |
| 190 | case HID_GD_Y: |
| 191 | features->y_max = field->logical_maximum; |
| 192 | if (finger) { |
| 193 | features->y_phy = field->physical_maximum; |
| 194 | if (features->type != BAMBOO_PT) { |
| 195 | features->unit = field->unit; |
| 196 | features->unitExpo = field->unit_exponent; |
| 197 | } |
| 198 | } |
| 199 | break; |
| 200 | case HID_DG_TIPPRESSURE: |
| 201 | if (pen) |
| 202 | features->pressure_max = field->logical_maximum; |
| 203 | break; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | static void wacom_parse_hid(struct hid_device *hdev, |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 208 | struct wacom_features *features) |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 209 | { |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 210 | struct hid_report_enum *rep_enum; |
| 211 | struct hid_report *hreport; |
| 212 | int i, j; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 213 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 214 | /* check features first */ |
| 215 | rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; |
| 216 | list_for_each_entry(hreport, &rep_enum->report_list, list) { |
| 217 | for (i = 0; i < hreport->maxfield; i++) { |
| 218 | /* Ignore if report count is out of bounds. */ |
| 219 | if (hreport->field[i]->report_count < 1) |
| 220 | continue; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 221 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 222 | for (j = 0; j < hreport->field[i]->maxusage; j++) { |
| 223 | wacom_feature_mapping(hdev, hreport->field[i], |
| 224 | hreport->field[i]->usage + j); |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 225 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 226 | } |
| 227 | } |
| 228 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 229 | /* now check the input usages */ |
| 230 | rep_enum = &hdev->report_enum[HID_INPUT_REPORT]; |
| 231 | list_for_each_entry(hreport, &rep_enum->report_list, list) { |
| 232 | |
| 233 | if (!hreport->maxfield) |
| 234 | continue; |
| 235 | |
| 236 | for (i = 0; i < hreport->maxfield; i++) |
| 237 | for (j = 0; j < hreport->field[i]->maxusage; j++) |
| 238 | wacom_usage_mapping(hdev, hreport->field[i], |
| 239 | hreport->field[i]->usage + j); |
| 240 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 241 | } |
| 242 | |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 243 | static int wacom_set_device_mode(struct hid_device *hdev, int report_id, |
| 244 | int length, int mode) |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 245 | { |
| 246 | unsigned char *rep_data; |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 247 | int error = -ENOMEM, limit = 0; |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 248 | |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 249 | rep_data = kzalloc(length, GFP_KERNEL); |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 250 | if (!rep_data) |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 251 | return error; |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 252 | |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 253 | do { |
Chris Bagwell | 9937c02 | 2013-01-23 19:37:34 -0800 | [diff] [blame] | 254 | rep_data[0] = report_id; |
| 255 | rep_data[1] = mode; |
| 256 | |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 257 | error = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, |
| 258 | length, 1); |
Benjamin Tissoires | 3cb8315 | 2014-07-24 12:47:47 -0700 | [diff] [blame] | 259 | if (error >= 0) |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 260 | error = wacom_get_report(hdev, HID_FEATURE_REPORT, |
Ping Cheng | c64d883 | 2014-09-10 12:41:04 -0700 | [diff] [blame^] | 261 | rep_data, length, 1); |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 262 | } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES); |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 263 | |
| 264 | kfree(rep_data); |
| 265 | |
| 266 | return error < 0 ? error : 0; |
| 267 | } |
| 268 | |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 269 | static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed, |
| 270 | struct wacom_features *features) |
| 271 | { |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 272 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 273 | int ret; |
| 274 | u8 rep_data[2]; |
| 275 | |
| 276 | switch (features->type) { |
| 277 | case GRAPHIRE_BT: |
| 278 | rep_data[0] = 0x03; |
| 279 | rep_data[1] = 0x00; |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 280 | ret = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 2, |
| 281 | 3); |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 282 | |
| 283 | if (ret >= 0) { |
| 284 | rep_data[0] = speed == 0 ? 0x05 : 0x06; |
| 285 | rep_data[1] = 0x00; |
| 286 | |
| 287 | ret = wacom_set_report(hdev, HID_FEATURE_REPORT, |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 288 | rep_data, 2, 3); |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 289 | |
| 290 | if (ret >= 0) { |
| 291 | wacom->wacom_wac.bt_high_speed = speed; |
| 292 | return 0; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /* |
| 297 | * Note that if the raw queries fail, it's not a hard failure |
| 298 | * and it is safe to continue |
| 299 | */ |
| 300 | hid_warn(hdev, "failed to poke device, command %d, err %d\n", |
| 301 | rep_data[0], ret); |
| 302 | break; |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 303 | case INTUOS4WL: |
| 304 | if (speed == 1) |
| 305 | wacom->wacom_wac.bt_features &= ~0x20; |
| 306 | else |
| 307 | wacom->wacom_wac.bt_features |= 0x20; |
| 308 | |
| 309 | rep_data[0] = 0x03; |
| 310 | rep_data[1] = wacom->wacom_wac.bt_features; |
| 311 | |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 312 | ret = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data, 2, |
| 313 | 1); |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 314 | if (ret >= 0) |
| 315 | wacom->wacom_wac.bt_high_speed = speed; |
| 316 | break; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 319 | return 0; |
| 320 | } |
| 321 | |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 322 | /* |
| 323 | * Switch the tablet into its most-capable mode. Wacom tablets are |
| 324 | * typically configured to power-up in a mode which sends mouse-like |
| 325 | * reports to the OS. To get absolute position, pressure data, etc. |
| 326 | * from the tablet, it is necessary to switch the tablet out of this |
| 327 | * mode and into one which sends the full range of tablet data. |
| 328 | */ |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 329 | static int wacom_query_tablet_data(struct hid_device *hdev, |
| 330 | struct wacom_features *features) |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 331 | { |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 332 | if (hdev->bus == BUS_BLUETOOTH) |
| 333 | return wacom_bt_query_tablet_data(hdev, 1, features); |
| 334 | |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 335 | if (features->device_type == BTN_TOOL_FINGER) { |
| 336 | if (features->type > TABLETPC) { |
| 337 | /* MT Tablet PC touch */ |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 338 | return wacom_set_device_mode(hdev, 3, 4, 4); |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 339 | } |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 340 | else if (features->type == WACOM_24HDT || features->type == CINTIQ_HYBRID) { |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 341 | return wacom_set_device_mode(hdev, 18, 3, 2); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 342 | } |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 343 | } else if (features->device_type == BTN_TOOL_PEN) { |
| 344 | if (features->type <= BAMBOO_PT && features->type != WIRELESS) { |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 345 | return wacom_set_device_mode(hdev, 2, 2, 2); |
Jason Gerecke | fe494bc | 2012-10-03 17:25:35 -0700 | [diff] [blame] | 346 | } |
| 347 | } |
| 348 | |
| 349 | return 0; |
| 350 | } |
| 351 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 352 | static void wacom_retrieve_hid_descriptor(struct hid_device *hdev, |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 353 | struct wacom_features *features) |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 354 | { |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 355 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 356 | struct usb_interface *intf = wacom->intf; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 357 | |
Henrik Rydberg | fed87e6 | 2010-09-05 12:25:11 -0700 | [diff] [blame] | 358 | /* default features */ |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 359 | features->device_type = BTN_TOOL_PEN; |
Henrik Rydberg | fed87e6 | 2010-09-05 12:25:11 -0700 | [diff] [blame] | 360 | features->x_fuzz = 4; |
| 361 | features->y_fuzz = 4; |
| 362 | features->pressure_fuzz = 0; |
| 363 | features->distance_fuzz = 0; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 364 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 365 | /* |
| 366 | * The wireless device HID is basic and layout conflicts with |
| 367 | * other tablets (monitor and touch interface can look like pen). |
| 368 | * Skip the query for this type and modify defaults based on |
| 369 | * interface number. |
| 370 | */ |
| 371 | if (features->type == WIRELESS) { |
| 372 | if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { |
| 373 | features->device_type = 0; |
| 374 | } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { |
Ping Cheng | adad004 | 2012-06-28 16:48:17 -0700 | [diff] [blame] | 375 | features->device_type = BTN_TOOL_FINGER; |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 376 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; |
| 377 | } |
| 378 | } |
| 379 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 380 | /* only devices that support touch need to retrieve the info */ |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 381 | if (features->type < BAMBOO_PT) |
| 382 | return; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 383 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 384 | wacom_parse_hid(hdev, features); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 385 | } |
| 386 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 387 | struct wacom_hdev_data { |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 388 | struct list_head list; |
| 389 | struct kref kref; |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 390 | struct hid_device *dev; |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 391 | struct wacom_shared shared; |
| 392 | }; |
| 393 | |
| 394 | static LIST_HEAD(wacom_udev_list); |
| 395 | static DEFINE_MUTEX(wacom_udev_list_lock); |
| 396 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 397 | static bool wacom_are_sibling(struct hid_device *hdev, |
| 398 | struct hid_device *sibling) |
Jason Gerecke | aea2bf6 | 2012-10-21 00:38:03 -0700 | [diff] [blame] | 399 | { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 400 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 401 | struct wacom_features *features = &wacom->wacom_wac.features; |
| 402 | int vid = features->oVid; |
| 403 | int pid = features->oPid; |
| 404 | int n1,n2; |
Jason Gerecke | aea2bf6 | 2012-10-21 00:38:03 -0700 | [diff] [blame] | 405 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 406 | if (vid == 0 && pid == 0) { |
| 407 | vid = hdev->vendor; |
| 408 | pid = hdev->product; |
Jason Gerecke | aea2bf6 | 2012-10-21 00:38:03 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 411 | if (vid != sibling->vendor || pid != sibling->product) |
| 412 | return false; |
| 413 | |
| 414 | /* Compare the physical path. */ |
| 415 | n1 = strrchr(hdev->phys, '.') - hdev->phys; |
| 416 | n2 = strrchr(sibling->phys, '.') - sibling->phys; |
| 417 | if (n1 != n2 || n1 <= 0 || n2 <= 0) |
| 418 | return false; |
| 419 | |
| 420 | return !strncmp(hdev->phys, sibling->phys, n1); |
Jason Gerecke | aea2bf6 | 2012-10-21 00:38:03 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 423 | static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev) |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 424 | { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 425 | struct wacom_hdev_data *data; |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 426 | |
| 427 | list_for_each_entry(data, &wacom_udev_list, list) { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 428 | if (wacom_are_sibling(hdev, data->dev)) { |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 429 | kref_get(&data->kref); |
| 430 | return data; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | return NULL; |
| 435 | } |
| 436 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 437 | static int wacom_add_shared_data(struct hid_device *hdev) |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 438 | { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 439 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 440 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 441 | struct wacom_hdev_data *data; |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 442 | int retval = 0; |
| 443 | |
| 444 | mutex_lock(&wacom_udev_list_lock); |
| 445 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 446 | data = wacom_get_hdev_data(hdev); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 447 | if (!data) { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 448 | data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 449 | if (!data) { |
| 450 | retval = -ENOMEM; |
| 451 | goto out; |
| 452 | } |
| 453 | |
| 454 | kref_init(&data->kref); |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 455 | data->dev = hdev; |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 456 | list_add_tail(&data->list, &wacom_udev_list); |
| 457 | } |
| 458 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 459 | wacom_wac->shared = &data->shared; |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 460 | |
| 461 | out: |
| 462 | mutex_unlock(&wacom_udev_list_lock); |
| 463 | return retval; |
| 464 | } |
| 465 | |
| 466 | static void wacom_release_shared_data(struct kref *kref) |
| 467 | { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 468 | struct wacom_hdev_data *data = |
| 469 | container_of(kref, struct wacom_hdev_data, kref); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 470 | |
| 471 | mutex_lock(&wacom_udev_list_lock); |
| 472 | list_del(&data->list); |
| 473 | mutex_unlock(&wacom_udev_list_lock); |
| 474 | |
| 475 | kfree(data); |
| 476 | } |
| 477 | |
| 478 | static void wacom_remove_shared_data(struct wacom_wac *wacom) |
| 479 | { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 480 | struct wacom_hdev_data *data; |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 481 | |
| 482 | if (wacom->shared) { |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 483 | data = container_of(wacom->shared, struct wacom_hdev_data, shared); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 484 | kref_put(&data->kref, wacom_release_shared_data); |
| 485 | wacom->shared = NULL; |
| 486 | } |
| 487 | } |
| 488 | |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 489 | static int wacom_led_control(struct wacom *wacom) |
| 490 | { |
| 491 | unsigned char *buf; |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 492 | int retval; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 493 | |
| 494 | buf = kzalloc(9, GFP_KERNEL); |
| 495 | if (!buf) |
| 496 | return -ENOMEM; |
| 497 | |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 498 | if (wacom->wacom_wac.features.type >= INTUOS5S && |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 499 | wacom->wacom_wac.features.type <= INTUOSPL) { |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 500 | /* |
| 501 | * Touch Ring and crop mark LED luminance may take on |
| 502 | * one of four values: |
| 503 | * 0 = Low; 1 = Medium; 2 = High; 3 = Off |
| 504 | */ |
| 505 | int ring_led = wacom->led.select[0] & 0x03; |
| 506 | int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; |
| 507 | int crop_lum = 0; |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 508 | |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 509 | buf[0] = WAC_CMD_LED_CONTROL; |
| 510 | buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); |
| 511 | } |
| 512 | else { |
| 513 | int led = wacom->led.select[0] | 0x4; |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 514 | |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 515 | if (wacom->wacom_wac.features.type == WACOM_21UX2 || |
| 516 | wacom->wacom_wac.features.type == WACOM_24HD) |
| 517 | led |= (wacom->led.select[1] << 4) | 0x40; |
| 518 | |
| 519 | buf[0] = WAC_CMD_LED_CONTROL; |
| 520 | buf[1] = led; |
| 521 | buf[2] = wacom->led.llv; |
| 522 | buf[3] = wacom->led.hlv; |
| 523 | buf[4] = wacom->led.img_lum; |
| 524 | } |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 525 | |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 526 | retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 9, |
| 527 | WAC_CMD_RETRIES); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 528 | kfree(buf); |
| 529 | |
| 530 | return retval; |
| 531 | } |
| 532 | |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 533 | static int wacom_led_putimage(struct wacom *wacom, int button_id, u8 xfer_id, |
| 534 | const unsigned len, const void *img) |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 535 | { |
| 536 | unsigned char *buf; |
| 537 | int i, retval; |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 538 | const unsigned chunk_len = len / 4; /* 4 chunks are needed to be sent */ |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 539 | |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 540 | buf = kzalloc(chunk_len + 3 , GFP_KERNEL); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 541 | if (!buf) |
| 542 | return -ENOMEM; |
| 543 | |
| 544 | /* Send 'start' command */ |
| 545 | buf[0] = WAC_CMD_ICON_START; |
| 546 | buf[1] = 1; |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 547 | retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, |
| 548 | WAC_CMD_RETRIES); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 549 | if (retval < 0) |
| 550 | goto out; |
| 551 | |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 552 | buf[0] = xfer_id; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 553 | buf[1] = button_id & 0x07; |
| 554 | for (i = 0; i < 4; i++) { |
| 555 | buf[2] = i; |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 556 | memcpy(buf + 3, img + i * chunk_len, chunk_len); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 557 | |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 558 | retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 559 | buf, chunk_len + 3, WAC_CMD_RETRIES); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 560 | if (retval < 0) |
| 561 | break; |
| 562 | } |
| 563 | |
| 564 | /* Send 'stop' */ |
| 565 | buf[0] = WAC_CMD_ICON_START; |
| 566 | buf[1] = 0; |
Przemo Firszt | 296b737 | 2014-08-06 14:00:38 -0700 | [diff] [blame] | 567 | wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, |
| 568 | WAC_CMD_RETRIES); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 569 | |
| 570 | out: |
| 571 | kfree(buf); |
| 572 | return retval; |
| 573 | } |
| 574 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 575 | static ssize_t wacom_led_select_store(struct device *dev, int set_id, |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 576 | const char *buf, size_t count) |
| 577 | { |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 578 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 579 | struct wacom *wacom = hid_get_drvdata(hdev); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 580 | unsigned int id; |
| 581 | int err; |
| 582 | |
| 583 | err = kstrtouint(buf, 10, &id); |
| 584 | if (err) |
| 585 | return err; |
| 586 | |
| 587 | mutex_lock(&wacom->lock); |
| 588 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 589 | wacom->led.select[set_id] = id & 0x3; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 590 | err = wacom_led_control(wacom); |
| 591 | |
| 592 | mutex_unlock(&wacom->lock); |
| 593 | |
| 594 | return err < 0 ? err : count; |
| 595 | } |
| 596 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 597 | #define DEVICE_LED_SELECT_ATTR(SET_ID) \ |
| 598 | static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \ |
| 599 | struct device_attribute *attr, const char *buf, size_t count) \ |
| 600 | { \ |
| 601 | return wacom_led_select_store(dev, SET_ID, buf, count); \ |
| 602 | } \ |
Ping Cheng | 04c59ab | 2011-10-04 23:51:49 -0700 | [diff] [blame] | 603 | static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ |
| 604 | struct device_attribute *attr, char *buf) \ |
| 605 | { \ |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 606 | struct hid_device *hdev = container_of(dev, struct hid_device, dev);\ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 607 | struct wacom *wacom = hid_get_drvdata(hdev); \ |
Ping Cheng | 37449ad | 2014-09-10 12:40:30 -0700 | [diff] [blame] | 608 | return scnprintf(buf, PAGE_SIZE, "%d\n", \ |
| 609 | wacom->led.select[SET_ID]); \ |
Ping Cheng | 04c59ab | 2011-10-04 23:51:49 -0700 | [diff] [blame] | 610 | } \ |
Ping Cheng | e0984bc | 2014-09-10 12:40:05 -0700 | [diff] [blame] | 611 | static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \ |
Ping Cheng | 04c59ab | 2011-10-04 23:51:49 -0700 | [diff] [blame] | 612 | wacom_led##SET_ID##_select_show, \ |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 613 | wacom_led##SET_ID##_select_store) |
| 614 | |
| 615 | DEVICE_LED_SELECT_ATTR(0); |
| 616 | DEVICE_LED_SELECT_ATTR(1); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 617 | |
| 618 | static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, |
| 619 | const char *buf, size_t count) |
| 620 | { |
| 621 | unsigned int value; |
| 622 | int err; |
| 623 | |
| 624 | err = kstrtouint(buf, 10, &value); |
| 625 | if (err) |
| 626 | return err; |
| 627 | |
| 628 | mutex_lock(&wacom->lock); |
| 629 | |
| 630 | *dest = value & 0x7f; |
| 631 | err = wacom_led_control(wacom); |
| 632 | |
| 633 | mutex_unlock(&wacom->lock); |
| 634 | |
| 635 | return err < 0 ? err : count; |
| 636 | } |
| 637 | |
| 638 | #define DEVICE_LUMINANCE_ATTR(name, field) \ |
| 639 | static ssize_t wacom_##name##_luminance_store(struct device *dev, \ |
| 640 | struct device_attribute *attr, const char *buf, size_t count) \ |
| 641 | { \ |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 642 | struct hid_device *hdev = container_of(dev, struct hid_device, dev);\ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 643 | struct wacom *wacom = hid_get_drvdata(hdev); \ |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 644 | \ |
| 645 | return wacom_luminance_store(wacom, &wacom->led.field, \ |
| 646 | buf, count); \ |
| 647 | } \ |
Ping Cheng | 37449ad | 2014-09-10 12:40:30 -0700 | [diff] [blame] | 648 | static ssize_t wacom_##name##_luminance_show(struct device *dev, \ |
| 649 | struct device_attribute *attr, char *buf) \ |
| 650 | { \ |
| 651 | struct wacom *wacom = dev_get_drvdata(dev); \ |
| 652 | return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \ |
| 653 | } \ |
Ping Cheng | e0984bc | 2014-09-10 12:40:05 -0700 | [diff] [blame] | 654 | static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \ |
Ping Cheng | 37449ad | 2014-09-10 12:40:30 -0700 | [diff] [blame] | 655 | wacom_##name##_luminance_show, \ |
| 656 | wacom_##name##_luminance_store) |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 657 | |
| 658 | DEVICE_LUMINANCE_ATTR(status0, llv); |
| 659 | DEVICE_LUMINANCE_ATTR(status1, hlv); |
| 660 | DEVICE_LUMINANCE_ATTR(buttons, img_lum); |
| 661 | |
| 662 | static ssize_t wacom_button_image_store(struct device *dev, int button_id, |
| 663 | const char *buf, size_t count) |
| 664 | { |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 665 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 666 | struct wacom *wacom = hid_get_drvdata(hdev); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 667 | int err; |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 668 | unsigned len; |
| 669 | u8 xfer_id; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 670 | |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 671 | if (hdev->bus == BUS_BLUETOOTH) { |
| 672 | len = 256; |
| 673 | xfer_id = WAC_CMD_ICON_BT_XFER; |
| 674 | } else { |
| 675 | len = 1024; |
| 676 | xfer_id = WAC_CMD_ICON_XFER; |
| 677 | } |
| 678 | |
| 679 | if (count != len) |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 680 | return -EINVAL; |
| 681 | |
| 682 | mutex_lock(&wacom->lock); |
| 683 | |
Benjamin Tissoires | 849e2f0 | 2014-08-06 13:58:25 -0700 | [diff] [blame] | 684 | err = wacom_led_putimage(wacom, button_id, xfer_id, len, buf); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 685 | |
| 686 | mutex_unlock(&wacom->lock); |
| 687 | |
| 688 | return err < 0 ? err : count; |
| 689 | } |
| 690 | |
| 691 | #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \ |
| 692 | static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \ |
| 693 | struct device_attribute *attr, const char *buf, size_t count) \ |
| 694 | { \ |
| 695 | return wacom_button_image_store(dev, BUTTON_ID, buf, count); \ |
| 696 | } \ |
Ping Cheng | e0984bc | 2014-09-10 12:40:05 -0700 | [diff] [blame] | 697 | static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \ |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 698 | NULL, wacom_btnimg##BUTTON_ID##_store) |
| 699 | |
| 700 | DEVICE_BTNIMG_ATTR(0); |
| 701 | DEVICE_BTNIMG_ATTR(1); |
| 702 | DEVICE_BTNIMG_ATTR(2); |
| 703 | DEVICE_BTNIMG_ATTR(3); |
| 704 | DEVICE_BTNIMG_ATTR(4); |
| 705 | DEVICE_BTNIMG_ATTR(5); |
| 706 | DEVICE_BTNIMG_ATTR(6); |
| 707 | DEVICE_BTNIMG_ATTR(7); |
| 708 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 709 | static struct attribute *cintiq_led_attrs[] = { |
| 710 | &dev_attr_status_led0_select.attr, |
| 711 | &dev_attr_status_led1_select.attr, |
| 712 | NULL |
| 713 | }; |
| 714 | |
| 715 | static struct attribute_group cintiq_led_attr_group = { |
| 716 | .name = "wacom_led", |
| 717 | .attrs = cintiq_led_attrs, |
| 718 | }; |
| 719 | |
| 720 | static struct attribute *intuos4_led_attrs[] = { |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 721 | &dev_attr_status0_luminance.attr, |
| 722 | &dev_attr_status1_luminance.attr, |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 723 | &dev_attr_status_led0_select.attr, |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 724 | &dev_attr_buttons_luminance.attr, |
| 725 | &dev_attr_button0_rawimg.attr, |
| 726 | &dev_attr_button1_rawimg.attr, |
| 727 | &dev_attr_button2_rawimg.attr, |
| 728 | &dev_attr_button3_rawimg.attr, |
| 729 | &dev_attr_button4_rawimg.attr, |
| 730 | &dev_attr_button5_rawimg.attr, |
| 731 | &dev_attr_button6_rawimg.attr, |
| 732 | &dev_attr_button7_rawimg.attr, |
| 733 | NULL |
| 734 | }; |
| 735 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 736 | static struct attribute_group intuos4_led_attr_group = { |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 737 | .name = "wacom_led", |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 738 | .attrs = intuos4_led_attrs, |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 739 | }; |
| 740 | |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 741 | static struct attribute *intuos5_led_attrs[] = { |
| 742 | &dev_attr_status0_luminance.attr, |
| 743 | &dev_attr_status_led0_select.attr, |
| 744 | NULL |
| 745 | }; |
| 746 | |
| 747 | static struct attribute_group intuos5_led_attr_group = { |
| 748 | .name = "wacom_led", |
| 749 | .attrs = intuos5_led_attrs, |
| 750 | }; |
| 751 | |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 752 | static int wacom_initialize_leds(struct wacom *wacom) |
| 753 | { |
| 754 | int error; |
| 755 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 756 | /* Initialize default values */ |
| 757 | switch (wacom->wacom_wac.features.type) { |
Jason Gerecke | a19fc98 | 2012-06-12 00:27:53 -0700 | [diff] [blame] | 758 | case INTUOS4S: |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 759 | case INTUOS4: |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 760 | case INTUOS4WL: |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 761 | case INTUOS4L: |
| 762 | wacom->led.select[0] = 0; |
| 763 | wacom->led.select[1] = 0; |
Ping Cheng | f4fa9a6 | 2011-10-04 23:49:42 -0700 | [diff] [blame] | 764 | wacom->led.llv = 10; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 765 | wacom->led.hlv = 20; |
| 766 | wacom->led.img_lum = 10; |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 767 | error = sysfs_create_group(&wacom->hdev->dev.kobj, |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 768 | &intuos4_led_attr_group); |
| 769 | break; |
| 770 | |
Jason Gerecke | 246835f | 2011-12-12 00:12:04 -0800 | [diff] [blame] | 771 | case WACOM_24HD: |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 772 | case WACOM_21UX2: |
| 773 | wacom->led.select[0] = 0; |
| 774 | wacom->led.select[1] = 0; |
| 775 | wacom->led.llv = 0; |
| 776 | wacom->led.hlv = 0; |
| 777 | wacom->led.img_lum = 0; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 778 | |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 779 | error = sysfs_create_group(&wacom->hdev->dev.kobj, |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 780 | &cintiq_led_attr_group); |
| 781 | break; |
| 782 | |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 783 | case INTUOS5S: |
| 784 | case INTUOS5: |
| 785 | case INTUOS5L: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 786 | case INTUOSPS: |
| 787 | case INTUOSPM: |
| 788 | case INTUOSPL: |
Ping Cheng | c2b0c27 | 2013-09-20 09:50:14 -0700 | [diff] [blame] | 789 | if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) { |
| 790 | wacom->led.select[0] = 0; |
| 791 | wacom->led.select[1] = 0; |
| 792 | wacom->led.llv = 32; |
| 793 | wacom->led.hlv = 0; |
| 794 | wacom->led.img_lum = 0; |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 795 | |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 796 | error = sysfs_create_group(&wacom->hdev->dev.kobj, |
Ping Cheng | c2b0c27 | 2013-09-20 09:50:14 -0700 | [diff] [blame] | 797 | &intuos5_led_attr_group); |
| 798 | } else |
| 799 | return 0; |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 800 | break; |
| 801 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 802 | default: |
| 803 | return 0; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 804 | } |
| 805 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 806 | if (error) { |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 807 | hid_err(wacom->hdev, |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 808 | "cannot create sysfs group err: %d\n", error); |
| 809 | return error; |
| 810 | } |
| 811 | wacom_led_control(wacom); |
Benjamin Tissoires | c757cba | 2014-07-24 13:16:17 -0700 | [diff] [blame] | 812 | wacom->led_initialized = true; |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 813 | |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 814 | return 0; |
| 815 | } |
| 816 | |
| 817 | static void wacom_destroy_leds(struct wacom *wacom) |
| 818 | { |
Benjamin Tissoires | c757cba | 2014-07-24 13:16:17 -0700 | [diff] [blame] | 819 | if (!wacom->led_initialized) |
| 820 | return; |
| 821 | |
| 822 | wacom->led_initialized = false; |
| 823 | |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 824 | switch (wacom->wacom_wac.features.type) { |
Jason Gerecke | a19fc98 | 2012-06-12 00:27:53 -0700 | [diff] [blame] | 825 | case INTUOS4S: |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 826 | case INTUOS4: |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 827 | case INTUOS4WL: |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 828 | case INTUOS4L: |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 829 | sysfs_remove_group(&wacom->hdev->dev.kobj, |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 830 | &intuos4_led_attr_group); |
| 831 | break; |
| 832 | |
Jason Gerecke | 246835f | 2011-12-12 00:12:04 -0800 | [diff] [blame] | 833 | case WACOM_24HD: |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 834 | case WACOM_21UX2: |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 835 | sysfs_remove_group(&wacom->hdev->dev.kobj, |
Ping Cheng | 09e7d94 | 2011-10-04 23:51:14 -0700 | [diff] [blame] | 836 | &cintiq_led_attr_group); |
| 837 | break; |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 838 | |
| 839 | case INTUOS5S: |
| 840 | case INTUOS5: |
| 841 | case INTUOS5L: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 842 | case INTUOSPS: |
| 843 | case INTUOSPM: |
| 844 | case INTUOSPL: |
Ping Cheng | c2b0c27 | 2013-09-20 09:50:14 -0700 | [diff] [blame] | 845 | if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) |
Benjamin Tissoires | c31a408 | 2014-07-24 12:59:45 -0700 | [diff] [blame] | 846 | sysfs_remove_group(&wacom->hdev->dev.kobj, |
Ping Cheng | c2b0c27 | 2013-09-20 09:50:14 -0700 | [diff] [blame] | 847 | &intuos5_led_attr_group); |
Jason Gerecke | 9b5b95d | 2012-04-03 15:50:37 -0700 | [diff] [blame] | 848 | break; |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 852 | static enum power_supply_property wacom_battery_props[] = { |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 853 | POWER_SUPPLY_PROP_STATUS, |
Bastien Nocera | 6e2a6e8 | 2013-10-15 23:33:00 -0700 | [diff] [blame] | 854 | POWER_SUPPLY_PROP_SCOPE, |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 855 | POWER_SUPPLY_PROP_CAPACITY |
| 856 | }; |
| 857 | |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 858 | static enum power_supply_property wacom_ac_props[] = { |
| 859 | POWER_SUPPLY_PROP_PRESENT, |
| 860 | POWER_SUPPLY_PROP_ONLINE, |
| 861 | POWER_SUPPLY_PROP_SCOPE, |
| 862 | }; |
| 863 | |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 864 | static int wacom_battery_get_property(struct power_supply *psy, |
| 865 | enum power_supply_property psp, |
| 866 | union power_supply_propval *val) |
| 867 | { |
| 868 | struct wacom *wacom = container_of(psy, struct wacom, battery); |
| 869 | int ret = 0; |
| 870 | |
| 871 | switch (psp) { |
Bastien Nocera | 6e2a6e8 | 2013-10-15 23:33:00 -0700 | [diff] [blame] | 872 | case POWER_SUPPLY_PROP_SCOPE: |
| 873 | val->intval = POWER_SUPPLY_SCOPE_DEVICE; |
| 874 | break; |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 875 | case POWER_SUPPLY_PROP_CAPACITY: |
| 876 | val->intval = |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 877 | wacom->wacom_wac.battery_capacity; |
| 878 | break; |
| 879 | case POWER_SUPPLY_PROP_STATUS: |
| 880 | if (wacom->wacom_wac.bat_charging) |
| 881 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
| 882 | else if (wacom->wacom_wac.battery_capacity == 100 && |
| 883 | wacom->wacom_wac.ps_connected) |
| 884 | val->intval = POWER_SUPPLY_STATUS_FULL; |
| 885 | else |
| 886 | val->intval = POWER_SUPPLY_STATUS_DISCHARGING; |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 887 | break; |
| 888 | default: |
| 889 | ret = -EINVAL; |
| 890 | break; |
| 891 | } |
| 892 | |
| 893 | return ret; |
| 894 | } |
| 895 | |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 896 | static int wacom_ac_get_property(struct power_supply *psy, |
| 897 | enum power_supply_property psp, |
| 898 | union power_supply_propval *val) |
| 899 | { |
| 900 | struct wacom *wacom = container_of(psy, struct wacom, ac); |
| 901 | int ret = 0; |
| 902 | |
| 903 | switch (psp) { |
| 904 | case POWER_SUPPLY_PROP_PRESENT: |
| 905 | /* fall through */ |
| 906 | case POWER_SUPPLY_PROP_ONLINE: |
| 907 | val->intval = wacom->wacom_wac.ps_connected; |
| 908 | break; |
| 909 | case POWER_SUPPLY_PROP_SCOPE: |
| 910 | val->intval = POWER_SUPPLY_SCOPE_DEVICE; |
| 911 | break; |
| 912 | default: |
| 913 | ret = -EINVAL; |
| 914 | break; |
| 915 | } |
| 916 | return ret; |
| 917 | } |
| 918 | |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 919 | static int wacom_initialize_battery(struct wacom *wacom) |
| 920 | { |
Benjamin Tissoires | d70420b | 2014-07-25 17:31:51 -0700 | [diff] [blame] | 921 | static atomic_t battery_no = ATOMIC_INIT(0); |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 922 | int error; |
Benjamin Tissoires | d70420b | 2014-07-25 17:31:51 -0700 | [diff] [blame] | 923 | unsigned long n; |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 924 | |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 925 | if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) { |
Benjamin Tissoires | d70420b | 2014-07-25 17:31:51 -0700 | [diff] [blame] | 926 | n = atomic_inc_return(&battery_no) - 1; |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 927 | |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 928 | wacom->battery.properties = wacom_battery_props; |
| 929 | wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props); |
| 930 | wacom->battery.get_property = wacom_battery_get_property; |
Benjamin Tissoires | d70420b | 2014-07-25 17:31:51 -0700 | [diff] [blame] | 931 | sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n); |
| 932 | wacom->battery.name = wacom->wacom_wac.bat_name; |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 933 | wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY; |
| 934 | wacom->battery.use_for_apm = 0; |
| 935 | |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 936 | wacom->ac.properties = wacom_ac_props; |
| 937 | wacom->ac.num_properties = ARRAY_SIZE(wacom_ac_props); |
| 938 | wacom->ac.get_property = wacom_ac_get_property; |
| 939 | sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n); |
| 940 | wacom->ac.name = wacom->wacom_wac.ac_name; |
| 941 | wacom->ac.type = POWER_SUPPLY_TYPE_MAINS; |
| 942 | wacom->ac.use_for_apm = 0; |
| 943 | |
Benjamin Tissoires | dd3181a | 2014-07-24 13:01:40 -0700 | [diff] [blame] | 944 | error = power_supply_register(&wacom->hdev->dev, |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 945 | &wacom->battery); |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 946 | if (error) |
| 947 | return error; |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 948 | |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 949 | power_supply_powers(&wacom->battery, &wacom->hdev->dev); |
| 950 | |
| 951 | error = power_supply_register(&wacom->hdev->dev, &wacom->ac); |
| 952 | if (error) { |
| 953 | power_supply_unregister(&wacom->battery); |
| 954 | return error; |
| 955 | } |
| 956 | |
| 957 | power_supply_powers(&wacom->ac, &wacom->hdev->dev); |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 958 | } |
| 959 | |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 960 | return 0; |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | static void wacom_destroy_battery(struct wacom *wacom) |
| 964 | { |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 965 | if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && |
| 966 | wacom->battery.dev) { |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 967 | power_supply_unregister(&wacom->battery); |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 968 | wacom->battery.dev = NULL; |
Benjamin Tissoires | 7dbd229 | 2014-07-25 17:32:41 -0700 | [diff] [blame] | 969 | power_supply_unregister(&wacom->ac); |
| 970 | wacom->ac.dev = NULL; |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 971 | } |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 972 | } |
| 973 | |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 974 | static ssize_t wacom_show_speed(struct device *dev, |
| 975 | struct device_attribute |
| 976 | *attr, char *buf) |
| 977 | { |
| 978 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 979 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 980 | |
| 981 | return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); |
| 982 | } |
| 983 | |
| 984 | static ssize_t wacom_store_speed(struct device *dev, |
| 985 | struct device_attribute *attr, |
| 986 | const char *buf, size_t count) |
| 987 | { |
| 988 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 989 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 990 | u8 new_speed; |
| 991 | |
| 992 | if (kstrtou8(buf, 0, &new_speed)) |
| 993 | return -EINVAL; |
| 994 | |
| 995 | if (new_speed != 0 && new_speed != 1) |
| 996 | return -EINVAL; |
| 997 | |
| 998 | wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features); |
| 999 | |
| 1000 | return count; |
| 1001 | } |
| 1002 | |
Ping Cheng | e0984bc | 2014-09-10 12:40:05 -0700 | [diff] [blame] | 1003 | static DEVICE_ATTR(speed, DEV_ATTR_RW_PERM, |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1004 | wacom_show_speed, wacom_store_speed); |
| 1005 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1006 | static struct input_dev *wacom_allocate_input(struct wacom *wacom) |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1007 | { |
| 1008 | struct input_dev *input_dev; |
Benjamin Tissoires | b6c79f2 | 2014-07-24 13:00:03 -0700 | [diff] [blame] | 1009 | struct hid_device *hdev = wacom->hdev; |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1010 | struct wacom_wac *wacom_wac = &(wacom->wacom_wac); |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1011 | |
| 1012 | input_dev = input_allocate_device(); |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1013 | if (!input_dev) |
| 1014 | return NULL; |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1015 | |
| 1016 | input_dev->name = wacom_wac->name; |
Benjamin Tissoires | b6c79f2 | 2014-07-24 13:00:03 -0700 | [diff] [blame] | 1017 | input_dev->phys = hdev->phys; |
| 1018 | input_dev->dev.parent = &hdev->dev; |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1019 | input_dev->open = wacom_open; |
| 1020 | input_dev->close = wacom_close; |
Benjamin Tissoires | b6c79f2 | 2014-07-24 13:00:03 -0700 | [diff] [blame] | 1021 | input_dev->uniq = hdev->uniq; |
| 1022 | input_dev->id.bustype = hdev->bus; |
| 1023 | input_dev->id.vendor = hdev->vendor; |
| 1024 | input_dev->id.product = hdev->product; |
| 1025 | input_dev->id.version = hdev->version; |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1026 | input_set_drvdata(input_dev, wacom); |
| 1027 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1028 | return input_dev; |
| 1029 | } |
| 1030 | |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1031 | static void wacom_unregister_inputs(struct wacom *wacom) |
| 1032 | { |
| 1033 | if (wacom->wacom_wac.input) |
| 1034 | input_unregister_device(wacom->wacom_wac.input); |
| 1035 | if (wacom->wacom_wac.pad_input) |
| 1036 | input_unregister_device(wacom->wacom_wac.pad_input); |
| 1037 | wacom->wacom_wac.input = NULL; |
| 1038 | wacom->wacom_wac.pad_input = NULL; |
| 1039 | } |
| 1040 | |
| 1041 | static int wacom_register_inputs(struct wacom *wacom) |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1042 | { |
| 1043 | struct input_dev *input_dev, *pad_input_dev; |
| 1044 | struct wacom_wac *wacom_wac = &(wacom->wacom_wac); |
| 1045 | int error; |
| 1046 | |
| 1047 | input_dev = wacom_allocate_input(wacom); |
| 1048 | pad_input_dev = wacom_allocate_input(wacom); |
| 1049 | if (!input_dev || !pad_input_dev) { |
| 1050 | error = -ENOMEM; |
| 1051 | goto fail1; |
| 1052 | } |
| 1053 | |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1054 | wacom_wac->input = input_dev; |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1055 | wacom_wac->pad_input = pad_input_dev; |
| 1056 | wacom_wac->pad_input->name = wacom_wac->pad_name; |
| 1057 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1058 | error = wacom_setup_input_capabilities(input_dev, wacom_wac); |
| 1059 | if (error) |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1060 | goto fail2; |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1061 | |
| 1062 | error = input_register_device(input_dev); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1063 | if (error) |
| 1064 | goto fail2; |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1065 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1066 | error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); |
| 1067 | if (error) { |
| 1068 | /* no pad in use on this interface */ |
| 1069 | input_free_device(pad_input_dev); |
| 1070 | wacom_wac->pad_input = NULL; |
| 1071 | pad_input_dev = NULL; |
| 1072 | } else { |
| 1073 | error = input_register_device(pad_input_dev); |
| 1074 | if (error) |
| 1075 | goto fail3; |
| 1076 | } |
| 1077 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1078 | return 0; |
| 1079 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1080 | fail3: |
| 1081 | input_unregister_device(input_dev); |
| 1082 | input_dev = NULL; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1083 | fail2: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1084 | wacom_wac->input = NULL; |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1085 | wacom_wac->pad_input = NULL; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1086 | fail1: |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1087 | if (input_dev) |
| 1088 | input_free_device(input_dev); |
| 1089 | if (pad_input_dev) |
| 1090 | input_free_device(pad_input_dev); |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1091 | return error; |
| 1092 | } |
| 1093 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1094 | static void wacom_wireless_work(struct work_struct *work) |
| 1095 | { |
| 1096 | struct wacom *wacom = container_of(work, struct wacom, work); |
| 1097 | struct usb_device *usbdev = wacom->usbdev; |
| 1098 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1099 | struct hid_device *hdev1, *hdev2; |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1100 | struct wacom *wacom1, *wacom2; |
| 1101 | struct wacom_wac *wacom_wac1, *wacom_wac2; |
| 1102 | int error; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1103 | |
| 1104 | /* |
| 1105 | * Regardless if this is a disconnect or a new tablet, |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1106 | * remove any existing input and battery devices. |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1107 | */ |
| 1108 | |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1109 | wacom_destroy_battery(wacom); |
| 1110 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1111 | /* Stylus interface */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1112 | hdev1 = usb_get_intfdata(usbdev->config->interface[1]); |
| 1113 | wacom1 = hid_get_drvdata(hdev1); |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1114 | wacom_wac1 = &(wacom1->wacom_wac); |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1115 | wacom_unregister_inputs(wacom1); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1116 | |
| 1117 | /* Touch interface */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1118 | hdev2 = usb_get_intfdata(usbdev->config->interface[2]); |
| 1119 | wacom2 = hid_get_drvdata(hdev2); |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1120 | wacom_wac2 = &(wacom2->wacom_wac); |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1121 | wacom_unregister_inputs(wacom2); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1122 | |
| 1123 | if (wacom_wac->pid == 0) { |
Benjamin Tissoires | e2114ce | 2014-07-24 13:01:56 -0700 | [diff] [blame] | 1124 | hid_info(wacom->hdev, "wireless tablet disconnected\n"); |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 1125 | wacom_wac1->shared->type = 0; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1126 | } else { |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1127 | const struct hid_device_id *id = wacom_ids; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1128 | |
Benjamin Tissoires | e2114ce | 2014-07-24 13:01:56 -0700 | [diff] [blame] | 1129 | hid_info(wacom->hdev, "wireless tablet connected with PID %x\n", |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 1130 | wacom_wac->pid); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1131 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1132 | while (id->bus) { |
| 1133 | if (id->vendor == USB_VENDOR_ID_WACOM && |
| 1134 | id->product == wacom_wac->pid) |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1135 | break; |
| 1136 | id++; |
| 1137 | } |
| 1138 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1139 | if (!id->bus) { |
Benjamin Tissoires | e2114ce | 2014-07-24 13:01:56 -0700 | [diff] [blame] | 1140 | hid_info(wacom->hdev, "ignoring unknown PID.\n"); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1141 | return; |
| 1142 | } |
| 1143 | |
| 1144 | /* Stylus interface */ |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1145 | wacom_wac1->features = |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1146 | *((struct wacom_features *)id->driver_data); |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1147 | wacom_wac1->features.device_type = BTN_TOOL_PEN; |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1148 | snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", |
| 1149 | wacom_wac1->features.name); |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1150 | snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", |
| 1151 | wacom_wac1->features.name); |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 1152 | wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max; |
| 1153 | wacom_wac1->shared->type = wacom_wac1->features.type; |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1154 | error = wacom_register_inputs(wacom1); |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1155 | if (error) |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1156 | goto fail; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1157 | |
| 1158 | /* Touch interface */ |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 1159 | if (wacom_wac1->features.touch_max || |
| 1160 | wacom_wac1->features.type == INTUOSHT) { |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1161 | wacom_wac2->features = |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1162 | *((struct wacom_features *)id->driver_data); |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1163 | wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; |
| 1164 | wacom_wac2->features.device_type = BTN_TOOL_FINGER; |
| 1165 | wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; |
| 1166 | if (wacom_wac2->features.touch_max) |
| 1167 | snprintf(wacom_wac2->name, WACOM_NAME_MAX, |
| 1168 | "%s (WL) Finger",wacom_wac2->features.name); |
| 1169 | else |
| 1170 | snprintf(wacom_wac2->name, WACOM_NAME_MAX, |
| 1171 | "%s (WL) Pad",wacom_wac2->features.name); |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1172 | snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, |
| 1173 | "%s (WL) Pad", wacom_wac2->features.name); |
| 1174 | error = wacom_register_inputs(wacom2); |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1175 | if (error) |
| 1176 | goto fail; |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 1177 | |
| 1178 | if (wacom_wac1->features.type == INTUOSHT && |
| 1179 | wacom_wac1->features.touch_max) |
| 1180 | wacom_wac->shared->touch_input = wacom_wac2->input; |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1181 | } |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1182 | |
| 1183 | error = wacom_initialize_battery(wacom); |
| 1184 | if (error) |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1185 | goto fail; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1186 | } |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1187 | |
| 1188 | return; |
| 1189 | |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1190 | fail: |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1191 | wacom_unregister_inputs(wacom1); |
| 1192 | wacom_unregister_inputs(wacom2); |
Chris Bagwell | b7af2bb | 2012-06-12 00:25:23 -0700 | [diff] [blame] | 1193 | return; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
Ping Cheng | 401d7d1 | 2013-07-28 00:38:54 -0700 | [diff] [blame] | 1196 | /* |
| 1197 | * Not all devices report physical dimensions from HID. |
| 1198 | * Compute the default from hardcoded logical dimension |
| 1199 | * and resolution before driver overwrites them. |
| 1200 | */ |
| 1201 | static void wacom_set_default_phy(struct wacom_features *features) |
| 1202 | { |
| 1203 | if (features->x_resolution) { |
| 1204 | features->x_phy = (features->x_max * 100) / |
| 1205 | features->x_resolution; |
| 1206 | features->y_phy = (features->y_max * 100) / |
| 1207 | features->y_resolution; |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | static void wacom_calculate_res(struct wacom_features *features) |
| 1212 | { |
| 1213 | features->x_resolution = wacom_calc_hid_res(features->x_max, |
| 1214 | features->x_phy, |
| 1215 | features->unit, |
| 1216 | features->unitExpo); |
| 1217 | features->y_resolution = wacom_calc_hid_res(features->y_max, |
| 1218 | features->y_phy, |
| 1219 | features->unit, |
| 1220 | features->unitExpo); |
| 1221 | } |
| 1222 | |
Benjamin Tissoires | 01c846f | 2014-07-24 12:59:11 -0700 | [diff] [blame] | 1223 | static int wacom_hid_report_len(struct hid_report *report) |
| 1224 | { |
| 1225 | /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ |
| 1226 | return ((report->size - 1) >> 3) + 1 + (report->id > 0); |
| 1227 | } |
| 1228 | |
| 1229 | static size_t wacom_compute_pktlen(struct hid_device *hdev) |
| 1230 | { |
| 1231 | struct hid_report_enum *report_enum; |
| 1232 | struct hid_report *report; |
| 1233 | size_t size = 0; |
| 1234 | |
| 1235 | report_enum = hdev->report_enum + HID_INPUT_REPORT; |
| 1236 | |
| 1237 | list_for_each_entry(report, &report_enum->report_list, list) { |
| 1238 | size_t report_size = wacom_hid_report_len(report); |
| 1239 | if (report_size > size) |
| 1240 | size = report_size; |
| 1241 | } |
| 1242 | |
| 1243 | return size; |
| 1244 | } |
| 1245 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1246 | static int wacom_probe(struct hid_device *hdev, |
| 1247 | const struct hid_device_id *id) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1248 | { |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1249 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1250 | struct usb_device *dev = interface_to_usbdev(intf); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1251 | struct wacom *wacom; |
| 1252 | struct wacom_wac *wacom_wac; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 1253 | struct wacom_features *features; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 1254 | int error; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1255 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1256 | if (!id->driver_data) |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 1257 | return -EINVAL; |
| 1258 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1259 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
Dan Carpenter | f182394 | 2012-03-29 22:38:11 -0700 | [diff] [blame] | 1260 | if (!wacom) |
| 1261 | return -ENOMEM; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1262 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1263 | hid_set_drvdata(hdev, wacom); |
| 1264 | wacom->hdev = hdev; |
| 1265 | |
Benjamin Tissoires | ba9a354 | 2014-07-24 12:58:45 -0700 | [diff] [blame] | 1266 | /* ask for the report descriptor to be loaded by HID */ |
| 1267 | error = hid_parse(hdev); |
| 1268 | if (error) { |
| 1269 | hid_err(hdev, "parse failed\n"); |
| 1270 | goto fail1; |
| 1271 | } |
| 1272 | |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1273 | wacom_wac = &wacom->wacom_wac; |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1274 | wacom_wac->features = *((struct wacom_features *)id->driver_data); |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 1275 | features = &wacom_wac->features; |
Benjamin Tissoires | 01c846f | 2014-07-24 12:59:11 -0700 | [diff] [blame] | 1276 | features->pktlen = wacom_compute_pktlen(hdev); |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 1277 | if (features->pktlen > WACOM_PKGLEN_MAX) { |
| 1278 | error = -EINVAL; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1279 | goto fail1; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 1280 | } |
| 1281 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1282 | if (features->check_for_hid_type && features->hid_type != hdev->type) { |
| 1283 | error = -ENODEV; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 1284 | goto fail1; |
| 1285 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1286 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1287 | wacom->usbdev = dev; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1288 | wacom->intf = intf; |
| 1289 | mutex_init(&wacom->lock); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1290 | INIT_WORK(&wacom->work, wacom_wireless_work); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1291 | |
Ping Cheng | 401d7d1 | 2013-07-28 00:38:54 -0700 | [diff] [blame] | 1292 | /* set the default size in case we do not get them from hid */ |
| 1293 | wacom_set_default_phy(features); |
| 1294 | |
Ping Cheng | f393ee2 | 2012-04-29 21:09:17 -0700 | [diff] [blame] | 1295 | /* Retrieve the physical and logical size for touch devices */ |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 1296 | wacom_retrieve_hid_descriptor(hdev, features); |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1297 | |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 1298 | /* |
| 1299 | * Intuos5 has no useful data about its touch interface in its |
Benjamin Tissoires | 01c846f | 2014-07-24 12:59:11 -0700 | [diff] [blame] | 1300 | * HID descriptor. If this is the touch interface (PacketSize |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 1301 | * of WACOM_PKGLEN_BBTOUCH3), override the table values. |
| 1302 | */ |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 1303 | if (features->type >= INTUOS5S && features->type <= INTUOSHT) { |
Benjamin Tissoires | 01c846f | 2014-07-24 12:59:11 -0700 | [diff] [blame] | 1304 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 1305 | features->device_type = BTN_TOOL_FINGER; |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 1306 | |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 1307 | features->x_max = 4096; |
| 1308 | features->y_max = 4096; |
| 1309 | } else { |
| 1310 | features->device_type = BTN_TOOL_PEN; |
| 1311 | } |
| 1312 | } |
| 1313 | |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 1314 | /* |
| 1315 | * Same thing for Bamboo 3rd gen. |
| 1316 | */ |
| 1317 | if ((features->type == BAMBOO_PT) && |
| 1318 | (features->pktlen == WACOM_PKGLEN_BBTOUCH3) && |
| 1319 | (features->device_type == BTN_TOOL_PEN)) { |
| 1320 | features->device_type = BTN_TOOL_FINGER; |
| 1321 | |
| 1322 | features->x_max = 4096; |
| 1323 | features->y_max = 4096; |
| 1324 | } |
| 1325 | |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1326 | if (hdev->bus == BUS_BLUETOOTH) |
| 1327 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 1328 | |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 1329 | wacom_setup_device_quirks(features); |
| 1330 | |
Ping Cheng | 401d7d1 | 2013-07-28 00:38:54 -0700 | [diff] [blame] | 1331 | /* set unit to "100th of a mm" for devices not reported by HID */ |
| 1332 | if (!features->unit) { |
| 1333 | features->unit = 0x11; |
Benjamin Tissoires | c669fb2 | 2014-07-24 13:02:14 -0700 | [diff] [blame] | 1334 | features->unitExpo = -3; |
Ping Cheng | 401d7d1 | 2013-07-28 00:38:54 -0700 | [diff] [blame] | 1335 | } |
| 1336 | wacom_calculate_res(features); |
| 1337 | |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 1338 | strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 1339 | snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), |
| 1340 | "%s Pad", features->name); |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 1341 | |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 1342 | if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 1343 | /* Append the device type to the name */ |
Ping Cheng | 57bcfce | 2013-10-15 23:44:00 -0700 | [diff] [blame] | 1344 | if (features->device_type != BTN_TOOL_FINGER) |
| 1345 | strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); |
| 1346 | else if (features->touch_max) |
| 1347 | strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); |
| 1348 | else |
| 1349 | strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1350 | |
Benjamin Tissoires | 4451e08 | 2014-07-24 13:01:05 -0700 | [diff] [blame] | 1351 | error = wacom_add_shared_data(hdev); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1352 | if (error) |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1353 | goto fail1; |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 1354 | } |
| 1355 | |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 1356 | error = wacom_initialize_leds(wacom); |
Dmitry Torokhov | 5014186 | 2007-04-12 01:33:39 -0400 | [diff] [blame] | 1357 | if (error) |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1358 | goto fail2; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1359 | |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1360 | if (!(features->quirks & WACOM_QUIRK_MONITOR) && |
| 1361 | (features->quirks & WACOM_QUIRK_BATTERY)) { |
| 1362 | error = wacom_initialize_battery(wacom); |
| 1363 | if (error) |
| 1364 | goto fail3; |
| 1365 | } |
| 1366 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 1367 | if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1368 | error = wacom_register_inputs(wacom); |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 1369 | if (error) |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1370 | goto fail4; |
| 1371 | } |
| 1372 | |
| 1373 | if (hdev->bus == BUS_BLUETOOTH) { |
| 1374 | error = device_create_file(&hdev->dev, &dev_attr_speed); |
| 1375 | if (error) |
| 1376 | hid_warn(hdev, |
| 1377 | "can't create sysfs speed attribute err: %d\n", |
| 1378 | error); |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 1379 | } |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 1380 | |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1381 | /* Note that if query fails it is not a hard failure */ |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 1382 | wacom_query_tablet_data(hdev, features); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1383 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1384 | /* Regular HID work starts now */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1385 | error = hid_hw_start(hdev, HID_CONNECT_HIDRAW); |
| 1386 | if (error) { |
| 1387 | hid_err(hdev, "hw start failed\n"); |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1388 | goto fail5; |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | if (features->quirks & WACOM_QUIRK_MONITOR) |
| 1392 | error = hid_hw_open(hdev); |
| 1393 | |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 1394 | if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { |
| 1395 | if (wacom_wac->features.device_type == BTN_TOOL_FINGER) |
| 1396 | wacom_wac->shared->touch_input = wacom_wac->input; |
| 1397 | } |
| 1398 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1399 | return 0; |
| 1400 | |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1401 | fail5: if (hdev->bus == BUS_BLUETOOTH) |
| 1402 | device_remove_file(&hdev->dev, &dev_attr_speed); |
| 1403 | wacom_unregister_inputs(wacom); |
| 1404 | fail4: wacom_destroy_battery(wacom); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1405 | fail3: wacom_destroy_leds(wacom); |
| 1406 | fail2: wacom_remove_shared_data(wacom_wac); |
Chris Bagwell | 3aac0ef | 2012-03-25 23:25:45 -0700 | [diff] [blame] | 1407 | fail1: kfree(wacom); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1408 | hid_set_drvdata(hdev, NULL); |
Dmitry Torokhov | 5014186 | 2007-04-12 01:33:39 -0400 | [diff] [blame] | 1409 | return error; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1410 | } |
| 1411 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1412 | static void wacom_remove(struct hid_device *hdev) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1413 | { |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1414 | struct wacom *wacom = hid_get_drvdata(hdev); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1415 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1416 | hid_hw_stop(hdev); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1417 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 1418 | cancel_work_sync(&wacom->work); |
Benjamin Tissoires | 008f4d9 | 2014-07-24 12:51:26 -0700 | [diff] [blame] | 1419 | wacom_unregister_inputs(wacom); |
Benjamin Tissoires | f81a129 | 2014-08-06 13:48:01 -0700 | [diff] [blame] | 1420 | if (hdev->bus == BUS_BLUETOOTH) |
| 1421 | device_remove_file(&hdev->dev, &dev_attr_speed); |
Chris Bagwell | a1d552c | 2012-03-25 23:26:30 -0700 | [diff] [blame] | 1422 | wacom_destroy_battery(wacom); |
Eduard Hasenleithner | 5d7e7d4 | 2011-09-07 14:08:54 -0700 | [diff] [blame] | 1423 | wacom_destroy_leds(wacom); |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1424 | wacom_remove_shared_data(&wacom->wacom_wac); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1425 | |
| 1426 | hid_set_drvdata(hdev, NULL); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1427 | kfree(wacom); |
| 1428 | } |
| 1429 | |
Geert Uytterhoeven | 41a7458 | 2014-08-11 11:03:19 -0700 | [diff] [blame] | 1430 | #ifdef CONFIG_PM |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1431 | static int wacom_resume(struct hid_device *hdev) |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1432 | { |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1433 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1434 | struct wacom_features *features = &wacom->wacom_wac.features; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1435 | |
| 1436 | mutex_lock(&wacom->lock); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1437 | |
| 1438 | /* switch to wacom mode first */ |
Benjamin Tissoires | 27b20a9 | 2014-07-24 12:56:22 -0700 | [diff] [blame] | 1439 | wacom_query_tablet_data(hdev, features); |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1440 | wacom_led_control(wacom); |
| 1441 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1442 | mutex_unlock(&wacom->lock); |
| 1443 | |
| 1444 | return 0; |
| 1445 | } |
| 1446 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1447 | static int wacom_reset_resume(struct hid_device *hdev) |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1448 | { |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1449 | return wacom_resume(hdev); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1450 | } |
Geert Uytterhoeven | 41a7458 | 2014-08-11 11:03:19 -0700 | [diff] [blame] | 1451 | #endif /* CONFIG_PM */ |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1452 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1453 | static struct hid_driver wacom_driver = { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1454 | .name = "wacom", |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 1455 | .id_table = wacom_ids, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1456 | .probe = wacom_probe, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1457 | .remove = wacom_remove, |
| 1458 | #ifdef CONFIG_PM |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 1459 | .resume = wacom_resume, |
| 1460 | .reset_resume = wacom_reset_resume, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1461 | #endif |
| 1462 | .raw_event = wacom_raw_event, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1463 | }; |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 1464 | module_hid_driver(wacom_driver); |
Benjamin Tissoires | f2e0a7d | 2014-08-06 14:07:49 -0700 | [diff] [blame] | 1465 | |
| 1466 | MODULE_VERSION(DRIVER_VERSION); |
| 1467 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 1468 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 1469 | MODULE_LICENSE(DRIVER_LICENSE); |