DMA Drivers API

group sof_dma_drivers

DMA Drivers API specification.

Defines

DMA_DIR_MEM_TO_MEM

local memory copy

DMA_DIR_HMEM_TO_LMEM

host memory to local mem copy

DMA_DIR_LMEM_TO_HMEM

local mem to host mem copy

DMA_DIR_MEM_TO_DEV

local mem to dev copy

DMA_DIR_DEV_TO_MEM

dev to local mem copy

DMA_DIR_DEV_TO_DEV

dev to dev copy

DMA_CAP_HDA

HDA DMA.

DMA_CAP_GP_LP

GP LP DMA.

DMA_CAP_GP_HP

GP HP DMA.

DMA_CAP_BT

BT DMA.

DMA_CAP_SP

SP DMA.

DMA_CAP_DMIC

ACP DMA DMIC >

DMA_CAP_SP_VIRTUAL

SP VIRTUAL DMA.

DMA_CAP_HS_VIRTUAL

HS VIRTUAL DMA.

DMA_CAP_HS

HS DMA.

DMA_CAP_SW

SW DMA.

DMA_DEV_HOST

connectable to host

DMA_DEV_HDA

connectable to HD/A link

DMA_DEV_SSP

connectable to SSP fifo

DMA_DEV_DMIC

connectable to DMIC fifo

DMA_DEV_SSI

connectable to SSI / SPI fifo

DMA_DEV_ALH

connectable to ALH link

DMA_DEV_SAI

connectable to SAI fifo

DMA_DEV_ESAI

connectable to ESAI fifo

DMA_DEV_BT

connectable to ACP BT I2S

DMA_DEV_SP

connectable to ACP SP I2S

DMA_DEV_AFE_MEMIF

connectable to AFE fifo

DMA_DEV_SP_VIRTUAL

connectable to ACP SP VIRTUAL I2S

DMA_DEV_HS_VIRTUAL

connectable to ACP HS VIRTUAL I2S

DMA_DEV_HS

connectable to ACP HS I2S

DMA_DEV_MICFIL

connectable to MICFIL fifo

DMA_DEV_SW

connectable to ACP SW

DMA_ACCESS_EXCLUSIVE
DMA_ACCESS_SHARED
DMA_COPY_BLOCKING
DMA_COPY_ONE_SHOT
DMA_CHAN_INVALID
DMA_CORE_INVALID
DMA_ATTR_BUFFER_ALIGNMENT
DMA_ATTR_COPY_ALIGNMENT
DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT
DMA_ATTR_BUFFER_PERIOD_COUNT
dma_set_drvdata(dma, data)
dma_get_drvdata(dma)
dma_base(dma)
dma_irq(dma)
dma_irq_name(dma)
dma_chan_size(dma)
dma_chan_base(dma, chan)
dma_chan_get_data(chan)
dma_chan_set_data(chan, data)

Typedefs

typedef int (*dma_process_func)(const struct audio_stream *source, uint32_t ioffset, struct audio_stream *sink, uint32_t ooffset, uint32_t source_samples, uint32_t chmap)

Enums

enum dma_cb_status

Values:

enumerator DMA_CB_STATUS_RELOAD
enumerator DMA_CB_STATUS_END
enum dma_irq_cmd

Values:

enumerator DMA_IRQ_STATUS_GET
enumerator DMA_IRQ_CLEAR
enumerator DMA_IRQ_MASK
enumerator DMA_IRQ_UNMASK

Functions

int dmac_init(struct sof *sof)

API to initialize a platform DMA controllers.

Parameters:

sof[in] Pointer to firmware main context.

struct dma *dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags)

API to request a platform DMAC.

Users can request DMAC based on dev type, copy direction, capabilities and access privilege. For exclusive access, ret DMAC with no channels draining. For shared access, ret DMAC with the least number of channels draining.

void dma_put(struct dma *dma)

API to release a platform DMAC.

