Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 a1cacb8a8e70 ("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 <tzimmermann@suse.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240906075439.98476-4-tzimmermann@suse.de
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Thomas Zimmermann and committed by
Lee Jones
48ffe207 26228256

+26 -1
+21 -1
drivers/video/backlight/lcd.c
··· 20 20 21 21 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ 22 22 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 + 23 41 /* This callback gets called when something important happens inside a 24 42 * framebuffer driver. We're looking if that important event is blanking, 25 43 * and if it is, we're switching lcd power as well ... ··· 60 42 return 0; 61 43 62 44 if (event == FB_EVENT_BLANK) { 45 + int power = to_lcd_power(*(int *)evdata->data); 46 + 63 47 if (ld->ops->set_power) 64 - ld->ops->set_power(ld, *(int *)evdata->data); 48 + ld->ops->set_power(ld, power); 65 49 } else { 66 50 if (ld->ops->set_mode) 67 51 ld->ops->set_mode(ld, evdata->data);
+5
include/linux/lcd.h
··· 14 14 #include <linux/notifier.h> 15 15 #include <linux/fb.h> 16 16 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 + 17 22 /* Notes on locking: 18 23 * 19 24 * lcd_device->ops_lock is an internal backlight lock protecting the ops