wacom_sys.c (8d58b66ed2b000f27658c88a4ed70e8042e86a58) wacom_sys.c (72b236d60218fe211a8e1210be31c31e81684b86)
1/*
2 * drivers/input/tablet/wacom_sys.c
3 *
4 * USB Wacom tablet support - system specific code
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify

--- 9 unchanged lines hidden (view full) ---

18#define WAC_MSG_RETRIES 5
19
20#define WAC_CMD_WL_LED_CONTROL 0x03
21#define WAC_CMD_LED_CONTROL 0x20
22#define WAC_CMD_ICON_START 0x21
23#define WAC_CMD_ICON_XFER 0x23
24#define WAC_CMD_ICON_BT_XFER 0x26
25#define WAC_CMD_RETRIES 10
1/*
2 * drivers/input/tablet/wacom_sys.c
3 *
4 * USB Wacom tablet support - system specific code
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify

--- 9 unchanged lines hidden (view full) ---

18#define WAC_MSG_RETRIES 5
19
20#define WAC_CMD_WL_LED_CONTROL 0x03
21#define WAC_CMD_LED_CONTROL 0x20
22#define WAC_CMD_ICON_START 0x21
23#define WAC_CMD_ICON_XFER 0x23
24#define WAC_CMD_ICON_BT_XFER 0x26
25#define WAC_CMD_RETRIES 10
26#define WAC_CMD_DELETE_PAIRING 0x20
27#define WAC_CMD_UNPAIR_ALL 0xFF
28#define WAC_REMOTE_SERIAL_MAX_STRLEN 9
26
27#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
28#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
29
30#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
31#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
32#define DEV_ATTR_RO_PERM (S_IRUSR | S_IRGRP)
29
30static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
31 size_t size, unsigned int retries)
32{
33 int retval;
34
35 do {
36 retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,

--- 293 unchanged lines hidden (view full) ---

330 rep_data[0] = report_id;
331 rep_data[1] = mode;
332
333 error = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data,
334 length, 1);
335 if (error >= 0)
336 error = wacom_get_report(hdev, HID_FEATURE_REPORT,
337 rep_data, length, 1);
33
34static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
35 size_t size, unsigned int retries)
36{
37 int retval;
38
39 do {
40 retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,

--- 293 unchanged lines hidden (view full) ---

334 rep_data[0] = report_id;
335 rep_data[1] = mode;
336
337 error = wacom_set_report(hdev, HID_FEATURE_REPORT, rep_data,
338 length, 1);
339 if (error >= 0)
340 error = wacom_get_report(hdev, HID_FEATURE_REPORT,
341 rep_data, length, 1);
338 } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
342 } while (error >= 0 && rep_data[1] != mode && limit++ < WAC_MSG_RETRIES);
339
340 kfree(rep_data);
341
342 return error < 0 ? error : 0;
343}
344
345static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
346 struct wacom_features *features)

--- 101 unchanged lines hidden (view full) ---

448
449 /*
450 * The wireless device HID is basic and layout conflicts with
451 * other tablets (monitor and touch interface can look like pen).
452 * Skip the query for this type and modify defaults based on
453 * interface number.
454 */
455 if (features->type == WIRELESS) {
343
344 kfree(rep_data);
345
346 return error < 0 ? error : 0;
347}
348
349static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
350 struct wacom_features *features)

--- 101 unchanged lines hidden (view full) ---

