mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 15:02:32 +00:00
75 lines
2.9 KiB
Diff
75 lines
2.9 KiB
Diff
|
From ed554d3f945179c5b159bddfad7be34b403fe11a Mon Sep 17 00:00:00 2001
|
||
|
From: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Date: Mon, 29 May 2023 18:32:31 +0200
|
||
|
Subject: [PATCH 01/13] leds: add APIs for LEDs hw control
|
||
|
|
||
|
Add an option to permit LED driver to declare support for a specific
|
||
|
trigger to use hw control and setup the LED to blink based on specific
|
||
|
provided modes.
|
||
|
|
||
|
Add APIs for LEDs hw control. These functions will be used to activate
|
||
|
hardware control where a LED will use the provided flags, from an
|
||
|
unique defined supported trigger, to setup the LED to be driven by
|
||
|
hardware.
|
||
|
|
||
|
Add hw_control_is_supported() to ask the LED driver if the requested
|
||
|
mode by the trigger are supported and the LED can be setup to follow
|
||
|
the requested modes.
|
||
|
|
||
|
Deactivate hardware blink control by setting brightness to LED_OFF via
|
||
|
the brightness_set() callback.
|
||
|
|
||
|
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||
|
---
|
||
|
include/linux/leds.h | 37 +++++++++++++++++++++++++++++++++++++
|
||
|
1 file changed, 37 insertions(+)
|
||
|
|
||
|
--- a/include/linux/leds.h
|
||
|
+++ b/include/linux/leds.h
|
||
|
@@ -164,6 +164,43 @@ struct led_classdev {
|
||
|
|
||
|
/* LEDs that have private triggers have this set */
|
||
|
struct led_hw_trigger_type *trigger_type;
|
||
|
+
|
||
|
+ /* Unique trigger name supported by LED set in hw control mode */
|
||
|
+ const char *hw_control_trigger;
|
||
|
+ /*
|
||
|
+ * Check if the LED driver supports the requested mode provided by the
|
||
|
+ * defined supported trigger to setup the LED to hw control mode.
|
||
|
+ *
|
||
|
+ * Return 0 on success. Return -EOPNOTSUPP when the passed flags are not
|
||
|
+ * supported and software fallback needs to be used.
|
||
|
+ * Return a negative error number on any other case for check fail due
|
||
|
+ * to various reason like device not ready or timeouts.
|
||
|
+ */
|
||
|
+ int (*hw_control_is_supported)(struct led_classdev *led_cdev,
|
||
|
+ unsigned long flags);
|
||
|
+ /*
|
||
|
+ * Activate hardware control, LED driver will use the provided flags
|
||
|
+ * from the supported trigger and setup the LED to be driven by hardware
|
||
|
+ * following the requested mode from the trigger flags.
|
||
|
+ * Deactivate hardware blink control by setting brightness to LED_OFF via
|
||
|
+ * the brightness_set() callback.
|
||
|
+ *
|
||
|
+ * Return 0 on success, a negative error number on flags apply fail.
|
||
|
+ */
|
||
|
+ int (*hw_control_set)(struct led_classdev *led_cdev,
|
||
|
+ unsigned long flags);
|
||
|
+ /*
|
||
|
+ * Get from the LED driver the current mode that the LED is set in hw
|
||
|
+ * control mode and put them in flags.
|
||
|
+ * Trigger can use this to get the initial state of a LED already set in
|
||
|
+ * hardware blink control.
|
||
|
+ *
|
||
|
+ * Return 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.
|
||
|
+ */
|
||
|
+ int (*hw_control_get)(struct led_classdev *led_cdev,
|
||
|
+ unsigned long *flags);
|
||
|
#endif
|
||
|
|
||
|
#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED
|