Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3fcc808 authored by Damien Lespiau's avatar Damien Lespiau Committed by Daniel Vetter
Browse files

drm/i915: Use for_each_intel_crtc() when iterating through intel_crtcs



Generated using the semantic patch:

  @@
  iterator name list_for_each_entry;
  iterator name for_each_intel_crtc;
  struct intel_crtc * crtc;
  struct drm_device * dev;
  @@
  -list_for_each_entry(crtc,&dev->mode_config.crtc_list,...) {
  +for_each_intel_crtc(dev,crtc) {
	...
  }

Followed by a couple of fixups by hand (that spatch doesn't match the
cases where list_for_each_entry() is not followed by a set of '{', '}',
but I couldn't figure out a way to leave the '{' out of the iterator
match).

Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent d063ae48
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -514,7 +514,7 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)
	unsigned long flags;
	unsigned long flags;
	struct intel_crtc *crtc;
	struct intel_crtc *crtc;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		const char pipe = pipe_name(crtc->pipe);
		const char pipe = pipe_name(crtc->pipe);
		const char plane = plane_name(crtc->plane);
		const char plane = plane_name(crtc->plane);
		struct intel_unpin_work *work;
		struct intel_unpin_work *work;
@@ -2345,7 +2345,7 @@ static int i915_display_info(struct seq_file *m, void *unused)
	drm_modeset_lock_all(dev);
	drm_modeset_lock_all(dev);
	seq_printf(m, "CRTC info\n");
	seq_printf(m, "CRTC info\n");
	seq_printf(m, "---------\n");
	seq_printf(m, "---------\n");
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		bool active;
		bool active;
		int x, y;
		int x, y;


+20 −33
Original line number Original line Diff line number Diff line
@@ -3261,7 +3261,7 @@ bool intel_has_pending_fb_unpin(struct drm_device *dev)
	 * cannot claim and pin a new fb without at least acquring the
	 * cannot claim and pin a new fb without at least acquring the
	 * struct_mutex and so serialising with us.
	 * struct_mutex and so serialising with us.
	 */
	 */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		if (atomic_read(&crtc->unpin_work_count) == 0)
		if (atomic_read(&crtc->unpin_work_count) == 0)
			continue;
			continue;


@@ -3993,7 +3993,7 @@ static void haswell_mode_set_planes_workaround(struct intel_crtc *crtc)


	/* We want to get the other_active_crtc only if there's only 1 other
	/* We want to get the other_active_crtc only if there's only 1 other
	 * active crtc. */
	 * active crtc. */
	list_for_each_entry(crtc_it, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc_it) {
		if (!crtc_it->active || crtc_it == crtc)
		if (!crtc_it->active || crtc_it == crtc)
			continue;
			continue;


@@ -4312,7 +4312,7 @@ static void modeset_update_crtc_power_domains(struct drm_device *dev)
	 * First get all needed power domains, then put all unneeded, to avoid
	 * First get all needed power domains, then put all unneeded, to avoid
	 * any unnecessary toggling of the power wells.
	 * any unnecessary toggling of the power wells.
	 */
	 */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		enum intel_display_power_domain domain;
		enum intel_display_power_domain domain;


		if (!crtc->base.enabled)
		if (!crtc->base.enabled)
@@ -4324,7 +4324,7 @@ static void modeset_update_crtc_power_domains(struct drm_device *dev)
			intel_display_power_get(dev_priv, domain);
			intel_display_power_get(dev_priv, domain);
	}
	}


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		enum intel_display_power_domain domain;
		enum intel_display_power_domain domain;


		for_each_power_domain(domain, crtc->enabled_power_domains)
		for_each_power_domain(domain, crtc->enabled_power_domains)