452
453 /*
454 * The wireless device HID is basic and layout conflicts with
455 * other tablets (monitor and touch interface can look like pen).
456 * Skip the query for this type and modify defaults based on
457 * interface number.
458 */
459 if (features->type == WIRELESS) {
456 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
460 if (intf->cur_altsetting->desc.bInterfaceNumber == 0)
461 features->device_type = WACOM_DEVICETYPE_WL_MONITOR;
462 else
457 features->device_type = WACOM_DEVICETYPE_NONE;
463 features->device_type = WACOM_DEVICETYPE_NONE;
458 } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) {
459 features->device_type |= WACOM_DEVICETYPE_TOUCH;
460 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
461 }
464 return;
462 }
463
464 wacom_parse_hid(hdev, features);
465}
466
467struct wacom_hdev_data {
468 struct list_head list;
469 struct kref kref;

--- 645 unchanged lines hidden (view full) ---

1115 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features);
1116
1117 return count;
1118}
1119
1120static DEVICE_ATTR(speed, DEV_ATTR_RW_PERM,
1121 wacom_show_speed, wacom_store_speed);
1122
465 }
466
467 wacom_parse_hid(hdev, features);
468}
469
470struct wacom_hdev_data {
471 struct list_head list;
472 struct kref kref;

--- 645 unchanged lines hidden (view full) ---

1118 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features);
1119
1120 return count;
1121}
1122
1123static DEVICE_ATTR(speed, DEV_ATTR_RW_PERM,
1124 wacom_show_speed, wacom_store_speed);
1125
1126
1127static ssize_t wacom_show_remote_mode(struct kobject *kobj,
1128 struct kobj_attribute *kattr,
1129 char *buf, int index)
1130{
1131 struct device *dev = container_of(kobj->parent, struct device, kobj);
1132 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1133 struct wacom *wacom = hid_get_drvdata(hdev);
1134 u8 mode;
1135
1136 mode = wacom->led.select[index];
1137 if (mode >= 0 && mode < 3)
1138 return snprintf(buf, PAGE_SIZE, "%d\n", mode);
1139 else
1140 return snprintf(buf, PAGE_SIZE, "%d\n", -1);
1141}
1142
1143#define DEVICE_EKR_ATTR_GROUP(SET_ID) \
1144static ssize_t wacom_show_remote##SET_ID##_mode(struct kobject *kobj, \
1145 struct kobj_attribute *kattr, char *buf) \
1146{ \
1147 return wacom_show_remote_mode(kobj, kattr, buf, SET_ID); \
1148} \
1149static struct kobj_attribute remote##SET_ID##_mode_attr = { \
1150 .attr = {.name = "remote_mode", \
1151 .mode = DEV_ATTR_RO_PERM}, \
1152 .show = wacom_show_remote##SET_ID##_mode, \
1153}; \
1154static struct attribute *remote##SET_ID##_serial_attrs[] = { \
1155 &remote##SET_ID##_mode_attr.attr, \
1156 NULL \
1157}; \
1158static struct attribute_group remote##SET_ID##_serial_group = { \
1159 .name = NULL, \
1160 .attrs = remote##SET_ID##_serial_attrs, \
1161}
1162
1163DEVICE_EKR_ATTR_GROUP(0);
1164DEVICE_EKR_ATTR_GROUP(1);
1165DEVICE_EKR_ATTR_GROUP(2);
1166DEVICE_EKR_ATTR_GROUP(3);
1167DEVICE_EKR_ATTR_GROUP(4);
1168
1169int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial, int index)
1170{
1171 int error = 0;
1172 char *buf;
1173 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1174
1175 wacom_wac->serial[index] = serial;
1176
1177 buf = kzalloc(WAC_REMOTE_SERIAL_MAX_STRLEN, GFP_KERNEL);
1178 if (!buf)
1179 return -ENOMEM;
1180 snprintf(buf, WAC_REMOTE_SERIAL_MAX_STRLEN, "%d", serial);
1181 wacom->remote_group[index].name = buf;
1182
1183 error = sysfs_create_group(wacom->remote_dir,
1184 &wacom->remote_group[index]);
1185 if (error) {
1186 hid_err(wacom->hdev,
1187 "cannot create sysfs group err: %d\n", error);
1188 kobject_put(wacom->remote_dir);
1189 return error;
1190 }
1191
1192 return 0;
1193}
1194
1195void wacom_remote_destroy_attr_group(struct wacom *wacom, __u32 serial)
1196{
1197 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1198 int i;
1199
1200 if (!serial)
1201 return;
1202
1203 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1204 if (wacom_wac->serial[i] == serial) {
1205 wacom_wac->serial[i] = 0;
1206 wacom->led.select[i] = WACOM_STATUS_UNKNOWN;
1207 if (wacom->remote_group[i].name) {
1208 sysfs_remove_group(wacom->remote_dir,
1209 &wacom->remote_group[i]);
1210 kfree(wacom->remote_group[i].name);
1211 wacom->remote_group[i].name = NULL;
1212 }
1213 }
1214 }
1215}
1216
1217static int wacom_cmd_unpair_remote(struct wacom *wacom, unsigned char selector)
1218{
1219 const size_t buf_size = 2;
1220 unsigned char *buf;
1221 int retval;
1222
1223 buf = kzalloc(buf_size, GFP_KERNEL);
1224 if (!buf)
1225 return -ENOMEM;
1226
1227 buf[0] = WAC_CMD_DELETE_PAIRING;
1228 buf[1] = selector;
1229
1230 retval = wacom_set_report(wacom->hdev, HID_OUTPUT_REPORT, buf,
1231 buf_size, WAC_CMD_RETRIES);
1232 kfree(buf);
1233
1234 return retval;
1235}
1236
1237static ssize_t wacom_store_unpair_remote(struct kobject *kobj,
1238 struct kobj_attribute *attr,
1239 const char *buf, size_t count)
1240{
1241 unsigned char selector = 0;
1242 struct device *dev = container_of(kobj->parent, struct device, kobj);
1243 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1244 struct wacom *wacom = hid_get_drvdata(hdev);
1245 int err;
1246
1247 if (!strncmp(buf, "*\n", 2)) {
1248 selector = WAC_CMD_UNPAIR_ALL;
1249 } else {
1250 hid_info(wacom->hdev, "remote: unrecognized unpair code: %s\n",
1251 buf);
1252 return -1;
1253 }
1254
1255 mutex_lock(&wacom->lock);
1256
1257 err = wacom_cmd_unpair_remote(wacom, selector);
1258 mutex_unlock(&wacom->lock);
1259
1260 return err < 0 ? err : count;
1261}
1262
1263static struct kobj_attribute unpair_remote_attr = {
1264 .attr = {.name = "unpair_remote", .mode = 0200},
1265 .store = wacom_store_unpair_remote,
1266};
1267
1268static const struct attribute *remote_unpair_attrs[] = {
1269 &unpair_remote_attr.attr,
1270 NULL
1271};
1272
1273static int wacom_initialize_remote(struct wacom *wacom)
1274{
1275 int error = 0;
1276 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1277 int i;
1278
1279 if (wacom->wacom_wac.features.type != REMOTE)
1280 return 0;
1281
1282 wacom->remote_group[0] = remote0_serial_group;
1283 wacom->remote_group[1] = remote1_serial_group;
1284 wacom->remote_group[2] = remote2_serial_group;
1285 wacom->remote_group[3] = remote3_serial_group;
1286 wacom->remote_group[4] = remote4_serial_group;
1287
1288 wacom->remote_dir = kobject_create_and_add("wacom_remote",
1289 &wacom->hdev->dev.kobj);
1290 if (!wacom->remote_dir)
1291 return -ENOMEM;
1292
1293 error = sysfs_create_files(wacom->remote_dir, remote_unpair_attrs);
1294
1295 if (error) {
1296 hid_err(wacom->hdev,
1297 "cannot create sysfs group err: %d\n", error);
1298 return error;
1299 }
1300
1301 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1302 wacom->led.select[i] = WACOM_STATUS_UNKNOWN;
1303 wacom_wac->serial[i] = 0;
1304 }
1305
1306 return 0;
1307}
1308
1123static struct input_dev *wacom_allocate_input(struct wacom *wacom)
1124{
1125 struct input_dev *input_dev;
1126 struct hid_device *hdev = wacom->hdev;
1127 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1128
1129 input_dev = input_allocate_device();
1130 if (!input_dev)
1131 return NULL;
1132
1309static struct input_dev *wacom_allocate_input(struct wacom *wacom)
1310{
1311 struct input_dev *input_dev;
1312 struct hid_device *hdev = wacom->hdev;
1313 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1314
1315 input_dev = input_allocate_device();
1316 if (!input_dev)
1317 return NULL;
1318
1133 input_dev->name = wacom_wac->pen_name;
1319 input_dev->name = wacom_wac->features.name;
1134 input_dev->phys = hdev->phys;
1135 input_dev->dev.parent = &hdev->dev;
1136 input_dev->open = wacom_open;
1137 input_dev->close = wacom_close;
1138 input_dev->uniq = hdev->uniq;
1139 input_dev->id.bustype = hdev->bus;
1140 input_dev->id.vendor = hdev->vendor;
1141 input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product;
1142 input_dev->id.version = hdev->version;
1143 input_set_drvdata(input_dev, wacom);
1144
1145 return input_dev;
1146}
1147
1320 input_dev->phys = hdev->phys;
1321 input_dev->dev.parent = &hdev->dev;
1322 input_dev->open = wacom_open;
1323 input_dev->close = wacom_close;
1324 input_dev->uniq = hdev->uniq;
1325 input_dev->id.bustype = hdev->bus;
1326 input_dev->id.vendor = hdev->vendor;
1327 input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product;
1328 input_dev->id.version = hdev->version;
1329 input_set_drvdata(input_dev, wacom);
1330
1331 return input_dev;
1332}
1333
1148static void wacom_free_inputs(struct wacom *wacom)
1149{
1150 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1151
1152 if (wacom_wac->pen_input)
1153 input_free_device(wacom_wac->pen_input);
1154 if (wacom_wac->touch_input)
1155 input_free_device(wacom_wac->touch_input);
1156 if (wacom_wac->pad_input)
1157 input_free_device(wacom_wac->pad_input);
1158 wacom_wac->pen_input = NULL;
1159 wacom_wac->touch_input = NULL;
1160 wacom_wac->pad_input = NULL;
1161}
1162
1163static int wacom_allocate_inputs(struct wacom *wacom)
1164{
1165 struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
1166 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1167
1168 pen_input_dev = wacom_allocate_input(wacom);
1169 touch_input_dev = wacom_allocate_input(wacom);
1170 pad_input_dev = wacom_allocate_input(wacom);
1171 if (!pen_input_dev || !touch_input_dev || !pad_input_dev) {
1172 wacom_free_inputs(wacom);
1173 return -ENOMEM;
1174 }
1175
1176 wacom_wac->pen_input = pen_input_dev;
1177 wacom_wac->touch_input = touch_input_dev;
1178 wacom_wac->touch_input->name = wacom_wac->touch_name;
1179 wacom_wac->pad_input = pad_input_dev;
1180 wacom_wac->pad_input->name = wacom_wac->pad_name;
1181
1182 return 0;
1183}
1184
1185static void wacom_clean_inputs(struct wacom *wacom)
1186{
1187 if (wacom->wacom_wac.pen_input) {
1188 if (wacom->wacom_wac.pen_registered)
1189 input_unregister_device(wacom->wacom_wac.pen_input);
1190 else
1191 input_free_device(wacom->wacom_wac.pen_input);
1192 }

--- 4 unchanged lines hidden (view full) ---

1197 input_free_device(wacom->wacom_wac.touch_input);
1198 }
1199 if (wacom->wacom_wac.pad_input) {
1200 if (wacom->wacom_wac.pad_registered)
1201 input_unregister_device(wacom->wacom_wac.pad_input);
1202 else
1203 input_free_device(wacom->wacom_wac.pad_input);
1204 }
1334static void wacom_clean_inputs(struct wacom *wacom)
1335{
1336 if (wacom->wacom_wac.pen_input) {
1337 if (wacom->wacom_wac.pen_registered)
1338 input_unregister_device(wacom->wacom_wac.pen_input);
1339 else
1340 input_free_device(wacom->wacom_wac.pen_input);
1341 }

--- 4 unchanged lines hidden (view full) ---

1346 input_free_device(wacom->wacom_wac.touch_input);
1347 }
1348 if (wacom->wacom_wac.pad_input) {
1349 if (wacom->wacom_wac.pad_registered)
1350 input_unregister_device(wacom->wacom_wac.pad_input);
1351 else
1352 input_free_device(wacom->wacom_wac.pad_input);
1353 }
1354 if (wacom->remote_dir)
1355 kobject_put(wacom->remote_dir);
1205 wacom->wacom_wac.pen_input = NULL;
1206 wacom->wacom_wac.touch_input = NULL;
1207 wacom->wacom_wac.pad_input = NULL;
1208 wacom_destroy_leds(wacom);
1209}
1210
1356 wacom->wacom_wac.pen_input = NULL;
1357 wacom->wacom_wac.touch_input = NULL;
1358 wacom->wacom_wac.pad_input = NULL;
1359 wacom_destroy_leds(wacom);
1360}
1361
1362static int wacom_allocate_inputs(struct wacom *wacom)
1363{
1364 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1365
1366 wacom_wac->pen_input = wacom_allocate_input(wacom);
1367 wacom_wac->touch_input = wacom_allocate_input(wacom);
1368 wacom_wac->pad_input = wacom_allocate_input(wacom);
1369 if (!wacom_wac->pen_input || !wacom_wac->touch_input || !wacom_wac->pad_input) {
1370 wacom_clean_inputs(wacom);
1371 return -ENOMEM;
1372 }
1373
1374 wacom_wac->pen_input->name = wacom_wac->pen_name;
1375 wacom_wac->touch_input->name = wacom_wac->touch_name;
1376 wacom_wac->pad_input->name = wacom_wac->pad_name;
1377
1378 return 0;
1379}
1380
1211static int wacom_register_inputs(struct wacom *wacom)
1212{
1213 struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
1214 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1215 int error = 0;
1216
1217 pen_input_dev = wacom_wac->pen_input;
1218 touch_input_dev = wacom_wac->touch_input;

--- 38 unchanged lines hidden (view full) ---

1257 error = input_register_device(pad_input_dev);
1258 if (error)
1259 goto fail_register_pad_input;
1260 wacom_wac->pad_registered = true;
1261
1262 error = wacom_initialize_leds(wacom);
1263 if (error)
1264 goto fail_leds;
1381static int wacom_register_inputs(struct wacom *wacom)
1382{
1383 struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
1384 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1385 int error = 0;
1386
1387 pen_input_dev = wacom_wac->pen_input;
1388 touch_input_dev = wacom_wac->touch_input;

--- 38 unchanged lines hidden (view full) ---

1427 error = input_register_device(pad_input_dev);
1428 if (error)
1429 goto fail_register_pad_input;
1430 wacom_wac->pad_registered = true;
1431
1432 error = wacom_initialize_leds(wacom);
1433 if (error)
1434 goto fail_leds;
1435
1436 error = wacom_initialize_remote(wacom);
1437 if (error)
1438 goto fail_remote;
1265 }
1266
1267 return 0;
1268
1439 }
1440
1441 return 0;
1442
1443fail_remote:
1444 wacom_destroy_leds(wacom);
1269fail_leds:
1270 input_unregister_device(pad_input_dev);
1271 pad_input_dev = NULL;
1272 wacom_wac->pad_registered = false;
1273fail_register_pad_input:
1445fail_leds:
1446 input_unregister_device(pad_input_dev);
1447 pad_input_dev = NULL;
1448 wacom_wac->pad_registered = false;
1449fail_register_pad_input:
1274 if (touch_input_dev)
1275 input_unregister_device(touch_input_dev);
1450 input_unregister_device(touch_input_dev);
1276 wacom_wac->touch_input = NULL;
1277 wacom_wac->touch_registered = false;
1278fail_register_touch_input:
1451 wacom_wac->touch_input = NULL;
1452 wacom_wac->touch_registered = false;
1453fail_register_touch_input:
1279 if (pen_input_dev)
1280 input_unregister_device(pen_input_dev);
1454 input_unregister_device(pen_input_dev);
1281 wacom_wac->pen_input = NULL;
1282 wacom_wac->pen_registered = false;
1283fail_register_pen_input:
1284 return error;
1285}
1286
1455 wacom_wac->pen_input = NULL;
1456 wacom_wac->pen_registered = false;
1457fail_register_pen_input:
1458 return error;
1459}
1460
1287/*
1288 * Not all devices report physical dimensions from HID.
1289 * Compute the default from hardcoded logical dimension
1290 * and resolution before driver overwrites them.
1291 */
1292static void wacom_set_default_phy(struct wacom_features *features)
1293{
1294 if (features->x_resolution) {
1295 features->x_phy = (features->x_max * 100) /
1296 features->x_resolution;
1297 features->y_phy = (features->y_max * 100) /
1298 features->y_resolution;
1299 }
1300}
1301
1302static void wacom_calculate_res(struct wacom_features *features)
1303{
1304 /* set unit to "100th of a mm" for devices not reported by HID */
1305 if (!features->unit) {
1306 features->unit = 0x11;
1307 features->unitExpo = -3;
1308 }
1309
1310 features->x_resolution = wacom_calc_hid_res(features->x_max,
1311 features->x_phy,
1312 features->unit,
1313 features->unitExpo);
1314 features->y_resolution = wacom_calc_hid_res(features->y_max,
1315 features->y_phy,
1316 features->unit,
1317 features->unitExpo);
1318}
1319
1320static void wacom_wireless_work(struct work_struct *work)
1321{
1322 struct wacom *wacom = container_of(work, struct wacom, work);
1323 struct usb_device *usbdev = wacom->usbdev;
1324 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1325 struct hid_device *hdev1, *hdev2;
1326 struct wacom *wacom1, *wacom2;
1327 struct wacom_wac *wacom_wac1, *wacom_wac2;

--- 41 unchanged lines hidden (view full) ---

1369
1370 /* Stylus interface */
1371 wacom_wac1->features =
1372 *((struct wacom_features *)id->driver_data);
1373 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PEN;
1374 if (wacom_wac1->features.type != INTUOSHT &&
1375 wacom_wac1->features.type != BAMBOO_PT)
1376 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1461static void wacom_wireless_work(struct work_struct *work)
1462{
1463 struct wacom *wacom = container_of(work, struct wacom, work);
1464 struct usb_device *usbdev = wacom->usbdev;
1465 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1466 struct hid_device *hdev1, *hdev2;
1467 struct wacom *wacom1, *wacom2;
1468 struct wacom_wac *wacom_wac1, *wacom_wac2;

--- 41 unchanged lines hidden (view full) ---

1510
1511 /* Stylus interface */
1512 wacom_wac1->features =
1513 *((struct wacom_features *)id->driver_data);
1514 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PEN;
1515 if (wacom_wac1->features.type != INTUOSHT &&
1516 wacom_wac1->features.type != BAMBOO_PT)
1517 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1377 wacom_set_default_phy(&wacom_wac1->features);
1378 wacom_calculate_res(&wacom_wac1->features);
1379 snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
1380 wacom_wac1->features.name);
1381 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1382 wacom_wac1->features.name);
1383 wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
1384 wacom_wac1->shared->type = wacom_wac1->features.type;
1385 wacom_wac1->pid = wacom_wac->pid;
1386 error = wacom_allocate_inputs(wacom1) ||
1387 wacom_register_inputs(wacom1);
1388 if (error)
1389 goto fail;
1390
1391 /* Touch interface */
1392 if (wacom_wac1->features.touch_max ||
1393 wacom_wac1->features.type == INTUOSHT) {
1394 wacom_wac2->features =
1395 *((struct wacom_features *)id->driver_data);
1396 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1518 snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
1519 wacom_wac1->features.name);
1520 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1521 wacom_wac1->features.name);
1522 wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
1523 wacom_wac1->shared->type = wacom_wac1->features.type;
1524 wacom_wac1->pid = wacom_wac->pid;
1525 error = wacom_allocate_inputs(wacom1) ||
1526 wacom_register_inputs(wacom1);
1527 if (error)
1528 goto fail;
1529
1530 /* Touch interface */
1531 if (wacom_wac1->features.touch_max ||
1532 wacom_wac1->features.type == INTUOSHT) {
1533 wacom_wac2->features =
1534 *((struct wacom_features *)id->driver_data);
1535 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1397 wacom_set_default_phy(&wacom_wac2->features);
1398 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1536 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1399 wacom_calculate_res(&wacom_wac2->features);
1400 snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
1401 "%s (WL) Finger",wacom_wac2->features.name);
1402 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1403 "%s (WL) Pad",wacom_wac2->features.name);
1404 if (wacom_wac1->features.touch_max)
1405 wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH;
1406 if (wacom_wac1->features.type == INTUOSHT ||
1407 wacom_wac1->features.type == BAMBOO_PT)

