This is RFC proposal to cache the backlight power state in order to avoid accessing pps register every time while brightness or bl_power attributes of class intel_backlight is being changed. Signed-off-by: Anshuman Gupta <anshuman.gupta@xxxxxxxxx> --- .../gpu/drm/i915/display/intel_display_types.h | 1 + drivers/gpu/drm/i915/display/intel_dp.c | 18 ++++++++++-------- drivers/gpu/drm/i915/display/intel_panel.c | 8 +++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 5bc5bfbc4551..7c12b66c11af 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -263,6 +263,7 @@ struct intel_panel { struct backlight_device *device; const struct intel_panel_bl_funcs *funcs; + bool bl_powered; void (*power)(struct intel_connector *, bool enable); } backlight; }; diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index b2bc0c8c39c7..73536e377c20 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -3398,6 +3398,8 @@ void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state) { struct intel_dp *intel_dp = enc_to_intel_dp(to_intel_encoder(conn_state->best_encoder)); + struct intel_connector *connector = to_intel_connector(conn_state->connector); + struct intel_panel *panel = &connector->panel; struct drm_i915_private *i915 = dp_to_i915(intel_dp); if (!intel_dp_is_edp(intel_dp)) @@ -3407,6 +3409,9 @@ void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state, intel_panel_enable_backlight(crtc_state, conn_state); _intel_edp_backlight_on(intel_dp); + mutex_lock(&i915->backlight_lock); + panel->backlight.bl_powered = true; + mutex_unlock(&i915->backlight_lock); } /* Disable backlight in the panel power control. */ @@ -3437,6 +3442,8 @@ static void _intel_edp_backlight_off(struct intel_dp *intel_dp) void intel_edp_backlight_off(const struct drm_connector_state *old_conn_state) { struct intel_dp *intel_dp = enc_to_intel_dp(to_intel_encoder(old_conn_state->best_encoder)); + struct intel_connector *connector = to_intel_connector(old_conn_state->connector); + struct intel_panel *panel = &connector->panel; struct drm_i915_private *i915 = dp_to_i915(intel_dp); if (!intel_dp_is_edp(intel_dp)) @@ -3445,6 +3452,9 @@ void intel_edp_backlight_off(const struct drm_connector_state *old_conn_state) drm_dbg_kms(&i915->drm, "\n"); _intel_edp_backlight_off(intel_dp); + mutex_lock(&i915->backlight_lock); + panel->backlight.bl_powered = false; + mutex_unlock(&i915->backlight_lock); intel_panel_disable_backlight(old_conn_state); } @@ -3457,14 +3467,6 @@ static void intel_edp_backlight_power(struct intel_connector *connector, { struct drm_i915_private *i915 = to_i915(connector->base.dev); struct intel_dp *intel_dp = intel_attached_dp(connector); - intel_wakeref_t wakeref; - bool is_enabled; - - is_enabled = false; - with_pps_lock(intel_dp, wakeref) - is_enabled = ilk_get_pp_control(intel_dp) & EDP_BLC_ENABLE; - if (is_enabled == enable) - return; drm_dbg_kms(&i915->drm, "panel power control backlight %s\n", enable ? "enable" : "disable"); diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c index 36b7693453ae..9f81edf25475 100644 --- a/drivers/gpu/drm/i915/display/intel_panel.c +++ b/drivers/gpu/drm/i915/display/intel_panel.c @@ -1282,6 +1282,7 @@ static void intel_panel_set_backlight(const struct drm_connector_state *conn_sta static int intel_backlight_device_update_status(struct backlight_device *bd) { struct intel_connector *connector = bl_get_data(bd); + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct intel_panel *panel = &connector->panel; struct drm_device *dev = connector->base.dev; @@ -1301,7 +1302,12 @@ static int intel_backlight_device_update_status(struct backlight_device *bd) if (panel->backlight.power) { bool enable = bd->props.power == FB_BLANK_UNBLANK && bd->props.brightness != 0; - panel->backlight.power(connector, enable); + mutex_lock(&dev_priv->backlight_lock); + if (enable != panel->backlight.bl_powered) { + panel->backlight.power(connector, enable); + panel->backlight.bl_powered = enable; + } + mutex_unlock(&dev_priv->backlight_lock); } } else { bd->props.power = FB_BLANK_POWERDOWN; -- 2.26.2 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx