From ebce6fdb8f7603d6daedfe8748caec4ed9e0d8ba Mon Sep 17 00:00:00 2001 From: hjc Date: Tue, 2 Sep 2014 15:48:42 +0800 Subject: [PATCH] audio: rk3036 codec: add rk3036 sound card unfinished function, If not,it not to set I2S clk and div,and lead to no sound on some TV. --- sound/soc/rockchip/rk_rk3036.c | 55 ++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) mode change 100644 => 100755 sound/soc/rockchip/rk_rk3036.c diff --git a/sound/soc/rockchip/rk_rk3036.c b/sound/soc/rockchip/rk_rk3036.c old mode 100644 new mode 100755 index ae413af647c1..b08134dfcfd2 --- a/sound/soc/rockchip/rk_rk3036.c +++ b/sound/soc/rockchip/rk_rk3036.c @@ -23,24 +23,73 @@ #include "rk_pcm.h" #include "rk_i2s.h" +#if 0 +#define DBG(x...) pr_info("rk_rk3036" x) +#else +#define DBG(x...) +#endif static int rk30_hw_params(struct snd_pcm_substream * substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int dai_fmt = rtd->dai_link->dai_fmt; + unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt; int ret; + DBG("Enter::%s----%d\n", __func__, __LINE__); + /* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); - if (ret < 0) + if (ret < 0) { + DBG("%s():failed to set the format for codec side\n", + __func__); return ret; + } /* set cpu DAI configuration */ ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); - if (ret < 0) + if (ret < 0) { + DBG("%s():failed to set the format for cpu side\n", + __func__); + return ret; + } + + switch (params_rate(params)) { + case 8000: + case 16000: + case 24000: + case 32000: + case 48000: + pll_out = 12288000; + break; + case 11025: + case 22050: + case 44100: + pll_out = 11289600; + break; + default: + DBG("Enter:%s, %d, Error rate=%d\n", + __func__, __LINE__, params_rate(params)); + return -EINVAL; + break; + } + + DBG("Enter:%s, %d, rate=%d\n", + __func__, __LINE__, params_rate(params)); + + /*Set the system clk for codec*/ + ret = snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, SND_SOC_CLOCK_IN); + if (ret < 0) { + DBG("rk_hifi_hw_params:failed to set the sysclk for codec\n"); return ret; + } + + snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, + (pll_out/4)/params_rate(params)-1); + snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3); + DBG("Enter:%s, %d, pll_out/4/params_rate(params) = %d \n", + __func__, __LINE__, (pll_out/4)/params_rate(params)); return 0; } -- 2.34.1