From patchwork Tue Jan 20 16:50:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 5671821 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DA044C058D for ; Tue, 20 Jan 2015 19:44:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A9562049D for ; Tue, 20 Jan 2015 19:44:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8BCF2203AD for ; Tue, 20 Jan 2015 19:44:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 92AAA6E655; Tue, 20 Jan 2015 11:44:24 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by gabe.freedesktop.org (Postfix) with ESMTP id E9FAD6E657 for ; Tue, 20 Jan 2015 11:44:23 -0800 (PST) Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:21c:dfff:fe9f:57fb]) by smtp6-g21.free.fr (Postfix) with ESMTP id B868E822A3; Tue, 20 Jan 2015 20:42:15 +0100 (CET) X-Mailbox-Line: From a67026f283019719432ef4310f9f8d75f467a4a6 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Jean-Francois Moine Date: Tue, 20 Jan 2015 17:50:25 +0100 Subject: [PATCH v10 7/9] drm/i2c: tda998x: set cts_n according to the sample width To: Mark Brown , Russell King - ARM Linux Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Andrew Jackson , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jyri Sarha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_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 With I2S input, the CTS_N predivider depends on the audio sample width. Signed-off-by: Jean-Francois Moine --- drivers/gpu/drm/i2c/tda998x_drv.c | 21 ++++++++++++++++++--- include/sound/tda998x.h | 4 +++- sound/soc/codecs/tda998x.c | 5 +++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index a2cfc11..adf34e0 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c @@ -28,6 +28,7 @@ #include #include #include +#include #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) @@ -663,7 +664,17 @@ 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); + + /* with I2S input, the CTS_N predivider depends on + * the sample width */ + switch (priv->audio.sample_format) { + case SNDRV_PCM_FORMAT_S16_LE: + cts_n = CTS_N_M(3) | CTS_N_K(1); + break; + default: + cts_n = CTS_N_M(3) | CTS_N_K(3); + break; + } break; default: @@ -751,7 +762,8 @@ static int tda998x_get_audio_var(struct device *dev, /* switch the audio port and initialize the audio parameters for streaming */ static int tda998x_set_audio_input(struct device *dev, int port_index, - unsigned sample_rate) + unsigned sample_rate, + int sample_format) { struct tda998x_priv *priv = dev_get_drvdata(dev); struct tda998x_encoder_params *p = &priv->params; @@ -767,7 +779,8 @@ static int tda998x_set_audio_input(struct device *dev, /* if same audio parameters, just enable the audio port */ if (p->audio_cfg == priv->audio.ports[port_index] && - p->audio_sample_rate == sample_rate) { + p->audio_sample_rate == sample_rate && + priv->audio.sample_format == sample_format) { reg_write(priv, REG_ENA_AP, p->audio_cfg); return 0; } @@ -776,6 +789,7 @@ static int tda998x_set_audio_input(struct device *dev, p->audio_clk_cfg = p->audio_format == AFMT_SPDIF ? 0 : 1; p->audio_cfg = priv->audio.ports[port_index]; p->audio_sample_rate = sample_rate; + priv->audio.sample_format = sample_format; tda998x_configure_audio(priv, &priv->encoder->crtc->hwmode, p); return 0; } @@ -1427,6 +1441,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv) priv->params.audio_frame[1] = 1; /* channels - 1 */ priv->params.audio_sample_rate = 48000; /* 48kHz */ + priv->audio.sample_format = SNDRV_PCM_FORMAT_S24_LE; priv->current_page = 0xff; priv->hdmi = client; diff --git a/include/sound/tda998x.h b/include/sound/tda998x.h index b4b747b..a870c40 100644 --- a/include/sound/tda998x.h +++ b/include/sound/tda998x.h @@ -9,6 +9,7 @@ struct tda998x_audio_s { u8 ports[2]; /* AP value */ u8 port_types[2]; /* AFMT_xxx */ + int sample_format; #if IS_ENABLED(CONFIG_SND_SOC_TDA998X) struct cea_sad cea_sad; /* Short Audio Descriptor */ void *codec_priv; @@ -20,7 +21,8 @@ struct tda998x_ops_s { struct tda998x_audio_s **tda998x_audio); int (*set_audio_input)(struct device *dev, int port_index, - unsigned sample_rate); + unsigned sample_rate, + int sample_format); }; int tda9998x_codec_register(struct device *dev, diff --git a/sound/soc/codecs/tda998x.c b/sound/soc/codecs/tda998x.c index 0a186e7..fece8d2 100644 --- a/sound/soc/codecs/tda998x.c +++ b/sound/soc/codecs/tda998x.c @@ -73,13 +73,14 @@ static int tda998x_codec_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { return tda998x_ops->set_audio_input(dai->dev, dai->id, - params_rate(params)); + params_rate(params), + params_format(params)); } static void tda998x_codec_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - tda998x_ops->set_audio_input(dai->dev, PORT_NONE, 0); + tda998x_ops->set_audio_input(dai->dev, PORT_NONE, 0, 0); } static const struct snd_soc_dai_ops tda998x_codec_ops = {