summaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2014-08-06 23:31:48 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-08-06 23:31:48 -0700
commitfc8104bc5a3f6f49d79f45f2706f79f77a9fb2ae (patch)
treec30f3c27cb719f1e268f485640cfab9898557676 /drivers/input
parent62238f3aadc9bc56da70100e19ec61b9f8d72a5f (diff)
parentf2e0a7d4a0b94b4274e3b7e15bf650d45a866f3c (diff)
Merge branch 'wacom' into next
Merge large update to Wacom driver, converting it from USB to a HID driver and unifying wired and bluetooth support, from Benjamin Tissoires.
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/tablet/Kconfig16
-rw-r--r--drivers/input/tablet/Makefile3
-rw-r--r--drivers/input/tablet/wacom.h139
-rw-r--r--drivers/input/tablet/wacom_sys.c1497
-rw-r--r--drivers/input/tablet/wacom_wac.c2499
-rw-r--r--drivers/input/tablet/wacom_wac.h165
6 files changed, 0 insertions, 4319 deletions
diff --git a/drivers/input/tablet/Kconfig b/drivers/input/tablet/Kconfig
index a5121b09c63f..623bb9e0d5a4 100644
--- a/drivers/input/tablet/Kconfig
+++ b/drivers/input/tablet/Kconfig
@@ -73,22 +73,6 @@ config TABLET_USB_KBTAB
To compile this driver as a module, choose M here: the
module will be called kbtab.
-config TABLET_USB_WACOM
- tristate "Wacom Intuos/Graphire tablet support (USB)"
- depends on USB_ARCH_HAS_HCD
- select POWER_SUPPLY
- select USB
- select NEW_LEDS
- select LEDS_CLASS
- help
- Say Y here if you want to use the USB version of the Wacom Intuos
- or Graphire tablet. Make sure to say Y to "Mouse support"
- (CONFIG_INPUT_MOUSEDEV) and/or "Event interface support"
- (CONFIG_INPUT_EVDEV) as well.
-
- To compile this driver as a module, choose M here: the
- module will be called wacom.
-
config TABLET_SERIAL_WACOM4
tristate "Wacom protocol 4 serial tablet support"
select SERIO
diff --git a/drivers/input/tablet/Makefile b/drivers/input/tablet/Makefile
index 4d9339fb3b63..2e130101cf3c 100644
--- a/drivers/input/tablet/Makefile
+++ b/drivers/input/tablet/Makefile
@@ -2,13 +2,10 @@
# Makefile for the tablet drivers
#
-# Multipart objects.
-wacom-objs := wacom_wac.o wacom_sys.o
obj-$(CONFIG_TABLET_USB_ACECAD) += acecad.o
obj-$(CONFIG_TABLET_USB_AIPTEK) += aiptek.o
obj-$(CONFIG_TABLET_USB_GTCO) += gtco.o
obj-$(CONFIG_TABLET_USB_HANWANG) += hanwang.o
obj-$(CONFIG_TABLET_USB_KBTAB) += kbtab.o
-obj-$(CONFIG_TABLET_USB_WACOM) += wacom.o
obj-$(CONFIG_TABLET_SERIAL_WACOM4) += wacom_serial4.o
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
deleted file mode 100644
index 9ebf0ed3b3b3..000000000000
--- a/drivers/input/tablet/wacom.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * drivers/input/tablet/wacom.h
- *
- * USB Wacom tablet support
- *
- * Copyright (c) 2000-2004 Vojtech Pavlik <vojtech@ucw.cz>
- * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
- * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
- * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
- * Copyright (c) 2000 James E. Blair <corvus@gnu.org>
- * Copyright (c) 2000 Daniel Egger <egger@suse.de>
- * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
- * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be>
- * Copyright (c) 2002-2011 Ping Cheng <pingc@wacom.com>
- *
- * ChangeLog:
- * v0.1 (vp) - Initial release
- * v0.2 (aba) - Support for all buttons / combinations
- * v0.3 (vp) - Support for Intuos added
- * v0.4 (sm) - Support for more Intuos models, menustrip
- * relative mode, proximity.
- * v0.5 (vp) - Big cleanup, nifty features removed,
- * they belong in userspace
- * v1.8 (vp) - Submit URB only when operating, moved to CVS,
- * use input_report_key instead of report_btn and
- * other cleanups
- * v1.11 (vp) - Add URB ->dev setting for new kernels
- * v1.11 (jb) - Add support for the 4D Mouse & Lens
- * v1.12 (de) - Add support for two more inking pen IDs
- * v1.14 (vp) - Use new USB device id probing scheme.
- * Fix Wacom Graphire mouse wheel
- * v1.18 (vp) - Fix mouse wheel direction
- * Make mouse relative
- * v1.20 (fl) - Report tool id for Intuos devices
- * - Multi tools support
- * - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
- * - Add PL models support
- * - Fix Wacom Graphire mouse wheel again
- * v1.21 (vp) - Removed protocol descriptions
- * - Added MISC_SERIAL for tool serial numbers
- * (gb) - Identify version on module load.
- * v1.21.1 (fl) - added Graphire2 support
- * v1.21.2 (fl) - added Intuos2 support
- * - added all the PL ids
- * v1.21.3 (fl) - added another eraser id from Neil Okamoto
- * - added smooth filter for Graphire from Peri Hankey
- * - added PenPartner support from Olaf van Es
- * - new tool ids from Ole Martin Bjoerndalen
- * v1.29 (pc) - Add support for more tablets
- * - Fix pressure reporting
- * v1.30 (vp) - Merge 2.4 and 2.5 drivers
- * - Since 2.5 now has input_sync(), remove MSC_SERIAL abuse
- * - Cleanups here and there
- * v1.30.1 (pi) - Added Graphire3 support
- * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ...
- * v1.43 (pc) - Added support for Cintiq 21UX
- * - Fixed a Graphire bug
- * - Merged wacom_intuos3_irq into wacom_intuos_irq
- * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc.
- * - Report Device IDs
- * v1.45 (pc) - Added support for DTF 521, Intuos3 12x12 and 12x19
- * - Minor data report fix
- * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c,
- * - where wacom_sys.c deals with system specific code,
- * - and wacom_wac.c deals with Wacom specific code
- * - Support Intuos3 4x6
- * v1.47 (pc) - Added support for Bamboo
- * v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX
- * v1.49 (pc) - Added support for USB Tablet PC (0x90, 0x93, and 0x9A)
- * v1.50 (pc) - Fixed a TabletPC touch bug in 2.6.28
- * v1.51 (pc) - Added support for Intuos4
- * v1.52 (pc) - Query Wacom data upon system resume
- * - add defines for features->type
- * - add new devices (0x9F, 0xE2, and 0XE3)
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-#ifndef WACOM_H
-#define WACOM_H
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/mod_devicetable.h>
-#include <linux/usb/input.h>
-#include <linux/power_supply.h>
-#include <asm/unaligned.h>
-
-/*
- * Version Information
- */
-#define DRIVER_VERSION "v1.53"
-#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
-#define DRIVER_DESC "USB Wacom tablet driver"
-#define DRIVER_LICENSE "GPL"
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE(DRIVER_LICENSE);
-
-#define USB_VENDOR_ID_WACOM 0x056a
-#define USB_VENDOR_ID_LENOVO 0x17ef
-
-struct wacom {
- dma_addr_t data_dma;
- struct usb_device *usbdev;
- struct usb_interface *intf;
- struct urb *irq;
- struct wacom_wac wacom_wac;
- struct mutex lock;
- struct work_struct work;
- bool open;
- char phys[32];
- struct wacom_led {
- u8 select[2]; /* status led selector (0..3) */
- u8 llv; /* status led brightness no button (1..127) */
- u8 hlv; /* status led brightness button pressed (1..127) */
- u8 img_lum; /* OLED matrix display brightness */
- } led;
- struct power_supply battery;
-};
-
-static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
-{
- struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
- schedule_work(&wacom->work);
-}
-
-extern const struct usb_device_id wacom_ids[];
-
-void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
-void wacom_setup_device_quirks(struct wacom_features *features);
-int wacom_setup_input_capabilities(struct input_dev *input_dev,
- struct wacom_wac *wacom_wac);
-#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
deleted file mode 100644
index 2c613cd41dd6..000000000000
--- a/drivers/input/tablet/wacom_sys.c
+++ /dev/null
@@ -1,1497 +0,0 @@
-/*
- * drivers/input/tablet/wacom_sys.c
- *
- * USB Wacom tablet support - system specific code
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include "wacom_wac.h"
-#include "wacom.h"
-
-/* defines to get HID report descriptor */
-#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
-#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
-#define HID_USAGE_UNDEFINED 0x00
-#define HID_USAGE_PAGE 0x05
-#define HID_USAGE_PAGE_DIGITIZER 0x0d
-#define HID_USAGE_PAGE_DESKTOP 0x01
-#define HID_USAGE 0x09
-#define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30)
-#define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31)
-#define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30)
-#define HID_USAGE_X_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3d)
-#define HID_USAGE_Y_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3e)
-#define HID_USAGE_FINGER ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x22)
-#define HID_USAGE_STYLUS ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x20)
-#define HID_USAGE_CONTACTMAX ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x55)
-#define HID_COLLECTION 0xa1
-#define HID_COLLECTION_LOGICAL 0x02
-#define HID_COLLECTION_END 0xc0
-
-struct hid_descriptor {
- struct usb_descriptor_header header;
- __le16 bcdHID;
- u8 bCountryCode;
- u8 bNumDescriptors;
- u8 bDescriptorType;
- __le16 wDescriptorLength;
-} __attribute__ ((packed));
-
-/* defines to get/set USB message */
-#define USB_REQ_GET_REPORT 0x01
-#define USB_REQ_SET_REPORT 0x09
-
-#define WAC_HID_FEATURE_REPORT 0x03
-#define WAC_MSG_RETRIES 5
-
-#define WAC_CMD_LED_CONTROL 0x20
-#define WAC_CMD_ICON_START 0x21
-#define WAC_CMD_ICON_XFER 0x23
-#define WAC_CMD_RETRIES 10
-
-static int wacom_get_report(struct usb_interface *intf, u8 type, u8 id,
- void *buf, size_t size, unsigned int retries)
-{
- struct usb_device *dev = interface_to_usbdev(intf);
- int retval;
-
- do {
- retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
- USB_REQ_GET_REPORT,
- USB_DIR_IN | USB_TYPE_CLASS |
- USB_RECIP_INTERFACE,
- (type << 8) + id,
- intf->altsetting[0].desc.bInterfaceNumber,
- buf, size, 100);
- } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
-
- return retval;
-}
-
-static int wacom_set_report(struct usb_interface *intf, u8 type, u8 id,
- void *buf, size_t size, unsigned int retries)
-{
- struct usb_device *dev = interface_to_usbdev(intf);
- int retval;
-
- do {
- retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_SET_REPORT,
- USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- (type << 8) + id,
- intf->altsetting[0].desc.bInterfaceNumber,
- buf, size, 1000);
- } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
-
- return retval;
-}
-
-static void wacom_sys_irq(struct urb *urb)
-{
- struct wacom *wacom = urb->context;
- struct device *dev = &wacom->intf->dev;
- int retval;
-
- switch (urb->status) {
- case 0:
- /* success */
- break;
- case -ECONNRESET:
- case -ENOENT:
- case -ESHUTDOWN:
- /* this urb is terminated, clean up */
- dev_dbg(dev, "%s - urb shutting down with status: %d\n",
- __func__, urb->status);
- return;
- default:
- dev_dbg(dev, "%s - nonzero urb status received: %d\n",
- __func__, urb->status);
- goto exit;
- }
-
- wacom_wac_irq(&wacom->wacom_wac, urb->actual_length);
-
- exit:
- usb_mark_last_busy(wacom->usbdev);
- retval = usb_submit_urb(urb, GFP_ATOMIC);
- if (retval)
- dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
- __func__, retval);
-}
-
-static int wacom_open(struct input_dev *dev)
-{
- struct wacom *wacom = input_get_drvdata(dev);
- int retval = 0;
-
- if (usb_autopm_get_interface(wacom->intf) < 0)
- return -EIO;
-
- mutex_lock(&wacom->lock);
-
- if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
- retval = -EIO;
- goto out;
- }
-
- wacom->open = true;
- wacom->intf->needs_remote_wakeup = 1;
-
-out:
- mutex_unlock(&wacom->lock);
- usb_autopm_put_interface(wacom->intf);
- return retval;
-}
-
-static void wacom_close(struct input_dev *dev)
-{
- struct wacom *wacom = input_get_drvdata(dev);
- int autopm_error;
-
- autopm_error = usb_autopm_get_interface(wacom->intf);
-
- mutex_lock(&wacom->lock);
- usb_kill_urb(wacom->irq);
- wacom->open = false;
- wacom->intf->needs_remote_wakeup = 0;
- mutex_unlock(&wacom->lock);
-
- if (!autopm_error)
- usb_autopm_put_interface(wacom->intf);
-}
-
-/*
- * Calculate the resolution of the X or Y axis, given appropriate HID data.
- * This function is little more than hidinput_calc_abs_res stripped down.
- */
-static int wacom_calc_hid_res(int logical_extents, int physical_extents,
- unsigned char unit, unsigned char exponent)
-{
- int prev, unit_exponent;
-
- /* Check if the extents are sane */
- if (logical_extents <= 0 || physical_extents <= 0)
- return 0;
-
- /* Get signed value of nybble-sized twos-compliment exponent */
- unit_exponent = exponent;
- if (unit_exponent > 7)
- unit_exponent -= 16;
-
- /* Convert physical_extents to millimeters */
- if (unit == 0x11) { /* If centimeters */
- unit_exponent += 1;
- } else if (unit == 0x13) { /* If inches */
- prev = physical_extents;
- physical_extents *= 254;
- if (physical_extents < prev)
- return 0;
- unit_exponent -= 1;
- } else {
- return 0;
- }
-
- /* Apply negative unit exponent */
- for (; unit_exponent < 0; unit_exponent++) {
- prev = logical_extents;
- logical_extents *= 10;
- if (logical_extents < prev)
- return 0;
- }
- /* Apply positive unit exponent */
- for (; unit_exponent > 0; unit_exponent--) {
- prev = physical_extents;
- physical_extents *= 10;
- if (physical_extents < prev)
- return 0;
- }
-
- /* Calculate resolution */
- return logical_extents / physical_extents;
-}
-
-static int wacom_parse_logical_collection(unsigned char *report,
- struct wacom_features *features)
-{
- int length = 0;
-
- if (features->type == BAMBOO_PT) {
-
- /* Logical collection is only used by 3rd gen Bamboo Touch */
- features->pktlen = WACOM_PKGLEN_BBTOUCH3;
- features->device_type = BTN_TOOL_FINGER;
-
- features->x_max = features->y_max =
- get_unaligned_le16(&report[10]);
-
- length = 11;
- }
- return length;
-}
-
-static void wacom_retrieve_report_data(struct usb_interface *intf,
- struct wacom_features *features)
-{
- int result = 0;
- unsigned char *rep_data;
-
- rep_data = kmalloc(2, GFP_KERNEL);
- if (rep_data) {
-
- rep_data[0] = 12;
- result = wacom_get_report(intf, WAC_HID_FEATURE_REPORT,
- rep_data[0], rep_data, 2,
- WAC_MSG_RETRIES);
-
- if (result >= 0 && rep_data[1] > 2)
- features->touch_max = rep_data[1];
-
- kfree(rep_data);
- }
-}
-
-/*
- * Interface Descriptor of wacom devices can be incomplete and
- * inconsistent so wacom_features table is used to store stylus
- * device's packet lengths, various maximum values, and tablet
- * resolution based on product ID's.
- *
- * For devices that contain 2 interfaces, wacom_features table is
- * inaccurate for the touch interface. Since the Interface Descriptor
- * for touch interfaces has pretty complete data, this function exists
- * to query tablet for this missing information instead of hard coding in
- * an additional table.
- *
- * A typical Interface Descriptor for a stylus will contain a
- * boot mouse application collection that is not of interest and this
- * function will ignore it.
- *
- * It also contains a digitizer application collection that also is not
- * of interest since any information it contains would be duplicate
- * of what is in wacom_features. Usually it defines a report of an array
- * of bytes that could be used as max length of the stylus packet returned.
- * If it happens to define a Digitizer-Stylus Physical Collection then
- * the X and Y logical values contain valid data but it is ignored.
- *
- * A typical Interface Descriptor for a touch interface will contain a
- * Digitizer-Finger Physical Collection which will define both logical
- * X/Y maximum as well as the physical size of tablet. Since touch
- * interfaces haven't supported pressure or distance, this is enough
- * information to override invalid values in the wacom_features table.
- *
- * 3rd gen Bamboo Touch no longer define a Digitizer-Finger Pysical
- * Collection. Instead they define a Logical Collection with a single
- * Logical Maximum for both X and Y.
- *
- * Intuos5 touch interface does not contain useful data. We deal with
- * this after returning from this function.
- */
-static int wacom_parse_hid(struct usb_interface *intf,
- struct hid_descriptor *hid_desc,
- struct wacom_features *features)
-{
- struct usb_device *dev = interface_to_usbdev(intf);
- char limit = 0;
- /* result has to be defined as int for some devices */
- int result = 0, touch_max = 0;
- int i = 0, page = 0, finger = 0, pen = 0;
- unsigned char *report;
-
- report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
- if (!report)
- return -ENOMEM;
-
- /* retrive report descriptors */
- do {
- result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
- USB_REQ_GET_DESCRIPTOR,
- USB_RECIP_INTERFACE | USB_DIR_IN,
- HID_DEVICET_REPORT << 8,
- intf->altsetting[0].desc.bInterfaceNumber, /* interface */
- report,
- hid_desc->wDescriptorLength,
- 5000); /* 5 secs */
- } while (result < 0 && limit++ < WAC_MSG_RETRIES);
-
- /* No need to parse the Descriptor. It isn't an error though */
- if (result < 0)
- goto out;
-
- for (i = 0; i < hid_desc->wDescriptorLength; i++) {
-
- switch (report[i]) {
- case HID_USAGE_PAGE:
- page = report[i + 1];
- i++;
- break;
-
- case HID_USAGE:
- switch (page << 16 | report[i + 1]) {
- case HID_USAGE_X:
- if (finger) {
- features->device_type = BTN_TOOL_FINGER;
- /* touch device at least supports one touch point */
- touch_max = 1;
- switch (features->type) {
- case TABLETPC2FG:
- features->pktlen = WACOM_PKGLEN_TPC2FG;
- break;
-
- case MTSCREEN:
- case WACOM_24HDT:
- features->pktlen = WACOM_PKGLEN_MTOUCH;
- break;
-
- case MTTPC:
- case MTTPC_B:
- features->pktlen = WACOM_PKGLEN_MTTPC;
- break;
-
- case BAMBOO_PT:
- features->pktlen = WACOM_PKGLEN_BBTOUCH;
- break;
-
- default:
- features->pktlen = WACOM_PKGLEN_GRAPHIRE;
- break;
- }
-
- switch (features->type) {
- case BAMBOO_PT:
- features->x_phy =
- get_unaligned_le16(&report[i + 5]);
- features->x_max =
- get_unaligned_le16(&report[i + 8]);
- i += 15;
- break;
-
- case WACOM_24HDT:
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- features->x_phy =
- get_unaligned_le16(&report[i + 8]);
- features->unit = report[i - 1];
- features->unitExpo = report[i - 3];
- i += 12;
- break;
-
- case MTTPC_B:
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- features->x_phy =
- get_unaligned_le16(&report[i + 6]);
- features->unit = report[i - 5];
- features->unitExpo = report[i - 3];
- i += 9;
- break;
-
- default:
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- features->x_phy =
- get_unaligned_le16(&report[i + 6]);
- features->unit = report[i + 9];
- features->unitExpo = report[i + 11];
- i += 12;
- break;
- }
- } else if (pen) {
- /* penabled only accepts exact bytes of data */
- if (features->type >= TABLETPC)
- features->pktlen = WACOM_PKGLEN_GRAPHIRE;
- features->device_type = BTN_TOOL_PEN;
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- }
- break;
-
- case HID_USAGE_Y:
- if (finger) {
- switch (features->type) {
- case TABLETPC2FG:
- case MTSCREEN:
- case MTTPC:
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- features->y_phy =
- get_unaligned_le16(&report[i + 6]);
- i += 7;
- break;
-
- case WACOM_24HDT:
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- features->y_phy =
- get_unaligned_le16(&report[i - 2]);
- i += 7;
- break;
-
- case BAMBOO_PT:
- features->y_phy =
- get_unaligned_le16(&report[i + 3]);
- features->y_max =
- get_unaligned_le16(&report[i + 6]);
- i += 12;
- break;
-
- case MTTPC_B:
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- features->y_phy =
- get_unaligned_le16(&report[i + 6]);
- i += 9;
- break;
-
- default:
- features->y_max =
- features->x_max;
- features->y_phy =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- break;
- }
- } else if (pen) {
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- }
- break;
-
- case HID_USAGE_FINGER:
- finger = 1;
- i++;
- break;
-
- /*
- * Requiring Stylus Usage will ignore boot mouse
- * X/Y values and some cases of invalid Digitizer X/Y
- * values commonly reported.
- */
- case HID_USAGE_STYLUS:
- pen = 1;
- i++;
- break;
-
- case HID_USAGE_CONTACTMAX:
- /* leave touch_max as is if predefined */
- if (!features->touch_max)
- wacom_retrieve_report_data(intf, features);
- i++;
- break;
-
- case HID_USAGE_PRESSURE:
- if (pen) {
- features->pressure_max =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- }
- break;
- }
- break;
-
- case HID_COLLECTION_END:
- /* reset UsagePage and Finger */
- finger = page = 0;
- break;
-
- case HID_COLLECTION:
- i++;
- switch (report[i]) {
- case HID_COLLECTION_LOGICAL:
- i += wacom_parse_logical_collection(&report[i],
- features);
- break;
- }
- break;
- }
- }
-
- out:
- if (!features->touch_max && touch_max)
- features->touch_max = touch_max;
- result = 0;
- kfree(report);
- return result;
-}
-
-static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int length, int mode)
-{
- unsigned char *rep_data;
- int error = -ENOMEM, limit = 0;
-
- rep_data = kzalloc(length, GFP_KERNEL);
- if (!rep_data)
- return error;
-
- do {
- rep_data[0] = report_id;
- rep_data[1] = mode;
-
- error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
- report_id, rep_data, length, 1);
- } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
-
- kfree(rep_data);
-
- return error < 0 ? error : 0;
-}
-
-/*
- * Switch the tablet into its most-capable mode. Wacom tablets are
- * typically configured to power-up in a mode which sends mouse-like
- * reports to the OS. To get absolute position, pressure data, etc.
- * from the tablet, it is necessary to switch the tablet out of this
- * mode and into one which sends the full range of tablet data.
- */
-static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
-{
- if (features->device_type == BTN_TOOL_FINGER) {
- if (features->type > TABLETPC) {
- /* MT Tablet PC touch */
- return wacom_set_device_mode(intf, 3, 4, 4);
- }
- else if (features->type == WACOM_24HDT || features->type == CINTIQ_HYBRID) {
- return wacom_set_device_mode(intf, 18, 3, 2);
- }
- } else if (features->device_type == BTN_TOOL_PEN) {
- if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
- return wacom_set_device_mode(intf, 2, 2, 2);
- }
- }
-
- return 0;
-}
-
-static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
- struct wacom_features *features)
-{
- int error = 0;
- struct usb_host_interface *interface = intf->cur_altsetting;
- struct hid_descriptor *hid_desc;
-
- /* default features */
- features->device_type = BTN_TOOL_PEN;
- features->x_fuzz = 4;
- features->y_fuzz = 4;
- features->pressure_fuzz = 0;
- features->distance_fuzz = 0;
-
- /*
- * The wireless device HID is basic and layout conflicts with
- * other tablets (monitor and touch interface can look like pen).
- * Skip the query for this type and modify defaults based on
- * interface number.
- */
- if (features->type == WIRELESS) {
- if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
- features->device_type = 0;
- } else if (intf->cur_altsetting->desc.bInterfaceNumber == 2) {
- features->device_type = BTN_TOOL_FINGER;
- features->pktlen = WACOM_PKGLEN_BBTOUCH3;
- }
- }
-
- /* only devices that support touch need to retrieve the info */
- if (features->type < BAMBOO_PT) {
- goto out;
- }
-
- error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc);
- if (error) {
- error = usb_get_extra_descriptor(&interface->endpoint[0],
- HID_DEVICET_REPORT, &hid_desc);
- if (error) {
- dev_err(&intf->dev,
- "can not retrieve extra class descriptor\n");
- goto out;
- }
- }
- error = wacom_parse_hid(intf, hid_desc, features);
-
- out:
- return error;
-}
-
-struct wacom_usbdev_data {
- struct list_head list;
- struct kref kref;
- struct usb_device *dev;
- struct wacom_shared shared;
-};
-
-static LIST_HEAD(wacom_udev_list);
-static DEFINE_MUTEX(wacom_udev_list_lock);
-
-static struct usb_device *wacom_get_sibling(struct usb_device *dev, int vendor, int product)
-{
- int port1;
- struct usb_device *sibling;
-
- if (vendor == 0 && product == 0)
- return dev;
-
- if (dev->parent == NULL)
- return NULL;
-
- usb_hub_for_each_child(dev->parent, port1, sibling) {
- struct usb_device_descriptor *d;
- if (sibling == NULL)
- continue;
-
- d = &sibling->descriptor;
- if (d->idVendor == vendor && d->idProduct == product)
- return sibling;
- }
-
- return NULL;
-}
-
-static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
-{
- struct wacom_usbdev_data *data;
-
- list_for_each_entry(data, &wacom_udev_list, list) {
- if (data->dev == dev) {
- kref_get(&data->kref);
- return data;
- }
- }
-
- return NULL;
-}
-
-static int wacom_add_shared_data(struct wacom_wac *wacom,
- struct usb_device *dev)
-{
- struct wacom_usbdev_data *data;
- int retval = 0;
-
- mutex_lock(&wacom_udev_list_lock);
-
- data = wacom_get_usbdev_data(dev);
- if (!data) {
- data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL);
- if (!data) {
- retval = -ENOMEM;
- goto out;
- }
-
- kref_init(&data->kref);
- data->dev = dev;
- list_add_tail(&data->list, &wacom_udev_list);
- }
-
- wacom->shared = &data->shared;
-
-out:
- mutex_unlock(&wacom_udev_list_lock);
- return retval;
-}
-
-static void wacom_release_shared_data(struct kref *kref)
-{
- struct wacom_usbdev_data *data =
- container_of(kref, struct wacom_usbdev_data, kref);
-
- mutex_lock(&wacom_udev_list_lock);
- list_del(&data->list);
- mutex_unlock(&wacom_udev_list_lock);
-
- kfree(data);
-}
-
-static void wacom_remove_shared_data(struct wacom_wac *wacom)
-{
- struct wacom_usbdev_data *data;
-
- if (wacom->shared) {
- data = container_of(wacom->shared, struct wacom_usbdev_data, shared);
- kref_put(&data->kref, wacom_release_shared_data);
- wacom->shared = NULL;
- }
-}
-
-static int wacom_led_control(struct wacom *wacom)
-{
- unsigned char *buf;
- int retval;
-
- buf = kzalloc(9, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- if (wacom->wacom_wac.features.type >= INTUOS5S &&
- wacom->wacom_wac.features.type <= INTUOSPL) {
- /*
- * Touch Ring and crop mark LED luminance may take on
- * one of four values:
- * 0 = Low; 1 = Medium; 2 = High; 3 = Off
- */
- int ring_led = wacom->led.select[0] & 0x03;
- int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03;
- int crop_lum = 0;
-
- buf[0] = WAC_CMD_LED_CONTROL;
- buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led);
- }
- else {
- int led = wacom->led.select[0] | 0x4;
-
- if (wacom->wacom_wac.features.type == WACOM_21UX2 ||
- wacom->wacom_wac.features.type == WACOM_24HD)
- led |= (wacom->led.select[1] << 4) | 0x40;
-
- buf[0] = WAC_CMD_LED_CONTROL;
- buf[1] = led;
- buf[2] = wacom->led.llv;
- buf[3] = wacom->led.hlv;
- buf[4] = wacom->led.img_lum;
- }
-
- retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL,
- buf, 9, WAC_CMD_RETRIES);
- kfree(buf);
-
- return retval;
-}
-
-static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *img)
-{
- unsigned char *buf;
- int i, retval;
-
- buf = kzalloc(259, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- /* Send 'start' command */
- buf[0] = WAC_CMD_ICON_START;
- buf[1] = 1;
- retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
- buf, 2, WAC_CMD_RETRIES);
- if (retval < 0)
- goto out;
-
- buf[0] = WAC_CMD_ICON_XFER;
- buf[1] = button_id & 0x07;
- for (i = 0; i < 4; i++) {
- buf[2] = i;
- memcpy(buf + 3, img + i * 256, 256);
-
- retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_XFER,
- buf, 259, WAC_CMD_RETRIES);
- if (retval < 0)
- break;
- }
-
- /* Send 'stop' */
- buf[0] = WAC_CMD_ICON_START;
- buf[1] = 0;
- wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
- buf, 2, WAC_CMD_RETRIES);
-
-out:
- kfree(buf);
- return retval;
-}
-
-static ssize_t wacom_led_select_store(struct device *dev, int set_id,
- const char *buf, size_t count)
-{
- struct wacom *wacom = dev_get_drvdata(dev);
- unsigned int id;
- int err;
-
- err = kstrtouint(buf, 10, &id);
- if (err)
- return err;
-
- mutex_lock(&wacom->lock);
-
- wacom->led.select[set_id] = id & 0x3;
- err = wacom_led_control(wacom);
-
- mutex_unlock(&wacom->lock);
-
- return err < 0 ? err : count;
-}
-
-#define DEVICE_LED_SELECT_ATTR(SET_ID) \
-static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
- struct device_attribute *attr, const char *buf, size_t count) \
-{ \
- return wacom_led_select_store(dev, SET_ID, buf, count); \
-} \
-static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
- struct device_attribute *attr, char *buf) \
-{ \
- struct wacom *wacom = dev_get_drvdata(dev); \
- return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
-} \
-static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
- wacom_led##SET_ID##_select_show, \
- wacom_led##SET_ID##_select_store)
-
-DEVICE_LED_SELECT_ATTR(0);
-DEVICE_LED_SELECT_ATTR(1);
-
-static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
- const char *buf, size_t count)
-{
- unsigned int value;
- int err;
-
- err = kstrtouint(buf, 10, &value);
- if (err)
- return err;
-
- mutex_lock(&wacom->lock);
-
- *dest = value & 0x7f;
- err = wacom_led_control(wacom);
-
- mutex_unlock(&wacom->lock);
-
- return err < 0 ? err : count;
-}
-
-#define DEVICE_LUMINANCE_ATTR(name, field) \
-static ssize_t wacom_##name##_luminance_store(struct device *dev, \
- struct device_attribute *attr, const char *buf, size_t count) \
-{ \
- struct wacom *wacom = dev_get_drvdata(dev); \
- \
- return wacom_luminance_store(wacom, &wacom->led.field, \
- buf, count); \
-} \
-static DEVICE_ATTR(name##_luminance, S_IWUSR, \
- NULL, wacom_##name##_luminance_store)
-
-DEVICE_LUMINANCE_ATTR(status0, llv);
-DEVICE_LUMINANCE_ATTR(status1, hlv);
-DEVICE_LUMINANCE_ATTR(buttons, img_lum);
-
-static ssize_t wacom_button_image_store(struct device *dev, int button_id,
- const char *buf, size_t count)
-{
- struct wacom *wacom = dev_get_drvdata(dev);
- int err;
-
- if (count != 1024)
- return -EINVAL;
-
- mutex_lock(&wacom->lock);
-
- err = wacom_led_putimage(wacom, button_id, buf);
-
- mutex_unlock(&wacom->lock);
-</