@@ -4458,8 +4458,7 @@ static int intel_mode_max_pixclk(struct drm_i915_private *dev_priv)
	struct intel_crtc *intel_crtc;
	struct intel_crtc *intel_crtc;
	int max_pixclk = 0;
	int max_pixclk = 0;


	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, intel_crtc) {
			    base.head) {
		if (intel_crtc->new_enabled)
		if (intel_crtc->new_enabled)
			max_pixclk = max(max_pixclk,
			max_pixclk = max(max_pixclk,
					 intel_crtc->new_config->adjusted_mode.crtc_clock);
					 intel_crtc->new_config->adjusted_mode.crtc_clock);
@@ -4480,8 +4479,7 @@ static void valleyview_modeset_global_pipes(struct drm_device *dev,
		return;
		return;


	/* disable/enable all currently active pipes while we change cdclk */
	/* disable/enable all currently active pipes while we change cdclk */
	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, intel_crtc)
			    base.head)
		if (intel_crtc->base.enabled)
		if (intel_crtc->base.enabled)
			*prepare_pipes |= (1 << intel_crtc->pipe);
			*prepare_pipes |= (1 << intel_crtc->pipe);
}
}
@@ -7120,7 +7118,7 @@ static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv)
	struct intel_ddi_plls *plls = &dev_priv->ddi_plls;
	struct intel_ddi_plls *plls = &dev_priv->ddi_plls;
	struct intel_crtc *crtc;
	struct intel_crtc *crtc;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head)
	for_each_intel_crtc(dev, crtc)
		WARN(crtc->active, "CRTC for pipe %c enabled\n",
		WARN(crtc->active, "CRTC for pipe %c enabled\n",
		     pipe_name(crtc->pipe));
		     pipe_name(crtc->pipe));


@@ -9298,8 +9296,7 @@ static void intel_modeset_update_staged_output_state(struct drm_device *dev)
			to_intel_crtc(encoder->base.crtc);
			to_intel_crtc(encoder->base.crtc);
	}
	}


	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		crtc->new_enabled = crtc->base.enabled;
		crtc->new_enabled = crtc->base.enabled;


		if (crtc->new_enabled)
		if (crtc->new_enabled)
