[3/8] drm/edid: Introduce is_detailed_timing_descritor()
diff mbox series

Message ID 20200124200231.10517-3-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
Related show

Commit Message

Ville Syrjälä Jan. 24, 2020, 8:02 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Let's introduce is_detailed_timing_descritor() as the opposite
counterpart of is_display_descriptor().

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 18 deletions(-)

Comments

Alex Deucher Jan. 27, 2020, 10:36 p.m. UTC | #1
On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Let's introduce is_detailed_timing_descritor() as the opposite
> counterpart of is_display_descriptor().
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++++++----------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 96ae1fde4ce2..d6bce58b27ac 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
>                 d[2] == 0x00 && d[3] == tag;
>  }
>
> +static bool is_detailed_timing_descriptor(const u8 d[18])
> +{
> +       return d[0] != 0x00 || d[1] != 0x00;
> +}
> +
>  typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>
>  static void
> @@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
>         struct detailed_mode_closure *closure = c;
>         struct drm_display_mode *newmode;
>
> -       if (timing->pixel_clock) {
> -               newmode = drm_mode_detailed(closure->connector->dev,
> -                                           closure->edid, timing,
> -                                           closure->quirks);
> -               if (!newmode)
> -                       return;
> +       if (!is_detailed_timing_descriptor((const u8 *)timing))
> +               return;
> +
> +       newmode = drm_mode_detailed(closure->connector->dev,
> +                                   closure->edid, timing,
> +                                   closure->quirks);
> +       if (!newmode)
> +               return;
>
> -               if (closure->preferred)
> -                       newmode->type |= DRM_MODE_TYPE_PREFERRED;
> +       if (closure->preferred)
> +               newmode->type |= DRM_MODE_TYPE_PREFERRED;
>
> -               /*
> -                * Detailed modes are limited to 10kHz pixel clock resolution,
> -                * so fix up anything that looks like CEA/HDMI mode, but the clock
> -                * is just slightly off.
> -                */
> -               fixup_detailed_cea_mode_clock(newmode);
> +       /*
> +        * Detailed modes are limited to 10kHz pixel clock resolution,
> +        * so fix up anything that looks like CEA/HDMI mode, but the clock
> +        * is just slightly off.
> +        */
> +       fixup_detailed_cea_mode_clock(newmode);
>
> -               drm_mode_probed_add(closure->connector, newmode);
> -               closure->modes++;
> -               closure->preferred = false;
> -       }
> +       drm_mode_probed_add(closure->connector, newmode);
> +       closure->modes++;
> +       closure->preferred = false;
>  }
>
>  /*
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Shankar, Uma Feb. 3, 2020, 7:49 p.m. UTC | #2
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:06 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 3/8] drm/edid: Introduce
> is_detailed_timing_descritor()
> 
> On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Let's introduce is_detailed_timing_descritor() as the opposite
> > counterpart of is_display_descriptor().
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 42
> > ++++++++++++++++++++++----------------
> >  1 file changed, 24 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 96ae1fde4ce2..d6bce58b27ac 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8
> tag)
> >                 d[2] == 0x00 && d[3] == tag;  }
> >
> > +static bool is_detailed_timing_descriptor(const u8 d[18]) {
> > +       return d[0] != 0x00 || d[1] != 0x00; }
> > +
> >  typedef void detailed_cb(struct detailed_timing *timing, void
> > *closure);
> >
> >  static void
> > @@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing,
> void *c)
> >         struct detailed_mode_closure *closure = c;
> >         struct drm_display_mode *newmode;
> >
> > -       if (timing->pixel_clock) {
> > -               newmode = drm_mode_detailed(closure->connector->dev,
> > -                                           closure->edid, timing,
> > -                                           closure->quirks);
> > -               if (!newmode)
> > -                       return;
> > +       if (!is_detailed_timing_descriptor((const u8 *)timing))
> > +               return;
> > +
> > +       newmode = drm_mode_detailed(closure->connector->dev,
> > +                                   closure->edid, timing,
> > +                                   closure->quirks);
> > +       if (!newmode)
> > +               return;
> >
> > -               if (closure->preferred)
> > -                       newmode->type |= DRM_MODE_TYPE_PREFERRED;
> > +       if (closure->preferred)
> > +               newmode->type |= DRM_MODE_TYPE_PREFERRED;
> >
> > -               /*
> > -                * Detailed modes are limited to 10kHz pixel clock resolution,
> > -                * so fix up anything that looks like CEA/HDMI mode, but the clock
> > -                * is just slightly off.
> > -                */
> > -               fixup_detailed_cea_mode_clock(newmode);
> > +       /*
> > +        * Detailed modes are limited to 10kHz pixel clock resolution,
> > +        * so fix up anything that looks like CEA/HDMI mode, but the clock
> > +        * is just slightly off.
> > +        */
> > +       fixup_detailed_cea_mode_clock(newmode);
> >
> > -               drm_mode_probed_add(closure->connector, newmode);
> > -               closure->modes++;
> > -               closure->preferred = false;
> > -       }
> > +       drm_mode_probed_add(closure->connector, newmode);
> > +       closure->modes++;
> > +       closure->preferred = false;
> >  }
> >
> >  /*
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Patch
diff mbox series

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 96ae1fde4ce2..d6bce58b27ac 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2202,6 +2202,11 @@  static bool is_display_descriptor(const u8 d[18], u8 tag)
 		d[2] == 0x00 && d[3] == tag;
 }
 
+static bool is_detailed_timing_descriptor(const u8 d[18])
+{
+	return d[0] != 0x00 || d[1] != 0x00;
+}
+
 typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 
 static void
@@ -3101,27 +3106,28 @@  do_detailed_mode(struct detailed_timing *timing, void *c)
 	struct detailed_mode_closure *closure = c;
 	struct drm_display_mode *newmode;
 
-	if (timing->pixel_clock) {
-		newmode = drm_mode_detailed(closure->connector->dev,
-					    closure->edid, timing,
-					    closure->quirks);
-		if (!newmode)
-			return;
+	if (!is_detailed_timing_descriptor((const u8 *)timing))
+		return;
+
+	newmode = drm_mode_detailed(closure->connector->dev,
+				    closure->edid, timing,
+				    closure->quirks);
+	if (!newmode)
+		return;
 
-		if (closure->preferred)
-			newmode->type |= DRM_MODE_TYPE_PREFERRED;
+	if (closure->preferred)
+		newmode->type |= DRM_MODE_TYPE_PREFERRED;
 
-		/*
-		 * Detailed modes are limited to 10kHz pixel clock resolution,
-		 * so fix up anything that looks like CEA/HDMI mode, but the clock
-		 * is just slightly off.
-		 */
-		fixup_detailed_cea_mode_clock(newmode);
+	/*
+	 * Detailed modes are limited to 10kHz pixel clock resolution,
+	 * so fix up anything that looks like CEA/HDMI mode, but the clock
+	 * is just slightly off.
+	 */
+	fixup_detailed_cea_mode_clock(newmode);
 
-		drm_mode_probed_add(closure->connector, newmode);
-		closure->modes++;
-		closure->preferred = false;
-	}
+	drm_mode_probed_add(closure->connector, newmode);
+	closure->modes++;
+	closure->preferred = false;
 }
 
 /*