From patchwork Wed Mar 2 14:49:11 2016
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 8481481
Return-Path:
X-Original-To: patchwork-alsa-devel@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.29.136])
by patchwork1.web.kernel.org (Postfix) with ESMTP id 19A8D9F314
for ;
Wed, 2 Mar 2016 14:53:08 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 378F12024F
for ;
Wed, 2 Mar 2016 14:53:06 +0000 (UTC)
Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243])
by mail.kernel.org (Postfix) with ESMTP id E705320383
for ;
Wed, 2 Mar 2016 14:53:01 +0000 (UTC)
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id 5F5B226693C; Wed, 2 Mar 2016 15:53:00 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org
X-Spam-Level:
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE,
UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1
Received: from alsa0.perex.cz (localhost [127.0.0.1])
by alsa0.perex.cz (Postfix) with ESMTP id CE01D266727;
Wed, 2 Mar 2016 15:49:40 +0100 (CET)
X-Original-To: alsa-devel@alsa-project.org
Delivered-To: alsa-devel@alsa-project.org
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id 0B0F22656F0; Wed, 2 Mar 2016 15:49:38 +0100 (CET)
Received: from metis.ext.4.pengutronix.de (metis.ext.4.pengutronix.de
[92.198.50.35]) by alsa0.perex.cz (Postfix) with ESMTP id DA9352655F7
for ;
Wed, 2 Mar 2016 15:49:23 +0100 (CET)
Received: from paszta.hi.4.pengutronix.de ([10.1.0.120]
helo=paszta.pengutronix.de.)
by metis.ext.pengutronix.de with esmtp (Exim 4.80)
(envelope-from )
id 1ab85b-0006uv-Hd; Wed, 02 Mar 2016 15:49:23 +0100
From: Philipp Zabel
To: alsa-devel@alsa-project.org
Date: Wed, 2 Mar 2016 15:49:11 +0100
Message-Id: <1456930153-11853-8-git-send-email-p.zabel@pengutronix.de>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <1456930153-11853-1-git-send-email-p.zabel@pengutronix.de>
References: <1456930153-11853-1-git-send-email-p.zabel@pengutronix.de>
X-SA-Exim-Connect-IP: 10.1.0.120
X-SA-Exim-Mail-From: p.zabel@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de);
SAEximRunCond expanded to false
X-PTX-Original-Recipient: alsa-devel@alsa-project.org
Cc: Jean-Francois Moine , Koro Chen ,
Lars-Peter Clausen ,
Russell King - ARM Linux ,
Philipp Zabel ,
Arnaud Pouliquen ,
Liam Girdwood , Jyri Sarha ,
Cawa Cheng , Mark Brown ,
linux-mediatek@lists.infradead.org, Daniel Kurtz ,
kernel@pengutronix.de, Matthias Brugger
Subject: [alsa-devel] [PATCH v5 7/9] ASoC: hdmi-codec: Add ELD control
X-BeenThere: alsa-devel@alsa-project.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "Alsa-devel mailing list for ALSA developers -
http://www.alsa-project.org"
List-Unsubscribe:
,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
MIME-Version: 1.0
Errors-To: alsa-devel-bounces@alsa-project.org
Sender: alsa-devel-bounces@alsa-project.org
X-Virus-Scanned: ClamAV using ClamSMTP
ALSA doesn't know about all the different compressed audio formats,
so there is no interface to let userspace enumerate the formats that
are supported by the connected sink. Exporting the raw ELD bytes to
userspace allows an application to select the appropriate audio format
depending on the current capabilities of the connected HDMI sink device.
Usually userspace then just pretends to ALSA that the data is in one of
the raw 16-bit PCM audio formats and relies on the IEC controls to tell
the sink how to interpret the data.
Signed-off-by: Philipp Zabel
Reviewed-by: Jyri Sarha
Tested-by: Jyri Sarha
---
sound/soc/codecs/hdmi-codec.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 7d5db11..9c4e65c 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -55,6 +55,42 @@ enum {
DAI_ID_SPDIF,
};
+static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+ struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
+ uinfo->count = sizeof(hcp->eld);
+
+ return 0;
+}
+
+static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+ struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+
+ mutex_lock(&hcp->eld_lock);
+ memcpy(ucontrol->value.bytes.data, hcp->eld, sizeof(hcp->eld));
+ mutex_unlock(&hcp->eld_lock);
+
+ return 0;
+}
+
+static const struct snd_kcontrol_new hdmi_controls[] = {
+ {
+ .access = SNDRV_CTL_ELEM_ACCESS_READ |
+ SNDRV_CTL_ELEM_ACCESS_VOLATILE,
+ .iface = SNDRV_CTL_ELEM_IFACE_PCM,
+ .name = "ELD",
+ .info = hdmi_eld_ctl_info,
+ .get = hdmi_eld_ctl_get,
+ },
+};
+
static void hdmi_codec_abort(struct device *dev)
{
struct hdmi_codec_priv *hcp = dev_get_drvdata(dev);
@@ -326,6 +362,8 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = {
};
static struct snd_soc_codec_driver hdmi_codec = {
+ .controls = hdmi_controls,
+ .num_controls = ARRAY_SIZE(hdmi_controls),
.dapm_widgets = hdmi_widgets,
.num_dapm_widgets = ARRAY_SIZE(hdmi_widgets),
.dapm_routes = hdmi_routes,