From: Paul Menzel Subject: Re: [RFC][PATCH] drm: add helper extracting SADs from EDID Date: Sun, 07 Apr 2013 13:50:29 +0200 Message-ID: <1365335429.7207.25.camel@mattotaupa> References: <1365331977-5622-1-git-send-email-zajec5@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1726337809==" Return-path: Received: from mail.gw90.de (mail.gw90.de [188.40.100.199]) by gabe.freedesktop.org (Postfix) with ESMTP id 03BF9E5F79 for ; Sun, 7 Apr 2013 04:50:32 -0700 (PDT) In-Reply-To: <1365331977-5622-1-git-send-email-zajec5@gmail.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: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1726337809== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-mHSv21W18/MkkFh51L5e" --=-mHSv21W18/MkkFh51L5e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Am Sonntag, den 07.04.2013, 12:52 +0200 schrieb Rafa=C5=82 Mi=C5=82ecki: > Some devices (ATI/AMD cards) don't want passing ELD struct to the want to pass > hardware but just require filling specific registers and then at end: =C2=BBthen *the* hardware=C2=AB (I think) > hardware/firmware does the rest. In such a cases we need to read info =E2=80=A2 =C2=BBIn such cases=C2=AB (without =C2=BBa=C2=AB) =E2=80=A2 the info > from SAD blocks and put them in the correct registers. Maybe mention the function name in the commit message (even summary) too. > --- > drivers/gpu/drm/drm_edid.c | 55 ++++++++++++++++++++++++++++++++++++++= ++++++ > include/drm/drm_edid.h | 24 +++++++++++++++++++ > 2 files changed, 79 insertions(+) >=20 > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index e2acfdb..7c9e799 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -2511,6 +2511,61 @@ void drm_edid_to_eld(struct drm_connector *connect= or, struct edid *edid) > EXPORT_SYMBOL(drm_edid_to_eld); > =20 > /** > + * drm_edid_to_sad - extracts SADs from EDID > + * @edid: EDID to parse > + * > + * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) = from it. > + */ > +struct cea_sad *drm_edid_to_sad(struct edid *edid) > +{ > + struct cea_sad *sads =3D NULL; No need to set it NULL, as it gets assigned later on? Looks like in the end there is a corner case, where nothing gets assigned in the `for_each_cea_db` loop. So the compiler is going to complain. > + int i, start, end, dbl; > + u8 *db, *cea; > + > + cea =3D drm_find_cea_extension(edid); > + if (!cea) { > + DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); > + return NULL; > + } > + > + if (cea_revision(cea) < 3) { > + DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); > + return NULL; > + } > + > + if (cea_db_offsets(cea, &start, &end)) { > + DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); > + return NULL; > + } Could the above be put in some helper too: `is_cea_valid_for_version(cea, version)`? > + for_each_cea_db(cea, i, start, end) { > + db =3D &cea[i]; > + dbl =3D cea_db_payload_len(db); > + > + if (cea_db_tag(db) =3D=3D AUDIO_BLOCK) { > + int count =3D dbl / 3; /* SAD is 3B */ > + int j; > + > + sads =3D kzalloc(count + 1 * sizeof(*sads), GFP_KERNEL); > + if (!sads) Add an error too? =C2=BBkzallac failed=C2=AB or something like this? > + return NULL; > + > + for (j =3D 0; j < count; j++) { > + u8 *sad =3D &db[1 + j * 3]; > + > + sads[j].format =3D (sad[0] & 0x78) >> 3; > + sads[j].channels =3D sad[0] & 0x7; > + sads[j].freq =3D sad[1] & 0x7F; > + sads[j].byte2 =3D sad[2]; > + } > + } > + } > + > + return sads; > +} > +EXPORT_SYMBOL(drm_edid_to_sad); > + > +/** > * drm_av_sync_delay - HDMI/DP sink audio-video sync delay in millisecon= d > * @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 5da1b4a..b36d052 100644 > --- a/include/drm/drm_edid.h > +++ b/include/drm/drm_edid.h > @@ -244,12 +244,36 @@ struct edid { > =20 > #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)= ) > =20 > +#define SAD_FORMAT_LPCM 0x01 > +#define SAD_FORMAT_AC3 0x02 At least in my MUA indentation looks different. > +#define SAD_FORMAT_MPEG1 0x03 > +#define SAD_FORMAT_MP3 0x04 > +#define SAD_FORMAT_MPEG2 0x05 > +#define SAD_FORMAT_AAC 0x06 > +#define SAD_FORMAT_DTS 0x07 > +#define SAD_FORMAT_ATRAC 0x08 > +#define SAD_FORMAT_ONE_BIT_AUDIO 0x09 > +#define SAD_FORMAT_DOLBY_DIGITAL 0x0a > +#define SAD_FORMAT_DTS_HD 0x0b > +#define SAD_FORMAT_MAT_MLP 0x0c > +#define SAD_FORMAT_DST 0x0d > +#define SAD_FORMAT_WMA_PRO 0x0e > + > +/* Short Audio Descriptor */ > +struct cea_sad { > + u8 format; > + u8 channels; /* max number of channels - 1 */ > + u8 freq; > + u8 byte2; /* meaning depends on format */ > +}; > + > struct drm_encoder; > struct drm_connector; > struct drm_display_mode; > struct hdmi_avi_infoframe; > =20 > void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)= ; > +struct cea_sad *drm_edid_to_sad(struct edid *edid); > int drm_av_sync_delay(struct drm_connector *connector, > struct drm_display_mode *mode); > struct drm_connector *drm_select_eld(struct drm_encoder *encoder, Otherwise this looks good. Thanks, Paul --=-mHSv21W18/MkkFh51L5e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEABECAAYFAlFhXYUACgkQPX1aK2wOHVjSVQCfRftEz1nXXpK8aYTK3jEBUseO 20gAoIb5NFIC+7Eb6+jAgkptISp0Oujh =tSzC -----END PGP SIGNATURE----- --=-mHSv21W18/MkkFh51L5e-- --===============1726337809== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1726337809==--