Skip to content

Commit 2144d00

Browse files
sravnborgLee Jones
authored andcommitted
backlight: backlight: Introduce backlight_get_brightness()
Based on an idea from Emil Velikov, add a helper that checks backlight_is_blank() and return 0 as brightness if display is blank or the property value if not. This allows us to simplify the update_status() implementation in most of the backlight drivers. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 5ab4246 commit 2144d00

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎include/linux/backlight.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,25 @@ static inline bool backlight_is_blank(const struct backlight_device *bd)
417417
bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK);
418418
}
419419

420+
/**
421+
* backlight_get_brightness - Returns the current brightness value
422+
* @bd: the backlight device
423+
*
424+
* Returns the current brightness value, taking in consideration the current
425+
* state. If backlight_is_blank() returns true then return 0 as brightness
426+
* otherwise return the current brightness property value.
427+
*
428+
* Backlight drivers are expected to use this function in their update_status()
429+
* operation to get the brightness value.
430+
*/
431+
static inline int backlight_get_brightness(const struct backlight_device *bd)
432+
{
433+
if (backlight_is_blank(bd))
434+
return 0;
435+
else
436+
return bd->props.brightness;
437+
}
438+
420439
struct backlight_device *
421440
backlight_device_register(const char *name, struct device *dev, void *devdata,
422441
const struct backlight_ops *ops,

0 commit comments

Comments
 (0)