Parameters:

dma[in] DMAC to relese.

static inline struct dma_chan_data *dma_channel_get_legacy(struct dma *dma, int req_channel)
static inline void dma_channel_put_legacy(struct dma_chan_data *channel)
static inline int dma_start_legacy(struct dma_chan_data *channel)
static inline int dma_stop_legacy(struct dma_chan_data *channel)
static inline int dma_stop_delayed_legacy(struct dma_chan_data *channel)
static inline int dma_pause_legacy(struct dma_chan_data *channel)
static inline int dma_release_legacy(struct dma_chan_data *channel)
static inline int dma_status_legacy(struct dma_chan_data *channel, struct dma_chan_status *status, uint8_t direction)
static inline int dma_set_config_legacy(struct dma_chan_data *channel, struct dma_sg_config *config)
static inline int dma_probe_legacy(struct dma *dma)
static inline int dma_remove_legacy(struct dma *dma)
static inline int dma_get_data_size_legacy(struct dma_chan_data *channel, uint32_t *avail, uint32_t *free)
static inline int dma_get_attribute_legacy(struct dma *dma, uint32_t type, uint32_t *value)
static inline int dma_interrupt_legacy(struct dma_chan_data *channel, enum dma_irq_cmd cmd)
static inline uint32_t dma_reg_read(struct dma *dma, uint32_t reg)
static inline uint16_t dma_reg_read16(struct dma *dma, uint32_t reg)
static inline void dma_reg_write(struct dma *dma, uint32_t reg, uint32_t value)
static inline void dma_reg_write16(struct dma *dma, uint32_t reg, uint16_t value)
static inline void dma_reg_update_bits(struct dma *dma, uint32_t reg, uint32_t mask, uint32_t value)
static inline uint32_t dma_chan_reg_read(struct dma_chan_data *channel, uint32_t reg)
static inline uint16_t dma_chan_reg_read16(struct dma_chan_data *channel, uint32_t reg)
static inline void dma_chan_reg_write(struct dma_chan_data *channel, uint32_t reg, uint32_t value)
static inline void dma_chan_reg_write16(struct dma_chan_data *channel, uint32_t reg, uint16_t value)
static inline void dma_chan_reg_update_bits(struct dma_chan_data *channel, uint32_t reg, uint32_t mask, uint32_t value)
static inline void dma_chan_reg_update_bits16(struct dma_chan_data *channel, uint32_t reg, uint16_t mask, uint16_t value)
static inline bool dma_is_scheduling_source(struct dma_chan_data *channel)
static inline void dma_sg_init(struct dma_sg_elem_array *ea)
int dma_sg_alloc(struct dma_sg_elem_array *ea, enum mem_zone zone, uint32_t direction, uint32_t buffer_count, uint32_t buffer_bytes, uintptr_t dma_buffer_addr, uintptr_t external_addr)
void dma_sg_free(struct dma_sg_elem_array *ea)
static inline uint32_t dma_sg_get_size(struct dma_sg_elem_array *ea)

Get the total size of SG buffer.

Parameters:

ea – Array of SG elements.

Returns:

Size of the buffer.

int dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink, dma_process_func process, uint32_t source_bytes, uint32_t chmap)
int stream_copy_from_no_consume(struct comp_buffer *source, struct comp_buffer *sink, dma_process_func process, uint32_t source_bytes, uint32_t chmap)
int dma_buffer_copy_to(struct comp_buffer *source, struct comp_buffer *sink, dma_process_func process, uint32_t sink_bytes, uint32_t chmap)
int dma_copy_new(struct dma_copy *dc)
static inline void dma_copy_free(struct dma_copy *dc)
int dma_copy_from_host(struct dma_copy *dc, struct dma_sg_config *host_sg, int32_t host_offset, void *local_ptr, int32_t size)
int dma_copy_from_host_nowait(struct dma_copy *dc, struct dma_sg_config *host_sg, int32_t host_offset, void *local_ptr, int32_t size)
int dma_copy_to_host(struct dma_copy *dc, struct dma_sg_config *host_sg, int32_t host_offset, void *local_ptr, int32_t size)
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)
int dma_copy_set_stream_tag(struct dma_copy *dc, uint32_t stream_tag)
static inline const struct dma_info *dma_info_get(void)
struct dma_sg_elem
#include <dma.h>

