Skip to content

Commit 398356f

Browse files
topology1: Add support for Virtual DAI for i.MX8
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>
1 parent 90f53ab commit 398356f

File tree

5 files changed

+122
-1
lines changed

5 files changed

+122
-1
lines changed

tools/topology/topology1/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ set(TPLGS
7171
"sof-imx8mp-compr-pcm-cap-wm8960\;sof-imx8mp-compr-pcm-cap-wm8960"
7272
"sof-imx8mp-compr-wm8960\;sof-imx8mp-compr-wm8960\;-DCODEC=wm8960\;-DRATE=48000"
7373
"sof-imx8mp-compr-wm8960\;sof-imx8mp-compr-wm8962\;-DCODEC=wm8962\;-DRATE=48000"
74+
"sof-imx8-virtual\;sof-imx8-virtual"
7475
## end i.MX8MP topologies
7576

7677
## i.MX8ULP topologies

tools/topology/topology1/m4/dai.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ define(`DO_DAI_CONFIG',
155155
`'
156156
` id "'$3`"'
157157
`'
158-
` ifelse($1, `SSP', $5, $1, `HDA', $5, $1, `ALH', $5, $1, `ESAI', $5, $1, `SAI', $5, $1, `MICFIL', $5, $1, `AFE', $5, $1, `ACP', $5, $1, `ACPSP', $5, $1,`ACPSP_VIRTUAL', $5, $1, `ACPHS', $5, $1, `ACPHS_VIRTUAL', $5, $1, `ACP_SDW', $5, $1, `ACPDMIC', $5, `}')'
158+
` ifelse($1, `SSP', $5, $1, `HDA', $5, $1, `ALH', $5, $1, `ESAI', $5, $1, `SAI', $5, $1, `MICFIL', $5, $1, `AFE', $5, $1, `ACP', $5, $1, `ACPSP', $5, $1,`ACPSP_VIRTUAL', $5, $1, `ACPHS', $5, $1, `ACPHS_VIRTUAL', $5, $1, `ACP_SDW', $5, $1, `ACPDMIC', $5, $1, `DAI_VIRTUAL', $5, `}')'
159159
`ifelse($1, `DMIC', $5, `')'
160160
`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_common" {'
161161
` tokens "sof_dai_tokens"'
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
divert(-1)
2+
3+
dnl Virtual DAI related macros
4+
5+
dnl DAI_VIRTUAL_CLOCK(clock, freq, codec_provider, polarity)
6+
dnl polarity is optional
7+
define(`DAI_VIRTUAL_CLOCK',
8+
$1 STR($3)
9+
$1_freq STR($2))
10+
`ifelse($4, `inverted', `$1_invert "true"',`')')
11+
12+
dnl DAI_VIRTUAL_TDM(slots, width, tx_mask, rx_mask)
13+
define(`DAI_VIRTUAL_TDM',
14+
` tdm_slots 'STR($1)
15+
` tdm_slot_width 'STR($2)
16+
` tx_slots 'STR($3)
17+
` rx_slots 'STR($4)
18+
)
19+
20+
dnl DAI_VIRTUAL_CONFIG(format, mclk, bclk, fsync, tdm, config_data)
21+
define(`DAI_VIRTUAL_CONFIG',
22+
` format "'$1`"'
23+
` '$2
24+
` '$3
25+
` '$4
26+
` '$5
27+
`}'
28+
$6
29+
)
30+
31+
dnl DAI_VIRTUAL_CONFIG_DATA(type, idx, dummy_id)
32+
dnl dummy_id is optional
33+
define(`DAI_VIRTUAL_CONFIG_DATA',
34+
`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {'
35+
` tokens "sof_virtual_tokens"'
36+
` tuples."short" {'
37+
` SOF_TKN_DAI_VIRTUAL_MCLK_ID' ifelse($3, `', "0", STR($3))
38+
` }'
39+
`}'
40+
`SectionData."'N_DAI_CONFIG($1$2)`_data" {'
41+
` tuples "'N_DAI_CONFIG($1$2)`_tuples"'
42+
`}'
43+
)
44+
45+
divert(0)dnl
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Topology for i.MX8 board using Virtual DAI (no physical codec)
3+
#
4+
5+
# Include topology builder
6+
include(`utils.m4')
7+
include(`dai.m4')
8+
include(`pipeline.m4')
9+
include(`virtual-dai.m4')
10+
include(`pcm.m4')
11+
include(`buffer.m4')
12+
13+
# Include TLV library
14+
include(`common/tlv.m4')
15+
16+
# Include Token library
17+
include(`sof/tokens.m4')
18+
19+
# Include DSP configuration
20+
include(`platform/imx/imx8.m4')
21+
22+
#
23+
# Define the pipelines
24+
#
25+
# PCM0 ---> Volume ---> Virtual DAI0 (NoCodec)
26+
#
27+
28+
dnl PIPELINE_PCM_ADD(pipeline,
29+
dnl pipe id, pcm, max channels, format,
30+
dnl period, priority, core,
31+
dnl pcm_min_rate, pcm_max_rate, pipeline_rate,
32+
dnl time_domain, sched_comp)
33+
34+
# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le
35+
PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4,
36+
1, 0, 2, s32le,
37+
1000, 0, 0,
38+
8000, 96000, 48000)
39+
40+
#
41+
# DAIs configuration
42+
#
43+
44+
dnl DAI_ADD(pipeline,
45+
dnl pipe id, dai type, dai_index, dai_be,
46+
dnl buffer, periods, format,
47+
dnl deadline, priority, core, time_domain)
48+
49+
DAI_ADD(sof/pipe-dai-playback.m4,
50+
1, DAI_VIRTUAL, 7, NoCodec-0,
51+
PIPELINE_SOURCE_1, 2, s32le,
52+
1000, 0, 0, SCHEDULE_TIME_DOMAIN_TIMER)
53+
54+
#
55+
# PCM interface
56+
#
57+
58+
dnl PCM_PLAYBACK_ADD(name, pcm_id, playback)
59+
PCM_PLAYBACK_ADD(Port0, 0, PIPELINE_PCM_1)
60+
61+
#
62+
# DAI Configuration
63+
#
64+
65+
dnl DAI_CONFIG(type, dai_index, link_id, name, config)
66+
DAI_CONFIG(DAI_VIRTUAL, 7, 0, NoCodec-0,
67+
DAI_VIRTUAL_CONFIG(I2S, DAI_VIRTUAL_CLOCK(mclk, 0, dai_provider),
68+
DAI_VIRTUAL_CLOCK(bclk, 0, dai_provider),
69+
DAI_VIRTUAL_CLOCK(fsync, 0, dai_provider),
70+
DAI_VIRTUAL_TDM(2, 32, 3, 3),
71+
DAI_VIRTUAL_CONFIG_DATA(DAI_VIRTUAL, 7, 0)))

tools/topology/topology1/sof/tokens.m4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,7 @@ SectionVendorTokens."sof_acp_sdw_tokens" {
157157
SOF_TKN_AMD_ACP_SDW_SAMPLERATE "2100"
158158
SOF_TKN_AMD_ACP_SDW_CH "2101"
159159
}
160+
161+
SectionVendorTokens."sof_virtual_tokens" {
162+
SOF_TKN_DAI_VIRTUAL_MCLK_ID "2102"
163+
}

0 commit comments

Comments
 (0)