Skip to content

Commit a1cacb8

Browse files
Thomas Zimmermannlag-linaro
authored andcommitted
backlight: Add BACKLIGHT_POWER_ constants for power states
Duplicate FB_BLANK_ constants as BACKLIGHT_POWER__ constants in the backlight header file. Allows backlight drivers to avoid including the fbdev header file and removes a compile-time dependency between the two subsystems. The new BACKLIGHT_POWER_ constants have the same values as their FB_BLANK_ counterparts. Hence UAPI and internal semantics do not change. The backlight drivers can be converted one by one. Each instance of FB_BLANK_UNBLANK becomes BACKLIGHT_POWER_ON, each of FB_BLANK_POWERDOWN becomes BACKLIGHT_POWER_OFF, and FB_BLANK_NORMAL becomes BACKLIGHT_POWER_REDUCED. Backlight code or drivers do not use FB_BLANK_VSYNC_SUSPEND and FB_BLANK_HSYNC_SUSPEND, so no new constants for these are being added. The semantics of FB_BLANK_NORMAL appear inconsistent. In fbdev, NORMAL means display off with sync enabled. In backlight code, this translates to turn the backlight off, but some drivers interpret it as backlight on. So we keep the current code as is, but mark BACKLIGHT_POWER_REDUCED as deprecated. Drivers should be fixed and the constant removed. This affects ams369fg06 and a few DRM panel drivers. v2: - rename BL_CORE_ power constants to BACKLIGHT_POWER_ (Sam) - fix documentation 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 b337cc3 commit a1cacb8

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Documentation/ABI/stable/sysfs-class-backlight

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ Date: April 2005
33
KernelVersion: 2.6.12
44
Contact: Richard Purdie <[email protected]>
55
Description:
6-
Control BACKLIGHT power, values are FB_BLANK_* from fb.h
6+
Control BACKLIGHT power, values are compatible with
7+
FB_BLANK_* from fb.h
78

8-
- FB_BLANK_UNBLANK (0) : power on.
9-
- FB_BLANK_POWERDOWN (4) : power off
9+
- 0 (FB_BLANK_UNBLANK) : power on.
10+
- 4 (FB_BLANK_POWERDOWN) : power off
1011
Users: HAL
1112

1213
What: /sys/class/backlight/<backlight>/brightness

include/linux/backlight.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,19 @@ struct backlight_properties {
209209
* attribute: /sys/class/backlight/<backlight>/bl_power
210210
* When the power property is updated update_status() is called.
211211
*
212-
* The possible values are: (0: full on, 1 to 3: power saving
213-
* modes; 4: full off), see FB_BLANK_XXX.
212+
* The possible values are: (0: full on, 4: full off), see
213+
* BACKLIGHT_POWER constants.
214214
*
215-
* When the backlight device is enabled @power is set
216-
* to FB_BLANK_UNBLANK. When the backlight device is disabled
217-
* @power is set to FB_BLANK_POWERDOWN.
215+
* When the backlight device is enabled, @power is set to
216+
* BACKLIGHT_POWER_ON. When the backlight device is disabled,
217+
* @power is set to BACKLIGHT_POWER_OFF.
218218
*/
219219
int power;
220220

221+
#define BACKLIGHT_POWER_ON (0)
222+
#define BACKLIGHT_POWER_OFF (4)
223+
#define BACKLIGHT_POWER_REDUCED (1) // deprecated; don't use in new code
224+
221225
/**
222226
* @type: The type of backlight supported.
223227
*
@@ -346,7 +350,7 @@ static inline int backlight_enable(struct backlight_device *bd)
346350
if (!bd)
347351
return 0;
348352

349-
bd->props.power = FB_BLANK_UNBLANK;
353+
bd->props.power = BACKLIGHT_POWER_ON;
350354
bd->props.state &= ~BL_CORE_FBBLANK;
351355

352356
return backlight_update_status(bd);
@@ -361,7 +365,7 @@ static inline int backlight_disable(struct backlight_device *bd)
361365
if (!bd)
362366
return 0;
363367

364-
bd->props.power = FB_BLANK_POWERDOWN;
368+
bd->props.power = BACKLIGHT_POWER_OFF;
365369
bd->props.state |= BL_CORE_FBBLANK;
366370

367371
return backlight_update_status(bd);
@@ -380,7 +384,7 @@ static inline int backlight_disable(struct backlight_device *bd)
380384
*/
381385
static inline bool backlight_is_blank(const struct backlight_device *bd)
382386
{
383-
return bd->props.power != FB_BLANK_UNBLANK ||
387+
return bd->props.power != BACKLIGHT_POWER_ON ||
384388
bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK);
385389
}
386390

0 commit comments

Comments
 (0)