Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid

Pull HID updates from Jiri Kosina:

 - spurious power/wakeup sysfs files removal for I2C-HID devices, from
   Andrew Duggan

 - Logitech M560 support, from Goffredo Baroncelli

 - a lot of housekeeping cleanups to hid-lg4ff driver, from Michal Maly

 - improved support for Plantronics devices, from Terry Junge

 - Sony Motion Controller and Navigation Controller support and
   subsequent cleanups of hid-sony driver, from Frank Praznik and Simon
   Wood

 - HW support improvements to the Wacom driver, from Jason Gerecke and
   Ping Cheng

 - assorted small cleanups and device ID additions all over the place

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (69 commits)
  HID: cypress: use swap() in cp_report_fixup()
  HID: microsoft: Add Surface Power Cover
  HID: hid-sony: Fix report descriptor for Navigation Controller
  HID: hid-sony: Navigation controller only has 1 LED and no rumble
  HID: hid-sony: Add BT support for Navigation Controller
  HID: wacom: Introduce new 'touch_input' device
  HID: wacom: Split apart 'wacom_setup_pentouch_input_capabilites'
  HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type
  HID: wacom: Treat features->device_type values as flags
  HID: wacom: Simplify 'wacom_update_name'
  HID: rmi: Disable populating F30 when the touchpad has physical buttons
  HID: plantronics: Update to map volume up/down controls
  HID: sony: PS Move fix report descriptor
  HID: sony: PS3 Move enable LEDs and Rumble via BT
  HID: sony: Add support PS3 Move Battery via BT
  HID: sony: Add quirk for MOTION_CONTROLLER_BT
  HID: sony: Support PS3 Move Controller when connected via Bluetooth
  HID: i2c-hid: Do not set the ACPI companion field in the HID device
  usb, HID: Remove Vernier devices from lsusb and hid_ignore_list
  HID: hidpp: Add driver for mouse logitech M560
  ...
This commit is contained in:
Linus Torvalds 2015-06-23 14:05:52 -07:00
commit 67db8a8086
27 changed files with 1579 additions and 629 deletions

View file

@ -1,7 +1,7 @@
What: /sys/module/hid_logitech/drivers/hid:logitech/<dev>/range. What: /sys/bus/hid/drivers/logitech/<dev>/range
Date: July 2011 Date: July 2011
KernelVersion: 3.2 KernelVersion: 3.2
Contact: Michal Malý <madcatxster@gmail.com> Contact: Michal Malý <madcatxster@devoid-pointer.net>
Description: Display minimum, maximum and current range of the steering Description: Display minimum, maximum and current range of the steering
wheel. Writing a value within min and max boundaries sets the wheel. Writing a value within min and max boundaries sets the
range of the wheel. range of the wheel.
@ -9,7 +9,7 @@ Description: Display minimum, maximum and current range of the steering
What: /sys/bus/hid/drivers/logitech/<dev>/alternate_modes What: /sys/bus/hid/drivers/logitech/<dev>/alternate_modes
Date: Feb 2015 Date: Feb 2015
KernelVersion: 4.1 KernelVersion: 4.1
Contact: Michal Malý <madcatxster@gmail.com> Contact: Michal Malý <madcatxster@devoid-pointer.net>
Description: Displays a set of alternate modes supported by a wheel. Each Description: Displays a set of alternate modes supported by a wheel. Each
mode is listed as follows: mode is listed as follows:
Tag: Mode Name Tag: Mode Name
@ -45,7 +45,7 @@ Description: Displays a set of alternate modes supported by a wheel. Each
What: /sys/bus/hid/drivers/logitech/<dev>/real_id What: /sys/bus/hid/drivers/logitech/<dev>/real_id
Date: Feb 2015 Date: Feb 2015
KernelVersion: 4.1 KernelVersion: 4.1
Contact: Michal Malý <madcatxster@gmail.com> Contact: Michal Malý <madcatxster@devoid-pointer.net>
Description: Displays the real model of the wheel regardless of any Description: Displays the real model of the wheel regardless of any
alternate mode the wheel might be switched to. alternate mode the wheel might be switched to.
It is a read-only value. It is a read-only value.

View file

@ -4650,6 +4650,18 @@ F: drivers/hid/
F: include/linux/hid* F: include/linux/hid*
F: include/uapi/linux/hid* F: include/uapi/linux/hid*
HID SENSOR HUB DRIVERS
M: Jiri Kosina <jkosina@suse.cz>
M: Jonathan Cameron <jic23@kernel.org>
M: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
L: linux-input@vger.kernel.org
L: linux-iio@vger.kernel.org
S: Maintained
F: Documentation/hid/hid-sensor*
F: drivers/hid/hid-sensor-*
F: drivers/iio/*/hid-*
F: include/linux/hid-sensor-*
HIGH-RESOLUTION TIMERS, CLOCKEVENTS, DYNTICKS HIGH-RESOLUTION TIMERS, CLOCKEVENTS, DYNTICKS
M: Thomas Gleixner <tglx@linutronix.de> M: Thomas Gleixner <tglx@linutronix.de>
L: linux-kernel@vger.kernel.org L: linux-kernel@vger.kernel.org

View file

@ -634,7 +634,12 @@ config HID_PLANTRONICS
tristate "Plantronics USB HID Driver" tristate "Plantronics USB HID Driver"
depends on HID depends on HID
---help--- ---help---
Provides HID support for Plantronics telephony devices. Provides HID support for Plantronics USB audio devices.
Correctly maps vendor unique volume up/down HID usages to
KEY_VOLUMEUP and KEY_VOLUMEDOWN events and prevents core mapping
of other vendor unique HID usages to random mouse events.
Say M here if you may ever plug in a Plantronics USB audio device.
config HID_PRIMAX config HID_PRIMAX
tristate "Primax non-fully HID-compliant devices" tristate "Primax non-fully HID-compliant devices"

View file

@ -24,7 +24,7 @@ obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_ACRUX) += hid-axff.o
obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLE) += hid-apple.o
obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o
obj-$(CONFIG_HID_AUREAL) += hid-aureal.o obj-$(CONFIG_HID_AUREAL) += hid-aureal.o
obj-$(CONFIG_HID_BELKIN) += hid-belkin.o obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o
obj-$(CONFIG_HID_CHERRY) += hid-cherry.o obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
@ -46,12 +46,12 @@ obj-$(CONFIG_HID_ICADE) += hid-icade.o
obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o
obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o
obj-$(CONFIG_HID_KYE) += hid-kye.o obj-$(CONFIG_HID_KYE) += hid-kye.o
obj-$(CONFIG_HID_LCPOWER) += hid-lcpower.o obj-$(CONFIG_HID_LCPOWER) += hid-lcpower.o
obj-$(CONFIG_HID_LENOVO) += hid-lenovo.o obj-$(CONFIG_HID_LENOVO) += hid-lenovo.o
obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o
obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o
obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o
obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o

View file

@ -706,7 +706,8 @@ static void hid_scan_collection(struct hid_parser *parser, unsigned type)
if (hid->vendor == USB_VENDOR_ID_MICROSOFT && if (hid->vendor == USB_VENDOR_ID_MICROSOFT &&
(hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 || (hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 ||
hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3_JP) && hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3_JP ||
hid->product == USB_DEVICE_ID_MS_POWER_COVER) &&
hid->group == HID_GROUP_MULTITOUCH) hid->group == HID_GROUP_MULTITOUCH)
hid->group = HID_GROUP_GENERIC; hid->group = HID_GROUP_GENERIC;
@ -1061,13 +1062,13 @@ static u32 s32ton(__s32 value, unsigned n)
* Search linux-kernel and linux-usb-devel archives for "hid-core extract". * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
*/ */
static __u32 extract(const struct hid_device *hid, __u8 *report, __u32 hid_field_extract(const struct hid_device *hid, __u8 *report,
unsigned offset, unsigned n) unsigned offset, unsigned n)
{ {
u64 x; u64 x;
if (n > 32) if (n > 32)
hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
n, current->comm); n, current->comm);
report += offset >> 3; /* adjust byte index */ report += offset >> 3; /* adjust byte index */
@ -1076,6 +1077,7 @@ static __u32 extract(const struct hid_device *hid, __u8 *report,
x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
return (u32) x; return (u32) x;
} }
EXPORT_SYMBOL_GPL(hid_field_extract);
/* /*
* "implement" : set bits in a little endian bit stream. * "implement" : set bits in a little endian bit stream.
@ -1221,9 +1223,9 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
for (n = 0; n < count; n++) { for (n = 0; n < count; n++) {
value[n] = min < 0 ? value[n] = min < 0 ?
snto32(extract(hid, data, offset + n * size, size), snto32(hid_field_extract(hid, data, offset + n * size,
size) : size), size) :
extract(hid, data, offset + n * size, size); hid_field_extract(hid, data, offset + n * size, size);
/* Ignore report if ErrorRollOver */ /* Ignore report if ErrorRollOver */
if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && if (!(field->flags & HID_MAIN_ITEM_VARIABLE) &&
@ -1851,6 +1853,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPPRODOCK) },
#endif #endif
{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
@ -1901,6 +1904,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) }, { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) },
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
@ -1959,9 +1963,12 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
@ -1997,6 +2004,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) },
@ -2265,14 +2273,6 @@ static const struct hid_device_id hid_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
@ -2399,14 +2399,6 @@ static const struct hid_device_id hid_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) }, { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) }, { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) },
#endif #endif
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
{ HID_USB_DEVICE(USB_VENDOR_ID_RISO_KAGAKU, USB_DEVICE_ID_RI_KA_WEBMAIL) }, { HID_USB_DEVICE(USB_VENDOR_ID_RISO_KAGAKU, USB_DEVICE_ID_RI_KA_WEBMAIL) },
{ } { }

View file

@ -41,13 +41,9 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
for (i = 0; i < *rsize - 4; i++) for (i = 0; i < *rsize - 4; i++)
if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) {
__u8 tmp;
rdesc[i] = 0x19; rdesc[i] = 0x19;
rdesc[i + 2] = 0x29; rdesc[i + 2] = 0x29;
tmp = rdesc[i + 3]; swap(rdesc[i + 3], rdesc[i + 1]);
rdesc[i + 3] = rdesc[i + 1];
rdesc[i + 1] = tmp;
} }
return rdesc; return rdesc;
} }

View file

@ -227,6 +227,7 @@
#define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 #define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418
#define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d #define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d
#define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618 #define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618
#define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053
#define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123 #define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123
#define USB_DEVICE_ID_CHICONY_AK1D 0x1125 #define USB_DEVICE_ID_CHICONY_AK1D 0x1125
@ -363,16 +364,6 @@
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100 #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100
#define USB_VENDOR_ID_GLAB 0x06c2
#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040
#define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044
#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045
#define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051
#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053
#define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058
#define USB_VENDOR_ID_GOODTOUCH 0x1aad #define USB_VENDOR_ID_GOODTOUCH 0x1aad
#define USB_DEVICE_ID_GOODTOUCH_000f 0x000f #define USB_DEVICE_ID_GOODTOUCH_000f 0x000f
@ -586,6 +577,7 @@
#define USB_DEVICE_ID_LENOVO_TPKBD 0x6009 #define USB_DEVICE_ID_LENOVO_TPKBD 0x6009
#define USB_DEVICE_ID_LENOVO_CUSBKBD 0x6047 #define USB_DEVICE_ID_LENOVO_CUSBKBD 0x6047
#define USB_DEVICE_ID_LENOVO_CBTKBD 0x6048 #define USB_DEVICE_ID_LENOVO_CBTKBD 0x6048
#define USB_DEVICE_ID_LENOVO_TPPRODOCK 0x6067
#define USB_VENDOR_ID_LG 0x1fd2 #define USB_VENDOR_ID_LG 0x1fd2
#define USB_DEVICE_ID_LG_MULTITOUCH 0x0064 #define USB_DEVICE_ID_LG_MULTITOUCH 0x0064
@ -673,6 +665,7 @@
#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 #define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9
#define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07dc #define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07dc
#define USB_DEVICE_ID_MS_TYPE_COVER_3_JP 0x07dd #define USB_DEVICE_ID_MS_TYPE_COVER_3_JP 0x07dd
#define USB_DEVICE_ID_MS_POWER_COVER 0x07da
#define USB_VENDOR_ID_MOJO 0x8282 #define USB_VENDOR_ID_MOJO 0x8282
#define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201
@ -852,6 +845,7 @@
#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306 #define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306
#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
#define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4
#define USB_DEVICE_ID_SONY_MOTION_CONTROLLER 0x03d5
#define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f
#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002 #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002
#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000
@ -958,13 +952,6 @@
#define USB_DEVICE_ID_VELLEMAN_K8061_FIRST 0x8061 #define USB_DEVICE_ID_VELLEMAN_K8061_FIRST 0x8061
#define USB_DEVICE_ID_VELLEMAN_K8061_LAST 0x8068 #define USB_DEVICE_ID_VELLEMAN_K8061_LAST 0x8068
#define USB_VENDOR_ID_VERNIER 0x08f7
#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
#define USB_VENDOR_ID_VTL 0x0306 #define USB_VENDOR_ID_VTL 0x0306
#define USB_DEVICE_ID_VTL_MULTITOUCH_FF3F 0xff3f #define USB_DEVICE_ID_VTL_MULTITOUCH_FF3F 0xff3f
@ -983,9 +970,6 @@
#define USB_VENDOR_ID_WISEGROUP 0x0925 #define USB_VENDOR_ID_WISEGROUP 0x0925
#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
#define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888 #define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888
#define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800 #define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800
#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866 #define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866
@ -1039,4 +1023,11 @@
#define USB_VENDOR_ID_RISO_KAGAKU 0x1294 /* Riso Kagaku Corp. */ #define USB_VENDOR_ID_RISO_KAGAKU 0x1294 /* Riso Kagaku Corp. */
#define USB_DEVICE_ID_RI_KA_WEBMAIL 0x1320 /* Webmail Notifier */ #define USB_DEVICE_ID_RI_KA_WEBMAIL 0x1320 /* Webmail Notifier */
#define USB_VENDOR_ID_MULTIPLE_1781 0x1781
#define USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD 0x0a8d
#define USB_VENDOR_ID_DRACAL_RAPHNET 0x289b
#define USB_DEVICE_ID_RAPHNET_2NES2SNES 0x0002
#define USB_DEVICE_ID_RAPHNET_4NES4SNES 0x0003
#endif #endif

View file

@ -1157,7 +1157,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
return; return;
/* report the usage code as scancode if the key status has changed */ /* report the usage code as scancode if the key status has changed */
if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value) if (usage->type == EV_KEY &&
(!test_bit(usage->code, input->key)) == value)
input_event(input, EV_MSC, MSC_SCAN, usage->hid); input_event(input, EV_MSC, MSC_SCAN, usage->hid);
input_event(input, usage->type, usage->code, value); input_event(input, usage->type, usage->code, value);

View file

@ -43,6 +43,35 @@ struct lenovo_drvdata_cptkbd {
#define map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c)) #define map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
static const __u8 lenovo_pro_dock_need_fixup_collection[] = {
0x05, 0x88, /* Usage Page (Vendor Usage Page 0x88) */
0x09, 0x01, /* Usage (Vendor Usage 0x01) */
0xa1, 0x01, /* Collection (Application) */
0x85, 0x04, /* Report ID (4) */
0x19, 0x00, /* Usage Minimum (0) */
0x2a, 0xff, 0xff, /* Usage Maximum (65535) */
};
static __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
switch (hdev->product) {
case USB_DEVICE_ID_LENOVO_TPPRODOCK:
/* the fixups that need to be done:
* - get a reasonable usage max for the vendor collection
* 0x8801 from the report ID 4
*/
if (*rsize >= 153 &&
memcmp(&rdesc[140], lenovo_pro_dock_need_fixup_collection,
sizeof(lenovo_pro_dock_need_fixup_collection)) == 0) {
rdesc[151] = 0x01;
rdesc[152] = 0x00;
}
break;
}
return rdesc;
}
static int lenovo_input_mapping_tpkbd(struct hid_device *hdev, static int lenovo_input_mapping_tpkbd(struct hid_device *hdev,
struct hid_input *hi, struct hid_field *field, struct hid_input *hi, struct hid_field *field,
struct hid_usage *usage, unsigned long **bit, int *max) struct hid_usage *usage, unsigned long **bit, int *max)
@ -599,7 +628,8 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
GFP_KERNEL); GFP_KERNEL);
if (data_pointer == NULL) { if (data_pointer == NULL) {
hid_err(hdev, "Could not allocate memory for driver data\n"); hid_err(hdev, "Could not allocate memory for driver data\n");
return -ENOMEM; ret = -ENOMEM;
goto err;
} }
// set same default values as windows driver // set same default values as windows driver
@ -610,7 +640,8 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
if (name_mute == NULL || name_micmute == NULL) { if (name_mute == NULL || name_micmute == NULL) {
hid_err(hdev, "Could not allocate memory for led data\n"); hid_err(hdev, "Could not allocate memory for led data\n");
return -ENOMEM; ret = -ENOMEM;
goto err;
} }
snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(dev)); snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(dev));
snprintf(name_micmute, name_sz, "%s:amber:micmute", dev_name(dev)); snprintf(name_micmute, name_sz, "%s:amber:micmute", dev_name(dev));
@ -634,6 +665,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
lenovo_features_set_tpkbd(hdev); lenovo_features_set_tpkbd(hdev);
return 0; return 0;
err:
sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd);
return ret;
} }
static int lenovo_probe_cptkbd(struct hid_device *hdev) static int lenovo_probe_cptkbd(struct hid_device *hdev)
@ -762,10 +796,29 @@ static void lenovo_remove(struct hid_device *hdev)
hid_hw_stop(hdev); hid_hw_stop(hdev);
} }
static void lenovo_input_configured(struct hid_device *hdev,
struct hid_input *hi)
{
switch (hdev->product) {
case USB_DEVICE_ID_LENOVO_TPKBD:
case USB_DEVICE_ID_LENOVO_CUSBKBD:
case USB_DEVICE_ID_LENOVO_CBTKBD:
if (test_bit(EV_REL, hi->input->evbit)) {
/* set only for trackpoint device */
__set_bit(INPUT_PROP_POINTER, hi->input->propbit);
__set_bit(INPUT_PROP_POINTING_STICK,
hi->input->propbit);
}
break;
}
}
static const struct hid_device_id lenovo_devices[] = { static const struct hid_device_id lenovo_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPPRODOCK) },
{ } { }
}; };
@ -774,10 +827,12 @@ MODULE_DEVICE_TABLE(hid, lenovo_devices);
static struct hid_driver lenovo_driver = { static struct hid_driver lenovo_driver = {
.name = "lenovo", .name = "lenovo",
.id_table = lenovo_devices, .id_table = lenovo_devices,
.input_configured = lenovo_input_configured,
.input_mapping = lenovo_input_mapping, .input_mapping = lenovo_input_mapping,
.probe = lenovo_probe, .probe = lenovo_probe,
.remove = lenovo_remove, .remove = lenovo_remove,
.raw_event = lenovo_raw_event, .raw_event = lenovo_raw_event,
.report_fixup = lenovo_report_fixup,
}; };
module_hid_driver(lenovo_driver); module_hid_driver(lenovo_driver);

View file

