brintos

brintos / linux-shallow public Read only

0
0
Text · 6.9 KiB · 63072f3 Raw
161 lines · plain
1=====================2LED Transient Trigger3=====================4 5The leds timer trigger does not currently have an interface to activate6a one shot timer. The current support allows for setting two timers, one for7specifying how long a state to be on, and the second for how long the state8to be off. The delay_on value specifies the time period an LED should stay9in on state, followed by a delay_off value that specifies how long the LED10should stay in off state. The on and off cycle repeats until the trigger11gets deactivated. There is no provision for one time activation to implement12features that require an on or off state to be held just once and then stay in13the original state forever.14 15Without one shot timer interface, user space can still use timer trigger to16set a timer to hold a state, however when user space application crashes or17goes away without deactivating the timer, the hardware will be left in that18state permanently.19 20Transient trigger addresses the need for one shot timer activation. The21transient trigger can be enabled and disabled just like the other leds22triggers.23 24When an led class device driver registers itself, it can specify all leds25triggers it supports and a default trigger. During registration, activation26routine for the default trigger gets called. During registration of an led27class device, the LED state does not change.28 29When the driver unregisters, deactivation routine for the currently active30trigger will be called, and LED state is changed to LED_OFF.31 32Driver suspend changes the LED state to LED_OFF and resume doesn't change33the state. Please note that there is no explicit interaction between the34suspend and resume actions and the currently enabled trigger. LED state35changes are suspended while the driver is in suspend state. Any timers36that are active at the time driver gets suspended, continue to run, without37being able to actually change the LED state. Once driver is resumed, triggers38start functioning again.39 40LED state changes are controlled using brightness which is a common led41class device property. When brightness is set to 0 from user space via42echo 0 > brightness, it will result in deactivating the current trigger.43 44Transient trigger uses standard register and unregister interfaces. During45trigger registration, for each led class device that specifies this trigger46as its default trigger, trigger activation routine will get called. During47registration, the LED state does not change, unless there is another trigger48active, in which case LED state changes to LED_OFF.49 50During trigger unregistration, LED state gets changed to LED_OFF.51 52Transient trigger activation routine doesn't change the LED state. It53creates its properties and does its initialization. Transient trigger54deactivation routine, will cancel any timer that is active before it cleans55up and removes the properties it created. It will restore the LED state to56non-transient state. When driver gets suspended, irrespective of the transient57state, the LED state changes to LED_OFF.58 59Transient trigger can be enabled and disabled from user space on led class60devices, that support this trigger as shown below::61 62	echo transient > trigger63	echo none > trigger64 65NOTE:66	Add a new property trigger state to control the state.67 68This trigger exports three properties, activate, state, and duration. When69transient trigger is activated these properties are set to default values.70 71- duration allows setting timer value in msecs. The initial value is 0.72- activate allows activating and deactivating the timer specified by73  duration as needed. The initial and default value is 0.  This will allow74  duration to be set after trigger activation.75- state allows user to specify a transient state to be held for the specified76  duration.77 78	activate79	      - one shot timer activate mechanism.80		1 when activated, 0 when deactivated.81		default value is zero when transient trigger is enabled,82		to allow duration to be set.83 84		activate state indicates a timer with a value of specified85		duration running.86		deactivated state indicates that there is no active timer87		running.88 89	duration90	      - one shot timer value. When activate is set, duration value91		is used to start a timer that runs once. This value doesn't92		get changed by the trigger unless user does a set via93		echo new_value > duration94 95	state96	      - transient state to be held. It has two values 0 or 1. 0 maps97		to LED_OFF and 1 maps to LED_FULL. The specified state is98		held for the duration of the one shot timer and then the99		state gets changed to the non-transient state which is the100		inverse of transient state.101		If state = LED_FULL, when the timer runs out the state will102		go back to LED_OFF.103		If state = LED_OFF, when the timer runs out the state will104		go back to LED_FULL.105		Please note that current LED state is not checked prior to106		changing the state to the specified state.107		Driver could map these values to inverted depending on the108		default states it defines for the LED in its brightness_set()109		interface which is called from the led brightness_set()110		interfaces to control the LED state.111 112When timer expires activate goes back to deactivated state, duration is left113at the set value to be used when activate is set at a future time. This will114allow user app to set the time once and activate it to run it once for the115specified value as needed. When timer expires, state is restored to the116non-transient state which is the inverse of the transient state:117 118	=================   ===============================================119	echo 1 > activate   starts timer = duration when duration is not 0.120	echo 0 > activate   cancels currently running timer.121	echo n > duration   stores timer value to be used upon next122			    activate. Currently active timer if123			    any, continues to run for the specified time.124	echo 0 > duration   stores timer value to be used upon next125			    activate. Currently active timer if any,126			    continues to run for the specified time.127	echo 1 > state      stores desired transient state LED_FULL to be128			    held for the specified duration.129	echo 0 > state      stores desired transient state LED_OFF to be130			    held for the specified duration.131	=================   ===============================================132 133What is not supported134=====================135 136- Timer activation is one shot and extending and/or shortening the timer137  is not supported.138 139Examples140========141 142use-case 1::143 144	echo transient > trigger145	echo n > duration146	echo 1 > state147 148repeat the following step as needed::149 150	echo 1 > activate - start timer = duration to run once151	echo 1 > activate - start timer = duration to run once152	echo none > trigger153 154This trigger is intended to be used for the following example use cases:155 156 - Use of LED by user space app as activity indicator.157 - Use of LED by user space app as a kind of watchdog indicator -- as158   long as the app is alive, it can keep the LED illuminated, if it dies159   the LED will be extinguished automatically.160 - Use by any user space app that needs a transient GPIO output.161