diff options
author | Jason Gerecke <killertofu@gmail.com> | 2015-06-15 18:01:42 -0700 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-06-18 10:42:39 +0200 |
commit | aa86b18cc9cd147b40412a2d57b383a5e16fe3b5 (patch) | |
tree | 5eb7432d73c86e3008f42fcc38013ff7e9b8ccaf /drivers/hid/wacom_sys.c | |
parent | 44b5250b97a0e5c3a257430ea28b10cf73899bd4 (diff) |
HID: wacom: Treat features->device_type values as flags
The USB devices that this driver has historically supported segregate the
pen and touch portions of the tablet. Oftentimes the segregation would be
done at the interface level, though on occasion (e.g. Cintiq 24HDT) the
tablet would combine two totally independent USB devices behind an internal
USB hub. Because pen and touch never shared the same interface, it made
sense for the 'device_type' to store a single value: "pen" or "touch".
Recently, however, some I2C devices have been created which combine the
two. A first step to accomodating this is to expand 'device_type' so that
it can represent two (or potentially more) types simultaneously. To do
this, we treat it as a bitfield and set/check individual bits rather
than using the '=' and '==' operators.
This should not result in any functional change since no supported devices
(that I'm aware of, at least) have HID descriptors that indicate both
pen and touch reports on a single interface.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/wacom_sys.c')
-rw-r--r-- | drivers/hid/wacom_sys.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index bdf31c97fa2a..2b4cbd872f94 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -197,9 +197,9 @@ static void wacom_usage_mapping(struct hid_device *hdev, * values commonly reported. */ if (pen) - features->device_type = BTN_TOOL_PEN; + features->device_type |= WACOM_DEVICETYPE_PEN; else if (finger) - features->device_type = BTN_TOOL_FINGER; + features->device_type |= WACOM_DEVICETYPE_TOUCH; else return; @@ -411,7 +411,7 @@ static int wacom_query_tablet_data(struct hid_device *hdev, if (features->type == HID_GENERIC) return wacom_hid_set_device_mode(hdev); - if (features->device_type == BTN_TOOL_FINGER) { + if (features->device_type & WACOM_DEVICETYPE_TOUCH) { if (features->type > TABLETPC) { /* MT Tablet PC touch */ return wacom_set_device_mode(hdev, 3, 4, 4); @@ -425,7 +425,7 @@ static int wacom_query_tablet_data(struct hid_device *hdev, else if (features->type == BAMBOO_PAD) { return wacom_set_device_mode(hdev, 2, 2, 2); } - } else if (features->device_type == BTN_TOOL_PEN) { + } else if (features->device_type & WACOM_DEVICETYPE_PEN) { if (features->type <= BAMBOO_PT && features->type != WIRELESS) { return wacom_set_device_mode(hdev, 2, 2, 2); } @@ -454,9 +454,9 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev, */ if (features->type == WIRELESS) { if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { - features->device_type = 0; + features->device_type = WACOM_DEVICETYPE_NONE; } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) { - features->device_type = BTN_TOOL_FINGER; + features->device_type |= WACOM_DEVICETYPE_TOUCH; features->pktlen = WACOM_PKGLEN_BBTOUCH3; } } @@ -538,9 +538,9 @@ static int wacom_add_shared_data(struct hid_device *hdev) wacom_wac->shared = &data->shared; - if (wacom_wac->features.device_type == BTN_TOOL_FINGER) + if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) wacom_wac->shared->touch = hdev; - else if (wacom_wac->features.device_type == BTN_TOOL_PEN) + else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN) wacom_wac->shared->pen = hdev; out: @@ -892,7 +892,7 @@ static int wacom_initialize_leds(struct wacom *wacom) case INTUOSPS: case INTUOSPM: case INTUOSPL: - if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) { + if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PEN) { wacom->led.select[0] = 0; wacom->led.select[1] = 0; wacom->led.llv = 32; @@ -948,7 +948,7 @@ static void wacom_destroy_leds(struct wacom *wacom) case INTUOSPS: case INTUOSPM: case INTUOSPL: - if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) + if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PEN) sysfs_remove_group(&wacom->hdev->dev.kobj, &intuos5_led_attr_group); break; @@ -1296,7 +1296,7 @@ static void wacom_wireless_work(struct work_struct *work) /* Stylus interface */ wacom_wac1->features = *((struct wacom_features *)id->driver_data); - wacom_wac1->features.device_type = BTN_TOOL_PEN; + wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PEN; snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", wacom_wac1->features.name); snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", @@ -1315,7 +1315,7 @@ static void wacom_wireless_work(struct work_struct *work) wacom_wac2->features = *((struct wacom_features *)id->driver_data); wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; - wacom_wac2->features.device_type = BTN_TOOL_FINGER; + wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH; wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; if (wacom_wac2->features.touch_max) snprintf(wacom_wac2->name, WACOM_NAME_MAX, @@ -1451,11 +1451,11 @@ static void wacom_update_name(struct wacom *wacom) snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), "%s Pad", name); - if (features->device_type == BTN_TOOL_PEN) { + if (features->device_type & WACOM_DEVICETYPE_PEN) { snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s Pen", name); } - else if (features->device_type == BTN_TOOL_FINGER) { + else if (features->device_type & WACOM_DEVICETYPE_TOUCH) { if (features->touch_max) snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s Finger", name); @@ -1545,7 +1545,8 @@ static int wacom_probe(struct hid_device *hdev, wacom_retrieve_hid_descriptor(hdev, features); wacom_setup_device_quirks(wacom); - if (!features->device_type && features->type != WIRELESS) { + if (features->device_type == WACOM_DEVICETYPE_NONE && + features->type != WIRELESS) { error = features->type == HID_GENERIC ? -ENODEV : 0; dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.", @@ -1555,7 +1556,7 @@ static int wacom_probe(struct hid_device *hdev, if (error) goto fail_shared_data; - features->device_type = BTN_TOOL_PEN; + features->device_type |= WACOM_DEVICETYPE_PEN; } wacom_calculate_res(features); @@ -1604,7 +1605,7 @@ static int wacom_probe(struct hid_device *hdev, error = hid_hw_open(hdev); if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { - if (wacom_wac->features.device_type == BTN_TOOL_FINGER) + if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) wacom_wac->shared->touch_input = wacom_wac->input; } |