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

[FEATURE] Include SRC tests to nocodec topology tests #1035

Open
singalsu opened this issue May 9, 2023 · 12 comments
Open

[FEATURE] Include SRC tests to nocodec topology tests #1035

singalsu opened this issue May 9, 2023 · 12 comments
Assignees
Labels
P2 Critical bugs or normal features type:test coverage gap This requires a new test case, not just fixing one

Comments

@singalsu
Copy link
Contributor

singalsu commented May 9, 2023

Is your feature request related to a problem? Please describe.
We don't have tests for SRC component. Without tests it breaks.

Describe the solution you'd like
Run twice with nocodec topologies in PR tests playback and capture to hw:0,2 with SSP2 loopback

  1. 48 kHz playback and 48 kHz capture to test current functionality
  2. 44.1 kHz playback and 96 kHz capture to test functionality with both playback and capture SRC active. In this case DAI operates with 48 kHz, playback SRC converts 44.1 to 48 and capture SRC converts 48 to 96.

Describe alternatives you've considered
N/A

Additional context
To get SRC to work currently need patches

@singalsu singalsu added the P1 Blocker bugs or important features label May 9, 2023
@singalsu
Copy link
Contributor Author

singalsu commented May 9, 2023

The 997 Hz alsabat test will be fine. If SRC breaks the result is very corrupted sine wave or different playback or capture time vs. desired and alsabat will notice the frequency shift and fail it.

@singalsu singalsu changed the title [FEATURE] Include SRC tests nocodec topology [FEATURE] Include SRC tests to nocodec topology tests May 9, 2023
@fredoh9
Copy link
Collaborator

fredoh9 commented May 9, 2023

If no one volunteers, I will assign it to me later this week.

  1. run current alsabat loopback test with 997Hz on SSP2
  2. run alsabat test with 997Hz on SSP2, playback SRC 44.1KHz to 48KHz, capture SRC 48KHz to 96Khz

I need a way to set SRC parameters. Will check with @singalsu . Need to implement that SOF CI friendly

@ranj063
Copy link
Contributor

ranj063 commented May 9, 2023

@fredoh9 just to be clear we only want 3 frequencies 44.1, 48 and 96K nothing in between

@singalsu
Copy link
Contributor Author

It seems alsabat takes similar -r argument as aplay and arecord, so adding other rate sine generation and sine wave analysis should be straightforward. Thanks Fred for volunteering!

@fredoh9
Copy link
Collaborator

fredoh9 commented May 10, 2023

Looks not trivial to me. hehe.

I know alsabat support -r parameter for targer frequency, we are already using it.
One piece missing is that need to generate sine wave with 44.1Khz where as target frequency is 48Khz. Found sine wave function, but it is not configurable, it is set by target frequency. This may require alsabat in alsa-utils repo.

int generate_sine_wave(struct bat *bat, int frames, void *buf)
{
...
	sin_generator_init(&sg[c], 1.0, bat->target_freq[c], bat->rate);
'''

@fredoh9
Copy link
Collaborator

fredoh9 commented May 10, 2023

Let me take back, still need to generate sine wave with 48Khz.
Missing a piece is set SRC input sampling rate of 44.1Khz and output sampling rate of 48Khz.

I think easy work around, I generated 997Hz sine wave with 44.1Khz sampling rate and save to a file. I can play the file with alsabat with target frequency 48Khz. Let me try that.

@fredoh9 fredoh9 self-assigned this May 10, 2023
@plbossart
Copy link
Member

plbossart commented May 11, 2023

@fredoh9 just to be clear we only want 3 frequencies 44.1, 48 and 96K nothing in between

why?

It's very useful to test 8/16 kHz as well. 192 as well.

I would suggest

8,16, 44.1, 96, 192 <-> 48kHz

@ranj063
Copy link
Contributor

ranj063 commented May 11, 2023

@fredoh9 just to be clear we only want 3 frequencies 44.1, 48 and 96K nothing in between

why?

It's very useful to test 8/16 kHz as well. 192 as well.

I would suggest

8,16, 44.1, 96, 192 <-> 48kHz

@plbossart this is for the PR device tests for sanity check. But for the daily test I agree we do want to add of those.

@fredoh9
Copy link
Collaborator

fredoh9 commented May 17, 2023

@singalsu
I have some errors on SSP2 capture for 8Khz, 96Khz. However 16Khz, 32Khz 44.1Khz,48Khz are working fine. 192Khz had same error with 96Khz.

$ arecord -Dhw:0,2 -c 2 -r 96000 -f S32_LE -vv /dev/null
...
arecord: pcm_read:2221: read error: Invalid argument

dmesg

[  490.400306] snd_sof:sof_ipc4_log_header: sof-audio-pci-intel-tgl 0000:00:1f.3: ipc tx reply: 0x33000007|0x1: GLB_SET_PIPELINE_STATE
[  490.400310] sof-audio-pci-intel-tgl 0000:00:1f.3: FW reported error: 7 - Unsupported operation requested
[  490.400373] sof-audio-pci-intel-tgl 0000:00:1f.3: ipc error for msg 0x13000004|0x1
[  490.400383] sof-audio-pci-intel-tgl 0000:00:1f.3: failed to set final state 4 for all pipelines
[  490.400389] sof-audio-pci-intel-tgl 0000:00:1f.3: ASoC: error at soc_component_trigger on 0000:00:1f.3: -22
[  490.400396]  Port2: ASoC: trigger FE cmd: 1 failed: -22
[  490.400404] snd_sof:sof_pcm_trigger: sof-audio-pci-intel-tgl 0000:00:1f.3: pcm: trigger stream 2 dir 1 cmd 0
[  490.400407] snd_sof:sof_ipc4_trigger_pipelines: sof-audio-pci-intel-tgl 0000:00:1f.3: trigger cmd: 0 state: 3

mtrace

[    0.134278] <inf> src: comp:1 0x80000 src_prepare()
[    0.134285] <inf> src: comp:1 0x80000 src_params()
[    0.134296] <inf> src: comp:1 0x80000 src_params(), source_rate = 48000, sink_rate = 96000
[    0.134320] <err> src: comp:1 0x80000 src_buffer_lengths(): rates not supported, fs_in: 48000, fs_out: 96000
[    0.134328] <err> src: comp:1 0x80000 src_params(): src_buffer_lengths() failed
[    0.134340] <err> module_adapter: comp:1 0x80000 module_prepare() error -22: module specific prepare failed, comp_id 524288
[    0.134350] <err> module_adapter: comp:1 0x80000 module_adapter_prepare() error ffffffea: module prepare failed
[    0.134358] <err> pipe: pipe:1 0x0 pipeline_prepare(): ret = -22, dev->comp.id = 262145
[    0.134366] <err> ipc: ipc: pipe 1 comp 0 prepare failed -22
[    0.134420] <inf> component: comp:1 0x80000 comp_set_state(), state already set to 1
[    0.134428] <err> ipc: failed to process msg 19 status 7
[    0.134436] <err> ipc: ipc4: FW_GEN_MSG failed with err 7
[    0.135040] <inf> ipc: rx	: 0x13000002|0x1
[    0.135525] <inf> ipc: rx	: 0x46000004|0x8
[    0.135915] <inf> ipc: rx	: 0x12000000|0x0
[    0.135943] <inf> dma: dma_put(), dma = 0x9e082390, sref = 0
[    0.135953] <inf> dai_intel_ssp: dai_ssp_pm_runtime_dis_ssp_power index 2
[    0.136088] <err> dai_intel_ssp: dai_ssp_poll_for_register_delay poll timeout reg 465924 mask 1024 val 1024 us 125
[    0.136095] <wrn> dai_intel_ssp: dai_ssp_pm_runtime_dis_ssp_power warning: timeout
[    0.136100] <inf> dai_intel_ssp: dai_ssp_pm_runtime_dis_ssp_power I2SLCTL
[    0.136586] <inf> ipc: rx	: 0x12010000|0x0
[    0.136601] <inf> src: comp:1 0x80000 src_free()
[    0.136671] <inf> dma: dma_put(), dma = 0x9e082420, sref = 1

$ arecord -Dhw:0,2 -c 2 -r 8000 -f S32_LE -vv /dev/null
Recording WAVE '/dev/null' : Signed 32 bit Little Endian, Rate 8000 Hz, Stereo
arecord: set_params:1416: Unable to install hw params:

dmesg

[  519.875389] snd_sof:sof_ipc4_init_input_audio_fmt: sof-audio-pci-intel-tgl 0000:00:1f.3: Init input audio formats for src.11.1
[  519.875391] snd_sof:sof_ipc4_dbg_audio_format: sof-audio-pci-intel-tgl 0000:00:1f.3: Pin index #0: 48000Hz, 32bit (ch_map 0xffffff10 ch_cfg 1 interleaving_style 0 fmt_cfg 0x2002) buffer size 384
[  519.875394] sof-audio-pci-intel-tgl 0000:00:1f.3: Failed to initialize output format for src.11.1
[  519.875400] sof-audio-pci-intel-tgl 0000:00:1f.3: failed to prepare widget src.11.1
[  519.875403] sof-audio-pci-intel-tgl 0000:00:1f.3: Failed to prepare connected widgets
[  519.875406] sof-audio-pci-intel-tgl 0000:00:1f.3: error: failed widget list set up for pcm 2 dir 1
[  519.875409] sof-audio-pci-intel-tgl 0000:00:1f.3: ASoC: error at snd_soc_pcm_component_hw_params on 0000:00:1f.3: -22
[  519.875431]  Port2: ASoC: error at __soc_pcm_hw_params on Port2: -22
[  519.875438]  Port2: ASoC: error at dpcm_fe_dai_hw_params on Port2: -22
[  519.875445] snd_sof:sof_pcm_hw_free: sof-audio-pci-intel-tgl 0000:00:1f.3: pcm: free stream 2 dir 1
[  519.875645] snd_sof:sof_pcm_close: sof-audio-pci-intel-tgl 0000:00:1f.3: pcm: close stream 2 dir 1

@fredoh9
Copy link
Collaborator

fredoh9 commented May 17, 2023

playback at 96Khz and capture 44.1Khz works. (96Khz -> 48Khz, 48Khz ->44.1Khz)
One more problem/question is that S16_LE didn't work, only S32_LE works. Is this right?

@singalsu
Copy link
Contributor Author

Ranjani's kernel PR is now merged. Also I've updated the topology PR thesofproject/sof#7547 .

In my own tests playback 8 - 96 kHz and capture 8 - 48 kHz with all formats worked.

@marc-hb marc-hb added the type:test coverage gap This requires a new test case, not just fixing one label Jun 22, 2023
@singalsu
Copy link
Contributor Author

#7547 is blocked due to a CI system issue with non-48 kHz ALSA speaker test limitation.

@lgirdwood lgirdwood added P2 Critical bugs or normal features and removed P1 Blocker bugs or important features labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Critical bugs or normal features type:test coverage gap This requires a new test case, not just fixing one
Projects
None yet
Development

No branches or pull requests

6 participants