@@ -202,6 +202,23 @@ hardware mode and any software only trigger will reject activation.
On init an LED driver that support a hardware mode should reset every blink mode
set by default.
+Once a trigger has declared support for hardware-controlled blinks, it will use
+blink_set() to try to offload his trigger on activation/configuration.
+blink_set() will return 0 if the requested modes set in trigger_data can be
+controlled by hardware or an error if both of the bitmap modes are not supported by
+the hardware or there was a problem in the configuration.
+
+Following blink_set logic, setting brightness to LED_OFF with hardware control active
+will reset any active blink mode and disable hardware control setting the LED to off.
+
+It's in the LED driver's interest to know how to elaborate the trigger data and report support
+for a particular set of blink modes. For this exact reason explicit support for the specific
+trigger is mandatory or the driver returns -EOPNOTSUPP if asked to enter hardware mode
+with a not supported trigger.
+If the driver returns -EOPNOTSUPP on hw_control_configure(), the trigger activation will
+fail as the driver doesn't support that specific hardware blink mode or doesn't know
+how to handle the provided trigger data.
+
Known Issues
============
@@ -180,6 +180,13 @@ static int led_classdev_check_hw_control_functions(struct led_classdev *led_cdev
led_cdev->hw_control_stop))
return -EINVAL;
+ /* blink_set is mandatory to configure the blink modes
+ * in hardware control.
+ */
+ if ((LED_HARDWARE_CONTROLLED & led_cdev->flags) &&
+ !led_cdev->blink_set)
+ return -EINVAL;
+
return 0;
}
#endif
@@ -76,6 +76,7 @@ struct led_classdev {
/* Lower 16 bits reflect status */
#define LED_SUSPENDED BIT(0)
#define LED_UNREGISTERING BIT(1)
+#define LED_HARDWARE_CONTROL BIT(2)
/* Upper 16 bits reflect control information */
#define LED_CORE_SUSPENDRESUME BIT(16)
#define LED_SYSFS_DISABLE BIT(17)
@@ -123,6 +124,12 @@ struct led_classdev {
* match the values specified exactly.
* Deactivate blinking again when the brightness is set to LED_OFF
* via the brightness_set() callback.
+ * With LED_HARDWARE_CONTROL set in LED flags blink_set will also
+ * configure blink modes requested by the current trigger if
+ * supported by the LED driver.
+ * Setting brightness to LED_OFF with hardware control active will
+ * reset any active blink mode and disable hardware control setting
+ * the LED off.
*/
int (*blink_set)(struct led_classdev *led_cdev,
unsigned long *delay_on,
@@ -165,6 +172,8 @@ struct led_classdev {
*/
bool (*hw_control_status)(struct led_classdev *led_cdev);
/* Set LED in hardware mode and reset any blink mode active by default.
+ * A trigger supporting hardware mode will have to use blink_set to configure
+ * the modes.
*/
int (*hw_control_start)(struct led_classdev *led_cdev);
/* Disable hardware mode for LED. It's advised to the LED driver to put it to
blink_set can now be used also to configure blink modes when hardware control is supported and active. Trigger will try to use blink_set and a LED driver will use the trigger_data to configure the blink_modes once blink_set is called. Setting a brightness to LED_OFF will reset any blink mode and disable hardware control setting the LED off. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> --- Documentation/leds/leds-class.rst | 17 +++++++++++++++++ drivers/leds/led-class.c | 7 +++++++ include/linux/leds.h | 9 +++++++++ 3 files changed, 33 insertions(+)