Sound Open Firmware
Loading...
Searching...
No Matches
dai-zephyr.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 * Keyon Jie <yang.jie@linux.intel.com>
7 */
8
15
16#ifndef __SOF_LIB_DAI_ZEPHYR_H__
17#define __SOF_LIB_DAI_ZEPHYR_H__
18
19#include <rtos/bit.h>
20#include <sof/list.h>
21#include <sof/lib/io.h>
22#include <sof/lib/memory.h>
23#include <sof/lib/dma.h>
24#include <sof/list.h>
25#include <rtos/sof.h>
26#include <rtos/spinlock.h>
27#include <sof/trace/trace.h>
28#include <sof/ipc/topology.h>
31#include <sof/audio/component.h>
32#include <ipc/dai.h>
33#include <errno.h>
34#include <stddef.h>
35#include <stdint.h>
36#include <zephyr/device.h>
37#include <zephyr/drivers/dai.h>
38
40
45
47#define DAI_CREAT BIT(0)
48
49struct dai {
50 uint32_t index;
51 uint32_t type;
52 uint32_t dma_caps;
53 uint32_t dma_dev;
54 const struct device *dev;
55 const struct dai_data *dd;
56 struct k_spinlock lock; /* protect properties */
57};
58
60 uint16_t full;
61 struct {
62 uint16_t lchan :4;
63 uint16_t hchan :4;
64 uint16_t stream :6;
65 uint16_t rsvd :1;
66 uint16_t dir :1;
68};
69
72struct dai_group {
76 uint32_t group_id;
77
81 uint32_t num_dais;
82
87
92
97
102};
103
108 uint32_t node_id;
109 uint32_t reg_offset;
110};
111
112typedef int (*channel_copy_func)(const struct audio_stream *src, unsigned int src_channel,
113 struct audio_stream *dst, unsigned int dst_channel,
114 unsigned int frames);
115
119struct dai_data {
120 /* local DMA config */
122 uint32_t stream_id;
124 struct dma_config *z_config;
128 struct dai_ts_cfg ts_config;
129 struct dai *dai;
130 struct sof_dma *dma;
131 struct dai_group *group; /* NULL if no group assigned */
132 int xrun; /* true if we are doing xrun recovery */
133
134 pcm_converter_func process; /* processing function */
135 uint32_t chmap;
136
137 channel_copy_func channel_copy; /* channel copy func used by multi-endpoint
138 * gateway to mux/demux stream from/to multiple
139 * DMA buffers
140 */
141
142 uint32_t period_bytes; /* number of DMA bytes per one period */
144
145 struct ipc_config_dai ipc_config; /* generic common config */
146 void *dai_spec_config; /* dai specific config from the host */
147
148 uint64_t wallclock; /* wall clock at stream start */
149
150 /*
151 * flag indicating two-step stop/pause for DAI comp and DAI DMA.
152 * DAI stop occurs during STREAM_TRIG_STOP IPC and DMA stop during DAI_CONFIG IPC with
153 * the SOF_DAI_CONFIG_FLAGS_HW_FREE flag.
154 * DAI pause occurs during STREAM_TRIG_PAUSE IPC and DMA pause during DAI_CONFIG IPC with
155 * the SOF_DAI_CONFIG_FLAGS_PAUSE flag.
156 */
158
159 /* llp slot info in memory windows */
161 /* fast mode, use one byte memory to save repreated cycles */
163#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
164 bool xrun_notification_sent;
165#endif
166#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
167 /* io performance measurement */
168 struct io_perf_data_item *io_perf_dai_byte_count;
169#endif
170 /* Copier gain params */
171 struct copier_gain_params *gain_data;
172
174};
175
176/* these 3 are here to satisfy clk.c and ssp.h interconnection, will be removed leter */
177static inline void dai_write(struct dai *dai, uint32_t reg, uint32_t value)
178{
179}
180
181static inline uint32_t dai_read(struct dai *dai, uint32_t reg)
182{
183 return 0;
184}
185
186static inline void dai_update_bits(struct dai *dai, uint32_t reg,
187 uint32_t mask, uint32_t value)
188{
189}
190
204struct dai_group *dai_group_get(uint32_t group_id, uint32_t flags);
205
213void dai_group_put(struct dai_group *group);
214
220static inline int dai_init(struct sof *sof)
221{
222 return 0;
223}
224
232struct dai *dai_get(uint32_t type, uint32_t index, uint32_t flags);
233
239void dai_put(struct dai *dai);
240
244int dai_set_config(struct dai *dai, struct ipc_config_dai *config,
245 const void *spec_config, size_t size);
246
250int dai_get_handshake(struct dai *dai, int direction, int stream_id);
251
255int dai_get_fifo_depth(struct dai *dai, int direction);
256
260uint32_t dai_get_init_delay_ms(struct dai *dai);
261
265int dai_get_stream_id(struct dai *dai, int direction);
266
270int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void *config);
271
275void dai_set_link_hda_config(uint16_t *link_config,
276 struct ipc_config_dai *common_config,
277 const void *spec_config);
281void dai_dma_release(struct dai_data *dd, struct comp_dev *dev);
282
286int dai_config(struct dai_data *dd, struct comp_dev *dev,
287 struct ipc_config_dai *common_cfg, const void *spec_cfg);
288
292int dai_assign_group(struct dai_data *dd, struct comp_dev *dev, uint32_t group_id);
293
297int dai_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn);
298
303
308
312__syscall const struct device *dai_get_device(enum sof_ipc_dai_type type, uint32_t index);
313
319const struct device **dai_get_device_list(size_t *count);
321
322#include <zephyr/syscalls/dai-zephyr.h>
323
324#endif /* __SOF_LIB_DAI_ZEPHYR_H__ */
Component API definition.
void dai_group_put(struct dai_group *group)
API to release DAI group.
int dai_get_fifo_depth(struct dai *dai, int direction)
Get Digital Audio interface fifo depth.
uint32_t dai_get_init_delay_ms(struct dai *dai)
Get DAI initial delay in milliseconds.
void dai_release_llp_slot(struct dai_data *dd)
release llp slot
int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void *config)
Configure DMA channel for DAI.
static uint32_t dai_read(struct dai *dai, uint32_t reg)
Definition dai-zephyr.h:181
int dai_config(struct dai_data *dd, struct comp_dev *dev, struct ipc_config_dai *common_cfg, const void *spec_cfg)
Configure DAI physical interface.
__syscall const struct device * dai_get_device(enum sof_ipc_dai_type type, uint32_t index)
Retrieve a pointer to the Zephyr device structure for a DAI of a given type and index.
void dai_put(struct dai *dai)
API to release a platform DAI.
const struct device ** dai_get_device_list(size_t *count)
Retrieve the list of all DAI devices.
int(* channel_copy_func)(const struct audio_stream *src, unsigned int src_channel, struct audio_stream *dst, unsigned int dst_channel, unsigned int frames)
Definition dai-zephyr.h:112
static int dai_init(struct sof *sof)
API to initialize a platform DAI.
Definition dai-zephyr.h:220
void dai_set_link_hda_config(uint16_t *link_config, struct ipc_config_dai *common_config, const void *spec_config)
Configure HD Audio DMA params for DAI.
void dai_dma_position_update(struct dai_data *dd, struct comp_dev *dev)
update dai dma position for host driver.
int dai_assign_group(struct dai_data *dd, struct comp_dev *dev, uint32_t group_id)
Assign DAI to a group for simultaneous triggering.
int dai_get_handshake(struct dai *dai, int direction, int stream_id)
Get Digital Audio interface DMA Handshake.
struct dai * dai_get(uint32_t type, uint32_t index, uint32_t flags)
API to request a platform DAI.
void dai_dma_release(struct dai_data *dd, struct comp_dev *dev)
Reset DAI DMA config.
static void dai_write(struct dai *dai, uint32_t reg, uint32_t value)
Definition dai-zephyr.h:177
static void dai_update_bits(struct dai *dai, uint32_t reg, uint32_t mask, uint32_t value)
Definition dai-zephyr.h:186
struct dai_group * dai_group_get(uint32_t group_id, uint32_t flags)
API to request DAI group.
int dai_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn)
dai position for host driver.
int dai_set_config(struct dai *dai, struct ipc_config_dai *config, const void *spec_config, size_t size)
Digital Audio interface formatting.
int dai_get_stream_id(struct dai *dai, int direction)
Get DAI stream id.
#define list_item(item, type, member)
Definition list.h:80
PCM converter header file.
int(* pcm_converter_func)(const struct cir_buf_source *source, uint32_t src_channels, struct cir_buf_sink *sink, uint32_t sink_channels, size_t source_samples, uint32_t chmap)
PCM conversion function interface for data in circular buffer.
Definition pcm_converter.h:51
IPC DAI definitions.
sof_ipc_dai_type
Types of DAI.
Definition dai.h:82
Audio stream is a circular buffer aware of audio format of the data in the buffer so provides API for...
Definition audio_stream.h:52
Definition buffer.h:130
Audio component base device "class".
Definition component.h:645
DAI runtime data.
Definition dai-zephyr.h:119
struct sof_dma * dma
Definition dai-zephyr.h:130
struct comp_buffer * dma_buffer
Definition dai-zephyr.h:126
struct dai_group * group
Definition dai-zephyr.h:131
struct ipc_config_dai ipc_config
Definition dai-zephyr.h:145
struct mod_alloc_ctx alloc_ctx
Definition dai-zephyr.h:173
bool delayed_dma_stop
Definition dai-zephyr.h:157
int xrun
Definition dai-zephyr.h:132
uint32_t stream_id
Definition dai-zephyr.h:122
struct dai * dai
Definition dai-zephyr.h:129
struct dma_sg_config config
Definition dai-zephyr.h:123
channel_copy_func channel_copy
Definition dai-zephyr.h:137
uint32_t chmap
Definition dai-zephyr.h:135
struct llp_slot_info slot_info
Definition dai-zephyr.h:160
pcm_converter_func process
Definition dai-zephyr.h:134
uint32_t period_bytes
Definition dai-zephyr.h:142
struct dai_ts_cfg ts_config
Definition dai-zephyr.h:128
struct comp_dev * dai_dev
Definition dai-zephyr.h:125
struct copier_gain_params * gain_data
Definition dai-zephyr.h:171
void * dai_spec_config
Definition dai-zephyr.h:146
bool fast_mode
Definition dai-zephyr.h:162
uint64_t total_data_processed
Definition dai-zephyr.h:143
struct comp_buffer * local_buffer
Definition dai-zephyr.h:127
uint64_t wallclock
Definition dai-zephyr.h:148
struct dma_config * z_config
Definition dai-zephyr.h:124
int chan_index
Definition dai-zephyr.h:121
DAI group information.
Definition dai-zephyr.h:72
int trigger_cmd
Trigger command to propagate.
Definition dai-zephyr.h:91
uint32_t trigger_counter
Number of DAIs to receive a trigger before processing begins.
Definition dai-zephyr.h:86
uint32_t num_dais
Number of DAIs in this group.
Definition dai-zephyr.h:81
struct list_item list
Group list.
Definition dai-zephyr.h:101
int trigger_ret
Last trigger error.
Definition dai-zephyr.h:96
uint32_t group_id
Group ID.
Definition dai-zephyr.h:76
Definition dai-zephyr.h:49
uint32_t index
Definition dai-zephyr.h:50
uint32_t dma_caps
Definition dai-zephyr.h:52
const struct dai_data * dd
Definition dai-zephyr.h:55
struct k_spinlock lock
Definition dai-zephyr.h:56
uint32_t dma_dev
Definition dai-zephyr.h:53
const struct device * dev
Definition dai-zephyr.h:54
uint32_t type
Definition dai-zephyr.h:51
Definition dma.h:161
Definition ipc-config.h:65
llp slot info for memory window
Definition dai-zephyr.h:107
uint32_t reg_offset
Definition dai-zephyr.h:109
uint32_t node_id
Definition dai-zephyr.h:108
Definition alloc.h:167
Definition stream.h:134
General firmware context.
Definition sof.h:44
char value[]
Definition tlv.h:2
uint32_t type
Definition tlv.h:0