--- 31 unchanged lines hidden (view full) ---

1439 wacom_initialize_battery(wacom);
1440 }
1441 else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
1442 wacom->battery) {
1443 wacom_destroy_battery(wacom);
1444 }
1445}
1446
1537 snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
1538 "%s (WL) Finger",wacom_wac2->features.name);
1539 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1540 "%s (WL) Pad",wacom_wac2->features.name);
1541 if (wacom_wac1->features.touch_max)
1542 wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH;
1543 if (wacom_wac1->features.type == INTUOSHT ||
1544 wacom_wac1->features.type == BAMBOO_PT)

--- 31 unchanged lines hidden (view full) ---

1576 wacom_initialize_battery(wacom);
1577 }
1578 else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
1579 wacom->battery) {
1580 wacom_destroy_battery(wacom);
1581 }
1582}
1583
1584/*
1585 * Not all devices report physical dimensions from HID.
1586 * Compute the default from hardcoded logical dimension
1587 * and resolution before driver overwrites them.
1588 */
1589static void wacom_set_default_phy(struct wacom_features *features)
1590{
1591 if (features->x_resolution) {
1592 features->x_phy = (features->x_max * 100) /
1593 features->x_resolution;
1594 features->y_phy = (features->y_max * 100) /
1595 features->y_resolution;
1596 }
1597}
1598
1599static void wacom_calculate_res(struct wacom_features *features)
1600{
1601 /* set unit to "100th of a mm" for devices not reported by HID */
1602 if (!features->unit) {
1603 features->unit = 0x11;
1604 features->unitExpo = -3;
1605 }
1606
1607 features->x_resolution = wacom_calc_hid_res(features->x_max,
1608 features->x_phy,
1609 features->unit,
1610 features->unitExpo);
1611 features->y_resolution = wacom_calc_hid_res(features->y_max,
1612 features->y_phy,
1613 features->unit,
1614 features->unitExpo);
1615}
1616
1447static size_t wacom_compute_pktlen(struct hid_device *hdev)
1448{
1449 struct hid_report_enum *report_enum;
1450 struct hid_report *report;
1451 size_t size = 0;
1452
1453 report_enum = hdev->report_enum + HID_INPUT_REPORT;
1454

--- 96 unchanged lines hidden (view full) ---

1551 goto fail_type;
1552 }
1553
1554 wacom->usbdev = dev;
1555 wacom->intf = intf;
1556 mutex_init(&wacom->lock);
1557 INIT_WORK(&wacom->work, wacom_wireless_work);
1558
1617static size_t wacom_compute_pktlen(struct hid_device *hdev)
1618{
1619 struct hid_report_enum *report_enum;
1620 struct hid_report *report;
1621 size_t size = 0;
1622
1623 report_enum = hdev->report_enum + HID_INPUT_REPORT;
1624

--- 96 unchanged lines hidden (view full) ---

1721 goto fail_type;
1722 }
1723
1724 wacom->usbdev = dev;
1725 wacom->intf = intf;
1726 mutex_init(&wacom->lock);
1727 INIT_WORK(&wacom->work, wacom_wireless_work);
1728
1559 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
1560 error = wacom_allocate_inputs(wacom);
1561 if (error)
1562 goto fail_allocate_inputs;
1563 }
1729 error = wacom_allocate_inputs(wacom);
1730 if (error)
1731 goto fail_allocate_inputs;
1564
1565 /*
1566 * Bamboo Pad has a generic hid handling for the Pen, and we switch it
1567 * into debug mode for the touch part.
1568 * We ignore the other interfaces.
1569 */
1570 if (features->type == BAMBOO_PAD) {
1571 if (features->pktlen == WACOM_PKGLEN_PENABLED) {

--- 29 unchanged lines hidden (view full) ---

1601 wacom_calculate_res(features);
1602
1603 wacom_update_name(wacom);
1604
1605 error = wacom_add_shared_data(hdev);
1606 if (error)
1607 goto fail_shared_data;
1608
1732
1733 /*
1734 * Bamboo Pad has a generic hid handling for the Pen, and we switch it
1735 * into debug mode for the touch part.
1736 * We ignore the other interfaces.
1737 */
1738 if (features->type == BAMBOO_PAD) {
1739 if (features->pktlen == WACOM_PKGLEN_PENABLED) {

--- 29 unchanged lines hidden (view full) ---

1769 wacom_calculate_res(features);
1770
1771 wacom_update_name(wacom);
1772
1773 error = wacom_add_shared_data(hdev);
1774 if (error)
1775 goto fail_shared_data;
1776
1609 if (!(features->quirks & WACOM_QUIRK_MONITOR) &&
1777 if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) &&
1610 (features->quirks & WACOM_QUIRK_BATTERY)) {
1611 error = wacom_initialize_battery(wacom);
1612 if (error)
1613 goto fail_battery;
1614 }
1615
1778 (features->quirks & WACOM_QUIRK_BATTERY)) {
1779 error = wacom_initialize_battery(wacom);
1780 if (error)
1781 goto fail_battery;
1782 }
1783
1616 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
1617 error = wacom_register_inputs(wacom);
1618 if (error)
1619 goto fail_register_inputs;
1620 }
1784 error = wacom_register_inputs(wacom);
1785 if (error)
1786 goto fail_register_inputs;
1621
1622 if (hdev->bus == BUS_BLUETOOTH) {
1623 error = device_create_file(&hdev->dev, &dev_attr_speed);
1624 if (error)
1625 hid_warn(hdev,
1626 "can't create sysfs speed attribute err: %d\n",
1627 error);
1628 }

--- 6 unchanged lines hidden (view full) ---

1635 if (error) {
1636 hid_err(hdev, "hw start failed\n");
1637 goto fail_hw_start;
1638 }
1639
1640 /* Note that if query fails it is not a hard failure */
1641 wacom_query_tablet_data(hdev, features);
1642
1787
1788 if (hdev->bus == BUS_BLUETOOTH) {
1789 error = device_create_file(&hdev->dev, &dev_attr_speed);
1790 if (error)
1791 hid_warn(hdev,
1792 "can't create sysfs speed attribute err: %d\n",
1793 error);
1794 }

--- 6 unchanged lines hidden (view full) ---

1801 if (error) {
1802 hid_err(hdev, "hw start failed\n");
1803 goto fail_hw_start;
1804 }
1805
1806 /* Note that if query fails it is not a hard failure */
1807 wacom_query_tablet_data(hdev, features);
1808
1643 if (features->quirks & WACOM_QUIRK_MONITOR)
1809 if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR)
1644 error = hid_hw_open(hdev);
1645
1646 if (wacom_wac->features.type == INTUOSHT &&
1647 wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
1648 wacom_wac->shared->touch_input = wacom_wac->touch_input;
1649 }
1650
1651 return 0;

