mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
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.
This commit is contained in:
55
sound/soc/rockchip/rk_rk3036.c
Normal file → Executable file
55
sound/soc/rockchip/rk_rk3036.c
Normal file → Executable file
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user