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_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_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 void (*dma_process_func)(const struct audio_stream *source, uint32_t ioffset, struct audio_stream *sink, uint32_t ooffset, uint32_t frames)
typedef void (*dma_process)(const struct audio_stream *, struct audio_stream *, uint32_t)

Enums

enum dma_cb_status

Values:

DMA_CB_STATUS_RELOAD = 0
DMA_CB_STATUS_END
enum dma_irq_cmd

Values:

DMA_IRQ_STATUS_GET = 0
DMA_IRQ_CLEAR
DMA_IRQ_MASK
DMA_IRQ_UNMASK

Functions

int dmac_init(struct sof *sof)

API to initialize a platform DMA controllers.

Parameters
  • [in] sof: 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
  • [in] dma: DMAC to relese.

static struct dma_chan_data *dma_channel_get(struct dma *dma, int req_channel)
static void dma_channel_put(struct dma_chan_data *channel)
static int dma_start(struct dma_chan_data *channel)
static int dma_stop(struct dma_chan_data *channel)
static int dma_pause(struct dma_chan_data *channel)
static int dma_release(struct dma_chan_data *channel)
static int dma_status(struct dma_chan_data *channel, struct dma_chan_status *status, uint8_t direction)
static int dma_set_config(struct dma_chan_data *channel, struct dma_sg_config *config)
static int dma_pm_context_restore(struct dma *dma)
static int dma_pm_context_store(struct dma *dma)
static int dma_probe(struct dma *dma)
static int dma_remove(struct dma *dma)
static int dma_get_data_size(struct dma_chan_data *channel, uint32_t *avail, uint32_t *free)
static int dma_get_attribute(struct dma *dma, uint32_t type, uint32_t *value)
static int dma_interrupt(struct dma_chan_data *channel, enum dma_irq_cmd cmd)
static uint32_t dma_reg_read(struct dma *dma, uint32_t reg)
static uint16_t dma_reg_read16(struct dma *dma, uint32_t reg)
static void dma_reg_write(struct dma *dma, uint32_t reg, uint32_t value)
static void dma_reg_write16(struct dma *dma, uint32_t reg, uint16_t value)
static void dma_reg_update_bits(struct dma *dma, uint32_t reg, uint32_t mask, uint32_t value)
static uint32_t dma_chan_reg_read(struct dma_chan_data *channel, uint32_t reg)
static uint16_t dma_chan_reg_read16(struct dma_chan_data *channel, uint32_t reg)
static void dma_chan_reg_write(struct dma_chan_data *channel, uint32_t reg, uint32_t value)
static void dma_chan_reg_write16(struct dma_chan_data *channel, uint32_t reg, uint16_t value)
static void dma_chan_reg_update_bits(struct dma_chan_data *channel, uint32_t reg, uint32_t mask, uint32_t value)
static void dma_chan_reg_update_bits16(struct dma_chan_data *channel, uint32_t reg, uint16_t mask, uint16_t value)
static bool dma_is_scheduling_source(struct dma_chan_data *channel)
static 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 uint32_t dma_sg_get_size(struct dma_sg_elem_array *ea)

Get the total size of SG buffer.

Return

Size of the buffer.

Parameters
  • ea: Array of SG elements.

void dma_buffer_copy_from(struct comp_buffer *source, uint32_t source_bytes, struct comp_buffer *sink, uint32_t sink_bytes, dma_process_func process, uint32_t samples)
void dma_buffer_copy_to(struct comp_buffer *source, uint32_t source_bytes, struct comp_buffer *sink, uint32_t sink_bytes, dma_process_func process, uint32_t samples)
int dma_copy_new(struct dma_copy *dc)
static 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_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 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
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
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 (*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 (*pm_context_restore)(struct dma *dma)
int (*pm_context_store)(struct dma *dma)
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
spinlock_t 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 *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 int dma_copy(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.