leds-class.txt 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. LED handling under Linux
  2. ========================
  3. If you're reading this and thinking about keyboard leds, these are
  4. handled by the input subsystem and the led class is *not* needed.
  5. In its simplest form, the LED class just allows control of LEDs from
  6. userspace. LEDs appear in /sys/class/leds/. The brightness file will
  7. set the brightness of the LED (taking a value 0-255). Most LEDs don't
  8. have hardware brightness support so will just be turned on for non-zero
  9. brightness settings.
  10. The class also introduces the optional concept of an LED trigger. A trigger
  11. is a kernel based source of led events. Triggers can either be simple or
  12. complex. A simple trigger isn't configurable and is designed to slot into
  13. existing subsystems with minimal additional code. Examples are the ide-disk,
  14. nand-disk and sharpsl-charge triggers. With led triggers disabled, the code
  15. optimises away.
  16. Complex triggers whilst available to all LEDs have LED specific
  17. parameters and work on a per LED basis. The timer trigger is an example.
  18. You can change triggers in a similar manner to the way an IO scheduler
  19. is chosen (via /sys/class/leds/<device>/trigger). Trigger specific
  20. parameters can appear in /sys/class/leds/<device> once a given trigger is
  21. selected.
  22. Design Philosophy
  23. =================
  24. The underlying design philosophy is simplicity. LEDs are simple devices
  25. and the aim is to keep a small amount of code giving as much functionality
  26. as possible. Please keep this in mind when suggesting enhancements.
  27. LED Device Naming
  28. =================
  29. Is currently of the form:
  30. "devicename:colour:function"
  31. There have been calls for LED properties such as colour to be exported as
  32. individual led class attributes. As a solution which doesn't incur as much
  33. overhead, I suggest these become part of the device name. The naming scheme
  34. above leaves scope for further attributes should they be needed. If sections
  35. of the name don't apply, just leave that section blank.
  36. Hardware accelerated blink of LEDs
  37. ==================================
  38. Some LEDs can be programmed to blink without any CPU interaction. To
  39. support this feature, a LED driver can optionally implement the
  40. blink_set() function (see <linux/leds.h>). If implemeted, triggers can
  41. attempt to use it before falling back to software timers. The blink_set()
  42. function should return 0 if the blink setting is supported, or -EINVAL
  43. otherwise, which means that LED blinking will be handled by software.
  44. The blink_set() function should choose a user friendly blinking
  45. value if it is called with *delay_on==0 && *delay_off==0 parameters. In
  46. this case the driver should give back the chosen value through delay_on
  47. and delay_off parameters to the leds subsystem.
  48. Any call to the brightness_set() callback function should cancel the
  49. previously programmed hardware blinking function so setting the brightness
  50. to 0 can also cancel the blinking of the LED.
  51. Known Issues
  52. ============
  53. The LED Trigger core cannot be a module as the simple trigger functions
  54. would cause nightmare dependency issues. I see this as a minor issue
  55. compared to the benefits the simple trigger functionality brings. The
  56. rest of the LED subsystem can be modular.
  57. Future Development
  58. ==================
  59. At the moment, a trigger can't be created specifically for a single LED.
  60. There are a number of cases where a trigger might only be mappable to a
  61. particular LED (ACPI?). The addition of triggers provided by the LED driver
  62. should cover this option and be possible to add without breaking the
  63. current interface.