Home » Linux Kernel » Linux Device Drivers » LED Driver » Understanding Linux LED Sysfs Class architecture

Understanding Linux LED Sysfs Class architecture

The LED class just allows control of LEDs from userspace. LEDs appear in /sys/class/leds/.

  • The maximum brightness of the LED is defined in max_brightness file.
  • The brightness file will set the brightness of the LED (taking a value 0 to max_brightness).

In this post which is very early description of LED class, we will try to understand the LED’s details available on laptop.

First check the available files in leds class in sysfs as,

$ ls /sys/class/leds/

dell::kbd_backlight  input4::capslock  input4::numlock  input4::scrolllock  mmc0::

If we check more details about those files, we can see all of those are some hyperlinks as below,

$ ls -l /sys/class/leds/

dell::kbd_backlight -> ../../devices/platform/dell-laptop/leds/dell::kbd_backlight
input4::capslock -> ../../devices/platform/i8042/serio0/input/input4/input4::capslock
input4::numlock -> ../../devices/platform/i8042/serio0/input/input4/input4::numlock
input4::scrolllock -> ../../devices/platform/i8042/serio0/input/input4/input4::scrolllock
mmc0:: -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/rtsx_usb_sdmmc.1.auto/leds/mmc0::

We will check the available files for “CapLock” key LED here. As we can see above the capslock LED is associated with input device “/sys/devices/platform/i8042/serio0/input/input4” which is nothing but a input driver for keyboard.

Now, we will check more about CapsLock LED,

$ ls /sys/class/leds/input4\:\:capslock
brightness  device  max_brightness  power  subsystem  trigger  uevent

this files can also be access from “/sys/devices/platform/i8042/serio0/input/input4/input4/input4::capslock”

$ cat brightness 
0
$ cat max_brightness 
1

from above, the value of “brightness” which is 0 indicates currently the CapsLock is turned OFF. Now, if we manually turn the CapsLock ON, we can again check the value of brightness as,

$ cat /sys/class/leds/input4\:\:capslock/brightness
1

As, we can see value changed to 1 and we can see the LED of CapsLock Turned ON.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment