dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 03/10] drm: Add drm_encoder_mask()
Date: Tue, 26 Jun 2018 13:11:56 -0700	[thread overview]
Message-ID: <20180626201154.GJ9765@intel.com> (raw)
In-Reply-To: <20180626194716.12522-3-ville.syrjala@linux.intel.com>

On Tue, Jun 26, 2018 at 10:47:09PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add drm_encoder_mask() which returns the 1<<index for the encoder.
> We already have an identical drm_crtc_mask() for crtcs.
> 
> Mostly performed with coccinelle:
> @@
> @@
> - (1<<drm_encoder_index(
> + drm_encoder_mask(
>   ...)
> -  )
> 
> @@
> @@
> - 1<<drm_encoder_index(
> + drm_encoder_mask(
>   ...)
> 
> @@
> @@
> - BIT(drm_encoder_index(
> + drm_encoder_mask(
>   ...)
> - )
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 10 +++++-----
>  include/drm/drm_encoder.h           | 16 ++++++++++++++--
>  2 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 17baf5057132..e022cacdae34 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -121,7 +121,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
>  			new_encoder = drm_atomic_helper_best_encoder(connector);
>  
>  		if (new_encoder) {
> -			if (encoder_mask & (1 << drm_encoder_index(new_encoder))) {
> +			if (encoder_mask & drm_encoder_mask(new_encoder)) {
>  				DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] on [CONNECTOR:%d:%s] already assigned\n",
>  					new_encoder->base.id, new_encoder->name,
>  					connector->base.id, connector->name);
> @@ -129,7 +129,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
>  				return -EINVAL;
>  			}
>  
> -			encoder_mask |= 1 << drm_encoder_index(new_encoder);
> +			encoder_mask |= drm_encoder_mask(new_encoder);
>  		}
>  	}
>  
> @@ -155,7 +155,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
>  			continue;
>  
>  		encoder = connector->state->best_encoder;
> -		if (!encoder || !(encoder_mask & (1 << drm_encoder_index(encoder))))
> +		if (!encoder || !(encoder_mask & drm_encoder_mask(encoder)))
>  			continue;
>  
>  		if (!disable_conflicting_encoders) {
> @@ -223,7 +223,7 @@ set_best_encoder(struct drm_atomic_state *state,
>  			crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
>  
>  			crtc_state->encoder_mask &=
> -				~(1 << drm_encoder_index(conn_state->best_encoder));
> +				~drm_encoder_mask(conn_state->best_encoder);
>  		}
>  	}
>  
> @@ -234,7 +234,7 @@ set_best_encoder(struct drm_atomic_state *state,
>  			crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
>  
>  			crtc_state->encoder_mask |=
> -				1 << drm_encoder_index(encoder);
> +				drm_encoder_mask(encoder);
>  		}
>  	}
>  
> diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
> index fb299696c7c4..4f597c0730b4 100644
> --- a/include/drm/drm_encoder.h
> +++ b/include/drm/drm_encoder.h
> @@ -191,11 +191,23 @@ int drm_encoder_init(struct drm_device *dev,
>   * Given a registered encoder, return the index of that encoder within a DRM
>   * device's list of encoders.
>   */
> -static inline unsigned int drm_encoder_index(struct drm_encoder *encoder)
> +static inline unsigned int drm_encoder_index(const struct drm_encoder *encoder)
>  {
>  	return encoder->index;
>  }
>  
> +/**
> + * drm_encoder_mask - find the mask of a registered ENCODER
> + * @encoder: encoder to find mask for
> + *
> + * Given a registered encoder, return the mask bit of that encoder for an
> + * encoder's possible_clones field.
> + */
> +static inline u32 drm_encoder_mask(const struct drm_encoder *encoder)
> +{
> +	return 1 << drm_encoder_index(encoder);
> +}
> +
>  /**
>   * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
>   * @encoder: encoder to test
> @@ -241,7 +253,7 @@ void drm_encoder_cleanup(struct drm_encoder *encoder);
>   */
>  #define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \
>  	list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \
> -		for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder)))
> +		for_each_if ((encoder_mask) & drm_encoder_mask(encoder))
>  
>  /**
>   * drm_for_each_encoder - iterate over all encoders
> -- 
> 2.16.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-06-26 20:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26 19:47 [PATCH 01/10] drm: Add drm_plane_mask() Ville Syrjala
2018-06-26 19:47 ` [PATCH 02/10] drm: Use drm_crtc_mask() Ville Syrjala
2018-06-26 20:11   ` Rodrigo Vivi
2018-06-26 19:47 ` [PATCH 03/10] drm: Add drm_encoder_mask() Ville Syrjala
2018-06-26 20:11   ` Rodrigo Vivi [this message]
2018-06-26 19:47 ` [PATCH 04/10] drm: Add drm_connector_mask() Ville Syrjala
2018-06-26 20:12   ` Rodrigo Vivi
2018-06-26 19:47 ` [PATCH 05/10] drm/i915: Use drm_plane_mask() & co Ville Syrjala
2018-06-26 20:16   ` Rodrigo Vivi
2018-06-26 19:47 ` [PATCH 06/10] drm/imx: Use drm_plane_mask() Ville Syrjala
2018-06-26 20:16   ` Rodrigo Vivi
2018-06-27  8:01   ` Philipp Zabel
2018-06-26 19:47 ` [PATCH 07/10] drm/rockchip: Use drm_crtc_mask() Ville Syrjala
2018-06-26 20:16   ` [Intel-gfx] " Rodrigo Vivi
2018-06-27 13:09   ` Heiko Stuebner
2018-06-26 19:47 ` [PATCH 08/10] drm/sun4i: " Ville Syrjala
2018-06-26 20:17   ` Rodrigo Vivi
2018-06-27  7:34   ` Maxime Ripard
2018-06-26 19:47 ` [PATCH 09/10] drm/vc4: " Ville Syrjala
2018-06-26 20:17   ` Rodrigo Vivi
2018-06-26 23:08   ` Eric Anholt
2018-06-26 19:47 ` [PATCH 10/10] drm/vmwgfx: Use drm_plane_mask() & co Ville Syrjala
2018-06-26 20:17   ` Rodrigo Vivi
2018-07-02 17:00   ` Sinclair Yeh
2018-07-03 12:34     ` Ville Syrjälä
2018-06-26 20:09 ` [PATCH 01/10] drm: Add drm_plane_mask() Rodrigo Vivi
2018-07-02 15:55   ` Ville Syrjälä

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=20180626201154.GJ9765@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).