[PATCH 03/28] backlight: lcd: Add LCD_POWER_ constants for power states
Thomas Zimmermann
tzimmermann at suse.de
Tue Aug 20 09:22:41 UTC 2024
Duplicate FB_BLANK_ constants as LCD_POWER_ constants in the lcd
header file. Allows lcd drivers to avoid including the fbdev header
file and removes a compile-time dependency between the two subsystems.
The new LCD_POWER_ constants have the same values as their
FB_BLANK_ counterparts. Hence semantics does not change and the lcd
drivers can be converted one by one. Each instance of FB_BLANK_UNBLANK
becomes LCD_POWER_ON, each of FB_BLANK_POWERDOWN becomes LCD_POWER_OFF,
FB_BLANK_NORMAL becomes LCD_POWER_REDUCED and FB_BLANK_VSYNC_SUSPEND
becomes LCD_POWER_REDUCED_VSYNC_SUSPEND.
Lcd code or drivers do not use FB_BLANK_HSYNC_SUSPEND, so no
new constants for this is being added. The tokens LCD_POWER_REDUCED
and LCD_POWER_REDUCED_VSYNC_SUSPEND are deprecated and drivers should
replace them with LCD_POWER_ON and LCD_POWER_OFF.
See also commit a1cacb8a8e70 ("backlight: Add BACKLIGHT_POWER_ constants
for power states"), which added similar constants fro backlight drivers.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
drivers/video/backlight/lcd.c | 22 +++++++++++++++++++++-
include/linux/lcd.h | 5 +++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 43a6752ec27f..edd5ccb7a43a 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -20,6 +20,24 @@
#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
+static int to_lcd_power(int fb_blank)
+{
+ switch (fb_blank) {
+ case FB_BLANK_UNBLANK:
+ return LCD_POWER_ON;
+ /* deprecated; TODO: should become 'off' */
+ case FB_BLANK_NORMAL:
+ return LCD_POWER_REDUCED;
+ case FB_BLANK_VSYNC_SUSPEND:
+ return LCD_POWER_REDUCED_VSYNC_SUSPEND;
+ /* 'off' */
+ case FB_BLANK_HSYNC_SUSPEND:
+ case FB_BLANK_POWERDOWN:
+ default:
+ return LCD_POWER_OFF;
+ }
+}
+
/* This callback gets called when something important happens inside a
* framebuffer driver. We're looking if that important event is blanking,
* and if it is, we're switching lcd power as well ...
@@ -43,8 +61,10 @@ static int fb_notifier_callback(struct notifier_block *self,
goto out;
if (event == FB_EVENT_BLANK) {
+ int power = to_lcd_power(*(int *)evdata->data);
+
if (ld->ops->set_power)
- ld->ops->set_power(ld, *(int *)evdata->data);
+ ld->ops->set_power(ld, power);
} else {
if (ld->ops->set_mode)
ld->ops->set_mode(ld, evdata->data);
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 68703a51dc53..dfcc54d327f5 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -14,6 +14,11 @@
#include <linux/notifier.h>
#include <linux/fb.h>
+#define LCD_POWER_ON (0)
+#define LCD_POWER_REDUCED (1) // deprecated; don't use in new code
+#define LCD_POWER_REDUCED_VSYNC_SUSPEND (2) // deprecated; don't use in new code
+#define LCD_POWER_OFF (4)
+
/* Notes on locking:
*
* lcd_device->ops_lock is an internal backlight lock protecting the ops
--
2.46.0
More information about the dri-devel
mailing list