History log of /linux-master/drivers/hid/wacom_wac.h
Revision Date Author Comments
# dcd5231f 31-Jan-2024 Jiri Slaby (SUSE) <jirislaby@kernel.org>

HID: wacom: remove unused hid_data::pressure

The pressure member in struct hid_data is unused. It was
added in commit 5ae6e89f7409 (HID: wacom: implement the finger part of
the HID generic handling), but never used.

As this is not a struct to communicate with the HW, remove that member.

Found by https://github.com/jirislaby/clang-struct.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Ping Cheng <ping.cheng@wacom.com>
Cc: Jason Gerecke <jason.gerecke@wacom.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>


# fd2a9b29 14-Nov-2023 Tatsunosuke Tobita <tatsunosuke.wacom@gmail.com>

HID: wacom: Remove AES power_supply after extended inactivity

Even if a user does not use their AES pen for an extended period,
the battery power supply attributes continue to exist.
This results in the desktop showing battery status for a pen
that is no longer in use and which may in fact be in a different
state (e.g. the user may be charging the pen).
To avoid confusion and ensure userspace has an accurate view
of the battery state, this patch automatically removes
the power_supply after 30 minutes of inactivity.

Signed-off-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
Reviewed-by: Jason Gerecke <Jason.Gerecke@wacom.com>
Reviewed-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Josh Dickens <joshua.dickens@wacom.com>
Link: https://lore.kernel.org/r/20231114235729.6867-1-tatsunosuke.wacom@gmail.com
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>


# 55ab9b2c 25-Jul-2023 Aaron Armstrong Skomra <aaron.skomra@wacom.com>

HID: wacom: struct name cleanup

Help differentiate the two remote related "serial" struct variables by
renaming "wacom_remote_data" to "wacom_remote_work_data".

Signed-off-by: Aaron Skomra <skomra@gmail.com>
Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 2834e380 25-Jul-2023 Aaron Armstrong Skomra <aaron.skomra@wacom.com>

HID: wacom: remove unnecessary 'connected' variable from EKR

The 'connected' variable was poorly named, and this has led to some
confusion. We can get the same information by checking if a serial number
exists in the specified EKR slot.

Signed-off-by: Aaron Skomra <skomra@gmail.com>
Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 9ac6678b 25-Jul-2023 Aaron Armstrong Skomra <aaron.skomra@wacom.com>

HID: wacom: remove the battery when the EKR is off

Currently the EKR battery remains even after we stop getting information
from the device. This can lead to a stale battery persisting indefinitely
in userspace.

The remote sends a heartbeat every 10 seconds. Delete the battery if we
miss two heartbeats (after 21 seconds). Restore the battery once we see
a heartbeat again.

Signed-off-by: Aaron Skomra <skomra@gmail.com>
Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Fixes: 9f1015d45f62 ("HID: wacom: EKR: attach the power_supply on first connection")
CC: stable@vger.kernel.org
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 9a6c0e28 08-Jun-2023 Jason Gerecke <jason.gerecke@wacom.com>

HID: wacom: Use ktime_t rather than int when dealing with timestamps

Code which interacts with timestamps needs to use the ktime_t type
returned by functions like ktime_get. The int type does not offer
enough space to store these values, and attempting to use it is a
recipe for problems. In this particular case, overflows would occur
when calculating/storing timestamps leading to incorrect values being
reported to userspace. In some cases these bad timestamps cause input
handling in userspace to appear hung.

Link: https://gitlab.freedesktop.org/libinput/libinput/-/issues/901
Fixes: 17d793f3ed53 ("HID: wacom: insert timestamp to packed Bluetooth (BT) events")
CC: stable@vger.kernel.org
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230608213828.2108-1-jason.gerecke@wacom.com
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>


# 17d793f3 24-Feb-2023 Ping Cheng <pinglinux@gmail.com>

HID: wacom: insert timestamp to packed Bluetooth (BT) events

To fully utilize the BT polling/refresh rate, a few input events
are sent together to reduce event delay. This causes issue to the
timestamp generated by input_sync since all the events in the same
packet would pretty much have the same timestamp. This patch inserts
time interval to the events by averaging the total time used for
sending the packet.

This decision was mainly based on observing the actual time interval
between each BT polling. The interval doesn't seem to be constant,
due to the network and system environment. So, using solutions other
than averaging doesn't end up with valid timestamps.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 1db1f392 01-Dec-2022 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Ensure bootloader PID is usable in hidraw mode

Some Wacom devices have a special "bootloader" mode that is used for
firmware flashing. When operating in this mode, the device cannot be
used for input, and the HID descriptor is not able to be processed by
the driver. The driver generates an "Unknown device_type" warning and
then returns an error code from wacom_probe(). This is a problem because
userspace still needs to be able to interact with the device via hidraw
to perform the firmware flash.

This commit adds a non-generic device definition for 056a:0094 which
is used when devices are in "bootloader" mode. It marks the devices
with a special BOOTLOADER type that is recognized by wacom_probe() and
wacom_raw_event(). When we see this type we ensure a hidraw device is
created and otherwise keep our hands off so that userspace is in full
control.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 35f47386 02-Aug-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

HID: wacom: Simplify comments

Remove a left-over from commit 2874c5fd2842 ("treewide: Replace GPLv2
boilerplate/reference with SPDX - rule 152").
An empty comment block can be removed.

While at it remove, also remove what is supposed to be the path/filename of
the file.
This is really low value... and wrong since commit 471d17148c8b
("Input: wacom - move the USB (now hid) Wacom driver in drivers/hid")

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 6d09085b 22-Mar-2022 Joshua-Dickens <Joshua@Joshua-Dickens.com>

HID: wacom: Adding Support for new usages

Added supprt for the following usages:
* HID_DG_SCANTIME to report the timestamp for pen and touch events.
* WACOM_HID_WD_BARRELSWITCH3 to support pens with 3 buttons.
* WACOM_HID_WD_SEQUENCENUMBER to detect and report dropped packets.

Signed-off-by: Joshua Dickens <joshua.dickens@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 7fb0413b 08-Nov-2021 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts

The HID descriptor of many of Wacom's touch input devices include a
"Confidence" usage that signals if a particular touch collection contains
useful data. The driver does not look at this flag, however, which causes
even invalid contacts to be reported to userspace. A lucky combination of
kernel event filtering and device behavior (specifically: contact ID 0 ==
invalid, contact ID >0 == valid; and order all data so that all valid
contacts are reported before any invalid contacts) spare most devices from
any visibly-bad behavior.

The DTH-2452 is one example of an unlucky device that misbehaves. It uses
ID 0 for both the first valid contact and all invalid contacts. Because
we report both the valid and invalid contacts, the kernel reports that
contact 0 first goes down (valid) and then goes up (invalid) in every
report. This causes ~100 clicks per second simply by touching the screen.

This patch inroduces new `confidence` flag in our `hid_data` structure.
The value is initially set to `true` at the start of a report and can be
set to `false` if an invalid touch usage is seen.

Link: https://github.com/linuxwacom/input-wacom/issues/270
Fixes: f8b6a74719b5 ("HID: wacom: generic: Support multiple tools per report")
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Joshua Dickens <joshua.dickens@wacom.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 5bed0128 19-Jul-2021 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Short-circuit processing of touch when it is disabled

Avoid doing unnecessary work when touch is disabled by detecting this
condition and returning early. Note that the probe process sends GET
FEATURE requests to discover e.g. HID_DG_CONTACTMAX, so we can't start
ignoring touch reports until probe finishes.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# dc9dc864 19-Jul-2021 Ping Cheng <ping.cheng@wacom.com>

HID: wacom: set initial hardware touch switch state to 'off'

Wacom touch devices have two types of touch switches: softkey touch
toggle and hardware touch switch. For softkey toggle, we assume
touch is on by default in the driver. However the hardware touch
switch is controlled by end users. We don't know if it's on or off
before getting the status event.

This patch sets touch off for devices with a hardware switch until we
get the status. This is a bit safer for users who leave the switch "off"
and don't want any accidental touches. The tradeoff is a slight delay
between device connection and touch becoming enabled for users who
leave the switch "on".

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 424d8237 23-Jun-2021 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Correct base usage for capacitive ExpressKey status bits

The capacitive status of ExpressKeys is reported with usages beginning
at 0x940, not 0x950. Bring our driver into alignment with reality.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 46fc466e 05-Apr-2021 Ping Cheng <pinglinux@gmail.com>

HID: wacom: Setup pen input capabilities to the targeted tools

Only set the bits that are supported by the targeted devices.
This patch also removes duplicated set_bit calls.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Jason Gerecke <Jason.Gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 179e8e47 21-Jan-2021 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Correct NULL dereference on AES pen proximity

The recent commit to fix a memory leak introduced an inadvertant NULL
pointer dereference. The `wacom_wac->pen_fifo` variable was never
intialized, resuling in a crash whenever functions tried to use it.
Since the FIFO is only used by AES pens (to buffer events from pen
proximity until the hardware reports the pen serial number) this would
have been easily overlooked without testing an AES device.

This patch converts `wacom_wac->pen_fifo` over to a pointer (since the
call to `devres_alloc` allocates memory for us) and ensures that we assign
it to point to the allocated and initalized `pen_fifo` before the function
returns.

Link: https://github.com/linuxwacom/input-wacom/issues/230
Fixes: 37309f47e2f5 ("HID: wacom: Fix memory leakage caused by kfifo_alloc")
CC: stable@vger.kernel.org # v4.19+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# f4e11d59 12-Jun-2019 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: support the 'report valid' usage for touch

Finger data is separated into chunks in our Bluetooth report,
where each report contains the same number of chunks. Those chunks
are not aligned in any particular way to a set of finger touches.
That is, the first half of a group of simultaneous touches may
be in one chunk at the end of a report and the second half could
be at the beginning of the next report.

Also some chunks contain no data and potentially some chunks could
contain leftover (bad) data.

Introduce and process the WACOM_HID_WT_REPORT_VALID usage that the
device uses to let us know if we should process a chunk of data.

Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 912c6aa6 12-Jun-2019 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: Add 2nd gen Intuos Pro Small support

The existing INTUOSP2_BT device class supports LEDs and this device
does not. A new device class enum entry, "INTUOSP2S_BT", is created
to avoid the INTUOSP2_BT LED code.

Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 2874c5fd 27-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 3029 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d8e98060 10-May-2019 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: only switch the mode on devices with LEDs

Currently, the driver will attempt to set the mode on all
devices with a center button, but some devices with a center
button lack LEDs, and attempting to set the LEDs on devices
without LEDs results in the kernel error message of the form:

"leds input8::wacom-0.1: Setting an LED's brightness failed (-32)"

This is because the generic codepath erroneously assumes that the
BUTTON_CENTER usage indicates that the device has LEDs, the
previously ignored TOUCH_RING_SETTING usage is a more accurate
indication of the existence of LEDs on the device.

Fixes: 10c55cacb8b2 ("HID: wacom: generic: support LEDs")
Cc: <stable@vger.kernel.org> # v4.11+
Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# b1f466a9 06-Mar-2018 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: add the "Report Valid" usage

Wacom Bluetooth reports contain multiple pen frames per report.
Each frame contains a flag indicating if the frame is valid.
Future Wacom devices with this type of report may contain HID
descriptors, add support for this usage to the generic codepath
of the Wacom driver.

Signed-off-by: Aaron Armstrong Skomra <skomra@gmail.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 87046b6c 06-Mar-2018 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: Add support for 3rd generation Intuos BT

Use the code path that predates generic device support.

Signed-off-by: Aaron Armstrong Skomra <skomra@gmail.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 83417206 10-Nov-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Queue events with missing type/serial data for later processing

Userspace expects to receive tool type and serial number information
for the active pen in the very first kernel report, if such data is
supported by the hardware. While this expectation is not an issue for
EMR devices, AES sensors will often send several packets worth of in-
range data before relaying type/serial data to the kernel. Sending this
data "late" can result in proximity-tracking issues by xf86-input-wacom,
or an inability to distinguish different pens by input-wacom.

Options for dealing with this situation include ignoring reports from
the tablet until we get the necessary data, or using the information
from the last-seen pen instead of the (eventual) real data. Neither
option is particularly attractive: the former results in truncated
strokes and the latter causes issues with switching between pens.

This commit instead opts to queue up events with missing information
until we receive a report which contains it. At that point, we can
update the driver's state variables (id[0] and serial[0]) and replay
the queued events.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 99acedad 10-Nov-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Properly handle AES serial number and tool type

Current AES sensors relay tool type and serial number information with
a different set of usages than those prescribed by the modern (i.e.
MobileStudio Pro and newer) EMR tablet standard. To ensure the driver
properly understands these usages, we modify them to be compatible.
The identifying information is split across three consecutive fields:
a 16-bit WACOM_HID_WT_SERIALNUMBER (which is more accurately described
as WACOM_HID_WD_TOOLTYPE), a 32-bit HID_DG_TOOLSERIALNUMBER, and an
8-bit 0xFF000000 (which should be WACOM_HID_WD_SERIALHI). While we're
at it, we also define proper min/max values since may may be undefined
on some devices.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 9e429d56 07-Nov-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Send BTN_STYLUS3 when both barrel switches are set

The Wacom Pro Pen 3D includes a third barrel switch which is intended to
be particularly useful in applications where one frequency uses pan, zoom,
and rotate to navigate around a scene or model. The pen is compatible with
the MobileStudio Pro, 2nd-gen Intuos Pro, and Cintiq Pro. When the third
button is pressed, these devices set both the HID_DG_BARRELSWITCH and
HID_DG_BARRELSWITCH2 usages since their HID descriptors do not include a
usage specific to the button.

Rather than send both BTN_STYLUS and BTN_STYLUS2 when the third button is
pressed, userspace (libinput) has requested that we detect this condition
and report a newly-defined BTN_STYLUS3 event instead. We could define a
quirk specific to devices compatible with the Pro Pen 3D, but the liklihood
of seeing both barrel switch bits set with other pens/devices is low enough
to not worry about (pens mechanically prevent accidental activation of
multiple switches).

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 885e89f6 18-Oct-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Recognize WACOM_HID_WD_PEN as a type of pen collection

The WACOM_PEN_FIELD macro is used to determine if a given HID field should be
associated with pen input. This field includes several known collection types
that Wacom pen data is contained in, but the WACOM_HID_WD_PEN application
collection type is notably missing. This can result in fields within this
kind of collection being completely ignored by the `wacom_usage_mapping`
function, preventing the later '*_event' functions from being notified about
changes to their value.

Fixes: c9c095874a ("HID: wacom: generic: Support and use 'Custom HID' mode and usages")
Fixes: ac2423c975 ("HID: wacom: generic: add vendor defined touch")
Cc: stable@vger.kernel.org
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 5ac3d4ae 28-Apr-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Refactor generic battery handling

Generic battery handling code is spread between the pen and pad codepaths
since battery usages may appear in reports for either. This makes it
difficult to concisely see the logic involved. Since battery data is
not treated like other data (i.e., we report it through the power_supply
subsystem rather than through the input subsystem), it makes reasonable
sense to split the functionality out into its own functions.

This commit has the generic battery handling duplicate the same pattern
that is used by the pen, pad, and touch interfaces. A "mapping" function
is provided to set up the battery, an "event" function is provided to
update the battery data, and a "report" function is provided to notify
the power_supply subsystem after all the data has been read. We look at
the usage itself rather than its collection to determine if one of the
battery functions should handle it. Additionally, we unconditionally
call the "report" function since there is no particularly good way to
know if a report contained a battery usage; 'wacom_notify_battery()'
will filter out any duplicate updates, however.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 16e45989 28-Apr-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Add ability to provide explicit battery status info

At the moment, our driver relies on 'wacom_battery_get_property()' to
determine the most likely battery state (e.g charging, discharging, or
full) based on the information available. It is not always possible
for the function to properly determine this, however. For instance,
whenever an AES pen leaves proximity the battery state becomes
indeterminite. This commit adds the ability to provide it with explict
state information if desired. Whenever explicit state is not required
(the majority of circumstances), WACOM_POWER_SUPPLY_STATUS_AUTO can
be used in its place.

Three uses of explicit battery status are added: two wireless disconnect
paths and the AES case mentioned above.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# ed1fa736 04-Apr-2017 Ping Cheng <pinglinux@gmail.com>

HID: wacom: generic: sync pad events only for actual packets

Commits d793ff8 and 4082da8 introduced two pad usages which do not
actually send pad input events. To make sure we do not post empty
pad packets, pad_input_event_flag is introduced. Turn on the flag
for real pad input events so we can synchronize them properly.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# d793ff81 14-Feb-2017 Ping Cheng <pinglinux@gmail.com>

HID: wacom: generic: support touch on/off softkey

Wacom Cintiq Pro has a softkey to turn touch on/off. Since it is
a softkey, hardware/firmware still reports touch events no matter
what state the softkey is. We need to ignore touch events when
the key is in off mode.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 4082da80 14-Feb-2017 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: generic: add mode change touch key

Wacom Cintiq Pro added a touch key to switch the tablet between
display and opaque mode. This patch informs the change by removing
the old devices and creating new ones with proper properties.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Tested-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 4eb220cb 14-Feb-2017 Ping Cheng <pinglinux@gmail.com>

HID: wacom: generic: add 3 tablet touch keys

This patch add support to the 3 touch keys on Wacom Cintiq Pro. These touch
keys are in the middle of the other two keys on the top edge of the tablet.

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 10c55cac 25-Jan-2017 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: support LEDs

Add support for the LEDs around the mode switch to the generic code path in
support of the second generation Intuos Pro.

Signed-off-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# d2ec58ae 25-Jan-2017 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: support generic touch switch

The second generation Intuos Pro is the first device in the generic codepath
which has a touchswitch. We utilize a flag in wacom_shared in order to report
this switch event received from the pad on the touch input.

Signed-off-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# ac2423c9 25-Jan-2017 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: add vendor defined touch

Add vendor defined touch to support the second generation Intuos Pro.
Previously all generic Wacom devices used true HID to report their touch.

Signed-off-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 65ef4c1e 25-Jan-2017 Aaron Armstrong Skomra <skomra@gmail.com>

HID: wacom: generic: remove input_event_flag

Input_event_flag duplicates the information we track in
wacom_wac->hid_data.inrange_state for the pad.

Signed-off-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 4922cd26 25-Jan-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Support 2nd-gen Intuos Pro's Bluetooth classic interface

In addition to its USB interface, the second-generation Intuos Pro
includes a Bluetooth radio that offers two pairing interfaces: classic
and low-energy. The classic interface functions just like the earlier
Bluetooth-enabled Intuos4 and Graphire4 tablets, appearing as a HID device
that our driver can work with. The low-energy interface is intented to
be used by userspace applications that make use of its paper-to-digital
capabilities.

Despite the USB interface using Wacom's new vendor-defined HID usages,
the Bluetooth interface provides us with useless black-box "blob"
report descriptors like past devices. We thus have to explicitly add
support for the PIDs and reports used.

These devices pack a /lot/ of information into a single Bluetooth
input report. Each report contains up to seven snapshots of the pen
state, four snapshots of the touch state (of five touches each), pad
state, and battery data. Thankfully this isn't too hard for the driver
to report -- it just takes a fair amount of code to extract!

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 5ba13c64 25-Jan-2017 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Move WAC_CMD_* into wacom_wac.h

Centralize our definition of report IDs by moving those for device commands
into wacom_wac.h alongside those for input reports.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# c9cfb2ac 08-Dec-2016 Ping Cheng <pinglinux@gmail.com>

HID: wacom: generic: Don't sync input on empty input packets

post input_sync only when there are input events posted

Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
Reviewed-By: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# bf78adcb 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Extend pad support

The HID specification that the MobileStudio Pro follows includes usages
for several values that would be good to support so that future devices
"just work" out of the box. Extend the HID_GENERIC pad codepath to handle
these usages.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 93aab7fa 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Add support for battery status on pen and pad interfaces

Adds support for usages that may appear on the pen or pad interface which
report the state of the tablet battery.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 5922e613 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Introduce pad support

As with usages for the pen, the Custom HID specificiation includes
usages for the pad. Here we add functions to map and handle most
of the pad usages present on the MobileStudio Pro.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 345857bb 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Add support for sensor offsets

Many of Wacom's display tablets include an "outbound" area where pen
digitizing is possible but outside of the display area. To accommodate
such sensors in the HID_GENERIC codepath, we add support for the
necessary vendor-defined HID feature usages and adjust the min/max
values of the X and Y axes accordingly, similar to what is done in
the non-generic codepath.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# e779ef23 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Fix sensor outbounds and redefine as offsets from each edge

Many of Wacom's display tablets include an "outbound" area where pen
digitizing is possible but outside of the display area. To ensure that
pen coordinates are mapped to the correct on-screen location, the driver
sets the minimum and maximum axis values of X and Y to those coordinates
which coincide with the screen edge. These values are simply the
hardware minimum/maximum plus/minus the outbound size for a particular
edge.

When outbound support was added/updated in ac414da, fa77034, and
ecd618d, we decided to have the wacom_features structs store the desired
minimum and maximum values directly. In hindsight, this was perhaps not
the best choice since it has allowed minor errors to crop up unnoticed.
Some tablets have had their coordinates over-corrected (e.g. most of the
devices "fixed" in ecd618d were already adjusted in ac414da), while
others never had a correction applied (e.g. the ISDv5 325, whose
declared maximum the hardware maximum instead of the outbound maximum).

A less error-prone method of handling the outbound is to let the driver
calculate the correct minimum/maximum values by providing it with both
the actual hardware maximums and the size of the outbound on each edge.
These values are more easy to verify as correct since the values can be
trivially compared against specifications.

This patch reverts the declared maximum values to the actual hardware
maximums, e.g. as declared prior to ac414da (values for these and other
display tablets that were subsuquently introduced have been verified
against specs). Per-edge outbound sizes are stored in the wacom_features
struct as offset_{left,right,top,bottom} and used in combination with
the hardware ranges to calculate effective axis ranges for ABS_X and
ABS_Y.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# f85c9dc6 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Support tool ID and additional tool types

Devices following the new Custom HID mode specification (as well as even
some recent component sensors which use the same standard HID usage)
are capable of reporting tool ID information that we need to relay to
userspace. This patch adds support for reading and relaying the tool
type information, which is (unfortunately) split across two usages.
We also advertise the existence of tool types beyond BTN_TOOL_PEN
that might be available.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 61ce346a 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Add support for vendor-defined "Sense" usage

Wacom's professional tablets beginning with the Intuos4 are capable of
reporting an intermediate degree of proximity where the pen is no longer
close enough to communicate with ("in prox"), but still close enough to
be sensed ("in range"). This additional state is particularly useful for
performing palm rejection as it allows the driver to disable the touch
sensor while the pen is a greater distance from the tablet.

Like other professional tablets, the new MobileStudio Pro also reports
this intermeidate "in range" proximity state. Its descriptor assigns
usage 0xff0d0036 to this bit. Normally 'wacom_equivalent_usage' would
translate this to the standard HID "Quality" usage, but since this has
a different meaning we have it explicitly ignore the usage and define
it ourselves as "Sense" (since "In Range" is already defined by the
HID standard and interpreted by our driver as meaning "in prox").

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 929d6d5d 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Add support for vendor-defined "Fingerwheel" usage

The airbrush fingerwheel does not have a usage that corresponds cleanly
with a standard HID usage, so we add explicit support for it via its
vendor-defined usage.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# b5c921e6 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Add support for vendor-defined "Distance" usage

The vendor-defined 0xFF0D01032 ("Distance") usage is nearly equivalent to
HID_GD_Z, except that the axis direction is inverted. Unlike HID_GD_Z which
increases in value as the pen-to-surface distance is decreased, this usage
decreases. Treat this usage as a special case to ensure we don't invert the
scale to be ABS_DISTANCE compatible like we do for HID_GD_Z.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# c9c09587 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: generic: Support and use 'Custom HID' mode and usages

Wacom's new "MobileStudio Pro" tablets are the first devices in their
branded product line-up to include a usable HID descriptor for the pen
interface. Like prior branded products, the device can operate in one
of two modes: 'Standard HID', and 'Wacom Custom HID'. Although the
first mode is usable by the HID_GENERIC codepath as-is (huzzah!), it is
subject to some restrictions -- most notably pressure being limited
to 2048 levels instead of 8192. To ensure tablets that include support
for Custom HID mode work optimally, we add support for its usages and
switch the device to Custom HID mode if possible.

The usages defined for Custom HID mode are often numerically similar to
their standard HID equivalents, allowing us to write a simple translation
function that takes arbitrary HID usages as input and which returns
the corresponding standard HID usage as output (if one exists). Switching
on this translated usage instead of the actual usage allows the existing
cases to apply to both modes of operation without having to explicitly
define every Custom HID usage.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 1b18b75c 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Have WACOM_PEN_FIELD and WACOM_FINGER_FIELD recgonize more fields

We've defined several new usages (e.g. WACOM_G9_PEN and WACOM_G9_TOUCHSCREEN)
which aren't checked by the WACOM_PEN_FIELD and WACOM_FINGER_FIELD macros but
probably should be.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 8de82280 19-Oct-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Update vendor-defined usage names to better match standards

Our loose use of "pen" and "digitizer" in the naming of several of our
vendor-defined usages may be a source of confusion given that the terms
have specific meaning within the HID specification. "Pen" specifically
refers to "an integrated display that allows the use of a stylus" (e.g.
something like a tablet PC or Cintiq) wheras "Digitizer" is a better
fit for opaque tablets like an Intuos.

While we're at it, go ahead and rename the definitions to make them more
distinct and better match up with the convention used by HID (e.g. the use
of '_UP_' for usage pages) and make them more distinct.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 003f50ab 21-Jul-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Update last_slot_field during pre_report phase

If a touchscreen contains both multitouch and single-touch reports in its
descriptor in that order, the driver may overwrite information it saved
about the format of the multitouch report. This can cause the report
processing code to get tripped up and send an incorrect event stream to
userspace.

In particular, this can cause last_slot_field to be overwritten with the
result that the driver prematurely assumes it has finished processing a
slot and sending the ABS_MT_SLOT event at the wrong point in time,
associating events for the current contact with the following contact
instead.

To prevent this from occurring, we update the value of last_slot_field
durring the pre_report phase to ensure that it is correct for the report
that is to be processed.

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>


# e5bc8eb1 08-Aug-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Add WACOM_DEVICETYPE_DIRECT for Cintiqs and similar

"Direct" input devices like Cintiqs and Tablet PCs set the INPUT_PROP_DIRECT
property to notify userspace that the sensor and screen are overlaid. This
information can also be useful elsewhere within the kernel driver, however,
so we introduce a new WACOM_DEVICETYPE_DIRECT that signals this to other
kernel code.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 9956953e 13-Jul-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: power_supply: provide the actual model_name

Instead of displaying a generic "tablet", now g-c-c shows a pretty
"Wacom Intuos Pro S (WL)".

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 59d69bc8 13-Jul-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: EKR: have one power_supply per remote

Previously, all the remotes attached to the same receiver would share the
same power_supply. That's not good as the remotes will constantly change
the battery information according to their own state.

To have something generic enough, we introduce struct wacom_battery
which regroups all the information we need for a battery.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 83e6b40e 13-Jul-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: EKR: have the wacom resources dynamically allocated

If we want to have one input device per remote, it's better to have our
own struct wacom_remote which is dynamically allocated.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# e6f2813a 13-Jul-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: EKR: add a worker to add/remove resources on addition/removal

wacom_remote_status_irq() sends information of addition/removal of EKR.
We want to allocate one input node per remote, so better having this
in a separate worker, not handled in the IRQ directly.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 84dfbd7f 13-Jul-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: put the managed resources in a group

We currently have a complex clean_inputs() function while this can be
handled all by devres. Set a group that we can destroy in wireless_work().

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# bef7e200 22-Apr-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Add fuzz factor to distance and tilt axes

The fuzz present on the distance and tilt axes is noticable when a puck is
present, and userspace (specifically libinput) would like the ability to
filter out the noise. To facilitate this, we assign a fuzz value of '1'
for the distance and tilt axes. This is large enough to cover most of the
natural variation in distance value as the puck is moved around, and
enough to cover the jitter in rotation (reported through tilt axes) when
the puck is left alone.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 326ea2a9 04-Apr-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Support switching from vendor-defined device mode on G9 and G11

A tablet PC booted into Windows may have its pen/touch hardware switched
into "Wacom mode" similar to what we do with explicitly-supported hardware.
Some devices appear to maintain this state across reboots, preventing their
use with the generic HID driver. This patch adds support for detecting the
presence of the mode switch feature report used by devices based on the G9
and G11 chips and has the HID codepath always attempt to reset the device
back to sending standard HID reports.

Fixes: https://sourceforge.net/p/linuxwacom/bugs/307/
Fixes: https://sourceforge.net/p/linuxwacom/bugs/310/
Fixes: https://github.com/linuxwacom/input-wacom/issues/15

Co-authored-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 0bbfe28a 06-Jan-2016 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Use correct report to query pen ID from INTUOSHT2 devices

Unlike other tablets which are compatible with the wacom_intuos_irq handler,
INTUOSHT2 devices provide pen ID with report ID 8 instead of 5. To ensure
wacom_intuos_schedule_prox_event works as intended for these tablets, we
must be sure it uses the correct report ID in this case.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 06109993 30-Nov-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Rename wacom ID report ID macros

"INTUOSREAD" and "INTUOSWRITE" are poorly named. These are report IDs
for pen ID (proximity) packets. It should be noted that the latter is
only used on Intuos/Intuos2 for a second stylus when DualTrack is in use.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 7adb91bd 26-Oct-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: fix Intuos wireless report id issue

Intuos Pen in wireless mode does not have the same report id (2) as
when it is in USB mode (17).

This patch also moves WIRELESS next to REMOTE in type enum so we
can group devices with similar features easily.

Reported-by: Dale Brewe <dlbrewe@hotmail.com>
Tested-by: Dale Brewe <dlbrewe@hotmail.com>
Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 499522c8 07-Oct-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Tie cached HID_DG_CONTACTCOUNT indices to report ID

The cached indicies 'cc_index' and 'cc_value_index' introduced in 1b5d514
are only valid for a single report ID. If a touchscreen has multiple
reports with a HID_DG_CONTACTCOUNT usage, its possible that the values
will not be correct for the report we're handling, resulting in an
incorrect value for 'num_expected'. This has been observed with the Cintiq
Companion 2.

To address this, we store the ID of the report those indicies are valid
for in a new 'cc_report' variable. Before using them to get the expected
contact count, we first check if the ID of the report we're processing
matches 'cc_report'. If it doesn't, we update the indicies to point to
the HID_DG_CONTACTCOUNT usage of the current report (if it has one).

Cc: stable@vger.kernel.org
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# f7acb55c 13-Oct-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Add support for Cintiq Companion 2

Adds support for the EMR (pen+pad) and touchscreen devices used by the
Wacom Cintiq Companion 2. This applies both to using the device as a
standalone system, as well as when operating in "Cintiq mode" (where
the EMR/touchscreen are simply exposed as USB devices to the system
its connected to).

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Clifford Jolly <expiredpopsicle@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# eda01dab 23-Sep-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: Add four new Intuos devices

This series of devices supports both pen and touch. It reports
touch data in Bamboo3 format and pen data in Intuos pro format.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Tested-By: Aaron Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 3b164a00 23-Sep-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: Cleanup unsupported device_type for BAMBOO_PT

Not all Bamboo support both pen and touch. Make sure we deal with
pen only and touch only devices properly.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Tested-By: Aaron Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 72b236d6 20-Aug-2015 Aaron Skomra <skomra@gmail.com>

HID: wacom: Add support for Express Key Remote.

This device is pad (buttons) only, there is no stylus or touch. Up to
five remotes can pair with the device's associated USB dongle.

Signed-off-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 70ee06c5 20-Aug-2015 Aaron Skomra <skomra@gmail.com>

HID: wacom: Set button bits based on a new numbered_buttons

Prior to this commit, numbered button bit setting was done separately
for each device type in wacom_setup_pad_capabilities(). Here we add a
numbered_buttons property to the wacom_features struct and extract the
repeated bit setting code to a new function:
wacom_settup_numbered_buttons().

Signed-off-by: Aaron Skomra <aaron.skomra@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 3f14a63a 03-Aug-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Remove WACOM_QUIRK_NO_INPUT

WACOM_QUIRK_NO_INPUT is a signal to the driver that input devices
should not be created for a particular device. This quirk was used by
the wireless receiver to prevent any devices from being created during
the initial probe (defering it instead until we got a tablet connection
event in 'wacom_wireless_work').

This quirk is not necessary now that a device_type is associated with each
device. Any input device allocated by 'wacom_allocate_inputs' which is
not necessary for a particular device is freed in 'wacom_register_inputs'.
In particular, none of the wireless receivers devices have the pen, pad,
or touch device types set so the same effect is achieved without the need
to be explicit.

We now return early in wacom_retrieve_hid_descriptor for wireless devices
(to prevent the device_type from being overridden) but since we ignore the
HID descriptor for the wireless reciever anyway, this is not an issue.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>


# ccad85cc 03-Aug-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Replace WACOM_QUIRK_MONITOR with WACOM_DEVICETYPE_WL_MONITOR

The monitor interface on the wireless receiver is more logically expressed
as a type of device instead of a quirk.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>


# 1b5d514a 21-Jul-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Ignore contacts in excess of declared contact count

The reports sent from some touch devices (e.g. the Cintiq 24HDT) contain
junk data in the contact slots which follow the final "valid" contact.
To avoid forwarding it to usrspace, we store the reported contact count
during the pre-process phase and then only process that many contacts.
If a device sends its contacts across multiple reports (what Microsoft
refers to as "hybrid" mode) then the contact count will be zero for
reports other than the first.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>


# 2a6cdbdd 15-Jun-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Introduce new 'touch_input' device

Instead of having a single 'input_dev' device that will take either pen
or touch data depending on the type of the device, create seperate devices
devices for each. By splitting things like this, we can support devices
(e.g. the I2C "AES" sensors in some newer tablet PCs) that send both pen
and touch reports from a single endpoint.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 862cf553 15-Jun-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type

Historically, both the touch and pad tools would have shared the
'BTN_TOOL_FINGER' type. Any time you needed to distinguish the two, you
had to use some other bit of knowledge (e.g. that the pad was on the same
interface as the pen, and thus 'touch_max' would be zero).

To make these checks more readable, we introduce WACOM_DEVICETYPE_PAD.
Although we still have to rely on other bits of knowledge to set this
bit on the right interface (since it cannot be detected from the HID
descriptor), it can be done just once inside 'wacom_setup_device_quirks'.

This patch introduces no functional changes.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# aa86b18c 15-Jun-2015 Jason Gerecke <killertofu@gmail.com>

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>


# 042628ab 30-Apr-2015 Jason Gerecke <killertofu@gmail.com>

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>


# e48151a3 15-Apr-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: remove unused packet lengths

We use generic hid_report_len() to get individual packet length now.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# f3586d2f 20-Mar-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: remove hardcoded WACOM_QUIRK_MULTI_INPUT

The quirk was added for devices that support both pen and touch. It decides if
a device supports multiple inputs by hardcoded feature type. However, for some
devices, we do not know if they support both before accessing their HID
descriptors.

This patch relies on dynamically assigned device_type to make the decision.
Also, we make it certain that wacom_wac->shared is always created. That is, the
driver will not be loaded if it fails to create wacom_wac->shared.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 71fa641e 11-Mar-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Add battery presence indicator to wireless tablets

Declare the POWER_SUPPLY_PROP_PRESENT property to provide userspace
with a way to determine if the battery on a wireless tablet is plugged
in. Although current wireless tablets do not explicitly report this
information, it can be inferred from other state information. In
particular, a battery is assumed to be present if any of the following
are true: a non-zero battery level reported, the battery is reported as
charging, or the tablet is operating wirelessly.

Note: The last condition above may not strictly hold for the Graphire
Wireless (it charges from a DC barrel jack instead of a USB port), but I
do not know what is reported in the no-battery condition.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 8fac1722 11-Mar-2015 Jiri Kosina <jkosina@suse.cz>

HID: wacom: drop WACOM_PKGLEN_STATUS

The constant is not used (leftover from previous patch versions
that never got merged).

Reported-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 4ca4ec71 06-Mar-2015 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Move handling of Intuos status packets to seperate function

In addition to the touchswitch state for "Intuos", these packets are
also sent by the Intuos Pro, Intuos5, and last-generation Bamboo
tablets when using a wired connection. They contain, among other
things, information about the optional wireless module and battery
charge state (to be supported in subsuquent patches).

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 8c97a765 26-Feb-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: add full support of the Wacom Bamboo PAD

The stylus of this device works just fine out of the box.
The touch is seen by default as a mouse with relative events and some
gestures.
The wireless and the wired version have slightly different firmwares, but
the debug mode 2 on the feature 2 is common to the 2 devices. In this mode,
all the reports are emitted through the debug interface (pen, raw touch
and mouse emulation), so we have to re-route manually the events.

We keep the Pen interface as a HID_GENERIC one because it works, and only
parse the raw touches while discarding the mouse emulation & gestures.

Switching the default in raw mode allows us to have a consistent user
experience accross all the multitouch touchpads (and enable the touch part
of the devices).

Note that the buttons of this devices are reported through the touch
interface. There is no 'Pad' interface. It seemed more natural to have
the BTN_LEFT and BTN_RIGHT reported with the touch because they are
placed under the touch interface and it looks like they belong to the
touch part.

Tested-by: Josep Sanchez Ferreres <josep.sanchez.ferreres@est.fib.upc.edu>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# a97ac104 25-Feb-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: store the hid_device pointers of the sibling devices

The Bamboo PAD in debug mode needs to re-route events from the debug
interface to the Pen interface. This can be easily done with
hid_input_report(), but that means that we need to keep a reference to
the various hid_devices.

There should be only one touch and one pen interface per physical tablet,
so there is no need to keep a list of hid-devices, plain pointers are
sufficient.

Tested-by: Josep Sanchez Ferreres <josep.sanchez.ferreres@est.fib.upc.edu>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 500d4160 27-Jan-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: add support for Cintiq 27QHD and 27QHD touch

These devices have accelerometers. To report accelerometer coordinates, a new
property, INPUT_PROP_ACCELEROMETER, is added.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# b3bd7ef3 09-Jan-2015 Ping Cheng <pinglinux@gmail.com>

HID: wacom: peport In Range event according to the spec

Some Cintiq and Intuos tablets report In Range event. This event is sent before
valid data is reported when tool enters proximity; or before out of proximity
event is reported when tool exits.

While entering proximity, In Range means a pen is detected. This information
can be used for palm/touch rejection on both pen and touch enabled devices.
While exiting, it means the tool has reached its maximum detectable distance.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 61e9e7e4 05-Jan-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: add support of the Pen of the Bamboo Pad

Bamboo Pads are using the generic processing but their report descriptors
differ from the ISDv* line. The pen fields are marked with the .physical
as Digitizer_Pen, which makes also sense.

Add this field to the checks and enable for free Bamboo Pads.

Reported-by: Josep Sanchez Ferreres <josep.sanchez.ferreres@est.fib.upc.edu>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# d97a5522 05-Jan-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: use WACOM_*_FIELD macros in wacom_usage_mapping()

We introduced nice macros in wacom_wac.c to check whether a field is
a pen or a touch one.

wacom_usage_mapping() still uses it's own tests, which are not in sync with
the wacom_wac tests (.application is not checked).

That means that some legitimate fields might be filtered out from the
usage mapping, and thus will not be used properly while receiving the
events.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 601a22f3 10-Dec-2014 Jason Gerecke <killertofu@gmail.com>

HID: wacom: Report input events for each finger on generic devices

The existing generic touch code only reports events after reading an
entire HID report, which practically means that only data about the last
contact in a report will ever be provided to userspace. This patch uses
a trick from hid-multitouch.c to discover what type of field is at the
end of each contact; when such a field is encountered all the stored
contact data will be reported.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# fff00bf8 04-Dec-2014 Ping Cheng <pinglinux@gmail.com>

HID: wacom: Add support for DTU-1031X

Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 954df6ad 20-Nov-2014 Ping Cheng <pinglinux@gmail.com>

HID: wacom: PAD is independent with pen/touch

PAD can be on pen interface (Intuos Pro and Cintiq series) or touch
interface (Bamboo PT and Intuos PT series) or its own interface
(Bamboo pen-only and Intuos Pen M/S). We need to mark it independently.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 5ae6e89f 22-Sep-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: implement the finger part of the HID generic handling

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 7704ac93 22-Sep-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: implement generic HID handling for pen generic devices

ISDv4 and v5 are plain HID devices. We can directly implement a generic
HID parsing/handling and remove the need to manually add those PID in
the list of supported devices.

This patch implements the pen support only. The finger part will come in
a later patch.

To be properly notified of an .event() and a .report(), we need to force
hid-core to go through the HID parsing. By default, wacom.ko binds only
hidraw, so the hid parsing is not done by hid-core. When a true HID device
is there, we add the flag HID_CLAIMED_DRIVER to hid->claimed which will
force hid-core to parse the incoming reports.
(Note that this can be easily backported by directly setting the .claimed
flag to HID_CLAIMED_DRIVER even if hid-core does not support
HID_CONNECT_DRIVER)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 2546dacd 22-Sep-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

HID: wacom: split out input allocation and registration

If the input can be created earlier during probe, we can already populate
them while reading the report descriptor. This way, we can rely on the
hid subsystem directly for tablets which already provide a meaningful
report descriptor (like ISDv4-5).

This patch only splits the allocation and registration, but do not
change where we allocate the input. This will come in a later patch.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 81af7e61 06-Aug-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - handle Intuos 4 BT in wacom.ko

A good point of this change is that now, the Intuos4 bluetooth can handle
the different tools (artpen, airbrush, mice), and we get a common interface
between USB and BT for accessing the LEDs/OLEDs.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Tested-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 387142bb 06-Aug-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - handle Graphire BT tablets in wacom.ko

First, merge the Graphire BT tablet.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Tested-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# f81a1295 06-Aug-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - prepare the driver to include BT devices

Now that wacom is a hid driver, there is no point in having a separate
driver for bluetooth devices. This patch prepares the common paths of
Bluetooth devices in the common wacom driver. It also adds the sysfs file
"speed" used by Bluetooth devices.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Tested-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 7dbd229e 25-Jul-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - register an ac power supply for wireless devices

This is used by HID Bluetooth devices but also add some more information
to the USB Wireless Receiver.
We are just porting the bits from hid-wacom.c to the common driver here.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Przemo Firszt <przemo@firszt.eu>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# d70420b9 25-Jul-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - use a uniq name for the battery device

The current implementation uses "wacom_battery" as a generic name for
batteries. This prevents us to have two Wacom devices with a battery
attached as the power system will complain about the name which is already
registered.

Use an incremental name for each battery attached.

Related bug:
https://sourceforge.net/p/linuxwacom/bugs/248/

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Przemo Firszt <przemo@firszt.eu>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ac8d1010 25-Jul-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - enhance Wireless Receiver battery reporting

- Reports the current status of the battery (discharging, charging, full).
- Also notify the upower daemon when there is a change in the battery
value.
- keep the battery value as a percentage, not the raw value
- add WACOM_QUIRK_BATTERY to easily add a battery to a device (required
for Bluetooth devices)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Przemo Firszt <przemo@firszt.eu>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 471d1714 24-Jul-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: wacom - move the USB (now hid) Wacom driver in drivers/hid

wacom.ko is now a full HID driver, we have to move it into the proper
subdirectory: drivers/hid.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>