@ -700,7 +700,8 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
/* insert a little delay of 10 jiffies ~ 40ms */ /* insert a little delay of 10 jiffies ~ 40ms */
wait_queue_head_t wait; wait_queue_head_t wait;
init_waitqueue_head (&wait); init_waitqueue_head (&wait);
wait_event_interruptible_timeout(wait, 0, 10); wait_event_interruptible_timeout(wait, 0,
msecs_to_jiffies(40));
/* Select random Address */ /* Select random Address */
buf[1] = 0xB2; buf[1] = 0xB2;
@ -712,13 +713,16 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
} }
if (drv_data->quirks & LG_FF) if (drv_data->quirks & LG_FF)
lgff_init(hdev); ret = lgff_init(hdev);
if (drv_data->quirks & LG_FF2) else if (drv_data->quirks & LG_FF2)
lg2ff_init(hdev); ret = lg2ff_init(hdev);
if (drv_data->quirks & LG_FF3) else if (drv_data->quirks & LG_FF3)
lg3ff_init(hdev); ret = lg3ff_init(hdev);
if (drv_data->quirks & LG_FF4) else if (drv_data->quirks & LG_FF4)
lg4ff_init(hdev); ret = lg4ff_init(hdev);
if (ret)
goto err_free;
return 0; return 0;
err_free: err_free:
@ -731,8 +735,8 @@ static void lg_remove(struct hid_device *hdev)
struct lg_drv_data *drv_data = hid_get_drvdata(hdev); struct lg_drv_data *drv_data = hid_get_drvdata(hdev);
if (drv_data->quirks & LG_FF4) if (drv_data->quirks & LG_FF4)
lg4ff_deinit(hdev); lg4ff_deinit(hdev);
else
hid_hw_stop(hdev); hid_hw_stop(hdev);
kfree(drv_data); kfree(drv_data);
} }

View file

@ -68,26 +68,32 @@
#define LG4FF_FFEX_REV_MAJ 0x21 #define LG4FF_FFEX_REV_MAJ 0x21
#define LG4FF_FFEX_REV_MIN 0x00 #define LG4FF_FFEX_REV_MIN 0x00
static void hid_lg4ff_set_range_dfp(struct hid_device *hid, u16 range); static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range);
static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range); static void lg4ff_set_range_g25(struct hid_device *hid, u16 range);
struct lg4ff_device_entry { struct lg4ff_wheel_data {
__u32 product_id; const u32 product_id;
__u16 range; u16 range;
__u16 min_range; const u16 min_range;
__u16 max_range; const u16 max_range;
#ifdef CONFIG_LEDS_CLASS #ifdef CONFIG_LEDS_CLASS
__u8 led_state; u8 led_state;
struct led_classdev *led[5]; struct led_classdev *led[5];
#endif #endif
u32 alternate_modes; const u32 alternate_modes;
const char *real_tag; const char * const real_tag;
const char *real_name; const char * const real_name;
u16 real_product_id; const u16 real_product_id;
struct list_head list;
void (*set_range)(struct hid_device *hid, u16 range); void (*set_range)(struct hid_device *hid, u16 range);
}; };
struct lg4ff_device_entry {
spinlock_t report_lock; /* Protect output HID report */
struct hid_report *report;
struct lg4ff_wheel_data wdata;
};
static const signed short lg4ff_wheel_effects[] = { static const signed short lg4ff_wheel_effects[] = {
FF_CONSTANT, FF_CONSTANT,
FF_AUTOCENTER, FF_AUTOCENTER,
@ -95,16 +101,16 @@ static const signed short lg4ff_wheel_effects[] = {
}; };
struct lg4ff_wheel { struct lg4ff_wheel {
const __u32 product_id; const u32 product_id;
const signed short *ff_effects; const signed short *ff_effects;
const __u16 min_range; const u16 min_range;
const __u16 max_range; const u16 max_range;
void (*set_range)(struct hid_device *hid, u16 range); void (*set_range)(struct hid_device *hid, u16 range);
}; };
struct lg4ff_compat_mode_switch { struct lg4ff_compat_mode_switch {
const __u8 cmd_count; /* Number of commands to send */ const u8 cmd_count; /* Number of commands to send */
const __u8 cmd[]; const u8 cmd[];
}; };
struct lg4ff_wheel_ident_info { struct lg4ff_wheel_ident_info {
@ -134,10 +140,10 @@ struct lg4ff_alternate_mode {
static const struct lg4ff_wheel lg4ff_devices[] = { static const struct lg4ff_wheel lg4ff_devices[] = {
{USB_DEVICE_ID_LOGITECH_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}, {USB_DEVICE_ID_LOGITECH_WHEEL, lg4ff_wheel_effects, 40, 270, NULL},
{USB_DEVICE_ID_LOGITECH_MOMO_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}, {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL, lg4ff_wheel_effects, 40, 270, NULL},
{USB_DEVICE_ID_LOGITECH_DFP_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_dfp}, {USB_DEVICE_ID_LOGITECH_DFP_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_dfp},
{USB_DEVICE_ID_LOGITECH_G25_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_g25}, {USB_DEVICE_ID_LOGITECH_G25_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_g25}, {USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_G27_WHEEL, lg4ff_wheel_effects, 40, 900, hid_lg4ff_set_range_g25}, {USB_DEVICE_ID_LOGITECH_G27_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2, lg4ff_wheel_effects, 40, 270, NULL}, {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2, lg4ff_wheel_effects, 40, 270, NULL},
{USB_DEVICE_ID_LOGITECH_WII_WHEEL, lg4ff_wheel_effects, 40, 270, NULL} {USB_DEVICE_ID_LOGITECH_WII_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}
}; };
@ -245,10 +251,10 @@ static const struct lg4ff_compat_mode_switch lg4ff_mode_switch_ext16_g25 = {
}; };
/* Recalculates X axis value accordingly to currently selected range */ /* Recalculates X axis value accordingly to currently selected range */
static __s32 lg4ff_adjust_dfp_x_axis(__s32 value, __u16 range) static s32 lg4ff_adjust_dfp_x_axis(s32 value, u16 range)
{ {
__u16 max_range; u16 max_range;
__s32 new_value; s32 new_value;
if (range == 900) if (range == 900)
return value; return value;
@ -269,21 +275,21 @@ static __s32 lg4ff_adjust_dfp_x_axis(__s32 value, __u16 range)
} }
int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field, int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value, struct lg_drv_data *drv_data) struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data)
{ {
struct lg4ff_device_entry *entry = drv_data->device_props; struct lg4ff_device_entry *entry = drv_data->device_props;
__s32 new_value = 0; s32 new_value = 0;
if (!entry) { if (!entry) {
hid_err(hid, "Device properties not found"); hid_err(hid, "Device properties not found");
return 0; return 0;
} }
switch (entry->product_id) { switch (entry->wdata.product_id) {
case USB_DEVICE_ID_LOGITECH_DFP_WHEEL: case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
switch (usage->code) { switch (usage->code) {
case ABS_X: case ABS_X:
new_value = lg4ff_adjust_dfp_x_axis(value, entry->range); new_value = lg4ff_adjust_dfp_x_axis(value, entry->wdata.range);
input_event(field->hidinput->input, usage->type, usage->code, new_value); input_event(field->hidinput->input, usage->type, usage->code, new_value);
return 1; return 1;
default: default:
@ -294,14 +300,56 @@ int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
} }
} }
static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect) static void lg4ff_init_wheel_data(struct lg4ff_wheel_data * const wdata, const struct lg4ff_wheel *wheel,
const struct lg4ff_multimode_wheel *mmode_wheel,
const u16 real_product_id)
{
u32 alternate_modes = 0;
const char *real_tag = NULL;
const char *real_name = NULL;
if (mmode_wheel) {
alternate_modes = mmode_wheel->alternate_modes;
real_tag = mmode_wheel->real_tag;
real_name = mmode_wheel->real_name;
}
{
struct lg4ff_wheel_data t_wdata = { .product_id = wheel->product_id,
.real_product_id = real_product_id,
.min_range = wheel->min_range,
.max_range = wheel->max_range,
.set_range = wheel->set_range,
.alternate_modes = alternate_modes,
.real_tag = real_tag,
.real_name = real_name };
memcpy(wdata, &t_wdata, sizeof(t_wdata));
}
}
static int lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
{ {
struct hid_device *hid = input_get_drvdata(dev); struct hid_device *hid = input_get_drvdata(dev);
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct lg4ff_device_entry *entry;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct lg_drv_data *drv_data;
__s32 *value = report->field[0]->value; unsigned long flags;
s32 *value;
int x; int x;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Private driver data not found!\n");
return -EINVAL;
}
entry = drv_data->device_props;
if (!entry) {
hid_err(hid, "Device properties not found!\n");
return -EINVAL;
}
value = entry->report->field[0]->value;
#define CLAMP(x) do { if (x < 0) x = 0; else if (x > 0xff) x = 0xff; } while (0) #define CLAMP(x) do { if (x < 0) x = 0; else if (x > 0xff) x = 0xff; } while (0)
switch (effect->type) { switch (effect->type) {
@ -309,6 +357,7 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e
x = effect->u.ramp.start_level + 0x80; /* 0x80 is no force */ x = effect->u.ramp.start_level + 0x80; /* 0x80 is no force */
CLAMP(x); CLAMP(x);
spin_lock_irqsave(&entry->report_lock, flags);
if (x == 0x80) { if (x == 0x80) {
/* De-activate force in slot-1*/ /* De-activate force in slot-1*/
value[0] = 0x13; value[0] = 0x13;
@ -319,7 +368,8 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
return 0; return 0;
} }
@ -331,7 +381,8 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
break; break;
} }
return 0; return 0;
@ -339,15 +390,16 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e
/* Sends default autocentering command compatible with /* Sends default autocentering command compatible with
* all wheels except Formula Force EX */ * all wheels except Formula Force EX */
static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude) static void lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude)
{ {
struct hid_device *hid = input_get_drvdata(dev); struct hid_device *hid = input_get_drvdata(dev);
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
__s32 *value = report->field[0]->value; s32 *value = report->field[0]->value;
__u32 expand_a, expand_b; u32 expand_a, expand_b;
struct lg4ff_device_entry *entry; struct lg4ff_device_entry *entry;
struct lg_drv_data *drv_data; struct lg_drv_data *drv_data;
unsigned long flags;
drv_data = hid_get_drvdata(hid); drv_data = hid_get_drvdata(hid);
if (!drv_data) { if (!drv_data) {
@ -360,8 +412,10 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
hid_err(hid, "Device properties not found!\n"); hid_err(hid, "Device properties not found!\n");
return; return;
} }
value = entry->report->field[0]->value;
/* De-activate Auto-Center */ /* De-activate Auto-Center */
spin_lock_irqsave(&entry->report_lock, flags);
if (magnitude == 0) { if (magnitude == 0) {
value[0] = 0xf5; value[0] = 0xf5;
value[1] = 0x00; value[1] = 0x00;
@ -371,7 +425,8 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
return; return;
} }
@ -384,7 +439,7 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
} }
/* Adjust for non-MOMO wheels */ /* Adjust for non-MOMO wheels */
switch (entry->product_id) { switch (entry->wdata.product_id) {
case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL: case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2: case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
break; break;
@ -401,7 +456,7 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
/* Activate Auto-Center */ /* Activate Auto-Center */
value[0] = 0x14; value[0] = 0x14;
@ -412,18 +467,34 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
} }
/* Sends autocentering command compatible with Formula Force EX */ /* Sends autocentering command compatible with Formula Force EX */
static void hid_lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude) static void lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude)
{ {
struct hid_device *hid = input_get_drvdata(dev); struct hid_device *hid = input_get_drvdata(dev);
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct lg4ff_device_entry *entry;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct lg_drv_data *drv_data;
__s32 *value = report->field[0]->value; unsigned long flags;
s32 *value;
magnitude = magnitude * 90 / 65535; magnitude = magnitude * 90 / 65535;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Private driver data not found!\n");
return;
}
entry = drv_data->device_props;
if (!entry) {
hid_err(hid, "Device properties not found!\n");
return;
}
value = entry->report->field[0]->value;
spin_lock_irqsave(&entry->report_lock, flags);
value[0] = 0xfe; value[0] = 0xfe;
value[1] = 0x03; value[1] = 0x03;
value[2] = magnitude >> 14; value[2] = magnitude >> 14;
@ -432,18 +503,33 @@ static void hid_lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude)
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
} }
/* Sends command to set range compatible with G25/G27/Driving Force GT */ /* Sends command to set range compatible with G25/G27/Driving Force GT */
static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range) static void lg4ff_set_range_g25(struct hid_device *hid, u16 range)
{ {
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct lg4ff_device_entry *entry;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct lg_drv_data *drv_data;
__s32 *value = report->field[0]->value; unsigned long flags;
s32 *value;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Private driver data not found!\n");
return;
}
entry = drv_data->device_props;
if (!entry) {
hid_err(hid, "Device properties not found!\n");
return;
}
value = entry->report->field[0]->value;
dbg_hid("G25/G27/DFGT: setting range to %u\n", range); dbg_hid("G25/G27/DFGT: setting range to %u\n", range);
spin_lock_irqsave(&entry->report_lock, flags);
value[0] = 0xf8; value[0] = 0xf8;
value[1] = 0x81; value[1] = 0x81;
value[2] = range & 0x00ff; value[2] = range & 0x00ff;
@ -452,20 +538,35 @@ static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range)
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
} }
/* Sends commands to set range compatible with Driving Force Pro wheel */ /* Sends commands to set range compatible with Driving Force Pro wheel */
static void hid_lg4ff_set_range_dfp(struct hid_device *hid, __u16 range) static void lg4ff_set_range_dfp(struct hid_device *hid, u16 range)
{ {
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct lg4ff_device_entry *entry;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct lg_drv_data *drv_data;
unsigned long flags;
int start_left, start_right, full_range; int start_left, start_right, full_range;
__s32 *value = report->field[0]->value; s32 *value;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Private driver data not found!\n");
return;
}
entry = drv_data->device_props;
if (!entry) {
hid_err(hid, "Device properties not found!\n");
return;
}
value = entry->report->field[0]->value;
dbg_hid("Driving Force Pro: setting range to %u\n", range); dbg_hid("Driving Force Pro: setting range to %u\n", range);
/* Prepare "coarse" limit command */ /* Prepare "coarse" limit command */
spin_lock_irqsave(&entry->report_lock, flags);
value[0] = 0xf8; value[0] = 0xf8;
value[1] = 0x00; /* Set later */ value[1] = 0x00; /* Set later */
value[2] = 0x00; value[2] = 0x00;
@ -475,13 +576,13 @@ static void hid_lg4ff_set_range_dfp(struct hid_device *hid, __u16 range)
value[6] = 0x00; value[6] = 0x00;
if (range > 200) { if (range > 200) {
report->field[0]->value[1] = 0x03; value[1] = 0x03;
full_range = 900; full_range = 900;
} else { } else {
report->field[0]->value[1] = 0x02; value[1] = 0x02;
full_range = 200; full_range = 200;
} }
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
/* Prepare "fine" limit command */ /* Prepare "fine" limit command */
value[0] = 0x81; value[0] = 0x81;
@ -493,7 +594,8 @@ static void hid_lg4ff_set_range_dfp(struct hid_device *hid, __u16 range)
value[6] = 0x00; value[6] = 0x00;
if (range == 200 || range == 900) { /* Do not apply any fine limit */ if (range == 200 || range == 900) { /* Do not apply any fine limit */
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
return; return;
} }
@ -507,7 +609,8 @@ static void hid_lg4ff_set_range_dfp(struct hid_device *hid, __u16 range)
value[5] = (start_right & 0xe) << 4 | (start_left & 0xe); value[5] = (start_right & 0xe) << 4 | (start_left & 0xe);
value[6] = 0xff; value[6] = 0xff;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
} }
static const struct lg4ff_compat_mode_switch *lg4ff_get_mode_switch_command(const u16 real_product_id, const u16 target_product_id) static const struct lg4ff_compat_mode_switch *lg4ff_get_mode_switch_command(const u16 real_product_id, const u16 target_product_id)
@ -569,19 +672,35 @@ static const struct lg4ff_compat_mode_switch *lg4ff_get_mode_switch_command(cons
static int lg4ff_switch_compatibility_mode(struct hid_device *hid, const struct lg4ff_compat_mode_switch *s) static int lg4ff_switch_compatibility_mode(struct hid_device *hid, const struct lg4ff_compat_mode_switch *s)
{ {
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct lg4ff_device_entry *entry;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct lg_drv_data *drv_data;
__s32 *value = report->field[0]->value; unsigned long flags;
s32 *value;
u8 i; u8 i;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Private driver data not found!\n");
return -EINVAL;
}
entry = drv_data->device_props;
if (!entry) {
hid_err(hid, "Device properties not found!\n");
return -EINVAL;
}
value = entry->report->field[0]->value;
spin_lock_irqsave(&entry->report_lock, flags);
for (i = 0; i < s->cmd_count; i++) { for (i = 0; i < s->cmd_count; i++) {
u8 j; u8 j;
for (j = 0; j < 7; j++) for (j = 0; j < 7; j++)
value[j] = s->cmd[j + (7*i)]; value[j] = s->cmd[j + (7*i)];
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
} }
spin_unlock_irqrestore(&entry->report_lock, flags);
hid_hw_wait(hid); hid_hw_wait(hid);
return 0; return 0;
} }
@ -606,23 +725,23 @@ static ssize_t lg4ff_alternate_modes_show(struct device *dev, struct device_attr
return 0; return 0;
} }
if (!entry->real_name) { if (!entry->wdata.real_name) {
hid_err(hid, "NULL pointer to string\n"); hid_err(hid, "NULL pointer to string\n");
return 0; return 0;
} }
for (i = 0; i < LG4FF_MODE_MAX_IDX; i++) { for (i = 0; i < LG4FF_MODE_MAX_IDX; i++) {
if (entry->alternate_modes & BIT(i)) { if (entry->wdata.alternate_modes & BIT(i)) {
/* Print tag and full name */ /* Print tag and full name */
count += scnprintf(buf + count, PAGE_SIZE - count, "%s: %s", count += scnprintf(buf + count, PAGE_SIZE - count, "%s: %s",
lg4ff_alternate_modes[i].tag, lg4ff_alternate_modes[i].tag,
!lg4ff_alternate_modes[i].product_id ? entry->real_name : lg4ff_alternate_modes[i].name); !lg4ff_alternate_modes[i].product_id ? entry->wdata.real_name : lg4ff_alternate_modes[i].name);
if (count >= PAGE_SIZE - 1) if (count >= PAGE_SIZE - 1)
return count; return count;
/* Mark the currently active mode with an asterisk */ /* Mark the currently active mode with an asterisk */
if (lg4ff_alternate_modes[i].product_id == entry->product_id || if (lg4ff_alternate_modes[i].product_id == entry->wdata.product_id ||
(lg4ff_alternate_modes[i].product_id == 0 && entry->product_id == entry->real_product_id)) (lg4ff_alternate_modes[i].product_id == 0 && entry->wdata.product_id == entry->wdata.real_product_id))
count += scnprintf(buf + count, PAGE_SIZE - count, " *\n"); count += scnprintf(buf + count, PAGE_SIZE - count, " *\n");
else else
count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
@ -675,10 +794,10 @@ static ssize_t lg4ff_alternate_modes_store(struct device *dev, struct device_att
const u16 mode_product_id = lg4ff_alternate_modes[i].product_id; const u16 mode_product_id = lg4ff_alternate_modes[i].product_id;
const char *tag = lg4ff_alternate_modes[i].tag; const char *tag = lg4ff_alternate_modes[i].tag;
if (entry->alternate_modes & BIT(i)) { if (entry->wdata.alternate_modes & BIT(i)) {
if (!strcmp(tag, lbuf)) { if (!strcmp(tag, lbuf)) {
if (!mode_product_id) if (!mode_product_id)
target_product_id = entry->real_product_id; target_product_id = entry->wdata.real_product_id;
else else
target_product_id = mode_product_id; target_product_id = mode_product_id;
break; break;
@ -693,24 +812,24 @@ static ssize_t lg4ff_alternate_modes_store(struct device *dev, struct device_att
} }
kfree(lbuf); /* Not needed anymore */ kfree(lbuf); /* Not needed anymore */
if (target_product_id == entry->product_id) /* Nothing to do */ if (target_product_id == entry->wdata.product_id) /* Nothing to do */
return count; return count;
/* Automatic switching has to be disabled for the switch to DF-EX mode to work correctly */ /* Automatic switching has to be disabled for the switch to DF-EX mode to work correctly */
if (target_product_id == USB_DEVICE_ID_LOGITECH_WHEEL && !lg4ff_no_autoswitch) { if (target_product_id == USB_DEVICE_ID_LOGITECH_WHEEL && !lg4ff_no_autoswitch) {
hid_info(hid, "\"%s\" cannot be switched to \"DF-EX\" mode. Load the \"hid_logitech\" module with \"lg4ff_no_autoswitch=1\" parameter set and try again\n", hid_info(hid, "\"%s\" cannot be switched to \"DF-EX\" mode. Load the \"hid_logitech\" module with \"lg4ff_no_autoswitch=1\" parameter set and try again\n",
entry->real_name); entry->wdata.real_name);
return -EINVAL; return -EINVAL;
} }
/* Take care of hardware limitations */ /* Take care of hardware limitations */
if ((entry->real_product_id == USB_DEVICE_ID_LOGITECH_DFP_WHEEL || entry->real_product_id == USB_DEVICE_ID_LOGITECH_G25_WHEEL) && if ((entry->wdata.real_product_id == USB_DEVICE_ID_LOGITECH_DFP_WHEEL || entry->wdata.real_product_id == USB_DEVICE_ID_LOGITECH_G25_WHEEL) &&
entry->product_id > target_product_id) { entry->wdata.product_id > target_product_id) {
hid_info(hid, "\"%s\" cannot be switched back into \"%s\" mode\n", entry->real_name, lg4ff_alternate_modes[i].name); hid_info(hid, "\"%s\" cannot be switched back into \"%s\" mode\n", entry->wdata.real_name, lg4ff_alternate_modes[i].name);
return -EINVAL; return -EINVAL;
} }
s = lg4ff_get_mode_switch_command(entry->real_product_id, target_product_id); s = lg4ff_get_mode_switch_command(entry->wdata.real_product_id, target_product_id);
if (!s) { if (!s) {
hid_err(hid, "Invalid target product ID %X\n", target_product_id); hid_err(hid, "Invalid target product ID %X\n", target_product_id);
return -EINVAL; return -EINVAL;
@ -721,9 +840,9 @@ static ssize_t lg4ff_alternate_modes_store(struct device *dev, struct device_att
} }
static DEVICE_ATTR(alternate_modes, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_alternate_modes_show, lg4ff_alternate_modes_store); static DEVICE_ATTR(alternate_modes, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_alternate_modes_show, lg4ff_alternate_modes_store);
/* Read current range and display it in terminal */ /* Export the currently set range of the wheel */
static ssize_t range_show(struct device *dev, struct device_attribute *attr, static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hid = to_hid_device(dev); struct hid_device *hid = to_hid_device(dev);
struct lg4ff_device_entry *entry; struct lg4ff_device_entry *entry;
@ -742,19 +861,19 @@ static ssize_t range_show(struct device *dev, struct device_attribute *attr,
return 0; return 0;
} }
count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->range); count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.range);
return count; return count;
} }
/* Set range to user specified value, call appropriate function /* Set range to user specified value, call appropriate function
* according to the type of the wheel */ * according to the type of the wheel */
static ssize_t range_store(struct device *dev, struct device_attribute *attr, static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct hid_device *hid = to_hid_device(dev); struct hid_device *hid = to_hid_device(dev);
struct lg4ff_device_entry *entry; struct lg4ff_device_entry *entry;
struct lg_drv_data *drv_data; struct lg_drv_data *drv_data;
__u16 range = simple_strtoul(buf, NULL, 10); u16 range = simple_strtoul(buf, NULL, 10);
drv_data = hid_get_drvdata(hid); drv_data = hid_get_drvdata(hid);
if (!drv_data) { if (!drv_data) {
@ -769,18 +888,18 @@ static ssize_t range_store(struct device *dev, struct device_attribute *attr,
} }
if (range == 0) if (range == 0)
range = entry->max_range; range = entry->wdata.max_range;
/* Check if the wheel supports range setting /* Check if the wheel supports range setting
* and that the range is within limits for the wheel */ * and that the range is within limits for the wheel */
if (entry->set_range != NULL && range >= entry->min_range && range <= entry->max_range) { if (entry->wdata.set_range && range >= entry->wdata.min_range && range <= entry->wdata.max_range) {
entry->set_range(hid, range); entry->wdata.set_range(hid, range);
entry->range = range; entry->wdata.range = range;
} }
return count; return count;
} }
static DEVICE_ATTR_RW(range); static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, lg4ff_range_show, lg4ff_range_store);
static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
@ -801,12 +920,12 @@ static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *a
return 0; return 0;
} }
if (!entry->real_tag || !entry->real_name) { if (!entry->wdata.real_tag || !entry->wdata.real_name) {
hid_err(hid, "NULL pointer to string\n"); hid_err(hid, "NULL pointer to string\n");
return 0; return 0;
} }
count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->real_tag, entry->real_name); count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name);
return count; return count;
} }
@ -818,12 +937,27 @@ static ssize_t lg4ff_real_id_store(struct device *dev, struct device_attribute *
static DEVICE_ATTR(real_id, S_IRUGO, lg4ff_real_id_show, lg4ff_real_id_store); static DEVICE_ATTR(real_id, S_IRUGO, lg4ff_real_id_show, lg4ff_real_id_store);
#ifdef CONFIG_LEDS_CLASS #ifdef CONFIG_LEDS_CLASS
static void lg4ff_set_leds(struct hid_device *hid, __u8 leds) static void lg4ff_set_leds(struct hid_device *hid, u8 leds)
{ {
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; struct lg_drv_data *drv_data;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list); struct lg4ff_device_entry *entry;
__s32 *value = report->field[0]->value; unsigned long flags;
s32 *value;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Private driver data not found!\n");
return;
}
entry = drv_data->device_props;
if (!entry) {
hid_err(hid, "Device properties not found!\n");
return;
}
value = entry->report->field[0]->value;
spin_lock_irqsave(&entry->report_lock, flags);
value[0] = 0xf8; value[0] = 0xf8;
value[1] = 0x12; value[1] = 0x12;
value[2] = leds; value[2] = leds;
@ -831,7 +965,8 @@ static void lg4ff_set_leds(struct hid_device *hid, __u8 leds)
value[4] = 0x00; value[4] = 0x00;
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hid, report, HID_REQ_SET_REPORT); hid_hw_request(hid, entry->report, HID_REQ_SET_REPORT);
spin_unlock_irqrestore(&entry->report_lock, flags);
} }
static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, static void lg4ff_led_set_brightness(struct led_classdev *led_cdev,
@ -848,7 +983,7 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev,
return; return;
} }
entry = (struct lg4ff_device_entry *)drv_data->device_props; entry = drv_data->device_props;
if (!entry) { if (!entry) {
hid_err(hid, "Device properties not found."); hid_err(hid, "Device properties not found.");
@ -856,15 +991,15 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev,
} }
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
if (led_cdev != entry->led[i]) if (led_cdev != entry->wdata.led[i])
continue; continue;
state = (entry->led_state >> i) & 1; state = (entry->wdata.led_state >> i) & 1;
if (value == LED_OFF && state) { if (value == LED_OFF && state) {
entry->led_state &= ~(1 << i); entry->wdata.led_state &= ~(1 << i);
lg4ff_set_leds(hid, entry->led_state); lg4ff_set_leds(hid, entry->wdata.led_state);
} else if (value != LED_OFF && !state) { } else if (value != LED_OFF && !state) {
entry->led_state |= 1 << i; entry->wdata.led_state |= 1 << i;
lg4ff_set_leds(hid, entry->led_state); lg4ff_set_leds(hid, entry->wdata.led_state);
} }
break; break;
} }
@ -883,7 +1018,7 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
return LED_OFF; return LED_OFF;
} }
entry = (struct lg4ff_device_entry *)drv_data->device_props; entry = drv_data->device_props;
if (!entry) { if (!entry) {
hid_err(hid, "Device properties not found."); hid_err(hid, "Device properties not found.");
@ -891,8 +1026,8 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
} }
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
if (led_cdev == entry->led[i]) { if (led_cdev == entry->wdata.led[i]) {
value = (entry->led_state >> i) & 1; value = (entry->wdata.led_state >> i) & 1;
break; break;
} }
@ -991,8 +1126,11 @@ int lg4ff_init(struct hid_device *hid)
{ {
struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
struct input_dev *dev = hidinput->input; struct input_dev *dev = hidinput->input;
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice); const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice);
const struct lg4ff_multimode_wheel *mmode_wheel = NULL;
struct lg4ff_device_entry *entry; struct lg4ff_device_entry *entry;
struct lg_drv_data *drv_data; struct lg_drv_data *drv_data;
int error, i, j; int error, i, j;
@ -1003,6 +1141,18 @@ int lg4ff_init(struct hid_device *hid)
if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
return -1; return -1;
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Cannot add device, private driver data not allocated\n");
return -1;
}
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (!entry)
return -ENOMEM;
spin_lock_init(&entry->report_lock);
entry->report = report;
drv_data->device_props = entry;
/* Check if a multimode wheel has been connected and /* Check if a multimode wheel has been connected and
* handle it appropriately */ * handle it appropriately */
mmode_ret = lg4ff_handle_multimode_wheel(hid, &real_product_id, bcdDevice); mmode_ret = lg4ff_handle_multimode_wheel(hid, &real_product_id, bcdDevice);
@ -1012,6 +1162,11 @@ int lg4ff_init(struct hid_device *hid)
*/ */
if (mmode_ret == LG4FF_MMODE_SWITCHED) if (mmode_ret == LG4FF_MMODE_SWITCHED)
return 0; return 0;
else if (mmode_ret < 0) {
hid_err(hid, "Unable to switch device mode during initialization, errno %d\n", mmode_ret);
error = mmode_ret;
goto err_init;
}
/* Check what wheel has been connected */ /* Check what wheel has been connected */
for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) { for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
@ -1022,9 +1177,11 @@ int lg4ff_init(struct hid_device *hid)
} }
if (i == ARRAY_SIZE(lg4ff_devices)) { if (i == ARRAY_SIZE(lg4ff_devices)) {
hid_err(hid, "Device is not supported by lg4ff driver. If you think it should be, consider reporting a bug to" hid_err(hid, "This device is flagged to be handled by the lg4ff module but this module does not know how to handle it. "
"LKML, Simon Wood <simon@mungewell.org> or Michal Maly <madcatxster@gmail.com>\n"); "Please report this as a bug to LKML, Simon Wood <simon@mungewell.org> or "
return -1; "Michal Maly <madcatxster@devoid-pointer.net>\n");
error = -1;
goto err_init;
} }
if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
@ -1035,7 +1192,8 @@ int lg4ff_init(struct hid_device *hid)
if (mmode_idx == ARRAY_SIZE(lg4ff_multimode_wheels)) { if (mmode_idx == ARRAY_SIZE(lg4ff_multimode_wheels)) {
hid_err(hid, "Device product ID %X is not listed as a multimode wheel", real_product_id); hid_err(hid, "Device product ID %X is not listed as a multimode wheel", real_product_id);
return -1; error = -1;
goto err_init;
} }
} }
@ -1043,37 +1201,17 @@ int lg4ff_init(struct hid_device *hid)
for (j = 0; lg4ff_devices[i].ff_effects[j] >= 0; j++) for (j = 0; lg4ff_devices[i].ff_effects[j] >= 0; j++)
set_bit(lg4ff_devices[i].ff_effects[j], dev->ffbit); set_bit(lg4ff_devices[i].ff_effects[j], dev->ffbit);
error = input_ff_create_memless(dev, NULL, hid_lg4ff_play); error = input_ff_create_memless(dev, NULL, lg4ff_play);
if (error) if (error)
return error; goto err_init;
/* Get private driver data */
drv_data = hid_get_drvdata(hid);
if (!drv_data) {
hid_err(hid, "Cannot add device, private driver data not allocated\n");
return -1;
}
/* Initialize device properties */ /* Initialize device properties */
entry = kzalloc(sizeof(struct lg4ff_device_entry), GFP_KERNEL);
if (!entry) {
hid_err(hid, "Cannot add device, insufficient memory to allocate device properties.\n");
return -ENOMEM;
}
drv_data->device_props = entry;
entry->product_id = lg4ff_devices[i].product_id;
entry->real_product_id = real_product_id;
entry->min_range = lg4ff_devices[i].min_range;
entry->max_range = lg4ff_devices[i].max_range;
entry->set_range = lg4ff_devices[i].set_range;
if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
BUG_ON(mmode_idx == -1); BUG_ON(mmode_idx == -1);
entry->alternate_modes = lg4ff_multimode_wheels[mmode_idx].alternate_modes; mmode_wheel = &lg4ff_multimode_wheels[mmode_idx];
entry->real_tag = lg4ff_multimode_wheels[mmode_idx].real_tag;
entry->real_name = lg4ff_multimode_wheels[mmode_idx].real_name;
} }
lg4ff_init_wheel_data(&entry->wdata, &lg4ff_devices[i], mmode_wheel, real_product_id);
/* Check if autocentering is available and /* Check if autocentering is available and
* set the centering force to zero by default */ * set the centering force to zero by default */
@ -1081,9 +1219,9 @@ int lg4ff_init(struct hid_device *hid)
/* Formula Force EX expects different autocentering command */ /* Formula Force EX expects different autocentering command */
if ((bcdDevice >> 8) == LG4FF_FFEX_REV_MAJ && if ((bcdDevice >> 8) == LG4FF_FFEX_REV_MAJ &&
(bcdDevice & 0xff) == LG4FF_FFEX_REV_MIN) (bcdDevice & 0xff) == LG4FF_FFEX_REV_MIN)
dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex; dev->ff->set_autocenter = lg4ff_set_autocenter_ffex;
else else
dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default; dev->ff->set_autocenter = lg4ff_set_autocenter_default;
dev->ff->set_autocenter(dev, 0); dev->ff->set_autocenter(dev, 0);
} }
@ -1091,27 +1229,27 @@ int lg4ff_init(struct hid_device *hid)
/* Create sysfs interface */ /* Create sysfs interface */
error = device_create_file(&hid->dev, &dev_attr_range); error = device_create_file(&hid->dev, &dev_attr_range);
if (error) if (error)
return error; hid_warn(hid, "Unable to create sysfs interface for \"range\", errno %d\n", error);
if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) { if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
error = device_create_file(&hid->dev, &dev_attr_real_id); error = device_create_file(&hid->dev, &dev_attr_real_id);
if (error) if (error)
return error; hid_warn(hid, "Unable to create sysfs interface for \"real_id\", errno %d\n", error);
error = device_create_file(&hid->dev, &dev_attr_alternate_modes); error = device_create_file(&hid->dev, &dev_attr_alternate_modes);
if (error) if (error)
return error; hid_warn(hid, "Unable to create sysfs interface for \"alternate_modes\", errno %d\n", error);
} }
dbg_hid("sysfs interface created\n"); dbg_hid("sysfs interface created\n");
/* Set the maximum range to start with */ /* Set the maximum range to start with */
entry->range = entry->max_range; entry->wdata.range = entry->wdata.max_range;
if (entry->set_range != NULL) if (entry->wdata.set_range)
entry->set_range(hid, entry->range); entry->wdata.set_range(hid, entry->wdata.range);
#ifdef CONFIG_LEDS_CLASS #ifdef CONFIG_LEDS_CLASS
/* register led subsystem - G27 only */ /* register led subsystem - G27 only */
entry->led_state = 0; entry->wdata.led_state = 0;
for (j = 0; j < 5; j++) for (j = 0; j < 5; j++)
entry->led[j] = NULL; entry->wdata.led[j] = NULL;
if (lg4ff_devices[i].product_id == USB_DEVICE_ID_LOGITECH_G27_WHEEL) { if (lg4ff_devices[i].product_id == USB_DEVICE_ID_LOGITECH_G27_WHEEL) {
struct led_classdev *led; struct led_classdev *led;
@ -1126,7 +1264,7 @@ int lg4ff_init(struct hid_device *hid)
led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL); led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL);
if (!led) { if (!led) {
hid_err(hid, "can't allocate memory for LED %d\n", j); hid_err(hid, "can't allocate memory for LED %d\n", j);
goto err; goto err_leds;
} }
name = (void *)(&led[1]); name = (void *)(&led[1]);
@ -1137,16 +1275,16 @@ int lg4ff_init(struct hid_device *hid)
led->brightness_get = lg4ff_led_get_brightness; led->brightness_get = lg4ff_led_get_brightness;
led->brightness_set = lg4ff_led_set_brightness; led->brightness_set = lg4ff_led_set_brightness;
entry->led[j] = led; entry->wdata.led[j] = led;
error = led_classdev_register(&hid->dev, led); error = led_classdev_register(&hid->dev, led);
if (error) { if (error) {
hid_err(hid, "failed to register LED %d. Aborting.\n", j); hid_err(hid, "failed to register LED %d. Aborting.\n", j);
err: err_leds:
/* Deregister LEDs (if any) */ /* Deregister LEDs (if any) */
for (j = 0; j < 5; j++) { for (j = 0; j < 5; j++) {
led = entry->led[j]; led = entry->wdata.led[j];
entry->led[j] = NULL; entry->wdata.led[j] = NULL;
if (!led) if (!led)
continue; continue;
led_classdev_unregister(led); led_classdev_unregister(led);
@ -1160,6 +1298,11 @@ int lg4ff_init(struct hid_device *hid)
#endif #endif
hid_info(hid, "Force feedback support for Logitech Gaming Wheels\n"); hid_info(hid, "Force feedback support for Logitech Gaming Wheels\n");
return 0; return 0;
err_init:
drv_data->device_props = NULL;
kfree(entry);
return error;
} }
int lg4ff_deinit(struct hid_device *hid) int lg4ff_deinit(struct hid_device *hid)
@ -1176,14 +1319,13 @@ int lg4ff_deinit(struct hid_device *hid)
if (!entry) if (!entry)
goto out; /* Nothing more to do */ goto out; /* Nothing more to do */
device_remove_file(&hid->dev, &dev_attr_range);
/* Multimode devices will have at least the "MODE_NATIVE" bit set */ /* Multimode devices will have at least the "MODE_NATIVE" bit set */
if (entry->alternate_modes) { if (entry->wdata.alternate_modes) {
device_remove_file(&hid->dev, &dev_attr_real_id); device_remove_file(&hid->dev, &dev_attr_real_id);
device_remove_file(&hid->dev, &dev_attr_alternate_modes); device_remove_file(&hid->dev, &dev_attr_alternate_modes);
} }
device_remove_file(&hid->dev, &dev_attr_range);
#ifdef CONFIG_LEDS_CLASS #ifdef CONFIG_LEDS_CLASS
{ {
int j; int j;
@ -1192,8 +1334,8 @@ int lg4ff_deinit(struct hid_device *hid)
/* Deregister LEDs (if any) */ /* Deregister LEDs (if any) */
for (j = 0; j < 5; j++) { for (j = 0; j < 5; j++) {
led = entry->led[j]; led = entry->wdata.led[j];
entry->led[j] = NULL; entry->wdata.led[j] = NULL;
if (!led) if (!led)
continue; continue;
led_classdev_unregister(led); led_classdev_unregister(led);
@ -1201,10 +1343,10 @@ int lg4ff_deinit(struct hid_device *hid)
} }
} }
#endif #endif
hid_hw_stop(hid);
drv_data->device_props = NULL;
/* Deallocate memory */
kfree(entry); kfree(entry);
out: out:
dbg_hid("Device successfully unregistered\n"); dbg_hid("Device successfully unregistered\n");
return 0; return 0;

View file

@ -5,12 +5,12 @@
extern int lg4ff_no_autoswitch; /* From hid-lg.c */ extern int lg4ff_no_autoswitch; /* From hid-lg.c */
int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field, int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value, struct lg_drv_data *drv_data); struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data);
int lg4ff_init(struct hid_device *hdev); int lg4ff_init(struct hid_device *hdev);
int lg4ff_deinit(struct hid_device *hdev); int lg4ff_deinit(struct hid_device *hdev);
#else #else
static inline int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field, static inline int lg4ff_adjust_input_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value, struct lg_drv_data *drv_data) { return 0; } struct hid_usage *usage, s32 value, struct lg_drv_data *drv_data) { return 0; }
static inline int lg4ff_init(struct hid_device *hdev) { return -1; } static inline int lg4ff_init(struct hid_device *hdev) { return -1; }
static inline int lg4ff_deinit(struct hid_device *hdev) { return -1; } static inline int lg4ff_deinit(struct hid_device *hdev) { return -1; }
#endif #endif

View file

@ -40,8 +40,9 @@ MODULE_PARM_DESC(disable_raw_mode,
#define HIDPP_REPORT_LONG_LENGTH 20 #define HIDPP_REPORT_LONG_LENGTH 20
#define HIDPP_QUIRK_CLASS_WTP BIT(0) #define HIDPP_QUIRK_CLASS_WTP BIT(0)
#define HIDPP_QUIRK_CLASS_M560 BIT(1)
/* bits 1..20 are reserved for classes */ /* bits 2..20 are reserved for classes */
#define HIDPP_QUIRK_DELAYED_INIT BIT(21) #define HIDPP_QUIRK_DELAYED_INIT BIT(21)
#define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22)
@ -930,6 +931,207 @@ static int wtp_connect(struct hid_device *hdev, bool connected)
true, true); true, true);
} }
/* ------------------------------------------------------------------------- */
/* Logitech M560 devices */
/* ------------------------------------------------------------------------- */
/*
* Logitech M560 protocol overview
*
* The Logitech M560 mouse, is designed for windows 8. When the middle and/or
* the sides buttons are pressed, it sends some keyboard keys events
* instead of buttons ones.
* To complicate things further, the middle button keys sequence
* is different from the odd press and the even press.
*
* forward button -> Super_R
* backward button -> Super_L+'d' (press only)
* middle button -> 1st time: Alt_L+SuperL+XF86TouchpadOff (press only)
* 2nd time: left-click (press only)
* NB: press-only means that when the button is pressed, the
* KeyPress/ButtonPress and KeyRelease/ButtonRelease events are generated
* together sequentially; instead when the button is released, no event is
* generated !
*
* With the command
* 10<xx>0a 3500af03 (where <xx> is the mouse id),
* the mouse reacts differently:
* - it never sends a keyboard key event
* - for the three mouse button it sends:
* middle button press 11<xx>0a 3500af00...
* side 1 button (forward) press 11<xx>0a 3500b000...
* side 2 button (backward) press 11<xx>0a 3500ae00...
* middle/side1/side2 button release 11<xx>0a 35000000...
*/
static const u8 m560_config_parameter[] = {0x00, 0xaf, 0x03};
struct m560_private_data {
struct input_dev *input;
};
/* how buttons are mapped in the report */
#define M560_MOUSE_BTN_LEFT 0x01
#define M560_MOUSE_BTN_RIGHT 0x02
#define M560_MOUSE_BTN_WHEEL_LEFT 0x08
#define M560_MOUSE_BTN_WHEEL_RIGHT 0x10
#define M560_SUB_ID 0x0a
#define M560_BUTTON_MODE_REGISTER 0x35
static int m560_send_config_command(struct hid_device *hdev, bool connected)
{
struct hidpp_report response;
struct hidpp_device *hidpp_dev;
hidpp_dev = hid_get_drvdata(hdev);
if (!connected)
return -ENODEV;
return hidpp_send_rap_command_sync(
hidpp_dev,
REPORT_ID_HIDPP_SHORT,
M560_SUB_ID,
M560_BUTTON_MODE_REGISTER,
(u8 *)m560_config_parameter,
sizeof(m560_config_parameter),
&response
);
}
static int m560_allocate(struct hid_device *hdev)
{
struct hidpp_device *hidpp = hid_get_drvdata(hdev);
struct m560_private_data *d;
d = devm_kzalloc(&hdev->dev, sizeof(struct m560_private_data),
GFP_KERNEL);
if (!d)
return -ENOMEM;
hidpp->private_data = d;
return 0;
};
static int m560_raw_event(struct hid_device *hdev, u8 *data, int size)
{
struct hidpp_device *hidpp = hid_get_drvdata(hdev);
struct m560_private_data *mydata = hidpp->private_data;
/* sanity check */
if (!mydata || !mydata->input) {
hid_err(hdev, "error in parameter\n");
return -EINVAL;
}
if (size < 7) {
hid_err(hdev, "error in report\n");
return 0;
}
if (data[0] == REPORT_ID_HIDPP_LONG &&
data[2] == M560_SUB_ID && data[6] == 0x00) {
/*
* m560 mouse report for middle, forward and backward button
*
* data[0] = 0x11
* data[1] = device-id
* data[2] = 0x0a
* data[5] = 0xaf -> middle
* 0xb0 -> forward
* 0xae -> backward
* 0x00 -> release all
* data[6] = 0x00
*/
switch (data[5]) {
case 0xaf:
input_report_key(mydata->input, BTN_MIDDLE, 1);
break;
case 0xb0:
input_report_key(mydata->input, BTN_FORWARD, 1);
break;
case 0xae:
input_report_key(mydata->input, BTN_BACK, 1);
break;
case 0x00:
input_report_key(mydata->input, BTN_BACK, 0);
input_report_key(mydata->input, BTN_FORWARD, 0);
input_report_key(mydata->input, BTN_MIDDLE, 0);
break;
default:
hid_err(hdev, "error in report\n");
return 0;
}
input_sync(mydata->input);
} else if (data[0] == 0x02) {
/*
* Logitech M560 mouse report
*
* data[0] = type (0x02)
* data[1..2] = buttons
* data[3..5] = xy
* data[6] = wheel
*/
int v;
input_report_key(mydata->input, BTN_LEFT,
!!(data[1] & M560_MOUSE_BTN_LEFT));
input_report_key(mydata->input, BTN_RIGHT,
!!(data[1] & M560_MOUSE_BTN_RIGHT));
if (data[1] & M560_MOUSE_BTN_WHEEL_LEFT)
input_report_rel(mydata->input, REL_HWHEEL, -1);
else if (data[1] & M560_MOUSE_BTN_WHEEL_RIGHT)
input_report_rel(mydata->input, REL_HWHEEL, 1);
v = hid_snto32(hid_field_extract(hdev, data+3, 0, 12), 12);
input_report_rel(mydata->input, REL_X, v);
v = hid_snto32(hid_field_extract(hdev, data+3, 12, 12), 12);
input_report_rel(mydata->input, REL_Y, v);
v = hid_snto32(data[6], 8);
input_report_rel(mydata->input, REL_WHEEL, v);
input_sync(mydata->input);
}
return 1;
}
static void m560_populate_input(struct hidpp_device *hidpp,
struct input_dev *input_dev, bool origin_is_hid_core)
{
struct m560_private_data *mydata = hidpp->private_data;
mydata->input = input_dev;
__set_bit(EV_KEY, mydata->input->evbit);
__set_bit(BTN_MIDDLE, mydata->input->keybit);
__set_bit(BTN_RIGHT, mydata->input->keybit);
__set_bit(BTN_LEFT, mydata->input->keybit);
__set_bit(BTN_BACK, mydata->input->keybit);
__set_bit(BTN_FORWARD, mydata->input->keybit);
__set_bit(EV_REL, mydata->input->evbit);
__set_bit(REL_X, mydata->input->relbit);
__set_bit(REL_Y, mydata->input->relbit);
__set_bit(REL_WHEEL, mydata->input->relbit);
__set_bit(REL_HWHEEL, mydata->input->relbit);
}
static int m560_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
return -1;
}
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* Generic HID++ devices */ /* Generic HID++ devices */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@ -942,6 +1144,9 @@ static int hidpp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
return wtp_input_mapping(hdev, hi, field, usage, bit, max); return wtp_input_mapping(hdev, hi, field, usage, bit, max);
else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 &&
field->application != HID_GD_MOUSE)
return m560_input_mapping(hdev, hi, field, usage, bit, max);
return 0; return 0;
} }
@ -951,6 +1156,8 @@ static void hidpp_populate_input(struct hidpp_device *hidpp,
{ {
if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
wtp_populate_input(hidpp, input, origin_is_hid_core); wtp_populate_input(hidpp, input, origin_is_hid_core);
else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560)
m560_populate_input(hidpp, input, origin_is_hid_core);
} }
static void hidpp_input_configured(struct hid_device *hdev, static void hidpp_input_configured(struct hid_device *hdev,
@ -1038,6 +1245,8 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report,
if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
return wtp_raw_event(hdev, data, size); return wtp_raw_event(hdev, data, size);
else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560)
return m560_raw_event(hdev, data, size);
return 0; return 0;
} }
@ -1115,6 +1324,10 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
ret = wtp_connect(hdev, connected); ret = wtp_connect(hdev, connected);
if (ret) if (ret)
return; return;
} else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) {
ret = m560_send_config_command(hdev, connected);
if (ret)
return;
} }
if (!connected || hidpp->delayed_input) if (!connected || hidpp->delayed_input)
@ -1190,7 +1403,11 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
ret = wtp_allocate(hdev, id); ret = wtp_allocate(hdev, id);
if (ret) if (ret)
goto wtp_allocate_fail; goto allocate_fail;
} else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) {
ret = m560_allocate(hdev);
if (ret)
goto allocate_fail;
} }
INIT_WORK(&hidpp->work, delayed_work_cb); INIT_WORK(&hidpp->work, delayed_work_cb);
@ -1253,7 +1470,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
hid_parse_fail: hid_parse_fail:
cancel_work_sync(&hidpp->work); cancel_work_sync(&hidpp->work);
mutex_destroy(&hidpp->send_mutex); mutex_destroy(&hidpp->send_mutex);
wtp_allocate_fail: allocate_fail:
hid_set_drvdata(hdev, NULL); hid_set_drvdata(hdev, NULL);
return ret; return ret;
} }
@ -1281,6 +1498,10 @@ static const struct hid_device_id hidpp_devices[] = {
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
USB_DEVICE_ID_LOGITECH_T651), USB_DEVICE_ID_LOGITECH_T651),
.driver_data = HIDPP_QUIRK_CLASS_WTP }, .driver_data = HIDPP_QUIRK_CLASS_WTP },
{ /* Mouse logitech M560 */
HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
USB_VENDOR_ID_LOGITECH, 0x402d),
.driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560 },
{ HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
USB_VENDOR_ID_LOGITECH, HID_ANY_ID)}, USB_VENDOR_ID_LOGITECH, HID_ANY_ID)},

View file

@ -280,6 +280,8 @@ static const struct hid_device_id ms_devices[] = {
.driver_data = MS_HIDINPUT }, .driver_data = MS_HIDINPUT },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP), { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP),
.driver_data = MS_HIDINPUT }, .driver_data = MS_HIDINPUT },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER),
.driver_data = MS_HIDINPUT },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT),
.driver_data = MS_PRESENTER }, .driver_data = MS_PRESENTER },

View file

@ -2,7 +2,7 @@
* Plantronics USB HID Driver * Plantronics USB HID Driver
* *
* Copyright (c) 2014 JD Cole <jd.cole@plantronics.com> * Copyright (c) 2014 JD Cole <jd.cole@plantronics.com>
* Copyright (c) 2014 Terry Junge <terry.junge@plantronics.com> * Copyright (c) 2015 Terry Junge <terry.junge@plantronics.com>
*/ */
/* /*
@ -17,23 +17,138 @@
#include <linux/hid.h> #include <linux/hid.h>
#include <linux/module.h> #include <linux/module.h>
#define PLT_HID_1_0_PAGE 0xffa00000
#define PLT_HID_2_0_PAGE 0xffa20000
#define PLT_BASIC_TELEPHONY 0x0003
#define PLT_BASIC_EXCEPTION 0x0005
#define PLT_VOL_UP 0x00b1
#define PLT_VOL_DOWN 0x00b2
#define PLT1_VOL_UP (PLT_HID_1_0_PAGE | PLT_VOL_UP)
#define PLT1_VOL_DOWN (PLT_HID_1_0_PAGE | PLT_VOL_DOWN)
#define PLT2_VOL_UP (PLT_HID_2_0_PAGE | PLT_VOL_UP)
#define PLT2_VOL_DOWN (PLT_HID_2_0_PAGE | PLT_VOL_DOWN)
#define PLT_DA60 0xda60
#define PLT_BT300_MIN 0x0413
#define PLT_BT300_MAX 0x0418
#define PLT_ALLOW_CONSUMER (field->application == HID_CP_CONSUMERCONTROL && \
(usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER)
static int plantronics_input_mapping(struct hid_device *hdev, static int plantronics_input_mapping(struct hid_device *hdev,
struct hid_input *hi, struct hid_input *hi,
struct hid_field *field, struct hid_field *field,
struct hid_usage *usage, struct hid_usage *usage,
unsigned long **bit, int *max) unsigned long **bit, int *max)
{ {
if (field->application == HID_CP_CONSUMERCONTROL unsigned short mapped_key;
&& (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) { unsigned long plt_type = (unsigned long)hid_get_drvdata(hdev);
hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n",
usage->hid, field->application); /* handle volume up/down mapping */
return 0; /* non-standard types or multi-HID interfaces - plt_type is PID */
if (!(plt_type & HID_USAGE_PAGE)) {
switch (plt_type) {
case PLT_DA60:
if (PLT_ALLOW_CONSUMER)
goto defaulted;
goto ignored;
default:
if (PLT_ALLOW_CONSUMER)
goto defaulted;
}
}
/* handle standard types - plt_type is 0xffa0uuuu or 0xffa2uuuu */
/* 'basic telephony compliant' - allow default consumer page map */
else if ((plt_type & HID_USAGE) >= PLT_BASIC_TELEPHONY &&
(plt_type & HID_USAGE) != PLT_BASIC_EXCEPTION) {
if (PLT_ALLOW_CONSUMER)
goto defaulted;
}
/* not 'basic telephony' - apply legacy mapping */
/* only map if the field is in the device's primary vendor page */
else if (!((field->application ^ plt_type) & HID_USAGE_PAGE)) {
switch (usage->hid) {
case PLT1_VOL_UP:
case PLT2_VOL_UP:
mapped_key = KEY_VOLUMEUP;
goto mapped;
case PLT1_VOL_DOWN:
case PLT2_VOL_DOWN:
mapped_key = KEY_VOLUMEDOWN;
goto mapped;
}
} }
hid_dbg(hdev, "usage: %08x (appl: %08x) - ignored\n", /*
usage->hid, field->application); * Future mapping of call control or other usages,
* if and when keys are defined would go here
* otherwise, ignore everything else that was not mapped
*/
ignored:
return -1; return -1;
defaulted:
hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n",
usage->hid, field->application);
return 0;
mapped:
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, mapped_key);
hid_dbg(hdev, "usage: %08x (appl: %08x) - mapped to key %d\n",
usage->hid, field->application, mapped_key);
return 1;
}
static unsigned long plantronics_device_type(struct hid_device *hdev)
{
unsigned i, col_page;
unsigned long plt_type = hdev->product;
/* multi-HID interfaces? - plt_type is PID */
if (plt_type >= PLT_BT300_MIN && plt_type <= PLT_BT300_MAX)
goto exit;
/* determine primary vendor page */
for (i = 0; i < hdev->maxcollection; i++) {
col_page = hdev->collection[i].usage & HID_USAGE_PAGE;
if (col_page == PLT_HID_2_0_PAGE) {
plt_type = hdev->collection[i].usage;
break;
}
if (col_page == PLT_HID_1_0_PAGE)
plt_type = hdev->collection[i].usage;
}
exit:
hid_dbg(hdev, "plt_type decoded as: %08lx\n", plt_type);
return plt_type;
}
static int plantronics_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
int ret;
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
goto err;
}
hid_set_drvdata(hdev, (void *)plantronics_device_type(hdev));
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT |
HID_CONNECT_HIDINPUT_FORCE | HID_CONNECT_HIDDEV_FORCE);
if (ret)
hid_err(hdev, "hw start failed\n");
err:
return ret;
} }
static const struct hid_device_id plantronics_devices[] = { static const struct hid_device_id plantronics_devices[] = {
@ -46,6 +161,7 @@ static struct hid_driver plantronics_driver = {
.name = "plantronics", .name = "plantronics",
.id_table = plantronics_devices, .id_table = plantronics_devices,
.input_mapping = plantronics_input_mapping, .input_mapping = plantronics_input_mapping,
.probe = plantronics_probe,
}; };
module_hid_driver(plantronics_driver); module_hid_driver(plantronics_driver);

View file

@ -395,11 +395,10 @@ static int pcmidi_handle_report4(struct pcmidi_snd *pm, u8 *data)
/* break keys */ /* break keys */
for (bit_index = 0; bit_index < 24; bit_index++) { for (bit_index = 0; bit_index < 24; bit_index++) {
key = pm->last_key[bit_index];
if (!((0x01 << bit_index) & bit_mask)) { if (!((0x01 << bit_index) & bit_mask)) {
input_event(pm->input_ep82, EV_KEY, input_event(pm->input_ep82, EV_KEY,
pm->last_key[bit_index], 0); pm->last_key[bit_index], 0);
pm->last_key[bit_index] = 0; pm->last_key[bit_index] = 0;
} }
} }

View file

@ -29,9 +29,9 @@
#define RMI_SET_RMI_MODE_REPORT_ID 0x0f /* Feature Report */ #define RMI_SET_RMI_MODE_REPORT_ID 0x0f /* Feature Report */
/* flags */ /* flags */
#define RMI_READ_REQUEST_PENDING BIT(0) #define RMI_READ_REQUEST_PENDING 0
#define RMI_READ_DATA_PENDING BIT(1) #define RMI_READ_DATA_PENDING 1
#define RMI_STARTED BIT(2) #define RMI_STARTED 2
/* device flags */ /* device flags */
#define RMI_DEVICE BIT(0) #define RMI_DEVICE BIT(0)
@ -1013,6 +1013,7 @@ static int rmi_populate_f30(struct hid_device *hdev)
static int rmi_populate(struct hid_device *hdev) static int rmi_populate(struct hid_device *hdev)
{ {
struct rmi_data *data = hid_get_drvdata(hdev);
int ret; int ret;
ret = rmi_scan_pdt(hdev); ret = rmi_scan_pdt(hdev);
@ -1033,9 +1034,11 @@ static int rmi_populate(struct hid_device *hdev)
return ret; return ret;
} }
ret = rmi_populate_f30(hdev); if (!(data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)) {
if (ret) ret = rmi_populate_f30(hdev);
hid_warn(hdev, "Error while initializing F30 (%d).\n", ret); if (ret)
hid_warn(hdev, "Error while initializing F30 (%d).\n", ret);
}
return 0; return 0;
} }

View file

@ -166,6 +166,9 @@ static const struct hid_device_id sjoy_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD), { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD),
.driver_data = HID_QUIRK_MULTI_INPUT | .driver_data = HID_QUIRK_MULTI_INPUT |
HID_QUIRK_SKIP_OUTPUT_REPORTS }, HID_QUIRK_SKIP_OUTPUT_REPORTS },
{ HID_USB_DEVICE(USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII),
.driver_data = HID_QUIRK_MULTI_INPUT |
HID_QUIRK_SKIP_OUTPUT_REPORTS },
{ } { }
}; };
MODULE_DEVICE_TABLE(hid, sjoy_devices); MODULE_DEVICE_TABLE(hid, sjoy_devices);

View file

