All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Anderson <thomasanderson@google.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Hans Verkuil <hansverk@cisco.com>,
	intel-gfc@freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [v3,1/4] drm/edid: Abstract away cea_edid_modes[]
Date: Tue, 10 Dec 2019 15:06:10 -0800	[thread overview]
Message-ID: <20191210230610.GA24882@google.com> (raw)
In-Reply-To: <20191210223423.GA85292@google.com>

+CCs that were accidnetally lost

On Tue, Dec 10, 2019 at 02:34:23PM -0800, Tom Anderson wrote:
> On Wed, Sep 25, 2019 at 04:54:59PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > We're going to need two cea mode tables (on for VICs < 128,
> 
> s/on/one
> 
> > another one for VICs >= 193). To that end replace the direct
> > edid_cea_modes[] lookups with a function call. And we'll rename
> > the array to edid_cea_modes_0[] to indicathe how it's to be
> 
> s/indicathe/indicate
> 
> > indexed.
> > 
> > Cc: Hans Verkuil <hansverk@cisco.com>
> > Cc: Shashank Sharma <shashank.sharma@intel.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 80 +++++++++++++++++++++++++++-----------
> >  1 file changed, 58 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 3c9703b08491..b700fc075257 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -707,12 +707,11 @@ static const struct minimode extra_modes[] = {
> >  };
> >  
> >  /*
> > - * Probably taken from CEA-861 spec.
> > - * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c.
> > + * From CEA/CTA-861 spec.
> >   *
> > - * Index using the VIC.
> > + * Index with VIC.
> >   */
> > -static const struct drm_display_mode edid_cea_modes[] = {
> > +static const struct drm_display_mode edid_cea_modes_0[] = {
> 
> Nit: The "_0" suffix is a bit odd. Maybe edid_cea_modes_{lo,hi}, but I'm not
> sure if that's actually better. Up to you.
> 
> >  	/* 0 - dummy, VICs start at 1 */
> >  	{ },
> >  	/* 1 - 640x480@60Hz 4:3 */
> > @@ -3067,6 +3066,25 @@ static u8 *drm_find_cea_extension(const struct edid *edid)
> >  	return cea;
> >  }
> >  
> > +static const struct drm_display_mode *cea_mode_for_vic(u8 vic)
> > +{
> > +	if (!vic)
> > +		return NULL;
> > +	if (vic < ARRAY_SIZE(edid_cea_modes_0))
> > +		return &edid_cea_modes_0[vic];
> > +	return NULL;
> > +}
> > +
> > +static u8 cea_num_vics(void)
> > +{
> > +	return ARRAY_SIZE(edid_cea_modes_0);
> > +}
> > +
> > +static u8 cea_next_vic(u8 vic)
> > +{
> > +	return vic + 1;
> > +}
> > +
> >  /*
> >   * Calculate the alternate clock for the CEA mode
> >   * (60Hz vs. 59.94Hz etc.)
> > @@ -3104,14 +3122,14 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
> >  	 * get the other variants by simply increasing the
> >  	 * vertical front porch length.
> >  	 */
> > -	BUILD_BUG_ON(edid_cea_modes[8].vtotal != 262 ||
> > -		     edid_cea_modes[9].vtotal != 262 ||
> > -		     edid_cea_modes[12].vtotal != 262 ||
> > -		     edid_cea_modes[13].vtotal != 262 ||
> > -		     edid_cea_modes[23].vtotal != 312 ||
> > -		     edid_cea_modes[24].vtotal != 312 ||
> > -		     edid_cea_modes[27].vtotal != 312 ||
> > -		     edid_cea_modes[28].vtotal != 312);
> > +	BUILD_BUG_ON(cea_mode_for_vic(8)->vtotal != 262 ||
> > +		     cea_mode_for_vic(9)->vtotal != 262 ||
> > +		     cea_mode_for_vic(12)->vtotal != 262 ||
> > +		     cea_mode_for_vic(13)->vtotal != 262 ||
> > +		     cea_mode_for_vic(23)->vtotal != 312 ||
> > +		     cea_mode_for_vic(24)->vtotal != 312 ||
> > +		     cea_mode_for_vic(27)->vtotal != 312 ||
> > +		     cea_mode_for_vic(28)->vtotal != 312);
> >  
> >  	if (((vic == 8 || vic == 9 ||
> >  	      vic == 12 || vic == 13) && mode->vtotal < 263) ||
> > @@ -3139,10 +3157,16 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
> >  	if (to_match->picture_aspect_ratio)
> >  		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
> >  
> > -	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> > -		struct drm_display_mode cea_mode = edid_cea_modes[vic];
> > +	for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
> > +		const struct drm_display_mode *mode = cea_mode_for_vic(vic);
> > +		struct drm_display_mode cea_mode;
> >  		unsigned int clock1, clock2;
> >  
> > +		if (!mode)
> > +			continue;
> 
> Isn't this check is a no-op now that we have cea_next_vic()?
> 
> > +
> > +		cea_mode = *mode;
> > +
> 
> Get rid of |cea_mode| and use *mode. There's only 1 place where cea_mode.*
> was used, and 3 places where &cea_mode was used, so using a pointer seems
> better.
> 
> >  		/* Check both 60Hz and 59.94Hz */
> >  		clock1 = cea_mode.clock;
> >  		clock2 = cea_mode_alternate_clock(&cea_mode);
> > @@ -3178,10 +3202,16 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
> >  	if (to_match->picture_aspect_ratio)
> >  		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
> >  
> > -	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> > -		struct drm_display_mode cea_mode = edid_cea_modes[vic];
> > +	for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
> > +		const struct drm_display_mode *mode = cea_mode_for_vic(vic);
> > +		struct drm_display_mode cea_mode;
> >  		unsigned int clock1, clock2;
> >  
> > +		if (!mode)
> > +			continue;
> > +
> > +		cea_mode = *mode;
> > +
> 
> Same 2 comments as above.
> 
> >  		/* Check both 60Hz and 59.94Hz */
> >  		clock1 = cea_mode.clock;
> >  		clock2 = cea_mode_alternate_clock(&cea_mode);
> > @@ -3202,7 +3232,7 @@ EXPORT_SYMBOL(drm_match_cea_mode);
> >  
> >  static bool drm_valid_cea_vic(u8 vic)
> >  {
> > -	return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes);
> > +	return cea_mode_for_vic(vic) != NULL;
> >  }
> >  
> >  /**
> > @@ -3214,7 +3244,13 @@ static bool drm_valid_cea_vic(u8 vic)
> >   */
> >  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)
> >  {
> > -	return edid_cea_modes[video_code].picture_aspect_ratio;
> > +	const struct drm_display_mode *mode;
> > +
> > +	mode = cea_mode_for_vic(video_code);
> 
> Nit: do declaration and assignment for |mode| on the same line?
> 
> > +	if (mode)
> > +		return mode->picture_aspect_ratio;
> > +
> > +	return HDMI_PICTURE_ASPECT_NONE;
> >  }
> >  EXPORT_SYMBOL(drm_get_cea_aspect_ratio);
> >  
> > @@ -3323,7 +3359,7 @@ add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
> >  		unsigned int clock1, clock2;
> >  
> >  		if (drm_valid_cea_vic(vic)) {
> > -			cea_mode = &edid_cea_modes[vic];
> > +			cea_mode = cea_mode_for_vic(vic);
> >  			clock2 = cea_mode_alternate_clock(cea_mode);
> >  		} else {
> >  			vic = drm_match_hdmi_mode(mode);
> > @@ -3398,7 +3434,7 @@ drm_display_mode_from_vic_index(struct drm_connector *connector,
> >  	if (!drm_valid_cea_vic(vic))
> >  		return NULL;
> >  
> > -	newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]);
> > +	newmode = drm_mode_duplicate(dev, cea_mode_for_vic(vic));
> >  	if (!newmode)
> >  		return NULL;
> >  
> > @@ -3432,7 +3468,7 @@ static int do_y420vdb_modes(struct drm_connector *connector,
> >  		if (!drm_valid_cea_vic(vic))
> >  			continue;
> >  
> > -		newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]);
> > +		newmode = drm_mode_duplicate(dev, cea_mode_for_vic(vic));
> >  		if (!newmode)
> >  			break;
> >  		bitmap_set(hdmi->y420_vdb_modes, vic, 1);
> > @@ -4001,7 +4037,7 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
> >  	vic = drm_match_cea_mode_clock_tolerance(mode, 5);
> >  	if (drm_valid_cea_vic(vic)) {
> >  		type = "CEA";
> > -		cea_mode = &edid_cea_modes[vic];
> > +		cea_mode = cea_mode_for_vic(vic);
> >  		clock1 = cea_mode->clock;
> >  		clock2 = cea_mode_alternate_clock(cea_mode);
> >  	} else {
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-12-11  9:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25 13:54 [PATCH v3 0/4] drm/edid: Add new modes from CTA-861-G Ville Syrjala
2019-09-25 13:54 ` [PATCH v3 1/4] drm/edid: Abstract away cea_edid_modes[] Ville Syrjala
2019-10-03  8:16   ` Sharma, Shashank
2019-10-03 13:55     ` Ville Syrjälä
     [not found]   ` <20191210223423.GA85292@google.com>
2019-12-10 23:06     ` Tom Anderson [this message]
2019-09-25 13:54 ` Ville Syrjala
2019-09-25 13:55 ` [PATCH v3 2/4] drm/edid: Add CTA-861-G modes with VIC >= 193 Ville Syrjala
2019-09-27 21:35   ` Manasi Navare
2019-10-03  8:22   ` Sharma, Shashank
2019-10-03 14:15     ` Ville Syrjälä
2019-12-10 23:16   ` [v3,2/4] " Tom Anderson
2019-09-25 13:55 ` [PATCH v3 2/4] " Ville Syrjala
2019-09-25 13:55 ` [PATCH v3 3/4] drm/edid: Throw away the dummy VIC 0 cea mode Ville Syrjala
2019-10-03  8:29   ` Sharma, Shashank
2019-10-03 14:16     ` Ville Syrjälä
2019-12-10 23:18   ` [v3,3/4] " Tom Anderson
2019-12-11 11:07     ` Ville Syrjälä
2019-09-25 13:55 ` [PATCH v3 3/4] " Ville Syrjala
2019-09-25 13:55 ` [PATCH v3 4/4] drm/edid: Make sure the CEA mode arrays have the correct amount of modes Ville Syrjala
2019-09-27 21:38   ` Manasi Navare
2019-12-10 23:20   ` [v3,4/4] " Tom Anderson
2019-09-25 13:55 ` [PATCH v3 4/4] " Ville Syrjala
2019-09-25 16:19 ` ✗ Fi.CI.CHECKPATCH: warning for drm/edid: Add new modes from CTA-861-G (rev2) Patchwork
2019-09-25 16:42 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-26  8:37 ` ✗ Fi.CI.IGT: failure " Patchwork

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=20191210230610.GA24882@google.com \
    --to=thomasanderson@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hansverk@cisco.com \
    --cc=intel-gfc@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 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.