From: Daniel Vetter <daniel.vetter@ffwll.ch> To: Intel Graphics Development <intel-gfx@lists.freedesktop.org> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Subject: [PATCH] drm/i915: introduce for_each_encoder_on_crtc Date: Thu, 5 Jul 2012 09:50:24 +0200 Message-ID: <1341474624-27720-1-git-send-email-daniel.vetter@ffwll.ch> (raw) In-Reply-To: <CA+gsUGQ6BarhCCmTMwrN8+2fib4jv3BWn+GtZOeEHtgx=zDgvg@mail.gmail.com> We already have this pattern at quite a few places, and moving part of the modeset helper stuff into the driver will add more. v2: Don't clobber the crtc struct name with the macro parameter ... v3: Convert two more places noticed by Paulo Zanoni. Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch> --- drivers/gpu/drm/i915/i915_drv.h | 4 +++ drivers/gpu/drm/i915/intel_display.c | 38 ++++++++------------------------- drivers/gpu/drm/i915/intel_dp.c | 22 +++++-------------- drivers/gpu/drm/i915/intel_lvds.c | 6 ++-- drivers/gpu/drm/i915/intel_tv.c | 10 ++------ 5 files changed, 25 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a0c15ab..aa24fc1 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -79,6 +79,10 @@ enum port { #define for_each_pipe(p) for ((p) = 0; (p) < dev_priv->num_pipe; (p)++) +#define for_each_encoder_on_crtc(dev, __crtc, intel_encoder) \ + list_for_each_entry((intel_encoder), &(dev)->mode_config.encoder_list, base.head) \ + if ((intel_encoder)->base.crtc == (__crtc)) + struct intel_pch_pll { int refcount; /* count of number of CRTCs sharing this PLL */ int active; /* count of number of active CRTCs (i.e. DPMS on) */ diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 3fbc802..72b73f8 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -627,11 +627,10 @@ static void intel_clock(struct drm_device *dev, int refclk, intel_clock_t *clock bool intel_pipe_has_type(struct drm_crtc *crtc, int type) { struct drm_device *dev = crtc->dev; - struct drm_mode_config *mode_config = &dev->mode_config; struct intel_encoder *encoder; - list_for_each_entry(encoder, &mode_config->encoder_list, base.head) - if (encoder->base.crtc == crtc && encoder->type == type) + for_each_encoder_on_crtc(dev, crtc, encoder) + if (encoder->type == type) return true; return false; @@ -2805,16 +2804,13 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) static bool intel_crtc_driving_pch(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; - struct drm_mode_config *mode_config = &dev->mode_config; struct intel_encoder *encoder; /* * If there's a non-PCH eDP on this crtc, it must be DP_A, and that * must be driven by its own crtc; no sharing is possible. */ - list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { - if (encoder->base.crtc != crtc) - continue; + for_each_encoder_on_crtc(dev, crtc, encoder) { /* On Haswell, LPT PCH handles the VGA connection via FDI, and Haswell * CPU handles all others */ @@ -3703,16 +3699,12 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, { struct drm_device *dev = crtc->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct drm_encoder *encoder; struct drm_connector *connector; + struct intel_encoder *intel_encoder; unsigned int display_bpc = UINT_MAX, bpc; /* Walk the encoders & connectors on this crtc, get min bpc */ - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { - struct intel_encoder *intel_encoder = to_intel_encoder(encoder); - - if (encoder->crtc != crtc) - continue; + for_each_encoder_on_crtc(dev, crtc, intel_encoder) { if (intel_encoder->type == INTEL_OUTPUT_LVDS) { unsigned int lvds_bpc; @@ -3744,7 +3736,7 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, /* Not one of the known troublemakers, check the EDID */ list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - if (connector->encoder != encoder) + if (connector->encoder != &intel_encoder->base) continue; /* Don't use an invalid EDID bpc value */ @@ -4213,15 +4205,11 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, u32 dspcntr, pipeconf, vsyncshift; bool ok, has_reduced_clock = false, is_sdvo = false; bool is_lvds = false, is_tv = false, is_dp = false; - struct drm_mode_config *mode_config = &dev->mode_config; struct intel_encoder *encoder; const intel_limit_t *limit; int ret; - list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { - if (encoder->base.crtc != crtc) - continue; - + for_each_encoder_on_crtc(dev, crtc, encoder) { switch (encoder->type) { case INTEL_OUTPUT_LVDS: is_lvds = true; @@ -4524,15 +4512,11 @@ static int ironlake_get_refclk(struct drm_crtc *crtc) struct drm_device *dev = crtc->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_encoder *encoder; - struct drm_mode_config *mode_config = &dev->mode_config; struct intel_encoder *edp_encoder = NULL; int num_connectors = 0; bool is_lvds = false; - list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { - if (encoder->base.crtc != crtc) - continue; - + for_each_encoder_on_crtc(dev, crtc, encoder) { switch (encoder->type) { case INTEL_OUTPUT_LVDS: is_lvds = true; @@ -4569,7 +4553,6 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, u32 dpll, fp = 0, fp2 = 0, dspcntr, pipeconf; bool ok, has_reduced_clock = false, is_sdvo = false; bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; - struct drm_mode_config *mode_config = &dev->mode_config; struct intel_encoder *encoder, *edp_encoder = NULL; const intel_limit_t *limit; int ret; @@ -4580,10 +4563,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, bool dither; bool is_cpu_edp = false, is_pch_edp = false; - list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { - if (encoder->base.crtc != crtc) - continue; - + for_each_encoder_on_crtc(dev, crtc, encoder) { switch (encoder->type) { case INTEL_OUTPUT_LVDS: is_lvds = true; diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 76a7080..096947d 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -793,8 +793,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { struct drm_device *dev = crtc->dev; - struct drm_mode_config *mode_config = &dev->mode_config; - struct drm_encoder *encoder; + struct intel_encoder *encoder; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); int lane_count = 4; @@ -804,13 +803,9 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, /* * Find the lane count in the intel_encoder private */ - list_for_each_entry(encoder, &mode_config->encoder_list, head) { - struct intel_dp *intel_dp; + for_each_encoder_on_crtc(dev, crtc, encoder) { + struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); - if (encoder->crtc != crtc) - continue; - - intel_dp = enc_to_intel_dp(encoder); if (intel_dp->base.type == INTEL_OUTPUT_DISPLAYPORT || intel_dp->base.type == INTEL_OUTPUT_EDP) { @@ -2404,16 +2399,11 @@ int intel_trans_dp_port_sel(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; - struct drm_mode_config *mode_config = &dev->mode_config; - struct drm_encoder *encoder; + struct intel_encoder *encoder; - list_for_each_entry(encoder, &mode_config->encoder_list, head) { - struct intel_dp *intel_dp; - - if (encoder->crtc != crtc) - continue; + for_each_encoder_on_crtc(dev, crtc, encoder) { + struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); - intel_dp = enc_to_intel_dp(encoder); if (intel_dp->base.type == INTEL_OUTPUT_DISPLAYPORT || intel_dp->base.type == INTEL_OUTPUT_EDP) return intel_dp->output_reg; diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index 05fcadb..9b706a5 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c @@ -236,7 +236,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); struct intel_lvds *intel_lvds = to_intel_lvds(encoder); - struct drm_encoder *tmp_encoder; + struct intel_encoder *tmp_encoder; u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; int pipe; @@ -247,8 +247,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, } /* Should never happen!! */ - list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, head) { - if (tmp_encoder != encoder && tmp_encoder->crtc == encoder->crtc) { + for_each_encoder_on_crtc(dev, encoder->crtc, tmp_encoder) { + if (&tmp_encoder->base != encoder) { DRM_ERROR("Can't enable LVDS and another " "encoder on the same pipe\n"); return false; diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c index a233a51..3b413c9 100644 --- a/drivers/gpu/drm/i915/intel_tv.c +++ b/drivers/gpu/drm/i915/intel_tv.c @@ -895,20 +895,16 @@ intel_tv_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { struct drm_device *dev = encoder->dev; - struct drm_mode_config *drm_config = &dev->mode_config; struct intel_tv *intel_tv = enc_to_intel_tv(encoder); const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); - struct drm_encoder *other_encoder; + struct intel_encoder *other_encoder; if (!tv_mode) return false; - /* FIXME: lock encoder list */ - list_for_each_entry(other_encoder, &drm_config->encoder_list, head) { - if (other_encoder != encoder && - other_encoder->crtc == encoder->crtc) + for_each_encoder_on_crtc(dev, encoder->crtc, other_encoder) + if (&other_encoder->base != encoder) return false; - } adjusted_mode->clock = tv_mode->clock; return true; -- 1.7.7.6
next prev parent reply index Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-07-03 9:27 [PATCH 00/43] [RFC] modeset rework, part 1 Daniel Vetter 2012-07-03 9:27 ` [PATCH 01/43] drm/i915: introduce for_each_encoder_on_crtc Daniel Vetter 2012-07-04 21:29 ` Paulo Zanoni 2012-07-05 7:50 ` Daniel Vetter [this message] 2012-07-05 13:08 ` [PATCH] " Daniel Vetter 2012-07-03 9:27 ` [PATCH 02/43] drm/i915: add crtc->enable/disable vfuncs insted of dpms Daniel Vetter 2012-07-03 9:27 ` [PATCH 03/43] drm/i915: rip out crtc prepare/commit indirection Daniel Vetter 2012-07-03 9:27 ` [PATCH 04/43] drm/i915: add direct encoder disable/enable infrastructure Daniel Vetter 2012-07-03 9:27 ` [PATCH 05/43] drm/i915: add missing gen2 pipe A quirk entries Daniel Vetter 2012-07-03 9:27 ` [PATCH 06/43] drm/i915: rip out the overlay pipe A workaround Daniel Vetter 2012-07-03 9:27 ` [PATCH 07/43] drm/i915: prepare load-detect pipe code for dpms changes Daniel Vetter 2012-07-03 9:28 ` [PATCH 08/43] drm/i915/hdmi: convert to encoder->disable/enable Daniel Vetter 2012-07-26 17:12 ` Paulo Zanoni 2012-07-03 9:28 ` [PATCH 09/43] drm/i915/tv: convert to encoder enable/disable Daniel Vetter 2012-07-03 9:28 ` [PATCH 10/43] drm/i915/lvds: ditch ->prepare special case Daniel Vetter 2012-07-03 9:28 ` [PATCH 11/43] drm/i915/lvds: convert to encoder disable/enable Daniel Vetter 2012-07-03 9:28 ` [PATCH 12/43] drm/i915/dp: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 13/43] drm/i915: create VLV_DSIPLAY_BASE #define Daniel Vetter 2012-07-03 9:28 ` [PATCH 14/43] drm/i915: group ADPA #defines together Daniel Vetter 2012-07-03 9:28 ` [PATCH 15/43] drm/i915: add inte_crt->adpa_reg Daniel Vetter 2012-07-03 9:28 ` [PATCH 16/43] drm/i915/crt: convert to encoder disable/enable Daniel Vetter 2012-07-03 9:28 ` [PATCH 17/43] drm/i915/sdvo: convert to encoder disabl/enable Daniel Vetter 2012-07-03 9:28 ` [PATCH 18/43] drm/i915: simplify dvo dpms interface Daniel Vetter 2012-07-03 9:28 ` [PATCH 19/43] drm/i915: simplify possible_clones computation Daniel Vetter 2012-07-03 9:28 ` [PATCH 20/43] drm/i915: add port parameter to intel_hdmi_init Daniel Vetter 2012-07-03 9:28 ` [PATCH 21/43] drm/i915: convert dpms functions of dvo/sdvo/crt Daniel Vetter 2012-07-03 9:28 ` [PATCH 22/43] drm/i915: rip out encoder->disable/enable checks Daniel Vetter 2012-07-03 9:28 ` [PATCH 23/43] drm/i915: clean up encoder_prepare/commit Daniel Vetter 2012-07-03 9:28 ` [PATCH 24/43] drm/fb helper: don't call drm_crtc_helper_set_config Daniel Vetter 2012-07-03 9:28 ` [PATCH 25/43] drm: remove the list_head from drm_mode_set Daniel Vetter 2012-07-03 9:28 ` [PATCH 26/43] drm/i915: copy&paste drm_crtc_helper_set_config Daniel Vetter 2012-07-03 9:28 ` [PATCH 27/43] drm/i915: call set_base directly Daniel Vetter 2012-07-03 9:28 ` [PATCH 28/43] drm/i915: inline intel_best_encoder Daniel Vetter 2012-07-03 9:28 ` [PATCH 29/43] drm/i915: copy&paste drm_crtc_helper_set_mode Daniel Vetter 2012-07-25 21:14 ` Paulo Zanoni 2012-07-03 9:28 ` [PATCH 30/43] drm/i915: simplify intel_crtc_prepare_encoders Daniel Vetter 2012-07-03 9:28 ` [PATCH 31/43] drm/i915: rip out encoder->prepare/commit Daniel Vetter 2012-07-03 9:28 ` [PATCH 32/43] drm/i915: call crtc functions directly Daniel Vetter 2012-07-03 9:28 ` [PATCH 33/43] drm/i915: WARN when trying to enabled an unused crtc Daniel Vetter 2012-07-03 9:28 ` [PATCH 34/43] drm/i915: Add interfaces to read out encoder/connector hw state Daniel Vetter 2012-07-03 9:28 ` [PATCH 35/43] drm/i915/dp: implement get_hw_state Daniel Vetter 2012-07-03 9:28 ` [PATCH 36/43] drm/i915/hdmi: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 37/43] drm/i915/tv: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 38/43] drm/i915/lvds: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 39/43] drm/i915/crt: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 40/43] drm/i915/sdvo: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 41/43] drm/i915/dvo: " Daniel Vetter 2012-07-03 9:28 ` [PATCH 42/43] drm/i915: read out the modeset hw state at load and resume time Daniel Vetter 2012-07-03 9:28 ` [PATCH 43/43] drm/i915: check connector hw/sw state Daniel Vetter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1341474624-27720-1-git-send-email-daniel.vetter@ffwll.ch \ --to=daniel.vetter@ffwll.ch \ --cc=intel-gfx@lists.freedesktop.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Intel-GFX Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/intel-gfx/0 intel-gfx/git/0.git git clone --mirror https://lore.kernel.org/intel-gfx/1 intel-gfx/git/1.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 intel-gfx intel-gfx/ https://lore.kernel.org/intel-gfx \ intel-gfx@lists.freedesktop.org public-inbox-index intel-gfx Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.freedesktop.lists.intel-gfx AGPL code for this site: git clone https://public-inbox.org/public-inbox.git