aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorMárton Németh <nm127@freemail.hu>2007-10-31 10:09:05 -0400
committerRichard Purdie <rpurdie@rpsys.net>2008-02-07 04:52:02 -0500
commit92e015cb31c0a312bf2e0e5b96aef76a8c57e645 (patch)
tree6df4b25865102607920b5c90f1271dfe2f3cc87e /drivers/leds
parent4c79141d28bc290ae307e3f81f5bc909c26faf6e (diff)
leds: hw acceleration for Clevo mail LED driver
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>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/Kconfig8
-rw-r--r--drivers/leds/leds-clevo-mail.c37
2 files changed, 42 insertions, 3 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 659448ead685..922c3df548a5 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -122,9 +122,11 @@ config LEDS_CLEVO_MAIL
122 programs through the leds subsystem. This LED have three 122 programs through the leds subsystem. This LED have three
123 known mode: off, blink at 0.5Hz and blink at 1Hz. 123 known mode: off, blink at 0.5Hz and blink at 1Hz.
124 124
125 As this LED cannot change it's brightness it blinks instead. 125 The driver supports two kinds of interface: using ledtrig-timer
126 The brightness value 0 means off, 1..127 means blink at 0.5Hz 126 or through /sys/class/leds/clevo::mail/brightness. As this LED
127 and 128..255 means blink at 1Hz. 127 cannot change it's brightness it blinks instead. The brightness
128 value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means
129 blink at 1Hz.
128 130
129 This module can drive the mail LED for the following notebooks: 131 This module can drive the mail LED for the following notebooks:
130 132
diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
index 49a7972459c9..6c3d33b8e383 100644
--- a/drivers/leds/leds-clevo-mail.c
+++ b/drivers/leds/leds-clevo-mail.c
@@ -92,9 +92,46 @@ static void clevo_mail_led_set(struct led_classdev *led_cdev,
92 92
93} 93}
94 94
95static int clevo_mail_led_blink(struct led_classdev *led_cdev,
96 unsigned long* delay_on,
97 unsigned long* delay_off)
98{
99 int status = -EINVAL;
100
101 if (*delay_on == 0 /* ms */ && *delay_off == 0 /* ms */) {
102 /* Special case: the leds subsystem requested us to
103 * chose one user friendly blinking of the LED, and
104 * start it. Let's blink the led slowly (0.5Hz).
105 */
106 *delay_on = 1000; /* ms */
107 *delay_off = 1000; /* ms */
108 i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
109 status = 0;
110
111 } else if (*delay_on == 500 /* ms */ && *delay_off == 500 /* ms */) {
112 /* blink the led with 1Hz */
113 i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
114 status = 0;
115
116 } else if (*delay_on == 1000 /* ms */ && *delay_off == 1000 /* ms */) {
117 /* blink the led with 0.5Hz */
118 i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
119 status = 0;
120
121 } else {
122 printk(KERN_DEBUG KBUILD_MODNAME
123 ": clevo_mail_led_blink(..., %lu, %lu),"
124 " returning -EINVAL (unsupported)\n",
125 *delay_on, *delay_off);
126 }
127
128 return status;
129}
130
95static struct led_classdev clevo_mail_led = { 131static struct led_classdev clevo_mail_led = {
96 .name = "clevo::mail", 132 .name = "clevo::mail",
97 .brightness_set = clevo_mail_led_set, 133 .brightness_set = clevo_mail_led_set,
134 .blink_set = clevo_mail_led_blink,
98}; 135};
99 136
100static int __init clevo_mail_led_probe(struct platform_device *pdev) 137static int __init clevo_mail_led_probe(struct platform_device *pdev)