Element of SG list (as array item).

Public Members

uint32_t src

source address

uint32_t dest

destination address

uint32_t size

size (in bytes)

struct dma_cb_data
#include <dma.h>

Data used in DMA callbacks.

Public Members

struct dma_chan_data *channel
struct dma_sg_elem elem
enum dma_cb_status status
struct dma_sg_elem_array
#include <dma.h>

SG elem array.

Public Members

uint32_t count

number of elements in elems

struct dma_sg_elem *elems

elements

struct dma_sg_config
#include <dma.h>

Public Members

uint32_t src_width
uint32_t dest_width
uint32_t burst_elems
uint32_t direction
uint32_t src_dev
uint32_t dest_dev
uint32_t cyclic
uint64_t period
struct dma_sg_elem_array elem_array
bool scatter
bool irq_disabled
bool is_scheduling_source
struct dma_chan_status
#include <dma.h>

Public Members

uint32_t state
uint32_t flags
uint32_t w_pos
uint32_t r_pos
uint32_t timestamp
void *ipc_posn_data
struct dma_ops
#include <dma.h>

Public Members

struct dma_chan_data *(*channel_get)(struct dma *dma, unsigned int req_channel)
void (*channel_put)(struct dma_chan_data *channel)
int (*start)(struct dma_chan_data *channel)
int (*stop)(struct dma_chan_data *channel)
int (*stop_delayed)(struct dma_chan_data *channel)
int (*copy)(struct dma_chan_data *channel, int bytes, uint32_t flags)
int (*pause)(struct dma_chan_data *channel)
int (*release)(struct dma_chan_data *channel)
int (*status)(struct dma_chan_data *channel, struct dma_chan_status *status, uint8_t direction)
int (*set_config)(struct dma_chan_data *channel, struct dma_sg_config *config)
int (*probe)(struct dma *dma)
int (*remove)(struct dma *dma)
int (*get_data_size)(struct dma_chan_data *channel, uint32_t *avail, uint32_t *free)
int (*get_attribute)(struct dma *dma, uint32_t type, uint32_t *value)
int (*interrupt)(struct dma_chan_data *channel, enum dma_irq_cmd cmd)
struct dma_plat_data
#include <dma.h>

Public Members

uint32_t id
uint32_t dir
uint32_t caps
uint32_t devs
uint32_t base
uint32_t channels
int irq
const char *irq_name
uint32_t chan_size
const void *drv_plat_data
struct dma
#include <dma.h>

Public Members

struct dma_plat_data plat_data
struct k_spinlock lock

locking mechanism

int sref

simple ref counter, guarded by lock

const struct dma_ops *ops
atomic_t num_channels_busy
struct dma_chan_data *chan
void *priv_data
struct dma_chan_data
#include <dma.h>

Public Members

struct dma *dma
uint32_t status
uint32_t direction
uint32_t desc_count
uint32_t index
uint32_t core
uint64_t period
bool is_scheduling_source
void *dev_data
void *priv_data
struct dma_info
#include <dma.h>

Public Members

struct dma *dma_array
size_t num_dmas
struct dma_copy
#include <dma.h>

Public Members

struct dma_chan_data *chan
struct dma *dmac
group sof_dma_copy_func

This function is in a separate subgroup to solve a name clash with struct dma_copy {}.

Functions

static inline int dma_copy_legacy(struct dma_chan_data *channel, int bytes, uint32_t flags)

This function is listed separately to solve a name clash with the struct dma_copy {} above.