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: 3556701 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 B562B9F2E9 for ; Thu, 30 Jan 2014 12:06:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CFB4201D5 for ; Thu, 30 Jan 2014 12:06:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6565120035 for ; Thu, 30 Jan 2014 12:06:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A668FFE3C for ; Thu, 30 Jan 2014 04:06:28 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4983CFFE46 for ; Thu, 30 Jan 2014 04:05:20 -0800 (PST) Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:212:bfff:fe1e:9ce4]) by smtp1-g21.free.fr (Postfix) with ESMTP id D849A9400EF; Thu, 30 Jan 2014 13:05:01 +0100 (CET) X-Mailbox-Line: From abcb2381bac2d7b300ab26a16a2ca81c551757da 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 v2 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.6 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 | 19 +++++++++++++++---- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index 92cbc40..ee17d42 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,8 @@ struct tda998x_priv { volatile int wq_edid_wait; struct drm_encoder *encoder; + int audio_sample_format; + u8 *eld; }; @@ -663,7 +666,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; @@ -744,13 +758,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); @@ -762,11 +777,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 7f21749..181388d 100644 --- a/sound/soc/codecs/tda998x.c +++ b/sound/soc/codecs/tda998x.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,8 @@ static void tda_get_encoder(struct tda_priv *priv) priv->i2c_client = i2c_client; } -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; @@ -76,7 +78,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; } @@ -156,9 +158,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, @@ -167,11 +177,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, };