mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
leds: class: Add new optional brightness_hw_changed attribute
Some LEDs may have their brightness level changed autonomously (outside of kernel control) by hardware / firmware. This commit adds support for an optional brightness_hw_changed attribute to signal such changes to userspace (if a driver can detect them): What: /sys/class/leds/<led>/brightness_hw_changed Date: January 2017 KernelVersion: 4.11 Description: Last hardware set brightness level for this LED. Some LEDs may be changed autonomously by hardware/firmware. Only LEDs where this happens and the driver can detect this, will have this file. This file supports poll() to detect when the hardware changes the brightness. Reading this file will return the last brightness level set by the hardware, this may be different from the current brightness. Drivers which want to support this, simply add LED_BRIGHT_HW_CHANGED to their flags field and call led_classdev_notify_brightness_hw_changed() with the hardware set brightness when they detect a hardware / firmware triggered brightness change. Signed-off-by: Hans de Goede <[email protected]> Acked-by: Pavel Machek <[email protected]> Signed-off-by: Jacek Anaszewski <[email protected]>
This commit is contained in:
parent
cbe99c538d
commit
0cb8eb30d4
5 changed files with 132 additions and 0 deletions
|
|
@ -65,6 +65,21 @@ LED subsystem core exposes following API for setting brightness:
|
|||
blinking, returns -EBUSY if software blink fallback is enabled.
|
||||
|
||||
|
||||
LED registration API
|
||||
====================
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Hardware accelerated blink of LEDs
|
||||
==================================
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue