1*4882a593Smuzhiyun===================== 2*4882a593SmuzhiyunLED Transient Trigger 3*4882a593Smuzhiyun===================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunThe leds timer trigger does not currently have an interface to activate 6*4882a593Smuzhiyuna one shot timer. The current support allows for setting two timers, one for 7*4882a593Smuzhiyunspecifying how long a state to be on, and the second for how long the state 8*4882a593Smuzhiyunto be off. The delay_on value specifies the time period an LED should stay 9*4882a593Smuzhiyunin on state, followed by a delay_off value that specifies how long the LED 10*4882a593Smuzhiyunshould stay in off state. The on and off cycle repeats until the trigger 11*4882a593Smuzhiyungets deactivated. There is no provision for one time activation to implement 12*4882a593Smuzhiyunfeatures that require an on or off state to be held just once and then stay in 13*4882a593Smuzhiyunthe original state forever. 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunWithout one shot timer interface, user space can still use timer trigger to 16*4882a593Smuzhiyunset a timer to hold a state, however when user space application crashes or 17*4882a593Smuzhiyungoes away without deactivating the timer, the hardware will be left in that 18*4882a593Smuzhiyunstate permanently. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunTransient trigger addresses the need for one shot timer activation. The 21*4882a593Smuzhiyuntransient trigger can be enabled and disabled just like the other leds 22*4882a593Smuzhiyuntriggers. 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunWhen an led class device driver registers itself, it can specify all leds 25*4882a593Smuzhiyuntriggers it supports and a default trigger. During registration, activation 26*4882a593Smuzhiyunroutine for the default trigger gets called. During registration of an led 27*4882a593Smuzhiyunclass device, the LED state does not change. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunWhen the driver unregisters, deactivation routine for the currently active 30*4882a593Smuzhiyuntrigger will be called, and LED state is changed to LED_OFF. 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunDriver suspend changes the LED state to LED_OFF and resume doesn't change 33*4882a593Smuzhiyunthe state. Please note that there is no explicit interaction between the 34*4882a593Smuzhiyunsuspend and resume actions and the currently enabled trigger. LED state 35*4882a593Smuzhiyunchanges are suspended while the driver is in suspend state. Any timers 36*4882a593Smuzhiyunthat are active at the time driver gets suspended, continue to run, without 37*4882a593Smuzhiyunbeing able to actually change the LED state. Once driver is resumed, triggers 38*4882a593Smuzhiyunstart functioning again. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunLED state changes are controlled using brightness which is a common led 41*4882a593Smuzhiyunclass device property. When brightness is set to 0 from user space via 42*4882a593Smuzhiyunecho 0 > brightness, it will result in deactivating the current trigger. 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunTransient trigger uses standard register and unregister interfaces. During 45*4882a593Smuzhiyuntrigger registration, for each led class device that specifies this trigger 46*4882a593Smuzhiyunas its default trigger, trigger activation routine will get called. During 47*4882a593Smuzhiyunregistration, the LED state does not change, unless there is another trigger 48*4882a593Smuzhiyunactive, in which case LED state changes to LED_OFF. 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunDuring trigger unregistration, LED state gets changed to LED_OFF. 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunTransient trigger activation routine doesn't change the LED state. It 53*4882a593Smuzhiyuncreates its properties and does its initialization. Transient trigger 54*4882a593Smuzhiyundeactivation routine, will cancel any timer that is active before it cleans 55*4882a593Smuzhiyunup and removes the properties it created. It will restore the LED state to 56*4882a593Smuzhiyunnon-transient state. When driver gets suspended, irrespective of the transient 57*4882a593Smuzhiyunstate, the LED state changes to LED_OFF. 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunTransient trigger can be enabled and disabled from user space on led class 60*4882a593Smuzhiyundevices, that support this trigger as shown below:: 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun echo transient > trigger 63*4882a593Smuzhiyun echo none > trigger 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunNOTE: 66*4882a593Smuzhiyun Add a new property trigger state to control the state. 67*4882a593Smuzhiyun 68*4882a593SmuzhiyunThis trigger exports three properties, activate, state, and duration. When 69*4882a593Smuzhiyuntransient trigger is activated these properties are set to default values. 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun- duration allows setting timer value in msecs. The initial value is 0. 72*4882a593Smuzhiyun- activate allows activating and deactivating the timer specified by 73*4882a593Smuzhiyun duration as needed. The initial and default value is 0. This will allow 74*4882a593Smuzhiyun duration to be set after trigger activation. 75*4882a593Smuzhiyun- state allows user to specify a transient state to be held for the specified 76*4882a593Smuzhiyun duration. 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun activate 79*4882a593Smuzhiyun - one shot timer activate mechanism. 80*4882a593Smuzhiyun 1 when activated, 0 when deactivated. 81*4882a593Smuzhiyun default value is zero when transient trigger is enabled, 82*4882a593Smuzhiyun to allow duration to be set. 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun activate state indicates a timer with a value of specified 85*4882a593Smuzhiyun duration running. 86*4882a593Smuzhiyun deactivated state indicates that there is no active timer 87*4882a593Smuzhiyun running. 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun duration 90*4882a593Smuzhiyun - one shot timer value. When activate is set, duration value 91*4882a593Smuzhiyun is used to start a timer that runs once. This value doesn't 92*4882a593Smuzhiyun get changed by the trigger unless user does a set via 93*4882a593Smuzhiyun echo new_value > duration 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun state 96*4882a593Smuzhiyun - transient state to be held. It has two values 0 or 1. 0 maps 97*4882a593Smuzhiyun to LED_OFF and 1 maps to LED_FULL. The specified state is 98*4882a593Smuzhiyun held for the duration of the one shot timer and then the 99*4882a593Smuzhiyun state gets changed to the non-transient state which is the 100*4882a593Smuzhiyun inverse of transient state. 101*4882a593Smuzhiyun If state = LED_FULL, when the timer runs out the state will 102*4882a593Smuzhiyun go back to LED_OFF. 103*4882a593Smuzhiyun If state = LED_OFF, when the timer runs out the state will 104*4882a593Smuzhiyun go back to LED_FULL. 105*4882a593Smuzhiyun Please note that current LED state is not checked prior to 106*4882a593Smuzhiyun changing the state to the specified state. 107*4882a593Smuzhiyun Driver could map these values to inverted depending on the 108*4882a593Smuzhiyun default states it defines for the LED in its brightness_set() 109*4882a593Smuzhiyun interface which is called from the led brightness_set() 110*4882a593Smuzhiyun interfaces to control the LED state. 111*4882a593Smuzhiyun 112*4882a593SmuzhiyunWhen timer expires activate goes back to deactivated state, duration is left 113*4882a593Smuzhiyunat the set value to be used when activate is set at a future time. This will 114*4882a593Smuzhiyunallow user app to set the time once and activate it to run it once for the 115*4882a593Smuzhiyunspecified value as needed. When timer expires, state is restored to the 116*4882a593Smuzhiyunnon-transient state which is the inverse of the transient state: 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun ================= =============================================== 119*4882a593Smuzhiyun echo 1 > activate starts timer = duration when duration is not 0. 120*4882a593Smuzhiyun echo 0 > activate cancels currently running timer. 121*4882a593Smuzhiyun echo n > duration stores timer value to be used upon next 122*4882a593Smuzhiyun activate. Currently active timer if 123*4882a593Smuzhiyun any, continues to run for the specified time. 124*4882a593Smuzhiyun echo 0 > duration stores timer value to be used upon next 125*4882a593Smuzhiyun activate. Currently active timer if any, 126*4882a593Smuzhiyun continues to run for the specified time. 127*4882a593Smuzhiyun echo 1 > state stores desired transient state LED_FULL to be 128*4882a593Smuzhiyun held for the specified duration. 129*4882a593Smuzhiyun echo 0 > state stores desired transient state LED_OFF to be 130*4882a593Smuzhiyun held for the specified duration. 131*4882a593Smuzhiyun ================= =============================================== 132*4882a593Smuzhiyun 133*4882a593SmuzhiyunWhat is not supported 134*4882a593Smuzhiyun===================== 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun- Timer activation is one shot and extending and/or shortening the timer 137*4882a593Smuzhiyun is not supported. 138*4882a593Smuzhiyun 139*4882a593SmuzhiyunExamples 140*4882a593Smuzhiyun======== 141*4882a593Smuzhiyun 142*4882a593Smuzhiyunuse-case 1:: 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun echo transient > trigger 145*4882a593Smuzhiyun echo n > duration 146*4882a593Smuzhiyun echo 1 > state 147*4882a593Smuzhiyun 148*4882a593Smuzhiyunrepeat the following step as needed:: 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun echo 1 > activate - start timer = duration to run once 151*4882a593Smuzhiyun echo 1 > activate - start timer = duration to run once 152*4882a593Smuzhiyun echo none > trigger 153*4882a593Smuzhiyun 154*4882a593SmuzhiyunThis trigger is intended to be used for the following example use cases: 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun - Use of LED by user space app as activity indicator. 157*4882a593Smuzhiyun - Use of LED by user space app as a kind of watchdog indicator -- as 158*4882a593Smuzhiyun long as the app is alive, it can keep the LED illuminated, if it dies 159*4882a593Smuzhiyun the LED will be extinguished automatically. 160*4882a593Smuzhiyun - Use by any user space app that needs a transient GPIO output. 161