Linux LED subsystem development
 help / color / mirror / Atom feed
* Proposal: Add color_temperature support
@ 2022-10-29  9:54 Andreas Bergmeier
  2022-10-29 16:52 ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Bergmeier @ 2022-10-29  9:54 UTC (permalink / raw)
  To: linux-leds

On the device Logitech Litra Glow it is possible to set not only the
brightness but also the color temperature (both via usb as well as via
hardware).
I am currently trying to add support for the device - and expose it
via LED - into the kernel.
So to support all device capabilities I am proposing to extend LEDs by
color temperature:
And initial patch for the headers:

 diff --git a/include/linux/leds.h b/include/linux/leds.h
index ba4861ec7..494eab49b 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -72,6 +72,9 @@ struct led_classdev {
unsigned int brightness;
unsigned int max_brightness;
int flags;
+ unsigned int color_temperature;
+ unsigned int min_color_temperature;
+ unsigned int max_color_temperature;
/* Lower 16 bits reflect status */
#define LED_SUSPENDED BIT(0)
@@ -123,6 +126,21 @@ struct led_classdev {
unsigned long *delay_on,
unsigned long *delay_off);
+ /* Set LED color temperature
+ * Must not sleep. Use color_temperature_set_blocking for drivers
+ * that can sleep while setting color temperature.
+ */
+ void (*color_temperature_set)(struct led_classdev *led_cdev,
+ unsigned int color_temperature);
+ /*
+ * Set LED color temperature immediately - it can block the caller for
+ * the time required for accessing a LED device register.
+ */
+ int (*color_temperature_set_blocking)(struct led_classdev *led_cdev,
+ unsigned int color_temperature);
+ /* Get LED color temperature */
+ unsigned int (*color_temperature_get)(struct led_classdev *led_cdev);
+
int (*pattern_set)(struct led_classdev *led_cdev,
struct led_pattern *pattern, u32 len, int repeat);
int (*pattern_clear)(struct led_classdev *led_cdev);
@@ -140,6 +158,7 @@ struct led_classdev {
void (*flash_resume)(struct led_classdev *led_cdev);
struct work_struct set_brightness_work;
+ struct work_struct set_color_temperature_work;
int delayed_set_value;
#ifdef CONFIG_LEDS_TRIGGERS
@@ -160,6 +179,10 @@ struct led_classdev {
int brightness_hw_changed;
struct kernfs_node *brightness_hw_changed_kn;
#endif
+#ifdef CONFIG_LEDS_COLOR_TEMPERATURE_HW_CHANGED
+ int color_temperature_hw_changed;
+ struct kernfs_node *color_temperature_hw_changed_kn;
+#endif
/* Ensures consistent access to the LED Flash Class device */
struct mutex led_access;
@@ -574,6 +597,14 @@ void led_classdev_notify_brightness_hw_changed(
static inline void led_classdev_notify_brightness_hw_changed(
struct led_classdev *led_cdev, enum led_brightness brightness) { }
#endif
+#ifdef CONFIG_LEDS_COLOR_TEMPERATURE_HW_CHANGED
+void led_classdev_notify_color_temperature_hw_changed(
+ struct led_classdev *led_cdev, unsigned int color_temperature);
+#else
+static inline void led_classdev_notify_color_temperature_hw_changed(
+ struct led_classdev *led_cdev, unsigned int color_temperature) { }
+#endif
+
/**
* struct led_pattern - pattern interval settings

What do you think?
Cheers

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-03 20:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-29  9:54 Proposal: Add color_temperature support Andreas Bergmeier
2022-10-29 16:52 ` Pavel Machek
2022-10-29 17:11   ` Andreas Bergmeier
2022-10-29 18:32     ` Pavel Machek
2022-10-29 19:18       ` Andreas Bergmeier
2022-11-03 20:37         ` Andreas Bergmeier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox