drm/i915: Pass crtc_state and connector state to backlight enable/disable functions
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Mon, 12 Jun 2017 10:21:13 +0000 (12:21 +0200)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Mon, 12 Jun 2017 14:05:45 +0000 (16:05 +0200)
The backlight functions need to determine the pipe and the transcoder the
backlight will be enabled on, so pass crtc_state instead of trying to
dereference the state without holding locks.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100022
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170612102115.23665-2-maarten.lankhorst@linux.intel.com
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_panel.c

index 8bac62805cd10a47998f5c26ca60394eb296810a..2d35d97d170ebb3ee56ee291994c1412f84df7d0 100644 (file)
@@ -1845,7 +1845,7 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder,
                if (port == PORT_A && INTEL_GEN(dev_priv) < 9)
                        intel_dp_stop_link_train(intel_dp);
 
-               intel_edp_backlight_on(intel_dp);
+               intel_edp_backlight_on(pipe_config, conn_state);
                intel_psr_enable(intel_dp);
                intel_edp_drrs_enable(intel_dp, pipe_config);
        }
@@ -1875,7 +1875,7 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder,
 
                intel_edp_drrs_disable(intel_dp, old_crtc_state);
                intel_psr_disable(intel_dp);
-               intel_edp_backlight_off(intel_dp);
+               intel_edp_backlight_off(old_conn_state);
        }
 }
 
index d2fd8b67bb8a20d8406f6d496c4bfd20574908fc..d1ee278064b7fadcb66d63404cdcc9578cbbca2a 100644 (file)
@@ -2338,14 +2338,17 @@ static void _intel_edp_backlight_on(struct intel_dp *intel_dp)
 }
 
 /* Enable backlight PWM and backlight PP control. */
-void intel_edp_backlight_on(struct intel_dp *intel_dp)
+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(conn_state->best_encoder);
+
        if (!is_edp(intel_dp))
                return;
 
        DRM_DEBUG_KMS("\n");
 
-       intel_panel_enable_backlight(intel_dp->attached_connector);
+       intel_panel_enable_backlight(crtc_state, conn_state);
        _intel_edp_backlight_on(intel_dp);
 }
 
@@ -2377,15 +2380,17 @@ static void _intel_edp_backlight_off(struct intel_dp *intel_dp)
 }
 
 /* Disable backlight PP control and backlight PWM. */
-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(old_conn_state->best_encoder);
+
        if (!is_edp(intel_dp))
                return;
 
        DRM_DEBUG_KMS("\n");
 
        _intel_edp_backlight_off(intel_dp);
-       intel_panel_disable_backlight(intel_dp->attached_connector);
+       intel_panel_disable_backlight(old_conn_state);
 }
 
 /*
@@ -2681,7 +2686,7 @@ static void intel_disable_dp(struct intel_encoder *encoder,
        /* Make sure the panel is off before trying to change the mode. But also
         * ensure that we have vdd while we switch off the panel. */
        intel_edp_panel_vdd_on(intel_dp);
-       intel_edp_backlight_off(intel_dp);
+       intel_edp_backlight_off(old_conn_state);
        intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
        intel_edp_panel_off(intel_dp);
 
@@ -2895,10 +2900,8 @@ static void g4x_enable_dp(struct intel_encoder *encoder,
                          struct intel_crtc_state *pipe_config,
                          struct drm_connector_state *conn_state)
 {
-       struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
-
        intel_enable_dp(encoder, pipe_config, conn_state);
-       intel_edp_backlight_on(intel_dp);
+       intel_edp_backlight_on(pipe_config, conn_state);
 }
 
 static void vlv_enable_dp(struct intel_encoder *encoder,
@@ -2907,7 +2910,7 @@ static void vlv_enable_dp(struct intel_encoder *encoder,
 {
        struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
 
-       intel_edp_backlight_on(intel_dp);
+       intel_edp_backlight_on(pipe_config, conn_state);
        intel_psr_enable(intel_dp);
 }
 
index ac5cd41ab4209ac0bb8d93cab65f4f1b0315ddd8..f08899becfe2028ac1645dbd46e1341896c8c886 100644 (file)
@@ -1527,8 +1527,9 @@ bool intel_dp_compute_config(struct intel_encoder *encoder,
 bool intel_dp_is_edp(struct drm_i915_private *dev_priv, enum port port);
 enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
                                  bool long_hpd);
-void intel_edp_backlight_on(struct intel_dp *intel_dp);
-void intel_edp_backlight_off(struct intel_dp *intel_dp);
+void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state,
+                           const struct drm_connector_state *conn_state);
+void intel_edp_backlight_off(const struct drm_connector_state *conn_state);
 void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
 void intel_edp_panel_on(struct intel_dp *intel_dp);
 void intel_edp_panel_off(struct intel_dp *intel_dp);
@@ -1715,8 +1716,9 @@ void intel_panel_set_backlight_acpi(struct intel_connector *connector,
                                    u32 level, u32 max);
 int intel_panel_setup_backlight(struct drm_connector *connector,
                                enum pipe pipe);
-void intel_panel_enable_backlight(struct intel_connector *connector);
-void intel_panel_disable_backlight(struct intel_connector *connector);
+void intel_panel_enable_backlight(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);
 void intel_panel_destroy_backlight(struct drm_connector *connector);
 enum drm_connector_status intel_panel_detect(struct drm_i915_private *dev_priv);
 extern struct drm_display_mode *intel_find_panel_downclock(
index 54030b68406a7aaca3e0f5d4d90403e4a1084333..721f3f3adc1e0416746443e210525abce00444ef 100644 (file)
@@ -835,7 +835,7 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder,
                intel_dsi_port_enable(encoder);
        }
 
-       intel_panel_enable_backlight(intel_dsi->attached_connector);
+       intel_panel_enable_backlight(pipe_config, conn_state);
        intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_BACKLIGHT_ON);
 }
 
