aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2013-09-06 23:23:44 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-09-06 23:23:44 -0400
commit07176b988ebb20f46a317a60ee1d983fe1630203 (patch)
treee54affb1f823742078c68d9506e6035016bc2ea4 /drivers/input/tablet
parentfa46c7984092f3dbdbb3bcd7338d81a1168d9d2b (diff)
parent52764fed5049655926bcecaefd52f0a415ceb105 (diff)
Merge branch 'next' into for-linus
Merge first round of changes for 3.12 merge window.
Diffstat (limited to 'drivers/input/tablet')
-rw-r--r--drivers/input/tablet/wacom_sys.c87
-rw-r--r--drivers/input/tablet/wacom_wac.c19
2 files changed, 46 insertions, 60 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index aaf23aeae2ea..79b69ea47f74 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -221,39 +221,6 @@ static int wacom_calc_hid_res(int logical_extents, int physical_extents,
221 return logical_extents / physical_extents; 221 return logical_extents / physical_extents;
222} 222}
223 223
224/*
225 * The physical dimension specified by the HID descriptor is likely not in
226 * the "100th of a mm" units expected by wacom_calculate_touch_res. This
227 * function adjusts the value of [xy]_phy based on the unit and exponent
228 * provided by the HID descriptor. If an error occurs durring conversion
229 * (e.g. from the unit being left unspecified) [xy]_phy is not modified.
230 */
231static void wacom_fix_phy_from_hid(struct wacom_features *features)
232{
233 int xres = wacom_calc_hid_res(features->x_max, features->x_phy,
234 features->unit, features->unitExpo);
235 int yres = wacom_calc_hid_res(features->y_max, features->y_phy,
236 features->unit, features->unitExpo);
237
238 if (xres > 0 && yres > 0) {
239 features->x_phy = (100 * features->x_max) / xres;
240 features->y_phy = (100 * features->y_max) / yres;
241 }
242}
243
244/*
245 * Static values for max X/Y and resolution of Pen interface is stored in
246 * features. This mean physical size of active area can be computed.
247 * This is useful to do when Pen and Touch have same active area of tablet.
248 * This means for Touch device, we only need to find max X/Y value and we
249 * have enough information to compute resolution of touch.
250 */
251static void wacom_set_phy_from_res(struct wacom_features *features)
252{
253 features->x_phy = (features->x_max * 100) / features->x_resolution;
254 features->y_phy = (features->y_max * 100) / features->y_resolution;
255}
256
257static int wacom_parse_logical_collection(unsigned char *report, 224static int wacom_parse_logical_collection(unsigned char *report,
258 struct wacom_features *features) 225 struct wacom_features *features)
259{ 226{
@@ -265,8 +232,6 @@ static int wacom_parse_logical_collection(unsigned char *report,
265 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 232 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
266 features->device_type = BTN_TOOL_FINGER; 233 features->device_type = BTN_TOOL_FINGER;
267 234
268 wacom_set_phy_from_res(features);
269
270 features->x_max = features->y_max = 235 features->x_max = features->y_max =
271 get_unaligned_le16(&report[10]); 236 get_unaligned_le16(&report[10]);
272 237
@@ -640,9 +605,6 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
640 } 605 }
641 } 606 }
642 error = wacom_parse_hid(intf, hid_desc, features); 607 error = wacom_parse_hid(intf, hid_desc, features);
643 if (error)
644 goto out;
645 wacom_fix_phy_from_hid(features);
646 608
647 out: 609 out:
648 return error; 610 return error;
@@ -1228,7 +1190,6 @@ static void wacom_wireless_work(struct work_struct *work)
1228 *((struct wacom_features *)id->driver_info); 1190 *((struct wacom_features *)id->driver_info);
1229 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1191 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1230 wacom_wac2->features.device_type = BTN_TOOL_FINGER; 1192 wacom_wac2->features.device_type = BTN_TOOL_FINGER;
1231 wacom_set_phy_from_res(&wacom_wac2->features);
1232 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1193 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1233 error = wacom_register_input(wacom2); 1194 error = wacom_register_input(wacom2);
1234 if (error) 1195 if (error)
@@ -1251,6 +1212,33 @@ fail1:
1251 return; 1212 return;
1252} 1213}
1253 1214
1215/*
1216 * Not all devices report physical dimensions from HID.
1217 * Compute the default from hardcoded logical dimension
1218 * and resolution before driver overwrites them.
1219 */
1220static void wacom_set_default_phy(struct wacom_features *features)
1221{
1222 if (features->x_resolution) {
1223 features->x_phy = (features->x_max * 100) /
1224 features->x_resolution;
1225 features->y_phy = (features->y_max * 100) /
1226 features->y_resolution;
1227 }
1228}
1229
1230static void wacom_calculate_res(struct wacom_features *features)
1231{
1232 features->x_resolution = wacom_calc_hid_res(features->x_max,
1233 features->x_phy,
1234 features->unit,
1235 features->unitExpo);
1236 features->y_resolution = wacom_calc_hid_res(features->y_max,
1237 features->y_phy,
1238 features->unit,
1239 features->unitExpo);
1240}
1241
1254static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 1242static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
1255{ 1243{
1256 struct usb_device *dev = interface_to_usbdev(intf); 1244 struct usb_device *dev = interface_to_usbdev(intf);
@@ -1297,6 +1285,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1297 1285
1298 endpoint = &intf->cur_altsetting->endpoint[0].desc; 1286 endpoint = &intf->cur_altsetting->endpoint[0].desc;
1299 1287
1288 /* set the default size in case we do not get them from hid */
1289 wacom_set_default_phy(features);
1290
1300 /* Retrieve the physical and logical size for touch devices */ 1291 /* Retrieve the physical and logical size for touch devices */
1301 error = wacom_retrieve_hid_descriptor(intf, features); 1292 error = wacom_retrieve_hid_descriptor(intf, features);
1302 if (error) 1293 if (error)
@@ -1312,8 +1303,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1312 features->device_type = BTN_TOOL_FINGER; 1303 features->device_type = BTN_TOOL_FINGER;
1313 features->pktlen = WACOM_PKGLEN_BBTOUCH3; 1304 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
1314 1305
1315 wacom_set_phy_from_res(features);
1316
1317 features->x_max = 4096; 1306 features->x_max = 4096;
1318 features->y_max = 4096; 1307 features->y_max = 4096;
1319 } else { 1308 } else {
@@ -1323,6 +1312,13 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1323 1312
1324 wacom_setup_device_quirks(features); 1313 wacom_setup_device_quirks(features);
1325 1314
1315 /* set unit to "100th of a mm" for devices not reported by HID */
1316 if (!features->unit) {
1317 features->unit = 0x11;
1318 features->unitExpo = 16 - 3;
1319 }
1320 wacom_calculate_res(features);
1321
1326 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 1322 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
1327 1323
1328 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { 1324 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
@@ -1334,7 +1330,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1334 " Pen" : " Finger", 1330 " Pen" : " Finger",
1335 sizeof(wacom_wac->name)); 1331 sizeof(wacom_wac->name));
1336 1332
1337
1338 other_dev = wacom_get_sibling(dev, features->oVid, features->oPid); 1333 other_dev = wacom_get_sibling(dev, features->oVid, features->oPid);
1339 if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL) 1334 if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL)
1340 other_dev = dev; 1335 other_dev = dev;
@@ -1366,8 +1361,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1366 usb_set_intfdata(intf, wacom); 1361 usb_set_intfdata(intf, wacom);
1367 1362
1368 if (features->quirks & WACOM_QUIRK_MONITOR) { 1363 if (features->quirks & WACOM_QUIRK_MONITOR) {
1369 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) 1364 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
1365 error = -EIO;
1370 goto fail5; 1366 goto fail5;
1367 }
1371 } 1368 }
1372 1369
1373 return 0; 1370 return 0;
@@ -1422,8 +1419,8 @@ static int wacom_resume(struct usb_interface *intf)
1422 wacom_query_tablet_data(intf, features); 1419 wacom_query_tablet_data(intf, features);
1423 wacom_led_control(wacom); 1420 wacom_led_control(wacom);
1424 1421
1425 if ((wacom->open || features->quirks & WACOM_QUIRK_MONITOR) 1422 if ((wacom->open || (features->quirks & WACOM_QUIRK_MONITOR)) &&
1426 && usb_submit_urb(wacom->irq, GFP_NOIO) < 0) 1423 usb_submit_urb(wacom->irq, GFP_NOIO) < 0)
1427 rv = -EIO; 1424 rv = -EIO;
1428 1425
1429 mutex_unlock(&wacom->lock); 1426 mutex_unlock(&wacom->lock);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index f3e91f0b57ae..b2aa503c16b1 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1445,13 +1445,6 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1445 } 1445 }
1446} 1446}
1447 1447
1448static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1449 unsigned int physical_max)
1450{
1451 /* Touch physical dimensions are in 100th of mm */
1452 return (logical_max * 100) / physical_max;
1453}
1454
1455static void wacom_abs_set_axis(struct input_dev *input_dev, 1448static void wacom_abs_set_axis(struct input_dev *input_dev,
1456 struct wacom_wac *wacom_wac) 1449 struct wacom_wac *wacom_wac)
1457{ 1450{
@@ -1475,11 +1468,9 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
1475 input_set_abs_params(input_dev, ABS_Y, 0, 1468 input_set_abs_params(input_dev, ABS_Y, 0,
1476 features->y_max, features->y_fuzz, 0); 1469 features->y_max, features->y_fuzz, 0);
1477 input_abs_set_res(input_dev, ABS_X, 1470 input_abs_set_res(input_dev, ABS_X,
1478 wacom_calculate_touch_res(features->x_max, 1471 features->x_resolution);
1479 features->x_phy));
1480 input_abs_set_res(input_dev, ABS_Y, 1472 input_abs_set_res(input_dev, ABS_Y,
1481 wacom_calculate_touch_res(features->y_max, 1473 features->y_resolution);
1482 features->y_phy));
1483 } 1474 }
1484 1475
1485 if (features->touch_max > 1) { 1476 if (features->touch_max > 1) {
@@ -1488,11 +1479,9 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
1488 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 1479 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
1489 features->y_max, features->y_fuzz, 0); 1480 features->y_max, features->y_fuzz, 0);
1490 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 1481 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
1491 wacom_calculate_touch_res(features->x_max, 1482 features->x_resolution);
1492 features->x_phy));
1493 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 1483 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
1494 wacom_calculate_touch_res(features->y_max, 1484 features->y_resolution);
1495 features->y_phy));
1496 } 1485 }
1497 } 1486 }
1498} 1487}