From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH 1/3] drm/edid: add a helper function to extract the speaker allocation data block Date: Wed, 14 Aug 2013 11:14:57 +0300 Message-ID: <20130814081457.GL7159@intel.com> References: <1376427700-19299-1-git-send-email-alexander.deucher@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 30CBCE5C67 for ; Wed, 14 Aug 2013 01:15:02 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1376427700-19299-1-git-send-email-alexander.deucher@amd.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Alex Deucher Cc: Alex Deucher , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Tue, Aug 13, 2013 at 05:01:38PM -0400, Alex Deucher wrote: > This adds a helper function to extract the speaker allocation > data block from the EDID. This data block describes what speakers > are present on the display device. > = > Signed-off-by: Alex Deucher > --- > drivers/gpu/drm/drm_edid.c | 50 ++++++++++++++++++++++++++++++++++++++++= ++++++ > include/drm/drm_edid.h | 1 + > 2 files changed, 51 insertions(+) > = > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index 70fc133..bc16c80 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -2735,6 +2735,56 @@ int drm_edid_to_sad(struct edid *edid, struct cea_= sad **sads) > EXPORT_SYMBOL(drm_edid_to_sad); > = > /** > + * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blo= cks from EDID > + * @edid: EDID to parse > + * @sadb: pointer to the speaker block > + * > + * Looks for CEA EDID block and extracts the Speaker Allocation Data Blo= ck from it. > + * > + * Return number of found Speaker Allocation Blocks or negative number o= n error. > + */ > +int drm_edid_to_speaker_allocation(struct edid *edid, u8 *sadb) > +{ > + int count =3D 0; > + int i, start, end, dbl; > + u8 *cea; Can be const. > + > + cea =3D drm_find_cea_extension(edid); > + if (!cea) { > + DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); > + return -ENOENT; > + } > + > + if (cea_revision(cea) < 3) { > + DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); > + return -ENOTSUPP; > + } > + > + if (cea_db_offsets(cea, &start, &end)) { > + DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); > + return -EPROTO; > + } > + > + for_each_cea_db(cea, i, start, end) { > + u8 *db =3D &cea[i]; Also const. > + > + if (cea_db_tag(db) =3D=3D SPEAKER_BLOCK) { > + dbl =3D cea_db_payload_len(db); > + > + /* Speaker Allocation Data Block */ > + if (dbl >=3D 1) { CEA-861-E says the length must be exactly 3. Maybe we should be strict with this check? Also the second payload byte also contains three valid bits. Do we not care about those speakers? > + *sadb =3D db[1]; > + count =3D 1; > + break; > + } > + } > + } > + > + return count; > +} > +EXPORT_SYMBOL(drm_edid_to_speaker_allocation); > + > +/** > * drm_av_sync_delay - HDMI/DP sink audio-video sync delay in millisecond > * @connector: connector associated with the HDMI/DP sink > * @mode: the display mode > diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h > index fc481fc..22d7985 100644 > --- a/include/drm/drm_edid.h > +++ b/include/drm/drm_edid.h > @@ -259,6 +259,7 @@ struct hdmi_avi_infoframe; > = > void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid); > int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); > +int drm_edid_to_speaker_allocation(struct edid *edid, u8 *sadb); > int drm_av_sync_delay(struct drm_connector *connector, > struct drm_display_mode *mode); > struct drm_connector *drm_select_eld(struct drm_encoder *encoder, > -- = > 1.8.3.1 > = > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel -- = Ville Syrj=E4l=E4 Intel OTC