[Intel-gfx] [PATCH 1/5] drm/i915/backlight: Restore backlight on resume, v3.
Jani Nikula
jani.nikula at linux.intel.com
Tue Jan 22 17:43:23 UTC 2019
On Tue, 08 Jan 2019, Maarten Lankhorst <maarten.lankhorst at linux.intel.com> wrote:
> Restore our saved values for backlight. This way even with fastset on
> S4 resume we will correctly restore the backlight to the active values.
>
> Changes since v1:
> - Call enable_backlight() when backlight.level is set. On suspend
> backlight.enabled is always cleared, this makes it not a good
> indicator. Also check for crtc->state->active.
> Changes since v2:
> - Use the new update_pipe() callback to run this on resume as well.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> Cc: Tolga Cakir <cevelnet at gmail.com>
> Cc: Basil Eric Rabi <ericbasil.rabi at gmail.com>
> Cc: Hans de Goede <jwrdegoede at fedoraproject.org>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Reported-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula at intel.com>
> ---
> drivers/gpu/drm/i915/icl_dsi.c | 1 +
> drivers/gpu/drm/i915/intel_ddi.c | 2 ++
> drivers/gpu/drm/i915/intel_dp.c | 1 +
> drivers/gpu/drm/i915/intel_drv.h | 3 ++
> drivers/gpu/drm/i915/intel_lvds.c | 1 +
> drivers/gpu/drm/i915/intel_panel.c | 49 +++++++++++++++++++++++-------
> drivers/gpu/drm/i915/vlv_dsi.c | 1 +
> 7 files changed, 47 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/icl_dsi.c b/drivers/gpu/drm/i915/icl_dsi.c
> index 4dd793b78996..3f92881600c5 100644
> --- a/drivers/gpu/drm/i915/icl_dsi.c
> +++ b/drivers/gpu/drm/i915/icl_dsi.c
> @@ -1378,6 +1378,7 @@ void icl_dsi_init(struct drm_i915_private *dev_priv)
> encoder->disable = gen11_dsi_disable;
> encoder->port = port;
> encoder->get_config = gen11_dsi_get_config;
> + encoder->update_pipe = intel_panel_update_backlight;
> encoder->compute_config = gen11_dsi_compute_config;
> encoder->get_hw_state = gen11_dsi_get_hw_state;
> encoder->type = INTEL_OUTPUT_DSI;
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 2d6ed990a232..d32865dc44e8 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -3548,6 +3548,8 @@ static void intel_ddi_update_pipe_dp(struct intel_encoder *encoder,
>
> intel_psr_enable(intel_dp, crtc_state);
> intel_edp_drrs_enable(intel_dp, crtc_state);
> +
> + intel_panel_update_backlight(encoder, crtc_state, conn_state);
> }
>
> static void intel_ddi_update_pipe(struct intel_encoder *encoder,
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 62fd11540942..0cbacdc70b07 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -6981,6 +6981,7 @@ bool intel_dp_init(struct drm_i915_private *dev_priv,
> intel_encoder->compute_config = intel_dp_compute_config;
> intel_encoder->get_hw_state = intel_dp_get_hw_state;
> intel_encoder->get_config = intel_dp_get_config;
> + intel_encoder->update_pipe = intel_panel_update_backlight;
> intel_encoder->suspend = intel_dp_encoder_suspend;
> if (IS_CHERRYVIEW(dev_priv)) {
> intel_encoder->pre_pll_enable = chv_dp_pre_pll_enable;
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 1a11c2beb7f3..0a6fb42e2086 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -2023,6 +2023,9 @@ int intel_panel_setup_backlight(struct drm_connector *connector,
> enum pipe pipe);
> void intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state,
> const struct drm_connector_state *conn_state);
> +void intel_panel_update_backlight(struct intel_encoder *encoder,
> + const struct intel_crtc_state *crtc_state,
> + const struct drm_connector_state *conn_state);
> void intel_panel_disable_backlight(const struct drm_connector_state *old_conn_state);
> extern struct drm_display_mode *intel_find_panel_downclock(
> struct drm_i915_private *dev_priv,
> diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
> index b85e195f7c8a..189693b4c5e8 100644
> --- a/drivers/gpu/drm/i915/intel_lvds.c
> +++ b/drivers/gpu/drm/i915/intel_lvds.c
> @@ -909,6 +909,7 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
> }
> intel_encoder->get_hw_state = intel_lvds_get_hw_state;
> intel_encoder->get_config = intel_lvds_get_config;
> + intel_encoder->update_pipe = intel_panel_update_backlight;
> intel_connector->get_hw_state = intel_connector_get_hw_state;
>
> intel_connector_attach_encoder(intel_connector, intel_encoder);
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index ee3e0842d542..f71b33cf1c97 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -1087,20 +1087,11 @@ static void pwm_enable_backlight(const struct intel_crtc_state *crtc_state,
> intel_panel_actually_set_backlight(conn_state, panel->backlight.level);
> }
>
> -void intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state,
> - const struct drm_connector_state *conn_state)
> +static void __intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state,
> + const struct drm_connector_state *conn_state)
> {
> struct intel_connector *connector = to_intel_connector(conn_state->connector);
> - struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
> struct intel_panel *panel = &connector->panel;
> - enum pipe pipe = to_intel_crtc(crtc_state->base.crtc)->pipe;
> -
> - if (!panel->backlight.present)
> - return;
> -
> - DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
> -
> - mutex_lock(&dev_priv->backlight_lock);
>
> WARN_ON(panel->backlight.max == 0);
>
> @@ -1117,6 +1108,24 @@ void intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state,
> panel->backlight.enabled = true;
> if (panel->backlight.device)
> panel->backlight.device->props.power = FB_BLANK_UNBLANK;
> +}
> +
> +void intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state,
> + const struct drm_connector_state *conn_state)
> +{
> + struct intel_connector *connector = to_intel_connector(conn_state->connector);
> + struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
> + struct intel_panel *panel = &connector->panel;
> + enum pipe pipe = to_intel_crtc(crtc_state->base.crtc)->pipe;
> +
> + if (!panel->backlight.present)
> + return;
> +
> + DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
> +
> + mutex_lock(&dev_priv->backlight_lock);
> +
> + __intel_panel_enable_backlight(crtc_state, conn_state);
>
> mutex_unlock(&dev_priv->backlight_lock);
> }
> @@ -1773,6 +1782,24 @@ static int pwm_setup_backlight(struct intel_connector *connector,
> return 0;
> }
>
> +void intel_panel_update_backlight(struct intel_encoder *encoder,
> + const struct intel_crtc_state *crtc_state,
> + const struct drm_connector_state *conn_state)
> +{
> + struct intel_connector *connector = to_intel_connector(conn_state->connector);
> + struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
> + struct intel_panel *panel = &connector->panel;
> +
> + if (!panel->backlight.present)
> + return;
> +
> + mutex_lock(&dev_priv->backlight_lock);
> + if (!panel->backlight.enabled)
> + __intel_panel_enable_backlight(crtc_state, conn_state);
> +
> + mutex_unlock(&dev_priv->backlight_lock);
> +}
> +
> int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe)
> {
> struct drm_i915_private *dev_priv = to_i915(connector->dev);
> diff --git a/drivers/gpu/drm/i915/vlv_dsi.c b/drivers/gpu/drm/i915/vlv_dsi.c
> index 361e962a7969..3dcf7ddca032 100644
> --- a/drivers/gpu/drm/i915/vlv_dsi.c
> +++ b/drivers/gpu/drm/i915/vlv_dsi.c
> @@ -1689,6 +1689,7 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
> intel_encoder->post_disable = intel_dsi_post_disable;
> intel_encoder->get_hw_state = intel_dsi_get_hw_state;
> intel_encoder->get_config = intel_dsi_get_config;
> + intel_encoder->update_pipe = intel_panel_update_backlight;
>
> intel_connector->get_hw_state = intel_connector_get_hw_state;
--
Jani Nikula, Intel Open Source Graphics Center
More information about the Intel-gfx
mailing list