diff options
author | Baolin Wang <baolin.wang@linaro.org> | 2019-04-23 05:26:22 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-04-25 21:43:49 +0300 |
commit | d7bff893e04f4e7b4a0789486da1435df5920f5a (patch) | |
tree | d110704cd86d70807dff57646d5eab23d9dee40c /sound/soc/sprd/sprd-mcdt.h | |
parent | c634d3ffc6b2c3b15ea79ffe0a761ce08b4da71a (diff) | |
download | linux-d7bff893e04f4e7b4a0789486da1435df5920f5a.tar.xz |
ASoC: sprd: Add Spreadtrum multi-channel data transfer support
On Spreadtrum platform, the audio subsystem will use the multi-channel
data transfer controller to transfer sound stream between audio subsystem
and other AP/CP subsystem.
It can support 10 DAC channel and 10 ADC channel, and each channel has
512 bytes depth data fifo. Moreover each channel can be used DMA mode
or interrupt mode to transfer data.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sprd/sprd-mcdt.h')
-rw-r--r-- | sound/soc/sprd/sprd-mcdt.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/sound/soc/sprd/sprd-mcdt.h b/sound/soc/sprd/sprd-mcdt.h new file mode 100644 index 000000000000..9cc7e207ac76 --- /dev/null +++ b/sound/soc/sprd/sprd-mcdt.h @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef __SPRD_MCDT_H +#define __SPRD_MCDT_H + +enum sprd_mcdt_channel_type { + SPRD_MCDT_DAC_CHAN, + SPRD_MCDT_ADC_CHAN, + SPRD_MCDT_UNKNOWN_CHAN, +}; + +enum sprd_mcdt_dma_chan { + SPRD_MCDT_DMA_CH0, + SPRD_MCDT_DMA_CH1, + SPRD_MCDT_DMA_CH2, + SPRD_MCDT_DMA_CH3, + SPRD_MCDT_DMA_CH4, +}; + +struct sprd_mcdt_chan_callback { + void (*notify)(void *data); + void *data; +}; + +/** + * struct sprd_mcdt_chan - this struct represents a single channel instance + * @mcdt: the mcdt controller + * @id: channel id + * @fifo_phys: channel fifo physical address which is used for DMA transfer + * @type: channel type + * @cb: channel fifo interrupt's callback interface to notify the fifo events + * @dma_enable: indicate if use DMA mode to transfer data + * @int_enable: indicate if use interrupt mode to notify users to read or + * write data manually + * @list: used to link into the global list + * + * Note: users should not modify any members of this structure. + */ +struct sprd_mcdt_chan { + struct sprd_mcdt_dev *mcdt; + u8 id; + unsigned long fifo_phys; + enum sprd_mcdt_channel_type type; + enum sprd_mcdt_dma_chan dma_chan; + struct sprd_mcdt_chan_callback *cb; + bool dma_enable; + bool int_enable; + struct list_head list; +}; + +#ifdef CONFIG_SND_SOC_SPRD_MCDT +struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel, + enum sprd_mcdt_channel_type type); +void sprd_mcdt_free_chan(struct sprd_mcdt_chan *chan); + +int sprd_mcdt_chan_write(struct sprd_mcdt_chan *chan, char *tx_buf, u32 size); +int sprd_mcdt_chan_read(struct sprd_mcdt_chan *chan, char *rx_buf, u32 size); +int sprd_mcdt_chan_int_enable(struct sprd_mcdt_chan *chan, u32 water_mark, + struct sprd_mcdt_chan_callback *cb); +void sprd_mcdt_chan_int_disable(struct sprd_mcdt_chan *chan); + +int sprd_mcdt_chan_dma_enable(struct sprd_mcdt_chan *chan, + enum sprd_mcdt_dma_chan dma_chan, u32 water_mark); +void sprd_mcdt_chan_dma_disable(struct sprd_mcdt_chan *chan); + +#else + +struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel, + enum sprd_mcdt_channel_type type) +{ + return NULL; +} + +void sprd_mcdt_free_chan(struct sprd_mcdt_chan *chan) +{ } + +int sprd_mcdt_chan_write(struct sprd_mcdt_chan *chan, char *tx_buf, u32 size) +{ + return -EINVAL; +} + +int sprd_mcdt_chan_read(struct sprd_mcdt_chan *chan, char *rx_buf, u32 size) +{ + return 0; +} + +int sprd_mcdt_chan_int_enable(struct sprd_mcdt_chan *chan, u32 water_mark, + struct sprd_mcdt_chan_callback *cb) +{ + return -EINVAL; +} + +void sprd_mcdt_chan_int_disable(struct sprd_mcdt_chan *chan) +{ } + +int sprd_mcdt_chan_dma_enable(struct sprd_mcdt_chan *chan, + enum sprd_mcdt_dma_chan dma_chan, u32 water_mark) +{ + return -EINVAL; +} + +void sprd_mcdt_chan_dma_disable(struct sprd_mcdt_chan *chan) +{ } + +#endif + +#endif /* __SPRD_MCDT_H */ |