@ -46,20 +46,37 @@
#define PS3REMOTE BIT(4) #define PS3REMOTE BIT(4)
#define DUALSHOCK4_CONTROLLER_USB BIT(5) #define DUALSHOCK4_CONTROLLER_USB BIT(5)
#define DUALSHOCK4_CONTROLLER_BT BIT(6) #define DUALSHOCK4_CONTROLLER_BT BIT(6)
#define MOTION_CONTROLLER_USB BIT(7)
#define MOTION_CONTROLLER_BT BIT(8)
#define NAVIGATION_CONTROLLER_USB BIT(9)
#define NAVIGATION_CONTROLLER_BT BIT(10)
#define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
#define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
#define NAVIGATION_CONTROLLER (NAVIGATION_CONTROLLER_USB |\
NAVIGATION_CONTROLLER_BT)
#define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\ #define DUALSHOCK4_CONTROLLER (DUALSHOCK4_CONTROLLER_USB |\
DUALSHOCK4_CONTROLLER_BT) DUALSHOCK4_CONTROLLER_BT)
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
DUALSHOCK4_CONTROLLER) DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER |\
#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) NAVIGATION_CONTROLLER)
#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
MOTION_CONTROLLER_BT | NAVIGATION_CONTROLLER)
#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
MOTION_CONTROLLER)
#define MAX_LEDS 4 #define MAX_LEDS 4
/*
* The Sixaxis reports both digital and analog values for each button on the
* controller except for Start, Select and the PS button. The controller ends
* up reporting 27 axes which causes them to spill over into the multi-touch
* axis values. Additionally, the controller only has 20 actual, physical axes
* so there are several unused axes in between the used ones.
*/
static __u8 sixaxis_rdesc[] = { static __u8 sixaxis_rdesc[] = {
0x05, 0x01, /* Usage Page (Desktop), */ 0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x04, /* Usage (Joystik), */ 0x09, 0x04, /* Usage (Joystick), */
0xA1, 0x01, /* Collection (Application), */ 0xA1, 0x01, /* Collection (Application), */
0xA1, 0x02, /* Collection (Logical), */ 0xA1, 0x02, /* Collection (Logical), */
0x85, 0x01, /* Report ID (1), */ 0x85, 0x01, /* Report ID (1), */
@ -134,6 +151,186 @@ static __u8 sixaxis_rdesc[] = {
0xC0 /* End Collection */ 0xC0 /* End Collection */
}; };
/* PS/3 Motion controller */
static __u8 motion_rdesc[] = {
0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x04, /* Usage (Joystick), */
0xA1, 0x01, /* Collection (Application), */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0x01, /* Report ID (1), */
0x75, 0x01, /* Report Size (1), */
0x95, 0x15, /* Report Count (21), */
0x15, 0x00, /* Logical Minimum (0), */
0x25, 0x01, /* Logical Maximum (1), */
0x35, 0x00, /* Physical Minimum (0), */
0x45, 0x01, /* Physical Maximum (1), */
0x05, 0x09, /* Usage Page (Button), */
0x19, 0x01, /* Usage Minimum (01h), */
0x29, 0x15, /* Usage Maximum (15h), */
0x81, 0x02, /* Input (Variable), * Buttons */
0x95, 0x0B, /* Report Count (11), */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x81, 0x03, /* Input (Constant, Variable), * Padding */
0x15, 0x00, /* Logical Minimum (0), */
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
0x05, 0x01, /* Usage Page (Desktop), */
0xA1, 0x00, /* Collection (Physical), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x01, /* Report Count (1), */
0x35, 0x00, /* Physical Minimum (0), */
0x46, 0xFF, 0x00, /* Physical Maximum (255), */
0x09, 0x30, /* Usage (X), */
0x81, 0x02, /* Input (Variable), * Trigger */
0xC0, /* End Collection, */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x07, /* Report Count (7), * skip 7 bytes */
0x81, 0x02, /* Input (Variable), */
0x05, 0x01, /* Usage Page (Desktop), */
0x75, 0x10, /* Report Size (16), */
0x46, 0xFF, 0xFF, /* Physical Maximum (65535), */
0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum (65535), */
0x95, 0x03, /* Report Count (3), * 3x Accels */
0x09, 0x33, /* Usage (rX), */
0x09, 0x34, /* Usage (rY), */
0x09, 0x35, /* Usage (rZ), */
0x81, 0x02, /* Input (Variable), */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x95, 0x03, /* Report Count (3), * Skip Accels 2nd frame */
0x81, 0x02, /* Input (Variable), */
0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x01, /* Usage (Pointer), */
0x95, 0x03, /* Report Count (3), * 3x Gyros */
0x81, 0x02, /* Input (Variable), */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x95, 0x03, /* Report Count (3), * Skip Gyros 2nd frame */
0x81, 0x02, /* Input (Variable), */
0x75, 0x0C, /* Report Size (12), */
0x46, 0xFF, 0x0F, /* Physical Maximum (4095), */
0x26, 0xFF, 0x0F, /* Logical Maximum (4095), */
0x95, 0x04, /* Report Count (4), * Skip Temp and Magnetometers */
0x81, 0x02, /* Input (Variable), */
0x75, 0x08, /* Report Size (8), */
0x46, 0xFF, 0x00, /* Physical Maximum (255), */
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
0x95, 0x06, /* Report Count (6), * Skip Timestamp and Extension Bytes */
0x81, 0x02, /* Input (Variable), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0x91, 0x02, /* Output (Variable), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0x02, /* Report ID (2), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0xEE, /* Report ID (238), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0xEF, /* Report ID (239), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xC0 /* End Collection */
};
/* PS/3 Navigation controller */
static __u8 navigation_rdesc[] = {
0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x04, /* Usage (Joystik), */
0xA1, 0x01, /* Collection (Application), */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0x01, /* Report ID (1), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x01, /* Report Count (1), */
0x15, 0x00, /* Logical Minimum (0), */
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
0x81, 0x03, /* Input (Constant, Variable), */
0x75, 0x01, /* Report Size (1), */
0x95, 0x13, /* Report Count (19), */
0x15, 0x00, /* Logical Minimum (0), */
0x25, 0x01, /* Logical Maximum (1), */
0x35, 0x00, /* Physical Minimum (0), */
0x45, 0x01, /* Physical Maximum (1), */
0x05, 0x09, /* Usage Page (Button), */
0x19, 0x01, /* Usage Minimum (01h), */
0x29, 0x13, /* Usage Maximum (13h), */
0x81, 0x02, /* Input (Variable), */
0x75, 0x01, /* Report Size (1), */
0x95, 0x0D, /* Report Count (13), */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x81, 0x03, /* Input (Constant, Variable), */
0x15, 0x00, /* Logical Minimum (0), */
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x01, /* Usage (Pointer), */
0xA1, 0x00, /* Collection (Physical), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x02, /* Report Count (2), */
0x35, 0x00, /* Physical Minimum (0), */
0x46, 0xFF, 0x00, /* Physical Maximum (255), */
0x09, 0x30, /* Usage (X), */
0x09, 0x31, /* Usage (Y), */
0x81, 0x02, /* Input (Variable), */
0xC0, /* End Collection, */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x95, 0x06, /* Report Count (6), */
0x81, 0x03, /* Input (Constant, Variable), */
0x05, 0x01, /* Usage Page (Desktop), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x05, /* Report Count (5), */
0x09, 0x01, /* Usage (Pointer), */
0x81, 0x02, /* Input (Variable), */
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
0x95, 0x20, /* Report Count (26), */
0x81, 0x02, /* Input (Variable), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0x91, 0x02, /* Output (Variable), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0x02, /* Report ID (2), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0xEE, /* Report ID (238), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xA1, 0x02, /* Collection (Logical), */
0x85, 0xEF, /* Report ID (239), */
0x75, 0x08, /* Report Size (8), */
0x95, 0x30, /* Report Count (48), */
0x09, 0x01, /* Usage (Pointer), */
0xB1, 0x02, /* Feature (Variable), */
0xC0, /* End Collection, */
0xC0 /* End Collection */
};
/* /*
* The default descriptor doesn't provide mapping for the accelerometers * The default descriptor doesn't provide mapping for the accelerometers
* or orientation sensors. This fixed descriptor maps the accelerometers * or orientation sensors. This fixed descriptor maps the accelerometers
@ -798,12 +995,20 @@ union sixaxis_output_report_01 {
__u8 buf[36]; __u8 buf[36];
}; };
struct motion_output_report_02 {
u8 type, zero;
u8 r, g, b;
u8 zero2;
u8 rumble;
};
#define DS4_REPORT_0x02_SIZE 37 #define DS4_REPORT_0x02_SIZE 37
#define DS4_REPORT_0x05_SIZE 32 #define DS4_REPORT_0x05_SIZE 32
#define DS4_REPORT_0x11_SIZE 78 #define DS4_REPORT_0x11_SIZE 78
#define DS4_REPORT_0x81_SIZE 7 #define DS4_REPORT_0x81_SIZE 7
#define SIXAXIS_REPORT_0xF2_SIZE 17 #define SIXAXIS_REPORT_0xF2_SIZE 17
#define SIXAXIS_REPORT_0xF5_SIZE 8 #define SIXAXIS_REPORT_0xF5_SIZE 8
#define MOTION_REPORT_0x02_SIZE 49
static DEFINE_SPINLOCK(sony_dev_list_lock); static DEFINE_SPINLOCK(sony_dev_list_lock);
static LIST_HEAD(sony_device_list); static LIST_HEAD(sony_device_list);
@ -844,6 +1049,20 @@ static __u8 *sixaxis_fixup(struct hid_device *hdev, __u8 *rdesc,
return sixaxis_rdesc; return sixaxis_rdesc;
} }
static u8 *motion_fixup(struct hid_device *hdev, u8 *rdesc,
unsigned int *rsize)
{
*rsize = sizeof(motion_rdesc);
return motion_rdesc;
}
static u8 *navigation_fixup(struct hid_device *hdev, u8 *rdesc,
unsigned int *rsize)
{
*rsize = sizeof(navigation_rdesc);
return navigation_rdesc;
}
static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc, static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize) unsigned int *rsize)
{ {
@ -924,6 +1143,12 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
if (sc->quirks & SIXAXIS_CONTROLLER) if (sc->quirks & SIXAXIS_CONTROLLER)
return sixaxis_fixup(hdev, rdesc, rsize); return sixaxis_fixup(hdev, rdesc, rsize);
if (sc->quirks & MOTION_CONTROLLER)
return motion_fixup(hdev, rdesc, rsize);
if (sc->quirks & NAVIGATION_CONTROLLER)
return navigation_fixup(hdev, rdesc, rsize);
if (sc->quirks & PS3REMOTE) if (sc->quirks & PS3REMOTE)
return ps3remote_fixup(hdev, rdesc, rsize); return ps3remote_fixup(hdev, rdesc, rsize);
@ -934,6 +1159,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
{ {
static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 }; static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
unsigned long flags; unsigned long flags;
int offset;
__u8 cable_state, battery_capacity, battery_charging; __u8 cable_state, battery_capacity, battery_charging;
/* /*
@ -942,12 +1168,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
* It does not report the actual level while charging so it * It does not report the actual level while charging so it
* is set to 100% while charging is in progress. * is set to 100% while charging is in progress.
*/ */
if (rd[30] >= 0xee) { offset = (sc->quirks & MOTION_CONTROLLER) ? 12 : 30;
if (rd[offset] >= 0xee) {
battery_capacity = 100; battery_capacity = 100;
battery_charging = !(rd[30] & 0x01); battery_charging = !(rd[offset] & 0x01);
cable_state = 1; cable_state = 1;
} else { } else {
__u8 index = rd[30] <= 5 ? rd[30] : 5; __u8 index = rd[offset] <= 5 ? rd[offset] : 5;
battery_capacity = sixaxis_battery_capacity[index]; battery_capacity = sixaxis_battery_capacity[index];
battery_charging = 0; battery_charging = 0;
cable_state = 0; cable_state = 0;
@ -1048,6 +1276,11 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
swap(rd[47], rd[48]); swap(rd[47], rd[48]);
sixaxis_parse_report(sc, rd, size); sixaxis_parse_report(sc, rd, size);
} else if ((sc->quirks & MOTION_CONTROLLER_BT) && rd[0] == 0x01 && size == 49) {
sixaxis_parse_report(sc, rd, size);
} else if ((sc->quirks & NAVIGATION_CONTROLLER) && rd[0] == 0x01 &&
size == 49) {
sixaxis_parse_report(sc, rd, size);
} else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 && } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
&& rd[0] == 0x11 && size == 78)) { && rd[0] == 0x11 && size == 78)) {
@ -1208,7 +1441,7 @@ static int dualshock4_set_operational_bt(struct hid_device *hdev)
return ret; return ret;
} }
static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS]) static void sixaxis_set_leds_from_id(struct sony_sc *sc)
{ {
static const __u8 sixaxis_leds[10][4] = { static const __u8 sixaxis_leds[10][4] = {
{ 0x01, 0x00, 0x00, 0x00 }, { 0x01, 0x00, 0x00, 0x00 },
@ -1223,16 +1456,18 @@ static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS])
{ 0x01, 0x01, 0x01, 0x01 } { 0x01, 0x01, 0x01, 0x01 }
}; };
BUG_ON(MAX_LEDS < ARRAY_SIZE(sixaxis_leds[0])); int id = sc->device_id;
BUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(sixaxis_leds[0]));
if (id < 0) if (id < 0)
return; return;
id %= 10; id %= 10;
memcpy(values, sixaxis_leds[id], sizeof(sixaxis_leds[id])); memcpy(sc->led_state, sixaxis_leds[id], sizeof(sixaxis_leds[id]));
} }
static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS]) static void dualshock4_set_leds_from_id(struct sony_sc *sc)
{ {
/* The first 4 color/index entries match what the PS4 assigns */ /* The first 4 color/index entries match what the PS4 assigns */
static const __u8 color_code[7][3] = { static const __u8 color_code[7][3] = {
@ -1245,46 +1480,44 @@ static void dualshock4_set_leds_from_id(int id, __u8 values[MAX_LEDS])
/* White */ { 0x01, 0x01, 0x01 } /* White */ { 0x01, 0x01, 0x01 }
}; };
BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0])); int id = sc->device_id;
BUILD_BUG_ON(MAX_LEDS < ARRAY_SIZE(color_code[0]));
if (id < 0) if (id < 0)
return; return;
id %= 7; id %= 7;
memcpy(values, color_code[id], sizeof(color_code[id])); memcpy(sc->led_state, color_code[id], sizeof(color_code[id]));
} }
static void buzz_set_leds(struct hid_device *hdev, const __u8 *leds) static void buzz_set_leds(struct sony_sc *sc)
{ {
struct hid_device *hdev = sc->hdev;
struct list_head *report_list = struct list_head *report_list =
&hdev->report_enum[HID_OUTPUT_REPORT].report_list; &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
struct hid_report *report = list_entry(report_list->next, struct hid_report *report = list_entry(report_list->next,
struct hid_report, list); struct hid_report, list);
__s32 *value = report->field[0]->value; __s32 *value = report->field[0]->value;
BUILD_BUG_ON(MAX_LEDS < 4);
value[0] = 0x00; value[0] = 0x00;
value[1] = leds[0] ? 0xff : 0x00; value[1] = sc->led_state[0] ? 0xff : 0x00;
value[2] = leds[1] ? 0xff : 0x00; value[2] = sc->led_state[1] ? 0xff : 0x00;
value[3] = leds[2] ? 0xff : 0x00; value[3] = sc->led_state[2] ? 0xff : 0x00;
value[4] = leds[3] ? 0xff : 0x00; value[4] = sc->led_state[3] ? 0xff : 0x00;
value[5] = 0x00; value[5] = 0x00;
value[6] = 0x00; value[6] = 0x00;
hid_hw_request(hdev, report, HID_REQ_SET_REPORT); hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
} }
static void sony_set_leds(struct sony_sc *sc, const __u8 *leds, int count) static void sony_set_leds(struct sony_sc *sc)
{ {
int n; if (!(sc->quirks & BUZZ_CONTROLLER))
BUG_ON(count > MAX_LEDS);
if (sc->quirks & BUZZ_CONTROLLER && count == 4) {
buzz_set_leds(sc->hdev, leds);
} else {
for (n = 0; n < count; n++)
sc->led_state[n] = leds[n];
schedule_work(&sc->state_worker); schedule_work(&sc->state_worker);
} else
buzz_set_leds(sc);
} }
static void sony_led_set_brightness(struct led_classdev *led, static void sony_led_set_brightness(struct led_classdev *led,
@ -1324,8 +1557,7 @@ static void sony_led_set_brightness(struct led_classdev *led,
drv_data->led_delay_on[n] = 0; drv_data->led_delay_on[n] = 0;
drv_data->led_delay_off[n] = 0; drv_data->led_delay_off[n] = 0;
sony_set_leds(drv_data, drv_data->led_state, sony_set_leds(drv_data);
drv_data->led_count);
break; break;
} }
} }
@ -1431,7 +1663,6 @@ static int sony_leds_init(struct sony_sc *sc)
const char *name_fmt; const char *name_fmt;
static const char * const ds4_name_str[] = { "red", "green", "blue", static const char * const ds4_name_str[] = { "red", "green", "blue",
"global" }; "global" };
__u8 initial_values[MAX_LEDS] = { 0 };
__u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 }; __u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 };
__u8 use_hw_blink[MAX_LEDS] = { 0 }; __u8 use_hw_blink[MAX_LEDS] = { 0 };
@ -1446,16 +1677,31 @@ static int sony_leds_init(struct sony_sc *sc)
if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7)) if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7))
return -ENODEV; return -ENODEV;
} else if (sc->quirks & DUALSHOCK4_CONTROLLER) { } else if (sc->quirks & DUALSHOCK4_CONTROLLER) {
dualshock4_set_leds_from_id(sc->device_id, initial_values); dualshock4_set_leds_from_id(sc);
initial_values[3] = 1; sc->led_state[3] = 1;
sc->led_count = 4; sc->led_count = 4;
memset(max_brightness, 255, 3); memset(max_brightness, 255, 3);
use_hw_blink[3] = 1; use_hw_blink[3] = 1;
use_ds4_names = 1; use_ds4_names = 1;
name_len = 0; name_len = 0;
name_fmt = "%s:%s"; name_fmt = "%s:%s";
} else if (sc->quirks & MOTION_CONTROLLER) {
sc->led_count = 3;
memset(max_brightness, 255, 3);
use_ds4_names = 1;
name_len = 0;
name_fmt = "%s:%s";
} else if (sc->quirks & NAVIGATION_CONTROLLER) {
static const __u8 navigation_leds[4] = {0x01, 0x00, 0x00, 0x00};
memcpy(sc->led_state, navigation_leds, sizeof(navigation_leds));
sc->led_count = 1;
memset(use_hw_blink, 1, 4);
use_ds4_names = 0;
name_len = strlen("::sony#");
name_fmt = "%s::sony%d";
} else { } else {
sixaxis_set_leds_from_id(sc->device_id, initial_values); sixaxis_set_leds_from_id(sc);
sc->led_count = 4; sc->led_count = 4;
memset(use_hw_blink, 1, 4); memset(use_hw_blink, 1, 4);
use_ds4_names = 0; use_ds4_names = 0;
@ -1468,7 +1714,7 @@ static int sony_leds_init(struct sony_sc *sc)
* only relevant if the driver is loaded after somebody actively set the * only relevant if the driver is loaded after somebody actively set the
* LEDs to on * LEDs to on
*/ */
sony_set_leds(sc, initial_values, sc->led_count); sony_set_leds(sc);
name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1; name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1;
@ -1491,7 +1737,7 @@ static int sony_leds_init(struct sony_sc *sc)
else else
snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1); snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1);
led->name = name; led->name = name;
led->brightness = initial_values[n]; led->brightness = sc->led_state[n];
led->max_brightness = max_brightness[n]; led->max_brightness = max_brightness[n];
led->brightness_get = sony_led_get_brightness; led->brightness_get = sony_led_get_brightness;
led->brightness_set = sony_led_set_brightness; led->brightness_set = sony_led_set_brightness;
@ -1622,9 +1868,31 @@ static void dualshock4_state_worker(struct work_struct *work)
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
} }
static void motion_state_worker(struct work_struct *work)
{
struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
struct hid_device *hdev = sc->hdev;
struct motion_output_report_02 *report =
(struct motion_output_report_02 *)sc->output_report_dmabuf;
memset(report, 0, MOTION_REPORT_0x02_SIZE);
report->type = 0x02; /* set leds */
report->r = sc->led_state[0];
report->g = sc->led_state[1];
report->b = sc->led_state[2];
#ifdef CONFIG_SONY_FF
report->rumble = max(sc->right, sc->left);
#endif
hid_hw_output_report(hdev, (__u8 *)report, MOTION_REPORT_0x02_SIZE);
}
static int sony_allocate_output_report(struct sony_sc *sc) static int sony_allocate_output_report(struct sony_sc *sc)
{ {
if (sc->quirks & SIXAXIS_CONTROLLER) if ((sc->quirks & SIXAXIS_CONTROLLER) ||
(sc->quirks & NAVIGATION_CONTROLLER))
sc->output_report_dmabuf = sc->output_report_dmabuf =
kmalloc(sizeof(union sixaxis_output_report_01), kmalloc(sizeof(union sixaxis_output_report_01),
GFP_KERNEL); GFP_KERNEL);
@ -1634,6 +1902,9 @@ static int sony_allocate_output_report(struct sony_sc *sc)
else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB)
sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE, sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE,
GFP_KERNEL); GFP_KERNEL);
else if (sc->quirks & MOTION_CONTROLLER)
sc->output_report_dmabuf = kmalloc(MOTION_REPORT_0x02_SIZE,
GFP_KERNEL);
else else
return 0; return 0;
@ -1839,6 +2110,8 @@ static int sony_check_add(struct sony_sc *sc)
int n, ret; int n, ret;
if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) || if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||
(sc->quirks & MOTION_CONTROLLER_BT) ||
(sc->quirks & NAVIGATION_CONTROLLER_BT) ||
(sc->quirks & SIXAXIS_CONTROLLER_BT)) { (sc->quirks & SIXAXIS_CONTROLLER_BT)) {
/* /*
* sony_get_bt_devaddr() attempts to parse the Bluetooth MAC * sony_get_bt_devaddr() attempts to parse the Bluetooth MAC
@ -1871,7 +2144,8 @@ static int sony_check_add(struct sony_sc *sc)
} }
memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address)); memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));
} else if (sc->quirks & SIXAXIS_CONTROLLER_USB) { } else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||
(sc->quirks & NAVIGATION_CONTROLLER_USB)) {
buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL); buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
@ -1993,19 +2267,20 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
return ret; return ret;
} }
ret = sony_allocate_output_report(sc);
if (ret < 0) {
hid_err(hdev, "failed to allocate the output report buffer\n");
goto err_stop;
}
ret = sony_set_device_id(sc); ret = sony_set_device_id(sc);
if (ret < 0) { if (ret < 0) {
hid_err(hdev, "failed to allocate the device id\n"); hid_err(hdev, "failed to allocate the device id\n");
goto err_stop; goto err_stop;
} }
if (sc->quirks & SIXAXIS_CONTROLLER_USB) { ret = sony_allocate_output_report(sc);
if (ret < 0) {
hid_err(hdev, "failed to allocate the output report buffer\n");
goto err_stop;
}
if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||
(sc->quirks & NAVIGATION_CONTROLLER_USB)) {
/* /*
* The Sony Sixaxis does not handle HID Output Reports on the * The Sony Sixaxis does not handle HID Output Reports on the
* Interrupt EP like it could, so we need to force HID Output * Interrupt EP like it could, so we need to force HID Output
@ -2020,7 +2295,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID;
ret = sixaxis_set_operational_usb(hdev); ret = sixaxis_set_operational_usb(hdev);
sony_init_work(sc, sixaxis_state_worker); sony_init_work(sc, sixaxis_state_worker);
} else if (sc->quirks & SIXAXIS_CONTROLLER_BT) { } else if ((sc->quirks & SIXAXIS_CONTROLLER_BT) ||
(sc->quirks & NAVIGATION_CONTROLLER_BT)) {
/* /*
* The Sixaxis wants output reports sent on the ctrl endpoint * The Sixaxis wants output reports sent on the ctrl endpoint
* when connected via Bluetooth. * when connected via Bluetooth.
@ -2043,6 +2319,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
} }
sony_init_work(sc, dualshock4_state_worker); sony_init_work(sc, dualshock4_state_worker);
} else if (sc->quirks & MOTION_CONTROLLER) {
sony_init_work(sc, motion_state_worker);
} else { } else {
ret = 0; ret = 0;
} }
@ -2122,7 +2400,13 @@ static const struct hid_device_id sony_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
.driver_data = SIXAXIS_CONTROLLER_USB }, .driver_data = SIXAXIS_CONTROLLER_USB },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER), { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
.driver_data = SIXAXIS_CONTROLLER_USB }, .driver_data = NAVIGATION_CONTROLLER_USB },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
.driver_data = NAVIGATION_CONTROLLER_BT },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER),
.driver_data = MOTION_CONTROLLER_USB },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER),
.driver_data = MOTION_CONTROLLER_BT },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
.driver_data = SIXAXIS_CONTROLLER_BT }, .driver_data = SIXAXIS_CONTROLLER_BT },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE), { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),

View file

@ -42,9 +42,9 @@
#include <linux/i2c/i2c-hid.h> #include <linux/i2c/i2c-hid.h>
/* flags */ /* flags */
#define I2C_HID_STARTED (1 << 0) #define I2C_HID_STARTED 0
#define I2C_HID_RESET_PENDING (1 << 1) #define I2C_HID_RESET_PENDING 1
#define I2C_HID_READ_PENDING (1 << 2) #define I2C_HID_READ_PENDING 2
#define I2C_HID_PWR_ON 0x00 #define I2C_HID_PWR_ON 0x00
#define I2C_HID_PWR_SLEEP 0x01 #define I2C_HID_PWR_SLEEP 0x01
@ -1019,7 +1019,6 @@ static int i2c_hid_probe(struct i2c_client *client,
hid->driver_data = client; hid->driver_data = client;
hid->ll_driver = &i2c_hid_ll_driver; hid->ll_driver = &i2c_hid_ll_driver;
hid->dev.parent = &client->dev; hid->dev.parent = &client->dev;
ACPI_COMPANION_SET(&hid->dev, ACPI_COMPANION(&client->dev));
hid->bus = BUS_I2C; hid->bus = BUS_I2C;
hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); hid->version = le16_to_cpu(ihid->hdesc.bcdVersion);
hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);

