diff mbox

[RFC,07/11] drm/edid: add function to help find SADs

Message ID E1YcfY0-0002vI-0F@rmk-PC.arm.linux.org.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Russell King March 30, 2015, 7:40 p.m. UTC
Add a function to find the start of the SADs in the ELD.  This
complements the helper to retrieve the SAD count.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 include/drm/drm_edid.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Jani Nikula April 1, 2015, 11:47 a.m. UTC | #1
On Mon, 30 Mar 2015, Russell King <rmk+kernel@arm.linux.org.uk> wrote:
> Add a function to find the start of the SADs in the ELD.  This
> complements the helper to retrieve the SAD count.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

I guess version 31 is specific enough to warrant a #define of its own,
but meh.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  include/drm/drm_edid.h | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> index 87d85e81d3a7..c44ad513e0f7 100644
> --- a/include/drm/drm_edid.h
> +++ b/include/drm/drm_edid.h
> @@ -346,6 +346,25 @@ static inline int drm_eld_mnl(const uint8_t *eld)
>  }
>  
>  /**
> + * drm_eld_sad - Get ELD SAD structures.
> + * @eld: pointer to an eld memory structure with sad_count set
> + */
> +static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
> +{
> +	unsigned int ver, mnl;
> +
> +	ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT;
> +	if (ver != 2 && ver != 31)
> +		return NULL;
> +
> +	mnl = drm_eld_mnl(eld);
> +	if (mnl > 16)
> +		return NULL;
> +
> +	return eld + DRM_ELD_CEA_SAD(mnl, 0);
> +}
> +
> +/**
>   * drm_eld_sad_count - Get ELD SAD count.
>   * @eld: pointer to an eld memory structure with sad_count set
>   */
> -- 
> 1.8.3.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Russell King - ARM Linux April 1, 2015, 11:56 a.m. UTC | #2
On Wed, Apr 01, 2015 at 02:47:32PM +0300, Jani Nikula wrote:
> On Mon, 30 Mar 2015, Russell King <rmk+kernel@arm.linux.org.uk> wrote:
> > Add a function to find the start of the SADs in the ELD.  This
> > complements the helper to retrieve the SAD count.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> 
> I guess version 31 is specific enough to warrant a #define of its own,
> but meh.

What about version 2?  We don't have any version definitions in
drm_edid.h at all.  It would be nice to see some...

It would also be nice to see some of this stuff not being DRM specific,
because EDID parsing isn't something limited to DRM - and let's face it,
one of the biggest consumers of graphics on Linux is Android, which I'm
told is pretty much wedded to the fbdev API.
diff mbox

Patch

diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 87d85e81d3a7..c44ad513e0f7 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -346,6 +346,25 @@  static inline int drm_eld_mnl(const uint8_t *eld)
 }
 
 /**
+ * drm_eld_sad - Get ELD SAD structures.
+ * @eld: pointer to an eld memory structure with sad_count set
+ */
+static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
+{
+	unsigned int ver, mnl;
+
+	ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT;
+	if (ver != 2 && ver != 31)
+		return NULL;
+
+	mnl = drm_eld_mnl(eld);
+	if (mnl > 16)
+		return NULL;
+
+	return eld + DRM_ELD_CEA_SAD(mnl, 0);
+}
+
+/**
  * drm_eld_sad_count - Get ELD SAD count.
  * @eld: pointer to an eld memory structure with sad_count set
  */