mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-22 23:04:43 +00: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 <hdegoede@redhat.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
This commit is contained in:
parent
cbe99c538d
commit
0cb8eb30d4
5 changed files with 132 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
|||
#define __LINUX_LEDS_H_INCLUDED
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/kernfs.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/rwsem.h>
|
||||
|
@ -47,6 +48,7 @@ struct led_classdev {
|
|||
#define LED_DEV_CAP_FLASH (1 << 18)
|
||||
#define LED_HW_PLUGGABLE (1 << 19)
|
||||
#define LED_PANIC_INDICATOR (1 << 20)
|
||||
#define LED_BRIGHT_HW_CHANGED (1 << 21)
|
||||
|
||||
/* set_brightness_work / blink_timer flags, atomic, private. */
|
||||
unsigned long work_flags;
|
||||
|
@ -111,6 +113,11 @@ struct led_classdev {
|
|||
bool activated;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED
|
||||
int brightness_hw_changed;
|
||||
struct kernfs_node *brightness_hw_changed_kn;
|
||||
#endif
|
||||
|
||||
/* Ensures consistent access to the LED Flash Class device */
|
||||
struct mutex led_access;
|
||||
};
|
||||
|
@ -423,4 +430,12 @@ static inline void ledtrig_cpu(enum cpu_led_event evt)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED
|
||||
extern void led_classdev_notify_brightness_hw_changed(
|
||||
struct led_classdev *led_cdev, enum led_brightness brightness);
|
||||
#else
|
||||
static inline void led_classdev_notify_brightness_hw_changed(
|
||||
struct led_classdev *led_cdev, enum led_brightness brightness) { }
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_LEDS_H_INCLUDED */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue