From: Daniel Vetter <daniel@ffwll.ch>
To: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 04/11] drm/i915: Add for_each_connector_in_state helper macro
Date: Fri, 10 Apr 2015 11:42:35 +0200 [thread overview]
Message-ID: <20150410094235.GF6092@phenom.ffwll.local> (raw)
In-Reply-To: <1428655120-22494-5-git-send-email-ander.conselvan.de.oliveira@intel.com>
On Fri, Apr 10, 2015 at 11:38:33AM +0300, Ander Conselvan de Oliveira wrote:
> This saves some typing whenever a iteration over all the connector
> states in the atomic state is written, which happens quite often.
>
> Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 8 +++++
> drivers/gpu/drm/i915/intel_ddi.c | 9 ++---
> drivers/gpu/drm/i915/intel_display.c | 65 ++++++++++--------------------------
> drivers/gpu/drm/i915/intel_dp_mst.c | 12 +++----
> drivers/gpu/drm/i915/intel_hdmi.c | 7 ++--
> 5 files changed, 38 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 78f31cb..e12bc5a 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -264,6 +264,14 @@ enum hpd_pin {
> for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++) \
> if ((1 << (domain)) & (mask))
>
> +#define for_each_connector_in_state(state, connector, connector_state, __i) \
Imo this should be a drm_atomic.h thing. At least there's a lot of loops
with exactly this pattern in drm_atomic_helper.c and drm_atomic.c
Maybe even do helpers for plane/crtc looping too.
-Daniel
> + for ((__i) = 0; \
> + (connector) = to_intel_connector((state)->connectors[__i]), \
> + (connector_state) = (state)->connector_states[__i], \
> + (__i) < (state)->num_connector; \
> + (__i)++) \
> + if (connector)
> +
> struct drm_i915_private;
> struct i915_mm_struct;
> struct i915_mmu_object;
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index 486f6fa..2e005e3 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -496,18 +496,19 @@ 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 intel_connector *connector;
> struct drm_atomic_state *state;
> + 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++;
> }
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 894788d..3035a3d 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -437,13 +437,10 @@ static bool intel_pipe_will_have_type(const struct intel_crtc_state *crtc_state,
> struct drm_atomic_state *state = crtc_state->base.state;
> struct drm_connector_state *connector_state;
> struct intel_encoder *encoder;
> + struct intel_connector *connector;
> 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;
>
> @@ -6919,16 +6916,13 @@ static int i9xx_crtc_compute_clock(struct intel_crtc *crtc,
> bool ok, has_reduced_clock = false;
> bool is_lvds = false, is_dsi = false;
> struct intel_encoder *encoder;
> + struct intel_connector *connector;
> const intel_limit_t *limit;
> struct drm_atomic_state *state = crtc_state->base.state;
> 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;
>
> @@ -7614,14 +7608,11 @@ static int ironlake_get_refclk(struct intel_crtc_state *crtc_state)
> struct drm_atomic_state *state = crtc_state->base.state;
> struct drm_connector_state *connector_state;
> struct intel_encoder *encoder;
> + struct intel_connector *connector;
> 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;
>
> @@ -7877,15 +7868,12 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc,
> struct drm_atomic_state *state = crtc_state->base.state;
> struct drm_connector_state *connector_state;
> struct intel_encoder *encoder;
> + struct intel_connector *connector;
> 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;
>
> @@ -10522,6 +10510,7 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc,
> {
> struct drm_device *dev = crtc->base.dev;
> struct drm_atomic_state *state;
> + struct drm_connector_state *connector_state;
> struct intel_connector *connector;
> int bpp, i;
>
> @@ -10566,12 +10555,8 @@ 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);
> @@ -10658,14 +10643,11 @@ static bool check_single_encoder_cloning(struct drm_atomic_state *state,
> struct intel_encoder *encoder)
> {
> struct intel_encoder *source_encoder;
> + struct intel_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;
>
> @@ -10682,14 +10664,11 @@ static bool check_encoder_cloning(struct drm_atomic_state *state,
> struct intel_crtc *crtc)
> {
> struct intel_encoder *encoder;
> + struct intel_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;
>
> @@ -10705,6 +10684,7 @@ static bool check_digital_port_conflicts(struct drm_atomic_state *state)
> {
> struct drm_device *dev = state->dev;
> struct intel_encoder *encoder;
> + struct intel_connector *connector;
> struct drm_connector_state *connector_state;
> unsigned int used_ports = 0;
> int i;
> @@ -10714,11 +10694,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;
>
> @@ -10845,12 +10821,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;
>
> diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
> index 7335089..5561eca 100644
> --- a/drivers/gpu/drm/i915/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/intel_dp_mst.c
> @@ -40,7 +40,8 @@ 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 intel_connector *connector, *found = NULL;
> + struct drm_connector_state *connector_state;
> int mst_pbn;
>
> pipe_config->dp_encoder_is_mst = true;
> @@ -70,12 +71,9 @@ 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;
> -
> - if (state->connector_states[i]->best_encoder == &encoder->base) {
> - found = to_intel_connector(state->connectors[i]);
> + for_each_connector_in_state(state, connector, connector_state, i) {
> + if (connector_state->best_encoder == &encoder->base) {
> + found = connector;
> break;
> }
> }
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> index 02252d9..9d02746 100644
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -956,6 +956,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 intel_connector *connector;
> struct drm_connector_state *connector_state;
> int count = 0, count_hdmi = 0;
> int i;
> @@ -965,11 +966,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;
>
> --
> 2.1.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-04-10 9:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 8:38 [PATCH 00/11] Small modeset refactoring Ander Conselvan de Oliveira
2015-04-10 8:38 ` [PATCH 01/11] drm/i915: Allocate connector state together with the connectors Ander Conselvan de Oliveira
2015-04-10 8:38 ` [PATCH 02/11] drm/i915: Remove stale comment from __intel_set_mode() Ander Conselvan de Oliveira
2015-04-10 9:37 ` Daniel Vetter
2015-04-10 9:39 ` Daniel Vetter
2015-04-10 8:38 ` [PATCH 03/11] drm/i915: Reset changed flags when duplicating crtc state Ander Conselvan de Oliveira
2015-04-10 9:39 ` Daniel Vetter
2015-04-13 11:07 ` Jani Nikula
2015-04-10 8:38 ` [PATCH 04/11] drm/i915: Add for_each_connector_in_state helper macro Ander Conselvan de Oliveira
2015-04-10 9:42 ` Daniel Vetter [this message]
2015-04-10 10:50 ` Ander Conselvan De Oliveira
2015-04-10 8:38 ` [PATCH 05/11] drm/i915: Extract mode_changed computation out of stage_output_config() Ander Conselvan de Oliveira
2015-04-10 10:07 ` Daniel Vetter
2015-04-10 8:38 ` [PATCH 06/11] drm/i915: Add crtc states before calling compute_config() Ander Conselvan de Oliveira
2015-04-10 8:38 ` [PATCH 07/11] drm/i915: Remove all *_pipes flags from modeset Ander Conselvan de Oliveira
2015-04-10 9:54 ` Daniel Vetter
2015-04-10 8:38 ` [PATCH 08/11] drm/i915: Remove saved_mode from __intel_set_mode() Ander Conselvan de Oliveira
2015-04-10 8:38 ` [PATCH 09/11] drm/i915: Move compute part of __intel_set_mode() to separate function Ander Conselvan de Oliveira
2015-04-10 8:38 ` [PATCH 10/11] drm/i915: Simplify error handling in __intel_set_mode() Ander Conselvan de Oliveira
2015-04-10 8:38 ` [PATCH 11/11] drm/i915: Don't modeset with old mode when set_crtc fails Ander Conselvan de Oliveira
2015-04-10 10:12 ` Daniel Vetter
2015-04-10 10:24 ` Ander Conselvan De Oliveira
2015-04-10 13:27 ` shuang.he
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=20150410094235.GF6092@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=ander.conselvan.de.oliveira@intel.com \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox