2009-05-11 22:18:12 +07:00
|
|
|
/*
|
|
|
|
* Bluetooth Wacom Tablet support
|
|
|
|
*
|
|
|
|
* Copyright (c) 1999 Andreas Gal
|
|
|
|
* Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
|
|
|
|
* Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
|
|
|
|
* Copyright (c) 2006-2007 Jiri Kosina
|
|
|
|
* Copyright (c) 2007 Paul Walmsley
|
|
|
|
* Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
|
|
|
|
* Copyright (c) 2006 Andrew Zabolotny <zap@homelink.ru>
|
|
|
|
* Copyright (c) 2009 Bastien Nocera <hadess@hadess.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2010-12-10 10:29:03 +07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-05-11 22:18:12 +07:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/hid.h>
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2010-03-16 02:16:23 +07:00
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
#include <linux/power_supply.h>
|
|
|
|
#endif
|
2009-05-11 22:18:12 +07:00
|
|
|
|
|
|
|
#include "hid-ids.h"
|
|
|
|
|
|
|
|
struct wacom_data {
|
|
|
|
__u16 tool;
|
|
|
|
unsigned char butstate;
|
2010-03-18 21:34:34 +07:00
|
|
|
unsigned char high_speed;
|
2010-03-16 02:16:23 +07:00
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
int battery_capacity;
|
|
|
|
struct power_supply battery;
|
|
|
|
struct power_supply ac;
|
|
|
|
#endif
|
2009-05-11 22:18:12 +07:00
|
|
|
};
|
|
|
|
|
2010-03-16 02:16:23 +07:00
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
/*percent of battery capacity, 0 means AC online*/
|
|
|
|
static unsigned short batcap[8] = { 1, 15, 25, 35, 50, 70, 100, 0 };
|
|
|
|
|
|
|
|
static enum power_supply_property wacom_battery_props[] = {
|
|
|
|
POWER_SUPPLY_PROP_PRESENT,
|
|
|
|
POWER_SUPPLY_PROP_CAPACITY
|
|
|
|
};
|
|
|
|
|
|
|
|
static enum power_supply_property wacom_ac_props[] = {
|
|
|
|
POWER_SUPPLY_PROP_PRESENT,
|
|
|
|
POWER_SUPPLY_PROP_ONLINE
|
|
|
|
};
|
|
|
|
|
|
|
|
static int wacom_battery_get_property(struct power_supply *psy,
|
|
|
|
enum power_supply_property psp,
|
|
|
|
union power_supply_propval *val)
|
|
|
|
{
|
|
|
|
struct wacom_data *wdata = container_of(psy,
|
|
|
|
struct wacom_data, battery);
|
|
|
|
int power_state = batcap[wdata->battery_capacity];
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch (psp) {
|
|
|
|
case POWER_SUPPLY_PROP_PRESENT:
|
|
|
|
val->intval = 1;
|
|
|
|
break;
|
|
|
|
case POWER_SUPPLY_PROP_CAPACITY:
|
|
|
|
/* show 100% battery capacity when charging */
|
|
|
|
if (power_state == 0)
|
|
|
|
val->intval = 100;
|
|
|
|
else
|
|
|
|
val->intval = power_state;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wacom_ac_get_property(struct power_supply *psy,
|
|
|
|
enum power_supply_property psp,
|
|
|
|
union power_supply_propval *val)
|
|
|
|
{
|
|
|
|
struct wacom_data *wdata = container_of(psy, struct wacom_data, ac);
|
|
|
|
int power_state = batcap[wdata->battery_capacity];
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch (psp) {
|
|
|
|
case POWER_SUPPLY_PROP_PRESENT:
|
|
|
|
/* fall through */
|
|
|
|
case POWER_SUPPLY_PROP_ONLINE:
|
|
|
|
if (power_state == 0)
|
|
|
|
val->intval = 1;
|
|
|
|
else
|
|
|
|
val->intval = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-22 15:55:04 +07:00
|
|
|
static void wacom_poke(struct hid_device *hdev, u8 speed)
|
|
|
|
{
|
2010-03-18 21:34:34 +07:00
|
|
|
struct wacom_data *wdata = hid_get_drvdata(hdev);
|
2010-03-22 15:55:04 +07:00
|
|
|
int limit, ret;
|
|
|
|
char rep_data[2];
|
|
|
|
|
|
|
|
rep_data[0] = 0x03 ; rep_data[1] = 0x00;
|
|
|
|
limit = 3;
|
|
|
|
do {
|
|
|
|
ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
|
|
|
|
HID_FEATURE_REPORT);
|
|
|
|
} while (ret < 0 && limit-- > 0);
|
|
|
|
|
|
|
|
if (ret >= 0) {
|
|
|
|
if (speed == 0)
|
|
|
|
rep_data[0] = 0x05;
|
|
|
|
else
|
|
|
|
rep_data[0] = 0x06;
|
|
|
|
|
|
|
|
rep_data[1] = 0x00;
|
|
|
|
limit = 3;
|
|
|
|
do {
|
|
|
|
ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
|
|
|
|
HID_FEATURE_REPORT);
|
|
|
|
} while (ret < 0 && limit-- > 0);
|
|
|
|
|
2010-03-18 21:34:34 +07:00
|
|
|
if (ret >= 0) {
|
|
|
|
wdata->high_speed = speed;
|
2010-03-22 15:55:04 +07:00
|
|
|
return;
|
2010-03-18 21:34:34 +07:00
|
|
|
}
|
2010-03-22 15:55:04 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that if the raw queries fail, it's not a hard failure and it
|
|
|
|
* is safe to continue
|
|
|
|
*/
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_warn(hdev, "failed to poke device, command %d, err %d\n",
|
|
|
|
rep_data[0], ret);
|
2010-03-22 15:55:04 +07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-18 21:34:34 +07:00
|
|
|
static ssize_t wacom_show_speed(struct device *dev,
|
|
|
|
struct device_attribute
|
|
|
|
*attr, char *buf)
|
|
|
|
{
|
|
|
|
struct wacom_data *wdata = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%i\n", wdata->high_speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t wacom_store_speed(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct hid_device *hdev = container_of(dev, struct hid_device, dev);
|
|
|
|
int new_speed;
|
|
|
|
|
|
|
|
if (sscanf(buf, "%1d", &new_speed ) != 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (new_speed == 0 || new_speed == 1) {
|
|
|
|
wacom_poke(hdev, new_speed);
|
|
|
|
return strnlen(buf, PAGE_SIZE);
|
|
|
|
} else
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-11-18 22:28:43 +07:00
|
|
|
static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP,
|
2010-03-18 21:34:34 +07:00
|
|
|
wacom_show_speed, wacom_store_speed);
|
|
|
|
|
2009-05-11 22:18:12 +07:00
|
|
|
static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
|
|
|
|
u8 *raw_data, int size)
|
|
|
|
{
|
|
|
|
struct wacom_data *wdata = hid_get_drvdata(hdev);
|
|
|
|
struct hid_input *hidinput;
|
|
|
|
struct input_dev *input;
|
|
|
|
unsigned char *data = (unsigned char *) raw_data;
|
|
|
|
int tool, x, y, rw;
|
|
|
|
|
|
|
|
if (!(hdev->claimed & HID_CLAIMED_INPUT))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
tool = 0;
|
|
|
|
hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
|
|
|
|
input = hidinput->input;
|
|
|
|
|
|
|
|
/* Check if this is a tablet report */
|
|
|
|
if (data[0] != 0x03)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Get X & Y positions */
|
|
|
|
x = le16_to_cpu(*(__le16 *) &data[2]);
|
|
|
|
y = le16_to_cpu(*(__le16 *) &data[4]);
|
|
|
|
|
|
|
|
/* Get current tool identifier */
|
|
|
|
if (data[1] & 0x90) { /* If pen is in the in/active area */
|
|
|
|
switch ((data[1] >> 5) & 3) {
|
|
|
|
case 0: /* Pen */
|
|
|
|
tool = BTN_TOOL_PEN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Rubber */
|
|
|
|
tool = BTN_TOOL_RUBBER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Mouse with wheel */
|
|
|
|
case 3: /* Mouse without wheel */
|
|
|
|
tool = BTN_TOOL_MOUSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset tool if out of active tablet area */
|
|
|
|
if (!(data[1] & 0x10))
|
|
|
|
tool = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If tool changed, notify input subsystem */
|
|
|
|
if (wdata->tool != tool) {
|
|
|
|
if (wdata->tool) {
|
|
|
|
/* Completely reset old tool state */
|
|
|
|
if (wdata->tool == BTN_TOOL_MOUSE) {
|
|
|
|
input_report_key(input, BTN_LEFT, 0);
|
|
|
|
input_report_key(input, BTN_RIGHT, 0);
|
|
|
|
input_report_key(input, BTN_MIDDLE, 0);
|
|
|
|
input_report_abs(input, ABS_DISTANCE,
|
2010-08-03 10:15:17 +07:00
|
|
|
input_abs_get_max(input, ABS_DISTANCE));
|
2009-05-11 22:18:12 +07:00
|
|
|
} else {
|
|
|
|
input_report_key(input, BTN_TOUCH, 0);
|
|
|
|
input_report_key(input, BTN_STYLUS, 0);
|
|
|
|
input_report_key(input, BTN_STYLUS2, 0);
|
|
|
|
input_report_abs(input, ABS_PRESSURE, 0);
|
|
|
|
}
|
|
|
|
input_report_key(input, wdata->tool, 0);
|
|
|
|
input_sync(input);
|
|
|
|
}
|
|
|
|
wdata->tool = tool;
|
|
|
|
if (tool)
|
|
|
|
input_report_key(input, tool, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tool) {
|
|
|
|
input_report_abs(input, ABS_X, x);
|
|
|
|
input_report_abs(input, ABS_Y, y);
|
|
|
|
|
|
|
|
switch ((data[1] >> 5) & 3) {
|
|
|
|
case 2: /* Mouse with wheel */
|
|
|
|
input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
|
|
|
|
rw = (data[6] & 0x01) ? -1 :
|
|
|
|
(data[6] & 0x02) ? 1 : 0;
|
|
|
|
input_report_rel(input, REL_WHEEL, rw);
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case 3: /* Mouse without wheel */
|
|
|
|
input_report_key(input, BTN_LEFT, data[1] & 0x01);
|
|
|
|
input_report_key(input, BTN_RIGHT, data[1] & 0x02);
|
|
|
|
/* Compute distance between mouse and tablet */
|
|
|
|
rw = 44 - (data[6] >> 2);
|
|
|
|
if (rw < 0)
|
|
|
|
rw = 0;
|
|
|
|
else if (rw > 31)
|
|
|
|
rw = 31;
|
|
|
|
input_report_abs(input, ABS_DISTANCE, rw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
input_report_abs(input, ABS_PRESSURE,
|
|
|
|
data[6] | (((__u16) (data[1] & 0x08)) << 5));
|
|
|
|
input_report_key(input, BTN_TOUCH, data[1] & 0x01);
|
|
|
|
input_report_key(input, BTN_STYLUS, data[1] & 0x02);
|
|
|
|
input_report_key(input, BTN_STYLUS2, (tool == BTN_TOOL_PEN) && data[1] & 0x04);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
input_sync(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Report the state of the two buttons at the top of the tablet
|
|
|
|
* as two extra fingerpad keys (buttons 4 & 5). */
|
|
|
|
rw = data[7] & 0x03;
|
|
|
|
if (rw != wdata->butstate) {
|
|
|
|
wdata->butstate = rw;
|
|
|
|
input_report_key(input, BTN_0, rw & 0x02);
|
|
|
|
input_report_key(input, BTN_1, rw & 0x01);
|
2010-01-09 21:20:03 +07:00
|
|
|
input_report_key(input, BTN_TOOL_FINGER, 0xf0);
|
2009-05-11 22:18:12 +07:00
|
|
|
input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
|
|
|
|
input_sync(input);
|
|
|
|
}
|
|
|
|
|
2010-03-16 02:16:23 +07:00
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
/* Store current battery capacity */
|
|
|
|
rw = (data[7] >> 2 & 0x07);
|
|
|
|
if (rw != wdata->battery_capacity)
|
|
|
|
wdata->battery_capacity = rw;
|
|
|
|
#endif
|
2009-05-11 22:18:12 +07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wacom_probe(struct hid_device *hdev,
|
|
|
|
const struct hid_device_id *id)
|
|
|
|
{
|
|
|
|
struct hid_input *hidinput;
|
|
|
|
struct input_dev *input;
|
|
|
|
struct wacom_data *wdata;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
|
|
|
|
if (wdata == NULL) {
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_err(hdev, "can't alloc wacom descriptor\n");
|
2009-05-11 22:18:12 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
hid_set_drvdata(hdev, wdata);
|
|
|
|
|
2010-01-20 19:00:53 +07:00
|
|
|
/* Parse the HID report now */
|
2009-05-11 22:18:12 +07:00
|
|
|
ret = hid_parse(hdev);
|
|
|
|
if (ret) {
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_err(hdev, "parse failed\n");
|
2009-05-11 22:18:12 +07:00
|
|
|
goto err_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
|
|
|
if (ret) {
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_err(hdev, "hw start failed\n");
|
2009-05-11 22:18:12 +07:00
|
|
|
goto err_free;
|
|
|
|
}
|
|
|
|
|
2010-03-18 21:34:34 +07:00
|
|
|
ret = device_create_file(&hdev->dev, &dev_attr_speed);
|
|
|
|
if (ret)
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_warn(hdev,
|
|
|
|
"can't create sysfs speed attribute err: %d\n", ret);
|
2010-02-03 21:52:31 +07:00
|
|
|
|
2010-03-22 15:55:04 +07:00
|
|
|
/* Set Wacom mode 2 with high reporting speed */
|
|
|
|
wacom_poke(hdev, 1);
|
2010-01-20 19:00:53 +07:00
|
|
|
|
2010-03-16 02:16:23 +07:00
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
wdata->battery.properties = wacom_battery_props;
|
|
|
|
wdata->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
|
|
|
|
wdata->battery.get_property = wacom_battery_get_property;
|
|
|
|
wdata->battery.name = "wacom_battery";
|
|
|
|
wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
|
|
|
|
wdata->battery.use_for_apm = 0;
|
2010-01-20 19:00:53 +07:00
|
|
|
|
2010-03-16 02:16:23 +07:00
|
|
|
ret = power_supply_register(&hdev->dev, &wdata->battery);
|
|
|
|
if (ret) {
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n",
|
|
|
|
ret);
|
2010-03-16 02:16:23 +07:00
|
|
|
/*
|
|
|
|
* battery attribute is not critical for the tablet, but if it
|
|
|
|
* failed then there is no need to create ac attribute
|
|
|
|
*/
|
|
|
|
goto move_on;
|
|
|
|
}
|
|
|
|
|
|
|
|
wdata->ac.properties = wacom_ac_props;
|
|
|
|
wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
|
|
|
|
wdata->ac.get_property = wacom_ac_get_property;
|
|
|
|
wdata->ac.name = "wacom_ac";
|
|
|
|
wdata->ac.type = POWER_SUPPLY_TYPE_MAINS;
|
|
|
|
wdata->ac.use_for_apm = 0;
|
|
|
|
|
|
|
|
ret = power_supply_register(&hdev->dev, &wdata->ac);
|
|
|
|
if (ret) {
|
2010-12-10 10:29:03 +07:00
|
|
|
hid_warn(hdev,
|
|
|
|
"can't create ac battery attribute, err: %d\n", ret);
|
2010-03-16 02:16:23 +07:00
|
|
|
/*
|
|
|
|
* ac attribute is not critical for the tablet, but if it
|
|
|
|
* failed then we don't want to battery attribute to exist
|
|
|
|
*/
|
|
|
|
power_supply_unregister(&wdata->battery);
|
|
|
|
}
|
|
|
|
|
|
|
|
move_on:
|
|
|
|
#endif
|
2009-05-11 22:18:12 +07:00
|
|
|
hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
|
|
|
|
input = hidinput->input;
|
|
|
|
|
|
|
|
/* Basics */
|
|
|
|
input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL);
|
2010-08-03 10:15:17 +07:00
|
|
|
|
|
|
|
__set_bit(REL_WHEEL, input->relbit);
|
|
|
|
|
|
|
|
__set_bit(BTN_TOOL_PEN, input->keybit);
|
|
|
|
__set_bit(BTN_TOUCH, input->keybit);
|
|
|
|
__set_bit(BTN_STYLUS, input->keybit);
|
|
|
|
__set_bit(BTN_STYLUS2, input->keybit);
|
|
|
|
__set_bit(BTN_LEFT, input->keybit);
|
|
|
|
__set_bit(BTN_RIGHT, input->keybit);
|
|
|
|
__set_bit(BTN_MIDDLE, input->keybit);
|
2009-05-11 22:18:12 +07:00
|
|
|
|
|
|
|
/* Pad */
|
|
|
|
input->evbit[0] |= BIT(EV_MSC);
|
|
|
|
|
2010-08-03 10:15:17 +07:00
|
|
|
__set_bit(MSC_SERIAL, input->mscbit);
|
2009-05-11 22:18:12 +07:00
|
|
|
|
2010-08-03 10:15:17 +07:00
|
|
|
__set_bit(BTN_0, input->keybit);
|
|
|
|
__set_bit(BTN_1, input->keybit);
|
|
|
|
__set_bit(BTN_TOOL_FINGER, input->keybit);
|
2009-05-11 22:18:12 +07:00
|
|
|
|
2010-08-03 10:15:17 +07:00
|
|
|
/* Distance, rubber and mouse */
|
|
|
|
__set_bit(BTN_TOOL_RUBBER, input->keybit);
|
|
|
|
__set_bit(BTN_TOOL_MOUSE, input->keybit);
|
|
|
|
|
|
|
|
input_set_abs_params(input, ABS_X, 0, 16704, 4, 0);
|
|
|
|
input_set_abs_params(input, ABS_Y, 0, 12064, 4, 0);
|
|
|
|
input_set_abs_params(input, ABS_PRESSURE, 0, 511, 0, 0);
|
|
|
|
input_set_abs_params(input, ABS_DISTANCE, 0, 32, 0, 0);
|
2009-05-11 22:18:12 +07:00
|
|
|
|
|
|
|
return 0;
|
2010-08-03 10:15:17 +07:00
|
|
|
|
2009-05-11 22:18:12 +07:00
|
|
|
err_free:
|
|
|
|
kfree(wdata);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wacom_remove(struct hid_device *hdev)
|
|
|
|
{
|
2010-03-16 02:16:23 +07:00
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
struct wacom_data *wdata = hid_get_drvdata(hdev);
|
|
|
|
#endif
|
2009-05-11 22:18:12 +07:00
|
|
|
hid_hw_stop(hdev);
|
2010-03-16 02:16:23 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
|
|
|
power_supply_unregister(&wdata->battery);
|
|
|
|
power_supply_unregister(&wdata->ac);
|
|
|
|
#endif
|
2009-05-11 22:18:12 +07:00
|
|
|
kfree(hid_get_drvdata(hdev));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct hid_device_id wacom_devices[] = {
|
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
|
2010-07-20 22:48:48 +07:00
|
|
|
|
2009-05-11 22:18:12 +07:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(hid, wacom_devices);
|
|
|
|
|
|
|
|
static struct hid_driver wacom_driver = {
|
|
|
|
.name = "wacom",
|
|
|
|
.id_table = wacom_devices,
|
|
|
|
.probe = wacom_probe,
|
|
|
|
.remove = wacom_remove,
|
|
|
|
.raw_event = wacom_raw_event,
|
|
|
|
};
|
|
|
|
|
2009-07-03 00:08:38 +07:00
|
|
|
static int __init wacom_init(void)
|
2009-05-11 22:18:12 +07:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hid_register_driver(&wacom_driver);
|
|
|
|
if (ret)
|
2010-12-10 10:29:03 +07:00
|
|
|
pr_err("can't register wacom driver\n");
|
2009-05-11 22:18:12 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-07-03 00:08:38 +07:00
|
|
|
static void __exit wacom_exit(void)
|
2009-05-11 22:18:12 +07:00
|
|
|
{
|
|
|
|
hid_unregister_driver(&wacom_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(wacom_init);
|
|
|
|
module_exit(wacom_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|