From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: Alex Deucher <alexander.deucher@amd.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/edid: add a helper function to extract the speaker allocation data block (v3)
Date: Wed, 14 Aug 2013 19:46:39 +0300 [thread overview]
Message-ID: <20130814164639.GX7159@intel.com> (raw)
In-Reply-To: <1376497821-9060-1-git-send-email-alexander.deucher@amd.com>
On Wed, Aug 14, 2013 at 12:30:21PM -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.
>
> v2: update per Ville Syrjälä's comments
> v3: fix copy/paste typo in memory allocation
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>
> Fixed the malloc issue. I can switch to passing a u32 if that is preferred.
At least the kmalloc adds a bit of symmetry between this and the SAD
extractor. So I'll hand out an r-b for this one in case there's no u32
version coming. But I'd be OK w/ the u32 approach too.
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> drivers/gpu/drm/drm_edid.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
> include/drm/drm_edid.h | 1 +
> 2 files changed, 53 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 70fc133..58b4882 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2735,6 +2735,58 @@ 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 Blocks from EDID
> + * @edid: EDID to parse
> + * @sadb: pointer to the speaker block
> + *
> + * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it.
> + * Note: returned pointer needs to be kfreed
> + *
> + * Return number of found Speaker Allocation Blocks or negative number on error.
> + */
> +int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb)
> +{
> + int count = 0;
> + int i, start, end, dbl;
> + const u8 *cea;
> +
> + cea = 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) {
> + const u8 *db = &cea[i];
> +
> + if (cea_db_tag(db) == SPEAKER_BLOCK) {
> + dbl = cea_db_payload_len(db);
> +
> + /* Speaker Allocation Data Block */
> + if (dbl == 3) {
> + *sadb = kmalloc(dbl, GFP_KERNEL);
> + memcpy(*sadb, &db[1], dbl);
> + count = dbl;
> + 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..c76a129 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älä
Intel OTC
prev parent reply other threads:[~2013-08-14 16:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-14 16:30 [PATCH 1/3] drm/edid: add a helper function to extract the speaker allocation data block (v3) Alex Deucher
2013-08-14 16:46 ` Ville Syrjälä [this message]
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=20130814164639.GX7159@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
/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.