audio: adjust pcm bclk for 24/32bit

PD#141217: fix pcm 24/32bit support

Change-Id: I3aae169645ec237079a17c89ce4f5361962a3e62
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
This commit is contained in:
Xing Wang
2017-04-13 20:07:33 +08:00
committed by Jianxin Pan
parent 188e2d88c6
commit fda2f6024c
3 changed files with 18 additions and 17 deletions

View File

@@ -132,9 +132,6 @@ RESET_FIFO:
pcm_mode = 2;
max_bits = 0x17;
valid_bits = 0x17;
//pcm_mode = 3;
max_bits = 0x1f;
break;
case SNDRV_PCM_FORMAT_S16_LE:
pcm_mode = 1;
@@ -549,10 +546,10 @@ void pcm_master_out_enable(struct snd_pcm_substream *substream, int flag)
break;
case SNDRV_PCM_FORMAT_S24_LE:
pcm_mode = 2;
valid_bits = 0x1f;
valid_bits = 0x17;
if (dsp_mode == SND_SOC_DAIFMT_DSP_A) {
bit_offset_s = 0xF;
slot_offset_s = 0x1F;
slot_offset_s = 0x17;
bit_offset_e = 0;
slot_offset_e = 0;
}
@@ -634,6 +631,7 @@ void pcm_master_out_enable(struct snd_pcm_substream *substream, int flag)
/* pcmout control2 */
/* FS * 16 * 16 = BCLK */
/* FS * 32 * 16 = BCLK */
aml_write_cbus(PCMOUT_CTRL2,
/* underrun use mute constant */
(0 << 29) |

View File

@@ -46,6 +46,8 @@
#define PCM_DEFAULT_SAMPLERATE 8000
#define PCM_DEFAULT_MCLK_RATIO_SR 256
#define PCM_24BIT_MCLK_RATIO_SR 384
#define PCM_32BIT_MCLK_RATIO_SR 512
static int aml_pcm_set_clk(struct aml_pcm *pcm, unsigned long rate)
{
@@ -89,9 +91,21 @@ static int aml_pcm_dai_prepare(struct snd_pcm_substream *substream,
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct aml_pcm_runtime_data *prtd = runtime->private_data;
struct aml_pcm *pcm = snd_soc_dai_get_drvdata(dai);
int mclk_rate;
pr_debug("***Entered %s\n", __func__);
/* set bclk */
if (runtime->format == SNDRV_PCM_FORMAT_S32_LE)
mclk_rate = runtime->rate * PCM_32BIT_MCLK_RATIO_SR;
else if (runtime->format == SNDRV_PCM_FORMAT_S24_LE)
mclk_rate = runtime->rate * PCM_24BIT_MCLK_RATIO_SR;
else
mclk_rate = runtime->rate * PCM_DEFAULT_MCLK_RATIO_SR;
aml_pcm_set_clk(pcm, mclk_rate);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
pr_info(
"%s playback stream buffer start: %ld size: 0x%x\n",
@@ -168,16 +182,6 @@ static int aml_pcm_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct aml_pcm *pcm = snd_soc_dai_get_drvdata(dai);
int srate, mclk_rate;
srate = params_rate(params);
if (pcm->old_samplerate != srate) {
pcm->old_samplerate = srate;
mclk_rate = srate * PCM_DEFAULT_MCLK_RATIO_SR;
aml_pcm_set_clk(pcm, mclk_rate);
}
pr_debug("***Entered %s:%s\n", __FILE__, __func__);
return 0;
}
@@ -301,7 +305,7 @@ static int aml_pcm_dai_probe(struct platform_device *pdev)
goto err;
}
/* now only 256fs is supported */
/* Default 256fs */
ret = aml_pcm_set_clk(pcm_p,
PCM_DEFAULT_SAMPLERATE * PCM_DEFAULT_MCLK_RATIO_SR);
if (ret < 0) {

View File

@@ -22,7 +22,6 @@ struct aml_pcm {
struct clk *clk_mpll;
struct clk *clk_pcm_mclk;
struct clk *clk_pcm_sync;
int old_samplerate;
int pcm_mode;
};