-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,10 @@ | |
| }; | ||
| }; | ||
|
|
||
| &emul_dma { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &sdma3 { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -194,6 +194,10 @@ __cold int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config, | |
| cfg.type = DAI_IMX_MICFIL; | ||
| cfg_params = &sof_cfg->micfil; | ||
| break; | ||
| case SOF_DAI_VIRTUAL: | ||
| cfg.type = DAI_VIRTUAL; | ||
| cfg_params = &sof_cfg->virtual_dai; | ||
| break; | ||
| default: | ||
| return -EINVAL; | ||
| } | ||
|
|
@@ -492,8 +496,12 @@ __cold int dai_common_new(struct dai_data *dd, struct comp_dev *dev, | |
| dd->ipc_config = *dai_cfg; | ||
|
|
||
| /* request GP LP DMA with shared access privilege */ | ||
| #if CONFIG_DAI_VIRTUAL | ||
| dir = SOF_DMA_DIR_MEM_TO_MEM; | ||
| #else | ||
|
Comment on lines
+499
to
+501
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? |
||
| dir = dai_cfg->direction == SOF_IPC_STREAM_PLAYBACK ? | ||
| SOF_DMA_DIR_MEM_TO_DEV : SOF_DMA_DIR_DEV_TO_MEM; | ||
| #endif | ||
|
|
||
| dd->dma = sof_dma_get(dir, dd->dai->dma_caps, dd->dai->dma_dev, SOF_DMA_ACCESS_SHARED); | ||
| if (!dd->dma) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| divert(-1) | ||
|
|
||
| dnl Virtual DAI related macros | ||
|
|
||
| dnl DAI_VIRTUAL_CLOCK(clock, freq, codec_provider, polarity) | ||
| dnl polarity is optional | ||
| define(`DAI_VIRTUAL_CLOCK', | ||
| $1 STR($3) | ||
| $1_freq STR($2)) | ||
| `ifelse($4, `inverted', `$1_invert "true"',`')') | ||
|
|
||
| dnl DAI_VIRTUAL_TDM(slots, width, tx_mask, rx_mask) | ||
| define(`DAI_VIRTUAL_TDM', | ||
| ` tdm_slots 'STR($1) | ||
| ` tdm_slot_width 'STR($2) | ||
| ` tx_slots 'STR($3) | ||
| ` rx_slots 'STR($4) | ||
| ) | ||
|
|
||
| dnl DAI_VIRTUAL_CONFIG(format, mclk, bclk, fsync, tdm, config_data) | ||
| define(`DAI_VIRTUAL_CONFIG', | ||
| ` format "'$1`"' | ||
| ` '$2 | ||
| ` '$3 | ||
| ` '$4 | ||
| ` '$5 | ||
| `}' | ||
| $6 | ||
| ) | ||
|
|
||
| dnl DAI_VIRTUAL_CONFIG_DATA(type, idx, dummy_id) | ||
| dnl dummy_id is optional | ||
| define(`DAI_VIRTUAL_CONFIG_DATA', | ||
| `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' | ||
| ` tokens "sof_virtual_tokens"' | ||
| ` tuples."short" {' | ||
| ` SOF_TKN_DAI_VIRTUAL_MCLK_ID' ifelse($3, `', "0", STR($3)) | ||
| ` }' | ||
| `}' | ||
| `SectionData."'N_DAI_CONFIG($1$2)`_data" {' | ||
| ` tuples "'N_DAI_CONFIG($1$2)`_tuples"' | ||
| `}' | ||
| ) | ||
|
|
||
| divert(0)dnl |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # | ||
| # Topology for i.MX8 board using Virtual DAI (no physical codec) | ||
| # | ||
|
|
||
| # Include topology builder | ||
| include(`utils.m4') | ||
| include(`dai.m4') | ||
| include(`pipeline.m4') | ||
| include(`virtual-dai.m4') | ||
| include(`pcm.m4') | ||
| include(`buffer.m4') | ||
|
|
||
| # Include TLV library | ||
| include(`common/tlv.m4') | ||
|
|
||
| # Include Token library | ||
| include(`sof/tokens.m4') | ||
|
|
||
| # Include DSP configuration | ||
| include(`platform/imx/imx8.m4') | ||
|
|
||
| # | ||
| # Define the pipelines | ||
| # | ||
| # PCM0 ---> Volume ---> Virtual DAI0 (NoCodec) | ||
| # | ||
|
|
||
| dnl PIPELINE_PCM_ADD(pipeline, | ||
| dnl pipe id, pcm, max channels, format, | ||
| dnl period, priority, core, | ||
| dnl pcm_min_rate, pcm_max_rate, pipeline_rate, | ||
| dnl time_domain, sched_comp) | ||
|
|
||
| # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le | ||
| PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, | ||
| 1, 0, 2, s32le, | ||
| 1000, 0, 0, | ||
| 8000, 96000, 48000) | ||
|
|
||
| # | ||
| # DAIs configuration | ||
| # | ||
|
|
||
| dnl DAI_ADD(pipeline, | ||
| dnl pipe id, dai type, dai_index, dai_be, | ||
| dnl buffer, periods, format, | ||
| dnl deadline, priority, core, time_domain) | ||
|
|
||
| DAI_ADD(sof/pipe-dai-playback.m4, | ||
| 1, DAI_VIRTUAL, 7, NoCodec-0, | ||
| PIPELINE_SOURCE_1, 2, s32le, | ||
| 1000, 0, 0, SCHEDULE_TIME_DOMAIN_TIMER) | ||
|
|
||
| # | ||
| # PCM interface | ||
| # | ||
|
|
||
| dnl PCM_PLAYBACK_ADD(name, pcm_id, playback) | ||
| PCM_PLAYBACK_ADD(Port0, 0, PIPELINE_PCM_1) | ||
|
|
||
| # | ||
| # DAI Configuration | ||
| # | ||
|
|
||
| dnl DAI_CONFIG(type, dai_index, link_id, name, config) | ||
| DAI_CONFIG(DAI_VIRTUAL, 7, 0, NoCodec-0, | ||
| DAI_VIRTUAL_CONFIG(I2S, DAI_VIRTUAL_CLOCK(mclk, 0, dai_provider), | ||
| DAI_VIRTUAL_CLOCK(bclk, 0, dai_provider), | ||
| DAI_VIRTUAL_CLOCK(fsync, 0, dai_provider), | ||
| DAI_VIRTUAL_TDM(2, 32, 3, 3), | ||
| DAI_VIRTUAL_CONFIG_DATA(DAI_VIRTUAL, 7, 0))) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,3 +157,7 @@ SectionVendorTokens."sof_acp_sdw_tokens" { | |
| SOF_TKN_AMD_ACP_SDW_SAMPLERATE "2100" | ||
| SOF_TKN_AMD_ACP_SDW_CH "2101" | ||
| } | ||
|
|
||
| SectionVendorTokens."sof_virtual_tokens" { | ||
| SOF_TKN_DAI_VIRTUAL_MCLK_ID "2102" | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,4 +190,9 @@ Object.Base.VendorToken { | |
| node_type 1980 | ||
| deep_buffer_dma_ms 1981 | ||
| } | ||
|
|
||
| "19" { | ||
| name "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 we should not enable DAI_VIRTUAL and DMA_EMUL by default so please remove them from the config file.