From patchwork Tue Mar 8 12:54:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 8533751 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 1F4949F46A for ; Tue, 8 Mar 2016 12:58:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10DFB201C8 for ; Tue, 8 Mar 2016 12:58:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B53B1201E4 for ; Tue, 8 Mar 2016 12:58:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E9126265E1A; Tue, 8 Mar 2016 13:57:59 +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 DDE152657BC; Tue, 8 Mar 2016 13:54:46 +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 82C112657A6; Tue, 8 Mar 2016 13:54:45 +0100 (CET) Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [62.209.51.94]) by alsa0.perex.cz (Postfix) with ESMTP id 4B242260524 for ; Tue, 8 Mar 2016 13:54:32 +0100 (CET) Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by m0046037.ppops.net (8.15.0.59/8.15.0.59) with SMTP id u28CrRfd003966; Tue, 8 Mar 2016 13:54:32 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by m0046037.ppops.net with ESMTP id 21h1y3s2sn-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 08 Mar 2016 13:54:32 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3627431; Tue, 8 Mar 2016 12:54:31 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 097411426; Tue, 8 Mar 2016 12:54:31 +0000 (GMT) Received: from localhost (10.201.23.162) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 8 Mar 2016 13:54:30 +0100 From: Arnaud Pouliquen To: Date: Tue, 8 Mar 2016 13:54:01 +0100 Message-ID: <1457441641-7501-7-git-send-email-arnaud.pouliquen@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457441641-7501-1-git-send-email-arnaud.pouliquen@st.com> References: <1457441641-7501-1-git-send-email-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.162] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-03-08_05:, , signatures=0 Cc: Jean-Francois Moine , Lars-Peter Clausen , Russell King - ARM Linux , David Airlie , arnaud.pouliquen@st.com, Liam Girdwood , Jyri Sarha , Takashi Iwai , Mark Brown , Philipp Zabel , Moise Gergaud Subject: [alsa-devel] [PATCH v4 6/6] ASoC: hdmi-codec: add IEC 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Create 'IEC958 Playback Default' controls to support IEC61937 formats. the use of the alsa control is optional, using 'iec_ctl' flag. Signed-off-by: Arnaud Pouliquen --- include/sound/hdmi-codec.h | 1 + sound/soc/codecs/hdmi-codec.c | 54 ++++++++++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index fc3a481..4366d9f 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -92,6 +92,7 @@ struct hdmi_codec_pdata { const struct hdmi_codec_ops *ops; uint i2s:1; uint spdif:1; + uint iec_ctl:1; int max_i2s_channels; }; diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index bc47b9a..6d156ea 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -32,6 +32,7 @@ struct hdmi_codec_priv { struct snd_pcm_substream *current_stream; struct snd_pcm_hw_constraint_list ratec; uint8_t eld[MAX_ELD_BYTES]; + struct snd_aes_iec958 iec; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -122,26 +123,29 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - struct hdmi_codec_params hp = { - .iec = { - .status = { 0 }, - .subcode = { 0 }, - .pad = 0, - .dig_subframe = { 0 }, - } - }; + struct hdmi_codec_params hp; int ret; dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, params_width(params), params_rate(params), params_channels(params)); - ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status, - sizeof(hp.iec.status)); - if (ret < 0) { - dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", - ret); - return ret; + mutex_lock(&hcp->current_stream_lock); + hp.iec = hcp->iec; + mutex_unlock(&hcp->current_stream_lock); + + if (!hcp->hcd.iec_ctl) { + /* + * only PCM format supported + *channel status set according to runtime parameters + */ + ret = snd_pcm_create_iec958_consumer_hw_params(params, + hp.iec.status, sizeof(hp.iec.status)); + if (ret < 0) { + dev_err(dai->dev, "Creating IEC958 status failed %d\n", + ret); + return ret; + } } ret = hdmi_codec_new_stream(substream, dai); @@ -248,6 +252,27 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) return 0; } +static int hdmi_codec_dai_probe(struct snd_soc_dai *dai) +{ + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + struct snd_pcm_iec958_params *iec958_params; + const struct snd_kcontrol_new *ctrl; + + if (!hcp->hcd.iec_ctl) + return 0; + + iec958_params = devm_kzalloc(dai->dev, sizeof(*iec958_params), + GFP_KERNEL); + if (!iec958_params) + return -ENOMEM; + + iec958_params->iec = &hcp->iec; + iec958_params->mutex = &hcp->current_stream_lock; + + ctrl = snd_pcm_iec958_ctl_new(SNDRV_PCM_STREAM_PLAYBACK); + return snd_soc_add_dai_pcm_controls(dai, ctrl, 1, iec958_params); +} + static const struct snd_soc_dai_ops hdmi_dai_ops = { .startup = hdmi_codec_startup, .shutdown = hdmi_codec_shutdown, @@ -293,6 +318,7 @@ static struct snd_soc_dai_driver hdmi_i2s_dai = { .sig_bits = 24, }, .ops = &hdmi_dai_ops, + .probe = hdmi_codec_dai_probe, }; static const struct snd_soc_dai_driver hdmi_spdif_dai = {