DAI Drivers API

group sof_dai_drivers

DAI Drivers API specification.



IRQ used for copy() timer.


If the device does not exist it will be created.

dai_cl_err(drv_p, __e, ...)
dai_cl_warn(drv_p, __e, ...)
dai_cl_info(drv_p, __e, ...)
dai_cl_dbg(drv_p, __e, ...)
dai_err(dai_p, __e, ...)
dai_warn(dai_p, __e, ...)
dai_info(dai_p, __e, ...)
dai_dbg(dai_p, __e, ...)
dai_set_drvdata(dai, data)
dai_fifo(dai, direction)


struct dai_group *dai_group_get(uint32_t group_id, uint32_t flags)

API to request DAI group.

Returns a DAI group for the given ID and increments the counter of DAIs in the group.

If a group for the given ID doesn’t exist, it will either return NULL or allocate a new group structure if the CREATE flag is supplied.

  • [in] group_id: Group ID

  • [in] flags: Flags (CREATE)

void dai_group_put(struct dai_group *group)

API to release DAI group.

Decrements the DAI counter inside the group.

  • [in] group: Group

int dai_init(struct sof *sof)

API to initialize a platform DAI.

  • [in] sof: Pointer to firmware main context.

struct dai *dai_get(uint32_t type, uint32_t index, uint32_t flags)

API to request a platform DAI.

  • [in] type: Type of requested DAI.

  • [in] index: Index of requested DAI.

  • [in] flags: Flags (CREATE)

void dai_put(struct dai *dai)

API to release a platform DAI.

  • [in] dai: DAI to relese.

static int dai_set_config(struct dai *dai, struct ipc_config_dai *config, void *spec_config)

Digital Audio interface formatting.

static int dai_trigger(struct dai *dai, int cmd, int direction)

Digital Audio interface trigger.

static int dai_get_hw_params(struct dai *dai, struct sof_ipc_stream_params *params, int dir)

Get Digital Audio interface stream parameters.

static int dai_hw_params(struct dai *dai, struct sof_ipc_stream_params *params)

Configure Digital Audio interface stream parameters.

static int dai_get_handshake(struct dai *dai, int direction, int stream_id)

Get Digital Audio interface DMA Handshake.

static int dai_get_fifo(struct dai *dai, int direction, int stream_id)

Get Digital Audio interface FIFO address.

static int dai_probe(struct dai *dai)

Digital Audio interface Probe.

static int dai_remove(struct dai *dai)

Digital Audio interface Remove.

static uint32_t dai_get_init_delay_ms(struct dai *dai)

Get DAI initial delay in milliseconds.

static int dai_get_info(struct dai *dai, int info)

Get driver specific DAI information.

static void dai_write(struct dai *dai, uint32_t reg, uint32_t value)
static uint32_t dai_read(struct dai *dai, uint32_t reg)
static void dai_update_bits(struct dai *dai, uint32_t reg, uint32_t mask, uint32_t value)
static const struct dai_info *dai_info_get(void)
int dai_config_dma_channel(struct comp_dev *dev, void *config)

Configure DMA channel for DAI.

void dai_dma_release(struct comp_dev *dev)

Reset DAI DMA config.

int dai_config(struct comp_dev *dev, struct ipc_config_dai *common_config, void *spec_config)

Configure DAI physical interface.

int dai_assign_group(struct comp_dev *dev, uint32_t group_id)

Assign DAI to a group for simultaneous triggering.

int dai_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn)

dai position for host driver.

void dai_dma_position_update(struct comp_dev *dev)

update dai dma position for host driver.

struct dai_ops
#include <dai.h>

DAI operations - all optional.

DAI drivers may allocate private data, which can be set with ‘dai_set_drvdata’ and retrieved with ‘dai_get_drvdata’. If a single DAI instance can have multiple DMA links and/or there is some other possibility of the same instance being used in multiple contexts at the same time, the private data should be allocated in the SOF_MEM_ZONE_SHARED.

