diff options
author | Chen Liangjun <b36089@freescale.com> | 2012-11-13 16:43:25 +0800 |
---|---|---|
committer | Chen Liangjun <b36089@freescale.com> | 2012-11-14 14:53:26 +0800 |
commit | 2103aa2f98bfafb504783dca387f9b182556a9c0 (patch) | |
tree | f384bed29433915a2a039bacaf0f4c8e1d6653a1 /drivers/mxc/asrc | |
parent | a4fe73addea738929f5145c0d1d6539d74723784 (diff) |
ENGR00233427 ASRC: add interface to modify ASRC input/output watermark
In this patch, add interface to modify ASRC input/output watermark.
Signed-off-by: Chen Liangjun <b36089@freescale.com>
Diffstat (limited to 'drivers/mxc/asrc')
-rw-r--r-- | drivers/mxc/asrc/mxc_asrc.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/drivers/mxc/asrc/mxc_asrc.c b/drivers/mxc/asrc/mxc_asrc.c index b728fe19226d..228f733b43fb 100644 --- a/drivers/mxc/asrc/mxc_asrc.c +++ b/drivers/mxc/asrc/mxc_asrc.c @@ -661,6 +661,28 @@ int asrc_config_pair(struct asrc_config *config) EXPORT_SYMBOL(asrc_config_pair); +int asrc_set_watermark(enum asrc_pair_index index, u32 in_wm, u32 out_wm) +{ + u32 reg; + + if ((in_wm > 63) || (out_wm > 63)) { + pr_err("error watermark!\n"); + return -EINVAL; + } + + reg = __raw_readl( + g_asrc->vaddr + ASRC_ASRMCRA_REG + (index << 3)); + reg |= 1 << 22; + reg &= ~0x3f; + reg += in_wm; + reg &= ~(0x3f << 12); + reg += out_wm << 12; + __raw_writel(reg, + g_asrc->vaddr + ASRC_ASRMCRA_REG + (index << 3)); + return 0; +} +EXPORT_SYMBOL(asrc_set_watermark); + void asrc_start_conv(enum asrc_pair_index index) { int reg, reg_1; @@ -1113,13 +1135,13 @@ static int imx_asrc_dma_config( slave_config.dst_addr = dma_addr; slave_config.dst_addr_width = buswidth; slave_config.dst_maxburst = - ASRC_INPUTFIFO_THRESHOLD * params->channel_nums; + params->input_wm * params->channel_nums; } else { slave_config.direction = DMA_DEV_TO_MEM; slave_config.src_addr = dma_addr; slave_config.src_addr_width = buswidth; slave_config.src_maxburst = - ASRC_OUTPUTFIFO_THRESHOLD * params->channel_nums; + params->output_wm * params->channel_nums; } ret = dmaengine_slave_config(chan, &slave_config); if (ret) { @@ -1223,7 +1245,7 @@ static int mxc_asrc_prepare_input_buffer(struct asrc_pair_params *params, } if (pbuf->input_buffer_length < - word_size * params->channel_nums * ASRC_INPUTFIFO_THRESHOLD) { + word_size * params->channel_nums * params->input_wm) { pr_err("input buffer size[%d] is too small!\n", pbuf->input_buffer_length); return -EINVAL; @@ -1447,6 +1469,13 @@ static long asrc_ioctl(struct file *file, err = asrc_config_pair(&config); if (err < 0) break; + + params->input_wm = 4; + params->output_wm = 2; + err = asrc_set_watermark(config.pair, + params->input_wm, params->output_wm); + if (err < 0) + break; params->output_buffer_size = config.dma_buffer_size; params->input_buffer_size = config.dma_buffer_size; if (config.buffer_num > ASRC_DMA_BUFFER_NUM) |