All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Sharma, Shashank" <shashank.sharma@intel.com>
Cc: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/8] drm/modes: Introduce drm_mode_match()
Date: Wed, 17 Jan 2018 17:21:48 +0200	[thread overview]
Message-ID: <20180117152148.GK10981@intel.com> (raw)
In-Reply-To: <a65e2bc3-74dc-582b-6193-1274ca01bea6@intel.com>

On Wed, Jan 17, 2018 at 02:11:55PM +0530, Sharma, Shashank wrote:
> 
> 
> On 1/12/2018 11:51 AM, Nautiyal, Ankit K wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Make mode matching less confusing by allowing the caller to specify
> > which parts of the modes should match via some flags.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/drm_modes.c | 134 ++++++++++++++++++++++++++++++++++----------
> >   include/drm/drm_modes.h     |   9 +++
> >   2 files changed, 112 insertions(+), 31 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> > index 4a3f68a..8128dbb 100644
> > --- a/drivers/gpu/drm/drm_modes.c
> > +++ b/drivers/gpu/drm/drm_modes.c
> > @@ -940,17 +940,68 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
> >   }
> >   EXPORT_SYMBOL(drm_mode_duplicate);
> >   
> > +static bool drm_mode_match_timings(const struct drm_display_mode *mode1,
> > +				   const struct drm_display_mode *mode2)
> Shouldn't the second parameter be aligned to next char after the opening 
> bracket in above line (instead of being align to the bracket) ?

It is. The extra junk at the start of the line is causing the alignment
to look wrong when it's not because the tab stops are still aligned to
the start of the line. This is one reason why I think that using tabs
for alignment isn't a particularly great idea.

