A set of patches cherry-picked from upstream to make the Intuos4 Bluetooth variant useful. Without these patches, some data is missing, so we miss out on relative mode, pad buttons, wheel support, etc.
Cheers, Peter
From: Przemo Firszt przemo@firszt.eu
Don't zero the current tool before reporting its release to the input subsystem.
Signed-off-by: Aristeu Rozanski aris@redhat.com Tested-by: Przemo Firszt przemo@firszt.eu Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 32db737fb2bfe9013362c9dc2c7af998edc758be) --- drivers/hid/hid-wacom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index acab74c..8b49229 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -322,10 +322,10 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata,
switch (data[1]) { case 0x80: /* Out of proximity report */ - wdata->tool = 0; input_report_key(input, BTN_TOUCH, 0); input_report_abs(input, ABS_PRESSURE, 0); input_report_key(input, wdata->tool, 0); + wdata->tool = 0; input_sync(input); break; case 0xC2: /* Tool report */
From: Przemo Firszt przemo@firszt.eu
ABS_MISC has to be set for Intuos4 WL otherwise xorg driver won't use proper protocol and the information about tool id and serial is lost.
Signed-off-by: Przemo Firszt przemo@firszt.eu Reviewed-by: Chris Bagwell chris@cnpbagwell.com Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 2c653e6bac85918ae76ed0199f25fb6a2206b92d) --- drivers/hid/hid-wacom.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 8b49229..c4a193b 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -471,6 +471,7 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, input_set_abs_params(input, ABS_DISTANCE, 0, 32, 0, 0); break; case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: + __set_bit(ABS_MISC, input->absbit); 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);
From: Przemo Firszt przemo@firszt.eu
This patch implements reporting id and serial number of used tool. Reported values are the same as for USB on of the driver for wacom Intuos4 WL
Signed-off-by: Przemo Firszt przemo@firszt.eu Reviewed-by: Chris Bagwell chris@cnpbagwell.com Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 2470900b68ccfde046d5a20c47ae9abb4e406084) --- drivers/hid/hid-wacom.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index c4a193b..a3476f9 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -35,6 +35,8 @@ struct wacom_data { __u16 tool; unsigned char butstate; __u8 features; + __u32 id; + __u32 serial; unsigned char high_speed; #ifdef CONFIG_HID_WACOM_POWER_SUPPLY int battery_capacity; @@ -318,26 +320,30 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, struct input_dev *input, unsigned char *data) { __u16 x, y, pressure; - __u32 id;
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, 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 */ - id = ((data[2] << 4) | (data[3] >> 4) | + wdata->id = ((data[2] << 4) | (data[3] >> 4) | ((data[7] & 0x0f) << 20) | - ((data[8] & 0xf0) << 12)) & 0xfffff; + ((data[8] & 0xf0) << 12)); + wdata->serial = ((data[3] & 0x0f) << 28) + + (data[4] << 20) + (data[5] << 12) + + (data[6] << 4) + (data[7] >> 4);
- switch (id) { - case 0x802: + switch (wdata->id) { + case 0x100802: wdata->tool = BTN_TOOL_PEN; break; - case 0x80A: + case 0x10080A: wdata->tool = BTN_TOOL_RUBBER; break; } @@ -356,6 +362,9 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 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_MISC, wdata->id); + input_event(input, EV_MSC, MSC_SERIAL, wdata->serial); + input_report_key(input, wdata->tool, 1); input_sync(input); break; }
From: Przemo Firszt przemo@firszt.eu
This patch adds reporting of distance of tool to the tablet surface. Maximum reported value is 63 (0x3F).
Signed-off-by: Przemo Firszt przemo@firszt.eu Acked-by: Peter Hutterer peter.hutterer@who-t.net Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit e0829e9c1e6981450f11204a4104646ed0f6907a) --- drivers/hid/hid-wacom.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index a3476f9..5a58db2 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -320,6 +320,7 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, struct input_dev *input, unsigned char *data) { __u16 x, y, pressure; + __u8 distance;
switch (data[1]) { case 0x80: /* Out of proximity report */ @@ -353,6 +354,7 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 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;
input_report_key(input, BTN_TOUCH, pressure > 1);
@@ -362,6 +364,7 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 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_MISC, wdata->id); input_event(input, EV_MSC, MSC_SERIAL, wdata->serial); input_report_key(input, wdata->tool, 1); @@ -484,6 +487,7 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, 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); break; }
From: Przemo Firszt przemo@firszt.eu
This patch adds reporting of 1 wheel button and 8 strip buttons for Intuos4 WL. The buttons are reported as BTN_0 to BTN_9. The change of type butstate variable is required as the old type 'char' couldn't store state of 9 buttons. The change is not affecting Graphire tablet as it only uses first 2 bits of 'butstate'.
Signed-off-by: Przemo Firszt przemo@firszt.eu Acked-by:Ping Cheng pinglinux@gmail.com Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 6245bde29dd049300d663516398335be8d451b78) --- drivers/hid/hid-wacom.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 5a58db2..58aedbc 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -31,9 +31,11 @@
#include "hid-ids.h"
+#define PAD_DEVICE_ID 0x0F + struct wacom_data { __u16 tool; - unsigned char butstate; + __u16 butstate; __u8 features; __u32 id; __u32 serial; @@ -316,6 +318,30 @@ static int wacom_gr_parse_report(struct hid_device *hdev, return 1; }
+static void wacom_i4_parse_button_report(struct wacom_data *wdata, + struct input_dev *input, unsigned char *data) +{ + __u16 new_butstate; + + 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); + 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) { @@ -389,6 +415,7 @@ static void wacom_i4_parse_report(struct hid_device *hdev, 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]); @@ -484,6 +511,13 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, break; case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: __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_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);
From: Przemo Firszt przemo@firszt.eu
Stylus buttons have to be resetted when going out-of-prox.
Signed-off-by: Przemo Firszt przemo@firszt.eu Reviewed-by: Jason Gerecke killertofu@gmail.com Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 693f45bb2d6ff5bf8fb3b69ff904b44ef8cffd8d) --- drivers/hid/hid-wacom.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 58aedbc..f9af474 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -352,6 +352,8 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 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);
From: Przemo Firszt przemo@firszt.eu
It's a trivial patch. It's doesn't change the functionality as the helper input_set_capability does the same thing.
Signed-off-by: Przemo Firszt przemo@firszt.eu Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 9a911da8d792a2d8f9a1e07eb1c41e0d7f4ec307) --- drivers/hid/hid-wacom.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index f9af474..3fc9386 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -492,9 +492,7 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, __set_bit(BTN_MIDDLE, input->keybit);
/* Pad */ - input->evbit[0] |= BIT(EV_MSC); - - __set_bit(MSC_SERIAL, input->mscbit); + input_set_capability(input, EV_MSC, MSC_SERIAL);
__set_bit(BTN_0, input->keybit); __set_bit(BTN_1, input->keybit);
From: Przemo Firszt przemo@firszt.eu
Tile is reported to input subsystem as reported by the device without any modifications. It means that tilt X/Y range is 0 to 127 and it's not centered on zero.
Signed-off-by: Przemo Firszt przemo@firszt.eu Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit c653daba895a2d339b3b8f04e69fc111443ef327) --- drivers/hid/hid-wacom.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 3fc9386..72a8e4a 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -347,6 +347,7 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, { __u16 x, y, pressure; __u8 distance; + __u8 tilt_x, tilt_y;
switch (data[1]) { case 0x80: /* Out of proximity report */ @@ -383,6 +384,8 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 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);
@@ -393,6 +396,8 @@ static void wacom_i4_parse_pen_report(struct wacom_data *wdata, 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); @@ -522,6 +527,8 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, 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; }
From: Przemo Firszt przemo@firszt.eu
This patch adds reporting of ABS_WHEEL event. Raported walues are 0..71 and are related to absolute location of the finger on the wheel.
Signed-off-by: Przemo Firszt przemo@firszt.eu Reviewed-by: Jason Gerecke killertofu@gmail.com Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit 7e503a37deee55cc30d2c8643e704a98556dd367) (cherry picked from commit fc7df53166117516c95eb48fc86d93d39b0f4063) --- drivers/hid/hid-wacom.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 72a8e4a..9614f93 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -36,6 +36,7 @@ struct wacom_data { __u16 tool; __u16 butstate; + __u8 whlstate; __u8 features; __u32 id; __u32 serial; @@ -322,6 +323,23 @@ 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) { @@ -336,6 +354,10 @@ static void wacom_i4_parse_button_report(struct wacom_data *wdata, 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); @@ -515,6 +537,7 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, 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); @@ -523,6 +546,7 @@ static int wacom_input_mapped(struct hid_device *hdev, struct hid_input *hi, __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);
From: Przemo Firszt przemo@firszt.eu
Add sysfs attribute to control LED selector on Wacom Intuos4. There are 4 different LEDs on the tablet and they can be turned on by something like:
echo 50 > /sys/class/leds/(device # here):selector:1/brightness
Only one can be lit at a time. The brightness range is 0 to 127. This patch also contains short ABI description.
Signed-off-by: Przemo Firszt przemo@firszt.eu Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit d13f5454e4acbbe2a470cc6743c2998cfcd607a8)
Conflicts:
drivers/hid/hid-wacom.c (cherry picked from commit 56cfa5441a9ba011a39d37c0a269da8574e22a5a) --- Documentation/ABI/testing/sysfs-driver-wacom | 8 ++ drivers/hid/Kconfig | 1 + drivers/hid/hid-wacom.c | 126 ++++++++++++++++++++++++++ 3 files changed, 135 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-driver-wacom b/Documentation/ABI/testing/sysfs-driver-wacom index 0130d66..56c5455 100644 --- a/Documentation/ABI/testing/sysfs-driver-wacom +++ b/Documentation/ABI/testing/sysfs-driver-wacom @@ -9,6 +9,14 @@ Description: or 0 otherwise. Writing to this file one of these values switches reporting speed.
+What: /sys/class/leds/0005:056A:00BD.0001:selector:*/ +Date: May 2012 +Kernel Version: 3.5 +Contact: linux-bluetooth@vger.kernel.org +Description: + LED selector for Intuos4 WL. There are 4 leds, but only one LED + can be lit at a time. Max brightness is 127. + What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/led Date: August 2011 Contact: linux-input@vger.kernel.org diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index a421abd..a7e9fbf 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -627,6 +627,7 @@ config HID_WACOM_POWER_SUPPLY bool "Wacom Bluetooth devices power supply status support" depends on HID_WACOM select POWER_SUPPLY + select LEDS_CLASS ---help--- Say Y here if you want to enable power supply status monitoring for Wacom Bluetooth devices. diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 9614f93..9f2f5c7 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -24,6 +24,7 @@ #include <linux/device.h> #include <linux/hid.h> #include <linux/module.h> +#include <linux/leds.h> #include <linux/slab.h> #ifdef CONFIG_HID_WACOM_POWER_SUPPLY #include <linux/power_supply.h> @@ -33,6 +34,8 @@
#define PAD_DEVICE_ID 0x0F
+#define WAC_CMD_LED_CONTROL 0x20 + struct wacom_data { __u16 tool; __u16 butstate; @@ -46,6 +49,8 @@ struct wacom_data { struct power_supply battery; struct power_supply ac; #endif + __u8 led_selector; + struct led_classdev *leds[4]; };
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY @@ -64,6 +69,117 @@ static enum power_supply_property wacom_ac_props[] = { POWER_SUPPLY_PROP_SCOPE, };
+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; + hdev->hid_output_raw_report(hdev, buf, 9, HID_FEATURE_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) @@ -599,6 +715,12 @@ static int wacom_probe(struct hid_device *hdev, case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: wdata->features = 0; wacom_set_features(hdev); + ret = wacom_initialize_leds(hdev); + if (ret) { + hid_warn(hdev, + "can't create led attribute, err: %d\n", ret); + goto destroy_leds; + } break; }
@@ -645,6 +767,8 @@ err_battery: device_remove_file(&hdev->dev, &dev_attr_speed); hid_hw_stop(hdev); #endif +destroy_leds: + wacom_destroy_leds(hdev); err_free: kfree(wdata); return ret; @@ -655,6 +779,8 @@ static void wacom_remove(struct hid_device *hdev) #ifdef CONFIG_HID_WACOM_POWER_SUPPLY struct wacom_data *wdata = hid_get_drvdata(hdev); #endif + + wacom_destroy_leds(hdev); device_remove_file(&hdev->dev, &dev_attr_speed); hid_hw_stop(hdev);
From: Przemo Firszt przemo@firszt.eu
The name reported by Inutos4 WL connected by bluetooth is "PTK-540WL" and to make it consistent with other Wacom devices it has to be converted to "Wacom Intuos4 WL". It also makes userland applications aware that it's a Wacom device.
This aligns naming of device to same used when this device is plugged into USB port and controlled by USB wacom driver; and thus helps align userland logic to route to apps like xf86-input-wacom.
Signed-off-by: Przemo Firszt przemo@firszt.eu Reviewed-by: Chris Bagwell chris@cnpbagwell.com Signed-off-by: Jiri Kosina jkosina@suse.cz (cherry picked from commit a72c5ddb675f2f0a2fa857f75286d50b7a0c0ba5) --- drivers/hid/hid-wacom.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 9f2f5c7..8653076 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -713,6 +713,7 @@ static int wacom_probe(struct hid_device *hdev, wacom_poke(hdev, 1); break; case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: + sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); wdata->features = 0; wacom_set_features(hdev); ret = wacom_initialize_leds(hdev);
On Wed, May 30, 2012 at 03:13:16PM +1000, Peter Hutterer wrote:
A set of patches cherry-picked from upstream to make the Intuos4 Bluetooth variant useful. Without these patches, some data is missing, so we miss out on relative mode, pad buttons, wheel support, etc.
Assuming these are for F16/F17 updates ? Which release were they picked from ? If 3.4, we'll be rebasing to that later this week.
Dave
On Wed, May 30, 2012 at 01:32:23AM -0400, Dave Jones wrote:
On Wed, May 30, 2012 at 03:13:16PM +1000, Peter Hutterer wrote:
A set of patches cherry-picked from upstream to make the Intuos4 Bluetooth variant useful. Without these patches, some data is missing, so we miss out on relative mode, pad buttons, wheel support, etc.
Assuming these are for F16/F17 updates ? Which release were they picked from ? If 3.4, we'll be rebasing to that later this week.
oh, right, sorry, stuck in my own little world here. they're from 3.4, with the exception of 10/11 but that one isn't necessary anyway. So rebasing to 3.4 will be good enough then, thanks.
Cheers, Peter
kernel@lists.fedoraproject.org