[Sound-open-firmware] [PATCH 1/3] dw-dma: add src_msize and dest_msize to dma_sg_element setting
We need configure different msize for different dma copy, so here introduce it to dma_sg_element struct.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/include/reef/dma.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/src/include/reef/dma.h b/src/include/reef/dma.h index 697e2c6..fea1cfa 100644 --- a/src/include/reef/dma.h +++ b/src/include/reef/dma.h @@ -70,6 +70,8 @@ struct dma_sg_elem { struct dma_sg_config { uint32_t src_width; uint32_t dest_width; + uint32_t src_msize; + uint32_t dest_msize; uint32_t direction; uint32_t src_dev; uint32_t dest_dev;
We should set src_msize and dest_msize for dma peripheral dev copy, for dai/ssp, they should be set to valid slot number, otherwise, the dma may copy in wrong burst size and data will run with wrong speed.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/audio/dai.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/src/audio/dai.c b/src/audio/dai.c index c50a274..e67e5cf 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -599,8 +599,26 @@ static int dai_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn) return 0; }
+/* + * use array to get msize for specific slot number setting. + * the relation between msize and slot_num should be + * 2 ^ msize = slot_num + */ +static const uint32_t msize[] = {1, 2, 4, 8}; static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config) { + struct dai_data *dd = comp_get_drvdata(dev); + int i; + + /* set dma msize according to slot number */ + for (i = 0; i < ARRAY_SIZE(msize); i++) { + if (msize[i] == config->num_slots) { + dd->config.src_msize = i; + dd->config.dest_msize = i; + break; + } + } + /* calc frame bytes */ switch (config->sample_valid_bits) { case 16:
On Sat, 2017-12-16 at 09:59 +0800, Keyon Jie wrote:
We should set src_msize and dest_msize for dma peripheral dev copy, for dai/ssp, they should be set to valid slot number, otherwise, the dma may copy in wrong burst size and data will run with wrong speed.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com
src/audio/dai.c | 18 ++++++++++++++++++
This is specific only for DW-MDA engine so should be in dw-dma.c and not dai.c which is generic.
Liam
1 file changed, 18 insertions(+)
diff --git a/src/audio/dai.c b/src/audio/dai.c index c50a274..e67e5cf 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -599,8 +599,26 @@ static int dai_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn) return 0; }
+/*
- use array to get msize for specific slot number setting.
- the relation between msize and slot_num should be
- 2 ^ msize = slot_num
- */
+static const uint32_t msize[] = {1, 2, 4, 8}; static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config) {
- struct dai_data *dd = comp_get_drvdata(dev);
- int i;
- /* set dma msize according to slot number */
- for (i = 0; i < ARRAY_SIZE(msize); i++) {
if (msize[i] == config->num_slots) {
dd->config.src_msize = i;
dd->config.dest_msize = i;
break;
}
- }
- /* calc frame bytes */ switch (config->sample_valid_bits) { case 16:
On 2017年12月17日 01:55, Liam Girdwood wrote:
On Sat, 2017-12-16 at 09:59 +0800, Keyon Jie wrote:
We should set src_msize and dest_msize for dma peripheral dev copy, for dai/ssp, they should be set to valid slot number, otherwise, the dma may copy in wrong burst size and data will run with wrong speed.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com
src/audio/dai.c | 18 ++++++++++++++++++
This is specific only for DW-MDA engine so should be in dw-dma.c and not dai.c which is generic.
OK, can you propose how should I change in detail then?
Thanks, ~Keyon
Liam
1 file changed, 18 insertions(+)
diff --git a/src/audio/dai.c b/src/audio/dai.c index c50a274..e67e5cf 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -599,8 +599,26 @@ static int dai_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn) return 0; }
+/*
- use array to get msize for specific slot number setting.
- the relation between msize and slot_num should be
- 2 ^ msize = slot_num
- */
+static const uint32_t msize[] = {1, 2, 4, 8}; static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config) {
- struct dai_data *dd = comp_get_drvdata(dev);
- int i;
- /* set dma msize according to slot number */
- for (i = 0; i < ARRAY_SIZE(msize); i++) {
if (msize[i] == config->num_slots) {
dd->config.src_msize = i;
dd->config.dest_msize = i;
break;
}
- }
- /* calc frame bytes */ switch (config->sample_valid_bits) { case 16:
For memory to memory copy, we don't require user to set msize, and set them to default 3, that is 2^3=8 items for each burst transaction.
For copy have peripheral device source/destination, we use the user configured src_msize and dest_msize, which usually be constrained by device hardware/fifos.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/drivers/dw-dma.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c index a28281a..958a659 100644 --- a/src/drivers/dw-dma.c +++ b/src/drivers/dw-dma.c @@ -518,8 +518,6 @@ static int dw_dma_set_config(struct dma *dma, int channel, goto out; }
- lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(3); /* config the src msize length 2^2 */ - lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(3); /* config the dest msize length 2^2 */ lli_desc->ctrl_lo |= DW_CTLL_INT_EN; /* enable interrupt */
/* config the SINC and DINC field of CTL_LOn, SRC/DST_PER filed of CFGn */ @@ -530,6 +528,8 @@ static int dw_dma_set_config(struct dma *dma, int channel, lli_desc->sar = (uint32_t)sg_elem->src | PLATFORM_HOST_DMA_MASK; lli_desc->dar = (uint32_t)sg_elem->dest; + lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(3); /* 2^3 items */ + lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(3); /* 2^3 items */ break; case DMA_DIR_HMEM_TO_LMEM: lli_desc->ctrl_lo |= DW_CTLL_FC_M2M; @@ -537,12 +537,16 @@ static int dw_dma_set_config(struct dma *dma, int channel, lli_desc->dar = (uint32_t)sg_elem->dest | PLATFORM_HOST_DMA_MASK; lli_desc->sar = (uint32_t)sg_elem->src; + lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(3); /* 2^3 items */ + lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(3); /* 2^3 items */ break; case DMA_DIR_MEM_TO_MEM: lli_desc->ctrl_lo |= DW_CTLL_FC_M2M; lli_desc->ctrl_lo |= DW_CTLL_SRC_INC | DW_CTLL_DST_INC; lli_desc->sar = (uint32_t)sg_elem->src | PLATFORM_HOST_DMA_MASK; lli_desc->dar = (uint32_t)sg_elem->dest | PLATFORM_HOST_DMA_MASK; + lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(3); /* 2^3 items */ + lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(3); /* 2^3 items */ break; case DMA_DIR_MEM_TO_DEV: lli_desc->ctrl_lo |= DW_CTLL_FC_M2P; @@ -551,6 +555,8 @@ static int dw_dma_set_config(struct dma *dma, int channel, DW_CFGH_DST_PER(config->dest_dev); lli_desc->sar = (uint32_t)sg_elem->src | PLATFORM_HOST_DMA_MASK; lli_desc->dar = (uint32_t)sg_elem->dest; + lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(config->src_msize); + lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(config->dest_msize); break; case DMA_DIR_DEV_TO_MEM: lli_desc->ctrl_lo |= DW_CTLL_FC_P2M; @@ -559,6 +565,8 @@ static int dw_dma_set_config(struct dma *dma, int channel, DW_CFGH_SRC_PER(config->src_dev); lli_desc->sar = (uint32_t)sg_elem->src; lli_desc->dar = (uint32_t)sg_elem->dest | PLATFORM_HOST_DMA_MASK; + lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(config->src_msize); + lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(config->dest_msize); break; case DMA_DIR_DEV_TO_DEV: lli_desc->ctrl_lo |= DW_CTLL_FC_P2P; @@ -568,6 +576,8 @@ static int dw_dma_set_config(struct dma *dma, int channel, DW_CFGH_DST_PER(config->dest_dev); lli_desc->sar = (uint32_t)sg_elem->src; lli_desc->dar = (uint32_t)sg_elem->dest; + lli_desc->ctrl_lo |= DW_CTLL_SRC_MSIZE(config->src_msize); + lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(config->dest_msize); break; default: trace_dma_error("eD4");
participants (2)
-
Keyon Jie
-
Liam Girdwood