[PATCH] LEDS-One-Shot-Timer-Trigger-implementation

From: Shuah Khan
Date: Tue Mar 27 2012 - 11:21:42 EST


LED infrastructure lacks support for one shot timer trigger and activation.
The current support allows for setting two timers, one for specifying how
long a state to be on, and the second for how long the state to be off. For
example, delay_on value specifies the time period an LED should stay in on
state, followed by a delay_off value that specifies how long the LED should
stay in off state. The on and off cycle repeats until the trigger gets
deactivated. There is no provision for one time activation to implement
features that require an on or off state to be held just once and then stay
in the original state forever.

This feature will help implement vibrate functionality which requires one
shot activation of vibrate mode without a continuous vibrate on/off cycles.

This patch implements the one-shot-timer trigger support by enhancing the
current led-class and ledtrig-timer drivers to support the following
use-cases:

use-case 1:
echo one-shot-timer > /sys/class/leds/SOMELED/trigger
echo 2000 > /sys/class/leds/SOMELED/delay_on
echo forever > /sys/class/leds/SOMELED/delay_off

When one-shot-timer is activated in step1, unlike the timer trigger case,
one-shot-timer activate routine activates the trigger without starting
any timers. The default 1 HZ delay_on and delay_off timers won't be started
like in the case of timer trigger activation. Not starting timers ensures
that the one shot state isn't stuck if some error occurs before actual timer
periods are specified. delay_on and delay_off files get created with 0
values.

When delay_on value is specified in step 2, a timer gets started for delay_on
period, and delay_off stays at 0 or whatever its current value is.

When delay_off value is specified in step 3, delay_off_store recognizes the
special forever tag and records it and returns without starting any timer.

use-case 2:
echo one-shot-timer > /sys/class/leds/SOMELED/trigger
echo 2000 > /sys/class/leds/SOMELED/delay_off
echo forever > /sys/class/leds/SOMELED/delay_on

When one-shot-timer is activated in step1, unlike the timer trigger case,
one-shot-timer activate routine activates the trigger without starting
any timers. The default 1 HZ delay_on and delay_off timers won't be started
like in the case of timer trigger activation. Not starting timers ensures
that the one shot state isn't stuck if some error occurs before actual timer
periods are specified. delay_on and delay_off files get created with 0
values.

When delay_off value is specified in step 2, a timer gets started for delay_off
period, and delay_on stays at 0 or whatever its current value is.

When delay_on value is specified in step 3, delay_on_store recognizes the
special forever tag and records it and returns without starting any timer.