[PATCH] drm/i915/backlight: Power on before setting brightness

Jouni Högander jouni.hogander at intel.com
Mon Aug 22 07:08:18 UTC 2022


Currently we have same sequence for both, power on and off:

1. Set brightness to 0 or > 0
2. Power off or on

This patch changes power on sequence to be:

1. Power on
2. Set brightness to > 0

Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
 drivers/gpu/drm/i915/display/intel_backlight.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
index 262b2fda37e5..af28b143d27a 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -879,10 +879,17 @@ static int intel_backlight_device_update_status(struct backlight_device *bd)
 	struct intel_connector *connector = bl_get_data(bd);
 	struct intel_panel *panel = &connector->panel;
 	struct drm_device *dev = connector->base.dev;
+	bool enable = bd->props.power == FB_BLANK_UNBLANK &&
+		bd->props.brightness != 0;
 
 	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
 	DRM_DEBUG_KMS("updating intel_backlight, brightness=%d/%d\n",
 		      bd->props.brightness, bd->props.max_brightness);
+
+	/* Power on before setting brightness */
+	if (panel->backlight.enabled && panel->backlight.power && enable)
+		panel->backlight.power(connector, enable);
+
 	intel_panel_set_backlight(connector->base.state, bd->props.brightness,
 				  bd->props.max_brightness);
 
@@ -893,11 +900,8 @@ static int intel_backlight_device_update_status(struct backlight_device *bd)
 	 * callback needs to take this into account.
 	 */
 	if (panel->backlight.enabled) {
-		if (panel->backlight.power) {
-			bool enable = bd->props.power == FB_BLANK_UNBLANK &&
-				bd->props.brightness != 0;
+		if (panel->backlight.power && !enable)
 			panel->backlight.power(connector, enable);
-		}
 	} else {
 		bd->props.power = FB_BLANK_POWERDOWN;
 	}
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list