-
Notifications
You must be signed in to change notification settings - Fork 8.1k
drivers: dai: Add virtual DAI driver and tests #95233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
drivers: dai: Add virtual DAI driver and tests #95233
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SurajSonawane24 ! Code is looking good. Only some minor notes on documentation, Kconfig defaults and log verbosity. Please see inline.
drivers/dai/virtual/Kconfig.virtual
Outdated
|
|
||
| config DAI_VIRTUAL | ||
| bool "Virtual DAI driver support for SOF" | ||
| default n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"default n" is superfluous -> https://docs.zephyrproject.org/latest/build/kconfig/tips.html#redundant-defaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also no need to mention SOF. While SOF is currently the primary user of DAI interface, DAIs could be used by any app.
drivers/dai/virtual/Kconfig.virtual
Outdated
| bool "Virtual DAI driver support for SOF" | ||
| default n | ||
| help | ||
| Enable support for a Virtual DAI (Digital Audio Interface) in SOF. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here.
drivers/dai/virtual/virtual_dai.c
Outdated
|
|
||
| static int virtual_dai_probe(const struct device *dev) | ||
| { | ||
| LOG_INF("%s", __func__); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestions, I’ve made the changes.
drivers/dai/virtual/virtual_dai.c
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rruuaanng Thanks for the suggestion. Can you clarify the reason for these whitespace changes?
7dfac22 to
7f3747d
Compare
@kv2019i Thanks for the detailed review!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good now @SurajSonawane2415 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
dts/bindings/dai/dai-virtual.yaml
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you I will make the changes.
dts/xtensa/nxp/nxp_imx8m.dtsi
Outdated
| status = "disabled"; | ||
| }; | ||
|
|
||
| virtual_dai: virtual_dai { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Add a basic ztest-based testsuite for the virtual DAI driver. This includes initial API coverage and simple validation. Signed-off-by: Suraj Sonawane <[email protected]>
7cc9c25 to
a6c0c23
Compare
|



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.)