Skip to content

Commit 0be0171

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Report correct device resolution when using the wireless adapater
The 'wacom_wireless_work' function does not recalculate the tablet's resolution, causing the value contained in the 'features' struct to always be reported to userspace. This value is valid only for the pen interface, meaning that the value will be incorrect for the touchpad (if present). This in particular causes problems for libinput which relies on the reported resolution being correct. This patch adds the necessary calls to recalculate the resolution for each interface. This requires a little bit of code shuffling since both the 'wacom_set_default_phy' and 'wacom_calculate_res' are declared below their new first point of use in 'wacom_wireless_work'. Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 0621809 commit 0be0171

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

drivers/hid/wacom_sys.c

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,39 @@ static int wacom_register_inputs(struct wacom *wacom)
12841284
return error;
12851285
}
12861286

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+
*/
1292+
static 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+
1302+
static 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+
12871320
static void wacom_wireless_work(struct work_struct *work)
12881321
{
12891322
struct wacom *wacom = container_of(work, struct wacom, work);
@@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work)
13411374
if (wacom_wac1->features.type != INTUOSHT &&
13421375
wacom_wac1->features.type != BAMBOO_PT)
13431376
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1377+
wacom_set_default_phy(&wacom_wac1->features);
1378+
wacom_calculate_res(&wacom_wac1->features);
13441379
snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
13451380
wacom_wac1->features.name);
13461381
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
@@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work)
13591394
wacom_wac2->features =
13601395
*((struct wacom_features *)id->driver_data);
13611396
wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1397+
wacom_set_default_phy(&wacom_wac2->features);
13621398
wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1399+
wacom_calculate_res(&wacom_wac2->features);
13631400
snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
13641401
"%s (WL) Finger",wacom_wac2->features.name);
13651402
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
@@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work)
14071444
}
14081445
}
14091446

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-
*/
1415-
static 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-
1425-
static 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-
14431447
static size_t wacom_compute_pktlen(struct hid_device *hdev)
14441448
{
14451449
struct hid_report_enum *report_enum;

0 commit comments

Comments
 (0)