[Sound-open-firmware] [PATCH v3 5/6] dma: update dma users with the new API

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Sat Jun 9 00:18:30 CEST 2018


Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 src/audio/dai.c        |  5 ++++-
 src/audio/host.c       | 18 ++++++++++--------
 src/host/common_test.c |  2 +-
 src/ipc/apl-ipc.c      |  6 ++++--
 src/ipc/byt-ipc.c      |  7 ++++---
 src/ipc/cnl-ipc.c      |  6 ++++--
 src/ipc/dma-copy.c     |  5 ++++-
 src/ipc/hsw-ipc.c      |  7 ++++---
 8 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/src/audio/dai.c b/src/audio/dai.c
index 1eeecd2..6ed1e86 100644
--- a/src/audio/dai.c
+++ b/src/audio/dai.c
@@ -176,6 +176,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
 	struct sof_ipc_comp_dai *dai;
 	struct sof_ipc_comp_dai *ipc_dai = (struct sof_ipc_comp_dai *)comp;
 	struct dai_data *dd;
+	uint32_t dma_cap;
 
 	trace_dai("new");
 
@@ -201,7 +202,9 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
 		goto error;
 	}
 
-	dd->dma = dma_get(ipc_dai->dmac_id);
+	/* request GP LP DMA with shared access privilege */
+	dma_cap = DMA_CAP_GP_LP | DMA_CAP_MEM_TO_DEV;
+	dd->dma = dma_get(dma_cap, DMA_ACCESS_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..ab8c20e 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -503,6 +503,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
 	struct sof_ipc_comp_host *host;
 	struct sof_ipc_comp_host *ipc_host = (struct sof_ipc_comp_host *)comp;
 	struct dma_sg_elem *elem;
+	uint32_t dma_cap;
 
 	trace_host("new");
 
@@ -529,14 +530,15 @@ 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
+	/* request Host DMA with shared access privilege */
+	if (ipc_host->direction == SOF_IPC_STREAM_PLAYBACK) {
+		dma_cap = DMA_CAP_HDA_HOST | DMA_CAP_HMEM_TO_LMEM;
+		hd->dma = dma_get(dma_cap, DMA_ACCESS_SHARED);
+	} else {
+		dma_cap = DMA_CAP_HDA_HOST | DMA_CAP_LMEM_TO_HMEM;
+		hd->dma = dma_get(dma_cap, DMA_ACCESS_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..fa4891f 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(uint32_t dmac_id, uint32_t flags)
 {
 	return NULL;
 }
diff --git a/src/ipc/apl-ipc.c b/src/ipc/apl-ipc.c
index 78291d0..79c5782 100644
--- a/src/ipc/apl-ipc.c
+++ b/src/ipc/apl-ipc.c
@@ -177,6 +177,7 @@ out:
 int platform_ipc_init(struct ipc *ipc)
 {
 	struct intel_ipc_data *iipc;
+	uint32_t dma_cap;
 	int i;
 
 	_ipc = ipc;
@@ -198,8 +199,9 @@ 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 GP LP DMA with shared access privilege */
+	dma_cap = DMA_CAP_GP_LP | DMA_CAP_HMEM_TO_LMEM;
+	iipc->dmac = dma_get(dma_cap, DMA_ACCESS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
diff --git a/src/ipc/byt-ipc.c b/src/ipc/byt-ipc.c
index 87e7949..c541c62 100644
--- a/src/ipc/byt-ipc.c
+++ b/src/ipc/byt-ipc.c
@@ -202,7 +202,7 @@ out:
 int platform_ipc_init(struct ipc *ipc)
 {
 	struct intel_ipc_data *iipc;
-	uint32_t imrd;
+	uint32_t imrd, dma_cap;
 	int i;
 
 	_ipc = ipc;
@@ -225,8 +225,9 @@ 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 DMA with shared access privilege */
+	dma_cap = DMA_CAP_GP_LP | DMA_CAP_HMEM_TO_LMEM;
+	iipc->dmac = dma_get(dma_cap, DMA_ACCESS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
diff --git a/src/ipc/cnl-ipc.c b/src/ipc/cnl-ipc.c
index ba65164..d66d46a 100644
--- a/src/ipc/cnl-ipc.c
+++ b/src/ipc/cnl-ipc.c
@@ -178,6 +178,7 @@ int platform_ipc_init(struct ipc *ipc)
 {
 	struct intel_ipc_data *iipc;
 	int i;
+	uint32_t dma_cap;
 
 	_ipc = ipc;
 
@@ -198,8 +199,9 @@ 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 GP LP DMA with shared access privilege */
+	dma_cap = DMA_CAP_GP_LP | DMA_CAP_HMEM_TO_LMEM;
+	iipc->dmac = dma_get(dma_cap, DMA_ACCESS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c
index be72eb8..25f891c 100644
--- a/src/ipc/dma-copy.c
+++ b/src/ipc/dma-copy.c
@@ -375,7 +375,10 @@ 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);
+	uint32_t dma_cap;
+
+	dma_cap = DMA_CAP_HDA_HOST | DMA_CAP_LMEM_TO_HMEM;
+	dc->dmac = dma_get(dma_cap, DMA_ACCESS_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..fd54c0f 100644
--- a/src/ipc/hsw-ipc.c
+++ b/src/ipc/hsw-ipc.c
@@ -198,7 +198,7 @@ out:
 int platform_ipc_init(struct ipc *ipc)
 {
 	struct intel_ipc_data *iipc;
-	uint32_t imrd;
+	uint32_t imrd, dma_cap;
 	int i;
 
 	_ipc = ipc;
@@ -221,8 +221,9 @@ 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 GP LP DMA with shared access privilege */
+	dma_cap = DMA_CAP_GP_LP | DMA_CAP_HMEM_TO_LMEM;
+	iipc->dmac = dma_get(dma_cap, DMA_ACCESS_SHARED);
 
 	/* PM */
 	iipc->pm_prepare_D3 = 0;
-- 
2.17.1



More information about the Sound-open-firmware mailing list