From 224b321b312e9c03989e1563beaa50f98f9b48e0 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Thu, 22 Mar 2012 18:54:05 +0000 Subject: HID: wacom: Remove CONFIG_HID_WACOM_POWER_SUPPLY option This option was ment as a safety mechanism in case the system treats the wacom tablet battery as the main power supply. It's no longer required as now we can distinguish between system power supply and device power supply. Signed-off-by: Przemo Firszt Reviewed-by: Chris Bagwell Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 8 +------- drivers/hid/hid-wacom.c | 16 ---------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index a3d03325299..c2ab80e5f62 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -595,16 +595,10 @@ config THRUSTMASTER_FF config HID_WACOM tristate "Wacom Bluetooth devices support" depends on BT_HIDP - ---help--- - Support for Wacom Graphire Bluetooth tablet. - -config HID_WACOM_POWER_SUPPLY - bool "Wacom Bluetooth devices power supply status support" depends on HID_WACOM select POWER_SUPPLY ---help--- - Say Y here if you want to enable power supply status monitoring for - Wacom Bluetooth devices. + Support for Wacom Graphire Bluetooth tablet. config HID_WIIMOTE tristate "Nintendo Wii Remote support" diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 067e2963314..46de2acada4 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -25,9 +25,7 @@ #include #include #include -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY #include -#endif #include "hid-ids.h" @@ -41,14 +39,11 @@ struct wacom_data { __u32 id; __u32 serial; unsigned char high_speed; -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY int battery_capacity; struct power_supply battery; struct power_supply ac; -#endif }; -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY /*percent of battery capacity, 0 means AC online*/ static unsigned short batcap[8] = { 1, 15, 25, 35, 50, 70, 100, 0 }; @@ -120,7 +115,6 @@ static int wacom_ac_get_property(struct power_supply *psy, } return ret; } -#endif static void wacom_set_features(struct hid_device *hdev) { @@ -310,12 +304,10 @@ static int wacom_gr_parse_report(struct hid_device *hdev, input_sync(input); } -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY /* Store current battery capacity */ rw = (data[7] >> 2 & 0x07); if (rw != wdata->battery_capacity) wdata->battery_capacity = rw; -#endif return 1; } @@ -596,7 +588,6 @@ static int wacom_probe(struct hid_device *hdev, break; } -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY wdata->battery.properties = wacom_battery_props; wdata->battery.num_properties = ARRAY_SIZE(wacom_battery_props); wdata->battery.get_property = wacom_battery_get_property; @@ -629,16 +620,13 @@ static int wacom_probe(struct hid_device *hdev, } power_supply_powers(&wdata->ac, &hdev->dev); -#endif return 0; -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY err_ac: power_supply_unregister(&wdata->battery); err_battery: device_remove_file(&hdev->dev, &dev_attr_speed); hid_hw_stop(hdev); -#endif err_free: kfree(wdata); return ret; @@ -646,16 +634,12 @@ err_free: static void wacom_remove(struct hid_device *hdev) { -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY struct wacom_data *wdata = hid_get_drvdata(hdev); -#endif device_remove_file(&hdev->dev, &dev_attr_speed); hid_hw_stop(hdev); -#ifdef CONFIG_HID_WACOM_POWER_SUPPLY power_supply_unregister(&wdata->battery); power_supply_unregister(&wdata->ac); -#endif kfree(hid_get_drvdata(hdev)); } -- cgit v1.2.3-70-g09d2 From 7e551abbc85703355dcc041434b4962697cdf628 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Thu, 22 Mar 2012 18:54:06 +0000 Subject: HID: wacom: Change HID_WACOM option description. Trivial patch: now the hid-wacom driver supports also Intuos4 WL tablet. Signed-off-by: Przemo Firszt Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index c2ab80e5f62..32ada100115 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -598,7 +598,7 @@ config HID_WACOM depends on HID_WACOM select POWER_SUPPLY ---help--- - Support for Wacom Graphire Bluetooth tablet. + Support for Wacom Graphire Bluetooth and Intuos4 WL tablets. config HID_WIIMOTE tristate "Nintendo Wii Remote support" -- cgit v1.2.3-70-g09d2 From e31e3832927f5ee2d788120826e73d120dd39ea9 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Thu, 22 Mar 2012 18:54:07 +0000 Subject: HID: wacom: Refactor battery/ac reporting for Graphire This patch doesn't change the way battery/ac is reported, but the changes are required to facilitate battery reporting for Intuos4 WL. wdata->battery_capacity now stores actual battery capacity as opposed to raw value reported by wacom graphire previously. Power supply state is now stored in a separate variable - it used to be calculated on-the-fly in wacom_ac_get_property function. The raw value has to be stored as well to be able to determine if it has changed. Signed-off-by: Przemo Firszt Reviewed-by: Chris Bagwell Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 46de2acada4..edf6cba6037 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -39,13 +39,16 @@ struct wacom_data { __u32 id; __u32 serial; unsigned char high_speed; - int battery_capacity; + __u8 battery_capacity; + __u8 power_raw; + __u8 ps_connected; struct power_supply battery; struct power_supply ac; }; -/*percent of battery capacity, 0 means AC online*/ -static unsigned short batcap[8] = { 1, 15, 25, 35, 50, 70, 100, 0 }; +/*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 enum power_supply_property wacom_battery_props[] = { POWER_SUPPLY_PROP_PRESENT, @@ -65,7 +68,6 @@ static int wacom_battery_get_property(struct power_supply *psy, { struct wacom_data *wdata = container_of(psy, struct wacom_data, battery); - int power_state = batcap[wdata->battery_capacity]; int ret = 0; switch (psp) { @@ -76,11 +78,7 @@ static int wacom_battery_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_SCOPE_DEVICE; break; case POWER_SUPPLY_PROP_CAPACITY: - /* show 100% battery capacity when charging */ - if (power_state == 0) - val->intval = 100; - else - val->intval = power_state; + val->intval = wdata->battery_capacity; break; default: ret = -EINVAL; @@ -94,17 +92,13 @@ static int wacom_ac_get_property(struct power_supply *psy, union power_supply_propval *val) { struct wacom_data *wdata = container_of(psy, struct wacom_data, ac); - int power_state = batcap[wdata->battery_capacity]; int ret = 0; switch (psp) { case POWER_SUPPLY_PROP_PRESENT: /* fall through */ case POWER_SUPPLY_PROP_ONLINE: - if (power_state == 0) - val->intval = 1; - else - val->intval = 0; + val->intval = wdata->ps_connected; break; case POWER_SUPPLY_PROP_SCOPE: val->intval = POWER_SUPPLY_SCOPE_DEVICE; @@ -304,10 +298,16 @@ static int wacom_gr_parse_report(struct hid_device *hdev, input_sync(input); } - /* Store current battery capacity */ + /* Store current battery capacity and power supply state*/ rw = (data[7] >> 2 & 0x07); - if (rw != wdata->battery_capacity) - wdata->battery_capacity = rw; + 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; } -- cgit v1.2.3-70-g09d2 From 4202f1de3b4f1edf74a7f8b2f8b56cb5a8398081 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Thu, 22 Mar 2012 18:54:08 +0000 Subject: HID: wacom: Add battery/ac reporting for Intuos4 WL This patch adds battery/ac reporting for Intuos4 WL. It uses existing sysfs code, but the device reports battery capacity in more fine-grained way, so there has to be a separate lookup table (called batcap_i4). Signed-off-by: Przemo Firszt Reviewed-by: Chris Bagwell Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index edf6cba6037..f130f40488f 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -49,6 +49,8 @@ struct wacom_data { /*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, @@ -447,6 +449,7 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, struct input_dev *input; unsigned char *data = (unsigned char *) raw_data; int i; + __u8 power_raw; if (!(hdev->claimed & HID_CLAIMED_INPUT)) return 0; @@ -474,6 +477,13 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, 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->ps_connected = power_raw & 0x08; + } + break; default: hid_err(hdev, "Unknown report: %d,%d size:%d\n", -- cgit v1.2.3-70-g09d2 From b73b2da0353d15b712b27b1aed3c50856bdfc341 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Tue, 20 Mar 2012 16:01:32 +0200 Subject: HID: hid-input: Add digitizer tilt usage support Add digitizer X Tilt and Y Tilt usage support along with resolution calculation. Signed-off-by: Nikolai Kondrashov Signed-off-by: Jiri Kosina --- drivers/hid/hid-input.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 002781c5a61..22d8ce6d5a5 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -225,7 +225,10 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) * Verify and convert units. * See HID specification v1.11 6.2.2.7 Global Items for unit decoding */ - if (code == ABS_X || code == ABS_Y || code == ABS_Z) { + switch (code) { + case ABS_X: + case ABS_Y: + case ABS_Z: if (field->unit == 0x11) { /* If centimeters */ /* Convert to millimeters */ unit_exponent += 1; @@ -239,7 +242,13 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) } else { return 0; } - } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { + break; + + case ABS_RX: + case ABS_RY: + case ABS_RZ: + case ABS_TILT_X: + case ABS_TILT_Y: if (field->unit == 0x14) { /* If degrees */ /* Convert to radians */ prev = logical_extents; @@ -250,7 +259,9 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) } else if (field->unit != 0x12) { /* If not radians */ return 0; } - } else { + break; + + default: return 0; } @@ -623,6 +634,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel map_key_clear(BTN_TOOL_RUBBER); break; + case 0x3d: /* X Tilt */ + map_abs_clear(ABS_TILT_X); + break; + + case 0x3e: /* Y Tilt */ + map_abs_clear(ABS_TILT_Y); + break; + case 0x33: /* Touch */ case 0x42: /* TipSwitch */ case 0x43: /* TipSwitch2 */ -- cgit v1.2.3-70-g09d2 From d2ee4dd9a4d68543bddddb69d38cba51b4373e6b Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Tue, 20 Mar 2012 16:01:33 +0200 Subject: HID: waltop: Add support for Sirius tablet Add support for Waltop Sirius Battery Free Tablet. VisTablet Muse and Princeton PTB-S1BK are other possible names of this tablet. Signed-off-by: Nikolai Kondrashov Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-waltop.c | 189 ++++++++++++++++++++++++++++++++++++++++ drivers/hid/usbhid/hid-quirks.c | 1 + 4 files changed, 192 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 990fe19330e..59f32a70ec5 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1578,6 +1578,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) }, { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) }, { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX) }, { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 3eb00902ca4..9f5b1cd9148 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -737,6 +737,7 @@ #define USB_DEVICE_ID_WALTOP_PID_0038 0x0038 #define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH 0x0501 #define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH 0x0500 +#define USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET 0x0502 #define USB_VENDOR_ID_WISEGROUP 0x0925 #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 diff --git a/drivers/hid/hid-waltop.c b/drivers/hid/hid-waltop.c index 2cfd95c4467..9a48438090a 100644 --- a/drivers/hid/hid-waltop.c +++ b/drivers/hid/hid-waltop.c @@ -502,6 +502,142 @@ static __u8 media_tablet_14_1_inch_rdesc_fixed[] = { 0xC0 /* End Collection */ }; +/* + * See Sirius Battery Free Tablet description, device and HID report descriptors + * at + * http://sf.net/apps/mediawiki/digimend/?title=Waltop_Sirius_Battery_Free_Tablet + */ + +/* Size of the original report descriptor of Sirius Battery Free Tablet */ +#define SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE 335 + +/* Fixed Sirius Battery Free Tablet descriptor */ +static __u8 sirius_battery_free_tablet_rdesc_fixed[] = { + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x02, /* Usage (Pen), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x10, /* Report ID (16), */ + 0x09, 0x20, /* Usage (Stylus), */ + 0xA0, /* Collection (Physical), */ + 0x95, 0x01, /* Report Count (1), */ + 0x15, 0x01, /* Logical Minimum (1), */ + 0x25, 0x03, /* Logical Maximum (3), */ + 0x75, 0x02, /* Report Size (2), */ + 0x09, 0x42, /* Usage (Tip Switch), */ + 0x09, 0x44, /* Usage (Barrel Switch), */ + 0x09, 0x46, /* Usage (Tablet Pick), */ + 0x80, /* Input, */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x09, 0x3C, /* Usage (Invert), */ + 0x81, 0x02, /* Input (Variable), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x09, 0x32, /* Usage (In Range), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0xA4, /* Push, */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x55, 0xFD, /* Unit Exponent (-3), */ + 0x65, 0x13, /* Unit (Inch), */ + 0x34, /* Physical Minimum (0), */ + 0x14, /* Logical Minimum (0), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x01, /* Report Count (1), */ + 0x46, 0x10, 0x27, /* Physical Maximum (10000), */ + 0x26, 0x20, 0x4E, /* Logical Maximum (20000), */ + 0x09, 0x30, /* Usage (X), */ + 0x81, 0x02, /* Input (Variable), */ + 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ + 0x26, 0xE0, 0x2E, /* Logical Maximum (12000), */ + 0x09, 0x31, /* Usage (Y), */ + 0x81, 0x02, /* Input (Variable), */ + 0xB4, /* Pop, */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x01, /* Report Count (1), */ + 0x14, /* Logical Minimum (0), */ + 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ + 0x09, 0x30, /* Usage (Tip Pressure), */ + 0x81, 0x02, /* Input (Variable), */ + 0xA4, /* Push, */ + 0x55, 0xFE, /* Unit Exponent (-2), */ + 0x65, 0x12, /* Unit (Radians), */ + 0x35, 0x97, /* Physical Minimum (-105), */ + 0x45, 0x69, /* Physical Maximum (105), */ + 0x15, 0x97, /* Logical Minimum (-105), */ + 0x25, 0x69, /* Logical Maximum (105), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x02, /* Report Count (2), */ + 0x09, 0x3D, /* Usage (X Tilt), */ + 0x09, 0x3E, /* Usage (Y Tilt), */ + 0x81, 0x02, /* Input (Variable), */ + 0xB4, /* Pop, */ + 0xC0, /* End Collection, */ + 0xC0, /* End Collection, */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x02, /* Usage (Mouse), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x01, /* Report ID (1), */ + 0x09, 0x01, /* Usage (Pointer), */ + 0xA0, /* Collection (Physical), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x09, 0x38, /* Usage (Wheel), */ + 0x15, 0xFF, /* Logical Minimum (-1), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x06, /* Input (Variable, Relative), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0xC0, /* End Collection, */ + 0xC0, /* End Collection, */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x06, /* Usage (Keyboard), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x0D, /* Report ID (13), */ + 0x05, 0x07, /* Usage Page (Keyboard), */ + 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */ + 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x08, /* Report Count (8), */ + 0x81, 0x02, /* Input (Variable), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x01, /* Input (Constant), */ + 0x18, /* Usage Minimum (None), */ + 0x29, 0x65, /* Usage Maximum (KB Application), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x65, /* Logical Maximum (101), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x05, /* Report Count (5), */ + 0x80, /* Input, */ + 0xC0, /* End Collection, */ + 0x05, 0x0C, /* Usage Page (Consumer), */ + 0x09, 0x01, /* Usage (Consumer Control), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x0C, /* Report ID (12), */ + 0x09, 0xE9, /* Usage (Volume Inc), */ + 0x09, 0xEA, /* Usage (Volume Dec), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x02, /* Input (Variable), */ + 0x75, 0x06, /* Report Size (6), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0xC0 /* End Collection */ +}; + struct waltop_state { u8 pressure0; u8 pressure1; @@ -583,6 +719,12 @@ static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc, *rsize = sizeof(media_tablet_14_1_inch_rdesc_fixed); } break; + case USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET: + if (*rsize == SIRIUS_BATTERY_FREE_TABLET_RDESC_ORIG_SIZE) { + rdesc = sirius_battery_free_tablet_rdesc_fixed; + *rsize = sizeof(sirius_battery_free_tablet_rdesc_fixed); + } + break; } return rdesc; } @@ -614,6 +756,51 @@ static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report, } } + /* If this is a pen input report of Sirius Battery Free Tablet */ + if (hdev->product == USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET && + report->type == HID_INPUT_REPORT && + report->id == 16 && + size == 10) { + /* + * The tablet reports tilt as roughly sin(a)*21 (18 means 60 + * degrees). + * + * This array stores angles as radians * 100, corresponding to + * reported values up to 60 degrees, as expected by userspace. + */ + static const s8 tilt_to_radians[] = { + 0, 5, 10, 14, 19, 24, 29, 34, 40, 45, + 50, 56, 62, 68, 74, 81, 88, 96, 105 + }; + + s8 tilt_x = (s8)data[8]; + s8 tilt_y = (s8)data[9]; + s8 sign_x = tilt_x >= 0 ? 1 : -1; + s8 sign_y = tilt_y >= 0 ? 1 : -1; + + tilt_x *= sign_x; + tilt_y *= sign_y; + + /* + * Reverse the Y Tilt direction to match the HID standard and + * userspace expectations. See HID Usage Tables v1.12 16.3.2 + * Tilt Orientation. + */ + sign_y *= -1; + + /* + * This effectively clamps reported tilt to 60 degrees - the + * range expected by userspace + */ + if (tilt_x > ARRAY_SIZE(tilt_to_radians) - 1) + tilt_x = ARRAY_SIZE(tilt_to_radians) - 1; + if (tilt_y > ARRAY_SIZE(tilt_to_radians) - 1) + tilt_y = ARRAY_SIZE(tilt_to_radians) - 1; + + data[8] = tilt_to_radians[tilt_x] * sign_x; + data[9] = tilt_to_radians[tilt_y] * sign_y; + } + return 0; } @@ -638,6 +825,8 @@ static const struct hid_device_id waltop_devices[] = { USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, + USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, { } }; MODULE_DEVICE_TABLE(hid, waltop_devices); diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 782c63955f2..0597ee604f6 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c @@ -88,6 +88,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH, HID_QUIRK_MULTI_INPUT }, + { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_WISEGROUP_LTD2, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, -- cgit v1.2.3-70-g09d2 From cfb7563bca99a264c1e5574027b80018cac1752e Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Wed, 28 Mar 2012 22:13:36 +0100 Subject: HID: wacom: Fix HID_WACOM self-dependency This patch fixes a silly mistake: HID_WACOM was dependent on HID_WACOM, so the option wasn't showing up after make menuconfig Signed-off-by: Przemo Firszt Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 32ada100115..4ecc25629a4 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -595,7 +595,6 @@ config THRUSTMASTER_FF config HID_WACOM tristate "Wacom Bluetooth devices support" depends on BT_HIDP - depends on HID_WACOM select POWER_SUPPLY ---help--- Support for Wacom Graphire Bluetooth and Intuos4 WL tablets. -- cgit v1.2.3-70-g09d2 From 1fa2f722a70a6785fc3c2afd026a74b2684f32c7 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Wed, 28 Mar 2012 22:13:37 +0100 Subject: HID: wacom: Add module description Add description for hid-wacom module: "Driver for Wacom Graphire Bluetooth and Wacom Intuos4 WL" Signed-off-by: Przemo Firszt Signed-off-by: Jiri Kosina --- 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 f130f40488f..fb0fe165a89 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -687,5 +687,5 @@ static void __exit wacom_exit(void) module_init(wacom_init); module_exit(wacom_exit); +MODULE_DESCRIPTION("Driver for Wacom Graphire Bluetooth and Wacom Intuos4 WL"); MODULE_LICENSE("GPL"); - -- cgit v1.2.3-70-g09d2 From 0a97e1e9f9a6765e6243030ac42b04694f3f3647 Mon Sep 17 00:00:00 2001 From: Alexey Kaminsky Date: Mon, 23 Apr 2012 18:02:18 +0200 Subject: HID: apple: Add Apple wireless keyboard 2011 ANSI PID Signed-off-by: Alexey Kaminsky Signed-off-by: Jiri Kosina --- drivers/hid/hid-apple.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 299d2387112..9c6a4a328ac 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -458,6 +458,9 @@ static const struct hid_device_id apple_devices[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, + USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), -- cgit v1.2.3-70-g09d2 From 692d30d63b80b174d0ed24bbffb7a1ea536d5fee Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Tue, 24 Apr 2012 10:51:30 +0200 Subject: HID: add Kconfig text to HID_BATTERY_STRENGTH HID_BATTERY_STRENGTH is missing both help text and description text. Reported-by: Geert Uytterhoeven Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index ffddcba32af..a6f6b50b67a 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -32,9 +32,13 @@ config HID If unsure, say Y. config HID_BATTERY_STRENGTH - bool + bool "Battery level reporting for HID devices" depends on HID && POWER_SUPPLY && HID = POWER_SUPPLY default n + ---help--- + This option adds support of reporting battery strength (for HID devices + that support this feature) through power_supply class so that userspace + tools, such as upower, can display it. config HIDRAW bool "/dev/hidraw raw HID device support" -- cgit v1.2.3-70-g09d2 From c653daba895a2d339b3b8f04e69fc111443ef327 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Fri, 4 May 2012 18:00:10 +0100 Subject: HID: wacom: Add tilt reporting for Intuos4 WL 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 Signed-off-by: Jiri Kosina --- 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 fb0fe165a89..a66e1aa25ca 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -363,6 +363,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 */ @@ -399,6 +400,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); @@ -409,6 +412,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); @@ -548,6 +553,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; } -- cgit v1.2.3-70-g09d2 From 74b89e8a3625c17c7452532dfb997ac4f1a38751 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 8 May 2012 16:52:31 +0200 Subject: HID: wiimote: Fix IR data parser We incorrectly parse incoming IR data. The extra byte contains the upper bits and not the lower bits of the x/y coordinates. User-space expects absolute position data from us so this patch does not break existing applications. On the contrary, it extends the virtual view and fixes garbage reports for margin areas of the virtual screen. Cc: stable@kernel.org Reported-by: Peter Bukovsky Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- drivers/hid/hid-wiimote-core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index cac3589b1ed..84e2fbec5fb 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c @@ -769,7 +769,7 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir, /* * Basic IR data is encoded into 3 bytes. The first two bytes are the - * upper 8 bit of the X/Y data, the 3rd byte contains the lower 2 bits + * lower 8 bit of the X/Y data, the 3rd byte contains the upper 2 bits * of both. * If data is packed, then the 3rd byte is put first and slightly * reordered. This allows to interleave packed and non-packed data to @@ -778,17 +778,11 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir, */ if (packed) { - x = ir[1] << 2; - y = ir[2] << 2; - - x |= ir[0] & 0x3; - y |= (ir[0] >> 2) & 0x3; + x = ir[1] | ((ir[0] & 0x03) << 8); + y = ir[2] | ((ir[0] & 0x0c) << 6); } else { - x = ir[0] << 2; - y = ir[1] << 2; - - x |= (ir[2] >> 4) & 0x3; - y |= (ir[2] >> 6) & 0x3; + x = ir[0] | ((ir[2] & 0x30) << 4); + y = ir[1] | ((ir[2] & 0xc0) << 2); } input_report_abs(wdata->ir, xid, x); -- cgit v1.2.3-70-g09d2 From d13f5454e4acbbe2a470cc6743c2998cfcd607a8 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Thu, 10 May 2012 19:23:52 +0100 Subject: HID: wacom: Add LED selector control for Wacom Intuos4 WL 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 Signed-off-by: Jiri Kosina --- 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 0130d6683c1..56c54558c8a 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/-:./wacom_led/led Date: August 2011 Contact: linux-input@vger.kernel.org diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 4ecc25629a4..6e0d65aca30 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -596,6 +596,7 @@ config HID_WACOM tristate "Wacom Bluetooth devices support" depends on BT_HIDP select POWER_SUPPLY + select LEDS_CLASS ---help--- Support for Wacom Graphire Bluetooth and Intuos4 WL tablets. diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index a66e1aa25ca..29372edc31c 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,8 @@ #define PAD_DEVICE_ID 0x0F +#define WAC_CMD_LED_CONTROL 0x20 + struct wacom_data { __u16 tool; __u16 butstate; @@ -44,6 +47,8 @@ struct wacom_data { __u8 ps_connected; struct power_supply battery; struct power_supply ac; + __u8 led_selector; + struct led_classdev *leds[4]; }; /*percent of battery capacity for Graphire @@ -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) @@ -602,6 +718,12 @@ static int wacom_probe(struct hid_device *hdev, sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); 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; } @@ -644,6 +766,8 @@ err_ac: err_battery: device_remove_file(&hdev->dev, &dev_attr_speed); hid_hw_stop(hdev); +destroy_leds: + wacom_destroy_leds(hdev); err_free: kfree(wdata); return ret; @@ -652,6 +776,8 @@ err_free: 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_speed); hid_hw_stop(hdev); -- cgit v1.2.3-70-g09d2 From 44d27f7dfedd9aadc082cda31462f6600f56e4ec Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 11 May 2012 16:17:16 +0200 Subject: HID: logitech: read all 32 bits of report type bitfield On big-endian systems (e.g., Apple PowerBook), trying to use a logitech wireless mouse with the Logitech Unifying Receiver does not work with v3.2 and later kernels. The device doesn't show up in /dev/input. Older kernels work fine. That is because the new hid-logitech-dj driver claims the device. The device arrival notification appears: 20 00 41 02 00 00 00 00 00 00 00 00 00 00 00 and we read the report_types bitfield (02 00 00 00) to find out what kind of device it is. Unfortunately the driver only reads the first 8 bits and treats that value as a 32-bit little-endian number, so on a powerpc the report type seems to be 0x02000000 and is not recognized. Even on little-endian machines, connecting a media center remote control (report type 00 01 00 00) with this driver loaded would presumably fail for the same reason. Fix both problems by using get_unaligned_le32() to read all four bytes, which is a little clearer anyway. After this change, the wireless mouse works on Hugo's PowerBook again. Based on a patch by Nestor Lopez Casado. Addresses http://bugs.debian.org/671292 Reported-by: Hugo Osvaldo Barrera Inspired-by: Nestor Lopez Casado Signed-off-by: Jonathan Nieder Signed-off-by: Nestor Lopez Casado Cc: Signed-off-by: Jiri Kosina --- drivers/hid/hid-logitech-dj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index 2b56efcbdf6..d44ea58c597 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "usbhid/usbhid.h" #include "hid-ids.h" #include "hid-logitech-dj.h" @@ -265,8 +266,8 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev, goto dj_device_allocate_fail; } - dj_dev->reports_supported = le32_to_cpu( - dj_report->report_params[DEVICE_PAIRED_RF_REPORT_TYPE]); + dj_dev->reports_supported = get_unaligned_le32( + dj_report->report_params + DEVICE_PAIRED_RF_REPORT_TYPE); dj_dev->hdev = dj_hiddev; dj_dev->dj_receiver_dev = djrcv_dev; dj_dev->device_index = dj_report->device_index; -- cgit v1.2.3-70-g09d2 From 163a6ae19b8f6afc4ac4f60711b998a3c150b858 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 15 May 2012 19:32:25 +0100 Subject: HID: wacom: Move Graphire raport header check. That check is valid only for Wacom Graphire, as the device raports always start with 0x03. Intuos4 WL high-speed raports begin with 0x04, so the check would be filtering out valid reports. Signed-off-by: Przemo Firszt Acked-by: Ping Cheng Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 29372edc31c..4fc4eebe978 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -578,13 +578,15 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, hidinput = list_entry(hdev->inputs.next, struct hid_input, list); input = hidinput->input; - /* Check if this is a tablet report */ - if (data[0] != 0x03) - return 0; - switch (hdev->product) { case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: - return wacom_gr_parse_report(hdev, wdata, input, data); + 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; -- cgit v1.2.3-70-g09d2 From be4925b018b3c398d2775826091c693f214630a8 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 15 May 2012 19:32:26 +0100 Subject: HID: wacom: Add speed setting for Intuos4 WL Add option to change reporting speed for Intuos4 WL. The option is only internal to the module, but it will be extended to allow control over sysfs, as it is already implemented for Graphire. Signed-off-by: Przemo Firszt Acked-by: Ping Cheng Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 4fc4eebe978..5f6ce70c23f 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -228,16 +228,25 @@ static int wacom_ac_get_property(struct power_supply *psy, return ret; } -static void wacom_set_features(struct hid_device *hdev) +static void wacom_set_features(struct hid_device *hdev, u8 speed) { + struct wacom_data *wdata = hid_get_drvdata(hdev); int ret; __u8 rep_data[2]; - /*set high speed, tablet mode*/ + if (speed == 1) + wdata->features &= ~0x20; + else + wdata->features |= 0x20; + rep_data[0] = 0x03; - rep_data[1] = 0x20; + rep_data[1] = wdata->features; + ret = hdev->hid_output_raw_report(hdev, rep_data, 2, HID_FEATURE_REPORT); + if (ret >= 0) + wdata->high_speed = speed; + return; } @@ -719,7 +728,7 @@ static int wacom_probe(struct hid_device *hdev, case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); wdata->features = 0; - wacom_set_features(hdev); + wacom_set_features(hdev, 1); ret = wacom_initialize_leds(hdev); if (ret) { hid_warn(hdev, -- cgit v1.2.3-70-g09d2 From d70a2ffe3a8ce37eeeecbed34e5b7a177956d535 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Tue, 15 May 2012 19:32:28 +0100 Subject: HID: wacom: Unify speed setting This patch unifies speed setting for both supported tablets. Functionality of "wacom_poke" (used only by Graphire) is now in "wacom_set_features". Reporting speed for both tablets can be changed by somethinkg like: echo 1 > /sys/class/bluetooth/hci0/hci0:1/{device No}/speed Accepted values: 0 - low speed, 1 - high speed. The way of changing reporting speed is the same for Graphire and Intuos4 WL. Signed-off-by: Przemo Firszt Acked-by: Ping Cheng Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 102 ++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 5f6ce70c23f..fe23a1eb586 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -229,47 +229,14 @@ static int wacom_ac_get_property(struct power_supply *psy, } static void wacom_set_features(struct hid_device *hdev, u8 speed) -{ - struct wacom_data *wdata = hid_get_drvdata(hdev); - int ret; - __u8 rep_data[2]; - - if (speed == 1) - wdata->features &= ~0x20; - else - wdata->features |= 0x20; - - rep_data[0] = 0x03; - rep_data[1] = wdata->features; - - ret = hdev->hid_output_raw_report(hdev, rep_data, 2, - HID_FEATURE_REPORT); - if (ret >= 0) - wdata->high_speed = speed; - - return; -} - -static void wacom_poke(struct hid_device *hdev, u8 speed) { struct wacom_data *wdata = hid_get_drvdata(hdev); int limit, ret; - char rep_data[2]; - - rep_data[0] = 0x03 ; rep_data[1] = 0x00; - limit = 3; - do { - ret = hdev->hid_output_raw_report(hdev, rep_data, 2, - HID_FEATURE_REPORT); - } while (ret < 0 && limit-- > 0); - - if (ret >= 0) { - if (speed == 0) - rep_data[0] = 0x05; - else - rep_data[0] = 0x06; + __u8 rep_data[2]; - rep_data[1] = 0x00; + switch (hdev->product) { + case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: + rep_data[0] = 0x03 ; rep_data[1] = 0x00; limit = 3; do { ret = hdev->hid_output_raw_report(hdev, rep_data, 2, @@ -277,17 +244,47 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) } while (ret < 0 && limit-- > 0); if (ret >= 0) { - wdata->high_speed = speed; - return; + if (speed == 0) + rep_data[0] = 0x05; + else + rep_data[0] = 0x06; + + rep_data[1] = 0x00; + limit = 3; + do { + ret = hdev->hid_output_raw_report(hdev, + rep_data, 2, HID_FEATURE_REPORT); + } while (ret < 0 && limit-- > 0); + + 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 = hdev->hid_output_raw_report(hdev, rep_data, 2, + HID_FEATURE_REPORT); + if (ret >= 0) + wdata->high_speed = speed; + break; } - /* - * 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); return; } @@ -311,7 +308,7 @@ static ssize_t wacom_store_speed(struct device *dev, return -EINVAL; if (new_speed == 0 || new_speed == 1) { - wacom_poke(hdev, new_speed); + wacom_set_features(hdev, new_speed); return strnlen(buf, PAGE_SIZE); } else return -EINVAL; @@ -720,22 +717,17 @@ static int wacom_probe(struct hid_device *hdev, hid_warn(hdev, "can't create sysfs speed attribute err: %d\n", ret); - switch (hdev->product) { - case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: - /* Set Wacom mode 2 with high reporting speed */ - wacom_poke(hdev, 1); - break; - case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: + wdata->features = 0; + wacom_set_features(hdev, 1); + + if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) { sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); - wdata->features = 0; - wacom_set_features(hdev, 1); ret = wacom_initialize_leds(hdev); if (ret) { hid_warn(hdev, "can't create led attribute, err: %d\n", ret); goto destroy_leds; } - break; } wdata->battery.properties = wacom_battery_props; -- cgit v1.2.3-70-g09d2 From ed13794925786a64b2a21389d40a09e4012c357d Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Sun, 20 May 2012 21:23:36 +0300 Subject: HID: waltop: Extend barrel button fix Extend Waltop barrel button fix to all models: ignore reported pressure when a barrel button is pressed, because it is rarely correct. Report zero pressure in such cases instead. Signed-off-by: Nikolai Kondrashov Signed-off-by: Jiri Kosina --- drivers/hid/hid-waltop.c | 45 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/drivers/hid/hid-waltop.c b/drivers/hid/hid-waltop.c index 9a48438090a..745e4e9a8cf 100644 --- a/drivers/hid/hid-waltop.c +++ b/drivers/hid/hid-waltop.c @@ -638,28 +638,10 @@ static __u8 sirius_battery_free_tablet_rdesc_fixed[] = { 0xC0 /* End Collection */ }; -struct waltop_state { - u8 pressure0; - u8 pressure1; -}; - static int waltop_probe(struct hid_device *hdev, const struct hid_device_id *id) { int ret; - struct waltop_state *s; - - s = kzalloc(sizeof(*s), GFP_KERNEL); - if (s == NULL) { - hid_err(hdev, "can't allocate device state\n"); - ret = -ENOMEM; - goto err; - } - - s->pressure0 = 0; - s->pressure1 = 0; - - hid_set_drvdata(hdev, s); ret = hid_parse(hdev); if (ret) { @@ -675,7 +657,6 @@ static int waltop_probe(struct hid_device *hdev, return 0; err: - kfree(s); return ret; } @@ -732,27 +713,18 @@ static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc, static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { - /* If this is a pen input report of a tablet with PID 0038 */ - if (hdev->product == USB_DEVICE_ID_WALTOP_PID_0038 && - report->type == HID_INPUT_REPORT && - report->id == 16 && - size == 8) { - struct waltop_state *s = hid_get_drvdata(hdev); - + /* If this is a pen input report */ + if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) { /* - * Ignore maximum pressure reported when a barrel button is - * pressed. + * Ignore reported pressure when a barrel button is pressed, + * because it is rarely correct. */ /* If a barrel button is pressed */ if ((data[1] & 0xF) > 1) { - /* Use the last known pressure */ - data[6] = s->pressure0; - data[7] = s->pressure1; - } else { - /* Remember reported pressure */ - s->pressure0 = data[6]; - s->pressure1 = data[7]; + /* Report zero pressure */ + data[6] = 0; + data[7] = 0; } } @@ -806,10 +778,7 @@ static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report, static void waltop_remove(struct hid_device *hdev) { - struct waltop_state *s = hid_get_drvdata(hdev); - hid_hw_stop(hdev); - kfree(s); } static const struct hid_device_id waltop_devices[] = { -- cgit v1.2.3-70-g09d2 From 4e52b538e31d8eca2dde1f01e0685977c19d006e Mon Sep 17 00:00:00 2001 From: David Rientjes Date: Sat, 19 May 2012 19:11:55 -0700 Subject: HID: wacom: fix build breakage without CONFIG_LEDS_CLASS CONFIG_HID_WACOM must depend on CONFIG_LEDS_CLASS, otherwise CONFIG_NEW_LEDS may be disabled. Signed-off-by: David Rientjes Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 6e0d65aca30..81b13e41a0c 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -595,8 +595,8 @@ config THRUSTMASTER_FF config HID_WACOM tristate "Wacom Bluetooth devices support" depends on BT_HIDP + depends on LEDS_CLASS select POWER_SUPPLY - select LEDS_CLASS ---help--- Support for Wacom Graphire Bluetooth and Intuos4 WL tablets. -- cgit v1.2.3-70-g09d2