aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2015-04-30 20:51:54 -0400
committerJiri Kosina <jkosina@suse.cz>2015-05-04 04:00:22 -0400
commit042628abd59c9a034797bd3083f806fa17cda62d (patch)
tree32251d6b256514a68f1eb48d3292b54053fbf464
parent8d80f790ecbcd0c3d55be51d867cbe4db1debd89 (diff)
HID: wacom: Discover device_type from HID descriptor for all devices
Currently, we assume a device_type of BTN_TOOL_PEN before scanning the HID descriptor and then change the device_type if what we discover proves that assumption wrong. This way of doing things makes it more difficult to figure out if a device (particularly a HID_GENERIC device) actually does tablet/touch input or is something completley different. This patch leaves device_type at its initial value of 0 and then calls 'wacom_parse_hid' for every device (not just those that have touch). As we map the usages, we can set the device_type as before. After we're finished, we can then check if the value is still zero and do whatever is most appropriate. Detecting the pen can be a little tricky on most Wacom devices because the descriptors describe opaque blobs. Fortunately, older Wacom tablets have the HID_DG_DIGITIZER usage on the pen's application collection and newer tablets seem to have a similar vendor-defined usage that we can trigger on. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Ping Cheng <pingc@wacom.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom_sys.c23
-rw-r--r--drivers/hid/wacom_wac.c8
-rw-r--r--drivers/hid/wacom_wac.h6
3 files changed, 23 insertions, 14 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 222baf500435..157aa7aa1067 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -181,7 +181,11 @@ static void wacom_usage_mapping(struct hid_device *hdev,
181 * X/Y values and some cases of invalid Digitizer X/Y 181 * X/Y values and some cases of invalid Digitizer X/Y
182 * values commonly reported. 182 * values commonly reported.
183 */ 183 */
184 if (!pen && !finger) 184 if (pen)
185 features->device_type = BTN_TOOL_PEN;
186 else if (finger)
187 features->device_type = BTN_TOOL_FINGER;
188 else
185 return; 189 return;
186 190
187 /* 191 /*
@@ -198,14 +202,11 @@ static void wacom_usage_mapping(struct hid_device *hdev,
198 case HID_GD_X: 202 case HID_GD_X:
199 features->x_max = field->logical_maximum; 203 features->x_max = field->logical_maximum;
200 if (finger) { 204 if (finger) {
201 features->device_type = BTN_TOOL_FINGER;
202 features->x_phy = field->physical_maximum; 205 features->x_phy = field->physical_maximum;
203 if (features->type != BAMBOO_PT) { 206 if (features->type != BAMBOO_PT) {
204 features->unit = field->unit; 207 features->unit = field->unit;
205 features->unitExpo = field->unit_exponent; 208 features->unitExpo = field->unit_exponent;
206 } 209 }
207 } else {
208 features->device_type = BTN_TOOL_PEN;
209 } 210 }
210 break; 211 break;
211 case HID_GD_Y: 212 case HID_GD_Y:
@@ -425,7 +426,6 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
425 struct usb_interface *intf = wacom->intf; 426 struct usb_interface *intf = wacom->intf;
426 427
427 /* default features */ 428 /* default features */
428 features->device_type = BTN_TOOL_PEN;
429 features->x_fuzz = 4; 429 features->x_fuzz = 4;
430 features->y_fuzz = 4; 430 features->y_fuzz = 4;
431 features->pressure_fuzz = 0; 431 features->pressure_fuzz = 0;
@@ -446,10 +446,6 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
446 } 446 }
447 } 447 }
448 448
449 /* only devices that support touch need to retrieve the info */
450 if (features->type < BAMBOO_PT)
451 return;
452
453 wacom_parse_hid(hdev, features); 449 wacom_parse_hid(hdev, features);
454} 450}
455 451
@@ -1529,8 +1525,15 @@ static int wacom_probe(struct hid_device *hdev,
1529 1525
1530 /* Retrieve the physical and logical size for touch devices */ 1526 /* Retrieve the physical and logical size for touch devices */
1531 wacom_retrieve_hid_descriptor(hdev, features); 1527 wacom_retrieve_hid_descriptor(hdev, features);
1532
1533 wacom_setup_device_quirks(wacom); 1528 wacom_setup_device_quirks(wacom);
1529
1530 if (!features->device_type && features->type != WIRELESS) {
1531 dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
1532 hdev->name, "Assuming pen");
1533
1534 features->device_type = BTN_TOOL_PEN;
1535 }
1536
1534 wacom_calculate_res(features); 1537 wacom_calculate_res(features);
1535 1538
1536 wacom_update_name(wacom); 1539 wacom_update_name(wacom);
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index dff99ffc1bb1..a52fc2580b6b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2186,13 +2186,15 @@ void wacom_setup_device_quirks(struct wacom *wacom)
2186 2186
2187 features->x_max = 4096; 2187 features->x_max = 4096;
2188 features->y_max = 4096; 2188 features->y_max = 4096;
2189 } else {
2190 features->device_type = BTN_TOOL_PEN;
2191 } 2189 }
2192 } 2190 }
2193 2191
2194 /* 2192 /*
2195 * Same thing for Bamboo PAD 2193 * Raw Wacom-mode pen and touch events both come from interface
2194 * 0, whose HID descriptor has an application usage of 0xFF0D
2195 * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
2196 * out through the HID_GENERIC device created for interface 1,
2197 * so rewrite this one to be of type BTN_TOOL_FINGER.
2196 */ 2198 */
2197 if (features->type == BAMBOO_PAD) 2199 if (features->type == BAMBOO_PAD)
2198 features->device_type = BTN_TOOL_FINGER; 2200 features->device_type = BTN_TOOL_FINGER;
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index f5a5f686bc98..9a5ee623cb44 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -72,10 +72,14 @@
72#define WACOM_QUIRK_MONITOR 0x0004 72#define WACOM_QUIRK_MONITOR 0x0004
73#define WACOM_QUIRK_BATTERY 0x0008 73#define WACOM_QUIRK_BATTERY 0x0008
74 74
75#define WACOM_VENDORDEFINED_PEN 0xff0d0001
76
75#define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \ 77#define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
76 ((f)->physical == HID_DG_STYLUS) || \ 78 ((f)->physical == HID_DG_STYLUS) || \
77 ((f)->physical == HID_DG_PEN) || \ 79 ((f)->physical == HID_DG_PEN) || \
78 ((f)->application == HID_DG_PEN)) 80 ((f)->application == HID_DG_PEN) || \
81 ((f)->application == HID_DG_DIGITIZER) || \
82 ((f)->application == WACOM_VENDORDEFINED_PEN))
79#define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \ 83#define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
80 ((f)->physical == HID_DG_FINGER) || \ 84 ((f)->physical == HID_DG_FINGER) || \
81 ((f)->application == HID_DG_TOUCHSCREEN)) 85 ((f)->application == HID_DG_TOUCHSCREEN))