--- 57 unchanged lines hidden (view full) ---

1709}
1710#endif /* CONFIG_PM */
1711
1712static struct hid_driver wacom_driver = {
1713 .name = "wacom",
1714 .id_table = wacom_ids,
1715 .probe = wacom_probe,
1716 .remove = wacom_remove,
1810 error = hid_hw_open(hdev);
1811
1812 if (wacom_wac->features.type == INTUOSHT &&
1813 wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
1814 wacom_wac->shared->touch_input = wacom_wac->touch_input;
1815 }
1816
1817 return 0;

--- 57 unchanged lines hidden (view full) ---

1875}
1876#endif /* CONFIG_PM */
1877
1878static struct hid_driver wacom_driver = {
1879 .name = "wacom",
1880 .id_table = wacom_ids,
1881 .probe = wacom_probe,
1882 .remove = wacom_remove,
1717 .event = wacom_wac_event,
1718 .report = wacom_wac_report,
1719#ifdef CONFIG_PM
1720 .resume = wacom_resume,
1721 .reset_resume = wacom_reset_resume,
1722#endif
1723 .raw_event = wacom_raw_event,
1724};
1725module_hid_driver(wacom_driver);
1726
1727MODULE_VERSION(DRIVER_VERSION);
1728MODULE_AUTHOR(DRIVER_AUTHOR);
1729MODULE_DESCRIPTION(DRIVER_DESC);
1730MODULE_LICENSE(DRIVER_LICENSE);
1883 .report = wacom_wac_report,
1884#ifdef CONFIG_PM
1885 .resume = wacom_resume,
1886 .reset_resume = wacom_reset_resume,
1887#endif
1888 .raw_event = wacom_raw_event,
1889};
1890module_hid_driver(wacom_driver);
1891
1892MODULE_VERSION(DRIVER_VERSION);
1893MODULE_AUTHOR(DRIVER_AUTHOR);
1894MODULE_DESCRIPTION(DRIVER_DESC);
1895MODULE_LICENSE(DRIVER_LICENSE);