@@ -866,7 +866,7 @@ static void intel_dsi_disable(struct intel_encoder *encoder,
        DRM_DEBUG_KMS("\n");
 
        intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_BACKLIGHT_OFF);
-       intel_panel_disable_backlight(intel_dsi->attached_connector);
+       intel_panel_disable_backlight(old_conn_state);
 
        /*
         * Disable Device ready before the port shutdown in order
index d2c2bca1b327182c4395a12035dfde1ea44ae923..6fe5d7c3bc23bf149e67ab4af228efbd5bf0642c 100644 (file)
@@ -311,8 +311,6 @@ static void intel_enable_lvds(struct intel_encoder *encoder,
 {
        struct drm_device *dev = encoder->base.dev;
        struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
-       struct intel_connector *intel_connector =
-               &lvds_encoder->attached_connector->base;
        struct drm_i915_private *dev_priv = to_i915(dev);
 
        I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) | LVDS_PORT_EN);
@@ -322,7 +320,7 @@ static void intel_enable_lvds(struct intel_encoder *encoder,
        if (intel_wait_for_register(dev_priv, PP_STATUS(0), PP_ON, PP_ON, 1000))
                DRM_ERROR("timed out waiting for panel to power on\n");
 
-       intel_panel_enable_backlight(intel_connector);
+       intel_panel_enable_backlight(pipe_config, conn_state);
 }
 
 static void intel_disable_lvds(struct intel_encoder *encoder,
@@ -345,11 +343,7 @@ static void gmch_disable_lvds(struct intel_encoder *encoder,
                              struct drm_connector_state *old_conn_state)
 
 {
-       struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
-       struct intel_connector *intel_connector =
-               &lvds_encoder->attached_connector->base;
-
-       intel_panel_disable_backlight(intel_connector);
+       intel_panel_disable_backlight(old_conn_state);
 
        intel_disable_lvds(encoder, old_crtc_state, old_conn_state);
 }
@@ -358,11 +352,7 @@ static void pch_disable_lvds(struct intel_encoder *encoder,
                             struct intel_crtc_state *old_crtc_state,
                             struct drm_connector_state *old_conn_state)
 {
-       struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
-       struct intel_connector *intel_connector =
-               &lvds_encoder->attached_connector->base;
-
-       intel_panel_disable_backlight(intel_connector);
+       intel_panel_disable_backlight(old_conn_state);
 }
 
 static void pch_post_disable_lvds(struct intel_encoder *encoder,
index 4114cb3f14e71c7dbf6fde046afbdf8b7ee1faf8..2567533544aa411a437926df404d8e1149cad2b4 100644 (file)
@@ -819,8 +819,9 @@ static void pwm_disable_backlight(struct intel_connector *connector)
        pwm_disable(panel->backlight.pwm);
 }
 
-void intel_panel_disable_backlight(struct intel_connector *connector)
+void intel_panel_disable_backlight(const struct drm_connector_state *old_conn_state)
 {
+       struct intel_connector *connector = to_intel_connector(old_conn_state->connector);
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
        struct intel_panel *panel = &connector->panel;
 
@@ -1136,17 +1137,18 @@ static void pwm_enable_backlight(struct intel_connector *connector)
        intel_panel_actually_set_backlight(connector, panel->backlight.level);
 }
 
-void intel_panel_enable_backlight(struct intel_connector *connector)
+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 = intel_get_pipe_from_connector(connector);
+       enum pipe pipe = to_intel_crtc(crtc_state->base.crtc)->pipe;
 
        if (!panel->backlight.present)
                return;
 
-       if (!WARN_ON_ONCE(pipe == INVALID_PIPE))
-               DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
+       DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
 
        mutex_lock(&dev_priv->backlight_lock);