@@ -9330,8 +9327,7 @@ static void intel_modeset_commit_output_state(struct drm_device *dev)
		encoder->base.crtc = &encoder->new_crtc->base;
		encoder->base.crtc = &encoder->new_crtc->base;
	}
	}


	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		crtc->base.enabled = crtc->new_enabled;
		crtc->base.enabled = crtc->new_enabled;
	}
	}
}
}
@@ -9685,8 +9681,7 @@ intel_modeset_affected_pipes(struct drm_crtc *crtc, unsigned *modeset_pipes,
	}
	}


	/* Check for pipes that will be enabled/disabled ... */
	/* Check for pipes that will be enabled/disabled ... */
	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, intel_crtc) {
			    base.head) {
		if (intel_crtc->base.enabled == intel_crtc->new_enabled)
		if (intel_crtc->base.enabled == intel_crtc->new_enabled)
			continue;
			continue;


@@ -9759,8 +9754,7 @@ intel_modeset_update_state(struct drm_device *dev, unsigned prepare_pipes)
	intel_modeset_commit_output_state(dev);
	intel_modeset_commit_output_state(dev);


	/* Double check state. */
	/* Double check state. */
	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, intel_crtc) {
			    base.head) {
		WARN_ON(intel_crtc->base.enabled != intel_crtc_in_use(&intel_crtc->base));
		WARN_ON(intel_crtc->base.enabled != intel_crtc_in_use(&intel_crtc->base));
		WARN_ON(intel_crtc->new_config &&
		WARN_ON(intel_crtc->new_config &&
			intel_crtc->new_config != &intel_crtc->config);
			intel_crtc->new_config != &intel_crtc->config);
@@ -10038,8 +10032,7 @@ check_crtc_state(struct drm_device *dev)
	struct intel_encoder *encoder;
	struct intel_encoder *encoder;
	struct intel_crtc_config pipe_config;
	struct intel_crtc_config pipe_config;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		bool enabled = false;
		bool enabled = false;
		bool active = false;
		bool active = false;


@@ -10128,8 +10121,7 @@ check_shared_dpll_state(struct drm_device *dev)
		     "pll on state mismatch (expected %i, found %i)\n",
		     "pll on state mismatch (expected %i, found %i)\n",
		     pll->on, active);
		     pll->on, active);


		list_for_each_entry(crtc, &dev->mode_config.crtc_list,
		for_each_intel_crtc(dev, crtc) {
				    base.head) {
			if (crtc->base.enabled && intel_crtc_to_shared_dpll(crtc) == pll)
			if (crtc->base.enabled && intel_crtc_to_shared_dpll(crtc) == pll)
				enabled_crtcs++;
				enabled_crtcs++;
			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
@@ -10370,7 +10362,7 @@ static void intel_set_config_restore_state(struct drm_device *dev,
	int count;
	int count;


	count = 0;
	count = 0;
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		crtc->new_enabled = config->save_crtc_enabled[count++];
		crtc->new_enabled = config->save_crtc_enabled[count++];


		if (crtc->new_enabled)
		if (crtc->new_enabled)
@@ -10560,8 +10552,7 @@ intel_modeset_stage_output_state(struct drm_device *dev,
	}
	}
	/* Now we've also updated encoder->new_crtc for all encoders. */
	/* Now we've also updated encoder->new_crtc for all encoders. */


	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		crtc->new_enabled = false;
		crtc->new_enabled = false;


		list_for_each_entry(encoder,
		list_for_each_entry(encoder,
@@ -10774,7 +10765,7 @@ static void ibx_pch_dpll_disable(struct drm_i915_private *dev_priv,
	struct intel_crtc *crtc;
	struct intel_crtc *crtc;


	/* Make sure no transcoder isn't still depending on us. */
	/* Make sure no transcoder isn't still depending on us. */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, crtc) {
		if (intel_crtc_to_shared_dpll(crtc) == pll)
		if (intel_crtc_to_shared_dpll(crtc) == pll)
			assert_pch_transcoder_disabled(dev_priv, crtc->pipe);
			assert_pch_transcoder_disabled(dev_priv, crtc->pipe);
	}
	}
@@ -11627,8 +11618,7 @@ void intel_modeset_init(struct drm_device *dev)
	intel_modeset_setup_hw_state(dev, false);
	intel_modeset_setup_hw_state(dev, false);
	mutex_unlock(&dev->mode_config.mutex);
	mutex_unlock(&dev->mode_config.mutex);


	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		if (!crtc->active)
		if (!crtc->active)
			continue;
			continue;


@@ -11889,8 +11879,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
	struct intel_connector *connector;
	struct intel_connector *connector;
	int i;
	int i;


	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		memset(&crtc->config, 0, sizeof(crtc->config));
		memset(&crtc->config, 0, sizeof(crtc->config));


		crtc->config.quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
		crtc->config.quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
@@ -11915,8 +11904,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)


		pll->on = pll->get_hw_state(dev_priv, pll, &pll->hw_state);
		pll->on = pll->get_hw_state(dev_priv, pll, &pll->hw_state);
		pll->active = 0;
		pll->active = 0;
		list_for_each_entry(crtc, &dev->mode_config.crtc_list,
		for_each_intel_crtc(dev, crtc) {
				    base.head) {
			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
				pll->active++;
				pll->active++;
		}
		}
@@ -11981,8 +11969,7 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
	 * Note that this could go away if we move to using crtc_config
	 * Note that this could go away if we move to using crtc_config
	 * checking everywhere.
	 * checking everywhere.
	 */
	 */
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
	for_each_intel_crtc(dev, crtc) {
			    base.head) {
		if (crtc->active && i915.fastboot) {
		if (crtc->active && i915.fastboot) {
			intel_mode_from_pipe_config(&crtc->base.mode, &crtc->config);
			intel_mode_from_pipe_config(&crtc->base.mode, &crtc->config);
			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
+3 −3
Original line number Original line Diff line number Diff line
@@ -2170,7 +2170,7 @@ static void ilk_compute_wm_config(struct drm_device *dev,
	struct intel_crtc *intel_crtc;
	struct intel_crtc *intel_crtc;


	/* Compute the currently _active_ config */
	/* Compute the currently _active_ config */
	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, intel_crtc) {
		const struct intel_pipe_wm *wm = &intel_crtc->wm.active;
		const struct intel_pipe_wm *wm = &intel_crtc->wm.active;


		if (!wm->pipe_enabled)
		if (!wm->pipe_enabled)
@@ -2254,7 +2254,7 @@ static void ilk_merge_wm_level(struct drm_device *dev,


	ret_wm->enable = true;
	ret_wm->enable = true;


	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, intel_crtc) {
		const struct intel_pipe_wm *active = &intel_crtc->wm.active;
		const struct intel_pipe_wm *active = &intel_crtc->wm.active;
		const struct intel_wm_level *wm = &active->wm[level];
		const struct intel_wm_level *wm = &active->wm[level];


@@ -2400,7 +2400,7 @@ static void ilk_compute_wm_results(struct drm_device *dev,
	}
	}


	/* LP0 register values */
	/* LP0 register values */
	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head) {
	for_each_intel_crtc(dev, intel_crtc) {
		enum pipe pipe = intel_crtc->pipe;
		enum pipe pipe = intel_crtc->pipe;
		const struct intel_wm_level *r =
		const struct intel_wm_level *r =
			&intel_crtc->wm.active.wm[0];
			&intel_crtc->wm.active.wm[0];