-
Notifications
You must be signed in to change notification settings - Fork 349
dai: Add support for Virtual DAI for rapid prototyping and software loopback #10147
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?
dai: Add support for Virtual DAI for rapid prototyping and software loopback #10147
Conversation
|
Can one of the admins verify this patch?
|
86aa27b to
7168fe9
Compare
src/include/ipc/dai.h
Outdated
| SOF_DAI_IMX_MICFIL, /**< i.MX MICFIL */ | ||
| SOF_DAI_AMD_SW_AUDIO /**<Amd SW AUDIO */ | ||
| SOF_DAI_AMD_SW_AUDIO, /**<Amd SW AUDIO */ | ||
| SOF_DAI_VIRTUAL /**< Virtual DAI for testing/debugging*/ |
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.
can we add a comma at the end to prepare for the next addition?
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.
@SurajSonawane2415 please add comma after last member e.g SOF_DAI_VIRTUAL,
src/lib/dai.c
Outdated
| d->dma_caps = SOF_DMA_CAP_HDA; | ||
| break; | ||
| case SOF_DAI_VIRTUAL: | ||
| break; |
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.
already handled by default below
|
|
||
| # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le | ||
| PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, | ||
| 1, 0, 2, s24le, |
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.
why s24le? it should be s32le.
| @@ -0,0 +1,72 @@ | |||
|
|
|||
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.
This topology seems to be quite generic, not specific to 8MP.
@dbaluta maybe you can test this on 8QM or 8QXP so we can be sure it works on other platforms as well.
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.
@SurajSonawane2415 since this is virtual it may be possible to create a ztest for this feature (in another PR), this would mean the feature would be tested by CI. i.e. a small pipeline with virtual loopback as a ztest.
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.
@lgirdwood something like this zephyr/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c but for DAI, right?
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.
Fwiw, this would allow a higher level ztest where we could have a small loopback pipeline and test that we can copy A -> B, this would invoke a lot of pipeline logic/infra and could be easily run in CI. Depends if time permits for development though.
3b19886 to
9a09895
Compare
lgirdwood
left a comment
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.
LGTM
| compatible = "nxp,sof-host-dma"; | ||
| dma-channels = <32>; | ||
| #dma-cells = <0>; | ||
| }; |
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.
@SurajSonawane2415 we should not enable DAI_VIRTUAL and DMA_EMUL by default so please remove them from the config file.
zephyr/lib/dma.c
Outdated
| }, | ||
| .z_dev = DEVICE_DT_GET(DT_NODELABEL(emul_dma)), | ||
| }, | ||
| #else |
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.
Here you should just add #endif.
bc0bb10 to
2db9df2
Compare
|
|
||
| SectionVendorTokens."sof_virtual_tokens" { | ||
| SOF_TKN_DAI_VIRTUAL_MCLK_ID "2102" | ||
| } |
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 think this should be SOF_TKN_DAI_VIRTUAL_MCLK_ID 22000 to allow sufficient space between members.
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.
@SurajSonawane2415 can you add the same token ID to topology 2 tokens too, just to make sure we have alignment.
2db9df2 to
52b5f8c
Compare
|
|
||
| SectionVendorTokens."sof_virtual_tokens" { | ||
| SOF_TKN_DAI_VIRTUAL_MCLK_ID "2102" | ||
| } |
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.
@SurajSonawane2415 can you add the same token ID to topology 2 tokens too, just to make sure we have alignment.
| #if CONFIG_DAI_VIRTUAL | ||
| dir = SOF_DMA_DIR_MEM_TO_MEM; | ||
| #else |
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.
Is there anyway we can do this without the ifdef i.e. we may want to be able to combine virtual and real DAIs, you could add a flag to the dai structure to indicate virtual ?
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>
52b5f8c to
9441b0c
Compare
Add a new topology file for i.MX8 platforms that enables Virtual DAI support, allowing software-based audio pipelines without physical DAI hardware. Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
Add emul_dma configuration to enable Virtual DAI with memory-to-memory DMA for software-based audio pipelines on i.MX8MP. Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
9441b0c to
dace206
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
SOF_DAI_VIRTUALtype and its associated support to enable audio pipelines that do not rely on physical DAI hardware. This is useful in the following scenarios:Virtual DAI Behavior
/dev/null— consumes data from the source and logs or discards it./dev/zero— generates dummy data (currently zero-filled) and passes it to the sink.Key Changes
Testing
Logs:
Related PR & Commits
Zephyr PR: #95233 drivers: dai: Add virtual DAI driver and tests
Includes Virtual DAI driver, DTS binding, Kconfig/CMake updates, and ztest-based API tests.
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.)