]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: Use for_each_connector_in_state helper macro
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Tue, 21 Apr 2015 14:12:59 +0000 (17:12 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 8 May 2015 11:03:58 +0000 (13:03 +0200)
Simplifies looping over connector states a bit.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp_mst.c
drivers/gpu/drm/i915/intel_hdmi.c

index b8eabc65dc27c6855602f5a268691968290f1eb4..ec5d2eaef43ca75dc6b61026ae3227f8e60d1084 100644 (file)
@@ -584,17 +584,18 @@ intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
        struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
        struct intel_encoder *ret = NULL;
        struct drm_atomic_state *state;
+       struct drm_connector *connector;
+       struct drm_connector_state *connector_state;
        int num_encoders = 0;
        int i;
 
        state = crtc_state->base.state;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i] ||
-                   state->connector_states[i]->crtc != crtc_state->base.crtc)
+       for_each_connector_in_state(state, connector, connector_state, i) {
+               if (connector_state->crtc != crtc_state->base.crtc)
                        continue;
 
-               ret = to_intel_encoder(state->connector_states[i]->best_encoder);
+               ret = to_intel_encoder(connector_state->best_encoder);
                num_encoders++;
        }
 
index 1375f53cdc9584ed8eadcd45ec292425b5953460..b1f5038221d57f52f96cbe788b97eece7c7aabd3 100644 (file)
@@ -453,15 +453,12 @@ static bool intel_pipe_will_have_type(const struct intel_crtc_state *crtc_state,
                                      int type)
 {
        struct drm_atomic_state *state = crtc_state->base.state;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        struct intel_encoder *encoder;
        int i, num_connectors = 0;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != crtc_state->base.crtc)
                        continue;
 
@@ -7461,14 +7458,11 @@ static int i9xx_crtc_compute_clock(struct intel_crtc *crtc,
        struct intel_encoder *encoder;
        const intel_limit_t *limit;
        struct drm_atomic_state *state = crtc_state->base.state;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        int i;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != &crtc->base)
                        continue;
 
@@ -8152,16 +8146,13 @@ static int ironlake_get_refclk(struct intel_crtc_state *crtc_state)
        struct drm_device *dev = crtc_state->base.crtc->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_atomic_state *state = crtc_state->base.state;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        struct intel_encoder *encoder;
        int num_connectors = 0, i;
        bool is_lvds = false;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != crtc_state->base.crtc)
                        continue;
 
@@ -8415,17 +8406,14 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc,
        struct drm_device *dev = crtc->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_atomic_state *state = crtc_state->base.state;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        struct intel_encoder *encoder;
        uint32_t dpll;
        int factor, num_connectors = 0, i;
        bool is_lvds = false, is_sdvo = false;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != crtc_state->base.crtc)
                        continue;
 
@@ -11149,7 +11137,8 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc,
 {
        struct drm_device *dev = crtc->base.dev;
        struct drm_atomic_state *state;
-       struct intel_connector *connector;
+       struct drm_connector *connector;
+       struct drm_connector_state *connector_state;
        int bpp, i;
 
        if ((IS_G4X(dev) || IS_VALLEYVIEW(dev)))
@@ -11165,15 +11154,12 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc,
        state = pipe_config->base.state;
 
        /* Clamp display bpp to EDID value */
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector = to_intel_connector(state->connectors[i]);
-               if (state->connector_states[i]->crtc != &crtc->base)
+       for_each_connector_in_state(state, connector, connector_state, i) {
+               if (connector_state->crtc != &crtc->base)
                        continue;
 
-               connected_sink_compute_bpp(connector, pipe_config);
+               connected_sink_compute_bpp(to_intel_connector(connector),
+                                          pipe_config);
        }
 
        return bpp;
@@ -11300,14 +11286,11 @@ static bool check_single_encoder_cloning(struct drm_atomic_state *state,
                                         struct intel_encoder *encoder)
 {
        struct intel_encoder *source_encoder;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        int i;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != &crtc->base)
                        continue;
 
@@ -11324,14 +11307,11 @@ static bool check_encoder_cloning(struct drm_atomic_state *state,
                                  struct intel_crtc *crtc)
 {
        struct intel_encoder *encoder;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        int i;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != &crtc->base)
                        continue;
 
@@ -11347,6 +11327,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
 {
        struct drm_device *dev = state->dev;
        struct intel_encoder *encoder;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        unsigned int used_ports = 0;
        int i;
@@ -11356,11 +11337,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
         * list to detect the problem on ddi platforms
         * where there's just one encoder per digital port.
         */
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (!connector_state->best_encoder)
                        continue;
 
@@ -11411,7 +11388,7 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
                          struct drm_atomic_state *state)
 {
        struct intel_encoder *encoder;
-       struct intel_connector *connector;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        struct intel_crtc_state *pipe_config;
        int base_bpp, ret = -EINVAL;
@@ -11489,12 +11466,7 @@ encoder_retry:
         * adjust it according to limitations or connector properties, and also
         * a chance to reject the mode entirely.
         */
-       for (i = 0; i < state->num_connector; i++) {
-               connector = to_intel_connector(state->connectors[i]);
-               if (!connector)
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != crtc)
                        continue;
 
index 3945057c5bbeb9f1a93ab52fda0550a3dce22b52..6e4cc5334f47d7105b60c0bec72fccfb4875ddac 100644 (file)
@@ -40,7 +40,9 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
        int bpp, i;
        int lane_count, slots, rate;
        struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
-       struct intel_connector *found = NULL;
+       struct drm_connector *drm_connector;
+       struct intel_connector *connector, *found = NULL;
+       struct drm_connector_state *connector_state;
        int mst_pbn;
 
        pipe_config->dp_encoder_is_mst = true;
@@ -70,12 +72,11 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
 
        state = pipe_config->base.state;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
+       for_each_connector_in_state(state, drm_connector, connector_state, i) {
+               connector = to_intel_connector(drm_connector);
 
-               if (state->connector_states[i]->best_encoder == &encoder->base) {
-                       found = to_intel_connector(state->connectors[i]);
+               if (connector_state->best_encoder == &encoder->base) {
+                       found = connector;
                        break;
                }
        }
index 65bc3867dda21048754c06c3039f4a8e134eeef5..590d46b124e036dd795c91bba5af7b3872213349 100644 (file)
@@ -964,6 +964,7 @@ static bool hdmi_12bpc_possible(struct intel_crtc_state *crtc_state)
        struct drm_device *dev = crtc_state->base.crtc->dev;
        struct drm_atomic_state *state;
        struct intel_encoder *encoder;
+       struct drm_connector *connector;
        struct drm_connector_state *connector_state;
        int count = 0, count_hdmi = 0;
        int i;
@@ -973,11 +974,7 @@ static bool hdmi_12bpc_possible(struct intel_crtc_state *crtc_state)
 
        state = crtc_state->base.state;
 
-       for (i = 0; i < state->num_connector; i++) {
-               if (!state->connectors[i])
-                       continue;
-
-               connector_state = state->connector_states[i];
+       for_each_connector_in_state(state, connector, connector_state, i) {
                if (connector_state->crtc != crtc_state->base.crtc)
                        continue;