Den 17.01.2018 18.00, skrev Daniel Thompson:
On 16/01/18 10:31, Meghana Madhyastha wrote:
Add helper functions backlight_enable and backlight_disable to
enable/disable a backlight device. These helper functions can
then be used by different drm and tinydrm drivers to avoid
repetition of code and also to enforce a uniform and consistent
way to enable/disable a backlight device.
Signed-off-by: Meghana Madhyastha <meghana.madhyastha@xxxxxxxxx>
To be clear I don't disagree with anthing Daniel V. said about the
horribly confused (and confusing) power states for backlight.
Nevertheless I don't recall seeing any response (positive or negative)
to this post from v13:
https://www.spinics.net/lists/dri-devel/msg154459.html
I see that Daniel V has answered while I was chasing this down, but anyways:
A grep suggests that omap1_bl is the only driver that only checks fb_blank.
All the other drivers check both fb_blank and power, a few check state. The
backlight fbdev notifier callback doesn't set power, but sets fb_blank and
state.
fb_blank was marked 'Due to be removed' 9 years ago, so it hasn't been
high priority.
So for completeness I guess it makes sense to set fb_blank.
Noralf.
$ grep -r -C10 "props\.fb_blank" .
./drivers/video/backlight/corgi_lcd.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/corgi_lcd.c- intensity = 0;
./drivers/video/backlight/corgi_lcd.c-
./drivers/video/backlight/corgi_lcd.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/corgi_lcd.c- intensity = 0;
--
./drivers/video/backlight/adp8860_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/adp8860_bl.c- brightness = 0;
./drivers/video/backlight/adp8860_bl.c-
./drivers/video/backlight/adp8860_bl.c: if (bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/adp8860_bl.c- brightness = 0;
--
./drivers/video/backlight/hp680_bl.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/hp680_bl.c- intensity = 0;
./drivers/video/backlight/hp680_bl.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/hp680_bl.c- intensity = 0;
--
./drivers/video/backlight/cr_bllcd.c-static int
cr_backlight_set_intensity(struct backlight_device *bd)
./drivers/video/backlight/cr_bllcd.c-{
./drivers/video/backlight/cr_bllcd.c- int intensity =
bd->props.brightness;
./drivers/video/backlight/cr_bllcd.c- u32 addr = gpio_bar +
CRVML_PANEL_PORT;
./drivers/video/backlight/cr_bllcd.c- u32 cur = inl(addr);
./drivers/video/backlight/cr_bllcd.c-
./drivers/video/backlight/cr_bllcd.c- if (bd->props.power ==
FB_BLANK_UNBLANK)
./drivers/video/backlight/cr_bllcd.c- intensity =
FB_BLANK_UNBLANK;
./drivers/video/backlight/cr_bllcd.c: if (bd->props.fb_blank ==
FB_BLANK_UNBLANK)
./drivers/video/backlight/cr_bllcd.c- intensity =
FB_BLANK_UNBLANK;
./drivers/video/backlight/cr_bllcd.c- if (bd->props.power ==
FB_BLANK_POWERDOWN)
./drivers/video/backlight/cr_bllcd.c- intensity =
FB_BLANK_POWERDOWN;
./drivers/video/backlight/cr_bllcd.c: if (bd->props.fb_blank ==
FB_BLANK_POWERDOWN)
./drivers/video/backlight/cr_bllcd.c- intensity =
FB_BLANK_POWERDOWN;
--
./drivers/video/backlight/max8925_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/max8925_bl.c- brightness = 0;
./drivers/video/backlight/max8925_bl.c-
./drivers/video/backlight/max8925_bl.c: if (bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/max8925_bl.c- brightness = 0;
./drivers/video/backlight/max8925_bl.c-
./drivers/video/backlight/max8925_bl.c- if (bl->props.state &
BL_CORE_SUSPENDED)
./drivers/video/backlight/max8925_bl.c- brightness = 0;
--
./drivers/video/backlight/lv5207lp.c- if (backlight->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/lv5207lp.c: backlight->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/lv5207lp.c- backlight->props.state &
(BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
./drivers/video/backlight/lv5207lp.c- brightness = 0;
--
./drivers/video/backlight/lm3533_bl.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/lm3533_bl.c- brightness = 0;
./drivers/video/backlight/lm3533_bl.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/lm3533_bl.c- brightness = 0;
--
./drivers/video/backlight/omap1_bl.c-static int
omapbl_update_status(struct backlight_device *dev)
./drivers/video/backlight/omap1_bl.c-{
./drivers/video/backlight/omap1_bl.c- struct omap_backlight *bl =
bl_get_data(dev);
./drivers/video/backlight/omap1_bl.c-
./drivers/video/backlight/omap1_bl.c- if (bl->current_intensity !=
dev->props.brightness) {
./drivers/video/backlight/omap1_bl.c- if (bl->powermode ==
FB_BLANK_UNBLANK)
./drivers/video/backlight/omap1_bl.c-
omapbl_send_intensity(dev->props.brightness);
./drivers/video/backlight/omap1_bl.c- bl->current_intensity =
dev->props.brightness;
./drivers/video/backlight/omap1_bl.c- }
./drivers/video/backlight/omap1_bl.c-
./drivers/video/backlight/omap1_bl.c: if (dev->props.fb_blank !=
bl->powermode)
./drivers/video/backlight/omap1_bl.c: omapbl_set_power(dev,
dev->props.fb_blank);
./drivers/video/backlight/omap1_bl.c-
./drivers/video/backlight/omap1_bl.c- return 0;
./drivers/video/backlight/omap1_bl.c-}
./drivers/video/backlight/omap1_bl.c-
--
./drivers/video/backlight/kb3886_bl.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/kb3886_bl.c- intensity = 0;
./drivers/video/backlight/kb3886_bl.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/kb3886_bl.c- intensity = 0;
--
./drivers/video/backlight/pwm_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/pwm_bl.c: bl->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/pwm_bl.c- bl->props.state &
BL_CORE_FBBLANK)
./drivers/video/backlight/pwm_bl.c- brightness = 0;
--
./drivers/video/backlight/pm8941-wled.c- if (bl->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/pm8941-wled.c: bl->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/pm8941-wled.c- bl->props.state & BL_CORE_FBBLANK)
./drivers/video/backlight/pm8941-wled.c- val = 0;
--
./drivers/video/backlight/adp8870_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/adp8870_bl.c- brightness = 0;
./drivers/video/backlight/adp8870_bl.c-
./drivers/video/backlight/adp8870_bl.c: if (bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/adp8870_bl.c- brightness = 0;
--
./drivers/video/backlight/as3711_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/as3711_bl.c: bl->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/as3711_bl.c- bl->props.state &
(BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
./drivers/video/backlight/as3711_bl.c- brightness = 0;
--
./drivers/video/backlight/88pm860x_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/88pm860x_bl.c- brightness = 0;
./drivers/video/backlight/88pm860x_bl.c-
./drivers/video/backlight/88pm860x_bl.c: if (bl->props.fb_blank
!= FB_BLANK_UNBLANK)
./drivers/video/backlight/88pm860x_bl.c- brightness = 0;
./drivers/video/backlight/88pm860x_bl.c-
./drivers/video/backlight/88pm860x_bl.c- if (bl->props.state &
BL_CORE_SUSPENDED)
./drivers/video/backlight/88pm860x_bl.c- brightness = 0;
--
./drivers/video/backlight/tps65217_bl.c- if (bl->props.state &
BL_CORE_SUSPENDED)
./drivers/video/backlight/tps65217_bl.c- brightness = 0;
./drivers/video/backlight/tps65217_bl.c-
./drivers/video/backlight/tps65217_bl.c- if ((bl->props.power !=
FB_BLANK_UNBLANK) ||
./drivers/video/backlight/tps65217_bl.c: (bl->props.fb_blank !=
FB_BLANK_UNBLANK))
./drivers/video/backlight/tps65217_bl.c- /* framebuffer
in low power mode or blanking active */
./drivers/video/backlight/tps65217_bl.c- brightness = 0;
--
./drivers/video/backlight/adp5520_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/adp5520_bl.c- brightness = 0;
./drivers/video/backlight/adp5520_bl.c-
./drivers/video/backlight/adp5520_bl.c: if (bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/adp5520_bl.c- brightness = 0;
--
./drivers/video/backlight/wm831x_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/wm831x_bl.c- brightness = 0;
./drivers/video/backlight/wm831x_bl.c-
./drivers/video/backlight/wm831x_bl.c: if (bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/wm831x_bl.c- brightness = 0;
./drivers/video/backlight/wm831x_bl.c-
./drivers/video/backlight/wm831x_bl.c- if (bl->props.state &
BL_CORE_SUSPENDED)
./drivers/video/backlight/wm831x_bl.c- brightness = 0;
--
./drivers/video/backlight/gpio_backlight.c- if (bl->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/gpio_backlight.c: bl->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/gpio_backlight.c- bl->props.state &
(BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
./drivers/video/backlight/gpio_backlight.c- brightness = 0;
--
./drivers/video/backlight/da903x_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/da903x_bl.c- brightness = 0;
./drivers/video/backlight/da903x_bl.c-
./drivers/video/backlight/da903x_bl.c: if (bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/da903x_bl.c- brightness = 0;
./drivers/video/backlight/da903x_bl.c-
./drivers/video/backlight/da903x_bl.c- if (bl->props.state &
BL_CORE_SUSPENDED)
./drivers/video/backlight/da903x_bl.c- brightness = 0;
--
./drivers/video/backlight/locomolcd.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/locomolcd.c- intensity = 0;
./drivers/video/backlight/locomolcd.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/locomolcd.c- intensity = 0;
--
./drivers/video/backlight/bd6107.c- if (backlight->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/bd6107.c: backlight->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/bd6107.c- backlight->props.state &
(BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
./drivers/video/backlight/bd6107.c- brightness = 0;
--
./drivers/video/backlight/backlight.c- if (fb_blank ==
FB_BLANK_UNBLANK &&
./drivers/video/backlight/backlight.c- !bd->fb_bl_on[node]) {
./drivers/video/backlight/backlight.c- bd->fb_bl_on[node] = true;
./drivers/video/backlight/backlight.c- if
(!bd->use_count++) {
./drivers/video/backlight/backlight.c- bd->props.state &= ~BL_CORE_FBBLANK;
./drivers/video/backlight/backlight.c: bd->props.fb_blank =
FB_BLANK_UNBLANK;
./drivers/video/backlight/backlight.c- backlight_update_status(bd);
./drivers/video/backlight/backlight.c- }
./drivers/video/backlight/backlight.c- } else if
(fb_blank != FB_BLANK_UNBLANK &&
./drivers/video/backlight/backlight.c- bd->fb_bl_on[node]) {
./drivers/video/backlight/backlight.c- bd->fb_bl_on[node] = false;
./drivers/video/backlight/backlight.c- if
(!(--bd->use_count)) {
./drivers/video/backlight/backlight.c- bd->props.state |= BL_CORE_FBBLANK;
./drivers/video/backlight/backlight.c: bd->props.fb_blank = fb_blank;
./drivers/video/backlight/backlight.c- backlight_update_status(bd);
--
./drivers/video/backlight/ep93xx_bl.c- if (bl->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/backlight/ep93xx_bl.c: bl->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/backlight/ep93xx_bl.c- brightness = 0;
--
./drivers/video/backlight/jornada720_bl.c: if ((bd->props.power !=
FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
--
./drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c: if
(dev->props.fb_blank == FB_BLANK_UNBLANK &&
./drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c-
dev->props.power == FB_BLANK_UNBLANK)
./drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c- level =
dev->props.brightness;
./drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c- else
./drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c- level = 0;
--
./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c: if
(dev->props.fb_blank == FB_BLANK_UNBLANK &&
./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c-
dev->props.power == FB_BLANK_UNBLANK)
./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c-
level = dev->props.brightness;
./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c- else
./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c-
level = 0;
--
./drivers/video/fbdev/aty/atyfb_base.c- if (bd->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/fbdev/aty/atyfb_base.c: bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/fbdev/aty/atyfb_base.c- level = 0;
./drivers/video/fbdev/aty/atyfb_base.c- else
./drivers/video/fbdev/aty/atyfb_base.c- level =
bd->props.brightness;
--
./drivers/video/fbdev/aty/aty128fb.c- if (bd->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/fbdev/aty/aty128fb.c: bd->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/video/fbdev/aty/aty128fb.c- !par->lcd_on)
./drivers/video/fbdev/aty/aty128fb.c- level = 0;
./drivers/video/fbdev/aty/aty128fb.c- else
./drivers/video/fbdev/aty/aty128fb.c- level =
bd->props.brightness;
--
./drivers/video/fbdev/aty/radeon_backlight.c- if (bd->props.power
!= FB_BLANK_UNBLANK ||
./drivers/video/fbdev/aty/radeon_backlight.c: bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/fbdev/aty/radeon_backlight.c- level = 0;
./drivers/video/fbdev/aty/radeon_backlight.c- else
./drivers/video/fbdev/aty/radeon_backlight.c- level =
bd->props.brightness;
--
./drivers/video/fbdev/mx3fb.c- if (bl->props.power != FB_BLANK_UNBLANK)
./drivers/video/fbdev/mx3fb.c- brightness = 0;
./drivers/video/fbdev/mx3fb.c: if (bl->props.fb_blank != FB_BLANK_UNBLANK)
./drivers/video/fbdev/mx3fb.c- brightness = 0;
--
./drivers/video/fbdev/riva/fbdev.c- if (bd->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/fbdev/riva/fbdev.c: bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/fbdev/riva/fbdev.c- level = 0;
./drivers/video/fbdev/riva/fbdev.c- else
./drivers/video/fbdev/riva/fbdev.c- level =
bd->props.brightness;
--
./drivers/video/fbdev/atmel_lcdfb.c: if (bl->props.fb_blank !=
sinfo->bl_power)
./drivers/video/fbdev/atmel_lcdfb.c: power = bl->props.fb_blank;
./drivers/video/fbdev/atmel_lcdfb.c- else if (bl->props.power !=
sinfo->bl_power)
./drivers/video/fbdev/atmel_lcdfb.c- power = bl->props.power;
--
./drivers/video/fbdev/nvidia/nv_backlight.c- if (bd->props.power !=
FB_BLANK_UNBLANK ||
./drivers/video/fbdev/nvidia/nv_backlight.c: bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/video/fbdev/nvidia/nv_backlight.c- level = 0;
./drivers/video/fbdev/nvidia/nv_backlight.c- else
./drivers/video/fbdev/nvidia/nv_backlight.c- level =
bd->props.brightness;
--
./drivers/macintosh/via-pmu-backlight.c- if (bd->props.power !=
FB_BLANK_UNBLANK ||
./drivers/macintosh/via-pmu-backlight.c: bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/macintosh/via-pmu-backlight.c- level = 0;
--
./drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c: if
(dev->props.fb_blank == FB_BLANK_UNBLANK &&
./drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c- dev->props.power ==
FB_BLANK_UNBLANK)
./drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c- level =
dev->props.brightness;
./drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c- else
./drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c- level = 0;
--
./drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c: if
(dev->props.fb_blank == FB_BLANK_UNBLANK &&
./drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c-
dev->props.power == FB_BLANK_UNBLANK)
./drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c- level =
dev->props.brightness;
./drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c- else
./drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c- level = 0;
--
./drivers/staging/fbtft/fb_ssd1351.c- on = (bd->props.power ==
FB_BLANK_UNBLANK) &&
./drivers/staging/fbtft/fb_ssd1351.c: (bd->props.fb_blank ==
FB_BLANK_UNBLANK);
--
./drivers/staging/fbtft/fbtft-core.c- if ((bd->props.power ==
FB_BLANK_UNBLANK) &&
./drivers/staging/fbtft/fbtft-core.c: (bd->props.fb_blank ==
FB_BLANK_UNBLANK))
--
./drivers/staging/fbtft/fb_watterott.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/staging/fbtft/fb_watterott.c- brightness = 0;
./drivers/staging/fbtft/fb_watterott.c-
./drivers/staging/fbtft/fb_watterott.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/staging/fbtft/fb_watterott.c- brightness = 0;
--
./drivers/auxdisplay/ht16k33.c- if (bl->props.power != FB_BLANK_UNBLANK ||
./drivers/auxdisplay/ht16k33.c: bl->props.fb_blank !=
FB_BLANK_UNBLANK ||
./drivers/auxdisplay/ht16k33.c- bl->props.state & BL_CORE_FBBLANK ||
brightness == 0) {
./drivers/auxdisplay/ht16k33.c- return ht16k33_display_off(priv);
--
./drivers/platform/x86/thinkpad_acpi.c: (bd->props.fb_blank ==
FB_BLANK_UNBLANK &&
./drivers/platform/x86/thinkpad_acpi.c- bd->props.power ==
FB_BLANK_UNBLANK) ?
./drivers/platform/x86/thinkpad_acpi.c- bd->props.brightness : 0;
--
./drivers/platform/x86/acer-wmi.c- if (bd->props.power !=
FB_BLANK_UNBLANK)
./drivers/platform/x86/acer-wmi.c- intensity = 0;
./drivers/platform/x86/acer-wmi.c: if (bd->props.fb_blank !=
FB_BLANK_UNBLANK)
./drivers/platform/x86/acer-wmi.c- intensity = 0;
Daniel.
---
include/linux/backlight.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index af7003548..7b6a9a2a3 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -130,6 +130,36 @@ static inline int backlight_update_status(struct
backlight_device *bd)
return ret;
}
+/**
+ * backlight_enable - Enable backlight
+ * @bd: the backlight device to enable
+ */
+static inline int backlight_enable(struct backlight_device *bd)
+{
+ if (!bd)
+ return 0;
+
+ bd->props.power = FB_BLANK_UNBLANK;
+ bd->props.state &= ~BL_CORE_FBBLANK;
+
+ return backlight_update_status(bd);
+}
+
+/**
+ * backlight_disable - Disable backlight
+ * @bd: the backlight device to disable
+ */
+static inline int backlight_disable(struct backlight_device *bd)
+{
+ if (!bd)
+ return 0;
+
+ bd->props.power = FB_BLANK_POWERDOWN;
+ bd->props.state |= BL_CORE_FBBLANK;
+
+ return backlight_update_status(bd);
+}
+
extern struct backlight_device *backlight_device_register(const
char *name,
struct device *dev, void *devdata, const struct backlight_ops
*ops,
const struct backlight_properties *props);
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel