* [PATCH v2 02/10] Input - wacom: put a flag when the led are initialized
From: Benjamin Tissoires @ 2014-07-24 18:13 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
This solves a bug with the wireless receiver:
- at plug, the wireless receiver does not know which Wacom device it is
connected to, so it does not actually creates all the LEDs
- when the tablet connects, wacom->wacom_wac.features.type is set to the
proper device so that wacom_wac can understand the packets
- when the receiver is unplugged, it detects that a LED should have been
created (based on wacom->wacom_wac.features.type) and tries to remove
it: crash when removing the sysfs group.
Side effect, we can now safely call several times wacom_destroy_leds().
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
---
no changes in v2
drivers/hid/wacom.h | 1 +
drivers/hid/wacom_sys.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index dd67b7d..a678f82 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -118,6 +118,7 @@ struct wacom {
u8 hlv; /* status led brightness button pressed (1..127) */
u8 img_lum; /* OLED matrix display brightness */
} led;
+ bool led_initialized;
struct power_supply battery;
};
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 9dbb6dd..c857b3d 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -729,12 +729,18 @@ static int wacom_initialize_leds(struct wacom *wacom)
return error;
}
wacom_led_control(wacom);
+ wacom->led_initialized = true;
return 0;
}
static void wacom_destroy_leds(struct wacom *wacom)
{
+ if (!wacom->led_initialized)
+ return;
+
+ wacom->led_initialized = false;
+
switch (wacom->wacom_wac.features.type) {
case INTUOS4S:
case INTUOS4:
--
2.0.1
^ permalink raw reply related
* [PATCH v2 03/10] Input - wacom: enhance Wireless Receiver battery reporting
From: Benjamin Tissoires @ 2014-07-24 18:13 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
- Reports the current status of the battery (discharging, charging, full).
- Also notify the upower daemon when there is a change in the battery
value.
- keep the battery value as a percentage, not the raw value
- add WACOM_QUIRK_BATTERY to easily add a battery to a device (required
for Bluetooth devices)
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
changes in v2:
- add WACOM_QUIRK_BATTERY, which simplifies a bit the other patches
drivers/hid/wacom.h | 6 ++++++
drivers/hid/wacom_sys.c | 19 +++++++++++++++----
drivers/hid/wacom_wac.c | 22 ++++++++++++++++++----
drivers/hid/wacom_wac.h | 3 +++
4 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index a678f82..99516ba 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -128,6 +128,12 @@ static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
schedule_work(&wacom->work);
}
+static inline void wacom_notify_battery(struct wacom_wac *wacom_wac)
+{
+ struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
+ power_supply_changed(&wacom->battery);
+}
+
extern const struct hid_device_id wacom_ids[];
void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index c857b3d..f0ee7ff 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -769,6 +769,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
}
static enum power_supply_property wacom_battery_props[] = {
+ POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_CAPACITY
};
@@ -786,7 +787,16 @@ static int wacom_battery_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_CAPACITY:
val->intval =
- wacom->wacom_wac.battery_capacity * 100 / 31;
+ wacom->wacom_wac.battery_capacity;
+ break;
+ case POWER_SUPPLY_PROP_STATUS:
+ if (wacom->wacom_wac.bat_charging)
+ val->intval = POWER_SUPPLY_STATUS_CHARGING;
+ else if (wacom->wacom_wac.battery_capacity == 100 &&
+ wacom->wacom_wac.ps_connected)
+ val->intval = POWER_SUPPLY_STATUS_FULL;
+ else
+ val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
break;
default:
ret = -EINVAL;
@@ -800,7 +810,7 @@ static int wacom_initialize_battery(struct wacom *wacom)
{
int error = 0;
- if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) {
+ if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) {
wacom->battery.properties = wacom_battery_props;
wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
wacom->battery.get_property = wacom_battery_get_property;
@@ -821,8 +831,8 @@ static int wacom_initialize_battery(struct wacom *wacom)
static void wacom_destroy_battery(struct wacom *wacom)
{
- if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR &&
- wacom->battery.dev) {
+ if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
+ wacom->battery.dev) {
power_supply_unregister(&wacom->battery);
wacom->battery.dev = NULL;
}
@@ -947,6 +957,7 @@ static void wacom_wireless_work(struct work_struct *work)
if (wacom_wac->pid == 0) {
hid_info(wacom->hdev, "wireless tablet disconnected\n");
+ wacom_wac1->shared->type = 0;
} else {
const struct hid_device_id *id = wacom_ids;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index f30083f..2c69326 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1365,7 +1365,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
connected = data[1] & 0x01;
if (connected) {
- int pid, battery;
+ int pid, battery, ps_connected;
if ((wacom->shared->type == INTUOSHT) &&
wacom->shared->touch_max) {
@@ -1375,17 +1375,29 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
}
pid = get_unaligned_be16(&data[6]);
- battery = data[5] & 0x3f;
+ battery = (data[5] & 0x3f) * 100 / 31;
+ ps_connected = !!(data[5] & 0x80);
if (wacom->pid != pid) {
wacom->pid = pid;
wacom_schedule_work(wacom);
}
- wacom->battery_capacity = battery;
+
+ if (wacom->shared->type &&
+ ((battery != wacom->battery_capacity) ||
+ (ps_connected != wacom->ps_connected))) {
+ wacom->battery_capacity = battery;
+ wacom->ps_connected = ps_connected;
+ wacom->bat_charging = ps_connected &&
+ wacom->battery_capacity < 100;
+ wacom_notify_battery(wacom);
+ }
} else if (wacom->pid != 0) {
/* disconnected while previously connected */
wacom->pid = 0;
wacom_schedule_work(wacom);
wacom->battery_capacity = 0;
+ wacom->bat_charging = 0;
+ wacom->ps_connected = 0;
}
return 0;
@@ -1558,8 +1570,10 @@ void wacom_setup_device_quirks(struct wacom_features *features)
features->quirks |= WACOM_QUIRK_NO_INPUT;
/* must be monitor interface if no device_type set */
- if (!features->device_type)
+ if (!features->device_type) {
features->quirks |= WACOM_QUIRK_MONITOR;
+ features->quirks |= WACOM_QUIRK_BATTERY;
+ }
}
}
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 4c59247..8a042ac 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -68,6 +68,7 @@
#define WACOM_QUIRK_BBTOUCH_LOWRES 0x0002
#define WACOM_QUIRK_NO_INPUT 0x0004
#define WACOM_QUIRK_MONITOR 0x0008
+#define WACOM_QUIRK_BATTERY 0x0010
enum {
PENPARTNER = 0,
@@ -164,6 +165,8 @@ struct wacom_wac {
int pid;
int battery_capacity;
int num_contacts_left;
+ int bat_charging;
+ int ps_connected;
};
#endif
--
2.0.1
^ permalink raw reply related
* [PATCH v2 04/10] Input - wacom: use a uniq name for the battery device
From: Benjamin Tissoires @ 2014-07-24 18:13 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
The current implementation uses "wacom_battery" as a generic name for
batteries. This prevents us to have two Wacom devices with a battery
attached as the power system will complain about the name which is already
registered.
Use an incremental name for each battery attached.
Related bug:
https://sourceforge.net/p/linuxwacom/bugs/248/
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
changes in v2:
- do not use the name of the tablet (which removes the need of the check for
spaces), but use instead a simple counter to get a uniq name.
drivers/hid/wacom_sys.c | 6 +++++-
drivers/hid/wacom_wac.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index f0ee7ff..eb8705d 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -809,12 +809,16 @@ static int wacom_battery_get_property(struct power_supply *psy,
static int wacom_initialize_battery(struct wacom *wacom)
{
int error = 0;
+ static atomic_t battery_no = ATOMIC_INIT(0);
+ unsigned long n;
if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) {
+ n = atomic_inc_return(&battery_no) - 1;
wacom->battery.properties = wacom_battery_props;
wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
wacom->battery.get_property = wacom_battery_get_property;
- wacom->battery.name = "wacom_battery";
+ sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n);
+ wacom->battery.name = wacom->wacom_wac.bat_name;
wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY;
wacom->battery.use_for_apm = 0;
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 8a042ac..6cdf707 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -154,6 +154,7 @@ struct wacom_shared {
struct wacom_wac {
char name[WACOM_NAME_MAX];
char pad_name[WACOM_NAME_MAX];
+ char bat_name[WACOM_NAME_MAX];
unsigned char data[WACOM_PKGLEN_MAX];
int tool[2];
int id[2];
--
2.0.1
^ permalink raw reply related
* [PATCH v2 06/10] Input - wacom: prepare the driver to include BT devices
From: Benjamin Tissoires @ 2014-07-24 18:14 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
Now that wacom is a hid driver, there is no point in having a separate
driver for bluetooth devices.
This patch prepares the common paths of Bluetooth devices in the
common wacom driver.
It also adds the sysfs file "speed" used by Bluetooth devices.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
new in v2
drivers/hid/wacom_sys.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++---
drivers/hid/wacom_wac.h | 2 ++
2 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index d0d06b8..add76ec 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -262,6 +262,12 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
return error < 0 ? error : 0;
}
+static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
+ struct wacom_features *features)
+{
+ return 0;
+}
+
/*
* Switch the tablet into its most-capable mode. Wacom tablets are
* typically configured to power-up in a mode which sends mouse-like
@@ -272,6 +278,9 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
static int wacom_query_tablet_data(struct hid_device *hdev,
struct wacom_features *features)
{
+ if (hdev->bus == BUS_BLUETOOTH)
+ return wacom_bt_query_tablet_data(hdev, 1, features);
+
if (features->device_type == BTN_TOOL_FINGER) {
if (features->type > TABLETPC) {
/* MT Tablet PC touch */
@@ -890,6 +899,38 @@ static void wacom_destroy_battery(struct wacom *wacom)
}
}
+static ssize_t wacom_show_speed(struct device *dev,
+ struct device_attribute
+ *attr, char *buf)
+{
+ struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+ struct wacom *wacom = hid_get_drvdata(hdev);
+
+ return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_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);
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ int new_speed;
+
+ if (sscanf(buf, "%1d", &new_speed ) != 1)
+ return -EINVAL;
+
+ if (new_speed == 0 || new_speed == 1) {
+ wacom_bt_query_tablet_data(hdev, new_speed,
+ &wacom->wacom_wac.features);
+ return strnlen(buf, PAGE_SIZE);
+ } else
+ return -EINVAL;
+}
+
+static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP,
+ wacom_show_speed, wacom_store_speed);
+
static struct input_dev *wacom_allocate_input(struct wacom *wacom)
{
struct input_dev *input_dev;
@@ -1210,6 +1251,9 @@ static int wacom_probe(struct hid_device *hdev,
features->y_max = 4096;
}
+ 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 */
@@ -1241,10 +1285,25 @@ static int wacom_probe(struct hid_device *hdev,
if (error)
goto fail2;
+ if (!(features->quirks & WACOM_QUIRK_MONITOR) &&
+ (features->quirks & WACOM_QUIRK_BATTERY)) {
+ error = wacom_initialize_battery(wacom);
+ if (error)
+ goto fail3;
+ }
+
if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
error = wacom_register_inputs(wacom);
if (error)
- goto fail3;
+ goto fail4;
+ }
+
+ if (hdev->bus == BUS_BLUETOOTH) {
+ error = device_create_file(&hdev->dev, &dev_attr_speed);
+ if (error)
+ hid_warn(hdev,
+ "can't create sysfs speed attribute err: %d\n",
+ error);
}
/* Note that if query fails it is not a hard failure */
@@ -1254,7 +1313,7 @@ static int wacom_probe(struct hid_device *hdev,
error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
if (error) {
hid_err(hdev, "hw start failed\n");
- goto fail4;
+ goto fail5;
}
if (features->quirks & WACOM_QUIRK_MONITOR)
@@ -1267,7 +1326,10 @@ static int wacom_probe(struct hid_device *hdev,
return 0;
- fail4: wacom_unregister_inputs(wacom);
+ fail5: if (hdev->bus == BUS_BLUETOOTH)
+ device_remove_file(&hdev->dev, &dev_attr_speed);
+ wacom_unregister_inputs(wacom);
+ fail4: wacom_destroy_battery(wacom);
fail3: wacom_destroy_leds(wacom);
fail2: wacom_remove_shared_data(wacom_wac);
fail1: kfree(wacom);
@@ -1283,6 +1345,8 @@ static void wacom_remove(struct hid_device *hdev)
cancel_work_sync(&wacom->work);
wacom_unregister_inputs(wacom);
+ if (hdev->bus == BUS_BLUETOOTH)
+ device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_destroy_battery(wacom);
wacom_destroy_leds(wacom);
wacom_remove_shared_data(&wacom->wacom_wac);
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 3433a0e..3aa55d9 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -169,6 +169,8 @@ struct wacom_wac {
int num_contacts_left;
int bat_charging;
int ps_connected;
+ __u8 bt_features;
+ __u8 bt_high_speed;
};
#endif
--
2.0.1
^ permalink raw reply related
* [PATCH v2 07/10] Input - wacom: handle Graphire BT tablets in wacom.ko
From: Benjamin Tissoires @ 2014-07-24 18:14 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
First, merge the Graphire BT tablet.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
changes in v2:
- simplified because part of it has been splitted out in the previous commit.
drivers/hid/hid-core.c | 1 -
drivers/hid/hid-wacom.c | 1 -
drivers/hid/wacom_sys.c | 42 +++++++++++++++++++++
drivers/hid/wacom_wac.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
drivers/hid/wacom_wac.h | 2 +
5 files changed, 140 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 7cff1c2..4db6804 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1920,7 +1920,6 @@ 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_DUAL_BOX_PRO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
- { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
{ 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) },
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 4874f4e..967c457 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -952,7 +952,6 @@ static void wacom_remove(struct hid_device *hdev)
}
static const struct hid_device_id wacom_devices[] = {
- { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
{ }
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index add76ec..8492177 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -265,6 +265,48 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
struct wacom_features *features)
{
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ int limit, ret;
+ __u8 rep_data[2];
+
+ switch (features->type) {
+ case GRAPHIRE_BT:
+ rep_data[0] = 0x03 ; rep_data[1] = 0x00;
+ limit = 3;
+ do {
+ ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
+ HID_FEATURE_REPORT, HID_REQ_SET_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 = hid_hw_raw_request(hdev, rep_data[0],
+ rep_data, 2, HID_FEATURE_REPORT,
+ HID_REQ_SET_REPORT);
+ } while (ret < 0 && limit-- > 0);
+
+ if (ret >= 0) {
+ wacom->wacom_wac.bt_high_speed = speed;
+ return 0;
+ }
+ }
+
+ /*
+ * Note that if the raw queries fail, it's not a hard failure
+ * and it is safe to continue
+ */
+ hid_warn(hdev, "failed to poke device, command %d, err %d\n",
+ rep_data[0], ret);
+ break;
+ }
+
return 0;
}
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 2c69326..06bc600 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -30,6 +30,10 @@
*/
#define WACOM_CONTACT_AREA_SCALE 2607
+/*percent of battery capacity for Graphire
+ 8th value means AC online and show 100% capacity */
+static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
+
static int wacom_penpartner_irq(struct wacom_wac *wacom)
{
unsigned char *data = wacom->data;
@@ -263,11 +267,19 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
unsigned char *data = wacom->data;
struct input_dev *input = wacom->input;
struct input_dev *pad_input = wacom->pad_input;
+ int battery_capacity, ps_connected;
int prox;
int rw = 0;
int retval = 0;
- if (data[0] != WACOM_REPORT_PENABLED) {
+ if (features->type == GRAPHIRE_BT) {
+ if (data[0] != WACOM_REPORT_PENABLED_BT) {
+ dev_dbg(input->dev.parent,
+ "%s: received unknown report #%d\n", __func__,
+ data[0]);
+ goto exit;
+ }
+ } else if (data[0] != WACOM_REPORT_PENABLED) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
goto exit;
@@ -301,7 +313,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
if (wacom->tool[0] != BTN_TOOL_MOUSE) {
- input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
+ if (features->type == GRAPHIRE_BT)
+ input_report_abs(input, ABS_PRESSURE, data[6] |
+ (((__u16) (data[1] & 0x08)) << 5));
+ else
+ input_report_abs(input, ABS_PRESSURE, data[6] |
+ ((data[7] & 0x03) << 8));
input_report_key(input, BTN_TOUCH, data[1] & 0x01);
input_report_key(input, BTN_STYLUS, data[1] & 0x02);
input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
@@ -312,6 +329,23 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
features->type == WACOM_MO) {
input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
rw = (data[7] & 0x04) - (data[7] & 0x03);
+ } else if (features->type == GRAPHIRE_BT) {
+ /* 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);
+ if (((data[1] >> 5) & 3) == 2) {
+ /* Mouse with wheel */
+ input_report_key(input, BTN_MIDDLE,
+ data[1] & 0x04);
+ rw = (data[6] & 0x01) ? -1 :
+ (data[6] & 0x02) ? 1 : 0;
+ } else {
+ rw = 0;
+ }
} else {
input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
rw = -(signed char)data[6];
@@ -358,6 +392,31 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
retval = 1;
}
break;
+ case GRAPHIRE_BT:
+ prox = data[7] & 0x03;
+ if (prox || wacom->id[1]) {
+ wacom->id[1] = PAD_DEVICE_ID;
+ input_report_key(pad_input, BTN_0, (data[7] & 0x02));
+ input_report_key(pad_input, BTN_1, (data[7] & 0x01));
+ if (!prox)
+ wacom->id[1] = 0;
+ input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
+ retval = 1;
+ }
+ break;
+ }
+
+ /* Store current battery capacity and power supply state */
+ if (features->type == GRAPHIRE_BT) {
+ rw = (data[7] >> 2 & 0x07);
+ battery_capacity = batcap_gr[rw];
+ ps_connected = rw == 7;
+ if ((wacom->battery_capacity != battery_capacity) ||
+ (wacom->ps_connected != ps_connected)) {
+ wacom->battery_capacity = battery_capacity;
+ wacom->ps_connected = ps_connected;
+ wacom_notify_battery(wacom);
+ }
}
exit:
return retval;
@@ -1418,6 +1477,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
case WACOM_G4:
case GRAPHIRE:
+ case GRAPHIRE_BT:
case WACOM_MO:
sync = wacom_graphire_irq(wacom_wac);
break;
@@ -1654,6 +1714,27 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
break;
+ case GRAPHIRE_BT:
+ __clear_bit(ABS_MISC, input_dev->absbit);
+ input_set_abs_params(input_dev, ABS_DISTANCE, 0,
+ features->distance_max,
+ 0, 0);
+
+ input_set_capability(input_dev, EV_REL, REL_WHEEL);
+
+ __set_bit(BTN_LEFT, input_dev->keybit);
+ __set_bit(BTN_RIGHT, input_dev->keybit);
+ __set_bit(BTN_MIDDLE, input_dev->keybit);
+
+ __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
+ __set_bit(BTN_TOOL_PEN, input_dev->keybit);
+ __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
+ __set_bit(BTN_STYLUS, input_dev->keybit);
+ __set_bit(BTN_STYLUS2, input_dev->keybit);
+
+ __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
+ break;
+
case WACOM_24HD:
input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
@@ -1848,6 +1929,11 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
switch (features->type) {
+ case GRAPHIRE_BT:
+ __set_bit(BTN_0, input_dev->keybit);
+ __set_bit(BTN_1, input_dev->keybit);
+ break;
+
case WACOM_MO:
__set_bit(BTN_BACK, input_dev->keybit);
__set_bit(BTN_LEFT, input_dev->keybit);
@@ -2017,6 +2103,9 @@ static const struct wacom_features wacom_features_0x00 =
static const struct wacom_features wacom_features_0x10 =
{ "Wacom Graphire", 10206, 7422, 511, 63,
GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+static const struct wacom_features wacom_features_0x81 =
+ { "Wacom Graphire BT", 16704, 12064, 511, 32,
+ GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x11 =
{ "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
@@ -2412,6 +2501,10 @@ static const struct wacom_features wacom_features_0x309 =
HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
.driver_data = (kernel_ulong_t)&wacom_features_##prod
+#define BT_DEVICE_WACOM(prod) \
+ HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
+ .driver_data = (kernel_ulong_t)&wacom_features_##prod
+
#define USB_DEVICE_LENOVO(prod) \
HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
.driver_data = (kernel_ulong_t)&wacom_features_##prod
@@ -2469,6 +2562,7 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x69) },
{ USB_DEVICE_WACOM(0x6A) },
{ USB_DEVICE_WACOM(0x6B) },
+ { BT_DEVICE_WACOM(0x81) },
{ USB_DEVICE_WACOM(0x84) },
{ USB_DEVICE_WACOM(0x90) },
{ USB_DEVICE_WACOM(0x93) },
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 3aa55d9..0f3df34 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -46,6 +46,7 @@
/* wacom data packet report IDs */
#define WACOM_REPORT_PENABLED 2
+#define WACOM_REPORT_PENABLED_BT 3
#define WACOM_REPORT_INTUOSREAD 5
#define WACOM_REPORT_INTUOSWRITE 6
#define WACOM_REPORT_INTUOSPAD 12
@@ -73,6 +74,7 @@
enum {
PENPARTNER = 0,
GRAPHIRE,
+ GRAPHIRE_BT,
WACOM_G4,
PTU,
PL,
--
2.0.1
^ permalink raw reply related
* [PATCH v2 08/10] Input - wacom: handle Intuos 4 BT in wacom.ko
From: Benjamin Tissoires @ 2014-07-24 18:14 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
A good point of this change is that now, the Intuos4 bluetooth can handle
the different tools (artpen, airbrush, mice), and we get a common interface
between USB and BT for accessing the LEDs/OLEDs.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
no or little changes in v2
drivers/hid/hid-core.c | 1 -
drivers/hid/hid-wacom.c | 1 -
drivers/hid/wacom_sys.c | 16 +++++++++++
drivers/hid/wacom_wac.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
drivers/hid/wacom_wac.h | 1 +
5 files changed, 90 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 4db6804..1d35e6c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1920,7 +1920,6 @@ 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_DUAL_BOX_PRO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
- { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
{ 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_Q_PAD) },
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 967c457..db2d07d 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -952,7 +952,6 @@ static void wacom_remove(struct hid_device *hdev)
}
static const struct hid_device_id wacom_devices[] = {
- { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
{ }
};
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 8492177..8c4c76a 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -305,6 +305,20 @@ static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
hid_warn(hdev, "failed to poke device, command %d, err %d\n",
rep_data[0], ret);
break;
+ case INTUOS4WL:
+ if (speed == 1)
+ wacom->wacom_wac.bt_features &= ~0x20;
+ else
+ wacom->wacom_wac.bt_features |= 0x20;
+
+ rep_data[0] = 0x03;
+ rep_data[1] = wacom->wacom_wac.bt_features;
+
+ ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
+ HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
+ if (ret >= 0)
+ wacom->wacom_wac.bt_high_speed = speed;
+ break;
}
return 0;
@@ -729,6 +743,7 @@ static int wacom_initialize_leds(struct wacom *wacom)
switch (wacom->wacom_wac.features.type) {
case INTUOS4S:
case INTUOS4:
+ case INTUOS4WL:
case INTUOS4L:
wacom->led.select[0] = 0;
wacom->led.select[1] = 0;
@@ -795,6 +810,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
switch (wacom->wacom_wac.features.type) {
case INTUOS4S:
case INTUOS4:
+ case INTUOS4WL:
case INTUOS4L:
sysfs_remove_group(&wacom->hdev->dev.kobj,
&intuos4_led_attr_group);
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 06bc600..1bcee15 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -34,6 +34,9 @@
8th value means AC online and show 100% capacity */
static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
+/*percent of battery capacity for Intuos4 WL, AC has a separate bit*/
+static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
+
static int wacom_penpartner_irq(struct wacom_wac *wacom)
{
unsigned char *data = wacom->data;
@@ -953,6 +956,58 @@ static int int_dist(int x1, int y1, int x2, int y2)
return int_sqrt(x*x + y*y);
}
+static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
+ unsigned char *data)
+{
+ memcpy(wacom->data, data, 10);
+ wacom_intuos_irq(wacom);
+
+ input_sync(wacom->input);
+ if (wacom->pad_input)
+ input_sync(wacom->pad_input);
+}
+
+static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
+{
+ unsigned char data[WACOM_PKGLEN_MAX];
+ int i = 1;
+ unsigned power_raw, battery_capacity, bat_charging, ps_connected;
+
+ memcpy(data, wacom->data, len);
+
+ switch (data[0]) {
+ case 0x04:
+ wacom_intuos_bt_process_data(wacom, data + i);
+ i += 10;
+ /* fall through */
+ case 0x03:
+ wacom_intuos_bt_process_data(wacom, data + i);
+ i += 10;
+ wacom_intuos_bt_process_data(wacom, data + i);
+ i += 10;
+ power_raw = data[i];
+ bat_charging = (power_raw & 0x08) ? 1 : 0;
+ ps_connected = (power_raw & 0x10) ? 1 : 0;
+ battery_capacity = batcap_i4[power_raw & 0x07];
+ if ((wacom->battery_capacity != battery_capacity) ||
+ (wacom->bat_charging != bat_charging) ||
+ (wacom->ps_connected != ps_connected)) {
+ wacom->battery_capacity = battery_capacity;
+ wacom->bat_charging = bat_charging;
+ wacom->ps_connected = ps_connected;
+ wacom_notify_battery(wacom);
+ }
+
+ break;
+ default:
+ dev_dbg(wacom->input->dev.parent,
+ "Unknown report: %d,%d size:%li\n",
+ data[0], data[1], len);
+ return 0;
+ }
+ return 0;
+}
+
static int wacom_24hdt_irq(struct wacom_wac *wacom)
{
struct input_dev *input = wacom->input;
@@ -1512,6 +1567,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
sync = wacom_intuos_irq(wacom_wac);
break;
+ case INTUOS4WL:
+ sync = wacom_intuos_bt_irq(wacom_wac, len);
+ break;
+
case WACOM_24HDT:
sync = wacom_24hdt_irq(wacom_wac);
break;
@@ -1803,6 +1862,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
break;
case INTUOS4:
+ case INTUOS4WL:
case INTUOS4L:
case INTUOS4S:
input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
@@ -2051,6 +2111,15 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
break;
+ case INTUOS4WL:
+ /*
+ * For Bluetooth devices, the udev rule does not work correctly
+ * for pads unless we add a stylus capability, which forces
+ * ID_INPUT_TABLET to be set.
+ */
+ __set_bit(BTN_STYLUS, input_dev->keybit);
+ /* fall through */
+
case INTUOS4:
case INTUOS4L:
__set_bit(BTN_7, input_dev->keybit);
@@ -2265,6 +2334,9 @@ static const struct wacom_features wacom_features_0xBB =
static const struct wacom_features wacom_features_0xBC =
{ "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+static const struct wacom_features wacom_features_0xBD =
+ { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
+ INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0x26 =
{ "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
@@ -2581,6 +2653,7 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0xBA) },
{ USB_DEVICE_WACOM(0xBB) },
{ USB_DEVICE_WACOM(0xBC) },
+ { BT_DEVICE_WACOM(0xBD) },
{ USB_DEVICE_WACOM(0xC0) },
{ USB_DEVICE_WACOM(0xC2) },
{ USB_DEVICE_WACOM(0xC4) },
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 0f3df34..5039357 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -86,6 +86,7 @@ enum {
INTUOS3L,
INTUOS4S,
INTUOS4,
+ INTUOS4WL,
INTUOS4L,
INTUOS5S,
INTUOS5,
--
2.0.1
^ permalink raw reply related
* [PATCH v2 09/10] Input - wacom: add copyright note and bump version to 2.0
From: Benjamin Tissoires @ 2014-07-24 18:14 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
new in v2:
- I thought it was interesting to bump the number of the release
drivers/hid/wacom.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 2b5562b..e354972 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -12,6 +12,7 @@
* 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>
+ * Copyright (c) 2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>
*
* ChangeLog:
* v0.1 (vp) - Initial release
@@ -72,6 +73,8 @@
* v1.52 (pc) - Query Wacom data upon system resume
* - add defines for features->type
* - add new devices (0x9F, 0xE2, and 0XE3)
+ * v2.00 (bt) - conversion to a HID driver
+ * - integration of the Bluetooth devices
*/
/*
--
2.0.1
^ permalink raw reply related
* [PATCH v2 10/10] HID: remove hid-wacom Bluetooth driver
From: Benjamin Tissoires @ 2014-07-24 18:14 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
Bluetooth Wacom tablets are now handled by the regular wacom.ko driver.
Remove the now useless hid-wacom driver.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
no changes in v2
drivers/hid/Kconfig | 10 +-
drivers/hid/Makefile | 3 +-
drivers/hid/hid-wacom.c | 971 ------------------------------------------------
3 files changed, 2 insertions(+), 982 deletions(-)
delete mode 100644 drivers/hid/hid-wacom.c
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 5a7517b..5586b61 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -737,21 +737,13 @@ config THRUSTMASTER_FF
Rumble Force or Force Feedback Wheel.
config HID_WACOM
- tristate "Wacom Bluetooth devices support"
- depends on HID
- depends on LEDS_CLASS
- select POWER_SUPPLY
- ---help---
- Support for Wacom Graphire Bluetooth and Intuos4 WL tablets.
-
-config HID_USB_WACOM
tristate "Wacom Intuos/Graphire tablet support (USB)"
depends on HID
select POWER_SUPPLY
select NEW_LEDS
select LEDS_CLASS
help
- Say Y here if you want to use the USB version of the Wacom Intuos
+ Say Y here if you want to use the USB or BT version of the Wacom Intuos
or Graphire tablet.
To compile this driver as a module, choose M here: the
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index a9e9f48..ccb3c80 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -114,10 +114,9 @@ obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o
obj-$(CONFIG_HID_XINMO) += hid-xinmo.o
obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
-obj-$(CONFIG_HID_WACOM) += hid-wacom.o
wacom-objs := wacom_wac.o wacom_sys.o
-obj-$(CONFIG_HID_USB_WACOM) += wacom.o
+obj-$(CONFIG_HID_WACOM) += wacom.o
obj-$(CONFIG_HID_WALTOP) += hid-waltop.o
obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o
obj-$(CONFIG_HID_SENSOR_HUB) += hid-sensor-hub.o
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
deleted file mode 100644
index db2d07d..0000000
--- a/drivers/hid/hid-wacom.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/*
- * 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) 2008 Jiri Slaby <jirislaby@gmail.com>
- * Copyright (c) 2006 Andrew Zabolotny <zap@homelink.ru>
- * Copyright (c) 2009 Bastien Nocera <hadess@hadess.net>
- * Copyright (c) 2011 Przemysław Firszt <przemo@firszt.eu>
- */
-
-/*
- * 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.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/device.h>
-#include <linux/hid.h>
-#include <linux/module.h>
-#include <linux/leds.h>
-#include <linux/slab.h>
-#include <linux/power_supply.h>
-
-#include "hid-ids.h"
-
-#define PAD_DEVICE_ID 0x0F
-
-#define WAC_CMD_LED_CONTROL 0x20
-#define WAC_CMD_ICON_START_STOP 0x21
-#define WAC_CMD_ICON_TRANSFER 0x26
-
-struct wacom_data {
- __u16 tool;
- __u16 butstate;
- __u8 whlstate;
- __u8 features;
- __u32 id;
- __u32 serial;
- unsigned char high_speed;
- __u8 battery_capacity;
- __u8 power_raw;
- __u8 ps_connected;
- __u8 bat_charging;
- struct power_supply battery;
- struct power_supply ac;
- __u8 led_selector;
- struct led_classdev *leds[4];
-};
-
-/*percent of battery capacity for Graphire
- 8th value means AC online and show 100% capacity */
-static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
-/*percent of battery capacity for Intuos4 WL, AC has a separate bit*/
-static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
-
-static enum power_supply_property wacom_battery_props[] = {
- POWER_SUPPLY_PROP_PRESENT,
- POWER_SUPPLY_PROP_CAPACITY,
- POWER_SUPPLY_PROP_SCOPE,
- POWER_SUPPLY_PROP_STATUS,
-};
-
-static enum power_supply_property wacom_ac_props[] = {
- POWER_SUPPLY_PROP_PRESENT,
- POWER_SUPPLY_PROP_ONLINE,
- POWER_SUPPLY_PROP_SCOPE,
-};
-
-static void wacom_scramble(__u8 *image)
-{
- __u16 mask;
- __u16 s1;
- __u16 s2;
- __u16 r1 ;
- __u16 r2 ;
- __u16 r;
- __u8 buf[256];
- int i, w, x, y, z;
-
- for (x = 0; x < 32; x++) {
- for (y = 0; y < 8; y++)
- buf[(8 * x) + (7 - y)] = image[(8 * x) + y];
- }
-
- /* Change 76543210 into GECA6420 as required by Intuos4 WL
- * HGFEDCBA HFDB7531
- */
- for (x = 0; x < 4; x++) {
- for (y = 0; y < 4; y++) {
- for (z = 0; z < 8; z++) {
- mask = 0x0001;
- r1 = 0;
- r2 = 0;
- i = (x << 6) + (y << 4) + z;
- s1 = buf[i];
- s2 = buf[i+8];
- for (w = 0; w < 8; w++) {
- r1 |= (s1 & mask);
- r2 |= (s2 & mask);
- s1 <<= 1;
- s2 <<= 1;
- mask <<= 2;
- }
- r = r1 | (r2 << 1);
- i = (x << 6) + (y << 4) + (z << 1);
- image[i] = 0xFF & r;
- image[i+1] = (0xFF00 & r) >> 8;
- }
- }
- }
-}
-
-static void wacom_set_image(struct hid_device *hdev, const char *image,
- __u8 icon_no)
-{
- __u8 rep_data[68];
- __u8 p[256];
- int ret, i, j;
-
- for (i = 0; i < 256; i++)
- p[i] = image[i];
-
- rep_data[0] = WAC_CMD_ICON_START_STOP;
- rep_data[1] = 0;
- ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
- HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
- if (ret < 0)
- goto err;
-
- rep_data[0] = WAC_CMD_ICON_TRANSFER;
- rep_data[1] = icon_no & 0x07;
-
- wacom_scramble(p);
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 64; j++)
- rep_data[j + 3] = p[(i << 6) + j];
-
- rep_data[2] = i;
- ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 67,
- HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
- }
-
- rep_data[0] = WAC_CMD_ICON_START_STOP;
- rep_data[1] = 0;
-
- ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
- HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
-
-err:
- return;
-}
-
-static void wacom_leds_set_brightness(struct led_classdev *led_dev,
- enum led_brightness value)
-{
- struct device *dev = led_dev->dev->parent;
- struct hid_device *hdev;
- struct wacom_data *wdata;
- unsigned char *buf;
- __u8 led = 0;
- int i;
-
- hdev = container_of(dev, struct hid_device, dev);
- wdata = hid_get_drvdata(hdev);
- for (i = 0; i < 4; ++i) {
- if (wdata->leds[i] == led_dev)
- wdata->led_selector = i;
- }
-
- led = wdata->led_selector | 0x04;
- buf = kzalloc(9, GFP_KERNEL);
- if (buf) {
- buf[0] = WAC_CMD_LED_CONTROL;
- buf[1] = led;
- buf[2] = value >> 2;
- buf[3] = value;
- /* use fixed brightness for OLEDs */
- buf[4] = 0x08;
- hid_hw_raw_request(hdev, buf[0], buf, 9, HID_FEATURE_REPORT,
- HID_REQ_SET_REPORT);
- kfree(buf);
- }
-
- return;
-}
-
-static enum led_brightness wacom_leds_get_brightness(struct led_classdev *led_dev)
-{
- struct wacom_data *wdata;
- struct device *dev = led_dev->dev->parent;
- int value = 0;
- int i;
-
- wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev));
-
- for (i = 0; i < 4; ++i) {
- if (wdata->leds[i] == led_dev) {
- value = wdata->leds[i]->brightness;
- break;
- }
- }
-
- return value;
-}
-
-
-static int wacom_initialize_leds(struct hid_device *hdev)
-{
- struct wacom_data *wdata = hid_get_drvdata(hdev);
- struct led_classdev *led;
- struct device *dev = &hdev->dev;
- size_t namesz = strlen(dev_name(dev)) + 12;
- char *name;
- int i, ret;
-
- wdata->led_selector = 0;
-
- for (i = 0; i < 4; i++) {
- led = kzalloc(sizeof(struct led_classdev) + namesz, GFP_KERNEL);
- if (!led) {
- hid_warn(hdev,
- "can't allocate memory for LED selector\n");
- ret = -ENOMEM;
- goto err;
- }
-
- name = (void *)&led[1];
- snprintf(name, namesz, "%s:selector:%d", dev_name(dev), i);
- led->name = name;
- led->brightness = 0;
- led->max_brightness = 127;
- led->brightness_get = wacom_leds_get_brightness;
- led->brightness_set = wacom_leds_set_brightness;
-
- wdata->leds[i] = led;
-
- ret = led_classdev_register(dev, wdata->leds[i]);
-
- if (ret) {
- wdata->leds[i] = NULL;
- kfree(led);
- hid_warn(hdev, "can't register LED\n");
- goto err;
- }
- }
-
-err:
- return ret;
-}
-
-static void wacom_destroy_leds(struct hid_device *hdev)
-{
- struct wacom_data *wdata = hid_get_drvdata(hdev);
- struct led_classdev *led;
- int i;
-
- for (i = 0; i < 4; ++i) {
- if (wdata->leds[i]) {
- led = wdata->leds[i];
- wdata->leds[i] = NULL;
- led_classdev_unregister(led);
- kfree(led);
- }
- }
-
-}
-
-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 ret = 0;
-
- switch (psp) {
- case POWER_SUPPLY_PROP_PRESENT:
- val->intval = 1;
- break;
- case POWER_SUPPLY_PROP_SCOPE:
- val->intval = POWER_SUPPLY_SCOPE_DEVICE;
- break;
- case POWER_SUPPLY_PROP_CAPACITY:
- val->intval = wdata->battery_capacity;
- break;
- case POWER_SUPPLY_PROP_STATUS:
- if (wdata->bat_charging)
- val->intval = POWER_SUPPLY_STATUS_CHARGING;
- else
- if (wdata->battery_capacity == 100 && wdata->ps_connected)
- val->intval = POWER_SUPPLY_STATUS_FULL;
- else
- val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
- 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 ret = 0;
-
- switch (psp) {
- case POWER_SUPPLY_PROP_PRESENT:
- /* fall through */
- case POWER_SUPPLY_PROP_ONLINE:
- val->intval = wdata->ps_connected;
- break;
- case POWER_SUPPLY_PROP_SCOPE:
- val->intval = POWER_SUPPLY_SCOPE_DEVICE;
- break;
- default:
- ret = -EINVAL;
- break;
- }
- return ret;
-}
-
-static void wacom_set_features(struct hid_device *hdev, u8 speed)
-{
- struct wacom_data *wdata = hid_get_drvdata(hdev);
- int limit, ret;
- __u8 rep_data[2];
-
- switch (hdev->product) {
- case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH:
- rep_data[0] = 0x03 ; rep_data[1] = 0x00;
- limit = 3;
- do {
- ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
- HID_FEATURE_REPORT, HID_REQ_SET_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 = hid_hw_raw_request(hdev, rep_data[0],
- rep_data, 2, HID_FEATURE_REPORT,
- HID_REQ_SET_REPORT);
- } while (ret < 0 && limit-- > 0);
-
- if (ret >= 0) {
- wdata->high_speed = speed;
- return;
- }
- }
-
- /*
- * Note that if the raw queries fail, it's not a hard failure
- * and it is safe to continue
- */
- hid_warn(hdev, "failed to poke device, command %d, err %d\n",
- rep_data[0], ret);
- break;
- case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH:
- if (speed == 1)
- wdata->features &= ~0x20;
- else
- wdata->features |= 0x20;
-
- rep_data[0] = 0x03;
- rep_data[1] = wdata->features;
-
- ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
- HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
- if (ret >= 0)
- wdata->high_speed = speed;
- break;
- }
-
- return;
-}
-
-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_set_features(hdev, new_speed);
- return strnlen(buf, PAGE_SIZE);
- } else
- return -EINVAL;
-}
-
-static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP,
- wacom_show_speed, wacom_store_speed);
-
-#define WACOM_STORE(OLED_ID) \
-static ssize_t wacom_oled##OLED_ID##_store(struct device *dev, \
- struct device_attribute *attr, \
- const char *buf, size_t count) \
-{ \
- struct hid_device *hdev = container_of(dev, struct hid_device, \
- dev); \
- \
- if (count != 256) \
- return -EINVAL; \
- \
- wacom_set_image(hdev, buf, OLED_ID); \
- \
- return count; \
-} \
- \
-static DEVICE_ATTR(oled##OLED_ID##_img, S_IWUSR | S_IWGRP, NULL, \
- wacom_oled##OLED_ID##_store)
-
-WACOM_STORE(0);
-WACOM_STORE(1);
-WACOM_STORE(2);
-WACOM_STORE(3);
-WACOM_STORE(4);
-WACOM_STORE(5);
-WACOM_STORE(6);
-WACOM_STORE(7);
-
-static int wacom_gr_parse_report(struct hid_device *hdev,
- struct wacom_data *wdata,
- struct input_dev *input, unsigned char *data)
-{
- int tool, x, y, rw;
-
- tool = 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,
- input_abs_get_max(input, ABS_DISTANCE));
- } 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);
- input_report_key(input, BTN_TOOL_FINGER, 0xf0);
- input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
- input_sync(input);
- }
-
- /* Store current battery capacity and power supply state*/
- rw = (data[7] >> 2 & 0x07);
- if (rw != wdata->power_raw) {
- wdata->power_raw = rw;
- wdata->battery_capacity = batcap_gr[rw];
- if (rw == 7)
- wdata->ps_connected = 1;
- else
- wdata->ps_connected = 0;
- }
- return 1;
-}
-
-static void wacom_i4_parse_button_report(struct wacom_data *wdata,
- struct input_dev *input, unsigned char *data)
-{
- __u16 new_butstate;
- __u8 new_whlstate;
- __u8 sync = 0;
-
- new_whlstate = data[1];
- if (new_whlstate != wdata->whlstate) {
- wdata->whlstate = new_whlstate;
- if (new_whlstate & 0x80) {
- input_report_key(input, BTN_TOUCH, 1);
- input_report_abs(input, ABS_WHEEL, (new_whlstate & 0x7f));
- input_report_key(input, BTN_TOOL_FINGER, 1);
- } else {
- input_report_key(input, BTN_TOUCH, 0);
- input_report_abs(input, ABS_WHEEL, 0);
- input_report_key(input, BTN_TOOL_FINGER, 0);
- }
- sync = 1;
- }
-
- new_butstate = (data[3] << 1) | (data[2] & 0x01);
- if (new_butstate != wdata->butstate) {
- wdata->butstate = new_butstate;
- input_report_key(input, BTN_0, new_butstate & 0x001);
- input_report_key(input, BTN_1, new_butstate & 0x002);
- input_report_key(input, BTN_2, new_butstate & 0x004);
- input_report_key(input, BTN_3, new_butstate & 0x008);
- input_report_key(input, BTN_4, new_butstate & 0x010);
- input_report_key(input, BTN_5, new_butstate & 0x020);
- input_report_key(input, BTN_6, new_butstate & 0x040);
- input_report_key(input, BTN_7, new_butstate & 0x080);
- input_report_key(input, BTN_8, new_butstate & 0x100);
- input_report_key(input, BTN_TOOL_FINGER, 1);
- sync = 1;
- }
-
- if (sync) {
- input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
- input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
- input_sync(input);
- }
-}
-
-static void wacom_i4_parse_pen_report(struct wacom_data *wdata,
- struct input_dev *input, unsigned char *data)
-{
- __u16 x, y, pressure;
- __u8 distance;
- __u8 tilt_x, tilt_y;
-
- switch (data[1]) {
- case 0x80: /* Out of proximity report */
- input_report_key(input, BTN_TOUCH, 0);
- input_report_abs(input, ABS_PRESSURE, 0);
- input_report_key(input, BTN_STYLUS, 0);
- input_report_key(input, BTN_STYLUS2, 0);
- input_report_key(input, wdata->tool, 0);
- input_report_abs(input, ABS_MISC, 0);
- input_event(input, EV_MSC, MSC_SERIAL, wdata->serial);
- wdata->tool = 0;
- input_sync(input);
- break;
- case 0xC2: /* Tool report */
- wdata->id = ((data[2] << 4) | (data[3] >> 4) |
- ((data[7] & 0x0f) << 20) |
- ((data[8] & 0xf0) << 12));
- wdata->serial = ((data[3] & 0x0f) << 28) +
- (data[4] << 20) + (data[5] << 12) +
- (data[6] << 4) + (data[7] >> 4);
-
- switch (wdata->id) {
- case 0x100802:
- wdata->tool = BTN_TOOL_PEN;
- break;
- case 0x10080A:
- wdata->tool = BTN_TOOL_RUBBER;
- break;
- }
- break;
- default: /* Position/pressure report */
- x = data[2] << 9 | data[3] << 1 | ((data[9] & 0x02) >> 1);
- y = data[4] << 9 | data[5] << 1 | (data[9] & 0x01);
- pressure = (data[6] << 3) | ((data[7] & 0xC0) >> 5)
- | (data[1] & 0x01);
- distance = (data[9] >> 2) & 0x3f;
- tilt_x = ((data[7] << 1) & 0x7e) | (data[8] >> 7);
- tilt_y = data[8] & 0x7f;
-
- input_report_key(input, BTN_TOUCH, pressure > 1);
-
- input_report_key(input, BTN_STYLUS, data[1] & 0x02);
- input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
- input_report_key(input, wdata->tool, 1);
- input_report_abs(input, ABS_X, x);
- input_report_abs(input, ABS_Y, y);
- input_report_abs(input, ABS_PRESSURE, pressure);
- input_report_abs(input, ABS_DISTANCE, distance);
- input_report_abs(input, ABS_TILT_X, tilt_x);
- input_report_abs(input, ABS_TILT_Y, tilt_y);
- input_report_abs(input, ABS_MISC, wdata->id);
- input_event(input, EV_MSC, MSC_SERIAL, wdata->serial);
- input_report_key(input, wdata->tool, 1);
- input_sync(input);
- break;
- }
-
- return;
-}
-
-static void wacom_i4_parse_report(struct hid_device *hdev,
- struct wacom_data *wdata,
- struct input_dev *input, unsigned char *data)
-{
- switch (data[0]) {
- case 0x00: /* Empty report */
- break;
- case 0x02: /* Pen report */
- wacom_i4_parse_pen_report(wdata, input, data);
- break;
- case 0x03: /* Features Report */
- wdata->features = data[2];
- break;
- case 0x0C: /* Button report */
- wacom_i4_parse_button_report(wdata, input, data);
- break;
- default:
- hid_err(hdev, "Unknown report: %d,%d\n", data[0], data[1]);
- break;
- }
-}
-
-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 i;
- __u8 power_raw;
-
- if (!(hdev->claimed & HID_CLAIMED_INPUT))
- return 0;
-
- hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
- input = hidinput->input;
-
- switch (hdev->product) {
- case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH:
- if (data[0] == 0x03) {
- return wacom_gr_parse_report(hdev, wdata, input, data);
- } else {
- hid_err(hdev, "Unknown report: %d,%d size:%d\n",
- data[0], data[1], size);
- return 0;
- }
- break;
- case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH:
- i = 1;
-
- switch (data[0]) {
- case 0x04:
- wacom_i4_parse_report(hdev, wdata, input, data + i);
- i += 10;
- /* fall through */
- case 0x03:
- wacom_i4_parse_report(hdev, wdata, input, data + i);
- i += 10;
- wacom_i4_parse_report(hdev, wdata, input, data + i);
- power_raw = data[i+10];
- if (power_raw != wdata->power_raw) {
- wdata->power_raw = power_raw;
- wdata->battery_capacity = batcap_i4[power_raw & 0x07];
- wdata->bat_charging = (power_raw & 0x08) ? 1 : 0;
- wdata->ps_connected = (power_raw & 0x10) ? 1 : 0;
- }
-
- break;
- default:
- hid_err(hdev, "Unknown report: %d,%d size:%d\n",
- data[0], data[1], size);
- return 0;
- }
- }
- return 1;
-}
-
-static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi,
- struct hid_field *field, struct hid_usage *usage, unsigned long **bit,
- int *max)
-{
- struct input_dev *input = hi->input;
-
- __set_bit(INPUT_PROP_POINTER, input->propbit);
-
- /* Basics */
- input->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_REL);
-
- __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);
-
- /* Pad */
- input_set_capability(input, EV_MSC, MSC_SERIAL);
-
- __set_bit(BTN_0, input->keybit);
- __set_bit(BTN_1, input->keybit);
- __set_bit(BTN_TOOL_FINGER, input->keybit);
-
- /* Distance, rubber and mouse */
- __set_bit(BTN_TOOL_RUBBER, input->keybit);
- __set_bit(BTN_TOOL_MOUSE, input->keybit);
-
- switch (hdev->product) {
- case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH:
- 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);
- break;
- case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH:
- __set_bit(ABS_WHEEL, input->absbit);
- __set_bit(ABS_MISC, input->absbit);
- __set_bit(BTN_2, input->keybit);
- __set_bit(BTN_3, input->keybit);
- __set_bit(BTN_4, input->keybit);
- __set_bit(BTN_5, input->keybit);
- __set_bit(BTN_6, input->keybit);
- __set_bit(BTN_7, input->keybit);
- __set_bit(BTN_8, input->keybit);
- input_set_abs_params(input, ABS_WHEEL, 0, 71, 0, 0);
- input_set_abs_params(input, ABS_X, 0, 40640, 4, 0);
- input_set_abs_params(input, ABS_Y, 0, 25400, 4, 0);
- input_set_abs_params(input, ABS_PRESSURE, 0, 2047, 0, 0);
- input_set_abs_params(input, ABS_DISTANCE, 0, 63, 0, 0);
- input_set_abs_params(input, ABS_TILT_X, 0, 127, 0, 0);
- input_set_abs_params(input, ABS_TILT_Y, 0, 127, 0, 0);
- break;
- }
-
- return 0;
-}
-
-static int wacom_probe(struct hid_device *hdev,
- const struct hid_device_id *id)
-{
- struct wacom_data *wdata;
- int ret;
-
- wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
- if (wdata == NULL) {
- hid_err(hdev, "can't alloc wacom descriptor\n");
- return -ENOMEM;
- }
-
- hid_set_drvdata(hdev, wdata);
-
- /* Parse the HID report now */
- ret = hid_parse(hdev);
- if (ret) {
- hid_err(hdev, "parse failed\n");
- goto err_free;
- }
-
- ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
- if (ret) {
- hid_err(hdev, "hw start failed\n");
- goto err_free;
- }
-
- ret = device_create_file(&hdev->dev, &dev_attr_speed);
- if (ret)
- hid_warn(hdev,
- "can't create sysfs speed attribute err: %d\n", ret);
-
-#define OLED_INIT(OLED_ID) \
- do { \
- ret = device_create_file(&hdev->dev, \
- &dev_attr_oled##OLED_ID##_img); \
- if (ret) \
- hid_warn(hdev, \
- "can't create sysfs oled attribute, err: %d\n", ret);\
- } while (0)
-
-OLED_INIT(0);
-OLED_INIT(1);
-OLED_INIT(2);
-OLED_INIT(3);
-OLED_INIT(4);
-OLED_INIT(5);
-OLED_INIT(6);
-OLED_INIT(7);
-
- wdata->features = 0;
- wacom_set_features(hdev, 1);
-
- if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) {
- sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
- ret = wacom_initialize_leds(hdev);
- if (ret)
- hid_warn(hdev,
- "can't create led attribute, err: %d\n", ret);
- }
-
- 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;
-
-
- ret = power_supply_register(&hdev->dev, &wdata->battery);
- if (ret) {
- hid_err(hdev, "can't create sysfs battery attribute, err: %d\n",
- ret);
- goto err_battery;
- }
-
- power_supply_powers(&wdata->battery, &hdev->dev);
-
- 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) {
- hid_err(hdev,
- "can't create ac battery attribute, err: %d\n", ret);
- goto err_ac;
- }
-
- power_supply_powers(&wdata->ac, &hdev->dev);
- return 0;
-
-err_ac:
- power_supply_unregister(&wdata->battery);
-err_battery:
- wacom_destroy_leds(hdev);
- device_remove_file(&hdev->dev, &dev_attr_oled0_img);
- device_remove_file(&hdev->dev, &dev_attr_oled1_img);
- device_remove_file(&hdev->dev, &dev_attr_oled2_img);
- device_remove_file(&hdev->dev, &dev_attr_oled3_img);
- device_remove_file(&hdev->dev, &dev_attr_oled4_img);
- device_remove_file(&hdev->dev, &dev_attr_oled5_img);
- device_remove_file(&hdev->dev, &dev_attr_oled6_img);
- device_remove_file(&hdev->dev, &dev_attr_oled7_img);
- device_remove_file(&hdev->dev, &dev_attr_speed);
- hid_hw_stop(hdev);
-err_free:
- kfree(wdata);
- return ret;
-}
-
-static void wacom_remove(struct hid_device *hdev)
-{
- struct wacom_data *wdata = hid_get_drvdata(hdev);
-
- wacom_destroy_leds(hdev);
- device_remove_file(&hdev->dev, &dev_attr_oled0_img);
- device_remove_file(&hdev->dev, &dev_attr_oled1_img);
- device_remove_file(&hdev->dev, &dev_attr_oled2_img);
- device_remove_file(&hdev->dev, &dev_attr_oled3_img);
- device_remove_file(&hdev->dev, &dev_attr_oled4_img);
- device_remove_file(&hdev->dev, &dev_attr_oled5_img);
- device_remove_file(&hdev->dev, &dev_attr_oled6_img);
- device_remove_file(&hdev->dev, &dev_attr_oled7_img);
- device_remove_file(&hdev->dev, &dev_attr_speed);
- hid_hw_stop(hdev);
-
- power_supply_unregister(&wdata->battery);
- power_supply_unregister(&wdata->ac);
- kfree(hid_get_drvdata(hdev));
-}
-
-static const struct hid_device_id wacom_devices[] = {
-
- { }
-};
-MODULE_DEVICE_TABLE(hid, wacom_devices);
-
-static struct hid_driver wacom_driver = {
- .name = "hid-wacom",
- .id_table = wacom_devices,
- .probe = wacom_probe,
- .remove = wacom_remove,
- .raw_event = wacom_raw_event,
- .input_mapped = wacom_input_mapped,
-};
-module_hid_driver(wacom_driver);
-
-MODULE_DESCRIPTION("Driver for Wacom Graphire Bluetooth and Wacom Intuos4 WL");
-MODULE_LICENSE("GPL");
--
2.0.1
^ permalink raw reply related
* [PATCH v2 00/10] Input - wacom: conversion to HID driver, series 2
From: Benjamin Tissoires @ 2014-07-24 18:13 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
Hi Dmitry,
this is the second series I told you about for wacom.ko. This series also have
a good number of removed lines of code. \o/
The first patch is Jason's one that I finally decided to take with me. His
previous submission still applied correctly even after the moving of the files
(git is definitively awesome).
The second one is a patch I sent earlier and forgot to include in the v2 of
the first series. It might have been dropped during my many rebases. So here
he is.
The rest is for one part enhancing the battery reporting system (to make it
equal to the one in hid-wacom, and even slightly better). The other part
is the actual merge of hid-wacom into wacom which gives the same user space API
for bluetooth and USB devices, fixes the pad-in-a-separate-input-dev, and
fixes the missing tools not supported in the previous implementation of
hid-wacom for Intuos 4 BT.
Hi Jason,
I took your patch through this series, I hope you don't mind,
Hi Przemo,
Normally, this series contains all the bits of hid-wacom (except the custom
LED/OLED API). Please tell me if I am missing anything and if you like the
change.
Cheers,
Benjamin
Benjamin Tissoires (9):
Input - wacom: put a flag when the led are initialized
Input - wacom: enhance Wireless Receiver battery reporting
Input - wacom: use a uniq name for the battery device
Input - wacom: register an ac power supply for wireless devices
Input - wacom: prepare the driver to include BT devices
Input - wacom: handle Graphire BT tablets in wacom.ko
Input - wacom: handle Intuos 4 BT in wacom.ko
Input - wacom: add copyright note and bump version to 2.0
HID: remove hid-wacom Bluetooth driver
Jason Gerecke (1):
Input - wacom: Support up to 2048 pressure levels with ISDv4
drivers/hid/Kconfig | 10 +-
drivers/hid/Makefile | 3 +-
drivers/hid/hid-core.c | 2 -
drivers/hid/hid-wacom.c | 973 ------------------------------------------------
drivers/hid/wacom.h | 11 +
drivers/hid/wacom_sys.c | 217 ++++++++++-
drivers/hid/wacom_wac.c | 195 +++++++++-
drivers/hid/wacom_wac.h | 10 +
8 files changed, 415 insertions(+), 1006 deletions(-)
delete mode 100644 drivers/hid/hid-wacom.c
--
2.0.1
^ permalink raw reply
* [PATCH v2 05/10] Input - wacom: register an ac power supply for wireless devices
From: Benjamin Tissoires @ 2014-07-24 18:14 UTC (permalink / raw)
To: Dmitry Torokhov, Jiri Kosina, Ping Cheng, Jason Gerecke,
Przemo Firszt
Cc: linux-kernel, linux-input
In-Reply-To: <1406225645-32141-1-git-send-email-benjamin.tissoires@redhat.com>
This is used by HID Bluetooth devices but also add some more information
to the USB Wireless Receiver.
We are just porting the bits from hid-wacom.c to the common driver here.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
new in v2
drivers/hid/wacom.h | 1 +
drivers/hid/wacom_sys.c | 58 ++++++++++++++++++++++++++++++++++++++++++++-----
drivers/hid/wacom_wac.h | 1 +
3 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 99516ba..2b5562b 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -120,6 +120,7 @@ struct wacom {
} led;
bool led_initialized;
struct power_supply battery;
+ struct power_supply ac;
};
static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb8705d..d0d06b8 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -774,6 +774,12 @@ static enum power_supply_property wacom_battery_props[] = {
POWER_SUPPLY_PROP_CAPACITY
};
+static enum power_supply_property wacom_ac_props[] = {
+ POWER_SUPPLY_PROP_PRESENT,
+ POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_SCOPE,
+};
+
static int wacom_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -806,14 +812,38 @@ static int wacom_battery_get_property(struct power_supply *psy,
return ret;
}
+static int wacom_ac_get_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ struct wacom *wacom = container_of(psy, struct wacom, ac);
+ int ret = 0;
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_PRESENT:
+ /* fall through */
+ case POWER_SUPPLY_PROP_ONLINE:
+ val->intval = wacom->wacom_wac.ps_connected;
+ break;
+ case POWER_SUPPLY_PROP_SCOPE:
+ val->intval = POWER_SUPPLY_SCOPE_DEVICE;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+
static int wacom_initialize_battery(struct wacom *wacom)
{
- int error = 0;
static atomic_t battery_no = ATOMIC_INIT(0);
+ int error;
unsigned long n;
if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) {
n = atomic_inc_return(&battery_no) - 1;
+
wacom->battery.properties = wacom_battery_props;
wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
wacom->battery.get_property = wacom_battery_get_property;
@@ -822,15 +852,31 @@ static int wacom_initialize_battery(struct wacom *wacom)
wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY;
wacom->battery.use_for_apm = 0;
+ wacom->ac.properties = wacom_ac_props;
+ wacom->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
+ wacom->ac.get_property = wacom_ac_get_property;
+ sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n);
+ wacom->ac.name = wacom->wacom_wac.ac_name;
+ wacom->ac.type = POWER_SUPPLY_TYPE_MAINS;
+ wacom->ac.use_for_apm = 0;
+
error = power_supply_register(&wacom->hdev->dev,
&wacom->battery);
+ if (error)
+ return error;
+
+ power_supply_powers(&wacom->battery, &wacom->hdev->dev);
+
+ error = power_supply_register(&wacom->hdev->dev, &wacom->ac);
+ if (error) {
+ power_supply_unregister(&wacom->battery);
+ return error;
+ }
- if (!error)
- power_supply_powers(&wacom->battery,
- &wacom->hdev->dev);
+ power_supply_powers(&wacom->ac, &wacom->hdev->dev);
}
- return error;
+ return 0;
}
static void wacom_destroy_battery(struct wacom *wacom)
@@ -839,6 +885,8 @@ static void wacom_destroy_battery(struct wacom *wacom)
wacom->battery.dev) {
power_supply_unregister(&wacom->battery);
wacom->battery.dev = NULL;
+ power_supply_unregister(&wacom->ac);
+ wacom->ac.dev = NULL;
}
}
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 6cdf707..3433a0e 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -155,6 +155,7 @@ struct wacom_wac {
char name[WACOM_NAME_MAX];
char pad_name[WACOM_NAME_MAX];
char bat_name[WACOM_NAME_MAX];
+ char ac_name[WACOM_NAME_MAX];
unsigned char data[WACOM_PKGLEN_MAX];
int tool[2];
int id[2];
--
2.0.1
^ permalink raw reply related
* Re: Linux 3.16-rc6
From: Linus Torvalds @ 2014-07-24 18:18 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Borislav Petkov, Waiman Long, Ingo Molnar,
Linux Kernel Mailing List, USB list, linux-input@vger.kernel.org
In-Reply-To: <20140724125814.GX6758@twins.programming.kicks-ass.net>
On Thu, Jul 24, 2014 at 5:58 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> So going by the nifty picture rostedt made:
>
> [ 61.454336] CPU0 CPU1
> [ 61.454336] ---- ----
> [ 61.454336] lock(&(&p->alloc_lock)->rlock);
> [ 61.454336] local_irq_disable();
> [ 61.454336] lock(tasklist_lock);
> [ 61.454336] lock(&(&p->alloc_lock)->rlock);
> [ 61.454336] <Interrupt>
> [ 61.454336] lock(tasklist_lock);
So this *should* be fine. It always has been in the past, and it was
certainly the *intention* that it should continue to work with
qrwlock, even in the presense of pending writers on other cpu's.
The qrwlock rules are that a read-lock in an interrupt is still going
to be unfair and succeed if there are other readers.
> the fact that CPU1 holds tasklist_lock for reading, does not
> automagically allow CPU0 to acquire tasklist_lock for reading too, for
> example if CPU2 (not in the picture) is waiting to acquire tasklist_lock
> for writing, CPU0's read acquire is made to wait.
No.
That is true for qrwlock in general. But *not* in interrupt context.
In interrupt context, it's unfair. At least that was the _intent_ of
the code, maybe that got screwed up some way.
> The only kind of recursion that's safe is same CPU interrupt.
Any read-lock from an irq should still be unfair, no "same CPU" rules.
See queue_read_lock_slowpath(), where it will just wait for any actual
write lockers (not *waiting* writers) to go away. So by definition, of
somebody else (not just the current CPU) holds the lock for reading,
taking it for reading is safe on all cpu's in irq context, because we
obviously won't be waiting for any actual write lock holders.
So it sounds to me like the new lockdep rules in tip/master are too
strict and are throwing a false positive.
Linus
^ permalink raw reply
* Re: Linux 3.16-rc6
From: Peter Zijlstra @ 2014-07-24 18:36 UTC (permalink / raw)
To: Linus Torvalds
Cc: Borislav Petkov, Waiman Long, Ingo Molnar,
Linux Kernel Mailing List, USB list, linux-input@vger.kernel.org
In-Reply-To: <CA+55aFynW5xSRQvY6xO+mxmt6yh7mFkMjy-pgJXpXNy8qDMcPA@mail.gmail.com>
On Thu, Jul 24, 2014 at 11:18:16AM -0700, Linus Torvalds wrote:
> On Thu, Jul 24, 2014 at 5:58 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > So going by the nifty picture rostedt made:
> >
> > [ 61.454336] CPU0 CPU1
> > [ 61.454336] ---- ----
> > [ 61.454336] lock(&(&p->alloc_lock)->rlock);
> > [ 61.454336] local_irq_disable();
> > [ 61.454336] lock(tasklist_lock);
> > [ 61.454336] lock(&(&p->alloc_lock)->rlock);
> > [ 61.454336] <Interrupt>
> > [ 61.454336] lock(tasklist_lock);
>
> So this *should* be fine. It always has been in the past, and it was
> certainly the *intention* that it should continue to work with
> qrwlock, even in the presense of pending writers on other cpu's.
>
> The qrwlock rules are that a read-lock in an interrupt is still going
> to be unfair and succeed if there are other readers.
Ah, indeed. Should have checked :/
> So it sounds to me like the new lockdep rules in tip/master are too
> strict and are throwing a false positive.
Right. Waiman can you have a look?
^ permalink raw reply
* [PATCH] input: drv260x: Introduce TI drv260x haptics driver
From: Dan Murphy @ 2014-07-24 19:07 UTC (permalink / raw)
To: linux-input; +Cc: devicetree, linux-kernel, Dan Murphy
Add the TI drv260x haptics/vibrator driver.
This device uses the input force feedback
to produce a wave form to driver an
ERM or LRA actuator device.
The initial driver supports the devices
real time playback mode. But the device
has additional wave patterns in ROM.
This functionality will be added in
future patchsets.
Product data sheet is located here:
http://www.ti.com/product/drv2605
Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
.../devicetree/bindings/input/ti,drv260x.txt | 44 ++
drivers/input/misc/Kconfig | 9 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/drv260x.c | 537 ++++++++++++++++++++
include/dt-bindings/input/ti-drv260x.h | 30 ++
include/linux/input/drv260x.h | 181 +++++++
6 files changed, 802 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,drv260x.txt
create mode 100644 drivers/input/misc/drv260x.c
create mode 100644 include/dt-bindings/input/ti-drv260x.h
create mode 100644 include/linux/input/drv260x.h
diff --git a/Documentation/devicetree/bindings/input/ti,drv260x.txt b/Documentation/devicetree/bindings/input/ti,drv260x.txt
new file mode 100644
index 0000000..0860661
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/ti,drv260x.txt
@@ -0,0 +1,44 @@
+Texas Instruments - drv260x Haptics driver family
+
+The drv260x family serial control bus communicates through I2C protocols
+
+Required properties:
+ - compatible - One of:
+ "ti,drv2604" - DRV2604
+ "ti,drv2605" - DRV2605
+ "ti,drv2605l" - DRV2605L
+ - reg - I2C slave address
+ - mode - Power up mode of the chip (defined in include/dt-bindings/input/ti-drv260x.h)
+ DRV260X_RTP_MODE - Real time playback mode
+ DRV260X_LRA_MODE - Linear Resonance Actuator mode (Piezoelectric)
+ DRV260X_ERM_MODE - Eccentric Rotating Mass mode (Rotary vibrator)
+ - library_sel - Library to use at power up (defined in include/dt-bindings/input/ti-drv260x.h)
+ DRV260X_LIB_A - Pre-programmed Library
+ DRV260X_LIB_B - Pre-programmed Library
+ DRV260X_LIB_C - Pre-programmed Library
+ DRV260X_LIB_D - Pre-programmed Library
+ DRV260X_LIB_E - Pre-programmed Library
+ DRV260X_LIB_F - Pre-programmed Library
+
+Optional properties:
+ - enable-gpio - gpio pin to enable/disable the device.
+ - vib_rated_voltage - The rated voltage of the actuator. If this is not
+ set then the value will be defaulted to 0x90 in the
+ driver.
+ - vib_overdrive_voltage - The overdrive voltage of the actuator.
+ If this is not set then the value
+ will be defaulted to 0x90 in the driver.
+Example:
+
+drv2605l: drv2605l@41 {
+ compatible = "ti,drv2605l";
+ reg = <0x5a>;
+ enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>; /* GPIO 60 */
+ mode = <DRV260X_RTP_MODE>;
+ library_sel = <DRV260X_LIB_SEL_DEFAULT>;
+ vib_rated_voltage = <3200>;
+ vib_overdriver_voltage = <3200>;
+};
+
+For more product information please see the link below:
+http://www.ti.com/product/drv2605
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 2ff4425..99f6762 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -676,4 +676,13 @@ config INPUT_SOC_BUTTON_ARRAY
To compile this driver as a module, choose M here: the
module will be called soc_button_array.
+config INPUT_DRV260X_HAPTICS
+ tristate "TI DRV260X haptics support"
+ depends on INPUT && I2C
+ help
+ Say Y to enable support for the TI DRV260X haptics driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called drv260x-haptics.
+
endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 4955ad3..d8ef3c7 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -64,3 +64,4 @@ obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
obj-$(CONFIG_INPUT_YEALINK) += yealink.o
obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o
+obj-$(CONFIG_INPUT_DRV260X_HAPTICS) += drv260x.o
diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
new file mode 100644
index 0000000..aadfd57
--- /dev/null
+++ b/drivers/input/misc/drv260x.c
@@ -0,0 +1,537 @@
+/*
+ * drv260x.c - DRV260X haptics driver family
+ *
+ * Author: Dan Murphy <dmurphy@ti.com>
+ *
+ * Copyright: (C) 2014 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/regulator/consumer.h>
+
+#include <linux/input/drv260x.h>
+#include <dt-bindings/input/ti-drv260x.h>
+
+#define DRV260X_MAX_EFFECTS 255
+
+/**
+ * struct drv260x_data -
+ * @input_dev - Pointer to the input device
+ * @client - Pointer to the I2C client
+ * @timer - High res timer used to turn on/off vibration
+ * @regmap - Register map of the device
+ * @lock - Lock for device access
+ * @work - Work item used to off load the enable/disable of the vibration
+ * @enable_gpio - Pointer to the gpio used for enable/disabling
+ * @regulator - Pointer to the regulator for the IC
+ * @upload_effects - Vibration effect data array
+ * @runtime_left - Indicates how much runtime is remaining in the timer
+ * @effect_id - The ID of the vibration effect requested to be played
+ * @mode - The operating mode of the IC (RTP, ERM or LRA)
+ * @library - The vibration library to be used
+ * @rated_voltage - The rated_voltage of the actuator
+ * @overdriver_voltage - The over drive voltage of the actuator
+**/
+struct drv260x_data {
+ struct input_dev *input_dev;
+ struct i2c_client *client;
+ struct hrtimer timer;
+ struct regmap *regmap;
+ struct mutex lock;
+ struct work_struct work;
+ struct gpio_desc *enable_gpio;
+ struct regulator *regulator;
+ struct ff_effect upload_effects[DRV260X_MAX_EFFECTS];
+ u32 runtime_left;
+ u32 effect_id;
+ int mode;
+ int library;
+ int rated_voltage;
+ int overdrive_voltage;
+};
+
+static struct reg_default drv260x_reg_defs[] = {
+ { DRV260X_STATUS, 0xe0 },
+ { DRV260X_MODE, 0x40 },
+ { DRV260X_RT_PB_IN, 0x00},
+ { DRV260X_LIB_SEL, 0x00},
+ { DRV260X_WV_SEQ_1, 0x01},
+ { DRV260X_WV_SEQ_2, 0x00},
+ { DRV260X_WV_SEQ_3, 0x00},
+ { DRV260X_WV_SEQ_4, 0x00},
+ { DRV260X_WV_SEQ_5, 0x00},
+ { DRV260X_WV_SEQ_6, 0x00},
+ { DRV260X_WV_SEQ_7, 0x00},
+ { DRV260X_WV_SEQ_8, 0x00},
+ { DRV260X_GO, 0x00},
+ { DRV260X_OVERDRIVE_OFF, 0x00},
+ { DRV260X_SUSTAIN_P_OFF, 0x00},
+ { DRV260X_SUSTAIN_N_OFF, 0x00},
+ { DRV260X_BRAKE_OFF , 0x00},
+ { DRV260X_A_TO_V_CTRL , 0x05},
+ { DRV260X_A_TO_V_MIN_INPUT, 0x19},
+ { DRV260X_A_TO_V_MAX_INPUT, 0xff},
+ { DRV260X_A_TO_V_MIN_OUT, 0x19},
+ { DRV260X_A_TO_V_MAX_OUT, 0xff},
+ { DRV260X_RATED_VOLT, 0x3e},
+ { DRV260X_OD_CLAMP_VOLT, 0x8c},
+ { DRV260X_CAL_COMP, 0x0c},
+ { DRV260X_CAL_BACK_EMF, 0x6c},
+ { DRV260X_FEEDBACK_CTRL, 0x36},
+ { DRV260X_CTRL1, 0x93},
+ { DRV260X_CTRL2, 0xfa},
+ { DRV260X_CTRL3, 0xa0},
+ { DRV260X_CTRL4, 0x20},
+ { DRV260X_CTRL5, 0x80},
+ { DRV260X_LRA_LOOP_PERIOD, 0x33},
+ { DRV260X_VBAT_MON, 0x00},
+ { DRV260X_LRA_RES_PERIOD, 0x00},
+};
+
+/**
+ * Rated and Overdriver Voltages:
+ * Calculated using the formula r = v * 255 / 5.6
+ * where r is what will be written to the register
+ * and v is the rated or overdriver voltage of the actuator
+ **/
+#define DRV260X_DEF_RATED_VOLT 0x90
+#define DRV260X_DEF_OD_CLAMP_VOLT 0x90
+
+static int drv260x_calculate_voltage(int voltage)
+{
+ return (voltage * 255 / 5600);
+}
+
+static void drv260x_worker(struct work_struct *work)
+{
+ struct drv260x_data *haptics = container_of(work, struct drv260x_data, work);
+ int effect_id = haptics->effect_id;
+ int magnitude;
+
+ mutex_lock(&haptics->lock);
+
+ if (haptics->upload_effects[effect_id].u.rumble.strong_magnitude > 0)
+ magnitude = haptics->upload_effects[effect_id].u.rumble.strong_magnitude;
+ else if (haptics->upload_effects[effect_id].u.rumble.weak_magnitude > 0)
+ magnitude = haptics->upload_effects[effect_id].u.rumble.weak_magnitude;
+ else
+ goto out;
+
+ if (haptics->runtime_left > 0)
+ regmap_write(haptics->regmap, DRV260X_RT_PB_IN, magnitude);
+ else
+ regmap_write(haptics->regmap, DRV260X_RT_PB_IN, 0x0);
+
+out:
+ mutex_unlock(&haptics->lock);
+}
+
+static enum hrtimer_restart drv260x_timer(struct hrtimer *timer)
+{
+ struct drv260x_data *data = container_of(timer, struct drv260x_data, timer);
+
+ data->runtime_left = 0;
+ schedule_work(&data->work);
+
+ return HRTIMER_NORESTART;
+}
+
+static int drv260x_playback(struct input_dev *input, int effect_id, int value)
+{
+ struct drv260x_data *haptics = input_get_drvdata(input);
+ unsigned long time_ms;
+
+ gpiod_set_value(haptics->enable_gpio, 1);
+ /* Data sheet says to wait 250us before trying to communicate */
+ udelay(250);
+
+ regmap_write(haptics->regmap, DRV260X_MODE, DRV260X_RT_PLAYBACK);
+
+ haptics->mode = DRV260X_RTP_MODE;
+ haptics->runtime_left = haptics->upload_effects[effect_id].replay.length;
+ haptics->effect_id = effect_id;
+
+ time_ms = haptics->runtime_left * NSEC_PER_MSEC;
+
+ schedule_work(&haptics->work);
+ hrtimer_start(&haptics->timer, ktime_set(0, time_ms), HRTIMER_MODE_REL);
+
+ return 0;
+}
+
+static int drv260x_upload_effect(struct input_dev *input,
+ struct ff_effect *effect,
+ struct ff_effect *old)
+{
+ struct drv260x_data *haptics = input_get_drvdata(input);
+
+ haptics->upload_effects[effect->id] = *effect;
+
+ return 0;
+}
+
+static void drv260x_close(struct input_dev *input)
+{
+ struct drv260x_data *haptics = input_get_drvdata(input);
+
+ cancel_work_sync(&haptics->work);
+ regmap_write(haptics->regmap, DRV260X_MODE, DRV260X_STANDBY);
+ gpiod_set_value(haptics->enable_gpio, 0);
+}
+
+static const struct reg_default drv260x_lra_cal_regs[] = {
+ { DRV260X_MODE, DRV260X_AUTO_CAL },
+ { DRV260X_CTRL3, DRV260X_NG_THRESH_2},
+ { DRV260X_FEEDBACK_CTRL, DRV260X_FB_REG_LRA_MODE | DRV260X_BRAKE_FACTOR_4X | DRV260X_LOOP_GAIN_HIGH },
+};
+
+static const struct reg_default drv260x_lra_init_regs[] = {
+ { DRV260X_MODE, DRV260X_RT_PLAYBACK},
+ { DRV260X_LIB_SEL, DRV260X_LIB_F },
+ { DRV260X_A_TO_V_CTRL, DRV260X_AUDIO_HAPTICS_PEAK_20MS | DRV260X_AUDIO_HAPTICS_FILTER_125HZ},
+ { DRV260X_A_TO_V_MIN_INPUT, DRV260X_AUDIO_HAPTICS_MIN_IN_VOLT },
+ { DRV260X_A_TO_V_MAX_INPUT, DRV260X_AUDIO_HAPTICS_MAX_IN_VOLT },
+ { DRV260X_A_TO_V_MIN_OUT, DRV260X_AUDIO_HAPTICS_MIN_OUT_VOLT },
+ { DRV260X_A_TO_V_MAX_OUT, DRV260X_AUDIO_HAPTICS_MAX_OUT_VOLT },
+ { DRV260X_FEEDBACK_CTRL, DRV260X_FB_REG_LRA_MODE | DRV260X_BRAKE_FACTOR_2X | DRV260X_LOOP_GAIN_MED | DRV260X_BEMF_GAIN_3 },
+ { DRV260X_CTRL1, DRV260X_STARTUP_BOOST },
+ { DRV260X_CTRL2, DRV260X_SAMP_TIME_250 },
+ { DRV260X_CTRL3, DRV260X_NG_THRESH_2 | DRV260X_ANANLOG_IN },
+ { DRV260X_CTRL4, DRV260X_AUTOCAL_TIME_500MS },
+};
+
+static const struct reg_default drv260x_erm_cal_regs[] = {
+ { DRV260X_MODE, DRV260X_AUTO_CAL },
+ { DRV260X_A_TO_V_MIN_INPUT, DRV260X_AUDIO_HAPTICS_MIN_IN_VOLT },
+ { DRV260X_A_TO_V_MAX_INPUT, DRV260X_AUDIO_HAPTICS_MAX_IN_VOLT },
+ { DRV260X_A_TO_V_MIN_OUT, DRV260X_AUDIO_HAPTICS_MIN_OUT_VOLT },
+ { DRV260X_A_TO_V_MAX_OUT, DRV260X_AUDIO_HAPTICS_MAX_OUT_VOLT },
+ { DRV260X_FEEDBACK_CTRL, DRV260X_BRAKE_FACTOR_3X | DRV260X_LOOP_GAIN_MED | DRV260X_BEMF_GAIN_2 },
+ { DRV260X_CTRL1, DRV260X_STARTUP_BOOST },
+ { DRV260X_CTRL2, DRV260X_SAMP_TIME_250 | DRV260X_BLANK_TIME_75 | DRV260X_SAMP_TIME_250 | DRV260X_IDISS_TIME_75 },
+ { DRV260X_CTRL3, DRV260X_NG_THRESH_2 | DRV260X_ERM_OPEN_LOOP },
+ { DRV260X_CTRL4, DRV260X_AUTOCAL_TIME_500MS },
+};
+
+static int drv260x_init(struct drv260x_data *haptics)
+{
+ int ret;
+ unsigned int cal_buf;
+
+ ret = regmap_write(haptics->regmap,
+ DRV260X_RATED_VOLT, haptics->rated_voltage);
+ if (ret != 0)
+ goto write_failure;
+
+ ret = regmap_write(haptics->regmap,
+ DRV260X_OD_CLAMP_VOLT, haptics->overdrive_voltage);
+ if (ret != 0)
+ goto write_failure;
+
+ if (haptics->mode == DRV260X_LRA_MODE) {
+ ret = regmap_register_patch(haptics->regmap,
+ drv260x_lra_cal_regs,
+ ARRAY_SIZE(drv260x_lra_cal_regs));
+ if (ret != 0)
+ goto write_failure;
+
+ } else if (haptics->mode == DRV260X_ERM_MODE) {
+ ret = regmap_register_patch(haptics->regmap,
+ drv260x_erm_cal_regs,
+ ARRAY_SIZE(drv260x_erm_cal_regs));
+ if (ret != 0)
+ goto write_failure;
+
+ ret = regmap_update_bits(haptics->regmap, DRV260X_LIB_SEL,
+ DRV260X_LIB_SEL_MASK,
+ haptics->library);
+ if (ret != 0)
+ goto write_failure;
+
+ } else {
+ ret = regmap_register_patch(haptics->regmap,
+ drv260x_lra_init_regs,
+ ARRAY_SIZE(drv260x_lra_init_regs));
+ if (ret != 0)
+ goto write_failure;
+
+ goto skip_go_bit;
+ }
+
+ if (ret != 0) {
+ dev_err(&haptics->client->dev,
+ "Failed to write init registers: %d\n",
+ ret);
+ goto write_failure;
+ }
+
+ ret = regmap_write(haptics->regmap, DRV260X_GO, DRV260X_GO_BIT);
+ if (ret != 0)
+ goto write_failure;
+
+ do {
+ ret = regmap_read(haptics->regmap, DRV260X_GO, &cal_buf);
+ if (ret != 0)
+ goto write_failure;
+ } while (cal_buf == DRV260X_GO_BIT || ret != 0);
+
+ return ret;
+
+write_failure:
+ dev_err(&haptics->client->dev,
+ "Failed to write init registers: %d\n",
+ ret);
+skip_go_bit:
+ return ret;
+}
+
+static const struct regmap_config drv260x_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+
+ .max_register = DRV260X_MAX_REG,
+ .reg_defaults = drv260x_reg_defs,
+ .num_reg_defaults = ARRAY_SIZE(drv260x_reg_defs),
+ .cache_type = REGCACHE_NONE,
+};
+
+static int drv260x_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct drv260x_data *haptics;
+ struct device_node *np = client->dev.of_node;
+ struct drv260x_platform_data *pdata = client->dev.platform_data;
+ struct ff_device *ff;
+ int ret;
+ int voltage;
+
+ haptics = devm_kzalloc(&client->dev, sizeof(*haptics), GFP_KERNEL);
+ if (!haptics)
+ return -ENOMEM;
+
+ haptics->rated_voltage = DRV260X_DEF_OD_CLAMP_VOLT;
+ haptics->rated_voltage = DRV260X_DEF_RATED_VOLT;
+
+ if (np) {
+ ret = of_property_read_u32(np, "mode", &haptics->mode);
+ if (ret < 0) {
+ dev_err(&client->dev,
+ "%s: No entry for mode\n", __func__);
+
+ return ret;
+ }
+ ret = of_property_read_u32(np, "library_sel",
+ &haptics->library);
+ if (ret < 0) {
+ dev_err(&client->dev,
+ "%s: No entry for library selection\n", __func__);
+
+ return ret;
+ }
+ ret = of_property_read_u32(np, "vib_rated_voltage",
+ &voltage);
+ if (!ret)
+ haptics->rated_voltage = drv260x_calculate_voltage(voltage);
+
+
+ ret = of_property_read_u32(np, "vib_overdrive_voltage",
+ &voltage);
+ if (!ret)
+ haptics->overdrive_voltage = drv260x_calculate_voltage(voltage);
+
+ } else if (pdata) {
+ haptics->mode = pdata->mode;
+ haptics->library = pdata->library_selection;
+ if (pdata->vib_overdrive_voltage)
+ haptics->overdrive_voltage = drv260x_calculate_voltage(pdata->vib_overdrive_voltage);
+ if (pdata->vib_rated_voltage)
+ haptics->rated_voltage = drv260x_calculate_voltage(pdata->vib_rated_voltage);
+ } else {
+ dev_err(&client->dev, "Platform data not set\n");
+ return -ENODEV;
+ }
+
+ haptics->regulator = regulator_get(&client->dev, "vbat");
+ if (IS_ERR(haptics->regulator)) {
+ ret = PTR_ERR(haptics->regulator);
+ dev_err(&client->dev,
+ "unable to get regulator, error: %d\n", ret);
+ goto err_regulator;
+ }
+
+ haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable");
+ if (IS_ERR(haptics->enable_gpio)) {
+ ret = PTR_ERR(haptics->enable_gpio);
+ if (ret != -ENOENT && ret != -ENOSYS)
+ goto err_gpio;
+
+ haptics->enable_gpio = NULL;
+ } else {
+ gpiod_direction_output(haptics->enable_gpio, 1);
+ }
+
+ haptics->input_dev = input_allocate_device();
+ if (haptics->input_dev == NULL) {
+ dev_err(&client->dev, "Failed to allocate input device\n");
+ ret = -ENOMEM;
+ goto err_input_alloc;
+ }
+
+ haptics->input_dev->name = "drv260x:haptics";
+ haptics->input_dev->dev.parent = client->dev.parent;
+ haptics->input_dev->close = drv260x_close;
+ input_set_drvdata(haptics->input_dev, haptics);
+ input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE);
+
+ ret = input_ff_create(haptics->input_dev, DRV260X_MAX_EFFECTS);
+ if (ret < 0) {
+ dev_err(&client->dev, "input_ff_create() failed: %d\n",
+ ret);
+ goto err_ff_create;
+ }
+
+ ff = haptics->input_dev->ff;
+ ff->playback = drv260x_playback;
+ ff->upload = drv260x_upload_effect;
+
+ mutex_init(&haptics->lock);
+ INIT_WORK(&haptics->work, drv260x_worker);
+ hrtimer_init(&haptics->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ haptics->timer.function = drv260x_timer;
+
+ haptics->client = client;
+ i2c_set_clientdata(client, haptics);
+
+ haptics->regmap = devm_regmap_init_i2c(client, &drv260x_regmap_config);
+ if (IS_ERR(haptics->regmap)) {
+ ret = PTR_ERR(haptics->regmap);
+ dev_err(&client->dev, "Failed to allocate register map: %d\n",
+ ret);
+ goto err_regmap;
+ }
+
+ drv260x_init(haptics);
+
+ ret = input_register_device(haptics->input_dev);
+ if (ret < 0) {
+ dev_err(&client->dev, "couldn't register input device: %d\n",
+ ret);
+ goto err_iff;
+ }
+ return 0;
+
+err_iff:
+err_regmap:
+ if (haptics->input_dev)
+ input_ff_destroy(haptics->input_dev);
+err_ff_create:
+ input_free_device(haptics->input_dev);
+err_input_alloc:
+err_gpio:
+ regulator_put(haptics->regulator);
+err_regulator:
+ return ret;
+}
+
+static int drv260x_remove(struct i2c_client *client)
+{
+ struct drv260x_data *haptics = i2c_get_clientdata(client);
+
+ cancel_work_sync(&haptics->work);
+
+ regmap_write(haptics->regmap, DRV260X_MODE, DRV260X_STANDBY);
+ gpiod_set_value(haptics->enable_gpio, 0);
+
+ input_unregister_device(haptics->input_dev);
+ regulator_put(haptics->regulator);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int drv260x_suspend(struct device *dev)
+{
+ struct drv260x_data *haptics = dev_get_drvdata(dev);
+
+ regmap_update_bits(haptics->regmap,
+ DRV260X_MODE,
+ DRV260X_STANDBY_MASK,
+ DRV260X_STANDBY);
+ gpiod_set_value(haptics->enable_gpio, 0);
+
+ regulator_disable(haptics->regulator);
+
+ return 0;
+}
+
+static int drv260x_resume(struct device *dev)
+{
+ struct drv260x_data *haptics = dev_get_drvdata(dev);
+ int ret;
+
+ ret = regulator_enable(haptics->regulator);
+ if (ret) {
+ dev_err(dev, "Failed to enable regulator\n");
+ return ret;
+ }
+ regmap_update_bits(haptics->regmap,
+ DRV260X_MODE,
+ DRV260X_STANDBY_MASK, 0);
+
+ gpiod_set_value(haptics->enable_gpio, 1);
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(drv260x_pm_ops, drv260x_suspend, drv260x_resume);
+
+static const struct i2c_device_id drv260x_id[] = {
+ { "drv2605l", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, drv260x_id);
+
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id drv260x_of_match[] = {
+ { .compatible = "ti,drv2604", },
+ { .compatible = "ti,drv2605", },
+ { .compatible = "ti,drv2605l", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, drv260x_of_match);
+#endif
+
+static struct i2c_driver drv260x_driver = {
+ .probe = drv260x_probe,
+ .remove = drv260x_remove,
+ .driver = {
+ .name = "drv260x-haptics",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(drv260x_of_match),
+ .pm = &drv260x_pm_ops,
+ },
+ .id_table = drv260x_id,
+};
+module_i2c_driver(drv260x_driver);
+
+MODULE_ALIAS("platform:drv260x-haptics");
+MODULE_DESCRIPTION("TI DRV260x haptics driver");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
diff --git a/include/dt-bindings/input/ti-drv260x.h b/include/dt-bindings/input/ti-drv260x.h
new file mode 100644
index 0000000..28f1dfa
--- /dev/null
+++ b/include/dt-bindings/input/ti-drv260x.h
@@ -0,0 +1,30 @@
+/*
+ * ti-drv260x.h - DRV260X haptics driver family
+ *
+ * Author: Dan Murphy <dmurphy@ti.com>
+ *
+ * Copyright: (C) 2014 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+/* Calibration Types */
+#define DRV260X_RTP_MODE 0x00
+#define DRV260X_LRA_MODE 0x01
+#define DRV260X_ERM_MODE 0x02
+
+/* Library Selection */
+#define DRV260X_LIB_SEL_DEFAULT 0x00
+#define DRV260X_LIB_A 0x01
+#define DRV260X_LIB_B 0x02
+#define DRV260X_LIB_C 0x03
+#define DRV260X_LIB_D 0x04
+#define DRV260X_LIB_E 0x05
+#define DRV260X_LIB_F 0x06
diff --git a/include/linux/input/drv260x.h b/include/linux/input/drv260x.h
new file mode 100644
index 0000000..709395e
--- /dev/null
+++ b/include/linux/input/drv260x.h
@@ -0,0 +1,181 @@
+/*
+ * drv260x.h - DRV260X haptics driver family
+ *
+ * Author: Dan Murphy <dmurphy@ti.com>
+ *
+ * Copyright: (C) 2014 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef _LINUX_DRV260X_I2C_H
+#define _LINUX_DRV260X_I2C_H
+
+#define DRV260X_STATUS 0x0
+#define DRV260X_MODE 0x1
+#define DRV260X_RT_PB_IN 0x2
+#define DRV260X_LIB_SEL 0x3
+#define DRV260X_WV_SEQ_1 0x4
+#define DRV260X_WV_SEQ_2 0x5
+#define DRV260X_WV_SEQ_3 0x6
+#define DRV260X_WV_SEQ_4 0x7
+#define DRV260X_WV_SEQ_5 0x8
+#define DRV260X_WV_SEQ_6 0x9
+#define DRV260X_WV_SEQ_7 0xa
+#define DRV260X_WV_SEQ_8 0xb
+#define DRV260X_GO 0xc
+#define DRV260X_OVERDRIVE_OFF 0xd
+#define DRV260X_SUSTAIN_P_OFF 0xe
+#define DRV260X_SUSTAIN_N_OFF 0xf
+#define DRV260X_BRAKE_OFF 0x10
+#define DRV260X_A_TO_V_CTRL 0x11
+#define DRV260X_A_TO_V_MIN_INPUT 0x12
+#define DRV260X_A_TO_V_MAX_INPUT 0x13
+#define DRV260X_A_TO_V_MIN_OUT 0x14
+#define DRV260X_A_TO_V_MAX_OUT 0x15
+#define DRV260X_RATED_VOLT 0x16
+#define DRV260X_OD_CLAMP_VOLT 0x17
+#define DRV260X_CAL_COMP 0x18
+#define DRV260X_CAL_BACK_EMF 0x19
+#define DRV260X_FEEDBACK_CTRL 0x1a
+#define DRV260X_CTRL1 0x1b
+#define DRV260X_CTRL2 0x1c
+#define DRV260X_CTRL3 0x1d
+#define DRV260X_CTRL4 0x1e
+#define DRV260X_CTRL5 0x1f
+#define DRV260X_LRA_LOOP_PERIOD 0x20
+#define DRV260X_VBAT_MON 0x21
+#define DRV260X_LRA_RES_PERIOD 0x22
+#define DRV260X_MAX_REG 0x23
+
+#define DRV260X_ALLOWED_R_BYTES 25
+#define DRV260X_ALLOWED_W_BYTES 2
+#define DRV260X_MAX_RW_RETRIES 5
+#define DRV260X_I2C_RETRY_DELAY 10
+
+#define DRV260X_GO_BIT 0x01
+
+/* Library Selection */
+#define DRV260X_LIB_SEL_MASK 0x07
+#define DRV260X_LIB_SEL_RAM 0x0
+#define DRV260X_LIB_SEL_OD 0x1
+#define DRV260X_LIB_SEL_40_60 0x2
+#define DRV260X_LIB_SEL_60_80 0x3
+#define DRV260X_LIB_SEL_100_140 0x4
+#define DRV260X_LIB_SEL_140_PLUS 0x5
+
+#define DRV260X_LIB_SEL_HIZ_MASK 0x10
+#define DRV260X_LIB_SEL_HIZ_EN 0x01
+#define DRV260X_LIB_SEL_HIZ_DIS 0
+
+/* Mode register */
+#define DRV260X_STANDBY (1 << 6)
+#define DRV260X_STANDBY_MASK 0x40
+#define DRV260X_INTERNAL_TRIGGER 0x00
+#define DRV260X_EXT_TRIGGER_EDGE 0x01
+#define DRV260X_EXT_TRIGGER_LEVEL 0x02
+#define DRV260X_PWM_ANALOG_IN 0x03
+#define DRV260X_AUDIOHAPTIC 0x04
+#define DRV260X_RT_PLAYBACK 0x05
+#define DRV260X_DIAGNOSTICS 0x06
+#define DRV260X_AUTO_CAL 0x07
+
+/* Audio to Haptics Control */
+#define DRV260X_AUDIO_HAPTICS_PEAK_10MS (0 << 2)
+#define DRV260X_AUDIO_HAPTICS_PEAK_20MS (1 << 2)
+#define DRV260X_AUDIO_HAPTICS_PEAK_30MS (2 << 2)
+#define DRV260X_AUDIO_HAPTICS_PEAK_40MS (3 << 2)
+
+#define DRV260X_AUDIO_HAPTICS_FILTER_100HZ 0x00
+#define DRV260X_AUDIO_HAPTICS_FILTER_125HZ 0x01
+#define DRV260X_AUDIO_HAPTICS_FILTER_150HZ 0x02
+#define DRV260X_AUDIO_HAPTICS_FILTER_200HZ 0x03
+
+/* Min/Max Input/Output Voltages */
+#define DRV260X_AUDIO_HAPTICS_MIN_IN_VOLT 0x19
+#define DRV260X_AUDIO_HAPTICS_MAX_IN_VOLT 0x64
+#define DRV260X_AUDIO_HAPTICS_MIN_OUT_VOLT 0x19
+#define DRV260X_AUDIO_HAPTICS_MAX_OUT_VOLT 0xFF
+
+/* Feedback register */
+#define DRV260X_FB_REG_ERM_MODE 0x7f
+#define DRV260X_FB_REG_LRA_MODE (1 << 7)
+
+#define DRV260X_BRAKE_FACTOR_MASK 0x1f
+#define DRV260X_BRAKE_FACTOR_2X (1 << 0)
+#define DRV260X_BRAKE_FACTOR_3X (2 << 4)
+#define DRV260X_BRAKE_FACTOR_4X (3 << 4)
+#define DRV260X_BRAKE_FACTOR_6X (4 << 4)
+#define DRV260X_BRAKE_FACTOR_8X (5 << 4)
+#define DRV260X_BRAKE_FACTOR_16 (6 << 4)
+#define DRV260X_BRAKE_FACTOR_DIS (7 << 4)
+
+#define DRV260X_LOOP_GAIN_LOW 0xf3
+#define DRV260X_LOOP_GAIN_MED (1 << 2)
+#define DRV260X_LOOP_GAIN_HIGH (2 << 2)
+#define DRV260X_LOOP_GAIN_VERY_HIGH (3 << 2)
+
+#define DRV260X_BEMF_GAIN_0 0xfc
+#define DRV260X_BEMF_GAIN_1 (1 << 0)
+#define DRV260X_BEMF_GAIN_2 (2 << 0)
+#define DRV260X_BEMF_GAIN_3 (3 << 0)
+
+/* Control 1 register */
+#define DRV260X_AC_CPLE_EN (1 << 5)
+#define DRV260X_STARTUP_BOOST (1 << 7)
+
+/* Control 2 register */
+
+#define DRV260X_IDISS_TIME_45 0
+#define DRV260X_IDISS_TIME_75 (1 << 0)
+#define DRV260X_IDISS_TIME_150 (1 << 1)
+#define DRV260X_IDISS_TIME_225 0x03
+
+#define DRV260X_BLANK_TIME_45 (0 << 2)
+#define DRV260X_BLANK_TIME_75 (1 << 2)
+#define DRV260X_BLANK_TIME_150 (2 << 2)
+#define DRV260X_BLANK_TIME_225 (3 << 2)
+
+#define DRV260X_SAMP_TIME_150 (0 << 4)
+#define DRV260X_SAMP_TIME_200 (1 << 4)
+#define DRV260X_SAMP_TIME_250 (2 << 4)
+#define DRV260X_SAMP_TIME_300 (3 << 4)
+
+#define DRV260X_BRAKE_STABILIZER (1 << 6)
+#define DRV260X_UNIDIR_IN (0 << 7)
+#define DRV260X_BIDIR_IN (1 << 7)
+
+/* Control 3 Register */
+#define DRV260X_LRA_OPEN_LOOP (1 << 0)
+#define DRV260X_ANANLOG_IN (1 << 1)
+#define DRV260X_LRA_DRV_MODE (1 << 2)
+#define DRV260X_RTP_UNSIGNED_DATA (1 << 3)
+#define DRV260X_SUPPLY_COMP_DIS (1 << 4)
+#define DRV260X_ERM_OPEN_LOOP (1 << 5)
+#define DRV260X_NG_THRESH_0 (0 << 6)
+#define DRV260X_NG_THRESH_2 (1 << 6)
+#define DRV260X_NG_THRESH_4 (2 << 6)
+#define DRV260X_NG_THRESH_8 (3 << 6)
+
+/* Control 4 Register */
+#define DRV260X_AUTOCAL_TIME_150MS (0 << 4)
+#define DRV260X_AUTOCAL_TIME_250MS (1 << 4)
+#define DRV260X_AUTOCAL_TIME_500MS (2 << 4)
+#define DRV260X_AUTOCAL_TIME_1000MS (3 << 4)
+
+struct drv260x_platform_data {
+ int enable_gpio;
+ int library_selection;
+ int mode;
+ int vib_rated_voltage;
+ int vib_overdrive_voltage;
+};
+
+#endif
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v2 07/10] Input - wacom: handle Graphire BT tablets in wacom.ko
From: Dmitry Torokhov @ 2014-07-24 19:35 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Jiri Kosina, Ping Cheng, Jason Gerecke, Przemo Firszt,
linux-kernel, linux-input
In-Reply-To: <1406225645-32141-8-git-send-email-benjamin.tissoires@redhat.com>
Hi Benjamin,
On Thu, Jul 24, 2014 at 02:14:02PM -0400, Benjamin Tissoires wrote:
> First, merge the Graphire BT tablet.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>
> changes in v2:
> - simplified because part of it has been splitted out in the previous commit.
>
> drivers/hid/hid-core.c | 1 -
> drivers/hid/hid-wacom.c | 1 -
> drivers/hid/wacom_sys.c | 42 +++++++++++++++++++++
> drivers/hid/wacom_wac.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
> drivers/hid/wacom_wac.h | 2 +
> 5 files changed, 140 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 7cff1c2..4db6804 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1920,7 +1920,6 @@ 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_DUAL_BOX_PRO) },
> { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
> - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
> { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
> { 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) },
> diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
> index 4874f4e..967c457 100644
> --- a/drivers/hid/hid-wacom.c
> +++ b/drivers/hid/hid-wacom.c
> @@ -952,7 +952,6 @@ static void wacom_remove(struct hid_device *hdev)
> }
>
> static const struct hid_device_id wacom_devices[] = {
> - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
> { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
>
> { }
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index add76ec..8492177 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -265,6 +265,48 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
> static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
> struct wacom_features *features)
> {
> + struct wacom *wacom = hid_get_drvdata(hdev);
> + int limit, ret;
> + __u8 rep_data[2];
I think just u8 in kerneli proper.
> +
> + switch (features->type) {
> + case GRAPHIRE_BT:
> + rep_data[0] = 0x03 ; rep_data[1] = 0x00;
> + limit = 3;
> + do {
> + ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
> + HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
> + } while (ret < 0 && limit-- > 0);
> +
> + if (ret >= 0) {
> + if (speed == 0)
> + rep_data[0] = 0x05;
> + else
> + rep_data[0] = 0x06;
I am a fan of
rep_data[0] = speed == 0 ? 0x05 : 0x06;
as it takes 1 line vs 3.
> +
> + rep_data[1] = 0x00;
> + limit = 3;
> + do {
> + ret = hid_hw_raw_request(hdev, rep_data[0],
> + rep_data, 2, HID_FEATURE_REPORT,
> + HID_REQ_SET_REPORT);
> + } while (ret < 0 && limit-- > 0);
> +
> + if (ret >= 0) {
> + wacom->wacom_wac.bt_high_speed = speed;
> + return 0;
> + }
> + }
> +
> + /*
> + * Note that if the raw queries fail, it's not a hard failure
> + * and it is safe to continue
> + */
> + hid_warn(hdev, "failed to poke device, command %d, err %d\n",
> + rep_data[0], ret);
> + break;
> + }
> +
> return 0;
> }
>
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 2c69326..06bc600 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -30,6 +30,10 @@
> */
> #define WACOM_CONTACT_AREA_SCALE 2607
>
> +/*percent of battery capacity for Graphire
> + 8th value means AC online and show 100% capacity */
> +static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
> +
> static int wacom_penpartner_irq(struct wacom_wac *wacom)
> {
> unsigned char *data = wacom->data;
> @@ -263,11 +267,19 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> unsigned char *data = wacom->data;
> struct input_dev *input = wacom->input;
> struct input_dev *pad_input = wacom->pad_input;
> + int battery_capacity, ps_connected;
> int prox;
> int rw = 0;
> int retval = 0;
>
> - if (data[0] != WACOM_REPORT_PENABLED) {
> + if (features->type == GRAPHIRE_BT) {
> + if (data[0] != WACOM_REPORT_PENABLED_BT) {
> + dev_dbg(input->dev.parent,
> + "%s: received unknown report #%d\n", __func__,
> + data[0]);
> + goto exit;
> + }
> + } else if (data[0] != WACOM_REPORT_PENABLED) {
> dev_dbg(input->dev.parent,
> "%s: received unknown report #%d\n", __func__, data[0]);
> goto exit;
> @@ -301,7 +313,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
> input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
> if (wacom->tool[0] != BTN_TOOL_MOUSE) {
> - input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
> + if (features->type == GRAPHIRE_BT)
> + input_report_abs(input, ABS_PRESSURE, data[6] |
> + (((__u16) (data[1] & 0x08)) << 5));
> + else
> + input_report_abs(input, ABS_PRESSURE, data[6] |
> + ((data[7] & 0x03) << 8));
> input_report_key(input, BTN_TOUCH, data[1] & 0x01);
> input_report_key(input, BTN_STYLUS, data[1] & 0x02);
> input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
> @@ -312,6 +329,23 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> features->type == WACOM_MO) {
> input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
> rw = (data[7] & 0x04) - (data[7] & 0x03);
> + } else if (features->type == GRAPHIRE_BT) {
> + /* Compute distance between mouse and tablet */
> + rw = 44 - (data[6] >> 2);
> + if (rw < 0)
> + rw = 0;
> + else if (rw > 31)
> + rw = 31;
rw = clamp_val(rw, 0, 31);
?
> + input_report_abs(input, ABS_DISTANCE, rw);
> + if (((data[1] >> 5) & 3) == 2) {
> + /* Mouse with wheel */
> + input_report_key(input, BTN_MIDDLE,
> + data[1] & 0x04);
> + rw = (data[6] & 0x01) ? -1 :
> + (data[6] & 0x02) ? 1 : 0;
> + } else {
> + rw = 0;
> + }
> } else {
> input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
> rw = -(signed char)data[6];
> @@ -358,6 +392,31 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> retval = 1;
> }
> break;
> + case GRAPHIRE_BT:
> + prox = data[7] & 0x03;
> + if (prox || wacom->id[1]) {
> + wacom->id[1] = PAD_DEVICE_ID;
> + input_report_key(pad_input, BTN_0, (data[7] & 0x02));
> + input_report_key(pad_input, BTN_1, (data[7] & 0x01));
> + if (!prox)
> + wacom->id[1] = 0;
> + input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
> + retval = 1;
> + }
> + break;
> + }
> +
> + /* Store current battery capacity and power supply state */
> + if (features->type == GRAPHIRE_BT) {
> + rw = (data[7] >> 2 & 0x07);
> + battery_capacity = batcap_gr[rw];
> + ps_connected = rw == 7;
> + if ((wacom->battery_capacity != battery_capacity) ||
> + (wacom->ps_connected != ps_connected)) {
> + wacom->battery_capacity = battery_capacity;
> + wacom->ps_connected = ps_connected;
> + wacom_notify_battery(wacom);
> + }
> }
> exit:
> return retval;
> @@ -1418,6 +1477,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
>
> case WACOM_G4:
> case GRAPHIRE:
> + case GRAPHIRE_BT:
> case WACOM_MO:
> sync = wacom_graphire_irq(wacom_wac);
> break;
> @@ -1654,6 +1714,27 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
> __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
> break;
>
> + case GRAPHIRE_BT:
> + __clear_bit(ABS_MISC, input_dev->absbit);
> + input_set_abs_params(input_dev, ABS_DISTANCE, 0,
> + features->distance_max,
> + 0, 0);
> +
> + input_set_capability(input_dev, EV_REL, REL_WHEEL);
> +
> + __set_bit(BTN_LEFT, input_dev->keybit);
> + __set_bit(BTN_RIGHT, input_dev->keybit);
> + __set_bit(BTN_MIDDLE, input_dev->keybit);
> +
> + __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
> + __set_bit(BTN_TOOL_PEN, input_dev->keybit);
> + __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
> + __set_bit(BTN_STYLUS, input_dev->keybit);
> + __set_bit(BTN_STYLUS2, input_dev->keybit);
> +
> + __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
> + break;
> +
> case WACOM_24HD:
> input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
> input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
> @@ -1848,6 +1929,11 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
> input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
>
> switch (features->type) {
> + case GRAPHIRE_BT:
> + __set_bit(BTN_0, input_dev->keybit);
> + __set_bit(BTN_1, input_dev->keybit);
> + break;
> +
> case WACOM_MO:
> __set_bit(BTN_BACK, input_dev->keybit);
> __set_bit(BTN_LEFT, input_dev->keybit);
> @@ -2017,6 +2103,9 @@ static const struct wacom_features wacom_features_0x00 =
> static const struct wacom_features wacom_features_0x10 =
> { "Wacom Graphire", 10206, 7422, 511, 63,
> GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
> +static const struct wacom_features wacom_features_0x81 =
> + { "Wacom Graphire BT", 16704, 12064, 511, 32,
> + GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
> static const struct wacom_features wacom_features_0x11 =
> { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
> GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
> @@ -2412,6 +2501,10 @@ static const struct wacom_features wacom_features_0x309 =
> HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
> .driver_data = (kernel_ulong_t)&wacom_features_##prod
>
> +#define BT_DEVICE_WACOM(prod) \
> + HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
> + .driver_data = (kernel_ulong_t)&wacom_features_##prod
> +
> #define USB_DEVICE_LENOVO(prod) \
> HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
> .driver_data = (kernel_ulong_t)&wacom_features_##prod
> @@ -2469,6 +2562,7 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0x69) },
> { USB_DEVICE_WACOM(0x6A) },
> { USB_DEVICE_WACOM(0x6B) },
> + { BT_DEVICE_WACOM(0x81) },
> { USB_DEVICE_WACOM(0x84) },
> { USB_DEVICE_WACOM(0x90) },
> { USB_DEVICE_WACOM(0x93) },
> diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
> index 3aa55d9..0f3df34 100644
> --- a/drivers/hid/wacom_wac.h
> +++ b/drivers/hid/wacom_wac.h
> @@ -46,6 +46,7 @@
>
> /* wacom data packet report IDs */
> #define WACOM_REPORT_PENABLED 2
> +#define WACOM_REPORT_PENABLED_BT 3
> #define WACOM_REPORT_INTUOSREAD 5
> #define WACOM_REPORT_INTUOSWRITE 6
> #define WACOM_REPORT_INTUOSPAD 12
> @@ -73,6 +74,7 @@
> enum {
> PENPARTNER = 0,
> GRAPHIRE,
> + GRAPHIRE_BT,
> WACOM_G4,
> PTU,
> PL,
> --
> 2.0.1
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 07/10] Input - wacom: handle Graphire BT tablets in wacom.ko
From: Benjamin Tissoires @ 2014-07-24 19:43 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jiri Kosina, Ping Cheng, Jason Gerecke, Przemo Firszt,
linux-kernel, linux-input
In-Reply-To: <20140724193509.GB26752@core.coreip.homeip.net>
On Jul 24 2014 or thereabouts, Dmitry Torokhov wrote:
> Hi Benjamin,
>
> On Thu, Jul 24, 2014 at 02:14:02PM -0400, Benjamin Tissoires wrote:
> > First, merge the Graphire BT tablet.
> >
> > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> > ---
> >
> > changes in v2:
> > - simplified because part of it has been splitted out in the previous commit.
> >
> > drivers/hid/hid-core.c | 1 -
> > drivers/hid/hid-wacom.c | 1 -
> > drivers/hid/wacom_sys.c | 42 +++++++++++++++++++++
> > drivers/hid/wacom_wac.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
> > drivers/hid/wacom_wac.h | 2 +
> > 5 files changed, 140 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > index 7cff1c2..4db6804 100644
> > --- a/drivers/hid/hid-core.c
> > +++ b/drivers/hid/hid-core.c
> > @@ -1920,7 +1920,6 @@ 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_DUAL_BOX_PRO) },
> > { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
> > - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
> > { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
> > { 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) },
> > diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
> > index 4874f4e..967c457 100644
> > --- a/drivers/hid/hid-wacom.c
> > +++ b/drivers/hid/hid-wacom.c
> > @@ -952,7 +952,6 @@ static void wacom_remove(struct hid_device *hdev)
> > }
> >
> > static const struct hid_device_id wacom_devices[] = {
> > - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
> > { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
> >
> > { }
> > diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> > index add76ec..8492177 100644
> > --- a/drivers/hid/wacom_sys.c
> > +++ b/drivers/hid/wacom_sys.c
> > @@ -265,6 +265,48 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
> > static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
> > struct wacom_features *features)
> > {
> > + struct wacom *wacom = hid_get_drvdata(hdev);
> > + int limit, ret;
> > + __u8 rep_data[2];
>
> I think just u8 in kerneli proper.
OK, I will adjust.
>
> > +
> > + switch (features->type) {
> > + case GRAPHIRE_BT:
> > + rep_data[0] = 0x03 ; rep_data[1] = 0x00;
> > + limit = 3;
> > + do {
> > + ret = hid_hw_raw_request(hdev, rep_data[0], rep_data, 2,
> > + HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
> > + } while (ret < 0 && limit-- > 0);
> > +
> > + if (ret >= 0) {
> > + if (speed == 0)
> > + rep_data[0] = 0x05;
> > + else
> > + rep_data[0] = 0x06;
>
> I am a fan of
>
> rep_data[0] = speed == 0 ? 0x05 : 0x06;
>
> as it takes 1 line vs 3.
>
hehe
BTW, actually, I just copied/pasted the chunks from hid-wacom. But you
are right, a little cleanup is definitively better.
> > +
> > + rep_data[1] = 0x00;
> > + limit = 3;
> > + do {
> > + ret = hid_hw_raw_request(hdev, rep_data[0],
> > + rep_data, 2, HID_FEATURE_REPORT,
> > + HID_REQ_SET_REPORT);
> > + } while (ret < 0 && limit-- > 0);
> > +
> > + if (ret >= 0) {
> > + wacom->wacom_wac.bt_high_speed = speed;
> > + return 0;
> > + }
> > + }
> > +
> > + /*
> > + * Note that if the raw queries fail, it's not a hard failure
> > + * and it is safe to continue
> > + */
> > + hid_warn(hdev, "failed to poke device, command %d, err %d\n",
> > + rep_data[0], ret);
> > + break;
> > + }
> > +
> > return 0;
> > }
> >
> > diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> > index 2c69326..06bc600 100644
> > --- a/drivers/hid/wacom_wac.c
> > +++ b/drivers/hid/wacom_wac.c
> > @@ -30,6 +30,10 @@
> > */
> > #define WACOM_CONTACT_AREA_SCALE 2607
> >
> > +/*percent of battery capacity for Graphire
> > + 8th value means AC online and show 100% capacity */
> > +static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
> > +
> > static int wacom_penpartner_irq(struct wacom_wac *wacom)
> > {
> > unsigned char *data = wacom->data;
> > @@ -263,11 +267,19 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> > unsigned char *data = wacom->data;
> > struct input_dev *input = wacom->input;
> > struct input_dev *pad_input = wacom->pad_input;
> > + int battery_capacity, ps_connected;
> > int prox;
> > int rw = 0;
> > int retval = 0;
> >
> > - if (data[0] != WACOM_REPORT_PENABLED) {
> > + if (features->type == GRAPHIRE_BT) {
> > + if (data[0] != WACOM_REPORT_PENABLED_BT) {
> > + dev_dbg(input->dev.parent,
> > + "%s: received unknown report #%d\n", __func__,
> > + data[0]);
> > + goto exit;
> > + }
> > + } else if (data[0] != WACOM_REPORT_PENABLED) {
> > dev_dbg(input->dev.parent,
> > "%s: received unknown report #%d\n", __func__, data[0]);
> > goto exit;
> > @@ -301,7 +313,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> > input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
> > input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
> > if (wacom->tool[0] != BTN_TOOL_MOUSE) {
> > - input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
> > + if (features->type == GRAPHIRE_BT)
> > + input_report_abs(input, ABS_PRESSURE, data[6] |
> > + (((__u16) (data[1] & 0x08)) << 5));
> > + else
> > + input_report_abs(input, ABS_PRESSURE, data[6] |
> > + ((data[7] & 0x03) << 8));
> > input_report_key(input, BTN_TOUCH, data[1] & 0x01);
> > input_report_key(input, BTN_STYLUS, data[1] & 0x02);
> > input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
> > @@ -312,6 +329,23 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> > features->type == WACOM_MO) {
> > input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
> > rw = (data[7] & 0x04) - (data[7] & 0x03);
> > + } else if (features->type == GRAPHIRE_BT) {
> > + /* Compute distance between mouse and tablet */
> > + rw = 44 - (data[6] >> 2);
> > + if (rw < 0)
> > + rw = 0;
> > + else if (rw > 31)
> > + rw = 31;
>
> rw = clamp_val(rw, 0, 31);
>
> ?
could be...
I'll do the tests and resubmit later the v3. I'll wait a little in case
you have other comments on the other patches :)
Cheers,
Benjamin
>
> > + input_report_abs(input, ABS_DISTANCE, rw);
> > + if (((data[1] >> 5) & 3) == 2) {
> > + /* Mouse with wheel */
> > + input_report_key(input, BTN_MIDDLE,
> > + data[1] & 0x04);
> > + rw = (data[6] & 0x01) ? -1 :
> > + (data[6] & 0x02) ? 1 : 0;
> > + } else {
> > + rw = 0;
> > + }
> > } else {
> > input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
> > rw = -(signed char)data[6];
> > @@ -358,6 +392,31 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
> > retval = 1;
> > }
> > break;
> > + case GRAPHIRE_BT:
> > + prox = data[7] & 0x03;
> > + if (prox || wacom->id[1]) {
> > + wacom->id[1] = PAD_DEVICE_ID;
> > + input_report_key(pad_input, BTN_0, (data[7] & 0x02));
> > + input_report_key(pad_input, BTN_1, (data[7] & 0x01));
> > + if (!prox)
> > + wacom->id[1] = 0;
> > + input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
> > + retval = 1;
> > + }
> > + break;
> > + }
> > +
> > + /* Store current battery capacity and power supply state */
> > + if (features->type == GRAPHIRE_BT) {
> > + rw = (data[7] >> 2 & 0x07);
> > + battery_capacity = batcap_gr[rw];
> > + ps_connected = rw == 7;
> > + if ((wacom->battery_capacity != battery_capacity) ||
> > + (wacom->ps_connected != ps_connected)) {
> > + wacom->battery_capacity = battery_capacity;
> > + wacom->ps_connected = ps_connected;
> > + wacom_notify_battery(wacom);
> > + }
> > }
> > exit:
> > return retval;
> > @@ -1418,6 +1477,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
> >
> > case WACOM_G4:
> > case GRAPHIRE:
> > + case GRAPHIRE_BT:
> > case WACOM_MO:
> > sync = wacom_graphire_irq(wacom_wac);
> > break;
> > @@ -1654,6 +1714,27 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
> > __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
> > break;
> >
> > + case GRAPHIRE_BT:
> > + __clear_bit(ABS_MISC, input_dev->absbit);
> > + input_set_abs_params(input_dev, ABS_DISTANCE, 0,
> > + features->distance_max,
> > + 0, 0);
> > +
> > + input_set_capability(input_dev, EV_REL, REL_WHEEL);
> > +
> > + __set_bit(BTN_LEFT, input_dev->keybit);
> > + __set_bit(BTN_RIGHT, input_dev->keybit);
> > + __set_bit(BTN_MIDDLE, input_dev->keybit);
> > +
> > + __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
> > + __set_bit(BTN_TOOL_PEN, input_dev->keybit);
> > + __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
> > + __set_bit(BTN_STYLUS, input_dev->keybit);
> > + __set_bit(BTN_STYLUS2, input_dev->keybit);
> > +
> > + __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
> > + break;
> > +
> > case WACOM_24HD:
> > input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
> > input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
> > @@ -1848,6 +1929,11 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
> > input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
> >
> > switch (features->type) {
> > + case GRAPHIRE_BT:
> > + __set_bit(BTN_0, input_dev->keybit);
> > + __set_bit(BTN_1, input_dev->keybit);
> > + break;
> > +
> > case WACOM_MO:
> > __set_bit(BTN_BACK, input_dev->keybit);
> > __set_bit(BTN_LEFT, input_dev->keybit);
> > @@ -2017,6 +2103,9 @@ static const struct wacom_features wacom_features_0x00 =
> > static const struct wacom_features wacom_features_0x10 =
> > { "Wacom Graphire", 10206, 7422, 511, 63,
> > GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
> > +static const struct wacom_features wacom_features_0x81 =
> > + { "Wacom Graphire BT", 16704, 12064, 511, 32,
> > + GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
> > static const struct wacom_features wacom_features_0x11 =
> > { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
> > GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
> > @@ -2412,6 +2501,10 @@ static const struct wacom_features wacom_features_0x309 =
> > HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
> > .driver_data = (kernel_ulong_t)&wacom_features_##prod
> >
> > +#define BT_DEVICE_WACOM(prod) \
> > + HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
> > + .driver_data = (kernel_ulong_t)&wacom_features_##prod
> > +
> > #define USB_DEVICE_LENOVO(prod) \
> > HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
> > .driver_data = (kernel_ulong_t)&wacom_features_##prod
> > @@ -2469,6 +2562,7 @@ const struct hid_device_id wacom_ids[] = {
> > { USB_DEVICE_WACOM(0x69) },
> > { USB_DEVICE_WACOM(0x6A) },
> > { USB_DEVICE_WACOM(0x6B) },
> > + { BT_DEVICE_WACOM(0x81) },
> > { USB_DEVICE_WACOM(0x84) },
> > { USB_DEVICE_WACOM(0x90) },
> > { USB_DEVICE_WACOM(0x93) },
> > diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
> > index 3aa55d9..0f3df34 100644
> > --- a/drivers/hid/wacom_wac.h
> > +++ b/drivers/hid/wacom_wac.h
> > @@ -46,6 +46,7 @@
> >
> > /* wacom data packet report IDs */
> > #define WACOM_REPORT_PENABLED 2
> > +#define WACOM_REPORT_PENABLED_BT 3
> > #define WACOM_REPORT_INTUOSREAD 5
> > #define WACOM_REPORT_INTUOSWRITE 6
> > #define WACOM_REPORT_INTUOSPAD 12
> > @@ -73,6 +74,7 @@
> > enum {
> > PENPARTNER = 0,
> > GRAPHIRE,
> > + GRAPHIRE_BT,
> > WACOM_G4,
> > PTU,
> > PL,
> > --
> > 2.0.1
> >
>
> --
> Dmitry
^ permalink raw reply
* Re: [PATCH v2 07/10] Input - wacom: handle Graphire BT tablets in wacom.ko
From: Dmitry Torokhov @ 2014-07-24 19:58 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Jiri Kosina, Ping Cheng, Jason Gerecke, Przemo Firszt,
linux-kernel, linux-input
In-Reply-To: <20140724194352.GB4190@mail.corp.redhat.com>
On Thu, Jul 24, 2014 at 03:43:52PM -0400, Benjamin Tissoires wrote:
> On Jul 24 2014 or thereabouts, Dmitry Torokhov wrote:
> > Hi Benjamin,
> >
> > On Thu, Jul 24, 2014 at 02:14:02PM -0400, Benjamin Tissoires wrote:
> > > + } else if (features->type == GRAPHIRE_BT) {
> > > + /* Compute distance between mouse and tablet */
> > > + rw = 44 - (data[6] >> 2);
> > > + if (rw < 0)
> > > + rw = 0;
> > > + else if (rw > 31)
> > > + rw = 31;
> >
> > rw = clamp_val(rw, 0, 31);
> >
> > ?
>
> could be...
>
> I'll do the tests and resubmit later the v3. I'll wait a little in case
> you have other comments on the other patches :)
How about doing it incrementally - the patch is still sound as far as I
am concerned. I will wait a bit for other to chime in with comments or
acks before applying this series.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 07/10] Input - wacom: handle Graphire BT tablets in wacom.ko
From: Benjamin Tissoires @ 2014-07-24 20:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jiri Kosina, Ping Cheng, Jason Gerecke, Przemo Firszt,
linux-kernel, linux-input
In-Reply-To: <20140724195827.GC26752@core.coreip.homeip.net>
On Jul 24 2014 or thereabouts, Dmitry Torokhov wrote:
> On Thu, Jul 24, 2014 at 03:43:52PM -0400, Benjamin Tissoires wrote:
> > On Jul 24 2014 or thereabouts, Dmitry Torokhov wrote:
> > > Hi Benjamin,
> > >
> > > On Thu, Jul 24, 2014 at 02:14:02PM -0400, Benjamin Tissoires wrote:
> > > > + } else if (features->type == GRAPHIRE_BT) {
> > > > + /* Compute distance between mouse and tablet */
> > > > + rw = 44 - (data[6] >> 2);
> > > > + if (rw < 0)
> > > > + rw = 0;
> > > > + else if (rw > 31)
> > > > + rw = 31;
> > >
> > > rw = clamp_val(rw, 0, 31);
> > >
> > > ?
> >
> > could be...
> >
> > I'll do the tests and resubmit later the v3. I'll wait a little in case
> > you have other comments on the other patches :)
>
> How about doing it incrementally - the patch is still sound as far as I
> am concerned. I will wait a bit for other to chime in with comments or
> acks before applying this series.
>
As you want.
Just making the exact changes you mentioned still makes the Graphire
working (what a surprise, isn't it?). So I am fine either way.
Cheers,
Benjamin
^ permalink raw reply
* Re: [PATCH] Input: synaptics-rmi4 - fix compiler warnings in F11
From: Andrew Duggan @ 2014-07-24 20:08 UTC (permalink / raw)
To: Christopher Heiny, Dmitry Torokhov, linux-input
Cc: Benjamin Tissoires, linux-kernel
In-Reply-To: <53D0644F.608@synaptics.com>
On 07/23/2014 06:41 PM, Christopher Heiny wrote:
> On 07/22/2014 11:11 PM, Dmitry Torokhov wrote:
>> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> I've reviewed this, and can say:
>
> Acked-by: Christopher Heiny <cheiny@synaptics.com>
>
> but I haven't had a chance to apply it to my build tree.
>
> Andrew - I'll be OOO for a couple of days. Can you do that, and add a
> Tested-by: or rev the patch, as appropriate?
>
> Thanks,
> Chris
>
It compiles cleanly and works on my test system.
Tested-by: Andrew Duggan <aduggan@synaptics.com>
>> ---
>> drivers/input/rmi4/rmi_f11.c | 135
>> +++++++++++++++++++++++--------------------
>> 1 file changed, 71 insertions(+), 64 deletions(-)
>>
>> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
>> index b739d31..7af4f68 100644
>> --- a/drivers/input/rmi4/rmi_f11.c
>> +++ b/drivers/input/rmi4/rmi_f11.c
>> @@ -553,7 +553,7 @@ struct f11_data {
>> unsigned long *result_bits;
>> };
>>
>> -enum finger_state_values {
>> +enum f11_finger_state {
>> F11_NO_FINGER = 0x00,
>> F11_PRESENT = 0x01,
>> F11_INACCURATE = 0x02,
>> @@ -563,12 +563,14 @@ enum finger_state_values {
>> /** F11_INACCURATE state is overloaded to indicate pen present. */
>> #define F11_PEN F11_INACCURATE
>>
>> -static int get_tool_type(struct f11_2d_sensor *sensor, u8 finger_state)
>> +static int rmi_f11_get_tool_type(struct f11_2d_sensor *sensor,
>> + enum f11_finger_state finger_state)
>> {
>> if (IS_ENABLED(CONFIG_RMI4_F11_PEN) &&
>> sensor->sens_query.has_pen &&
>> finger_state == F11_PEN)
>> return MT_TOOL_PEN;
>> +
>> return MT_TOOL_FINGER;
>> }
>>
>> @@ -603,36 +605,32 @@ static void rmi_f11_rel_pos_report(struct
>> f11_2d_sensor *sensor, u8 n_finger)
>>
>> static void rmi_f11_abs_pos_report(struct f11_data *f11,
>> struct f11_2d_sensor *sensor,
>> - u8 finger_state, u8 n_finger)
>> + enum f11_finger_state finger_state,
>> + u8 n_finger)
>> {
>> struct f11_2d_data *data = &sensor->data;
>> + struct input_dev *input = sensor->input;
>> struct rmi_f11_2d_axis_alignment *axis_align =
>> &sensor->axis_align;
>> + u8 *pos_data = &data->abs_pos[n_finger * RMI_F11_ABS_BYTES];
>> u16 x, y, z;
>> int w_x, w_y, w_max, w_min, orient;
>> - int temp;
>> - u8 abs_base = n_finger * RMI_F11_ABS_BYTES;
>> + int tool_type = rmi_f11_get_tool_type(sensor, finger_state);
>> +
>> + if (sensor->type_a) {
>> + input_report_abs(input, ABS_MT_TRACKING_ID, n_finger);
>> + input_report_abs(input, ABS_MT_TOOL_TYPE, tool_type);
>> + } else {
>> + input_mt_slot(input, n_finger);
>> + input_mt_report_slot_state(input, tool_type,
>> + finger_state != F11_NO_FINGER);
>> + }
>>
>> if (finger_state) {
>> - x = (data->abs_pos[abs_base] << 4) |
>> - (data->abs_pos[abs_base + 2] & 0x0F);
>> - y = (data->abs_pos[abs_base + 1] << 4) |
>> - (data->abs_pos[abs_base + 2] >> 4);
>> - w_x = data->abs_pos[abs_base + 3] & 0x0F;
>> - w_y = data->abs_pos[abs_base + 3] >> 4;
>> - w_max = max(w_x, w_y);
>> - w_min = min(w_x, w_y);
>> - z = data->abs_pos[abs_base + 4];
>> -
>> - if (axis_align->swap_axes) {
>> - temp = x;
>> - x = y;
>> - y = temp;
>> - temp = w_x;
>> - w_x = w_y;
>> - w_y = temp;
>> - }
>> + x = (pos_data[0] << 4) | (pos_data[2] & 0x0F);
>> + y = (pos_data[1] << 4) | (pos_data[2] >> 4);
>>
>> - orient = w_x > w_y ? 1 : 0;
>> + if (axis_align->swap_axes)
>> + swap(x, y);
>>
>> if (axis_align->flip_x)
>> x = max(sensor->max_x - x, 0);
>> @@ -641,13 +639,13 @@ static void rmi_f11_abs_pos_report(struct
>> f11_data *f11,
>> y = max(sensor->max_y - y, 0);
>>
>> /*
>> - * here checking if X offset or y offset are specified is
>> - * redundant. We just add the offsets or, clip the values
>> - *
>> - * note: offsets need to be done before clipping occurs,
>> - * or we could get funny values that are outside
>> - * clipping boundaries.
>> - */
>> + * Here checking if X offset or y offset are specified is
>> + * redundant. We just add the offsets or clip the values.
>> + *
>> + * Note: offsets need to be applied before clipping occurs,
>> + * or we could get funny values that are outside of
>> + * clipping boundaries.
>> + */
>> x += axis_align->offset_x;
>> y += axis_align->offset_y;
>> x = max(axis_align->clip_x_low, x);
>> @@ -657,41 +655,44 @@ static void rmi_f11_abs_pos_report(struct
>> f11_data *f11,
>> if (axis_align->clip_y_high)
>> y = min(axis_align->clip_y_high, y);
>>
>> - }
>> + w_x = pos_data[3] & 0x0f;
>> + w_y = pos_data[3] >> 4;
>>
>> - /* Some UIs ignore W of zero, so we fudge it to 1 for pens. This
>> - * only appears to be an issue when reporting pens, not plain old
>> - * fingers. */
>> - if (IS_ENABLED(CONFIG_RMI4_F11_PEN) &&
>> - get_tool_type(sensor, finger_state) == MT_TOOL_PEN) {
>> - w_max = max(1, w_max);
>> - w_min = max(1, w_min);
>> - }
>> + if (axis_align->swap_axes)
>> + swap(w_x, w_y);
>>
>> - if (sensor->type_a) {
>> - input_report_abs(sensor->input, ABS_MT_TRACKING_ID, n_finger);
>> - input_report_abs(sensor->input, ABS_MT_TOOL_TYPE,
>> - get_tool_type(sensor, finger_state));
>> - } else {
>> - input_mt_slot(sensor->input, n_finger);
>> - input_mt_report_slot_state(sensor->input,
>> - get_tool_type(sensor, finger_state), finger_state);
>> - }
>> + orient = w_x > w_y ? 1 : 0;
>> +
>> + w_max = max(w_x, w_y);
>> + w_min = min(w_x, w_y);
>> +
>> + /*
>> + * Some UIs ignore W of zero, so we fudge it to 1 for pens.
>> This
>> + * only appears to be an issue when reporting pens, not
>> plain old
>> + * fingers.
>> + */
>> + if (tool_type == MT_TOOL_PEN) {
>> + w_max = max(1, w_max);
>> + w_min = max(1, w_min);
>> + }
>> +
>> + z = pos_data[4];
>> +
>> + input_report_abs(input, ABS_MT_PRESSURE, z);
>> + input_report_abs(input, ABS_MT_TOUCH_MAJOR, w_max);
>> + input_report_abs(input, ABS_MT_TOUCH_MINOR, w_min);
>> + input_report_abs(input, ABS_MT_ORIENTATION, orient);
>> + input_report_abs(input, ABS_MT_POSITION_X, x);
>> + input_report_abs(input, ABS_MT_POSITION_Y, y);
>>
>> - if (finger_state) {
>> - input_report_abs(sensor->input, ABS_MT_PRESSURE, z);
>> - input_report_abs(sensor->input, ABS_MT_TOUCH_MAJOR, w_max);
>> - input_report_abs(sensor->input, ABS_MT_TOUCH_MINOR, w_min);
>> - input_report_abs(sensor->input, ABS_MT_ORIENTATION, orient);
>> - input_report_abs(sensor->input, ABS_MT_POSITION_X, x);
>> - input_report_abs(sensor->input, ABS_MT_POSITION_Y, y);
>> dev_dbg(&sensor->fn->dev,
>> "finger[%d]:%d - x:%d y:%d z:%d w_max:%d w_min:%d\n",
>> n_finger, finger_state, x, y, z, w_max, w_min);
>> }
>> +
>> /* MT sync between fingers */
>> if (sensor->type_a)
>> - input_mt_sync(sensor->input);
>> + input_mt_sync(input);
>> }
>>
>> static void rmi_f11_finger_handler(struct f11_data *f11,
>> @@ -710,25 +711,31 @@ static void rmi_f11_finger_handler(struct
>> f11_data *f11,
>> /* Possible of having 4 fingers per f_statet register */
>> finger_state = (f_state[i / 4] >> (2 * (i % 4))) &
>> FINGER_STATE_MASK;
>> - if (finger_state == F11_RESERVED) {
>> - pr_err("%s: Invalid finger state[%d]:0x%02x.", __func__,
>> - i, finger_state);
>> + switch (finger_state) {
>> + case F11_RESERVED:
>> + pr_err("Invalid finger state[%d]: 0x%02x", i,
>> finger_state);
>> continue;
>> - } else if ((finger_state == F11_PRESENT) ||
>> - (finger_state == F11_INACCURATE)) {
>> +
>> + case F11_PRESENT:
>> + case F11_INACCURATE:
>> finger_pressed_count++;
>> + break;
>> +
>> + case F11_NO_FINGER:
>> + break;
>> }
>>
>> abs_bits = bitmap_and(f11->result_bits, irq_bits,
>> f11->abs_mask,
>> - num_irq_regs);
>> + num_irq_regs);
>> if (abs_bits)
>> rmi_f11_abs_pos_report(f11, sensor, finger_state, i);
>>
>> rel_bits = bitmap_and(f11->result_bits, irq_bits,
>> f11->rel_mask,
>> - num_irq_regs);
>> + num_irq_regs);
>> if (rel_bits)
>> rmi_f11_rel_pos_report(sensor, i);
>> }
>> +
>> input_mt_sync_frame(sensor->input);
>> input_sync(sensor->input);
>> }
>>
>
>
^ permalink raw reply
* Re: [PATCH v2 23/23] Input - wacom: Move the USB (now hid) Wacom driver in drivers/hid
From: Dmitry Torokhov @ 2014-07-24 20:25 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Jiri Kosina, Ping Cheng, Jason Gerecke, linux-kernel, linux-input,
Hans de Goede
In-Reply-To: <1405449946-11515-24-git-send-email-benjamin.tissoires@redhat.com>
On Tue, Jul 15, 2014 at 02:45:46PM -0400, Benjamin Tissoires wrote:
> wacom.ko is now a full HID driver, we have to move it into the proper
> subdirectory: drivers/hid.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Hmm, this breaks the new wacom_serial4 driver that wants wacom_wac.h. It
looks like it only wants STYLUS_DEVICE_ID, ERASER_DEVICE_ID, and
CURSOR_DEVICE_ID definitions, I think I will just copy them into
wacom_serial4.c and be done with it. Hans?
Thanks.
--
Dmitry
^ permalink raw reply
* [PATCH] Input: wacom_serial4 - prepare for wacom USB moving to HID
From: Dmitry Torokhov @ 2014-07-24 20:31 UTC (permalink / raw)
To: Julian Squires, Hans de Goede, Benjamin Tissoires
Cc: linux-input, linux-kernel
wacom_wac.h will be moving to drivers/hid. Since we only need 3 definitions
from it let's simply copy them over.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/tablet/wacom_serial4.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/input/tablet/wacom_serial4.c b/drivers/input/tablet/wacom_serial4.c
index d3d251e..deef50e 100644
--- a/drivers/input/tablet/wacom_serial4.c
+++ b/drivers/input/tablet/wacom_serial4.c
@@ -149,6 +149,11 @@ MODULE_LICENSE("GPL");
#define F_HAS_STYLUS2 0x02
#define F_HAS_SCROLLWHEEL 0x04
+/* device IDs */
+#define STYLUS_DEVICE_ID 0x02
+#define CURSOR_DEVICE_ID 0x06
+#define ERASER_DEVICE_ID 0x0A
+
enum { STYLUS = 1, ERASER, CURSOR };
static const struct {
--
2.0.0.526.g5318336
--
Dmitry
^ permalink raw reply related
* Re: Linux 3.16-rc6
From: Waiman Long @ 2014-07-24 20:38 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Linus Torvalds, Borislav Petkov, Ingo Molnar,
Linux Kernel Mailing List, USB list, linux-input@vger.kernel.org
In-Reply-To: <20140724183643.GM3935@laptop>
On 07/24/2014 02:36 PM, Peter Zijlstra wrote:
> On Thu, Jul 24, 2014 at 11:18:16AM -0700, Linus Torvalds wrote:
>> On Thu, Jul 24, 2014 at 5:58 AM, Peter Zijlstra<peterz@infradead.org> wrote:
>>> So going by the nifty picture rostedt made:
>>>
>>> [ 61.454336] CPU0 CPU1
>>> [ 61.454336] ---- ----
>>> [ 61.454336] lock(&(&p->alloc_lock)->rlock);
>>> [ 61.454336] local_irq_disable();
>>> [ 61.454336] lock(tasklist_lock);
>>> [ 61.454336] lock(&(&p->alloc_lock)->rlock);
>>> [ 61.454336]<Interrupt>
>>> [ 61.454336] lock(tasklist_lock);
>> So this *should* be fine. It always has been in the past, and it was
>> certainly the *intention* that it should continue to work with
>> qrwlock, even in the presense of pending writers on other cpu's.
>>
>> The qrwlock rules are that a read-lock in an interrupt is still going
>> to be unfair and succeed if there are other readers.
> Ah, indeed. Should have checked :/
>
>> So it sounds to me like the new lockdep rules in tip/master are too
>> strict and are throwing a false positive.
> Right. Waiman can you have a look?
Yes, I think I may have a solution for that.
Borislav, can you apply the following patch on top of the lockdep patch
to see if it can fix the problem?
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index d24e433..507a8ce 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3595,6 +3595,12 @@ void lock_acquire(struct lockdep_map *lock,
unsigned int
raw_local_irq_save(flags);
check_flags(flags);
+ /*
+ * An interrupt recursive read in interrupt context can be
considered
+ * to be the same as a recursive read from checking perspective.
+ */
+ if ((read == 3) && in_interrupt())
+ read = 2;
current->lockdep_recursion = 1;
trace_lock_acquire(lock, subclass, trylock, read, check,
nest_lock, ip);
__lock_acquire(lock, subclass, trylock, read, check,
^ permalink raw reply related
* Re: [PATCH v2 07/10] Input - wacom: handle Graphire BT tablets in wacom.ko
From: Ping Cheng @ 2014-07-24 20:43 UTC (permalink / raw)
To: linux-input; +Cc: linux-kernel@vger.kernel.org
On Thu, Jul 24, 2014 at 12:58 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Thu, Jul 24, 2014 at 03:43:52PM -0400, Benjamin Tissoires wrote:
> > On Jul 24 2014 or thereabouts, Dmitry Torokhov wrote:
> > > Hi Benjamin,
> > >
> > > On Thu, Jul 24, 2014 at 02:14:02PM -0400, Benjamin Tissoires wrote:
> > > > + } else if (features->type == GRAPHIRE_BT) {
> > > > + /* Compute distance between mouse and tablet */
> > > > + rw = 44 - (data[6] >> 2);
> > > > + if (rw < 0)
> > > > + rw = 0;
> > > > + else if (rw > 31)
> > > > + rw = 31;
> > >
> > > rw = clamp_val(rw, 0, 31);
> > >
> > > ?
> >
> > could be...
> >
> > I'll do the tests and resubmit later the v3. I'll wait a little in case
> > you have other comments on the other patches :)
>
> How about doing it incrementally - the patch is still sound as far as I
> am concerned. I will wait a bit for other to chime in with comments or
> acks before applying this series.
Thank you Benjamin and Dmitry for your support. The whole series is:
Acked-by: Ping Cheng <pingc@wacom.com>
Cheers,
Ping
^ permalink raw reply
* Re: [PATCH 00/15] atmel_mxt_ts - device tree, bootloader, etc
From: Stephen Warren @ 2014-07-24 21:19 UTC (permalink / raw)
To: Nick Dyer
Cc: Dmitry Torokhov, Yufeng Shen, Daniel Kurtz, Henrik Rydberg,
Joonyoung Shim, Alan Bowens, linux-input, linux-kernel,
Peter Meerwald, Benson Leung, Olof Johansson, Sekhar Nori
In-Reply-To: <53D10E78.4010908@itdev.co.uk>
On 07/24/2014 07:47 AM, Nick Dyer wrote:
> On 23/07/14 18:22, Stephen Warren wrote:
>> That didn't make any difference.
>>
>> I also tried the tool interactively. the "Display raw (M)essages" option
>> never displayed anything, and the couple of self-tests I tried just
>> timed out. "Read (I)nfo block" did display some values that seemed like
>> they might be correct rather than random data.
>>
>> Interestingly though, I did bisect the series and found "Input:
>> atmel_mxt_ts - use deep sleep mode when stopped" causes the problem. If
>> I apply the whole series and revert that one patch, the touchpad works
>> for mouse movement, but interestingly not for taps or physical clicks.
>
> Could you dump out the config for me (when it's in the failed state)? This
> can be done by running:
>
> mxt-app [device] --save fail.xcfg
That command always experiences a timeout error, but still seems to dump
something out. Is this timeout error an issue? I'm a little hesitant to
modify the COMMSCONFIG settings until I know load/save are really working.
root@localhost:~/obp-utils# ./mxt-app -d i2c-dev:1-004b --save
~/mxt-save-no-movement.xml
Version:1.16-65-g0a4c
Registered i2c-dev adapter:1 address:0x4b
Opening config file /root/mxt-save-no-movement.xml...
REPORTALL command issued
Timeout
I've uploaded 2 logs to:
http://avon.wwwdotorg.org/downloads/mxt-logs/
(note there's no directory indexing, so manually add the filenames below
to the URL)
mxt-save-no-movement.xml
This is with the whole series applied. Neither mouse movement nor clicks
works. I tried mxt-app --reset and it made no difference to the dump
results.
mxt-save-move-ok-no-clicking.xml
This is with "Input: atmel_mxt_ts - use deep sleep mode when stopped"
reverted; mouse movement works, but clicking doesn't.
^ permalink raw reply
* Re: Linux 3.16-rc6
From: Borislav Petkov @ 2014-07-24 21:45 UTC (permalink / raw)
To: Waiman Long
Cc: Peter Zijlstra, Linus Torvalds, Ingo Molnar,
Linux Kernel Mailing List, USB list, linux-input@vger.kernel.org
In-Reply-To: <53D16EC4.1000801@hp.com>
On Thu, Jul 24, 2014 at 04:38:28PM -0400, Waiman Long wrote:
> Borislav, can you apply the following patch on top of the lockdep
> patch to see if it can fix the problem?
It is too late here for me to test anything but the ingridients to
reproduce are nothing special. Just grab a kvm guest and pick out the
locking or so options out of the .config I sent previously. Then boot it
a couple of times, it triggers pretty easy after a couple of tries.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply
* Re: Linux 3.16-rc6
From: John Stoffel @ 2014-07-24 22:06 UTC (permalink / raw)
To: Waiman Long
Cc: Peter Zijlstra, Linus Torvalds, Borislav Petkov, Ingo Molnar,
Linux Kernel Mailing List, USB list, linux-input@vger.kernel.org
In-Reply-To: <53D16EC4.1000801@hp.com>
>>>>> "Waiman" == Waiman Long <waiman.long@hp.com> writes:
Waiman> On 07/24/2014 02:36 PM, Peter Zijlstra wrote:
>> On Thu, Jul 24, 2014 at 11:18:16AM -0700, Linus Torvalds wrote:
>>> On Thu, Jul 24, 2014 at 5:58 AM, Peter Zijlstra<peterz@infradead.org> wrote:
>>>> So going by the nifty picture rostedt made:
>>>>
>>>> [ 61.454336] CPU0 CPU1
>>>> [ 61.454336] ---- ----
>>>> [ 61.454336] lock(&(&p->alloc_lock)->rlock);
>>>> [ 61.454336] local_irq_disable();
>>>> [ 61.454336] lock(tasklist_lock);
>>>> [ 61.454336] lock(&(&p->alloc_lock)->rlock);
>>>> [ 61.454336]<Interrupt>
>>>> [ 61.454336] lock(tasklist_lock);
>>> So this *should* be fine. It always has been in the past, and it was
>>> certainly the *intention* that it should continue to work with
>>> qrwlock, even in the presense of pending writers on other cpu's.
>>>
>>> The qrwlock rules are that a read-lock in an interrupt is still going
>>> to be unfair and succeed if there are other readers.
>> Ah, indeed. Should have checked :/
>>
>>> So it sounds to me like the new lockdep rules in tip/master are too
>>> strict and are throwing a false positive.
>> Right. Waiman can you have a look?
Waiman> Yes, I think I may have a solution for that.
Waiman> Borislav, can you apply the following patch on top of the lockdep patch
Waiman> to see if it can fix the problem?
Waiman> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
Waiman> index d24e433..507a8ce 100644
Waiman> --- a/kernel/locking/lockdep.c
Waiman> +++ b/kernel/locking/lockdep.c
Waiman> @@ -3595,6 +3595,12 @@ void lock_acquire(struct lockdep_map *lock,
Waiman> unsigned int
Waiman> raw_local_irq_save(flags);
Waiman> check_flags(flags);
Waiman> + /*
Waiman> + * An interrupt recursive read in interrupt context can be
Waiman> considered
Waiman> + * to be the same as a recursive read from checking perspective.
Waiman> + */
Waiman> + if ((read == 3) && in_interrupt())
Waiman> + read = 2;
current-> lockdep_recursion = 1;
Waiman> trace_lock_acquire(lock, subclass, trylock, read, check,
Waiman> nest_lock, ip);
Waiman> __lock_acquire(lock, subclass, trylock, read, check,
Instead of the magic numbers 1,2,3, could you use some nicely named
constants here instead?
John
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox