Browse Source

MLK-10048-4: ASoC: fsl_asrc: fix dma task timeout issue when use 3 instance

Merged from 49108fcf7b
1. Watermark level in sdma use byte as its unit. but asrc driver use
word, there is mismatch between them. Here fix this issue and sdma can
work more efficiency.
2. Enlarge the larst_period_size, when use small size, for some case,
the dma task will timeout, because sdma has no much data for output.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
isee-imx_3.14.28.y
Shengjiu Wang 6 years ago
committed by Nitin Garg
parent
commit
a73b35be1d
2 changed files with 14 additions and 6 deletions
  1. +2
    -1
      sound/soc/fsl/fsl_asrc.h
  2. +12
    -5
      sound/soc/fsl/fsl_asrc_m2m.c

+ 2
- 1
sound/soc/fsl/fsl_asrc.h View File

@ -25,7 +25,8 @@
#define ASRC_FIFO_THRESHOLD_MAX 63
#define ASRC_DMA_BUFFER_SIZE (1024 * 48 * 4)
#define ASRC_MAX_BUFFER_SIZE (1024 * 48)
#define ASRC_OUTPUT_LAST_SAMPLE 8
#define ASRC_OUTPUT_LAST_SAMPLE_MAX 32
#define ASRC_OUTPUT_LAST_SAMPLE 16
#define IDEAL_RATIO_RATE 1000000


+ 12
- 5
sound/soc/fsl/fsl_asrc_m2m.c View File

@ -24,6 +24,7 @@ struct fsl_asrc_m2m {
enum asrc_word_width word_width[2];
unsigned int rate[2];
unsigned int last_period_size;
u32 watermark[2];
spinlock_t lock;
};
@ -111,8 +112,8 @@ retry:
if (size)
goto retry;
if (t_size > ASRC_OUTPUT_LAST_SAMPLE)
t_size = ASRC_OUTPUT_LAST_SAMPLE;
if (t_size > m2m->last_period_size)
t_size = m2m->last_period_size;
if (reg24)
output->length += t_size * pair->channels * 4;
@ -181,13 +182,13 @@ static int fsl_asrc_dmaconfig(struct fsl_asrc_pair *pair, struct dma_chan *chan,
slave_config.dst_addr = dma_addr;
slave_config.dst_addr_width = buswidth;
slave_config.dst_maxburst =
m2m->watermark[IN] * pair->channels / buswidth;
m2m->watermark[IN] * pair->channels;
} else {
slave_config.direction = DMA_DEV_TO_MEM;
slave_config.src_addr = dma_addr;
slave_config.src_addr_width = buswidth;
slave_config.src_maxburst =
m2m->watermark[OUT] * pair->channels / buswidth;
m2m->watermark[OUT] * pair->channels;
}
ret = dmaengine_slave_config(chan, &slave_config);
@ -251,6 +252,7 @@ static int fsl_asrc_prepare_io_buffer(struct fsl_asrc_pair *pair,
struct dma_chan *dma_chan = pair->dma_chan[dir];
unsigned int buf_len, wm = m2m->watermark[dir];
unsigned int *sg_nodes = &m2m->sg_nodes[dir];
unsigned int last_period_size = m2m->last_period_size;
enum asrc_pair_index index = pair->index;
u32 word_size, fifo_addr;
void __user *buf_vaddr;
@ -283,7 +285,7 @@ static int fsl_asrc_prepare_io_buffer(struct fsl_asrc_pair *pair,
*dma_len = buf_len;
if (dir == OUT)
*dma_len -= ASRC_OUTPUT_LAST_SAMPLE * word_size * pair->channels;
*dma_len -= last_period_size * word_size * pair->channels;
*sg_nodes = *dma_len / ASRC_MAX_BUFFER_SIZE + 1;
@ -556,6 +558,11 @@ static long fsl_asrc_ioctl_config_pair(struct fsl_asrc_pair *pair,
m2m->rate[IN] = config.input_sample_rate;
m2m->rate[OUT] = config.output_sample_rate;
if (m2m->rate[OUT] > m2m->rate[IN])
m2m->last_period_size = ASRC_OUTPUT_LAST_SAMPLE_MAX;
else
m2m->last_period_size = ASRC_OUTPUT_LAST_SAMPLE;
ret = fsl_allocate_dma_buf(pair);
if (ret) {
pair_err("failed to allocate DMA buffer: %ld\n", ret);


Loading…
Cancel
Save