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: 3565111 Return-Path: X-Original-To: patchwork-dri-devel@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 3E2369F383 for ; Sat, 1 Feb 2014 17:33:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4985220274 for ; Sat, 1 Feb 2014 17:33:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7140C20270 for ; Sat, 1 Feb 2014 17:33:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 646696C97 for ; Sat, 1 Feb 2014 09:33:51 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [212.27.42.2]) by gabe.freedesktop.org (Postfix) with ESMTP id B49BC6C97 for ; Sat, 1 Feb 2014 09:33:14 -0800 (PST) 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 Cc: Russell King - ARM Linux , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, broonie@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.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, };