From patchwork Thu Jan 30 11:08:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 3565161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 828479F383 for ; Sat, 1 Feb 2014 17:35:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2C0C20274 for ; Sat, 1 Feb 2014 17:35:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6A2E20265 for ; Sat, 1 Feb 2014 17:35:50 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9eSM-0000rH-5e; Sat, 01 Feb 2014 17:34:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9eRs-0003ul-1p; Sat, 01 Feb 2014 17:33:44 +0000 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9eRf-0003qc-0W for linux-arm-kernel@lists.infradead.org; Sat, 01 Feb 2014 17:33:35 +0000 Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:212:bfff:fe1e:9ce4]) by smtp2-g21.free.fr (Postfix) with ESMTP id 1E2D54B00D5; Sat, 1 Feb 2014 18:33:00 +0100 (CET) X-Mailbox-Line: From df65a2de7d4afc2471846c02b73e8bbdc4f9a743 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Jean-Francois Moine Date: Thu, 30 Jan 2014 12:08:06 +0100 Subject: [PATCH v3 5/5] ASoC: tda998x: adjust the audio CTS_N pre-divider from audio format To: alsa-devel@alsa-project.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140201_123331_709236_E6E2F383 X-CRM114-Status: GOOD ( 15.35 ) X-Spam-Score: -1.9 (-) Cc: Russell King - ARM Linux , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Rob Clark , broonie@kernel.org, Dave Airlie , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some boards, with I2S input, the NXP TDA998x HDMI transmitter did not play audio streams with a sample width lower than S16_32. This patch adjusts the CTS_N predivider according to the used sample width. Signed-off-by: Jean-Francois Moine --- drivers/gpu/drm/i2c/tda998x_drv.c | 25 +++++++++++++++++++++---- include/drm/i2c/tda998x.h | 5 ++++- sound/soc/codecs/tda998x.c | 18 ++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index b833fa5..66013ba 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,8 @@ struct tda998x_priv { volatile int wq_edid_wait; struct drm_encoder *encoder; + int audio_sample_format; + u8 *eld; }; @@ -664,7 +667,18 @@ tda998x_configure_audio(struct tda998x_priv *priv, reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_I2S); clksel_aip = AIP_CLKSEL_AIP_I2S; clksel_fs = AIP_CLKSEL_FS_ACLK; - cts_n = CTS_N_M(3) | CTS_N_K(3); + switch (priv->audio_sample_format) { + case SNDRV_PCM_FORMAT_S16_LE: + cts_n = CTS_N_M(3) | CTS_N_K(1); + break; + case SNDRV_PCM_FORMAT_S24_LE: + cts_n = CTS_N_M(3) | CTS_N_K(2); + break; + default: + case SNDRV_PCM_FORMAT_S32_LE: + cts_n = CTS_N_M(3) | CTS_N_K(3); + break; + } aclk = 1; /* clock enable */ break; @@ -745,13 +759,14 @@ EXPORT_SYMBOL_GPL(tda998x_audio_get_eld); void tda998x_audio_update(struct i2c_client *client, int format, - int port) + int port, + struct snd_pcm_hw_params *params) { struct tda998x_priv *priv = i2c_get_clientdata(client); struct tda998x_encoder_params *p = &priv->params; /* if the audio output is active, it may be a second start or a stop */ - if (format == 0 || priv->audio_active) { + if (format == 0 || !params || priv->audio_active) { if (format == 0) { priv->audio_active = 0; reg_write(priv, REG_ENA_AP, 0); @@ -763,11 +778,13 @@ void tda998x_audio_update(struct i2c_client *client, p->audio_cfg = port; /* don't restart audio if same input format */ - if (format == p->audio_format) { + if (format == p->audio_format && + params_format(params) == priv->audio_sample_format) { reg_write(priv, REG_ENA_AP, p->audio_cfg); return; } p->audio_format = format; + priv->audio_sample_format = params_format(params); tda998x_configure_audio(priv, &priv->encoder->crtc->hwmode, p); } diff --git a/include/drm/i2c/tda998x.h b/include/drm/i2c/tda998x.h index 99387ae..62b838f 100644 --- a/include/drm/i2c/tda998x.h +++ b/include/drm/i2c/tda998x.h @@ -27,8 +27,11 @@ struct tda998x_encoder_params { unsigned audio_sample_rate; }; +struct snd_pcm_hw_params; + u8 *tda998x_audio_get_eld(struct i2c_client *client); void tda998x_audio_update(struct i2c_client *client, int format, - int port); + int port, + struct snd_pcm_hw_params *params); #endif diff --git a/sound/soc/codecs/tda998x.c b/sound/soc/codecs/tda998x.c index 0493163..a1de35d 100644 --- a/sound/soc/codecs/tda998x.c +++ b/sound/soc/codecs/tda998x.c @@ -47,7 +47,8 @@ static int tda_get_encoder(struct tda_priv *priv) return 0; } -static int tda_start_stop(struct tda_priv *priv) +static int tda_start_stop(struct tda_priv *priv, + struct snd_pcm_hw_params *params) { int port; @@ -56,7 +57,7 @@ static int tda_start_stop(struct tda_priv *priv) port = priv->ports[0]; else port = priv->ports[1]; - tda998x_audio_update(priv->i2c_client, priv->dai_id, port); + tda998x_audio_update(priv->i2c_client, priv->dai_id, port, params); return 0; } @@ -136,9 +137,17 @@ static int tda_startup(struct snd_pcm_substream *substream, stream->channels_max = max_channels; stream->formats = formats; } + return 0; +} + +static int tda_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct tda_priv *priv = snd_soc_codec_get_drvdata(dai->codec); /* start the TDA998x audio */ - return tda_start_stop(priv); + return tda_start_stop(priv, params); } static void tda_shutdown(struct snd_pcm_substream *substream, @@ -147,11 +156,12 @@ static void tda_shutdown(struct snd_pcm_substream *substream, struct tda_priv *priv = snd_soc_codec_get_drvdata(dai->codec); priv->dai_id = 0; /* streaming stop */ - tda_start_stop(priv); + tda_start_stop(priv, NULL); } static const struct snd_soc_dai_ops tda_ops = { .startup = tda_startup, + .hw_params = tda_hw_params, .shutdown = tda_shutdown, };