]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
leds: hw acceleration for Clevo mail LED driver
authorMárton Németh <nm127@freemail.hu>
Wed, 31 Oct 2007 14:09:05 +0000 (15:09 +0100)
committerRichard Purdie <rpurdie@rpsys.net>
Thu, 7 Feb 2008 09:52:02 +0000 (09:52 +0000)
Add support for hardware accelerated LED blinking for the mail LED
commonly found on Clevo notebooks.

Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/leds/Kconfig
drivers/leds/leds-clevo-mail.c

index 659448ead6858b718b711759ffebb9a10839a41d..922c3df548a54916837cb3e765ec4478e39a4732 100644 (file)
@@ -122,9 +122,11 @@ config LEDS_CLEVO_MAIL
          programs through the leds subsystem. This LED have three
          known mode: off, blink at 0.5Hz and blink at 1Hz.
 
-         As this LED cannot change it's brightness it blinks instead.
-         The brightness value 0 means off, 1..127 means blink at 0.5Hz
-         and 128..255 means blink at 1Hz.
+         The driver supports two kinds of interface: using ledtrig-timer
+         or through /sys/class/leds/clevo::mail/brightness. As this LED
+         cannot change it's brightness it blinks instead. The brightness
+         value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means
+         blink at 1Hz.
 
          This module can drive the mail LED for the following notebooks:
 
index 49a7972459c9418cc59271b08010ce0b676bb804..6c3d33b8e3830f892afefa7045b71945b55192c7 100644 (file)
@@ -92,9 +92,46 @@ static void clevo_mail_led_set(struct led_classdev *led_cdev,
 
 }
 
+static int clevo_mail_led_blink(struct led_classdev *led_cdev,
+                               unsigned long* delay_on,
+                               unsigned long* delay_off)
+{
+       int status = -EINVAL;
+
+       if (*delay_on == 0 /* ms */ && *delay_off == 0 /* ms */) {
+               /* Special case: the leds subsystem requested us to
+                * chose one user friendly blinking of the LED, and
+                * start it. Let's blink the led slowly (0.5Hz).
+                */
+               *delay_on = 1000; /* ms */
+               *delay_off = 1000; /* ms */
+               i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+               status = 0;
+
+       } else if (*delay_on == 500 /* ms */ && *delay_off == 500 /* ms */) {
+               /* blink the led with 1Hz */
+               i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+               status = 0;
+
+       } else if (*delay_on == 1000 /* ms */ && *delay_off == 1000 /* ms */) {
+               /* blink the led with 0.5Hz */
+               i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+               status = 0;
+
+       } else {
+               printk(KERN_DEBUG KBUILD_MODNAME
+                      ": clevo_mail_led_blink(..., %lu, %lu),"
+                      " returning -EINVAL (unsupported)\n",
+                      *delay_on, *delay_off);
+       }
+
+       return status;
+}
+
 static struct led_classdev clevo_mail_led = {
        .name                   = "clevo::mail",
        .brightness_set         = clevo_mail_led_set,
+       .blink_set              = clevo_mail_led_blink,
 };
 
 static int __init clevo_mail_led_probe(struct platform_device *pdev)