Skip to content

Commit d6b9902

Browse files
authored
Merge pull request #51 from mmaka1/dma-caps
dma: separated dma queries for host connections and hda/gp caps
2 parents 7fafadd + 85e6161 commit d6b9902

14 files changed

Lines changed: 90 additions & 49 deletions

File tree

src/audio/dai.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
197197
}
198198

199199
/* request GP LP DMA with shared access privilege */
200+
/* TODO: hda: retrieve req'ed caps from the dai,
201+
* dmas are not cross-compatible.
202+
*/
200203
dir = DMA_DIR_MEM_TO_DEV | DMA_DIR_DEV_TO_MEM;
201204
caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP;
202205
dma_dev = DMA_DEV_SSP | DMA_DEV_DMIC;

src/audio/host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
513513
dir = DMA_DIR_LMEM_TO_HMEM;
514514

515515
caps = 0;
516-
dma_dev = DMA_DEV_HDA;
516+
dma_dev = DMA_DEV_HOST;
517517
hd->dma = dma_get(dir, caps, dma_dev, DMA_ACCESS_SHARED);
518518
if (hd->dma == NULL) {
519519
trace_host_error("eDM");

src/include/sof/bit.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
29+
*/
30+
31+
#ifndef __INCLUDE_BIT__
32+
#define __INCLUDE_BIT__
33+
34+
#define BIT(b) (1 << (b))
35+
#define MASK(b_hi, b_lo) ((1 << ((b_hi) - (b_lo) + 1)) - 1)
36+
#define SET_BIT(b, x) (((x) & 1) << (b))
37+
#define SET_BITS(b_hi, b_lo, x) \
38+
(((x) & ((1 << ((b_hi) - (b_lo) + 1)) - 1)) << (b_lo))
39+
40+
#endif

src/include/sof/dma.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <sof/lock.h>
4545
#include <sof/sof.h>
4646
#include <sof/wait.h>
47+
#include <sof/bit.h>
4748
#include <arch/atomic.h>
4849

4950
/** \addtogroup sof_dma_drivers DMA Drivers
@@ -52,29 +53,32 @@
5253
*/
5354

5455
/* DMA direction bitmasks used to define DMA copy direction */
55-
#define DMA_DIR_MEM_TO_MEM (1 << 0) /* local memory copy */
56-
#define DMA_DIR_HMEM_TO_LMEM (1 << 1) /* host memory to local mem copy */
57-
#define DMA_DIR_LMEM_TO_HMEM (1 << 2) /* local mem to host mem copy */
58-
#define DMA_DIR_MEM_TO_DEV (1 << 3) /* local mem to dev copy */
59-
#define DMA_DIR_DEV_TO_MEM (1 << 4) /* dev to local mem copy */
60-
#define DMA_DIR_DEV_TO_DEV (1 << 5) /* dev to dev copy */
56+
#define DMA_DIR_MEM_TO_MEM BIT(0) /**< local memory copy */
57+
#define DMA_DIR_HMEM_TO_LMEM BIT(1) /**< host memory to local mem copy */
58+
#define DMA_DIR_LMEM_TO_HMEM BIT(2) /**< local mem to host mem copy */
59+
#define DMA_DIR_MEM_TO_DEV BIT(3) /**< local mem to dev copy */
60+
#define DMA_DIR_DEV_TO_MEM BIT(4) /**< dev to local mem copy */
61+
#define DMA_DIR_DEV_TO_DEV BIT(5) /**< dev to dev copy */
6162

6263
/* DMA capabilities bitmasks used to define the type of DMA */
63-
#define DMA_CAP_GP_LP (1 << 0)
64-
#define DMA_CAP_GP_HP (1 << 1)
64+
#define DMA_CAP_HDA BIT(0) /**< HDA DMA */
65+
#define DMA_CAP_GP_LP BIT(1) /**< GP LP DMA */
66+
#define DMA_CAP_GP_HP BIT(2) /**< GP HP DMA */
6567

6668
/* DMA dev type bitmasks used to define the type of DMA */
67-
#define DMA_DEV_HDA (1 << 0)
68-
#define DMA_DEV_SSP (1 << 1)
69-
#define DMA_DEV_DMIC (1 << 2)
69+
70+
#define DMA_DEV_HOST BIT(0) /**< connectable to host */
71+
#define DMA_DEV_HDA BIT(1) /**< connectable to HD/A link */
72+
#define DMA_DEV_SSP BIT(2) /**< connectable to SSP fifo */
73+
#define DMA_DEV_DMIC BIT(3) /**< connectable to DMIC fifo */
7074

7175
/* DMA access privilege flag */
7276
#define DMA_ACCESS_EXCLUSIVE 1
7377
#define DMA_ACCESS_SHARED 0
7478

7579
/* DMA IRQ types */
76-
#define DMA_IRQ_TYPE_BLOCK (1 << 0)
77-
#define DMA_IRQ_TYPE_LLIST (1 << 1)
80+
#define DMA_IRQ_TYPE_BLOCK BIT(0)
81+
#define DMA_IRQ_TYPE_LLIST BIT(1)
7882

7983

8084
/* We will use this macro in cb handler to inform dma that

src/include/sof/io.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@
3232
#define __INCLUDE_IO__
3333

3434
#include <stdint.h>
35-
36-
/* Macros for register bits access */
37-
#define BIT(b) (1 << (b))
38-
#define MASK(b_hi, b_lo) ((1 << ((b_hi) - (b_lo) + 1)) - 1)
39-
#define SET_BIT(b, x) (((x) & 1) << (b))
40-
#define SET_BITS(b_hi, b_lo, x) \
41-
(((x) & ((1 << ((b_hi) - (b_lo) + 1)) - 1)) << (b_lo))
35+
#include <sof/bit.h>
4236

4337
static inline uint32_t io_reg_read(uint32_t reg)
4438
{

src/ipc/apl-ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ int platform_ipc_init(struct ipc *ipc)
199199
if (iipc->page_table)
200200
bzero(iipc->page_table, HOST_PAGE_SIZE);
201201

202-
/* request GP DMA with shared access privilege */
202+
/* request HDA DMA with shared access privilege */
203203
caps = 0;
204204
dir = DMA_DIR_HMEM_TO_LMEM;
205-
dev = DMA_DEV_HDA;
205+
dev = DMA_DEV_HOST;
206206
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);
207207

208208
/* PM */

src/ipc/byt-ipc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ int platform_ipc_init(struct ipc *ipc)
228228
/* request HDA DMA with shared access privilege */
229229
caps = 0;
230230
dir = DMA_DIR_HMEM_TO_LMEM;
231-
dev = DMA_DEV_HDA;
231+
dev = DMA_DEV_HOST;
232232
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);
233233

