18dab9197SMauro Carvalho Chehab===================== 28dab9197SMauro Carvalho ChehabLED Transient Trigger 38dab9197SMauro Carvalho Chehab===================== 48dab9197SMauro Carvalho Chehab 58dab9197SMauro Carvalho ChehabThe leds timer trigger does not currently have an interface to activate 68dab9197SMauro Carvalho Chehaba one shot timer. The current support allows for setting two timers, one for 78dab9197SMauro Carvalho Chehabspecifying how long a state to be on, and the second for how long the state 88dab9197SMauro Carvalho Chehabto be off. The delay_on value specifies the time period an LED should stay 98dab9197SMauro Carvalho Chehabin on state, followed by a delay_off value that specifies how long the LED 108dab9197SMauro Carvalho Chehabshould stay in off state. The on and off cycle repeats until the trigger 118dab9197SMauro Carvalho Chehabgets deactivated. There is no provision for one time activation to implement 128dab9197SMauro Carvalho Chehabfeatures that require an on or off state to be held just once and then stay in 138dab9197SMauro Carvalho Chehabthe original state forever. 148dab9197SMauro Carvalho Chehab 158dab9197SMauro Carvalho ChehabWithout one shot timer interface, user space can still use timer trigger to 168dab9197SMauro Carvalho Chehabset a timer to hold a state, however when user space application crashes or 178dab9197SMauro Carvalho Chehabgoes away without deactivating the timer, the hardware will be left in that 188dab9197SMauro Carvalho Chehabstate permanently. 198dab9197SMauro Carvalho Chehab 208dab9197SMauro Carvalho ChehabTransient trigger addresses the need for one shot timer activation. The 218dab9197SMauro Carvalho Chehabtransient trigger can be enabled and disabled just like the other leds 228dab9197SMauro Carvalho Chehabtriggers. 238dab9197SMauro Carvalho Chehab 248dab9197SMauro Carvalho ChehabWhen an led class device driver registers itself, it can specify all leds 258dab9197SMauro Carvalho Chehabtriggers it supports and a default trigger. During registration, activation 268dab9197SMauro Carvalho Chehabroutine for the default trigger gets called. During registration of an led 278dab9197SMauro Carvalho Chehabclass device, the LED state does not change. 288dab9197SMauro Carvalho Chehab 298dab9197SMauro Carvalho ChehabWhen the driver unregisters, deactivation routine for the currently active 308dab9197SMauro Carvalho Chehabtrigger will be called, and LED state is changed to LED_OFF. 318dab9197SMauro Carvalho Chehab 328dab9197SMauro Carvalho ChehabDriver suspend changes the LED state to LED_OFF and resume doesn't change 338dab9197SMauro Carvalho Chehabthe state. Please note that there is no explicit interaction between the 348dab9197SMauro Carvalho Chehabsuspend and resume actions and the currently enabled trigger. LED state 358dab9197SMauro Carvalho Chehabchanges are suspended while the driver is in suspend state. Any timers 368dab9197SMauro Carvalho Chehabthat are active at the time driver gets suspended, continue to run, without 378dab9197SMauro Carvalho Chehabbeing able to actually change the LED state. Once driver is resumed, triggers 388dab9197SMauro Carvalho Chehabstart functioning again. 398dab9197SMauro Carvalho Chehab 408dab9197SMauro Carvalho ChehabLED state changes are controlled using brightness which is a common led 418dab9197SMauro Carvalho Chehabclass device property. When brightness is set to 0 from user space via 428dab9197SMauro Carvalho Chehabecho 0 > brightness, it will result in deactivating the current trigger. 438dab9197SMauro Carvalho Chehab 448dab9197SMauro Carvalho ChehabTransient trigger uses standard register and unregister interfaces. During 458dab9197SMauro Carvalho Chehabtrigger registration, for each led class device that specifies this trigger 468dab9197SMauro Carvalho Chehabas its default trigger, trigger activation routine will get called. During 478dab9197SMauro Carvalho Chehabregistration, the LED state does not change, unless there is another trigger 488dab9197SMauro Carvalho Chehabactive, in which case LED state changes to LED_OFF. 498dab9197SMauro Carvalho Chehab 508dab9197SMauro Carvalho ChehabDuring trigger unregistration, LED state gets changed to LED_OFF. 518dab9197SMauro Carvalho Chehab 528dab9197SMauro Carvalho ChehabTransient trigger activation routine doesn't change the LED state. It 538dab9197SMauro Carvalho Chehabcreates its properties and does its initialization. Transient trigger 548dab9197SMauro Carvalho Chehabdeactivation routine, will cancel any timer that is active before it cleans 558dab9197SMauro Carvalho Chehabup and removes the properties it created. It will restore the LED state to 568dab9197SMauro Carvalho Chehabnon-transient state. When driver gets suspended, irrespective of the transient 578dab9197SMauro Carvalho Chehabstate, the LED state changes to LED_OFF. 588dab9197SMauro Carvalho Chehab 598dab9197SMauro Carvalho ChehabTransient trigger can be enabled and disabled from user space on led class 608dab9197SMauro Carvalho Chehabdevices, that support this trigger as shown below:: 618dab9197SMauro Carvalho Chehab 628dab9197SMauro Carvalho Chehab echo transient > trigger 638dab9197SMauro Carvalho Chehab echo none > trigger 648dab9197SMauro Carvalho Chehab 658dab9197SMauro Carvalho ChehabNOTE: 668dab9197SMauro Carvalho Chehab Add a new property trigger state to control the state. 678dab9197SMauro Carvalho Chehab 688dab9197SMauro Carvalho ChehabThis trigger exports three properties, activate, state, and duration. When 698dab9197SMauro Carvalho Chehabtransient trigger is activated these properties are set to default values. 708dab9197SMauro Carvalho Chehab 718dab9197SMauro Carvalho Chehab- duration allows setting timer value in msecs. The initial value is 0. 728dab9197SMauro Carvalho Chehab- activate allows activating and deactivating the timer specified by 738dab9197SMauro Carvalho Chehab duration as needed. The initial and default value is 0. This will allow 748dab9197SMauro Carvalho Chehab duration to be set after trigger activation. 758dab9197SMauro Carvalho Chehab- state allows user to specify a transient state to be held for the specified 768dab9197SMauro Carvalho Chehab duration. 778dab9197SMauro Carvalho Chehab 788dab9197SMauro Carvalho Chehab activate 798dab9197SMauro Carvalho Chehab - one shot timer activate mechanism. 808dab9197SMauro Carvalho Chehab 1 when activated, 0 when deactivated. 818dab9197SMauro Carvalho Chehab default value is zero when transient trigger is enabled, 828dab9197SMauro Carvalho Chehab to allow duration to be set. 838dab9197SMauro Carvalho Chehab 848dab9197SMauro Carvalho Chehab activate state indicates a timer with a value of specified 858dab9197SMauro Carvalho Chehab duration running. 868dab9197SMauro Carvalho Chehab deactivated state indicates that there is no active timer 878dab9197SMauro Carvalho Chehab running. 888dab9197SMauro Carvalho Chehab 898dab9197SMauro Carvalho Chehab duration 908dab9197SMauro Carvalho Chehab - one shot timer value. When activate is set, duration value 918dab9197SMauro Carvalho Chehab is used to start a timer that runs once. This value doesn't 928dab9197SMauro Carvalho Chehab get changed by the trigger unless user does a set via 938dab9197SMauro Carvalho Chehab echo new_value > duration 948dab9197SMauro Carvalho Chehab 958dab9197SMauro Carvalho Chehab state 968dab9197SMauro Carvalho Chehab - transient state to be held. It has two values 0 or 1. 0 maps 978dab9197SMauro Carvalho Chehab to LED_OFF and 1 maps to LED_FULL. The specified state is 988dab9197SMauro Carvalho Chehab held for the duration of the one shot timer and then the 998dab9197SMauro Carvalho Chehab state gets changed to the non-transient state which is the 1008dab9197SMauro Carvalho Chehab inverse of transient state. 1018dab9197SMauro Carvalho Chehab If state = LED_FULL, when the timer runs out the state will 1028dab9197SMauro Carvalho Chehab go back to LED_OFF. 1038dab9197SMauro Carvalho Chehab If state = LED_OFF, when the timer runs out the state will 1048dab9197SMauro Carvalho Chehab go back to LED_FULL. 1058dab9197SMauro Carvalho Chehab Please note that current LED state is not checked prior to 1068dab9197SMauro Carvalho Chehab changing the state to the specified state. 1078dab9197SMauro Carvalho Chehab Driver could map these values to inverted depending on the 1088dab9197SMauro Carvalho Chehab default states it defines for the LED in its brightness_set() 1098dab9197SMauro Carvalho Chehab interface which is called from the led brightness_set() 1108dab9197SMauro Carvalho Chehab interfaces to control the LED state. 1118dab9197SMauro Carvalho Chehab 1128dab9197SMauro Carvalho ChehabWhen timer expires activate goes back to deactivated state, duration is left 1138dab9197SMauro Carvalho Chehabat the set value to be used when activate is set at a future time. This will 1148dab9197SMauro Carvalho Chehaballow user app to set the time once and activate it to run it once for the 1158dab9197SMauro Carvalho Chehabspecified value as needed. When timer expires, state is restored to the 1168dab9197SMauro Carvalho Chehabnon-transient state which is the inverse of the transient state: 1178dab9197SMauro Carvalho Chehab 1188dab9197SMauro Carvalho Chehab ================= =============================================== 1198dab9197SMauro Carvalho Chehab echo 1 > activate starts timer = duration when duration is not 0. 1208dab9197SMauro Carvalho Chehab echo 0 > activate cancels currently running timer. 1218dab9197SMauro Carvalho Chehab echo n > duration stores timer value to be used upon next 1228dab9197SMauro Carvalho Chehab activate. Currently active timer if 1238dab9197SMauro Carvalho Chehab any, continues to run for the specified time. 1248dab9197SMauro Carvalho Chehab echo 0 > duration stores timer value to be used upon next 1258dab9197SMauro Carvalho Chehab activate. Currently active timer if any, 1268dab9197SMauro Carvalho Chehab continues to run for the specified time. 1278dab9197SMauro Carvalho Chehab echo 1 > state stores desired transient state LED_FULL to be 1288dab9197SMauro Carvalho Chehab held for the specified duration. 1298dab9197SMauro Carvalho Chehab echo 0 > state stores desired transient state LED_OFF to be 1308dab9197SMauro Carvalho Chehab held for the specified duration. 1318dab9197SMauro Carvalho Chehab ================= =============================================== 1328dab9197SMauro Carvalho Chehab 1338dab9197SMauro Carvalho ChehabWhat is not supported 1348dab9197SMauro Carvalho Chehab===================== 1358dab9197SMauro Carvalho Chehab 1368dab9197SMauro Carvalho Chehab- Timer activation is one shot and extending and/or shortening the timer 1378dab9197SMauro Carvalho Chehab is not supported. 1388dab9197SMauro Carvalho Chehab 1398dab9197SMauro Carvalho ChehabExamples 1408dab9197SMauro Carvalho Chehab======== 1418dab9197SMauro Carvalho Chehab 1428dab9197SMauro Carvalho Chehabuse-case 1:: 1438dab9197SMauro Carvalho Chehab 1448dab9197SMauro Carvalho Chehab echo transient > trigger 1458dab9197SMauro Carvalho Chehab echo n > duration 1468dab9197SMauro Carvalho Chehab echo 1 > state 1478dab9197SMauro Carvalho Chehab 1488dab9197SMauro Carvalho Chehabrepeat the following step as needed:: 1498dab9197SMauro Carvalho Chehab 1508dab9197SMauro Carvalho Chehab echo 1 > activate - start timer = duration to run once 1518dab9197SMauro Carvalho Chehab echo 1 > activate - start timer = duration to run once 1528dab9197SMauro Carvalho Chehab echo none > trigger 1538dab9197SMauro Carvalho Chehab 154*b7ecdb00SRandy DunlapThis trigger is intended to be used for the following example use cases: 1558dab9197SMauro Carvalho Chehab 1568dab9197SMauro Carvalho Chehab - Use of LED by user space app as activity indicator. 1578dab9197SMauro Carvalho Chehab - Use of LED by user space app as a kind of watchdog indicator -- as 1588dab9197SMauro Carvalho Chehab long as the app is alive, it can keep the LED illuminated, if it dies 1598dab9197SMauro Carvalho Chehab the LED will be extinguished automatically. 1608dab9197SMauro Carvalho Chehab - Use by any user space app that needs a transient GPIO output. 161