Public Members

int (*set_config)(struct dai *dai, struct ipc_config_dai *config, void *spec_config)
int (*trigger)(struct dai *dai, int cmd, int direction)
int (*get_hw_params)(struct dai *dai, struct sof_ipc_stream_params *params, int dir)
int (*hw_params)(struct dai *dai, struct sof_ipc_stream_params *params)
int (*get_handshake)(struct dai *dai, int direction, int stream_id)
int (*get_fifo)(struct dai *dai, int direction, int stream_id)
int (*probe)(struct dai *dai)
int (*remove)(struct dai *dai)
uint32_t (*get_init_delay_ms)(struct dai *dai)
struct timestamp_cfg
#include <dai.h>

Public Members

uint32_t walclk_rate
int type
int direction
int index
int dma_id
int dma_chan_index
int dma_chan_count
struct timestamp_data
#include <dai.h>

Public Members

uint64_t walclk
uint64_t sample
uint32_t walclk_rate
struct timestamp_ops
#include <dai.h>

Public Members

int (*ts_config)(struct dai *dai, struct timestamp_cfg *cfg)
int (*ts_start)(struct dai *dai, struct timestamp_cfg *cfg)
int (*ts_stop)(struct dai *dai, struct timestamp_cfg *cfg)
int (*ts_get)(struct dai *dai, struct timestamp_cfg *cfg, struct timestamp_data *tsd)
struct dai_driver
#include <dai.h>

Public Members

uint32_t type

type, one of SOF_DAI_…

const struct sof_uuid_entry *uid
struct tr_ctx *tctx
uint32_t dma_caps
uint32_t dma_dev
struct dai_ops ops
struct timestamp_ops ts_ops
struct dai_slot_map
#include <dai.h>

DAI slot map to audio channel.

Public Members

uint32_t channel

channel ID - CHAN_ID_

uint32_t slot

physical slot index

struct dai_plat_fifo_data
#include <dai.h>

Public Members

uint32_t offset
uint32_t width
uint32_t depth
uint32_t watermark
uint32_t handshake
struct dai_plat_data
#include <dai.h>

DAI platform data.

Public Members

uint32_t base
int irq
const char *irq_name
uint32_t flags
struct dai_plat_fifo_data fifo[2]
struct dai_data
#include <dai.h>

DAI runtime data.

Public Members

struct dma_chan_data *chan
uint32_t stream_id
struct dma_sg_config config
struct comp_buffer *dma_buffer
struct comp_buffer *local_buffer
struct timestamp_cfg ts_config
struct dai *dai
struct dma *dma
struct dai_group *group

NULL if no group assigned.

int xrun
pcm_converter_func process
uint32_t dai_pos_blks
uint64_t start_position
uint32_t period_bytes

number of bytes per one period

uint64_t *dai_pos
struct ipc_config_dai ipc_config
void *dai_spec_config
uint64_t wallclock
bool delayed_dma_stop
struct dai
#include <dai.h>

Public Members

uint32_t index


struct k_spinlock lock

locking mechanism

int sref

simple ref counter, guarded by lock

struct dai_plat_data plat_data
const struct dai_driver *drv
void *priv_data
struct dai_type_info
#include <dai.h>

Array of DAIs grouped by type.

Public Members

uint32_t type


struct dai *dai_array

Array of DAIs.

size_t num_dais

Number of elements in dai_array.

struct dai_group
#include <dai.h>

DAI group information.

Public Members

uint32_t group_id

Group ID.

uint32_t num_dais

Number of DAIs in this group.

uint32_t trigger_counter

Number of DAIs to receive a trigger before processing begins.

int trigger_cmd

Trigger command to propagate.

int trigger_ret

Last trigger error.

struct list_item list

Group list.

struct dai_info
#include <dai.h>

Holds information about array of DAIs grouped by type.

Public Members

const struct dai_type_info *dai_type_array
size_t num_dai_types