diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2014-07-24 15:59:11 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-07-25 21:53:51 -0400 |
commit | 01c846f9539c194c7a6e34af036b1115b8ed822a (patch) | |
tree | a81bf8cdd09bd3d338f13999e43361519a77f7c8 /drivers/input | |
parent | ba9a3541fba72e1532c8288a0775a211810280c1 (diff) |
Input: wacom - compute the HID report size to get the actual packet size
This removes an USB dependency and is more accurate: the computed pktlen
is the actual maximum size of the reports forwarded by the device.
Given that the pktlen is correctly computed/validated, we can store it now
in the features struct instead of having a special handling in the rest of
the code.
Likewise, this information is not mandatory anymore in the description
of devices in wacom_wac.c. They will be removed in a separate patch.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Tested-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/tablet/wacom_sys.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 2c0983bd0504..ce76e1ef2dbc 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -149,7 +149,6 @@ static int wacom_parse_logical_collection(unsigned char *report, | |||
149 | if (features->type == BAMBOO_PT) { | 149 | if (features->type == BAMBOO_PT) { |
150 | 150 | ||
151 | /* Logical collection is only used by 3rd gen Bamboo Touch */ | 151 | /* Logical collection is only used by 3rd gen Bamboo Touch */ |
152 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; | ||
153 | features->device_type = BTN_TOOL_FINGER; | 152 | features->device_type = BTN_TOOL_FINGER; |
154 | 153 | ||
155 | features->x_max = features->y_max = | 154 | features->x_max = features->y_max = |
@@ -240,29 +239,6 @@ static int wacom_parse_hid(struct hid_device *hdev, | |||
240 | features->device_type = BTN_TOOL_FINGER; | 239 | features->device_type = BTN_TOOL_FINGER; |
241 | /* touch device at least supports one touch point */ | 240 | /* touch device at least supports one touch point */ |
242 | touch_max = 1; | 241 | touch_max = 1; |
243 | switch (features->type) { | ||
244 | case TABLETPC2FG: | ||
245 | features->pktlen = WACOM_PKGLEN_TPC2FG; | ||
246 | break; | ||
247 | |||
248 | case MTSCREEN: | ||
249 | case WACOM_24HDT: | ||
250 | features->pktlen = WACOM_PKGLEN_MTOUCH; | ||
251 | break; | ||
252 | |||
253 | case MTTPC: | ||
254 | case MTTPC_B: | ||
255 | features->pktlen = WACOM_PKGLEN_MTTPC; | ||
256 | break; | ||
257 | |||
258 | case BAMBOO_PT: | ||
259 | features->pktlen = WACOM_PKGLEN_BBTOUCH; | ||
260 | break; | ||
261 | |||
262 | default: | ||
263 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | ||
264 | break; | ||
265 | } | ||
266 | 242 | ||
267 | switch (features->type) { | 243 | switch (features->type) { |
268 | case BAMBOO_PT: | 244 | case BAMBOO_PT: |
@@ -305,8 +281,6 @@ static int wacom_parse_hid(struct hid_device *hdev, | |||
305 | } | 281 | } |
306 | } else if (pen) { | 282 | } else if (pen) { |
307 | /* penabled only accepts exact bytes of data */ | 283 | /* penabled only accepts exact bytes of data */ |
308 | if (features->type >= TABLETPC) | ||
309 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | ||
310 | features->device_type = BTN_TOOL_PEN; | 284 | features->device_type = BTN_TOOL_PEN; |
311 | features->x_max = | 285 | features->x_max = |
312 | get_unaligned_le16(&report[i + 3]); | 286 | get_unaligned_le16(&report[i + 3]); |
@@ -1224,12 +1198,34 @@ static void wacom_calculate_res(struct wacom_features *features) | |||
1224 | features->unitExpo); | 1198 | features->unitExpo); |
1225 | } | 1199 | } |
1226 | 1200 | ||
1201 | static int wacom_hid_report_len(struct hid_report *report) | ||
1202 | { | ||
1203 | /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ | ||
1204 | return ((report->size - 1) >> 3) + 1 + (report->id > 0); | ||
1205 | } | ||
1206 | |||
1207 | static size_t wacom_compute_pktlen(struct hid_device *hdev) | ||
1208 | { | ||
1209 | struct hid_report_enum *report_enum; | ||
1210 | struct hid_report *report; | ||
1211 | size_t size = 0; | ||
1212 | |||
1213 | report_enum = hdev->report_enum + HID_INPUT_REPORT; | ||
1214 | |||
1215 | list_for_each_entry(report, &report_enum->report_list, list) { | ||
1216 | size_t report_size = wacom_hid_report_len(report); | ||
1217 | if (report_size > size) | ||
1218 | size = report_size; | ||
1219 | } | ||
1220 | |||
1221 | return size; | ||
1222 | } | ||
1223 | |||
1227 | static int wacom_probe(struct hid_device *hdev, | 1224 | static int wacom_probe(struct hid_device *hdev, |
1228 | const struct hid_device_id *id) | 1225 | const struct hid_device_id *id) |
1229 | { | 1226 | { |
1230 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | 1227 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
1231 | struct usb_device *dev = interface_to_usbdev(intf); | 1228 | struct usb_device *dev = interface_to_usbdev(intf); |
1232 | struct usb_endpoint_descriptor *endpoint; | ||
1233 | struct wacom *wacom; | 1229 | struct wacom *wacom; |
1234 | struct wacom_wac *wacom_wac; | 1230 | struct wacom_wac *wacom_wac; |
1235 | struct wacom_features *features; | 1231 | struct wacom_features *features; |
@@ -1255,6 +1251,7 @@ static int wacom_probe(struct hid_device *hdev, | |||
1255 | wacom_wac = &wacom->wacom_wac; | 1251 | wacom_wac = &wacom->wacom_wac; |
1256 | wacom_wac->features = *((struct wacom_features *)id->driver_data); | 1252 | wacom_wac->features = *((struct wacom_features *)id->driver_data); |
1257 | features = &wacom_wac->features; | 1253 | features = &wacom_wac->features; |
1254 | features->pktlen = wacom_compute_pktlen(hdev); | ||
1258 | if (features->pktlen > WACOM_PKGLEN_MAX) { | 1255 | if (features->pktlen > WACOM_PKGLEN_MAX) { |
1259 | error = -EINVAL; | 1256 | error = -EINVAL; |
1260 | goto fail1; | 1257 | goto fail1; |
@@ -1272,8 +1269,6 @@ static int wacom_probe(struct hid_device *hdev, | |||
1272 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | 1269 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); |
1273 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | 1270 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); |
1274 | 1271 | ||
1275 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | ||
1276 | |||
1277 | /* set the default size in case we do not get them from hid */ | 1272 | /* set the default size in case we do not get them from hid */ |
1278 | wacom_set_default_phy(features); | 1273 | wacom_set_default_phy(features); |
1279 | 1274 | ||
@@ -1284,13 +1279,12 @@ static int wacom_probe(struct hid_device *hdev, | |||
1284 | 1279 | ||
1285 | /* | 1280 | /* |
1286 | * Intuos5 has no useful data about its touch interface in its | 1281 | * Intuos5 has no useful data about its touch interface in its |
1287 | * HID descriptor. If this is the touch interface (wMaxPacketSize | 1282 | * HID descriptor. If this is the touch interface (PacketSize |
1288 | * of WACOM_PKGLEN_BBTOUCH3), override the table values. | 1283 | * of WACOM_PKGLEN_BBTOUCH3), override the table values. |
1289 | */ | 1284 | */ |
1290 | if (features->type >= INTUOS5S && features->type <= INTUOSHT) { | 1285 | if (features->type >= INTUOS5S && features->type <= INTUOSHT) { |
1291 | if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) { | 1286 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
1292 | features->device_type = BTN_TOOL_FINGER; | 1287 | features->device_type = BTN_TOOL_FINGER; |
1293 | features->pktlen = WACOM_PKGLEN_BBTOUCH3; | ||
1294 | 1288 | ||
1295 | features->x_max = 4096; | 1289 | features->x_max = 4096; |
1296 | features->y_max = 4096; | 1290 | features->y_max = 4096; |