[Sound-open-firmware] [PATCH 2/5][RFC] APL/CNL: Implement host DMA copy in existed DMA copy API.

yan.wang at linux.intel.com yan.wang at linux.intel.com
Tue Mar 13 11:16:11 CET 2018


From: Yan Wang <yan.wang at linux.intel.com>

Get DMA channel based on stream tag when use host DMA.
Need also call different API in dma_copy_to_host_nowait().

Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
---
 src/include/reef/dma.h |  4 ++++
 src/ipc/dma-copy.c     | 40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/include/reef/dma.h b/src/include/reef/dma.h
index 247bcbf..0f7dbfc 100644
--- a/src/include/reef/dma.h
+++ b/src/include/reef/dma.h
@@ -278,4 +278,8 @@ int dma_copy_to_host(struct dma_copy *dc, struct dma_sg_config *host_sg,
 int dma_copy_to_host_nowait(struct dma_copy *dc, struct dma_sg_config *host_sg,
 	int32_t host_offset, void *local_ptr, int32_t size);
 
+#if defined CONFIG_DMA_GW
+int dma_set_channel(struct dma_copy *dc, uint32_t stream_tag);
+#endif
+
 #endif
diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c
index 06f05d5..f11acf1 100644
--- a/src/ipc/dma-copy.c
+++ b/src/ipc/dma-copy.c
@@ -70,6 +70,8 @@ static struct dma_sg_elem *sg_get_elem_at(struct dma_sg_config *host_sg,
 	return NULL;
 }
 
+#if !defined CONFIG_DMA_GW
+
 static void dma_complete(void *data, uint32_t type, struct dma_sg_elem *next)
 {
 	completion_t *comp = (completion_t *)data;
@@ -84,6 +86,8 @@ static void dma_complete(void *data, uint32_t type, struct dma_sg_elem *next)
 	next->size = DMA_RELOAD_END;
 }
 
+#endif
+
 /* Copy DSP memory to host memory.
  * copies DSP memory to host in PAGE_SIZE or smaller blocks and waits/sleeps
  * between blocks. Can't be used in IRQ context.
@@ -172,8 +176,22 @@ int dma_copy_to_host(struct dma_copy *dc, struct dma_sg_config *host_sg,
  * Copies DSP memory to host in a single PAGE_SIZE or smaller block. Does not
  * waits/sleeps and can be used in IRQ context.
  */
+#if defined CONFIG_DMA_GW
+
 int dma_copy_to_host_nowait(struct dma_copy *dc, struct dma_sg_config *host_sg,
-	int32_t host_offset, void *local_ptr, int32_t size)
+			    int32_t host_offset, void *local_ptr, int32_t size)
+{
+	/* tell gateway to copy */
+	dma_copy(dc->dmac, dc->chan, size);
+
+	/* bytes copied */
+	return size;
+}
+
+#else
+
+int dma_copy_to_host_nowait(struct dma_copy *dc, struct dma_sg_config *host_sg,
+			    int32_t host_offset, void *local_ptr, int32_t size)
 {
 	struct dma_sg_config config;
 	struct dma_sg_elem *host_sg_elem;
@@ -219,6 +237,8 @@ int dma_copy_to_host_nowait(struct dma_copy *dc, struct dma_sg_config *host_sg,
 	return local_sg_elem.size;
 }
 
+#endif
+
 /* Copy host memory to DSP memory.
  * Copies host memory to host in PAGE_SIZE or smaller blocks and waits/sleeps
  * between blocks. Cant be used in IRQ context.
@@ -359,6 +379,7 @@ int dma_copy_new(struct dma_copy *dc, int dmac)
 		return -ENODEV;
 	}
 
+#if !defined CONFIG_DMA_GW
 	/* get DMA channel from DMAC0 */
 	dc->chan = dma_channel_get(dc->dmac, 0);
 	if (dc->chan < 0) {
@@ -369,6 +390,23 @@ int dma_copy_new(struct dma_copy *dc, int dmac)
 	dc->complete.timeout = 100;	/* wait 100 usecs for DMA to finish */
 	dma_set_cb(dc->dmac, dc->chan, DMA_IRQ_TYPE_LLIST, dma_complete,
 		&dc->complete);
+#endif
+
 	return 0;
 }
 
+#if defined CONFIG_DMA_GW
+
+int dma_set_channel(struct dma_copy *dc, uint32_t stream_tag)
+{
+	/* get DMA channel from DMAC */
+	dc->chan = dma_channel_get(dc->dmac, stream_tag - 1);
+	if (dc->chan < 0) {
+		trace_dma_error("ec1");
+		return dc->chan;
+	}
+
+	return 0;
+}
+
+#endif
-- 
2.14.3



More information about the Sound-open-firmware mailing list