From patchwork Thu Feb 18 15:02:20 2016
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 8351431
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 ED5689F38B
for ;
Thu, 18 Feb 2016 15:06:48 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 163B720125
for ;
Thu, 18 Feb 2016 15:06:48 +0000 (UTC)
Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243])
by mail.kernel.org (Postfix) with ESMTP id 353E420173
for ;
Thu, 18 Feb 2016 15:06:46 +0000 (UTC)
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id 53789266A0C; Thu, 18 Feb 2016 16:06:45 +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 6FD0C266573;
Thu, 18 Feb 2016 16:03:56 +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 0623A265E36; Thu, 18 Feb 2016 16:03:54 +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 26C2C2612AE
for ;
Thu, 18 Feb 2016 16:02:59 +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 1aWQ6c-0007KZ-DP; Thu, 18 Feb 2016 16:02:58 +0100
From: Philipp Zabel
To: alsa-devel@alsa-project.org
Date: Thu, 18 Feb 2016 16:02:20 +0100
Message-Id: <1455807741-19122-5-git-send-email-p.zabel@pengutronix.de>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <1455807526-16918-1-git-send-email-p.zabel@pengutronix.de>
References: <1455807526-16918-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] [RFC v4 7/8] 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
---
Changes since v3:
- Expanded commit message
- Add mutex to lock hcp->eld
---
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,