[Sound-open-firmware] [RFC PATCH v2 6/8] dma: use newly defined API for request DMAC

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Thu Jun 7 01:09:03 CEST 2018


Use the new dma_get() API to procure DMAC's for all the users.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 src/audio/dai.c        |  3 ++-
 src/audio/host.c       | 20 ++++++++++++--------
 src/host/common_test.c |  2 +-
 src/ipc/apl-ipc.c      |  4 ++--
 src/ipc/byt-ipc.c      |  4 ++--
 src/ipc/cnl-ipc.c      |  4 ++--
 src/ipc/dma-copy.c     |  3 ++-
 src/ipc/hsw-ipc.c      |  4 ++--
 8 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/audio/dai.c b/src/audio/dai.c
index 1eeecd2..b6e984d 100644
--- a/src/audio/dai.c
+++ b/src/audio/dai.c
@@ -201,7 +201,8 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
 		goto error;
 	}
 
-	dd->dma = dma_get(ipc_dai->dmac_id);
+	/* request DMAC with DMA_DIR_MEM_TO_DEV cap and shared access flag */
+	dd->dma = dma_get((1 << DMA_DIR_MEM_TO_DEV), DMAC_FLAGS_SHARED);
 	if (dd->dma == NULL) {
 		trace_dai_error("eDd");
 		goto error;
diff --git a/src/audio/host.c b/src/audio/host.c
index c0f4e1b..2a3ab00 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -529,14 +529,18 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
 
 	comp_set_drvdata(dev, hd);
 
-#if !defined CONFIG_DMA_GW
-	hd->dma = dma_get(ipc_host->dmac_id);
-#else
-	if (ipc_host->direction == SOF_IPC_STREAM_PLAYBACK)
-		hd->dma = dma_get(DMA_HOST_OUT_DMAC);
-	else
-		hd->dma = dma_get(DMA_HOST_IN_DMAC);
-#endif
+	if (ipc_host->direction == SOF_IPC_STREAM_PLAYBACK) {
+
+		/* get DMAC with DMA_DIR_HMEM_TO_LMEM cap & shared flag */
+		hd->dma = dma_get((1 << DMA_DIR_HMEM_TO_LMEM),
+				  DMAC_FLAGS_SHARED);
+	} else {
+
+		/* get DMAC with DMA_DIR_LMEM_TO_HMEM cap & shared flag */
+		hd->dma = dma_get((1 << DMA_DIR_LMEM_TO_HMEM),
+				  DMAC_FLAGS_SHARED);
+	}
+
 	if (hd->dma == NULL) {
 		trace_host_error("eDM");
 		goto error;
diff --git a/src/host/common_test.c b/src/host/common_test.c
index e286883..ef91577 100644
--- a/src/host/common_test.c
+++ b/src/host/common_test.c
@@ -200,7 +200,7 @@ struct dai *dai_get(uint32_t type, uint32_t index)
 	return NULL;
 }
 
-struct dma *dma_get(int dmac_id)
+struct dma *dma_get(int dma_cap, int flags)
 {
 	return NULL;
 }
diff --git a/src/ipc/apl-ipc.c b/src/ipc/apl-ipc.c
index 78291d0..f08fc80 100644
--- a/src/ipc/apl-ipc.c
+++ b/src/ipc/apl-ipc.c
@@ -198,8 +198,8 @@ int platform_ipc_init(struct ipc *ipc)
 	if (iipc->page_table)
 		bzero(iipc->page_table, HOST_PAGE_SIZE);
 
-	/* dma */
-	iipc->dmac = dma_get(DMA_GP_LP_DMAC0);
+	/* request DMAC with DMA_DIR_HMEM_TO_LMEM and shared access flag */
+	iipc->dmac = dma_get((1 << DMA_DIR_HMEM_TO_LMEM), DMAC_FLAGS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
diff --git a/src/ipc/byt-ipc.c b/src/ipc/byt-ipc.c
index 87e7949..f794f5d 100644
--- a/src/ipc/byt-ipc.c
+++ b/src/ipc/byt-ipc.c
@@ -225,8 +225,8 @@ int platform_ipc_init(struct ipc *ipc)
 	if (iipc->page_table)
 		bzero(iipc->page_table, PLATFORM_PAGE_TABLE_SIZE);
 
-	/* dma */
-	iipc->dmac = dma_get(DMA_ID_DMAC0);
+	/* request DMAC with DMA_DIR_HMEM_TO_LMEM and shared access flag */
+	iipc->dmac = dma_get((1 << DMA_DIR_HMEM_TO_LMEM), DMAC_FLAGS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
diff --git a/src/ipc/cnl-ipc.c b/src/ipc/cnl-ipc.c
index ba65164..c92dd1f 100644
--- a/src/ipc/cnl-ipc.c
+++ b/src/ipc/cnl-ipc.c
@@ -198,8 +198,8 @@ int platform_ipc_init(struct ipc *ipc)
 	if (iipc->page_table)
 		bzero(iipc->page_table, HOST_PAGE_SIZE);
 
-	/* dma */
-	iipc->dmac = dma_get(DMA_GP_LP_DMAC0);
+	/* request DMAC with DMA_DIR_HMEM_TO_LMEM and shared access flag */
+	iipc->dmac = dma_get((1 << DMA_DIR_HMEM_TO_LMEM), DMAC_FLAGS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c
index be72eb8..b801448 100644
--- a/src/ipc/dma-copy.c
+++ b/src/ipc/dma-copy.c
@@ -375,7 +375,8 @@ int dma_copy_from_host_nowait(struct dma_copy *dc, struct dma_sg_config *host_sg
 
 int dma_copy_new(struct dma_copy *dc, int dmac)
 {
-	dc->dmac = dma_get(dmac);
+	/* request DMAC with DMA_DIR_LMEM_TO_HMEM and shared access flag */
+	dc->dmac = dma_get((1 << DMA_DIR_LMEM_TO_HMEM), DMAC_FLAGS_SHARED);
 	if (dc->dmac == NULL) {
 		trace_dma_error("ec0");
 		return -ENODEV;
diff --git a/src/ipc/hsw-ipc.c b/src/ipc/hsw-ipc.c
index aa4d9e1..a2a169c 100644
--- a/src/ipc/hsw-ipc.c
+++ b/src/ipc/hsw-ipc.c
@@ -221,8 +221,8 @@ int platform_ipc_init(struct ipc *ipc)
 	if (iipc->page_table)
 		bzero(iipc->page_table, PLATFORM_PAGE_TABLE_SIZE);
 
-	/* dma */
-	iipc->dmac = dma_get(DMA_ID_DMAC1);
+	/* request DMAC with DMA_DIR_HMEM_TO_LMEM and shared access flag */
+	iipc->dmac = dma_get((1 << DMA_DIR_HMEM_TO_LMEM), DMAC_FLAGS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
-- 
2.17.1



More information about the Sound-open-firmware mailing list