Commit 2144d00e authored by Sam Ravnborg's avatar Sam Ravnborg Committed by Lee Jones

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: default avatarSam Ravnborg <sam@ravnborg.org>
Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 5ab4246c
...@@ -417,6 +417,25 @@ static inline bool backlight_is_blank(const struct backlight_device *bd) ...@@ -417,6 +417,25 @@ static inline bool backlight_is_blank(const struct backlight_device *bd)
bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK);
} }
/**
* backlight_get_brightness - Returns the current brightness value
* @bd: the backlight device
*
* Returns the current brightness value, taking in consideration the current
* state. If backlight_is_blank() returns true then return 0 as brightness
* otherwise return the current brightness property value.
*
* Backlight drivers are expected to use this function in their update_status()
* operation to get the brightness value.
*/
static inline int backlight_get_brightness(const struct backlight_device *bd)
{
if (backlight_is_blank(bd))
return 0;
else
return bd->props.brightness;
}
struct backlight_device * struct backlight_device *
backlight_device_register(const char *name, struct device *dev, void *devdata, backlight_device_register(const char *name, struct device *dev, void *devdata,
const struct backlight_ops *ops, const struct backlight_ops *ops,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment