From: Liam Girdwood liam.r.girdwood@linux.intel.com
Allow clients to request a particular DMA channel if supported by the DMA driver and it's available. If requested channel is not supported by DMAC then return another channel. If requested channel is not free then we return an error.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/audio/dai.c | 2 +- src/audio/host.c | 2 +- src/drivers/dw-dma.c | 2 +- src/include/reef/dma.h | 6 +++--- src/ipc/dma-copy.c | 4 ++-- src/ipc/intel-ipc.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/audio/dai.c b/src/audio/dai.c index ff2ff93..66edc2b 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -219,7 +219,7 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp) dd->xrun = 0;
/* get DMA channel from DMAC1 */ - dd->chan = dma_channel_get(dd->dma); + dd->chan = dma_channel_get(dd->dma, 0); if (dd->chan < 0){ trace_dai_error("eDc"); goto error; diff --git a/src/audio/host.c b/src/audio/host.c index b3c3c83..0d0a7bb 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -272,7 +272,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp) list_item_prepend(&elem->list, &hd->config.elem_list);
/* get DMA channel from DMAC */ - hd->chan = dma_channel_get(hd->dma); + hd->chan = dma_channel_get(hd->dma, 0); if (hd->chan < 0) { trace_host_error("eDC"); goto error; diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c index 7a1805e..cbfed0e 100644 --- a/src/drivers/dw-dma.c +++ b/src/drivers/dw-dma.c @@ -286,7 +286,7 @@ static inline void dw_update_bits(struct dma *dma, uint32_t reg, uint32_t mask, }
/* allocate next free DMA channel */ -static int dw_dma_channel_get(struct dma *dma) +static int dw_dma_channel_get(struct dma *dma, int req_chan) { struct dma_pdata *p = dma_get_drvdata(dma); uint32_t flags; diff --git a/src/include/reef/dma.h b/src/include/reef/dma.h index 13af20c..aab9217 100644 --- a/src/include/reef/dma.h +++ b/src/include/reef/dma.h @@ -89,7 +89,7 @@ struct dma_chan_status { /* DMA operations */ struct dma_ops {
- int (*channel_get)(struct dma *dma); + int (*channel_get)(struct dma *dma, int req_channel); void (*channel_put)(struct dma *dma, int channel);
int (*start)(struct dma *dma, int channel); @@ -163,9 +163,9 @@ struct dma *dma_get(int dmac_id); * 6) dma_channel_put() */
-static inline int dma_channel_get(struct dma *dma) +static inline int dma_channel_get(struct dma *dma, int req_channel) { - return dma->ops->channel_get(dma); + return dma->ops->channel_get(dma, req_channel); }
static inline void dma_channel_put(struct dma *dma, int channel) diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c index 57d3e3d..06f05d5 100644 --- a/src/ipc/dma-copy.c +++ b/src/ipc/dma-copy.c @@ -359,8 +359,8 @@ int dma_copy_new(struct dma_copy *dc, int dmac) return -ENODEV; }
- /* get DMA channel from DMAC0 */ - dc->chan = dma_channel_get(dc->dmac); + /* get DMA channel from DMAC0 */ + dc->chan = dma_channel_get(dc->dmac, 0); if (dc->chan < 0) { trace_dma_error("ec1"); return dc->chan; diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index 54a0812..fac3371 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -104,7 +104,7 @@ static int get_page_descriptors(struct intel_ipc_data *iipc, int ret = 0;
/* get DMA channel from DMAC0 */ - chan = dma_channel_get(iipc->dmac0); + chan = dma_channel_get(iipc->dmac0, 0); if (chan < 0) { trace_ipc_error("ePC"); return chan;