Skip to content

Commit 48ffe20

Browse files
tdzlag-linaro
authored andcommitted
backlight: lcd: Add LCD_POWER_ constants for power states
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 a1cacb8 ("backlight: Add BACKLIGHT_POWER_ constants for power states"), which added similar constants for backlight drivers. v2: - fix typo in commit description Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 2622825 commit 48ffe20

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

drivers/video/backlight/lcd.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@
2020

2121
#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
2222
defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
23+
static int to_lcd_power(int fb_blank)
24+
{
25+
switch (fb_blank) {
26+
case FB_BLANK_UNBLANK:
27+
return LCD_POWER_ON;
28+
/* deprecated; TODO: should become 'off' */
29+
case FB_BLANK_NORMAL:
30+
return LCD_POWER_REDUCED;
31+
case FB_BLANK_VSYNC_SUSPEND:
32+
return LCD_POWER_REDUCED_VSYNC_SUSPEND;
33+
/* 'off' */
34+
case FB_BLANK_HSYNC_SUSPEND:
35+
case FB_BLANK_POWERDOWN:
36+
default:
37+
return LCD_POWER_OFF;
38+
}
39+
}
40+
2341
/* This callback gets called when something important happens inside a
2442
* framebuffer driver. We're looking if that important event is blanking,
2543
* and if it is, we're switching lcd power as well ...
@@ -42,8 +60,10 @@ static int fb_notifier_callback(struct notifier_block *self,
4260
return 0;
4361

4462
if (event == FB_EVENT_BLANK) {
63+
int power = to_lcd_power(*(int *)evdata->data);
64+
4565
if (ld->ops->set_power)
46-
ld->ops->set_power(ld, *(int *)evdata->data);
66+
ld->ops->set_power(ld, power);
4767
} else {
4868
if (ld->ops->set_mode)
4969
ld->ops->set_mode(ld, evdata->data);

include/linux/lcd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
#include <linux/notifier.h>
1515
#include <linux/fb.h>
1616

17+
#define LCD_POWER_ON (0)
18+
#define LCD_POWER_REDUCED (1) // deprecated; don't use in new code
19+
#define LCD_POWER_REDUCED_VSYNC_SUSPEND (2) // deprecated; don't use in new code
20+
#define LCD_POWER_OFF (4)
21+
1722
/* Notes on locking:
1823
*
1924
* lcd_device->ops_lock is an internal backlight lock protecting the ops

0 commit comments

Comments
 (0)