Ssphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget#/translations/zh_CN/leds/leds-classmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/zh_TW/leds/leds-classmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/it_IT/leds/leds-classmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/ja_JP/leds/leds-classmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/ko_KR/leds/leds-classmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget#/translations/sp_SP/leds/leds-classmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hLED handling under Linuxh]hLED handling under Linux}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh=/var/lib/git/docbuild/linux/Documentation/leds/leds-class.rsthKubh paragraph)}(hX|In its simplest form, 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-max_brightness). Most LEDs don't have hardware brightness support so will just be turned on for non-zero brightness settings.h]hX~In its simplest form, 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-max_brightness). Most LEDs don’t have hardware brightness support so will just be turned on for non-zero brightness settings.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXThe class also introduces the optional concept of an LED trigger. A trigger is a kernel based source of led events. Triggers can either be simple or complex. A simple trigger isn't configurable and is designed to slot into existing subsystems with minimal additional code. Examples are the disk-activity, nand-disk and sharpsl-charge triggers. With led triggers disabled, the code optimises away.h]hXThe class also introduces the optional concept of an LED trigger. A trigger is a kernel based source of led events. Triggers can either be simple or complex. A simple trigger isn’t configurable and is designed to slot into existing subsystems with minimal additional code. Examples are the disk-activity, nand-disk and sharpsl-charge triggers. With led triggers disabled, the code optimises away.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hX Complex triggers while available to all LEDs have LED specific parameters and work on a per LED basis. The timer trigger is an example. The timer trigger will periodically change the LED brightness between LED_OFF and the current brightness setting. The "on" and "off" time can be specified via /sys/class/leds//delay_{on,off} in milliseconds. You can change the brightness value of a LED independently of the timer trigger. However, if you set the brightness value to LED_OFF it will also disable the timer trigger.h]hXComplex triggers while available to all LEDs have LED specific parameters and work on a per LED basis. The timer trigger is an example. The timer trigger will periodically change the LED brightness between LED_OFF and the current brightness setting. The “on” and “off” time can be specified via /sys/class/leds//delay_{on,off} in milliseconds. You can change the brightness value of a LED independently of the timer trigger. However, if you set the brightness value to LED_OFF it will also disable the timer trigger.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hYou can change triggers in a similar manner to the way an IO scheduler is chosen (via /sys/class/leds//trigger). Trigger specific parameters can appear in /sys/class/leds/ once a given trigger is selected.h]hYou can change triggers in a similar manner to the way an IO scheduler is chosen (via /sys/class/leds//trigger). Trigger specific parameters can appear in /sys/class/leds/ once a given trigger is selected.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hDesign Philosophyh]hDesign Philosophy}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK"ubh)}(hThe underlying design philosophy is simplicity. LEDs are simple devices and the aim is to keep a small amount of code giving as much functionality as possible. Please keep this in mind when suggesting enhancements.h]hThe underlying design philosophy is simplicity. LEDs are simple devices and the aim is to keep a small amount of code giving as much functionality as possible. Please keep this in mind when suggesting enhancements.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hhhhubeh}(h]design-philosophyah ]h"]design philosophyah$]h&]uh1hhhhhhhhK"ubh)}(hhh](h)}(hLED Device Namingh]hLED Device Naming}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK*ubh)}(hIs currently of the form:h]hIs currently of the form:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK,hjhhubh block_quote)}(h"devicename:color:function" h]h)}(h"devicename:color:function"h]h“devicename:color:function”}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hj9ubah}(h]h ]h"]h$]h&]uh1j7hhhK.hjhhubh bullet_list)}(hhh](h list_item)}(hXdevicename: it should refer to a unique identifier created by the kernel, like e.g. phyN for network devices or inputN for input devices, rather than to the hardware; the information related to the product and the bus to which given device is hooked is available in sysfs and can be retrieved using get_led_device_info.sh script from tools/leds; generally this section is expected mostly for LEDs that are somehow associated with other devices. h]hdefinition_list)}(hhh]hdefinition_list_item)}(hXdevicename: it should refer to a unique identifier created by the kernel, like e.g. phyN for network devices or inputN for input devices, rather than to the hardware; the information related to the product and the bus to which given device is hooked is available in sysfs and can be retrieved using get_led_device_info.sh script from tools/leds; generally this section is expected mostly for LEDs that are somehow associated with other devices. h](hterm)}(h devicename:h]h devicename:}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhK7hjcubh definition)}(hhh]h)}(hXit should refer to a unique identifier created by the kernel, like e.g. phyN for network devices or inputN for input devices, rather than to the hardware; the information related to the product and the bus to which given device is hooked is available in sysfs and can be retrieved using get_led_device_info.sh script from tools/leds; generally this section is expected mostly for LEDs that are somehow associated with other devices.h]hXit should refer to a unique identifier created by the kernel, like e.g. phyN for network devices or inputN for input devices, rather than to the hardware; the information related to the product and the bus to which given device is hooked is available in sysfs and can be retrieved using get_led_device_info.sh script from tools/leds; generally this section is expected mostly for LEDs that are somehow associated with other devices.}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hjyubah}(h]h ]h"]h$]h&]uh1jwhjcubeh}(h]h ]h"]h$]h&]uh1jahhhK7hj^ubah}(h]h ]h"]h$]h&]uh1j\hjXubah}(h]h ]h"]h$]h&]uh1jVhjShhhNhNubjW)}(hhcolor: one of LED_COLOR_ID_* definitions from the header include/dt-bindings/leds/common.h. h]j])}(hhh]jb)}(h\color: one of LED_COLOR_ID_* definitions from the header include/dt-bindings/leds/common.h. h](jh)}(hcolor:h]hcolor:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhK;hjubjx)}(hhh]h)}(hTone of LED_COLOR_ID_* definitions from the header include/dt-bindings/leds/common.h.h]hTone of LED_COLOR_ID_* definitions from the header include/dt-bindings/leds/common.h.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK:hjubah}(h]h ]h"]h$]h&]uh1jwhjubeh}(h]h ]h"]h$]h&]uh1jahhhK;hjubah}(h]h ]h"]h$]h&]uh1j\hjubah}(h]h ]h"]h$]h&]uh1jVhjShhhNhNubjW)}(hkfunction: one of LED_FUNCTION_* definitions from the header include/dt-bindings/leds/common.h. h]j])}(hhh]jb)}(h_function: one of LED_FUNCTION_* definitions from the header include/dt-bindings/leds/common.h. h](jh)}(h function:h]h function:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhK?hjubjx)}(hhh]h)}(hTone of LED_FUNCTION_* definitions from the header include/dt-bindings/leds/common.h.h]hTone of LED_FUNCTION_* definitions from the header include/dt-bindings/leds/common.h.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hjubah}(h]h ]h"]h$]h&]uh1jwhjubeh}(h]h ]h"]h$]h&]uh1jahhhK?hjubah}(h]h ]h"]h$]h&]uh1j\hjubah}(h]h ]h"]h$]h&]uh1jVhjShhhNhNubeh}(h]h ]h"]h$]h&]bullet-uh1jQhhhK0hjhhubh)}(h^If required color or function is missing, please submit a patch to linux-leds@vger.kernel.org.h](hCIf required color or function is missing, please submit a patch to }(hj.hhhNhNubh reference)}(hlinux-leds@vger.kernel.orgh]hlinux-leds@vger.kernel.org}(hj8hhhNhNubah}(h]h ]h"]h$]h&]refuri!mailto:linux-leds@vger.kernel.orguh1j6hj.ubh.}(hj.hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKAhjhhubh)}(hXIt is possible that more than one LED with the same color and function will be required for given platform, differing only with an ordinal number. In this case it is preferable to just concatenate the predefined LED_FUNCTION_* name with required "-N" suffix in the driver. fwnode based drivers can use function-enumerator property for that and then the concatenation will be handled automatically by the LED core upon LED class device registration.h]hXIt is possible that more than one LED with the same color and function will be required for given platform, differing only with an ordinal number. In this case it is preferable to just concatenate the predefined LED_FUNCTION_* name with required “-N” suffix in the driver. fwnode based drivers can use function-enumerator property for that and then the concatenation will be handled automatically by the LED core upon LED class device registration.}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjhhubh)}(hX)LED subsystem has also a protection against name clash, that may occur when LED class device is created by a driver of hot-pluggable device and it doesn't provide unique devicename section. In this case numerical suffix (e.g. "_1", "_2", "_3" etc.) is added to the requested LED class device name.h]hX7LED subsystem has also a protection against name clash, that may occur when LED class device is created by a driver of hot-pluggable device and it doesn’t provide unique devicename section. In this case numerical suffix (e.g. “_1”, “_2”, “_3” etc.) is added to the requested LED class device name.}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjhhubh)}(hXThere might be still LED class drivers around using vendor or product name for devicename, but this approach is now deprecated as it doesn't convey any added value. Product information can be found in other places in sysfs (see tools/leds/get_led_device_info.sh).h]hX There might be still LED class drivers around using vendor or product name for devicename, but this approach is now deprecated as it doesn’t convey any added value. Product information can be found in other places in sysfs (see tools/leds/get_led_device_info.sh).}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjhhubh)}(hExamples of proper LED names:h]hExamples of proper LED names:}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhjhhubj8)}(h- "red:disk" - "white:flash" - "red:indicator" - "phy1:green:wlan" - "phy3::wlan" - ":kbd_backlight" - "input5::kbd_backlight" - "input3::numlock" - "input3::scrolllock" - "input3::capslock" - "mmc1::status" - "white:status" h]jR)}(hhh](jW)}(h "red:disk"h]h)}(hjh]h“red:disk”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h "white:flash"h]h)}(hjh]h“white:flash”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"red:indicator"h]h)}(hjh]h“red:indicator”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"phy1:green:wlan"h]h)}(hjh]h“phy1:green:wlan”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h "phy3::wlan"h]h)}(hjh]h“phy3::wlan”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h":kbd_backlight"h]h)}(hjh]h“:kbd_backlight”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"input5::kbd_backlight"h]h)}(hjh]h“input5::kbd_backlight”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK^hjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"input3::numlock"h]h)}(hj4h]h“input3::numlock”}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hj2ubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"input3::scrolllock"h]h)}(hjKh]h“input3::scrolllock”}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hjIubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"input3::capslock"h]h)}(hjbh]h“input3::capslock”}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahj`ubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"mmc1::status"h]h)}(hjyh]h“mmc1::status”}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjwubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h"white:status" h]h)}(h"white:status"h]h“white:status”}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]j,j-uh1jQhhhKXhjubah}(h]h ]h"]h$]h&]uh1j7hhhKXhjhhubh)}(hXdget_led_device_info.sh script can be used for verifying if the LED name meets the requirements pointed out here. It performs validation of the LED class devicename sections and gives hints on expected value for a section in case the validation fails for it. So far the script supports validation of associations between LEDs and following types of devices:h]hXdget_led_device_info.sh script can be used for verifying if the LED name meets the requirements pointed out here. It performs validation of the LED class devicename sections and gives hints on expected value for a section in case the validation fails for it. So far the script supports validation of associations between LEDs and following types of devices:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjhhubj8)}(h2- input devices - ieee80211 compliant USB devices h]jR)}(hhh](jW)}(h input devicesh]h)}(hjh]h input devices}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjubah}(h]h ]h"]h$]h&]uh1jVhjubjW)}(h ieee80211 compliant USB devices h]h)}(hieee80211 compliant USB devicesh]hieee80211 compliant USB devices}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKlhjubah}(h]h ]h"]h$]h&]uh1jVhjubeh}(h]h ]h"]h$]h&]j,j-uh1jQhhhKkhjubah}(h]h ]h"]h$]h&]uh1j7hhhKkhjhhubh)}(h!The script is open to extensions.h]h!The script is open to extensions.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjhhubh)}(hXdThere have been calls for LED properties such as color to be exported as individual led class attributes. As a solution which doesn't incur as much overhead, I suggest these become part of the device name. The naming scheme above leaves scope for further attributes should they be needed. If sections of the name don't apply, just leave that section blank.h]hXhThere have been calls for LED properties such as color to be exported as individual led class attributes. As a solution which doesn’t incur as much overhead, I suggest these become part of the device name. The naming scheme above leaves scope for further attributes should they be needed. If sections of the name don’t apply, just leave that section blank.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjhhubeh}(h]led-device-namingah ]h"]led device namingah$]h&]uh1hhhhhhhhK*ubh)}(hhh](h)}(hBrightness setting APIh]hBrightness setting API}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj&hhhhhKxubh)}(h@LED subsystem core exposes following API for setting brightness:h]h@LED subsystem core exposes following API for setting brightness:}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhj&hhubj8)}(hX- led_set_brightness: it is guaranteed not to sleep, passing LED_OFF stops blinking, - led_set_brightness_sync: for use cases when immediate effect is desired - it can block the caller for the time required for accessing device registers and can sleep, passing LED_OFF stops hardware blinking, returns -EBUSY if software blink fallback is enabled. h]jR)}(hhh](jW)}(hgled_set_brightness: it is guaranteed not to sleep, passing LED_OFF stops blinking, h]j])}(hhh]jb)}(hSled_set_brightness: it is guaranteed not to sleep, passing LED_OFF stops blinking, h](jh)}(hled_set_brightness:h]hled_set_brightness:}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhK~hjSubjx)}(hhh]h)}(h>it is guaranteed not to sleep, passing LED_OFF stops blinking,h]h>it is guaranteed not to sleep, passing LED_OFF stops blinking,}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK}hjeubah}(h]h ]h"]h$]h&]uh1jwhjSubeh}(h]h ]h"]h$]h&]uh1jahhhK~hjPubah}(h]h ]h"]h$]h&]uh1j\hjLubah}(h]h ]h"]h$]h&]uh1jVhjIubjW)}(hX.led_set_brightness_sync: for use cases when immediate effect is desired - it can block the caller for the time required for accessing device registers and can sleep, passing LED_OFF stops hardware blinking, returns -EBUSY if software blink fallback is enabled. h]j])}(hhh]jb)}(hXled_set_brightness_sync: for use cases when immediate effect is desired - it can block the caller for the time required for accessing device registers and can sleep, passing LED_OFF stops hardware blinking, returns -EBUSY if software blink fallback is enabled. h](jh)}(hled_set_brightness_sync:h]hled_set_brightness_sync:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhKhjubjx)}(hhh]h)}(hfor use cases when immediate effect is desired - it can block the caller for the time required for accessing device registers and can sleep, passing LED_OFF stops hardware blinking, returns -EBUSY if software blink fallback is enabled.h]hfor use cases when immediate effect is desired - it can block the caller for the time required for accessing device registers and can sleep, passing LED_OFF stops hardware blinking, returns -EBUSY if software blink fallback is enabled.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jwhjubeh}(h]h ]h"]h$]h&]uh1jahhhKhjubah}(h]h ]h"]h$]h&]uh1j\hjubah}(h]h ]h"]h$]h&]uh1jVhjIubeh}(h]h ]h"]h$]h&]j,j-uh1jQhhhK|hjEubah}(h]h ]h"]h$]h&]uh1j7hhhK|hj&hhubeh}(h]brightness-setting-apiah ]h"]brightness setting apiah$]h&]uh1hhhhhhhhKxubh)}(hhh](h)}(hLED registration APIh]hLED registration API}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hX>A driver wanting to register a LED classdev for use by other drivers / userspace needs to allocate and fill a led_classdev struct and then call `[devm_]led_classdev_register`. If the non devm version is used the driver must call led_classdev_unregister from its remove function before free-ing the led_classdev struct.h](hA driver wanting to register a LED classdev for use by other drivers / userspace needs to allocate and fill a led_classdev struct and then call }(hjhhhNhNubhtitle_reference)}(h`[devm_]led_classdev_register`h]h[devm_]led_classdev_register}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh. If the non devm version is used the driver must call led_classdev_unregister from its remove function before free-ing the led_classdev struct.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX\If the driver can detect hardware initiated brightness changes and thus wants to have a brightness_hw_changed attribute then the LED_BRIGHT_HW_CHANGED flag must be set in flags before registering. Calling led_classdev_notify_brightness_hw_changed on a classdev not registered with the LED_BRIGHT_HW_CHANGED flag is a bug and will trigger a WARN_ON.h]hX\If the driver can detect hardware initiated brightness changes and thus wants to have a brightness_hw_changed attribute then the LED_BRIGHT_HW_CHANGED flag must be set in flags before registering. Calling led_classdev_notify_brightness_hw_changed on a classdev not registered with the LED_BRIGHT_HW_CHANGED flag is a bug and will trigger a WARN_ON.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]led-registration-apiah ]h"]led registration apiah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h"Hardware accelerated blink of LEDsh]h"Hardware accelerated blink of LEDs}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj-hhhhhKubh)}(hXHSome LEDs can be programmed to blink without any CPU interaction. To support this feature, a LED driver can optionally implement the blink_set() function (see ). To set an LED to blinking, however, it is better to use the API function led_blink_set(), as it will check and implement software fallback if necessary.h]hXHSome LEDs can be programmed to blink without any CPU interaction. To support this feature, a LED driver can optionally implement the blink_set() function (see ). To set an LED to blinking, however, it is better to use the API function led_blink_set(), as it will check and implement software fallback if necessary.}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj-hhubh)}(hTo turn off blinking, use the API function led_brightness_set() with brightness value LED_OFF, which should stop any software timers that may have been required for blinking.h]hTo turn off blinking, use the API function led_brightness_set() with brightness value LED_OFF, which should stop any software timers that may have been required for blinking.}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj-hhubh)}(hXThe blink_set() function should choose a user friendly blinking value if it is called with `*delay_on==0` && `*delay_off==0` parameters. In this case the driver should give back the chosen value through delay_on and delay_off parameters to the leds subsystem.h](h[The blink_set() function should choose a user friendly blinking value if it is called with }(hjZhhhNhNubj)}(h`*delay_on==0`h]h *delay_on==0}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjZubh && }(hjZhhhNhNubj)}(h`*delay_off==0`h]h *delay_off==0}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1jhjZubh parameters. In this case the driver should give back the chosen value through delay_on and delay_off parameters to the leds subsystem.}(hjZhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj-hhubh)}(hSetting the brightness to zero with brightness_set() callback function should completely turn off the LED and cancel the previously programmed hardware blinking function, if any.h]hSetting the brightness to zero with brightness_set() callback function should completely turn off the LED and cancel the previously programmed hardware blinking function, if any.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj-hhubeh}(h]"hardware-accelerated-blink-of-ledsah ]h"]"hardware accelerated blink of ledsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hHardware driven LEDsh]hHardware driven LEDs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXSome LEDs can be programmed to be driven by hardware. This is not limited to blink but also to turn off or on autonomously. To support this feature, a LED needs to implement various additional ops and needs to declare specific support for the supported triggers.h]hXSome LEDs can be programmed to be driven by hardware. This is not limited to blink but also to turn off or on autonomously. To support this feature, a LED needs to implement various additional ops and needs to declare specific support for the supported triggers.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h7With hw control we refer to the LED driven by hardware.h]h7With hw control we refer to the LED driven by hardware.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hALED driver must define the following value to support hw control:h]hALED driver must define the following value to support hw control:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj8)}(hi- hw_control_trigger: unique trigger name supported by the LED in hw control mode. h]jR)}(hhh]jW)}(hchw_control_trigger: unique trigger name supported by the LED in hw control mode. h]j])}(hhh]jb)}(hQhw_control_trigger: unique trigger name supported by the LED in hw control mode. h](jh)}(hhw_control_trigger:h]hhw_control_trigger:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhKhjubjx)}(hhh]h)}(hhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhKhj:ubjx)}(hhh](h)}(hget active modes from a LED already in hw control, parse them and set in flags the current active flags for the supported trigger.h]hget active modes from a LED already in hw control, parse them and set in flags the current active flags for the supported trigger.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjLubh)}(hReturn 0 on success, a negative error number on failing parsing the initial mode. Error from this function is NOT FATAL as the device may be in a not supported initial state by the attached LED trigger.h]hReturn 0 on success, a negative error number on failing parsing the initial mode. Error from this function is NOT FATAL as the device may be in a not supported initial state by the attached LED trigger.}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjLubeh}(h]h ]h"]h$]h&]uh1jwhj:ubeh}(h]h ]h"]h$]h&]uh1jahhhKhj7ubah}(h]h ]h"]h$]h&]uh1j\hj3ubah}(h]h ]h"]h$]h&]uh1jVhj0ubjW)}(hX=hw_control_get_device: return the device associated with the LED driver in hw control. A trigger might use this to match the returned device from this function with a configured device for the trigger as the source for blinking events and correctly enable hw control. (example a netdev trigger configured to blink for a particular dev match the returned dev from get_device to set hw control) Returns a pointer to a struct device or NULL if nothing is currently attached. h]j])}(hhh]jb)}(hXhw_control_get_device: return the device associated with the LED driver in hw control. A trigger might use this to match the returned device from this function with a configured device for the trigger as the source for blinking events and correctly enable hw control. (example a netdev trigger configured to blink for a particular dev match the returned dev from get_device to set hw control) Returns a pointer to a struct device or NULL if nothing is currently attached. h](jh)}(hhw_control_get_device:h]hhw_control_get_device:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jghhhKhjubjx)}(hhh](h)}(hXqreturn the device associated with the LED driver in hw control. A trigger might use this to match the returned device from this function with a configured device for the trigger as the source for blinking events and correctly enable hw control. (example a netdev trigger configured to blink for a particular dev match the returned dev from get_device to set hw control)h]hXqreturn the device associated with the LED driver in hw control. A trigger might use this to match the returned device from this function with a configured device for the trigger as the source for blinking events and correctly enable hw control. (example a netdev trigger configured to blink for a particular dev match the returned dev from get_device to set hw control)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hNReturns a pointer to a struct device or NULL if nothing is currently attached.h]hNReturns a pointer to a struct device or NULL if nothing is currently attached.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jwhjubeh}(h]h ]h"]h$]h&]uh1jahhhKhjubah}(h]h ]h"]h$]h&]uh1j\hjubah}(h]h ]h"]h$]h&]uh1jVhj0ubeh}(h]h ]h"]h$]h&]j,j-uh1jQhhhKhjGubeh}(h]h ]h"]h$]h&]uh1jwhj5ubeh}(h]h ]h"]h$]h&]uh1jahhhKhj2ubah}(h]h ]h"]h$]h&]uh1j\hjhhhNhNubh)}(hXLED driver can activate additional modes by default to workaround the impossibility of supporting each different mode on the supported trigger. Examples are hardcoding the blink speed to a set interval, enable special feature like bypassing blink if some requirements are not met.h]hXLED driver can activate additional modes by default to workaround the impossibility of supporting each different mode on the supported trigger. Examples are hardcoding the blink speed to a set interval, enable special feature like bypassing blink if some requirements are not met.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXA trigger should first check if the hw control API are supported by the LED driver and check if the trigger is supported to verify if hw control is possible, use hw_control_is_supported to check if the flags are supported and only at the end use hw_control_set to activate hw control.h]hXA trigger should first check if the hw control API are supported by the LED driver and check if the trigger is supported to verify if hw control is possible, use hw_control_is_supported to check if the flags are supported and only at the end use hw_control_set to activate hw control.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(haA trigger can use hw_control_get to check if a LED is already in hw control and init their flags.h]haA trigger can use hw_control_get to check if a LED is already in hw control and init their flags.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hnWhen the LED is in hw control, no software blink is possible and doing so will effectively disable hw control.h]hnWhen the LED is in hw control, no software blink is possible and doing so will effectively disable hw control.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]hardware-driven-ledsah ]h"]hardware driven ledsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Known Issuesh]h Known Issues}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj+hhhhhKubh)}(hThe LED Trigger core cannot be a module as the simple trigger functions would cause nightmare dependency issues. I see this as a minor issue compared to the benefits the simple trigger functionality brings. The rest of the LED subsystem can be modular.h]hThe LED Trigger core cannot be a module as the simple trigger functions would cause nightmare dependency issues. I see this as a minor issue compared to the benefits the simple trigger functionality brings. The rest of the LED subsystem can be modular.}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj+hhubeh}(h] known-issuesah ]h"] known issuesah$]h&]uh1hhhhhhhhKubeh}(h]led-handling-under-linuxah ]h"]led handling under linuxah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj}error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jWjTjjj#j jjj*j'jjj(j%jOjLu nametypes}(jWjj#jj*jj(jOuh}(jThjhj jjj&j'jjj-j%jjLj+u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.