diff options
author | Fabio Baltieri <fabio.baltieri@gmail.com> | 2012-05-27 07:19:22 +0800 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-24 07:52:34 +0800 |
commit | 5bb629c504394f4d42c53a25d75ccb02a393f92f (patch) | |
tree | c504fb776de83b95045d3274cd7bc82cee0bc983 /include/linux/leds.h | |
parent | eb202621f8c0fb264a35e1b35fc00bdb3114a897 (diff) | |
download | op-kernel-dev-5bb629c504394f4d42c53a25d75ccb02a393f92f.zip op-kernel-dev-5bb629c504394f4d42c53a25d75ccb02a393f92f.tar.gz |
leds: add oneshot blink functions
Add two new functions, led_blink_set_oneshot and
led_trigger_blink_oneshot, to be used by triggers for one-shot blink of
led devices.
This is implemented extending the existing software-blink code, and uses
the same timer and handler function.
The behavior of the code is to do a blink-on, blink-off sequence when
the function is called, ignoring other calls until the sequence is
completed so that the leds keep blinking at constant rate if the
functions are called repeatedly.
This is meant to be used by drivers which needs to trigger on sporadic
event, but doesn't have clear busy/idle trigger points.
After the blink sequence the led remains off. This behavior can be
inverted setting the "invert" argument, which blink the led off, than on
and leave the led on after the sequence.
(bryan.wu@canonical.com: rebase to commit 'leds: don't disable blinking
when writing the same value to delay_on or delay_off')
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Acked-by: Shuah Khan <shuahkhan@gmail.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'include/linux/leds.h')
-rw-r--r-- | include/linux/leds.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/leds.h b/include/linux/leds.h index 39eee41..dd93a220 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -38,6 +38,9 @@ struct led_classdev { #define LED_SUSPENDED (1 << 0) /* Upper 16 bits reflect control information */ #define LED_CORE_SUSPENDRESUME (1 << 16) +#define LED_BLINK_ONESHOT (1 << 17) +#define LED_BLINK_ONESHOT_STOP (1 << 18) +#define LED_BLINK_INVERT (1 << 19) /* Set LED brightness level */ /* Must not sleep, use a workqueue if needed */ @@ -103,6 +106,24 @@ extern void led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off); /** + * led_blink_set_oneshot - do a oneshot software blink + * @led_cdev: the LED to start blinking + * @delay_on: the time it should be on (in ms) + * @delay_off: the time it should ble off (in ms) + * @invert: blink off, then on, leaving the led on + * + * This function makes the LED blink one time for delay_on + + * delay_off time, ignoring the request if another one-shot + * blink is already in progress. + * + * If invert is set, led blinks for delay_off first, then for + * delay_on and leave the led on after the on-off cycle. + */ +extern void led_blink_set_oneshot(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off, + int invert); +/** * led_brightness_set - set LED brightness * @led_cdev: the LED to set * @brightness: the brightness to set it to @@ -150,6 +171,10 @@ extern void led_trigger_event(struct led_trigger *trigger, extern void led_trigger_blink(struct led_trigger *trigger, unsigned long *delay_on, unsigned long *delay_off); +extern void led_trigger_blink_oneshot(struct led_trigger *trigger, + unsigned long *delay_on, + unsigned long *delay_off, + int invert); #else |