summaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/usbled.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/misc/usbled.c')
-rw-r--r--drivers/usb/misc/usbled.c118
1 files changed, 90 insertions, 28 deletions
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index c96f51de1696..1732d9bc097e 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -1,5 +1,5 @@
/*
- * USB LED driver - 1.1
+ * USB LED driver
*
* Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com)
*
@@ -20,12 +20,17 @@
#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com"
#define DRIVER_DESC "USB LED Driver"
-#define VENDOR_ID 0x0fc5
-#define PRODUCT_ID 0x1223
+enum led_type {
+ DELCOM_VISUAL_SIGNAL_INDICATOR,
+ DREAM_CHEEKY_WEBMAIL_NOTIFIER,
+};
/* table of devices that work with this driver */
static const struct usb_device_id id_table[] = {
- { USB_DEVICE(VENDOR_ID, PRODUCT_ID) },
+ { USB_DEVICE(0x0fc5, 0x1223),
+ .driver_info = DELCOM_VISUAL_SIGNAL_INDICATOR },
+ { USB_DEVICE(0x1d34, 0x0004),
+ .driver_info = DREAM_CHEEKY_WEBMAIL_NOTIFIER },
{ },
};
MODULE_DEVICE_TABLE (usb, id_table);
@@ -35,15 +40,12 @@ struct usb_led {
unsigned char blue;
unsigned char red;
unsigned char green;
+ enum led_type type;
};
-#define BLUE 0x04
-#define RED 0x02
-#define GREEN 0x01
static void change_color(struct usb_led *led)
{
int retval;
- unsigned char color = 0x07;
unsigned char *buffer;
buffer = kmalloc(8, GFP_KERNEL);
@@ -52,25 +54,59 @@ static void change_color(struct usb_led *led)
return;
}
- if (led->blue)
- color &= ~(BLUE);
- if (led->red)
- color &= ~(RED);
- if (led->green)
- color &= ~(GREEN);
- dev_dbg(&led->udev->dev,
- "blue = %d, red = %d, green = %d, color = %.2x\n",
- led->blue, led->red, led->green, color);
-
- retval = usb_control_msg(led->udev,
- usb_sndctrlpipe(led->udev, 0),
- 0x12,
- 0xc8,
- (0x02 * 0x100) + 0x0a,
- (0x00 * 0x100) + color,
- buffer,
- 8,
- 2000);
+ switch (led->type) {
+ case DELCOM_VISUAL_SIGNAL_INDICATOR: {
+ unsigned char color = 0x07;
+
+ if (led->blue)
+ color &= ~0x04;
+ if (led->red)
+ color &= ~0x02;
+ if (led->green)
+ color &= ~0x01;
+ dev_dbg(&led->udev->dev,
+ "blue = %d, red = %d, green = %d, color = %.2x\n",
+ led->blue, led->red, led->green, color);
+
+ retval = usb_control_msg(led->udev,
+ usb_sndctrlpipe(led->udev, 0),
+ 0x12,
+ 0xc8,
+ (0x02 * 0x100) + 0x0a,
+ (0x00 * 0x100) + color,
+ buffer,
+ 8,
+ 2000);
+ break;
+ }
+
+ case DREAM_CHEEKY_WEBMAIL_NOTIFIER:
+ dev_dbg(&led->udev->dev,
+ "red = %d, green = %d, blue = %d\n",
+ led->red, led->green, led->blue);
+
+ buffer[0] = led->red;
+ buffer[1] = led->green;
+ buffer[2] = led->blue;
+ buffer[3] = buffer[4] = buffer[5] = 0;
+ buffer[6] = 0x1a;
+ buffer[7] = 0x05;
+
+ retval = usb_control_msg(led->udev,
+ usb_sndctrlpipe(led->udev, 0),
+ 0x09,
+ 0x21,
+ 0x200,
+ 0,
+ buffer,
+ 8,
+ 2000);
+ break;
+
+ default:
+ dev_err(&led->udev->dev, "unknown device type %d\n", led->type);
+ }
+
if (retval)
dev_dbg(&led->udev->dev, "retval = %d\n", retval);
kfree(buffer);
@@ -107,11 +143,12 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id
dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL);
if (dev == NULL) {
- dev_err(&interface->dev, "Out of memory\n");
+ dev_err(&interface->dev, "out of memory\n");
goto error_mem;
}
dev->udev = usb_get_dev(udev);
+ dev->type = id->driver_info;
usb_set_intfdata (interface, dev);
@@ -125,6 +162,31 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id
if (retval)
goto error;
+ if (dev->type == DREAM_CHEEKY_WEBMAIL_NOTIFIER) {
+ unsigned char *enable;
+
+ enable = kmemdup("\x1f\x02\0\x5f\0\0\x1a\x03", 8, GFP_KERNEL);
+ if (!enable) {
+ dev_err(&interface->dev, "out of memory\n");
+ retval = -ENOMEM;
+ goto error;
+ }
+
+ retval = usb_control_msg(udev,
+ usb_sndctrlpipe(udev, 0),
+ 0x09,
+ 0x21,
+ 0x200,
+ 0,
+ enable,
+ 8,
+ 2000);
+
+ kfree(enable);
+ if (retval != 8)
+ goto error;
+ }
+
dev_info(&interface->dev, "USB LED device now attached\n");
return 0;
OpenPOWER on IntegriCloud