drivers: dai: Add virtual DAI driver and tests#95233
drivers: dai: Add virtual DAI driver and tests#95233SurajSonawane2415 wants to merge 2 commits intozephyrproject-rtos:mainfrom
Conversation
|
Hello @SurajSonawane2415, and thank you very much for your first pull request to the Zephyr project! |
9fe555a to
f25130f
Compare
f25130f to
7dfac22
Compare
kv2019i
left a comment
There was a problem hiding this comment.
Thanks @SurajSonawane24 ! Code is looking good. Only some minor notes on documentation, Kconfig defaults and log verbosity. Please see inline.
|
|
||
| config DAI_VIRTUAL | ||
| bool "Virtual DAI driver support for SOF" | ||
| default n |
There was a problem hiding this comment.
"default n" is superfluous -> https://docs.zephyrproject.org/latest/build/kconfig/tips.html#redundant-defaults
There was a problem hiding this comment.
Also no need to mention SOF. While SOF is currently the primary user of DAI interface, DAIs could be used by any app.
| bool "Virtual DAI driver support for SOF" | ||
| default n | ||
| help | ||
| Enable support for a Virtual DAI (Digital Audio Interface) in SOF. |
|
|
||
| static int virtual_dai_probe(const struct device *dev) | ||
| { | ||
| LOG_INF("%s", __func__); |
There was a problem hiding this comment.
I'd reduce the number of these LOG_INF()s in the merged version. I know this virtual DAI is more for R&D use, so logging can be on the more verbose side, but I'd still drop the function entry/exit logs (especially as Zephyr logging can add the function info with a build option, no need to add "func" in driver code.
| description: | | ||
| Zephyr binding for a Virtual DAI (Digital Audio Interface). | ||
| This DAI is not connected to real hardware and is used for software-only | ||
| audio routing or testing within SOF + Zephyr systems. |
There was a problem hiding this comment.
| description: | | |
| Zephyr binding for a Virtual DAI (Digital Audio Interface). | |
| This DAI is not connected to real hardware and is used for software-only | |
| audio routing or testing within SOF + Zephyr systems. | |
| title: Zephyr for a Virtual DAI (Digital Audio Interface) | |
| description: | | |
| This DAI is not connected to real hardware and is used for software-only | |
| audio routing or testing within SOF + Zephyr systems. | |
There was a problem hiding this comment.
Thank you for the suggestions, I’ve made the changes.
| static const struct dai_properties | ||
| *virtual_dai_get_properties(const struct device *dev, enum dai_dir dir, int stream_id) |
There was a problem hiding this comment.
| static const struct dai_properties | |
| *virtual_dai_get_properties(const struct device *dev, enum dai_dir dir, int stream_id) | |
| static const struct dai_properties *virtual_dai_get_properties(const struct device *dev, | |
| enum dai_dir dir, int stream_id) |
or
| static const struct dai_properties | |
| *virtual_dai_get_properties(const struct device *dev, enum dai_dir dir, int stream_id) | |
| static const struct dai_properties* | |
| virtual_dai_get_properties(const struct device *dev, enum dai_dir dir, int stream_id) |
There was a problem hiding this comment.
@rruuaanng I accepted your suggestion, just kept the * with the function name (not the type) to follow kernel coding style.
| static struct virtual_dai_data virtual_dai_data_##inst = { \ | ||
| .cfg.type = DAI_VIRTUAL, \ | ||
| .cfg.dai_index = DT_INST_PROP_OR(inst, dai_index, 0), \ | ||
| }; \ | ||
| \ | ||
| DEVICE_DT_INST_DEFINE(inst, \ | ||
| &virtual_dai_init, NULL, \ | ||
| &virtual_dai_data_##inst, NULL, \ | ||
| POST_KERNEL, CONFIG_DAI_INIT_PRIORITY, \ | ||
| &virtual_dai_api); |
There was a problem hiding this comment.
| static struct virtual_dai_data virtual_dai_data_##inst = { \ | |
| .cfg.type = DAI_VIRTUAL, \ | |
| .cfg.dai_index = DT_INST_PROP_OR(inst, dai_index, 0), \ | |
| }; \ | |
| \ | |
| DEVICE_DT_INST_DEFINE(inst, \ | |
| &virtual_dai_init, NULL, \ | |
| &virtual_dai_data_##inst, NULL, \ | |
| POST_KERNEL, CONFIG_DAI_INIT_PRIORITY, \ | |
| &virtual_dai_api); | |
| static struct virtual_dai_data virtual_dai_data_##inst = { \ | |
| .cfg.type = DAI_VIRTUAL, \ | |
| .cfg.dai_index = DT_INST_PROP_OR(inst, dai_index, 0), \ | |
| }; \ | |
| \ | |
| DEVICE_DT_INST_DEFINE(inst, \ | |
| &virtual_dai_init, NULL, \ | |
| &virtual_dai_data_##inst, NULL, \ | |
| POST_KERNEL, CONFIG_DAI_INIT_PRIORITY, \ | |
| &virtual_dai_api); |
There was a problem hiding this comment.
@rruuaanng Thanks for the suggestion. Can you clarify the reason for these whitespace changes?
7dfac22 to
7f3747d
Compare
@kv2019i Thanks for the detailed review!
|
kv2019i
left a comment
There was a problem hiding this comment.
Thanks, looks good now @SurajSonawane2415 !
LaurentiuM1234
left a comment
There was a problem hiding this comment.
Good start, but IMO this should still be in the draft stage. I would like to see some actual functionality being implemented here. IMO, as things stand now, this PR introduces a DAI driver that doesn't seem to do anything and a test suite that doesn't test anything particularly useful?
| Zephyr binding for a Virtual DAI (Digital Audio Interface). | ||
| This DAI is not connected to real hardware and is used for software-only | ||
| audio routing or testing within SOF + Zephyr systems. | ||
| compatible: "virtual_dai" |
There was a problem hiding this comment.
The format of the compatible string is "vendor,model". Also, should be virtual-dai. My suggestion would be to use zephyr,virtual-dai.
There was a problem hiding this comment.
Thank you I will make the changes.
| status = "disabled"; | ||
| }; | ||
|
|
||
| virtual_dai: virtual_dai { |
There was a problem hiding this comment.
no virtual devices in the mainline DT, please. We can move this to the application DT overlay. See host_dma from https://github.com/thesofproject/sof/blob/main/app/boards/imx8qm_mek_mimx8qm6_adsp.overlay as an example.
There was a problem hiding this comment.
Got it, thanks for pointing this out. I’ve removed it.
I’ll refer to the host_dma example you shared for guidance.
7f3747d to
7cc9c25
Compare
Thanks for the feedback! I’ve marked it as draft. |
Introduce a virtual DAI driver for prototyping, loopback, and testing without requiring physical DAI hardware. This includes: - Initial virtual DAI implementation (logging only) - DTS binding (dai-virtual.yaml) - Kconfig and CMake updates - i.MX8M DTS integration Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
Add a basic ztest-based testsuite for the virtual DAI driver. This includes initial API coverage and simple validation. Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
7cc9c25 to
a6c0c23
Compare
|
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |



This PR is part of the GSoC 2025 Project: Add Virtual DAI Component to SOF and is based on SOF Issue #9349.
We introduce a new
DAI_VIRTUALtype with driver its associated support to enable audio pipelines that do not rely on physical DAI hardware. This is useful in the following scenarios:Key Changes
dai-virtual.yaml).Testing
Logs:
Related Work
SOF PR: #10147 dai: Add support for Virtual DAI for rapid prototyping and software loopback
Adds Virtual DAI support on i.MX8MP with topology and
emul_dmaintegration for software-based audio pipelines.linux-imx PR: #30 ASoC: SOF: Add Virtual DAI support for i.MX8M
Introduces
SOF_DAI_VIRTUALtype and configuration, adds topology tokens, extends IPC3 parsing, and registers a Virtual DAI backend for i.MX8M. Enables prototyping and loopback pipelines without physical DAI hardware.linux-imx nocodec feature commit: Enabled NoCodec support for the i.MX8M platform to allow pipeline testing without real codecs.
Link: nocodec-commit
Future Work
(Current limitation: To get
aplayandarecordworking, I replaced the real DMA withemul_dmafor Virtual DAI. All functions execute, but data is not being copied indma_emul_work_handlerduring playback.)