aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/wacom_sys.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 44958d79d598..01b937e63cf3 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1284,6 +1284,39 @@ fail_register_pen_input:
1284 return error; 1284 return error;
1285} 1285}
1286 1286
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
1287static void wacom_wireless_work(struct work_struct *work) 1320static void wacom_wireless_work(struct work_struct *work)
1288{ 1321{
1289 struct wacom *wacom = container_of(work, struct wacom, work); 1322 struct wacom *wacom = container_of(work, struct wacom, work);
@@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work)
1341 if (wacom_wac1->features.type != INTUOSHT && 1374 if (wacom_wac1->features.type != INTUOSHT &&
1342 wacom_wac1->features.type != BAMBOO_PT) 1375 wacom_wac1->features.type != BAMBOO_PT)
1343 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; 1376 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1377 wacom_set_default_phy(&wacom_wac1->features);
1378 wacom_calculate_res(&wacom_wac1->features);
1344 snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen", 1379 snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
1345 wacom_wac1->features.name); 1380 wacom_wac1->features.name);
1346 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", 1381 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
@@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work)
1359 wacom_wac2->features = 1394 wacom_wac2->features =
1360 *((struct wacom_features *)id->driver_data); 1395 *((struct wacom_features *)id->driver_data);
1361 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1396 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1397 wacom_set_default_phy(&wacom_wac2->features);
1362 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1398 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1399 wacom_calculate_res(&wacom_wac2->features);
1363 snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX, 1400 snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
1364 "%s (WL) Finger",wacom_wac2->features.name); 1401 "%s (WL) Finger",wacom_wac2->features.name);
1365 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, 1402 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
@@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work)
1407 } 1444 }
1408} 1445}
1409 1446
1410/*
1411 * Not all devices report physical dimensions from HID.
1412 * Compute the default from hardcoded logical dimension
1413 * and resolution before driver overwrites them.
1414 */
1415static void wacom_set_default_phy(struct wacom_features *features)
1416{
1417 if (features->x_resolution) {
1418 features->x_phy = (features->x_max * 100) /
1419 features->x_resolution;
1420 features->y_phy = (features->y_max * 100) /
1421 features->y_resolution;
1422 }
1423}
1424
1425static void wacom_calculate_res(struct wacom_features *features)
1426{
1427 /* set unit to "100th of a mm" for devices not reported by HID */
1428 if (!features->unit) {
1429 features->unit = 0x11;
1430 features->unitExpo = -3;
1431 }
1432
1433 features->x_resolution = wacom_calc_hid_res(features->x_max,
1434 features->x_phy,
1435 features->unit,
1436 features->unitExpo);
1437 features->y_resolution = wacom_calc_hid_res(features->y_max,
1438 features->y_phy,
1439 features->unit,
1440 features->unitExpo);
1441}
1442
1443static size_t wacom_compute_pktlen(struct hid_device *hdev) 1447static size_t wacom_compute_pktlen(struct hid_device *hdev)
1444{ 1448{
1445 struct hid_report_enum *report_enum; 1449 struct hid_report_enum *report_enum;