mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
b287a6d972
With EDMA, there is two dma channels can be used for dev_to_dev, one is from ASRC, one is from another peripheral (ESAI or SAI). If we select the dma channel of ASRC, there is an issue for ideal ratio case, the speed of copy data is faster than sample frequency, because ASRC output data is very fast in ideal ratio mode. So it is reasonable to use the dma channel of Back-End peripheral. then copying speed of DMA is controlled by data consumption speed in the peripheral FIFO, Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Nicolin Chen <nicoleotsuka@gmail.com> Link: https://lore.kernel.org/r/424ed6c249bafcbe30791c9de0352821c5ea67e2.1591947428.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
109 lines
2.8 KiB
C
109 lines
2.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright 2019 NXP
|
|
*
|
|
*/
|
|
|
|
#ifndef _FSL_ASRC_COMMON_H
|
|
#define _FSL_ASRC_COMMON_H
|
|
|
|
/* directions */
|
|
#define IN 0
|
|
#define OUT 1
|
|
|
|
enum asrc_pair_index {
|
|
ASRC_INVALID_PAIR = -1,
|
|
ASRC_PAIR_A = 0,
|
|
ASRC_PAIR_B = 1,
|
|
ASRC_PAIR_C = 2,
|
|
ASRC_PAIR_D = 3,
|
|
};
|
|
|
|
#define PAIR_CTX_NUM 0x4
|
|
|
|
/**
|
|
* fsl_asrc_pair: ASRC Pair common data
|
|
*
|
|
* @asrc: pointer to its parent module
|
|
* @error: error record
|
|
* @index: pair index (ASRC_PAIR_A, ASRC_PAIR_B, ASRC_PAIR_C)
|
|
* @channels: occupied channel number
|
|
* @desc: input and output dma descriptors
|
|
* @dma_chan: inputer and output DMA channels
|
|
* @dma_data: private dma data
|
|
* @pos: hardware pointer position
|
|
* @req_dma_chan: flag to release dev_to_dev chan
|
|
* @private: pair private area
|
|
*/
|
|
struct fsl_asrc_pair {
|
|
struct fsl_asrc *asrc;
|
|
unsigned int error;
|
|
|
|
enum asrc_pair_index index;
|
|
unsigned int channels;
|
|
|
|
struct dma_async_tx_descriptor *desc[2];
|
|
struct dma_chan *dma_chan[2];
|
|
struct imx_dma_data dma_data;
|
|
unsigned int pos;
|
|
bool req_dma_chan;
|
|
|
|
void *private;
|
|
};
|
|
|
|
/**
|
|
* fsl_asrc: ASRC common data
|
|
*
|
|
* @dma_params_rx: DMA parameters for receive channel
|
|
* @dma_params_tx: DMA parameters for transmit channel
|
|
* @pdev: platform device pointer
|
|
* @regmap: regmap handler
|
|
* @paddr: physical address to the base address of registers
|
|
* @mem_clk: clock source to access register
|
|
* @ipg_clk: clock source to drive peripheral
|
|
* @spba_clk: SPBA clock (optional, depending on SoC design)
|
|
* @lock: spin lock for resource protection
|
|
* @pair: pair pointers
|
|
* @channel_avail: non-occupied channel numbers
|
|
* @asrc_rate: default sample rate for ASoC Back-Ends
|
|
* @asrc_format: default sample format for ASoC Back-Ends
|
|
* @use_edma: edma is used
|
|
* @get_dma_channel: function pointer
|
|
* @request_pair: function pointer
|
|
* @release_pair: function pointer
|
|
* @get_fifo_addr: function pointer
|
|
* @pair_priv_size: size of pair private struct.
|
|
* @private: private data structure
|
|
*/
|
|
struct fsl_asrc {
|
|
struct snd_dmaengine_dai_dma_data dma_params_rx;
|
|
struct snd_dmaengine_dai_dma_data dma_params_tx;
|
|
struct platform_device *pdev;
|
|
struct regmap *regmap;
|
|
unsigned long paddr;
|
|
struct clk *mem_clk;
|
|
struct clk *ipg_clk;
|
|
struct clk *spba_clk;
|
|
spinlock_t lock; /* spin lock for resource protection */
|
|
|
|
struct fsl_asrc_pair *pair[PAIR_CTX_NUM];
|
|
unsigned int channel_avail;
|
|
|
|
int asrc_rate;
|
|
snd_pcm_format_t asrc_format;
|
|
bool use_edma;
|
|
|
|
struct dma_chan *(*get_dma_channel)(struct fsl_asrc_pair *pair, bool dir);
|
|
int (*request_pair)(int channels, struct fsl_asrc_pair *pair);
|
|
void (*release_pair)(struct fsl_asrc_pair *pair);
|
|
int (*get_fifo_addr)(u8 dir, enum asrc_pair_index index);
|
|
size_t pair_priv_size;
|
|
|
|
void *private;
|
|
};
|
|
|
|
#define DRV_NAME "fsl-asrc-dai"
|
|
extern struct snd_soc_component_driver fsl_asrc_component;
|
|
|
|
#endif /* _FSL_ASRC_COMMON_H */
|