View file

@ -52,7 +52,6 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH_2968, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH_2968, HID_QUIRK_MULTI_INPUT },
{ USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT },
{ USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
{ USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
{ USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT },
{ USB_VENDOR_ID_AIREN, USB_DEVICE_ID_AIREN_SLIMPLUS, HID_QUIRK_NOGET }, { USB_VENDOR_ID_AIREN, USB_DEVICE_ID_AIREN_SLIMPLUS, HID_QUIRK_NOGET },
@ -70,6 +69,7 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL },
{ USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL },
@ -89,6 +89,7 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS },
@ -141,6 +142,9 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP_V103, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP_V103, HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096, HID_QUIRK_NO_INIT_INPUT_REPORTS }, { USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096, HID_QUIRK_NO_INIT_INPUT_REPORTS },
{ USB_VENDOR_ID_MULTIPLE_1781, USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD, HID_QUIRK_MULTI_INPUT },
{ USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_2NES2SNES, HID_QUIRK_MULTI_INPUT },
{ USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_4NES4SNES, HID_QUIRK_MULTI_INPUT },
{ 0, 0 } { 0, 0 }
}; };

View file

@ -134,8 +134,10 @@ static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
extern const struct hid_device_id wacom_ids[]; extern const struct hid_device_id wacom_ids[];
void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
void wacom_setup_device_quirks(struct wacom_features *features); void wacom_setup_device_quirks(struct wacom *wacom);
int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac);
int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac); struct wacom_wac *wacom_wac);
int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac); struct wacom_wac *wacom_wac);

View file