> I have this same comment for most of the functions in this patch.
> > +{
> > +	return mode1->hdisplay == mode2->hdisplay &&
> > +		mode1->hsync_start == mode2->hsync_start &&
> > +		mode1->hsync_end == mode2->hsync_end &&
> > +		mode1->htotal == mode2->htotal &&
> > +		mode1->hskew == mode2->hskew &&
> > +		mode1->vdisplay == mode2->vdisplay &&
> > +		mode1->vsync_start == mode2->vsync_start &&
> > +		mode1->vsync_end == mode2->vsync_end &&
> > +		mode1->vtotal == mode2->vtotal &&
> > +		mode1->vscan == mode2->vscan;
> > +}
> > +
> > +static bool drm_mode_match_clock(const struct drm_display_mode *mode1,
> > +				  const struct drm_display_mode *mode2)
> > +{
> > +	/*
> > +	 * do clock check convert to PICOS
> > +	 * so fb modes get matched the same
> > +	 */
> > +	if (mode1->clock && mode2->clock)
> > +		return KHZ2PICOS(mode1->clock) == KHZ2PICOS(mode2->clock);
> > +	else
> > +		return mode1->clock == mode2->clock;
> > +}
> > +
> > +static bool drm_mode_match_flags(const struct drm_display_mode *mode1,
> Should we call it drm_mode_match_flag_no_stereo ?

It's not really "no stereo", rather it's "check all the flags not being
checked by something more specific".

> > +				 const struct drm_display_mode *mode2)
> > +{
> > +	return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
> > +		(mode2->flags & ~DRM_MODE_FLAG_3D_MASK);
> > +}
> > +
> > +static bool drm_mode_match_3d_flags(const struct drm_display_mode *mode1,
> > +				    const struct drm_display_mode *mode2)
> > +{
> > +	return (mode1->flags & DRM_MODE_FLAG_3D_MASK) ==
> > +		(mode2->flags & DRM_MODE_FLAG_3D_MASK);
> > +}
> > +
> > +static bool drm_mode_match_aspect_ratio(const struct drm_display_mode *mode1,
> > +					const struct drm_display_mode *mode2)
> > +{
> > +	return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio;
> > +}
> > +
> >   /**
> > - * drm_mode_equal - test modes for equality
> > + * drm_mode_match - test modes for (partial) equality
> >    * @mode1: first mode
> >    * @mode2: second mode
> > + * @match_flags: which parts need to match (DRM_MODE_MATCH_*)
> >    *
> >    * Check to see if @mode1 and @mode2 are equivalent.
> >    *
> >    * Returns:
> > - * True if the modes are equal, false otherwise.
> > + * True if the modes are (partially) equal, false otherwise.
> >    */
> > -bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
> > +bool drm_mode_match(const struct drm_display_mode *mode1,
> > +		    const struct drm_display_mode *mode2,
> > +		    unsigned int match_flags)
> >   {
> >   	if (!mode1 && !mode2)
> >   		return true;
> > @@ -958,15 +1009,48 @@ bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_displ
> >   	if (!mode1 || !mode2)
> >   		return false;
> >   
> > -	/* do clock check convert to PICOS so fb modes get matched
> > -	 * the same */
> > -	if (mode1->clock && mode2->clock) {
> > -		if (KHZ2PICOS(mode1->clock) != KHZ2PICOS(mode2->clock))
> > -			return false;
> > -	} else if (mode1->clock != mode2->clock)
> > +	if (match_flags & DRM_MODE_MATCH_TIMINGS &&
> > +	    !drm_mode_match_timings(mode1, mode2))
> > +		return false;
> > +
> > +	if (match_flags & DRM_MODE_MATCH_CLOCK &&
> > +	    !drm_mode_match_clock(mode1, mode2))
> > +		return false;
> > +
> > +	if (match_flags & DRM_MODE_MATCH_FLAGS &&
> > +	    !drm_mode_match_flags(mode1, mode2))
> > +		return false;
> > +
> > +	if (match_flags & DRM_MODE_MATCH_3D_FLAGS &&
> > +	    !drm_mode_match_3d_flags(mode1, mode2))
> >   		return false;
> >   
> > -	return drm_mode_equal_no_clocks(mode1, mode2);
> > +	if (match_flags & DRM_MODE_MATCH_ASPECT_RATIO &&
> > +	    !drm_mode_match_aspect_ratio(mode1, mode2))
> > +		return false;
> > +
> > +	return true;
> > +}
> > +EXPORT_SYMBOL(drm_mode_match);
> > +
> > +/**
> > + * drm_mode_equal - test modes for equality
> > + * @mode1: first mode
> > + * @mode2: second mode
> > + *
> > + * Check to see if @mode1 and @mode2 are equivalent.
> > + *
> > + * Returns:
> > + * True if the modes are equal, false otherwise.
> > + */
> > +bool drm_mode_equal(const struct drm_display_mode *mode1,
> > +		    const struct drm_display_mode *mode2)
> > +{
> > +	return drm_mode_match(mode1, mode2,
> > +			      DRM_MODE_MATCH_TIMINGS |
> > +			      DRM_MODE_MATCH_CLOCK |
> > +			      DRM_MODE_MATCH_FLAGS |
> > +			      DRM_MODE_MATCH_3D_FLAGS);
> >   }
> >   EXPORT_SYMBOL(drm_mode_equal);
> >   
> > @@ -981,13 +1065,13 @@ EXPORT_SYMBOL(drm_mode_equal);
> >    * Returns:
> >    * True if the modes are equal, false otherwise.
> >    */
> > -bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
> > +bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
> > +			      const struct drm_display_mode *mode2)
> >   {
> > -	if ((mode1->flags & DRM_MODE_FLAG_3D_MASK) !=
> > -	    (mode2->flags & DRM_MODE_FLAG_3D_MASK))
> > -		return false;
> > -
> > -	return drm_mode_equal_no_clocks_no_stereo(mode1, mode2);
> > +	return drm_mode_match(mode1, mode2,
> > +			      DRM_MODE_MATCH_TIMINGS |
> > +			      DRM_MODE_MATCH_FLAGS |
> > +			      DRM_MODE_MATCH_3D_FLAGS);
> >   }
> >   EXPORT_SYMBOL(drm_mode_equal_no_clocks);
> >   
> > @@ -1005,21 +1089,9 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks);
> >   bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
> >   					const struct drm_display_mode *mode2)
> >   {
> > -	if (mode1->hdisplay == mode2->hdisplay &&
> > -	    mode1->hsync_start == mode2->hsync_start &&
> > -	    mode1->hsync_end == mode2->hsync_end &&
> > -	    mode1->htotal == mode2->htotal &&
> > -	    mode1->hskew == mode2->hskew &&
> > -	    mode1->vdisplay == mode2->vdisplay &&
> > -	    mode1->vsync_start == mode2->vsync_start &&
> > -	    mode1->vsync_end == mode2->vsync_end &&
> > -	    mode1->vtotal == mode2->vtotal &&
> > -	    mode1->vscan == mode2->vscan &&
> > -	    (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
> > -	     (mode2->flags & ~DRM_MODE_FLAG_3D_MASK))
> > -		return true;
> > -
> > -	return false;
> > +	return drm_mode_match(mode1, mode2,
> > +			      DRM_MODE_MATCH_TIMINGS |
> > +			      DRM_MODE_MATCH_FLAGS);
> >   }
> >   EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
> >   
> > diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> > index 9f3421c..839eb9c 100644
> > --- a/include/drm/drm_modes.h
> > +++ b/include/drm/drm_modes.h
> > @@ -150,6 +150,12 @@ enum drm_mode_status {
> >   
> >   #define DRM_MODE_FLAG_3D_MAX	DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
> >   
> > +#define DRM_MODE_MATCH_TIMINGS (1 << 0)
> > +#define DRM_MODE_MATCH_CLOCK (1 << 1)
> > +#define DRM_MODE_MATCH_FLAGS (1 << 2)
> > +#define DRM_MODE_MATCH_3D_FLAGS (1 << 3)
> > +#define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4)
> > +
> >   /**
> >    * struct drm_display_mode - DRM kernel-internal display mode structure
> >    * @hdisplay: horizontal display size
> > @@ -493,6 +499,9 @@ void drm_mode_copy(struct drm_display_mode *dst,
> >   		   const struct drm_display_mode *src);
> >   struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
> >   					    const struct drm_display_mode *mode);
> > +bool drm_mode_match(const struct drm_display_mode *mode1,
> > +		    const struct drm_display_mode *mode2,
> Same here for the alignment
> > +		    unsigned int match_flags);
> >   bool drm_mode_equal(const struct drm_display_mode *mode1,
> >   		    const struct drm_display_mode *mode2);
> >   bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
> With the minor comments above, please feel free to use
> Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-01-17 15:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12  6:21 [PATCH v3 0/8] Aspect ratio support in DRM layer Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 1/8] drm/modes: Introduce drm_mode_match() Nautiyal, Ankit K
2018-01-17  8:41   ` Sharma, Shashank
2018-01-17 15:21     ` Ville Syrjälä [this message]
2018-01-18  6:10       ` Sharma, Shashank
2018-01-12  6:21 ` [PATCH v3 2/8] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Nautiyal, Ankit K
2018-01-17  8:53   ` Sharma, Shashank
2018-01-12  6:21 ` [PATCH v3 3/8] drm/edid: Fix cea mode aspect ratio handling Nautiyal, Ankit K
2018-01-17  9:05   ` Sharma, Shashank
2018-01-17 15:29     ` Ville Syrjälä
2018-01-18  6:14       ` Sharma, Shashank
2018-01-12  6:21 ` [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio Nautiyal, Ankit K
2018-01-17  9:11   ` Sharma, Shashank
2018-01-18 10:16   ` Maarten Lankhorst
2018-01-18 15:41     ` ankit.k.nautiyal
2018-01-18 16:04       ` Ville Syrjälä
2018-01-19  5:44         ` Nautiyal, Ankit K
2018-01-22  4:34     ` [PATCH v4 " Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths Nautiyal, Ankit K
2018-01-29 18:53   ` Ville Syrjälä
2018-01-31  6:34     ` Nautiyal, Ankit K
2018-01-31 13:09       ` Ville Syrjälä
2018-02-01 11:05         ` Nautiyal, Ankit K
2018-02-01 12:54           ` Ville Syrjälä
2018-02-08  4:29             ` Nautiyal, Ankit K
2018-02-13  4:51               ` Nautiyal, Ankit K
2018-02-13 13:18                 ` Ville Syrjälä
2018-02-13 16:23                   ` Nautiyal, Ankit K
2018-02-13 16:45                     ` Ville Syrjälä
2018-02-15 11:57                       ` Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 6/8] drm: Expose modes with aspect ratio, only if requested Nautiyal, Ankit K
2018-01-29 18:58   ` Ville Syrjälä
2018-01-31  8:00     ` Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 7/8] drm: Add aspect ratio parsing in DRM layer Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 8/8] drm: Add and handle new aspect ratios " Nautiyal, Ankit K

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=20180117152148.GK10981@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=shashank.sharma@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.