From 03d2d02b8cc6657b84e452ea2b86ce5429d070ad Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Wed, 6 Jun 2018 10:55:57 +0800 Subject: [PATCH] audio: support raw data even in touch sound[1/2] PD#164738: audio: auge: check frddr src for each frddr when output for raw data, disable the same frddrr src from other frddr Change-Id: I930c84b0520ff404c6a323be79b26102699c817b Signed-off-by: Xing Wang --- sound/soc/amlogic/auge/ddr_mngr.c | 36 ++++++++++++++++++++++++++++++++++-- sound/soc/amlogic/auge/ddr_mngr.h | 3 +++ sound/soc/amlogic/auge/tdm.c | 26 +++++++++++++++++--------- sound/soc/amlogic/auge/tdm_hw.c | 18 +++++++++--------- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/sound/soc/amlogic/auge/ddr_mngr.c b/sound/soc/amlogic/auge/ddr_mngr.c index 83d4d55..53cdd1c1 100644 --- a/sound/soc/amlogic/auge/ddr_mngr.c +++ b/sound/soc/amlogic/auge/ddr_mngr.c @@ -632,6 +632,32 @@ struct frddr *fetch_frddr_by_src(int frddr_src) return NULL; } +/* + * check frddr_src is used by other frddr for sharebuffer + * if used, disabled the other share frddr src, the module would + * for current frddr, and the checked frddr + */ +int aml_check_sharebuffer_valid(struct frddr *fr, int ss_sel) +{ + int current_fifo_id = fr->fifo_id; + unsigned int i; + int ret = 1; + + for (i = 0; i < DDRMAX; i++) { + if (frddrs[i].in_use + && (frddrs[i].fifo_id != current_fifo_id) + && (frddrs[i].dest == ss_sel)) { + + pr_info("ss_sel:%d used, invalid for share buffer\n", + ss_sel); + ret = 0; + break; + } + } + + return ret; +} + struct frddr *aml_audio_register_frddr(struct device *dev, struct aml_audio_controller *actrl, irq_handler_t handler, void *data) @@ -751,12 +777,16 @@ void aml_frddr_select_dst_ss(struct frddr *fr, { struct aml_audio_controller *actrl = fr->actrl; unsigned int reg_base = fr->reg_base; - unsigned int reg; + unsigned int reg, ss_valid; reg = calc_frddr_address(EE_AUDIO_FRDDR_A_CTRL0, reg_base); + + ss_valid = aml_check_sharebuffer_valid(fr, dst); + /* same source en */ if (fr->chipinfo - && fr->chipinfo->same_src_fn) { + && fr->chipinfo->same_src_fn + && ss_valid) { int s_v = 0, s_m = 0; switch (sel) { @@ -773,6 +803,8 @@ void aml_frddr_select_dst_ss(struct frddr *fr, sel); break; } + pr_info("%s sel:%d, dst_src:%d\n", + __func__, sel, dst); aml_audiobus_update_bits(actrl, reg, s_m, s_v); } } diff --git a/sound/soc/amlogic/auge/ddr_mngr.h b/sound/soc/amlogic/auge/ddr_mngr.h index 197ca02..3bf104c 100644 --- a/sound/soc/amlogic/auge/ddr_mngr.h +++ b/sound/soc/amlogic/auge/ddr_mngr.h @@ -94,6 +94,9 @@ void aml_frddr_enable(struct frddr *fr, bool enable); void aml_frddr_select_dst(struct frddr *fr, enum frddr_dest); extern void aml_frddr_select_dst_ss(struct frddr *fr, enum frddr_dest dst, int sel, bool enable); + +int aml_check_sharebuffer_valid(struct frddr *fr, int ss_sel); + void aml_frddr_set_fifos(struct frddr *fr, unsigned int depth, unsigned int thresh); unsigned int aml_frddr_get_fifo_id(struct frddr *fr); diff --git a/sound/soc/amlogic/auge/tdm.c b/sound/soc/amlogic/auge/tdm.c index bc85dbb..e567127 100644 --- a/sound/soc/amlogic/auge/tdm.c +++ b/sound/soc/amlogic/auge/tdm.c @@ -407,8 +407,10 @@ static int aml_dai_tdm_prepare(struct snd_pcm_substream *substream, /* share buffer prepare */ if (p_tdm->chipinfo && - p_tdm->chipinfo->same_src_fn) { - if (p_tdm->samesource_sel >= 0) + p_tdm->chipinfo->same_src_fn + && (p_tdm->samesource_sel >= 0) + && (aml_check_sharebuffer_valid(p_tdm->fddr, + p_tdm->samesource_sel))) { sharebuffer_prepare(substream, fr, p_tdm->samesource_sel); } @@ -500,8 +502,10 @@ static int aml_dai_tdm_trigger(struct snd_pcm_substream *substream, int cmd, /* share buffer trigger */ if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) && p_tdm->chipinfo - && p_tdm->chipinfo->same_src_fn) { - if (p_tdm->samesource_sel >= 0) + && p_tdm->chipinfo->same_src_fn + && (p_tdm->samesource_sel >= 0) + && (aml_check_sharebuffer_valid(p_tdm->fddr, + p_tdm->samesource_sel))) { sharebuffer_trigger(cmd, p_tdm->samesource_sel); } @@ -550,6 +554,7 @@ static int pcm_setting_init(struct pcm_setting *setting, unsigned int rate, unsigned int channels) { unsigned int ratio = 0; + setting->lrclk = rate; setting->bclk_lrclk_ratio = setting->slots * setting->slot_width; setting->bclk = setting->lrclk * setting->bclk_lrclk_ratio; @@ -576,7 +581,7 @@ static int aml_tdm_set_lanes(struct aml_tdm *p_tdm, unsigned int set_num = 0; unsigned int i; - pr_info("asoc debug: %d-%d\n", channels, setting->slots); + pr_debug("asoc channels:%d, slots:%d\n", channels, setting->slots); swap_val = 0; // calc lanes by channels and slots @@ -694,7 +699,9 @@ static int aml_dai_tdm_hw_params(struct snd_pcm_substream *substream, if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) && p_tdm->chipinfo && (p_tdm->chipinfo->same_src_fn) - && (p_tdm->samesource_sel >= 0)) { + && (p_tdm->samesource_sel >= 0) + && (aml_check_sharebuffer_valid(p_tdm->fddr, + p_tdm->samesource_sel))) { int mux = 0, ratio = 0; sharebuffer_get_mclk_fs_ratio(p_tdm->samesource_sel, @@ -723,8 +730,9 @@ static int aml_dai_tdm_hw_free(struct snd_pcm_substream *substream, if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) && p_tdm->chipinfo && p_tdm->chipinfo->same_src_fn - && fr) { - if (p_tdm->samesource_sel >= 0) + && (p_tdm->samesource_sel >= 0) + && fr + && (aml_check_sharebuffer_valid(fr, p_tdm->samesource_sel))) { sharebuffer_free(substream, fr, p_tdm->samesource_sel); } @@ -833,7 +841,7 @@ static int aml_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, struct aml_tdm *p_tdm = snd_soc_dai_get_drvdata(cpu_dai); unsigned int mclk_ratio; - pr_info("aml_dai_set_clkdiv, div %d, clksel(%d)\n", + pr_debug("aml_dai_set_clkdiv, div %d, clksel(%d)\n", div, p_tdm->clk_sel); p_tdm->setting.sysclk_bclk_ratio = div; diff --git a/sound/soc/amlogic/auge/tdm_hw.c b/sound/soc/amlogic/auge/tdm_hw.c index c3bfb29..7eb5482c 100644 --- a/sound/soc/amlogic/auge/tdm_hw.c +++ b/sound/soc/amlogic/auge/tdm_hw.c @@ -38,14 +38,14 @@ void aml_tdm_enable( unsigned int offset, reg; if (stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_info("tdm playback enable\n"); + pr_debug("tdm playback enable\n"); offset = EE_AUDIO_TDMOUT_B_CTRL0 - EE_AUDIO_TDMOUT_A_CTRL0; reg = EE_AUDIO_TDMOUT_A_CTRL0 + offset * index; aml_audiobus_update_bits(actrl, reg, 1<<31, is_enable<<31); } else { - pr_info("tdm capture enable\n"); + pr_debug("tdm capture enable\n"); offset = EE_AUDIO_TDMIN_B_CTRL - EE_AUDIO_TDMIN_A_CTRL; @@ -167,7 +167,7 @@ void aml_tdm_fifo_ctrl( } if (stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_info("tdm prepare----playback\n"); + pr_debug("tdm prepare----playback\n"); // from ddr, 63bit split into 2 samples offset = EE_AUDIO_TDMOUT_B_CTRL1 - EE_AUDIO_TDMOUT_A_CTRL1; @@ -176,7 +176,7 @@ void aml_tdm_fifo_ctrl( 0x3<<24|0x1f<<8|0x7<<4, fifo_id<<24|(bitwidth-1)<<8|frddr_type<<4); } else { - pr_info("tdm prepare----capture\n"); + pr_debug("tdm prepare----capture\n"); } } @@ -303,7 +303,7 @@ void aml_tdm_set_format( p_config->pcm_mode = fmt & SND_SOC_DAIFMT_FORMAT_MASK; - pr_info("pad clk ctl value:%x\n", clkctl); + pr_debug("pad clk ctl value:%x\n", clkctl); /* set lrclk/bclk invertion */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_IB_IF: @@ -332,7 +332,7 @@ void aml_tdm_set_format( default: return; } - pr_info("sclk_ph0 (pad) clk ctl set:%x\n", clkctl); + pr_debug("sclk_ph0 (pad) clk ctl set:%x\n", clkctl); /* clk ctrl: delay line and invert clk */ /*clkctl |= 0x88880000;*/ #ifdef G12A_PTM @@ -472,7 +472,7 @@ void aml_tdm_set_lane_channel_swap( offset = EE_AUDIO_TDMOUT_B_MASK0 - EE_AUDIO_TDMOUT_A_MASK0; reg = EE_AUDIO_TDMOUT_A_MASK0 + offset * index; - pr_info("\ttdmout swap val = %#x\n", swap); + pr_debug("\ttdmout swap val = %#x\n", swap); offset = EE_AUDIO_TDMOUT_B_SWAP - EE_AUDIO_TDMOUT_A_SWAP; reg = EE_AUDIO_TDMOUT_A_SWAP + offset * index; aml_audiobus_write(actrl, reg, swap); @@ -480,7 +480,7 @@ void aml_tdm_set_lane_channel_swap( offset = EE_AUDIO_TDMIN_B_MASK0 - EE_AUDIO_TDMIN_A_MASK0; reg = EE_AUDIO_TDMIN_A_MASK0 + offset * index; - pr_info("\ttdmin swap val = %#x\n", swap); + pr_debug("\ttdmin swap val = %#x\n", swap); offset = EE_AUDIO_TDMIN_B_SWAP - EE_AUDIO_TDMIN_A_SWAP; reg = EE_AUDIO_TDMIN_A_SWAP + offset * index; aml_audiobus_write(actrl, reg, swap); @@ -506,7 +506,7 @@ void aml_tdm_set_lrclkdiv( { unsigned int reg, reg_step = 2; - pr_info("aml_dai_set_clkdiv, clksel(%d), ratio(%d)\n", + pr_debug("aml_dai_set_clkdiv, clksel(%d), ratio(%d)\n", clk_sel, ratio); reg = EE_AUDIO_MST_A_SCLK_CTRL0 + reg_step * clk_sel; -- 2.7.4