234234
/* PM */

src/ipc/cnl-ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ int platform_ipc_init(struct ipc *ipc)
199199
if (iipc->page_table)
200200
bzero(iipc->page_table, HOST_PAGE_SIZE);
201201

202-
/* request GP DMA with shared access privilege */
202+
/* request HDA DMA with shared access privilege */
203203
caps = 0;
204204
dir = DMA_DIR_HMEM_TO_LMEM;
205-
dev = DMA_DEV_HDA;
205+
dev = DMA_DEV_HOST;
206206
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);
207207

208208
/* PM */

src/ipc/dma-copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ int dma_copy_new(struct dma_copy *dc)
379379

380380
/* request HDA DMA in the dir LMEM->HMEM with shared access */
381381
dir = DMA_DIR_LMEM_TO_HMEM;
382-
dev = DMA_DEV_HDA;
382+
dev = DMA_DEV_HOST;
383383
cap = 0;
384384
dc->dmac = dma_get(dir, cap, dev, DMA_ACCESS_SHARED);
385385
if (dc->dmac == NULL) {

src/ipc/hsw-ipc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ int platform_ipc_init(struct ipc *ipc)
224224
/* request GP DMA with shared access privilege */
225225
caps = 0;
226226
dir = DMA_DIR_HMEM_TO_LMEM;
227-
dev = DMA_DEV_HDA;
227+
dev = DMA_DEV_HOST;
228228
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);
229229

230230
/* PM */

0 commit comments

Comments
 (0)