xref: /OK3568_Linux_fs/kernel/Documentation/devicetree/bindings/leds/leds-trigger-pattern.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun* Pattern format for LED pattern trigger
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunThe pattern is given by a series of tuples, of brightness and duration (ms).
4*4882a593SmuzhiyunThe LED is expected to traverse the series and each brightness value for the
5*4882a593Smuzhiyunspecified duration. Duration of 0 means brightness should immediately change to
6*4882a593Smuzhiyunnew value, and writing malformed pattern deactivates any active one.
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun1. For gradual dimming, the dimming interval now is set as 50 milliseconds. So
9*4882a593Smuzhiyunthe tuple with duration less than dimming interval (50ms) is treated as a step
10*4882a593Smuzhiyunchange of brightness, i.e. the subsequent brightness will be applied without
11*4882a593Smuzhiyunadding intervening dimming intervals.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunThe gradual dimming format of the software pattern values should be:
14*4882a593Smuzhiyun"brightness_1 duration_1 brightness_2 duration_2 brightness_3 duration_3 ...".
15*4882a593SmuzhiyunFor example (using sysfs interface):
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunecho 0 1000 255 2000 > pattern
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunIt will make the LED go gradually from zero-intensity to max (255) intensity in
20*4882a593Smuzhiyun1000 milliseconds, then back to zero intensity in 2000 milliseconds:
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunLED brightness
23*4882a593Smuzhiyun    ^
24*4882a593Smuzhiyun255-|       / \            / \            /
25*4882a593Smuzhiyun    |      /    \         /    \         /
26*4882a593Smuzhiyun    |     /       \      /       \      /
27*4882a593Smuzhiyun    |    /          \   /          \   /
28*4882a593Smuzhiyun  0-|   /             \/             \/
29*4882a593Smuzhiyun    +---0----1----2----3----4----5----6------------> time (s)
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun2. To make the LED go instantly from one brightness value to another, we should
32*4882a593Smuzhiyunuse zero-time lengths (the brightness must be same as the previous tuple's). So
33*4882a593Smuzhiyunthe format should be: "brightness_1 duration_1 brightness_1 0 brightness_2
34*4882a593Smuzhiyunduration_2 brightness_2 0 ...".
35*4882a593SmuzhiyunFor example (using sysfs interface):
36*4882a593Smuzhiyun
37*4882a593Smuzhiyunecho 0 1000 0 0 255 2000 255 0 > pattern
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunIt will make the LED stay off for one second, then stay at max brightness for
40*4882a593Smuzhiyuntwo seconds:
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunLED brightness
43*4882a593Smuzhiyun    ^
44*4882a593Smuzhiyun255-|        +---------+    +---------+
45*4882a593Smuzhiyun    |        |         |    |         |
46*4882a593Smuzhiyun    |        |         |    |         |
47*4882a593Smuzhiyun    |        |         |    |         |
48*4882a593Smuzhiyun  0-|   -----+         +----+         +----
49*4882a593Smuzhiyun    +---0----1----2----3----4----5----6------------> time (s)
50