@ -35,7 +35,11 @@ static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
do { do {
retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
HID_REQ_GET_REPORT); HID_REQ_GET_REPORT);
} while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries);
if (retval < 0)
hid_err(hdev, "wacom_get_report: ran out of retries "
"(last error = %d)\n", retval);
return retval; return retval;
} }
@ -48,7 +52,11 @@ static int wacom_set_report(struct hid_device *hdev, u8 type, u8 *buf,
do { do {
retval = hid_hw_raw_request(hdev, buf[0], buf, size, type, retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
HID_REQ_SET_REPORT); HID_REQ_SET_REPORT);
} while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries); } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries);
if (retval < 0)
hid_err(hdev, "wacom_set_report: ran out of retries "
"(last error = %d)\n", retval);
return retval; return retval;
} }
@ -117,9 +125,16 @@ static void wacom_feature_mapping(struct hid_device *hdev,
break; break;
data[0] = field->report->id; data[0] = field->report->id;
ret = wacom_get_report(hdev, HID_FEATURE_REPORT, ret = wacom_get_report(hdev, HID_FEATURE_REPORT,
data, 2, 0); data, 2, WAC_CMD_RETRIES);
if (ret == 2) if (ret == 2) {
features->touch_max = data[1]; features->touch_max = data[1];
} else {
features->touch_max = 16;
hid_warn(hdev, "wacom_feature_mapping: "
"could not get HID_DG_CONTACTMAX, "
"defaulting to %d\n",
features->touch_max);
}
kfree(data); kfree(data);
} }
break; break;
@ -181,7 +196,11 @@ static void wacom_usage_mapping(struct hid_device *hdev,
* X/Y values and some cases of invalid Digitizer X/Y * X/Y values and some cases of invalid Digitizer X/Y
* values commonly reported. * values commonly reported.
*/ */
if (!pen && !finger) if (pen)
features->device_type |= WACOM_DEVICETYPE_PEN;
else if (finger)
features->device_type |= WACOM_DEVICETYPE_TOUCH;
else
return; return;
/* /*
@ -198,14 +217,11 @@ static void wacom_usage_mapping(struct hid_device *hdev,
case HID_GD_X: case HID_GD_X:
features->x_max = field->logical_maximum; features->x_max = field->logical_maximum;
if (finger) { if (finger) {
features->device_type = BTN_TOOL_FINGER;
features->x_phy = field->physical_maximum; features->x_phy = field->physical_maximum;
if (features->type != BAMBOO_PT) { if (features->type != BAMBOO_PT) {
features->unit = field->unit; features->unit = field->unit;
features->unitExpo = field->unit_exponent; features->unitExpo = field->unit_exponent;
} }
} else {
features->device_type = BTN_TOOL_PEN;
} }
break; break;
case HID_GD_Y: case HID_GD_Y:
@ -237,7 +253,7 @@ static void wacom_post_parse_hid(struct hid_device *hdev,
if (features->type == HID_GENERIC) { if (features->type == HID_GENERIC) {
/* Any last-minute generic device setup */ /* Any last-minute generic device setup */
if (features->touch_max > 1) { if (features->touch_max > 1) {
input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max, input_mt_init_slots(wacom_wac->touch_input, wacom_wac->features.touch_max,
INPUT_MT_DIRECT); INPUT_MT_DIRECT);
} }
} }
@ -395,7 +411,7 @@ static int wacom_query_tablet_data(struct hid_device *hdev,
if (features->type == HID_GENERIC) if (features->type == HID_GENERIC)
return wacom_hid_set_device_mode(hdev); 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) { if (features->type > TABLETPC) {
/* MT Tablet PC touch */ /* MT Tablet PC touch */
return wacom_set_device_mode(hdev, 3, 4, 4); return wacom_set_device_mode(hdev, 3, 4, 4);
@ -409,7 +425,7 @@ static int wacom_query_tablet_data(struct hid_device *hdev,
else if (features->type == BAMBOO_PAD) { else if (features->type == BAMBOO_PAD) {
return wacom_set_device_mode(hdev, 2, 2, 2); 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) { if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
return wacom_set_device_mode(hdev, 2, 2, 2); return wacom_set_device_mode(hdev, 2, 2, 2);
} }
@ -425,7 +441,6 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
struct usb_interface *intf = wacom->intf; struct usb_interface *intf = wacom->intf;
/* default features */ /* default features */
features->device_type = BTN_TOOL_PEN;
features->x_fuzz = 4; features->x_fuzz = 4;
features->y_fuzz = 4; features->y_fuzz = 4;
features->pressure_fuzz = 0; features->pressure_fuzz = 0;
@ -439,17 +454,13 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
*/ */
if (features->type == WIRELESS) { if (features->type == WIRELESS) {
if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { 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) { } 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; features->pktlen = WACOM_PKGLEN_BBTOUCH3;
} }
} }
/* only devices that support touch need to retrieve the info */
if (features->type < BAMBOO_PT)
return;
wacom_parse_hid(hdev, features); wacom_parse_hid(hdev, features);
} }
@ -527,9 +538,9 @@ static int wacom_add_shared_data(struct hid_device *hdev)
wacom_wac->shared = &data->shared; 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; 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; wacom_wac->shared->pen = hdev;
out: out:
@ -848,6 +859,9 @@ static int wacom_initialize_leds(struct wacom *wacom)
{ {
int error; int error;
if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD))
return 0;
/* Initialize default values */ /* Initialize default values */
switch (wacom->wacom_wac.features.type) { switch (wacom->wacom_wac.features.type) {
case INTUOS4S: case INTUOS4S:
@ -881,17 +895,14 @@ static int wacom_initialize_leds(struct wacom *wacom)
case INTUOSPS: case INTUOSPS:
case INTUOSPM: case INTUOSPM:
case INTUOSPL: case INTUOSPL:
if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) { wacom->led.select[0] = 0;
wacom->led.select[0] = 0; wacom->led.select[1] = 0;
wacom->led.select[1] = 0; wacom->led.llv = 32;
wacom->led.llv = 32; wacom->led.hlv = 0;
wacom->led.hlv = 0; wacom->led.img_lum = 0;
wacom->led.img_lum = 0;
error = sysfs_create_group(&wacom->hdev->dev.kobj, error = sysfs_create_group(&wacom->hdev->dev.kobj,
&intuos5_led_attr_group); &intuos5_led_attr_group);
} else
return 0;
break; break;
default: default:
@ -914,6 +925,9 @@ static void wacom_destroy_leds(struct wacom *wacom)
if (!wacom->led_initialized) if (!wacom->led_initialized)
return; return;
if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD))
return;
wacom->led_initialized = false; wacom->led_initialized = false;
switch (wacom->wacom_wac.features.type) { switch (wacom->wacom_wac.features.type) {
@ -937,9 +951,8 @@ static void wacom_destroy_leds(struct wacom *wacom)
case INTUOSPS: case INTUOSPS:
case INTUOSPM: case INTUOSPM:
case INTUOSPL: case INTUOSPL:
if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN) sysfs_remove_group(&wacom->hdev->dev.kobj,
sysfs_remove_group(&wacom->hdev->dev.kobj, &intuos5_led_attr_group);
&intuos5_led_attr_group);
break; break;
} }
} }
@ -1117,7 +1130,7 @@ static struct input_dev *wacom_allocate_input(struct wacom *wacom)
if (!input_dev) if (!input_dev)
return NULL; return NULL;
input_dev->name = wacom_wac->name; input_dev->name = wacom_wac->pen_name;
input_dev->phys = hdev->phys; input_dev->phys = hdev->phys;
input_dev->dev.parent = &hdev->dev; input_dev->dev.parent = &hdev->dev;
input_dev->open = wacom_open; input_dev->open = wacom_open;
@ -1136,27 +1149,33 @@ static void wacom_free_inputs(struct wacom *wacom)
{ {
struct wacom_wac *wacom_wac = &(wacom->wacom_wac); struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
if (wacom_wac->input) if (wacom_wac->pen_input)
input_free_device(wacom_wac->input); input_free_device(wacom_wac->pen_input);
if (wacom_wac->touch_input)
input_free_device(wacom_wac->touch_input);
if (wacom_wac->pad_input) if (wacom_wac->pad_input)
input_free_device(wacom_wac->pad_input); input_free_device(wacom_wac->pad_input);
wacom_wac->input = NULL; wacom_wac->pen_input = NULL;
wacom_wac->touch_input = NULL;
wacom_wac->pad_input = NULL; wacom_wac->pad_input = NULL;
} }
static int wacom_allocate_inputs(struct wacom *wacom) static int wacom_allocate_inputs(struct wacom *wacom)
{ {
struct input_dev *input_dev, *pad_input_dev; struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
struct wacom_wac *wacom_wac = &(wacom->wacom_wac); struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
input_dev = wacom_allocate_input(wacom); pen_input_dev = wacom_allocate_input(wacom);
touch_input_dev = wacom_allocate_input(wacom);
pad_input_dev = wacom_allocate_input(wacom); pad_input_dev = wacom_allocate_input(wacom);
if (!input_dev || !pad_input_dev) { if (!pen_input_dev || !touch_input_dev || !pad_input_dev) {
wacom_free_inputs(wacom); wacom_free_inputs(wacom);
return -ENOMEM; return -ENOMEM;
} }
wacom_wac->input = input_dev; wacom_wac->pen_input = pen_input_dev;
wacom_wac->touch_input = touch_input_dev;
wacom_wac->touch_input->name = wacom_wac->touch_name;
wacom_wac->pad_input = pad_input_dev; wacom_wac->pad_input = pad_input_dev;
wacom_wac->pad_input->name = wacom_wac->pad_name; wacom_wac->pad_input->name = wacom_wac->pad_name;
@ -1165,11 +1184,17 @@ static int wacom_allocate_inputs(struct wacom *wacom)
static void wacom_clean_inputs(struct wacom *wacom) static void wacom_clean_inputs(struct wacom *wacom)
{ {
if (wacom->wacom_wac.input) { if (wacom->wacom_wac.pen_input) {
if (wacom->wacom_wac.input_registered) if (wacom->wacom_wac.pen_registered)
input_unregister_device(wacom->wacom_wac.input); input_unregister_device(wacom->wacom_wac.pen_input);
else else
input_free_device(wacom->wacom_wac.input); input_free_device(wacom->wacom_wac.pen_input);
}
if (wacom->wacom_wac.touch_input) {
if (wacom->wacom_wac.touch_registered)
input_unregister_device(wacom->wacom_wac.touch_input);
else
input_free_device(wacom->wacom_wac.touch_input);
} }
if (wacom->wacom_wac.pad_input) { if (wacom->wacom_wac.pad_input) {
if (wacom->wacom_wac.pad_registered) if (wacom->wacom_wac.pad_registered)
@ -1177,29 +1202,49 @@ static void wacom_clean_inputs(struct wacom *wacom)
else else
input_free_device(wacom->wacom_wac.pad_input); input_free_device(wacom->wacom_wac.pad_input);
} }
wacom->wacom_wac.input = NULL; wacom->wacom_wac.pen_input = NULL;
wacom->wacom_wac.touch_input = NULL;
wacom->wacom_wac.pad_input = NULL; wacom->wacom_wac.pad_input = NULL;
wacom_destroy_leds(wacom); wacom_destroy_leds(wacom);
} }
static int wacom_register_inputs(struct wacom *wacom) static int wacom_register_inputs(struct wacom *wacom)
{ {
struct input_dev *input_dev, *pad_input_dev; struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
struct wacom_wac *wacom_wac = &(wacom->wacom_wac); struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
int error; int error = 0;
input_dev = wacom_wac->input; pen_input_dev = wacom_wac->pen_input;
touch_input_dev = wacom_wac->touch_input;
pad_input_dev = wacom_wac->pad_input; pad_input_dev = wacom_wac->pad_input;
if (!input_dev || !pad_input_dev) if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
return -EINVAL; return -EINVAL;
error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac); error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
if (!error) { if (error) {
error = input_register_device(input_dev); /* no pen in use on this interface */
input_free_device(pen_input_dev);
wacom_wac->pen_input = NULL;
pen_input_dev = NULL;
} else {
error = input_register_device(pen_input_dev);
if (error) if (error)
return error; goto fail_register_pen_input;
wacom_wac->input_registered = true; wacom_wac->pen_registered = true;
}
error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
if (error) {
/* no touch in use on this interface */
input_free_device(touch_input_dev);
wacom_wac->touch_input = NULL;
touch_input_dev = NULL;
} else {
error = input_register_device(touch_input_dev);
if (error)
goto fail_register_touch_input;
wacom_wac->touch_registered = true;
} }
error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
@ -1226,9 +1271,14 @@ static int wacom_register_inputs(struct wacom *wacom)
pad_input_dev = NULL; pad_input_dev = NULL;
wacom_wac->pad_registered = false; wacom_wac->pad_registered = false;
fail_register_pad_input: fail_register_pad_input:
input_unregister_device(input_dev); input_unregister_device(touch_input_dev);
wacom_wac->input = NULL; wacom_wac->touch_input = NULL;
wacom_wac->input_registered = false; wacom_wac->touch_registered = false;
fail_register_touch_input:
input_unregister_device(pen_input_dev);
wacom_wac->pen_input = NULL;
wacom_wac->pen_registered = false;
fail_register_pen_input:
return error; return error;
} }
@ -1285,8 +1335,11 @@ static void wacom_wireless_work(struct work_struct *work)
/* Stylus interface */ /* Stylus interface */
wacom_wac1->features = wacom_wac1->features =
*((struct wacom_features *)id->driver_data); *((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", if (wacom_wac1->features.type != INTUOSHT &&
wacom_wac1->features.type != BAMBOO_PT)
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
wacom_wac1->features.name); wacom_wac1->features.name);
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
wacom_wac1->features.name); wacom_wac1->features.name);
@ -1304,16 +1357,16 @@ static void wacom_wireless_work(struct work_struct *work)
wacom_wac2->features = wacom_wac2->features =
*((struct wacom_features *)id->driver_data); *((struct wacom_features *)id->driver_data);
wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
wacom_wac2->features.device_type = BTN_TOOL_FINGER;
wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
if (wacom_wac2->features.touch_max) snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
snprintf(wacom_wac2->name, WACOM_NAME_MAX, "%s (WL) Finger",wacom_wac2->features.name);
"%s (WL) Finger",wacom_wac2->features.name);
else
snprintf(wacom_wac2->name, WACOM_NAME_MAX,
"%s (WL) Pad",wacom_wac2->features.name);
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
"%s (WL) Pad", wacom_wac2->features.name); "%s (WL) Pad",wacom_wac2->features.name);
if (wacom_wac1->features.touch_max)
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_TOUCH;
if (wacom_wac1->features.type == INTUOSHT ||
wacom_wac1->features.type == BAMBOO_PT)
wacom_wac2->features.device_type |= WACOM_DEVICETYPE_PAD;
wacom_wac2->pid = wacom_wac->pid; wacom_wac2->pid = wacom_wac->pid;
error = wacom_allocate_inputs(wacom2) || error = wacom_allocate_inputs(wacom2) ||
wacom_register_inputs(wacom2); wacom_register_inputs(wacom2);
@ -1322,7 +1375,7 @@ static void wacom_wireless_work(struct work_struct *work)
if (wacom_wac1->features.type == INTUOSHT && if (wacom_wac1->features.type == INTUOSHT &&
wacom_wac1->features.touch_max) wacom_wac1->features.touch_max)
wacom_wac->shared->touch_input = wacom_wac2->input; wacom_wac->shared->touch_input = wacom_wac2->touch_input;
} }
error = wacom_initialize_battery(wacom); error = wacom_initialize_battery(wacom);
@ -1369,6 +1422,12 @@ static void wacom_set_default_phy(struct wacom_features *features)
static void wacom_calculate_res(struct wacom_features *features) static void wacom_calculate_res(struct wacom_features *features)
{ {
/* set unit to "100th of a mm" for devices not reported by HID */
if (!features->unit) {
features->unit = 0x11;
features->unitExpo = -3;
}
features->x_resolution = wacom_calc_hid_res(features->x_max, features->x_resolution = wacom_calc_hid_res(features->x_max,
features->x_phy, features->x_phy,
features->unit, features->unit,
@ -1396,6 +1455,49 @@ static size_t wacom_compute_pktlen(struct hid_device *hdev)
return size; return size;
} }
static void wacom_update_name(struct wacom *wacom)
{
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct wacom_features *features = &wacom_wac->features;
char name[WACOM_NAME_MAX];
/* Generic devices name unspecified */
if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) {
if (strstr(wacom->hdev->name, "Wacom") ||
strstr(wacom->hdev->name, "wacom") ||
strstr(wacom->hdev->name, "WACOM")) {
/* name is in HID descriptor, use it */
strlcpy(name, wacom->hdev->name, sizeof(name));
/* strip out excess whitespaces */
while (1) {
char *gap = strstr(name, " ");
if (gap == NULL)
break;
/* shift everything including the terminator */
memmove(gap, gap+1, strlen(gap));
}
/* get rid of trailing whitespace */
if (name[strlen(name)-1] == ' ')
name[strlen(name)-1] = '\0';
} else {
/* no meaningful name retrieved. use product ID */
snprintf(name, sizeof(name),
"%s %X", features->name, wacom->hdev->product);
}
} else {
strlcpy(name, features->name, sizeof(name));
}
/* Append the device type to the name */
snprintf(wacom_wac->pen_name, sizeof(wacom_wac->pen_name),
"%s Pen", name);
snprintf(wacom_wac->touch_name, sizeof(wacom_wac->touch_name),
"%s Finger", name);
snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name),
"%s Pad", name);
}
static int wacom_probe(struct hid_device *hdev, static int wacom_probe(struct hid_device *hdev,
const struct hid_device_id *id) const struct hid_device_id *id)
{ {
@ -1474,64 +1576,25 @@ static int wacom_probe(struct hid_device *hdev,
/* Retrieve the physical and logical size for touch devices */ /* Retrieve the physical and logical size for touch devices */
wacom_retrieve_hid_descriptor(hdev, features); wacom_retrieve_hid_descriptor(hdev, features);
wacom_setup_device_quirks(wacom);
/* if (features->device_type == WACOM_DEVICETYPE_NONE &&
* Intuos5 has no useful data about its touch interface in its features->type != WIRELESS) {
* HID descriptor. If this is the touch interface (PacketSize error = features->type == HID_GENERIC ? -ENODEV : 0;
* of WACOM_PKGLEN_BBTOUCH3), override the table values.
*/
if (features->type >= INTUOS5S && features->type <= INTUOSHT) {
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
features->device_type = BTN_TOOL_FINGER;
features->x_max = 4096; dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
features->y_max = 4096; hdev->name,
} else { error ? "Ignoring" : "Assuming pen");
features->device_type = BTN_TOOL_PEN;
} if (error)
goto fail_shared_data;
features->device_type |= WACOM_DEVICETYPE_PEN;
} }
/*
* Same thing for Bamboo 3rd gen.
*/
if ((features->type == BAMBOO_PT) &&
(features->pktlen == WACOM_PKGLEN_BBTOUCH3) &&
(features->device_type == BTN_TOOL_PEN)) {
features->device_type = BTN_TOOL_FINGER;
features->x_max = 4096;
features->y_max = 4096;
}
/*
* Same thing for Bamboo PAD
*/
if (features->type == BAMBOO_PAD)
features->device_type = BTN_TOOL_FINGER;
if (hdev->bus == BUS_BLUETOOTH)
features->quirks |= WACOM_QUIRK_BATTERY;
wacom_setup_device_quirks(features);
/* set unit to "100th of a mm" for devices not reported by HID */
if (!features->unit) {
features->unit = 0x11;
features->unitExpo = -3;
}
wacom_calculate_res(features); wacom_calculate_res(features);
strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); wacom_update_name(wacom);
snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name),
"%s Pad", features->name);
/* Append the device type to the name */
if (features->device_type != BTN_TOOL_FINGER)
strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX);
else if (features->touch_max)
strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX);
else
strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX);
error = wacom_add_shared_data(hdev); error = wacom_add_shared_data(hdev);
if (error) if (error)
@ -1574,9 +1637,9 @@ static int wacom_probe(struct hid_device *hdev,
if (features->quirks & WACOM_QUIRK_MONITOR) if (features->quirks & WACOM_QUIRK_MONITOR)
error = hid_hw_open(hdev); error = hid_hw_open(hdev);
if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { if (wacom_wac->features.type == INTUOSHT &&
if (wacom_wac->features.device_type == BTN_TOOL_FINGER) wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
wacom_wac->shared->touch_input = wacom_wac->input; wacom_wac->shared->touch_input = wacom_wac->touch_input;
} }
return 0; return 0;

View file

@ -69,7 +69,7 @@ static void wacom_notify_battery(struct wacom_wac *wacom_wac,
static int wacom_penpartner_irq(struct wacom_wac *wacom) static int wacom_penpartner_irq(struct wacom_wac *wacom)
{ {
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
switch (data[0]) { switch (data[0]) {
case 1: case 1:
@ -114,7 +114,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
int prox, pressure; int prox, pressure;
if (data[0] != WACOM_REPORT_PENABLED) { if (data[0] != WACOM_REPORT_PENABLED) {
@ -186,7 +186,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
static int wacom_ptu_irq(struct wacom_wac *wacom) static int wacom_ptu_irq(struct wacom_wac *wacom)
{ {
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
if (data[0] != WACOM_REPORT_PENABLED) { if (data[0] != WACOM_REPORT_PENABLED) {
dev_dbg(input->dev.parent, dev_dbg(input->dev.parent,
@ -215,7 +215,7 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
static int wacom_dtu_irq(struct wacom_wac *wacom) static int wacom_dtu_irq(struct wacom_wac *wacom)
{ {
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
int prox = data[1] & 0x20; int prox = data[1] & 0x20;
dev_dbg(input->dev.parent, dev_dbg(input->dev.parent,
@ -245,7 +245,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
static int wacom_dtus_irq(struct wacom_wac *wacom) static int wacom_dtus_irq(struct wacom_wac *wacom)
{ {
char *data = wacom->data; char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
unsigned short prox, pressure = 0; unsigned short prox, pressure = 0;
if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
@ -297,7 +297,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
struct input_dev *pad_input = wacom->pad_input; struct input_dev *pad_input = wacom->pad_input;
int battery_capacity, ps_connected; int battery_capacity, ps_connected;
int prox; int prox;
@ -464,7 +464,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
int idx = 0; int idx = 0;
/* tool number */ /* tool number */
@ -649,7 +649,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
unsigned int t; unsigned int t;
/* general pen packet */ /* general pen packet */
@ -681,7 +681,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
unsigned int t; unsigned int t;
int idx = 0, result; int idx = 0, result;
@ -1025,7 +1025,7 @@ static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
memcpy(wacom->data, data, 10); memcpy(wacom->data, data, 10);
wacom_intuos_irq(wacom); wacom_intuos_irq(wacom);
input_sync(wacom->input); input_sync(wacom->pen_input);
if (wacom->pad_input) if (wacom->pad_input)
input_sync(wacom->pad_input); input_sync(wacom->pad_input);
} }
@ -1057,7 +1057,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
ps_connected); ps_connected);
break; break;
default: default:
dev_dbg(wacom->input->dev.parent, dev_dbg(wacom->pen_input->dev.parent,
"Unknown report: %d,%d size:%zu\n", "Unknown report: %d,%d size:%zu\n",
data[0], data[1], len); data[0], data[1], len);
return 0; return 0;
@ -1067,7 +1067,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
{ {
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
unsigned touch_max = wacom->features.touch_max; unsigned touch_max = wacom->features.touch_max;
int count = 0; int count = 0;
int i; int i;
@ -1075,9 +1075,8 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
if (!touch_max) if (!touch_max)
return 0; return 0;
/* non-HID_GENERIC single touch input doesn't call this routine */ if (touch_max == 1)
if ((touch_max == 1) && (wacom->features.type == HID_GENERIC)) return test_bit(BTN_TOUCH, input->key) &&
return wacom->hid_data.tipswitch &&
!wacom->shared->stylus_in_proximity; !wacom->shared->stylus_in_proximity;
for (i = 0; i < input->mt->num_slots; i++) { for (i = 0; i < input->mt->num_slots; i++) {
@ -1092,7 +1091,7 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
static int wacom_24hdt_irq(struct wacom_wac *wacom) static int wacom_24hdt_irq(struct wacom_wac *wacom)
{ {
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
int i; int i;
int current_num_contacts = data[61]; int current_num_contacts = data[61];
@ -1160,7 +1159,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
static int wacom_mt_touch(struct wacom_wac *wacom) static int wacom_mt_touch(struct wacom_wac *wacom)
{ {
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
int i; int i;
int current_num_contacts = data[2]; int current_num_contacts = data[2];
@ -1211,7 +1210,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
static int wacom_tpc_mt_touch(struct wacom_wac *wacom) static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
{ {
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
int i; int i;
@ -1240,7 +1239,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
{ {
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
bool prox = !wacom->shared->stylus_in_proximity; bool prox = !wacom->shared->stylus_in_proximity;
int x = 0, y = 0; int x = 0, y = 0;
@ -1276,7 +1275,7 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
static int wacom_tpc_pen(struct wacom_wac *wacom) static int wacom_tpc_pen(struct wacom_wac *wacom)
{ {
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
bool prox = data[1] & 0x20; bool prox = data[1] & 0x20;
if (!wacom->shared->stylus_in_proximity) /* first in prox */ if (!wacom->shared->stylus_in_proximity) /* first in prox */
@ -1305,8 +1304,12 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
{ {
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
dev_dbg(wacom->input->dev.parent, if (wacom->pen_input)
"%s: received report #%d\n", __func__, data[0]); dev_dbg(wacom->pen_input->dev.parent,
"%s: received report #%d\n", __func__, data[0]);
else if (wacom->touch_input)
dev_dbg(wacom->touch_input->dev.parent,
"%s: received report #%d\n", __func__, data[0]);
switch (len) { switch (len) {
case WACOM_PKGLEN_TPC1FG: case WACOM_PKGLEN_TPC1FG:
@ -1338,11 +1341,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
return 0; return 0;
} }
static void wacom_map_usage(struct wacom *wacom, struct hid_usage *usage, static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
struct hid_field *field, __u8 type, __u16 code, int fuzz) struct hid_field *field, __u8 type, __u16 code, int fuzz)
{ {
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct input_dev *input = wacom_wac->input;
int fmin = field->logical_minimum; int fmin = field->logical_minimum;
int fmax = field->logical_maximum; int fmax = field->logical_maximum;
@ -1370,36 +1371,38 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
struct hid_field *field, struct hid_usage *usage) struct hid_field *field, struct hid_usage *usage)
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct input_dev *input = wacom_wac->pen_input;
switch (usage->hid) { switch (usage->hid) {
case HID_GD_X: case HID_GD_X:
wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
break; break;
case HID_GD_Y: case HID_GD_Y:
wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
break; break;
case HID_DG_TIPPRESSURE: case HID_DG_TIPPRESSURE:
wacom_map_usage(wacom, usage, field, EV_ABS, ABS_PRESSURE, 0); wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
break; break;
case HID_DG_INRANGE: case HID_DG_INRANGE:
wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOOL_PEN, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
break; break;
case HID_DG_INVERT: case HID_DG_INVERT:
wacom_map_usage(wacom, usage, field, EV_KEY, wacom_map_usage(input, usage, field, EV_KEY,
BTN_TOOL_RUBBER, 0); BTN_TOOL_RUBBER, 0);
break; break;
case HID_DG_ERASER: case HID_DG_ERASER:
case HID_DG_TIPSWITCH: case HID_DG_TIPSWITCH:
wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
break; break;
case HID_DG_BARRELSWITCH: case HID_DG_BARRELSWITCH:
wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
break; break;
case HID_DG_BARRELSWITCH2: case HID_DG_BARRELSWITCH2:
wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS2, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
break; break;
case HID_DG_TOOLSERIALNUMBER: case HID_DG_TOOLSERIALNUMBER:
wacom_map_usage(wacom, usage, field, EV_MSC, MSC_SERIAL, 0); wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
break; break;
} }
} }
@ -1409,7 +1412,7 @@ static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct input_dev *input = wacom_wac->input; struct input_dev *input = wacom_wac->pen_input;
/* checking which Tool / tip switch to send */ /* checking which Tool / tip switch to send */
switch (usage->hid) { switch (usage->hid) {
@ -1439,7 +1442,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct input_dev *input = wacom_wac->input; struct input_dev *input = wacom_wac->pen_input;
bool prox = wacom_wac->hid_data.inrange_state; bool prox = wacom_wac->hid_data.inrange_state;
if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */ if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
@ -1468,23 +1471,24 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct wacom_features *features = &wacom_wac->features; struct wacom_features *features = &wacom_wac->features;
struct input_dev *input = wacom_wac->touch_input;
unsigned touch_max = wacom_wac->features.touch_max; unsigned touch_max = wacom_wac->features.touch_max;
switch (usage->hid) { switch (usage->hid) {
case HID_GD_X: case HID_GD_X:
features->last_slot_field = usage->hid; features->last_slot_field = usage->hid;
if (touch_max == 1) if (touch_max == 1)
wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
else else
wacom_map_usage(wacom, usage, field, EV_ABS, wacom_map_usage(input, usage, field, EV_ABS,
ABS_MT_POSITION_X, 4); ABS_MT_POSITION_X, 4);
break; break;
case HID_GD_Y: case HID_GD_Y:
features->last_slot_field = usage->hid; features->last_slot_field = usage->hid;
if (touch_max == 1) if (touch_max == 1)
wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
else else
wacom_map_usage(wacom, usage, field, EV_ABS, wacom_map_usage(input, usage, field, EV_ABS,
ABS_MT_POSITION_Y, 4); ABS_MT_POSITION_Y, 4);
break; break;
case HID_DG_CONTACTID: case HID_DG_CONTACTID:
@ -1498,7 +1502,7 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
break; break;
case HID_DG_TIPSWITCH: case HID_DG_TIPSWITCH:
features->last_slot_field = usage->hid; features->last_slot_field = usage->hid;
wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
break; break;
} }
} }
@ -1554,7 +1558,7 @@ static int wacom_wac_finger_event(struct hid_device *hdev,
if (usage->usage_index + 1 == field->report_count) { if (usage->usage_index + 1 == field->report_count) {
if (usage->hid == wacom_wac->features.last_slot_field) if (usage->hid == wacom_wac->features.last_slot_field)
wacom_wac_finger_slot(wacom_wac, wacom_wac->input); wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
} }
return 0; return 0;
@ -1565,7 +1569,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct input_dev *input = wacom_wac->input; struct input_dev *input = wacom_wac->touch_input;
unsigned touch_max = wacom_wac->features.touch_max; unsigned touch_max = wacom_wac->features.touch_max;
if (touch_max > 1) if (touch_max > 1)
@ -1582,10 +1586,10 @@ void wacom_wac_usage_mapping(struct hid_device *hdev,
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct input_dev *input = wacom_wac->input;
/* currently, only direct devices have proper hid report descriptors */ /* currently, only direct devices have proper hid report descriptors */
__set_bit(INPUT_PROP_DIRECT, input->propbit); __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit);
__set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit);
if (WACOM_PEN_FIELD(field)) if (WACOM_PEN_FIELD(field))
return wacom_wac_pen_usage_mapping(hdev, field, usage); return wacom_wac_pen_usage_mapping(hdev, field, usage);
@ -1630,7 +1634,7 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
static int wacom_bpt_touch(struct wacom_wac *wacom) static int wacom_bpt_touch(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
struct input_dev *pad_input = wacom->pad_input; struct input_dev *pad_input = wacom->pad_input;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
int i; int i;
@ -1678,7 +1682,7 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
bool touch = data[1] & 0x80; bool touch = data[1] & 0x80;
int slot = input_mt_get_slot_by_key(input, data[0]); int slot = input_mt_get_slot_by_key(input, data[0]);
@ -1736,7 +1740,6 @@ static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
static int wacom_bpt3_touch(struct wacom_wac *wacom) static int wacom_bpt3_touch(struct wacom_wac *wacom)
{ {
struct input_dev *input = wacom->input;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
int count = data[1] & 0x07; int count = data[1] & 0x07;
int i; int i;
@ -1755,8 +1758,12 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
wacom_bpt3_button_msg(wacom, data + offset); wacom_bpt3_button_msg(wacom, data + offset);
} }
input_mt_sync_frame(input);
wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); /* only update the touch if we actually have a touchpad */
if (wacom->touch_registered) {
input_mt_sync_frame(wacom->touch_input);
wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
}
return 1; return 1;
} }
@ -1764,7 +1771,7 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
static int wacom_bpt_pen(struct wacom_wac *wacom) static int wacom_bpt_pen(struct wacom_wac *wacom)
{ {
struct wacom_features *features = &wacom->features; struct wacom_features *features = &wacom->features;
struct input_dev *input = wacom->input; struct input_dev *input = wacom->pen_input;
unsigned char *data = wacom->data; unsigned char *data = wacom->data;
int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
@ -1873,7 +1880,7 @@ static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
unsigned char *data) unsigned char *data)
{ {
struct input_dev *input = wacom->input; struct input_dev *input = wacom->touch_input;
unsigned char *finger_data, prefix; unsigned char *finger_data, prefix;
unsigned id; unsigned id;
int x, y; int x, y;
@ -2117,7 +2124,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
} }
if (sync) { if (sync) {
input_sync(wacom_wac->input); if (wacom_wac->pen_input)
input_sync(wacom_wac->pen_input);
if (wacom_wac->touch_input)
input_sync(wacom_wac->touch_input);
if (wacom_wac->pad_input) if (wacom_wac->pad_input)
input_sync(wacom_wac->pad_input); input_sync(wacom_wac->pad_input);
} }
@ -2125,7 +2135,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
{ {
struct input_dev *input_dev = wacom_wac->input; struct input_dev *input_dev = wacom_wac->pen_input;
input_set_capability(input_dev, EV_MSC, MSC_SERIAL); input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
@ -2148,7 +2158,7 @@ static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
static void wacom_setup_intuos(struct wacom_wac *wacom_wac) static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
{ {
struct input_dev *input_dev = wacom_wac->input; struct input_dev *input_dev = wacom_wac->pen_input;
input_set_capability(input_dev, EV_REL, REL_WHEEL); input_set_capability(input_dev, EV_REL, REL_WHEEL);
@ -2167,15 +2177,57 @@ static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
} }
void wacom_setup_device_quirks(struct wacom_features *features) void wacom_setup_device_quirks(struct wacom *wacom)
{ {
struct wacom_features *features = &wacom->wacom_wac.features;
/* The pen and pad share the same interface on most devices */
if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
features->type == DTUS || features->type == WACOM_MO ||
(features->type >= INTUOS3S && features->type <= WACOM_13HD &&
features->type != INTUOSHT)) {
if (features->device_type & WACOM_DEVICETYPE_PEN)
features->device_type |= WACOM_DEVICETYPE_PAD;
}
/* touch device found but size is not defined. use default */ /* touch device found but size is not defined. use default */
if (features->device_type == BTN_TOOL_FINGER && !features->x_max) { if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
features->x_max = 1023; features->x_max = 1023;
features->y_max = 1023; features->y_max = 1023;
} }
/*
* Intuos5/Pro and Bamboo 3rd gen have no useful data about its
* touch interface in its HID descriptor. If this is the touch
* interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
* tablet values.
*/
if ((features->type >= INTUOS5S && features->type <= INTUOSHT) ||
(features->type == BAMBOO_PT)) {
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
if (features->touch_max)
features->device_type |= WACOM_DEVICETYPE_TOUCH;
if (features->type == BAMBOO_PT || features->type == INTUOSHT)
features->device_type |= WACOM_DEVICETYPE_PAD;
features->x_max = 4096;
features->y_max = 4096;
}
}
/*
* Raw Wacom-mode pen and touch events both come from interface
* 0, whose HID descriptor has an application usage of 0xFF0D
* (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
* out through the HID_GENERIC device created for interface 1,
* so rewrite this one to be of type BTN_TOOL_FINGER.
*/
if (features->type == BAMBOO_PAD)
features->device_type |= WACOM_DEVICETYPE_TOUCH;
if (wacom->hdev->bus == BUS_BLUETOOTH)
features->quirks |= WACOM_QUIRK_BATTERY;
/* quirk for bamboo touch with 2 low res touches */ /* quirk for bamboo touch with 2 low res touches */
if (features->type == BAMBOO_PT && if (features->type == BAMBOO_PT &&
features->pktlen == WACOM_PKGLEN_BBTOUCH) { features->pktlen == WACOM_PKGLEN_BBTOUCH) {
@ -2192,61 +2244,23 @@ void wacom_setup_device_quirks(struct wacom_features *features)
features->quirks |= WACOM_QUIRK_NO_INPUT; features->quirks |= WACOM_QUIRK_NO_INPUT;
/* must be monitor interface if no device_type set */ /* must be monitor interface if no device_type set */
if (!features->device_type) { if (features->device_type == WACOM_DEVICETYPE_NONE) {
features->quirks |= WACOM_QUIRK_MONITOR; features->quirks |= WACOM_QUIRK_MONITOR;
features->quirks |= WACOM_QUIRK_BATTERY; features->quirks |= WACOM_QUIRK_BATTERY;
} }
} }
} }
static void wacom_abs_set_axis(struct input_dev *input_dev, int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac)
{
struct wacom_features *features = &wacom_wac->features;
if (features->device_type == BTN_TOOL_PEN) {
input_set_abs_params(input_dev, ABS_X, features->x_min,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, features->y_min,
features->y_max, features->y_fuzz, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0,
features->pressure_max, features->pressure_fuzz, 0);
/* penabled devices have fixed resolution for each model */
input_abs_set_res(input_dev, ABS_X, features->x_resolution);
input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
} else {
if (features->touch_max == 1) {
input_set_abs_params(input_dev, ABS_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_Y,
features->y_resolution);
}
if (features->touch_max > 1) {
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
features->y_resolution);
}
}
}
int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac) struct wacom_wac *wacom_wac)
{ {
struct wacom_features *features = &wacom_wac->features; struct wacom_features *features = &wacom_wac->features;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
if (features->type == HID_GENERIC) if (features->type == HID_GENERIC)
/* setup has already been done */ /* setup has already been done */
return 0; return 0;
@ -2254,7 +2268,17 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
__set_bit(BTN_TOUCH, input_dev->keybit); __set_bit(BTN_TOUCH, input_dev->keybit);
__set_bit(ABS_MISC, input_dev->absbit); __set_bit(ABS_MISC, input_dev->absbit);
wacom_abs_set_axis(input_dev, wacom_wac); input_set_abs_params(input_dev, ABS_X, features->x_min,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, features->y_min,
features->y_max, features->y_fuzz, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0,
features->pressure_max, features->pressure_fuzz, 0);
/* penabled devices have fixed resolution for each model */
input_abs_set_res(input_dev, ABS_X, features->x_resolution);
input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
switch (features->type) { switch (features->type) {
case GRAPHIRE_BT: case GRAPHIRE_BT:
@ -2323,53 +2347,25 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
case INTUOSPS: case INTUOSPS:
__set_bit(INPUT_PROP_POINTER, input_dev->propbit); __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
if (features->device_type == BTN_TOOL_PEN) { input_set_abs_params(input_dev, ABS_DISTANCE, 0,
input_set_abs_params(input_dev, ABS_DISTANCE, 0, features->distance_max,
features->distance_max, 0, 0);
0, 0);
input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
input_abs_set_res(input_dev, ABS_Z, 287); input_abs_set_res(input_dev, ABS_Z, 287);
wacom_setup_intuos(wacom_wac); wacom_setup_intuos(wacom_wac);
} else if (features->device_type == BTN_TOOL_FINGER) {
__clear_bit(ABS_MISC, input_dev->absbit);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
0, features->y_max, 0, 0);
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
}
break; break;
case WACOM_24HDT: case WACOM_24HDT:
if (features->device_type == BTN_TOOL_FINGER) {
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
}
/* fall through */
case WACOM_27QHDT: case WACOM_27QHDT:
case MTSCREEN: case MTSCREEN:
case MTTPC: case MTTPC:
case MTTPC_B: case MTTPC_B:
case TABLETPC2FG: case TABLETPC2FG:
if (features->device_type == BTN_TOOL_FINGER && features->touch_max > 1)
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
/* fall through */
case TABLETPC: case TABLETPC:
case TABLETPCE: case TABLETPCE:
__clear_bit(ABS_MISC, input_dev->absbit); __clear_bit(ABS_MISC, input_dev->absbit);
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
if (features->device_type != BTN_TOOL_PEN)
break; /* no need to process stylus stuff */
/* fall through */ /* fall through */
case DTUS: case DTUS:
@ -2397,50 +2393,114 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
break; break;
case INTUOSHT: case INTUOSHT:
if (features->touch_max &&
features->device_type == BTN_TOOL_FINGER) {
input_dev->evbit[0] |= BIT_MASK(EV_SW);
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
}
/* fall through */
case BAMBOO_PT: case BAMBOO_PT:
__clear_bit(ABS_MISC, input_dev->absbit); __clear_bit(ABS_MISC, input_dev->absbit);
if (features->device_type == BTN_TOOL_FINGER) { __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
if (features->touch_max) { __set_bit(BTN_TOOL_PEN, input_dev->keybit);
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { __set_bit(BTN_STYLUS, input_dev->keybit);
input_set_abs_params(input_dev, __set_bit(BTN_STYLUS2, input_dev->keybit);
ABS_MT_TOUCH_MAJOR, input_set_abs_params(input_dev, ABS_DISTANCE, 0,
0, features->x_max, 0, 0); features->distance_max,
input_set_abs_params(input_dev, 0, 0);
ABS_MT_TOUCH_MINOR,
0, features->y_max, 0, 0);
}
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
} else {
/* buttons/keys only interface */
__clear_bit(ABS_X, input_dev->absbit);
__clear_bit(ABS_Y, input_dev->absbit);
__clear_bit(BTN_TOUCH, input_dev->keybit);
/* PAD is setup by wacom_setup_pad_input_capabilities later */
return 1;
}
} else if (features->device_type == BTN_TOOL_PEN) {
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
__set_bit(BTN_STYLUS, input_dev->keybit);
__set_bit(BTN_STYLUS2, input_dev->keybit);
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
features->distance_max,
0, 0);
}
break; break;
case BAMBOO_PAD: case BAMBOO_PAD:
__clear_bit(ABS_MISC, input_dev->absbit); __clear_bit(ABS_MISC, input_dev->absbit);
break;
}
return 0;
}
int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac)
{
struct wacom_features *features = &wacom_wac->features;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
return -ENODEV;
if (features->type == HID_GENERIC)
/* setup has already been done */
return 0;
__set_bit(BTN_TOUCH, input_dev->keybit);
if (features->touch_max == 1) {
input_set_abs_params(input_dev, ABS_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_Y,
features->y_resolution);
}
else if (features->touch_max > 1) {
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
features->y_resolution);
}
switch (features->type) {
case INTUOS5:
case INTUOS5L:
case INTUOSPM:
case INTUOSPL:
case INTUOS5S:
case INTUOSPS:
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
break;
case WACOM_24HDT:
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
/* fall through */
case WACOM_27QHDT:
case MTSCREEN:
case MTTPC:
case MTTPC_B:
case TABLETPC2FG:
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
/*fall through */
case TABLETPC:
case TABLETPCE:
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
break;
case INTUOSHT:
input_dev->evbit[0] |= BIT_MASK(EV_SW);
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
/* fall through */
case BAMBOO_PT:
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
input_set_abs_params(input_dev,
ABS_MT_TOUCH_MAJOR,
0, features->x_max, 0, 0);
input_set_abs_params(input_dev,
ABS_MT_TOUCH_MINOR,
0, features->y_max, 0, 0);
}
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
break;
case BAMBOO_PAD:
input_mt_init_slots(input_dev, features->touch_max, input_mt_init_slots(input_dev, features->touch_max,
INPUT_MT_POINTER); INPUT_MT_POINTER);
__set_bit(BTN_LEFT, input_dev->keybit); __set_bit(BTN_LEFT, input_dev->keybit);
@ -2456,6 +2516,9 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
struct wacom_features *features = &wacom_wac->features; struct wacom_features *features = &wacom_wac->features;
int i; int i;
if (!(features->device_type & WACOM_DEVICETYPE_PAD))
return -ENODEV;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
/* kept for making legacy xf86-input-wacom working with the wheels */ /* kept for making legacy xf86-input-wacom working with the wheels */
@ -2592,10 +2655,6 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
case INTUOS5S: case INTUOS5S:
case INTUOSPS: case INTUOSPS:
/* touch interface does not have the pad device */
if (features->device_type != BTN_TOOL_PEN)
return -ENODEV;
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
__set_bit(BTN_0 + i, input_dev->keybit); __set_bit(BTN_0 + i, input_dev->keybit);
@ -2637,12 +2696,6 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
case INTUOSHT: case INTUOSHT:
case BAMBOO_PT: case BAMBOO_PT:
/* pad device is on the touch interface */
if ((features->device_type != BTN_TOOL_FINGER) ||
/* Bamboo Pen only tablet does not have pad */
((features->type == BAMBOO_PT) && !features->touch_max))
return -ENODEV;
__clear_bit(ABS_MISC, input_dev->absbit); __clear_bit(ABS_MISC, input_dev->absbit);
__set_bit(BTN_LEFT, input_dev->keybit); __set_bit(BTN_LEFT, input_dev->keybit);
@ -2922,6 +2975,9 @@ static const struct wacom_features wacom_features_0x32F =
{ "Wacom DTU1031X", 22472, 12728, 511, 0, { "Wacom DTU1031X", 22472, 12728, 511, 0,
DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
static const struct wacom_features wacom_features_0x336 =
{ "Wacom DTU1141", 23472, 13203, 1023, 0,
DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x57 = static const struct wacom_features wacom_features_0x57 =
{ "Wacom DTK2241", 95640, 54060, 2047, 63, { "Wacom DTK2241", 95640, 54060, 2047, 63,
DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
@ -3275,6 +3331,7 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x32F) }, { USB_DEVICE_WACOM(0x32F) },
{ USB_DEVICE_WACOM(0x333) }, { USB_DEVICE_WACOM(0x333) },
{ USB_DEVICE_WACOM(0x335) }, { USB_DEVICE_WACOM(0x335) },
{ USB_DEVICE_WACOM(0x336) },
{ USB_DEVICE_WACOM(0x4001) }, { USB_DEVICE_WACOM(0x4001) },
{ USB_DEVICE_WACOM(0x4004) }, { USB_DEVICE_WACOM(0x4004) },
{ USB_DEVICE_WACOM(0x5000) }, { USB_DEVICE_WACOM(0x5000) },

View file

@ -18,10 +18,7 @@
#define WACOM_NAME_MAX 64 #define WACOM_NAME_MAX 64
/* packet length for individual models */ /* packet length for individual models */
#define WACOM_PKGLEN_PENPRTN 7
#define WACOM_PKGLEN_GRAPHIRE 8
#define WACOM_PKGLEN_BBFUN 9 #define WACOM_PKGLEN_BBFUN 9
#define WACOM_PKGLEN_INTUOS 10
#define WACOM_PKGLEN_TPC1FG 5 #define WACOM_PKGLEN_TPC1FG 5
#define WACOM_PKGLEN_TPC1FG_B 10 #define WACOM_PKGLEN_TPC1FG_B 10
#define WACOM_PKGLEN_TPC2FG 14 #define WACOM_PKGLEN_TPC2FG 14
@ -29,9 +26,6 @@
#define WACOM_PKGLEN_BBTOUCH3 64 #define WACOM_PKGLEN_BBTOUCH3 64
#define WACOM_PKGLEN_BBPEN 10 #define WACOM_PKGLEN_BBPEN 10
#define WACOM_PKGLEN_WIRELESS 32 #define WACOM_PKGLEN_WIRELESS 32
#define WACOM_PKGLEN_MTOUCH 62
#define WACOM_PKGLEN_MTTPC 40
#define WACOM_PKGLEN_DTUS 68
#define WACOM_PKGLEN_PENABLED 8 #define WACOM_PKGLEN_PENABLED 8
#define WACOM_PKGLEN_BPAD_TOUCH 32 #define WACOM_PKGLEN_BPAD_TOUCH 32
#define WACOM_PKGLEN_BPAD_TOUCH_USB 64 #define WACOM_PKGLEN_BPAD_TOUCH_USB 64
@ -78,10 +72,20 @@
#define WACOM_QUIRK_MONITOR 0x0004 #define WACOM_QUIRK_MONITOR 0x0004
#define WACOM_QUIRK_BATTERY 0x0008 #define WACOM_QUIRK_BATTERY 0x0008
/* device types */
#define WACOM_DEVICETYPE_NONE 0x0000
#define WACOM_DEVICETYPE_PEN 0x0001
#define WACOM_DEVICETYPE_TOUCH 0x0002
#define WACOM_DEVICETYPE_PAD 0x0004
#define WACOM_VENDORDEFINED_PEN 0xff0d0001
#define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \ #define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
((f)->physical == HID_DG_STYLUS) || \ ((f)->physical == HID_DG_STYLUS) || \
((f)->physical == HID_DG_PEN) || \ ((f)->physical == HID_DG_PEN) || \
((f)->application == HID_DG_PEN)) ((f)->application == HID_DG_PEN) || \
((f)->application == HID_DG_DIGITIZER) || \
((f)->application == WACOM_VENDORDEFINED_PEN))
#define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \ #define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
((f)->physical == HID_DG_FINGER) || \ ((f)->physical == HID_DG_FINGER) || \
((f)->application == HID_DG_TOUCHSCREEN)) ((f)->application == HID_DG_TOUCHSCREEN))
@ -192,7 +196,8 @@ struct hid_data {
}; };
struct wacom_wac { struct wacom_wac {
char name[WACOM_NAME_MAX]; char pen_name[WACOM_NAME_MAX];
char touch_name[WACOM_NAME_MAX];
char pad_name[WACOM_NAME_MAX]; char pad_name[WACOM_NAME_MAX];
char bat_name[WACOM_NAME_MAX]; char bat_name[WACOM_NAME_MAX];
char ac_name[WACOM_NAME_MAX]; char ac_name[WACOM_NAME_MAX];
@ -203,9 +208,11 @@ struct wacom_wac {
bool reporting_data; bool reporting_data;
struct wacom_features features; struct wacom_features features;
struct wacom_shared *shared; struct wacom_shared *shared;
struct input_dev *input; struct input_dev *pen_input;
struct input_dev *touch_input;
struct input_dev *pad_input; struct input_dev *pad_input;
bool input_registered; bool pen_registered;
bool touch_registered;
bool pad_registered; bool pad_registered;
int pid; int pid;
int battery_capacity; int battery_capacity;

View file

@ -69,12 +69,6 @@
#define USB_DEVICE_ID_LD_HYBRID 0x2090 /* USB Product ID of Automotive Hybrid */ #define USB_DEVICE_ID_LD_HYBRID 0x2090 /* USB Product ID of Automotive Hybrid */
#define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0 /* USB Product ID of Heat control */ #define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0 /* USB Product ID of Heat control */
#define USB_VENDOR_ID_VERNIER 0x08f7
#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
#ifdef CONFIG_USB_DYNAMIC_MINORS #ifdef CONFIG_USB_DYNAMIC_MINORS
#define USB_LD_MINOR_BASE 0 #define USB_LD_MINOR_BASE 0
#else #else
@ -115,10 +109,6 @@ static const struct usb_device_id ld_usb_table[] = {
{ USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
{ USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
{ USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
{ USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
{ USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
{ USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
{ USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
{ } /* Terminating entry */ { } /* Terminating entry */
}; };
MODULE_DEVICE_TABLE(usb, ld_usb_table); MODULE_DEVICE_TABLE(usb, ld_usb_table);

View file

@ -815,6 +815,8 @@ void hid_disconnect(struct hid_device *hid);
const struct hid_device_id *hid_match_id(struct hid_device *hdev, const struct hid_device_id *hid_match_id(struct hid_device *hdev,
const struct hid_device_id *id); const struct hid_device_id *id);
s32 hid_snto32(__u32 value, unsigned n); s32 hid_snto32(__u32 value, unsigned n);
__u32 hid_field_extract(const struct hid_device *hid, __u8 *report,
unsigned offset, unsigned n);
/** /**
* hid_device_io_start - enable HID input during probe, remove * hid_device_io_start - enable HID input during probe, remove