summaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2016-06-21 21:49:29 +0200
committerJiri Kosina <jkosina@suse.cz>2016-06-23 08:47:41 +0200
commit007414e8fbc8894f33a548874946b6edd2a2918e (patch)
tree83f0fde2258e8e284d3a3ac585c66db00bbae3ff /drivers/hid
parent4374573008df08a3a7a84cd827ed8f1ceee9901b (diff)
downloadlinux-0-day-007414e8fbc8894f33a548874946b6edd2a2918e.tar.gz
linux-0-day-007414e8fbc8894f33a548874946b6edd2a2918e.tar.xz
HID: hid-led: add support for ThingM blink(1)
Add support for ThingM blink(1) and make the dedicated ThingM driver obsolete. Successfully tested with a blink(1) mk2. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/Kconfig7
-rw-r--r--drivers/hid/hid-led.c66
2 files changed, 70 insertions, 3 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 9eeb0138ede3a..0fecf8f0bb9d7 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -393,9 +393,10 @@ config HID_LED
depends on HID
depends on LEDS_CLASS
---help---
- Support for simple RGB LED devices. Currently supported are the
- Riso Kagaku Webmail Notifier and the Dream Cheeky Webmail Notifier
- and Friends Alert.
+ Support for simple RGB LED devices. Currently supported are:
+ - Riso Kagaku Webmail Notifier
+ - Dream Cheeky Webmail Notifier and Friends Alert
+ - ThingM blink(1)
To compile this driver as a module, choose M here: the
module will be called hid-led.
diff --git a/drivers/hid/hid-led.c b/drivers/hid/hid-led.c
index 4075f095c2a22..e11b6455429b8 100644
--- a/drivers/hid/hid-led.c
+++ b/drivers/hid/hid-led.c
@@ -26,6 +26,7 @@ enum hidled_report_type {
enum hidled_type {
RISO_KAGAKU,
DREAM_CHEEKY,
+ THINGM,
};
static unsigned const char riso_kagaku_tbl[] = {
@@ -198,6 +199,57 @@ static int dream_cheeky_init(struct hidled_device *ldev)
return hidled_send(ldev, buf);
}
+static int _thingm_write(struct led_classdev *cdev, enum led_brightness br,
+ u8 offset)
+{
+ struct hidled_led *led = to_hidled_led(cdev);
+ __u8 buf[MAX_REPORT_SIZE] = { [1] = 'c' };
+
+ buf[2] = led->rgb->red.cdev.brightness;
+ buf[3] = led->rgb->green.cdev.brightness;
+ buf[4] = led->rgb->blue.cdev.brightness;
+ buf[7] = led->rgb->num + offset;
+
+ return hidled_send(led->rgb->ldev, buf);
+}
+
+static int thingm_write_v1(struct led_classdev *cdev, enum led_brightness br)
+{
+ return _thingm_write(cdev, br, 0);
+}
+
+static int thingm_write(struct led_classdev *cdev, enum led_brightness br)
+{
+ return _thingm_write(cdev, br, 1);
+}
+
+static const struct hidled_config hidled_config_thingm_v1 = {
+ .name = "ThingM blink(1) v1",
+ .short_name = "thingm",
+ .max_brightness = 255,
+ .num_leds = 1,
+ .report_size = 9,
+ .report_type = RAW_REQUEST,
+ .report_id = 1,
+ .write = thingm_write_v1,
+};
+
+static int thingm_init(struct hidled_device *ldev)
+{
+ __u8 buf[MAX_REPORT_SIZE] = { [1] = 'v' };
+ int ret;
+
+ ret = hidled_recv(ldev, buf);
+ if (ret)
+ return ret;
+
+ /* Check for firmware major version 1 */
+ if (buf[3] == '1')
+ ldev->config = &hidled_config_thingm_v1;
+
+ return 0;
+}
+
static const struct hidled_config hidled_configs[] = {
{
.type = RISO_KAGAKU,
@@ -222,6 +274,18 @@ static const struct hidled_config hidled_configs[] = {
.init = dream_cheeky_init,
.write = dream_cheeky_write,
},
+ {
+ .type = THINGM,
+ .name = "ThingM blink(1)",
+ .short_name = "thingm",
+ .max_brightness = 255,
+ .num_leds = 2,
+ .report_size = 9,
+ .report_type = RAW_REQUEST,
+ .report_id = 1,
+ .init = thingm_init,
+ .write = thingm_write,
+ },
};
static int hidled_init_led(struct hidled_led *led, const char *color_name,
@@ -325,6 +389,8 @@ static const struct hid_device_id hidled_table[] = {
USB_DEVICE_ID_DREAM_CHEEKY_WN), .driver_data = DREAM_CHEEKY },
{ HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY,
USB_DEVICE_ID_DREAM_CHEEKY_FA), .driver_data = DREAM_CHEEKY },
+ { HID_USB_DEVICE(USB_VENDOR_ID_THINGM,
+ USB_DEVICE_ID_BLINK1), .driver_data = THINGM },
{ }
};
MODULE_DEVICE_TABLE(hid, hidled_table);