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 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/hid/Kconfig') diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index a3d033252995..c2ab80e5f62a 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" -- cgit v1.2.3 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(-) (limited to 'drivers/hid/Kconfig') diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index c2ab80e5f62a..32ada1001159 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 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(-) (limited to 'drivers/hid/Kconfig') diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 32ada1001159..4ecc25629a45 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 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(-) (limited to 'drivers/hid/Kconfig') diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index ffddcba32af6..a6f6b50b67af 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 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(+) (limited to 'drivers/hid/Kconfig') diff --git a/Documentation/ABI/testing/sysfs-driver-wacom b/Documentation/ABI/testing/sysfs-driver-wacom index 0130d6683c14..56c54558c8a4 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 4ecc25629a45..6e0d65aca308 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 a66e1aa25cac..29372edc31c0 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 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(-) (limited to 'drivers/hid/Kconfig') diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 6e0d65aca308..81b13e41a0c5 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