From 8845e25f4a4182ecb83908c296c5bc5cf5891d72 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 22 Nov 2018 18:19:50 +0800 Subject: [PATCH 1/3] dma: enable legacy platform dmac Add channel number to dmac in legacy platforms, and change the dma_init function to fit the curruct code framework. Signed-off-by: Pan Xiuli --- src/platform/baytrail/dma.c | 19 +++++++++---------- src/platform/haswell/dma.c | 18 ++++++++---------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/platform/baytrail/dma.c b/src/platform/baytrail/dma.c index f7fe1bc4a2c4..56673a1309c8 100644 --- a/src/platform/baytrail/dma.c +++ b/src/platform/baytrail/dma.c @@ -153,6 +153,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = { .caps = DMA_CAP_GP_HP, .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST, .base = DMA0_BASE, + .channels = 8, .irq = IRQ_NUM_EXT_DMAC0, .drv_plat_data = &dmac0, }, @@ -167,6 +168,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = { .caps = DMA_CAP_GP_HP, .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST, .base = DMA1_BASE, + .channels = 8, .irq = IRQ_NUM_EXT_DMAC1, .drv_plat_data = &dmac1, }, @@ -182,6 +184,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = { .caps = DMA_CAP_GP_HP, .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST, .base = DMA2_BASE, + .channels = 8, .irq = IRQ_NUM_EXT_DMAC2, .drv_plat_data = &dmac2, }, @@ -193,18 +196,14 @@ struct dma dma[PLATFORM_NUM_DMACS] = { /* Initialize all platform DMAC's */ int dmac_init(void) { - int i, ret; + int i; + /* no probing before first use */ - for (i = 0; i < ARRAY_SIZE(dma); i++) { - ret = dma_probe(&dma[i]); - if (ret < 0) { + /* TODO: dynamic init based on platform settings */ - /* trace failed DMAC ID */ - trace_error(TRACE_CLASS_DMA, "edi"); - trace_error_value(dma[i].plat_data.id); - return ret; - } - } + /* early lock initialization for ref counting */ + for (i = 0; i < ARRAY_SIZE(dma); i++) + spinlock_init(&dma[i].lock); /* tell the lib DMAs are ready to use */ dma_install(dma, ARRAY_SIZE(dma)); diff --git a/src/platform/haswell/dma.c b/src/platform/haswell/dma.c index aaa6904410bd..588208ad637a 100644 --- a/src/platform/haswell/dma.c +++ b/src/platform/haswell/dma.c @@ -115,6 +115,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = { .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST, .irq = IRQ_NUM_EXT_DMAC0, .drv_plat_data = &dmac0, + .channels = 8, }, .ops = &dw_dma_ops, }, @@ -128,6 +129,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = { .devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST, .irq = IRQ_NUM_EXT_DMAC1, .drv_plat_data = &dmac1, + .channels = 8, }, .ops = &dw_dma_ops, },}; @@ -135,18 +137,14 @@ struct dma dma[PLATFORM_NUM_DMACS] = { /* Initialize all platform DMAC's */ int dmac_init(void) { - int i, ret; + int i; + /* no probing before first use */ - for (i = 0; i < ARRAY_SIZE(dma); i++) { - ret = dma_probe(&dma[i]); - if (ret < 0) { + /* TODO: dynamic init based on platform settings */ - /* trace failed DMAC ID */ - trace_error(TRACE_CLASS_DMA, "edi"); - trace_error_value(dma[i].plat_data.id); - return ret; - } - } + /* early lock initialization for ref counting */ + for (i = 0; i < ARRAY_SIZE(dma); i++) + spinlock_init(&dma[i].lock); /* clear the masks for dsp of the dmacs */ io_reg_update_bits(SHIM_BASE + SHIM_IMRD, From 44ea105c06748809cfb11c31d9aefb5475692f28 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 22 Nov 2018 18:22:34 +0800 Subject: [PATCH 2/3] ipc: set timer delay to 0 for ipc_get_page_descriptors Set the timer delay to avoid none init value broke the dma copy. Signed-off-by: Pan Xiuli --- src/ipc/ipc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ipc/ipc.c b/src/ipc/ipc.c index 231172045816..c2cb8e79ca69 100644 --- a/src/ipc/ipc.c +++ b/src/ipc/ipc.c @@ -470,6 +470,7 @@ int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table, config.src_width = sizeof(uint32_t); config.dest_width = sizeof(uint32_t); config.cyclic = 0; + config.timer_delay = 0; dma_sg_init(&config.elem_array); /* set up DMA descriptor */ From a9157a7d924c95f4ef415ccded0b53035447d0dc Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 22 Nov 2018 18:25:25 +0800 Subject: [PATCH 3/3] host: fix wrong usage of dma_channel_get Need not to use stream tag for dw_dma as the comment said Signed-off-by: Pan Xiuli --- src/audio/host.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/audio/host.c b/src/audio/host.c index a5e9a548efd9..97e2512e6a0e 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -514,10 +514,7 @@ static int host_params(struct comp_dev *dev) config->dest_width = comp_sample_bytes(dev); config->cyclic = 0; -#if !defined CONFIG_DMA_GW - host_elements_reset(dev); -#endif - +#if defined CONFIG_DMA_GW dev->params.stream_tag -= 1; /* get DMA channel from DMAC * note: stream_tag is ignored by dw-dma @@ -527,13 +524,22 @@ static int host_params(struct comp_dev *dev) trace_host_error("eDC"); return -ENODEV; } -#if defined CONFIG_DMA_GW err = dma_set_config(hd->dma, hd->chan, &hd->config); if (err < 0) { trace_host_error("eDc"); dma_channel_put(hd->dma, hd->chan); return err; } +#else + host_elements_reset(dev); + /* get DMA channel from DMAC + * note: stream_tag is ignored by dw-dma + */ + hd->chan = dma_channel_get(hd->dma, 0); + if (hd->chan < 0) { + trace_host_error("eDC"); + return -ENODEV; + } #endif /* set up callback */ dma_set_cb(hd->dma, hd->chan, DMA_IRQ_TYPE_LLIST,