Skip to content

Commit db5a24b

Browse files
dai: Add support for Virtual DAI on i.MX8MP
Introduce a new DAI type, SOF_DAI_VIRTUAL, to enable rapid prototyping, software loopback, and testing without requiring physical DAI hardware. Define the IPC config structure for the virtual DAI and update the Zephyr DAI mapping logic to recognize and configure this backend. Enable virtual DAI for i.MX8MP to support software-based audio pipelines. Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
1 parent fa841ef commit db5a24b

5 files changed

Lines changed: 41 additions & 1 deletion

File tree

app/boards/imx8mp_evk_mimx8ml8_adsp.overlay

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@
2727
&micfil {
2828
status = "okay";
2929
};
30+
31+
&virtual_dai14 {
32+
status = "okay";
33+
};

src/audio/dai-zephyr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ __cold int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
194194
cfg.type = DAI_IMX_MICFIL;
195195
cfg_params = &sof_cfg->micfil;
196196
break;
197+
case SOF_DAI_VIRTUAL:
198+
cfg.type = DAI_VIRTUAL;
199+
cfg_params = &sof_cfg->virtual_dai;
200+
break;
197201
default:
198202
return -EINVAL;
199203
}

src/include/ipc/dai.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,31 @@ enum sof_ipc_dai_type {
9494
SOF_DAI_AMD_SP_VIRTUAL, /**<Amd SP VIRTUAL */
9595
SOF_DAI_AMD_HS_VIRTUAL, /**<Amd HS VIRTUAL */
9696
SOF_DAI_IMX_MICFIL, /**< i.MX MICFIL */
97-
SOF_DAI_AMD_SW_AUDIO /**<Amd SW AUDIO */
97+
SOF_DAI_AMD_SW_AUDIO, /**<Amd SW AUDIO */
98+
SOF_DAI_VIRTUAL, /**< Virtual DAI for testing/debugging*/
9899
};
99100

101+
/* Virtual DAI Configuration Request - SOF_IPC_DAI_VIRTUAL_CONFIG */
102+
struct sof_ipc_dai_virtual_params {
103+
uint32_t reserved0;
104+
105+
/* MCLK */
106+
uint16_t reserved1;
107+
uint16_t mclk_id;
108+
uint32_t mclk_direction;
109+
110+
uint32_t mclk_rate; /* MCLK frequency in Hz */
111+
uint32_t fsync_rate;
112+
uint32_t bclk_rate;
113+
114+
/* TDM */
115+
uint32_t tdm_slots;
116+
uint32_t rx_slots;
117+
uint32_t tx_slots;
118+
uint16_t tdm_slot_width;
119+
uint16_t reserved2; /* alignment */
120+
} __attribute__((packed, aligned(4)));
121+
100122
/* general purpose DAI configuration */
101123
struct sof_ipc_dai_config {
102124
struct sof_ipc_cmd_hdr hdr;
@@ -126,6 +148,7 @@ struct sof_ipc_dai_config {
126148
struct sof_ipc_dai_afe_params afe;
127149
struct sof_ipc_dai_micfil_params micfil;
128150
struct sof_ipc_dai_acp_sdw_params acpsdw;
151+
struct sof_ipc_dai_virtual_params virtual_dai;
129152
};
130153
} __attribute__((packed, aligned(4)));
131154

src/ipc/ipc3/dai.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void
6363
case SOF_DAI_IMX_ESAI:
6464
handshake = dai_get_handshake(dd->dai, dai->direction,
6565
dd->stream_id);
66+
case SOF_DAI_VIRTUAL:
67+
handshake = dai_get_handshake(dd->dai, dai->direction,
68+
dd->stream_id);
6669
/* TODO: remove this when transition to native drivers is complete on all NXP platforms */
6770
#ifndef CONFIG_ZEPHYR_NATIVE_DRIVERS
6871
channel = EDMA_HS_GET_CHAN(handshake);
@@ -171,6 +174,7 @@ int ipc_dai_data_config(struct dai_data *dd, struct comp_dev *dev)
171174
case SOF_DAI_IMX_MICFIL:
172175
case SOF_DAI_IMX_SAI:
173176
case SOF_DAI_IMX_ESAI:
177+
case SOF_DAI_VIRTUAL:
174178
dd->config.burst_elems = dai_get_fifo_depth(dd->dai, dai->direction);
175179
break;
176180
case SOF_DAI_AMD_BT:

src/lib/dai.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ const struct device *zephyr_dev[] = {
185185
#if CONFIG_DAI_NXP_MICFIL
186186
DT_FOREACH_STATUS_OKAY(nxp_dai_micfil, GET_DEVICE_LIST)
187187
#endif
188+
#if CONFIG_DAI_VIRTUAL
189+
DT_FOREACH_STATUS_OKAY(virtual_dai, GET_DEVICE_LIST)
190+
#endif
188191
};
189192

190193
/* convert sof_ipc_dai_type to Zephyr dai_type */
@@ -218,6 +221,8 @@ static int sof_dai_type_to_zephyr(uint32_t type)
218221
case SOF_DAI_AMD_HS_VIRTUAL:
219222
case SOF_DAI_AMD_SW_AUDIO:
220223
return -ENOTSUP;
224+
case SOF_DAI_VIRTUAL:
225+
return DAI_VIRTUAL;
221226
default:
222227
return -EINVAL;
223228
}

0 commit comments

Comments
 (0)