Skip to content
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

Audio: Start add simulated DAI and host component #8830

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

singalsu
Copy link
Collaborator

@singalsu singalsu commented Feb 2, 2024

No description provided.

}

DECLARE_MODULE(sys_comp_host_init);
SOF_MODULE_INIT(host, sys_comp_host_init);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and the dai version look like a lot of copy-paste, is this what we want to do? The code of the original source file will evolve over time so it's a maintenance nightmare to keep two separate files aligned by parts and different when they need to be different.

Code management/maintainability is hard.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, question. This way I would remove the disabled code parts. Though I didn't yet start to work with host so it's now just a duplicated. Other way would be adding abstraction to zephyr DAI and host and use stub functions for DMA and HW related for the simulated version.

@singalsu
Copy link
Collaborator Author

singalsu commented Feb 5, 2024

The just updated version adds a triangle wave generator to DAI capture and and glitch detector to DAI playback.

src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
@singalsu singalsu changed the title [TEST][Do not review] Audio: Start add simulated DAI and host component [TEST] Audio: Start add simulated DAI and host component Feb 6, 2024
@singalsu
Copy link
Collaborator Author

singalsu commented Feb 6, 2024

This version adds to host triangle wave generate to playback and to capture detecting of glitches. Both triangle generators in DAI and host have now an option to force making glitch every 5s for sanity check to make sure glitches are detected.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @singalsu - how would we use to fake the DAI today ? I assume we locally apply and enable in the Kconfig. Do we need any other Kconfig or usgae instructions.
@lyakh @serhiy-katsyuba-intel @abonislawski @kv2019i @ujfalusi fyi - this will enable some testing without any DAI IP (DAI and DMA) programming i.e. we should be able to see if this can change repro rates.

src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
src/audio/simulated-dai-zephyr.c Outdated Show resolved Hide resolved
app/boards/intel_adsp_cavs25.conf Outdated Show resolved Hide resolved
src/audio/Kconfig Outdated Show resolved Hide resolved
These replace the real dai-zephyr.c and host-zephyr.c if
enabled in Kconfig. Simulation versions are copies of the
originals without changes.

The simulation versions are enabled by setting
CONFIG_ZEPHYR_SIMULATED_HOST_DRIVER=y
CONFIG_ZEPHYR_SIMULATED_DAI_DRIVER=y

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu singalsu changed the title [TEST] Audio: Start add simulated DAI and host component Audio: Start add simulated DAI and host component Feb 8, 2024
@dbaluta
Copy link
Collaborator

dbaluta commented Feb 8, 2024

@singalsu AFAIK the simulated Host will self-generate the data right? Can we call it "Virtual"?

@lgirdwood @singalsu we are trying to decouple SOF firmware from Linux kernel to have it run on MCUs so this could be a good start for us.

@singalsu
Copy link
Collaborator Author

singalsu commented Feb 8, 2024

@singalsu AFAIK the simulated Host will self-generate the data right? Can we call it "Virtual"?

Virtual could be better., I'm not good in naming things. It's still a functional host with data flow to/from user but the playback data is replaced. The next step would be to remove the host DMA traffic, but I have no idea if such is possible without changes to kernel and other SOF framework. The DAI part is now decoupled from HW, so it is "virtual".

With this change the DAI just consumes all playback samples
and produces triangle wave capture samples.

In the playback direction the consumed samples are checked for
glitches base on assumed triangle wave. There is also count of
leading zero PCM samples per channel. It can be used to estimate
latency in the playback path.

Signed-off-by: Seppo Ingalsuo <[email protected]>
The playback stream is replaced with a triangle wave. The
capture stream is passed but checked for glitches.

In capture direction the number of leading zeros for every
channel is checked and reported in trace. It can be used to
estimate latency in the capture path.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu
Copy link
Collaborator Author

Update - removed device driver probe from dai_get().


config ZEPHYR_SIMULATED_DAI_DRIVER
bool "Simulate DAI component"
default n
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we get the CI to test these?..

if ((i & 1) == 0)
tg->pcm_increment[i] = 1;
else
tg->pcm_increment[i] = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional, matter of taste:
tg->pcm_increment[i] = 1 - 2 * (i & 1);


static void dai_glitch_core(struct comp_dev *dev,
struct dai_glitch_detect_state *gd,
int *c,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call it channel for more clarity

@@ -228,7 +513,7 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
pcm_converter_func *converter)
{
enum dma_cb_status dma_status = DMA_CB_STATUS_RELOAD;
int ret;
int ret = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unneeded


for (i = 0; i < channels; i++)
if (gd->no_signal[i])
no_signal_yet = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add a break here

if (gd->no_signal[i])
no_signal_yet = true;

if (!no_signal_yet && !gd->zeros_count_reported) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? !no_signal_yet seems to suggest, that signal is present?

@lyakh
Copy link
Collaborator

lyakh commented Feb 15, 2024

most comments apply to both host and DAI

@ranj063
Copy link
Collaborator

ranj063 commented Feb 20, 2024

@singalsu what topology would you use to test these? Also, how do you start a simulated host playback or capture? Would you still need a PCM in the topology? Ideally, we also want hostless capabaility right?

@lgirdwood
Copy link
Member

@singalsu AFAIK the simulated Host will self-generate the data right? Can we call it "Virtual"?

@lgirdwood @singalsu we are trying to decouple SOF firmware from Linux kernel to have it run on MCUs so this could be a good start for us.

This is not intended for MCU, but you could modify for MCUs as needed - intention here was to help test code flows without invoking any IP programming. i.e. pipelines could be created and run without programming IPs (and do memory to memory copies).

@lgirdwood
Copy link
Member

@singalsu what topology would you use to test these? Also, how do you start a simulated host playback or capture? Would you still need a PCM in the topology? Ideally, we also want hostless capabaility right?

Re hostless - yes, that would be a followup. i.e. it would use locally generated test data instead of copying from host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants