drm/i915: Don't use staged config in check_encoder_cloning()
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Thu, 2 Apr 2015 11:48:00 +0000 (14:48 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 10 Apr 2015 06:55:57 +0000 (08:55 +0200)
Reduce dependency on the staged config by using the atomic state
instead.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c

index b1fbe9d994ffc70588c3684d2ac26e484310fcb1..bc8e221a30d1750a8e6f376a13dfb27960663a3a 100644 (file)
@@ -10625,16 +10625,24 @@ static bool encoders_cloneable(const struct intel_encoder *a,
                          b->cloneable & (1 << a->type));
 }
 
-static bool check_single_encoder_cloning(struct intel_crtc *crtc,
+static bool check_single_encoder_cloning(struct drm_atomic_state *state,
+                                        struct intel_crtc *crtc,
                                         struct intel_encoder *encoder)
 {
-       struct drm_device *dev = crtc->base.dev;
        struct intel_encoder *source_encoder;
+       struct drm_connector_state *connector_state;
+       int i;
 
-       for_each_intel_encoder(dev, source_encoder) {
-               if (source_encoder->new_crtc != crtc)
+       for (i = 0; i < state->num_connector; i++) {
+               if (!state->connectors[i])
                        continue;
 
+               connector_state = state->connector_states[i];
+               if (connector_state->crtc != &crtc->base)
+                       continue;
+
+               source_encoder =
+                       to_intel_encoder(connector_state->best_encoder);
                if (!encoders_cloneable(encoder, source_encoder))
                        return false;
        }
@@ -10642,16 +10650,23 @@ static bool check_single_encoder_cloning(struct intel_crtc *crtc,
        return true;
 }
 
-static bool check_encoder_cloning(struct intel_crtc *crtc)
+static bool check_encoder_cloning(struct drm_atomic_state *state,
+                                 struct intel_crtc *crtc)
 {
-       struct drm_device *dev = crtc->base.dev;
        struct intel_encoder *encoder;
+       struct drm_connector_state *connector_state;
+       int i;
 
-       for_each_intel_encoder(dev, encoder) {
-               if (encoder->new_crtc != crtc)
+       for (i = 0; i < state->num_connector; i++) {
+               if (!state->connectors[i])
                        continue;
 
-               if (!check_single_encoder_cloning(crtc, encoder))
+               connector_state = state->connector_states[i];
+               if (connector_state->crtc != &crtc->base)
+                       continue;
+
+               encoder = to_intel_encoder(connector_state->best_encoder);
+               if (!check_single_encoder_cloning(state, crtc, encoder))
                        return false;
        }
 
@@ -10731,7 +10746,7 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
        int i;
        bool retry = true;
 
-       if (!check_encoder_cloning(to_intel_crtc(crtc))) {
+       if (!check_encoder_cloning(state, to_intel_crtc(crtc))) {
                DRM_DEBUG_KMS("rejecting invalid cloning configuration\n");
                return ERR_PTR(-EINVAL);
        }