1#
2# Unified topology for smart amplifier implementation.
3#
4
5# Include topology builder
6include(`utils.m4')
7include(`dai.m4')
8include(`pipeline.m4')
9
10ifelse(SDW, `1',
11`include(`alh.m4')',
12`include(`ssp.m4')')
13
14# Include Token library
15include(`sof/tokens.m4')
16
17DEBUG_START
18
19# define the default macros.
20# define them in your specific platform .m4 if needed.
21
22
23ifelse(SDW, `1',
24`
25# ALH related
26# define(`SMART_ALH_INDEX', 1) define smart amplifier ALH index
27ifdef(`SMART_ALH_INDEX',`',`errprint(note: Need to define ALH index for sof-smart-amplifier
28)')
29ifdef(`SMART_ALH_PLAYBACK_NAME',`',`errprint(note: Need to define ALH BE dai_link name for sof-smart-amplifier
30)')
31ifdef(`SMART_ALH_CAPTURE_NAME',`',`errprint(note: Need to define ALH BE dai_link name for sof-smart-amplifier
32)')
33',
34`
35# SSP related
36# define(`SMART_SSP_INDEX', 1) define smart amplifier SSP index
37ifdef(`SMART_SSP_INDEX',`',`errprint(note: Need to define SSP index for sof-smart-amplifier
38)')
39# define(`SMART_SSP_NAME', `SSP1-Codec') define SSP BE dai_link name
40ifdef(`SMART_SSP_NAME',`',`errprint(note: Need to define SSP BE dai_link name for sof-smart-amplifier
41)')
42# define(`SMART_SSP_QUIRK', 0) define SSP quirk for special use, e.g. set SSP_QUIRK_LBM to verify
43# smart_amp nocodec mode. Set it to 0 by default for normal mode.
44ifdef(`SMART_SSP_QUIRK',`',`define(`SMART_SSP_QUIRK', 0)')
45# define(`SSP_MCLK', ) define SSP mclk if not done yet
46ifdef(`SSP_MCLK',`',`define(`SSP_MCLK', 19200000)')
47')
48
49# define(`SMART_BE_ID', 7) define BE dai_link ID
50ifdef(`SMART_BE_ID',`',`errprint(note: Need to define SSP BE dai_link ID for sof-smart-amplifier
51)')
52# Playback related
53# define(`SMART_PB_PPL_ID', 1)
54ifdef(`SMART_PB_PPL_ID',`',`errprint(note: Need to define playback pipeline ID for sof-smart-amplifier
55)')
56# define(`SMART_PB_CH_NUM', 2)
57ifdef(`SMART_PB_CH_NUM',`',`errprint(note: Need to define playback channel number for sof-smart-amplifier
58)')
59define(`SMART_PIPE_SOURCE', concat(`PIPELINE_SOURCE_', SMART_PB_PPL_ID))
60# define(`SMART_TX_CHANNELS', 4)
61ifdef(`SMART_TX_CHANNELS',`',`errprint(note: Need to define DAI TX channel number for sof-smart-amplifier
62)')
63# define(`SMART_RX_CHANNELS', 8)
64ifdef(`SMART_RX_CHANNELS',`',`errprint(note: Need to define DAI RX channel number for sof-smart-amplifier
65)')
66# define(`SMART_FB_CHANNELS', 4)
67ifdef(`SMART_FB_CHANNELS',`',`errprint(note: Need to define feedback channel number for sof-smart-amplifier
68)')
69define(`SMART_PB_PPL_NAME', concat(`PIPELINE_PCM_', SMART_PB_PPL_ID))
70# Ref capture related
71# define(`SMART_REF_PPL_ID', 11)
72ifdef(`SMART_REF_PPL_ID',`',`errprint(note: Need to define Echo Ref pipeline ID for sof-smart-amplifier
73)')
74# define(`SMART_REF_CH_NUM', 4)
75ifdef(`SMART_REF_CH_NUM',`',`errprint(note: Need to define Echo Ref channel number for sof-smart-amplifier
76)')
77define(`SMART_PIPE_SINK', concat(`PIPELINE_SINK_', SMART_REF_PPL_ID))
78# define(`N_SMART_DEMUX', `MUXDEMUX'SMART_REF_PPL_ID`.'$1)
79define(`SMART_REF_PPL_NAME', concat(`PIPELINE_PCM_', SMART_REF_PPL_ID))
80# PCM related
81# define(`SMART_PCM_ID', 0)
82ifdef(`SMART_PCM_ID',`',`errprint(note: Need to define PCM ID for sof-smart-amplifier
83)')
84# define(`SMART_PCM_NAME', `smart373-spk')
85ifdef(`SMART_PCM_NAME',`',`errprint(note: Need to define Echo Ref pipeline ID for sof-smart-amplifier
86)')
87
88ifelse(SDW, `1',
89`
90#
91# Define the pipelines
92#
93# PCM2 ----> smart_amp ----> ALH(ALH_INDEX)
94#             ^
95#             |
96#             |
97# PCM3 <---- demux <----- ALH(ALH_INDEX + 1)
98#
99'
100,`
101#
102# Define the pipelines
103#
104# PCM0 ----> smart_amp ----> SSP(SSP_INDEX)
105#             ^
106#             |
107#             |
108# PCM0 <---- demux <----- SSP(SSP_INDEX)
109#
110')
111
112dnl PIPELINE_PCM_ADD(pipeline,
113dnl     pipe id, pcm, max channels, format,
114dnl     period, priority, core,
115dnl     pcm_min_rate, pcm_max_rate, pipeline_rate,
116dnl     time_domain, sched_comp)
117
118# Demux pipeline 1 on PCM 0 using max 2 channels of s32le.
119# Set 1000us deadline on core 0 with priority 0
120PIPELINE_PCM_ADD(sof/pipe-eq-iir-dts-codec-smart-amp-playback.m4,
121	SMART_PB_PPL_ID, SMART_PCM_ID, SMART_PB_CH_NUM, s32le,
122	1000, 0, SMART_AMP_CORE,
123	48000, 48000, 48000)
124
125# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le.
126# Set 1000us deadline on core 0 with priority 0
127ifelse(SDW, `1',
128`
129PIPELINE_PCM_ADD(sof/pipe-amp-ref-capture.m4,
130        SMART_REF_PPL_ID, eval(SMART_PCM_ID + 1), SMART_REF_CH_NUM, s32le,
131        1000, 0, SMART_AMP_CORE,
132        48000, 48000, 48000)
133',
134`
135PIPELINE_PCM_ADD(sof/pipe-amp-ref-capture.m4,
136	SMART_REF_PPL_ID, SMART_PCM_ID, SMART_REF_CH_NUM, s32le,
137	1000, 0, SMART_AMP_CORE,
138	48000, 48000, 48000)
139')
140
141#
142# DAIs configuration
143#
144
145dnl DAI_ADD(pipeline,
146dnl     pipe id, dai type, dai_index, dai_be,
147dnl     buffer, periods, format,
148dnl     deadline, priority, core, time_domain)
149
150ifelse(SDW, `1',
151`
152# playback DAI is ALH(ALH_INDEX) using 2 periods
153# Buffers use s32le format, 1000us deadline on core 0 with priority 0
154DAI_ADD(sof/pipe-dai-playback.m4,
155        SMART_PB_PPL_ID, ALH, SMART_ALH_INDEX, SMART_ALH_PLAYBACK_NAME,
156        SMART_PIPE_SOURCE, 2, s24le,
157        1000, 0, SMART_AMP_CORE, SCHEDULE_TIME_DOMAIN_TIMER)
158
159# capture DAI is ALH(ALH_INDEX) using 2 periods
160# Buffers use s32le format, 1000us deadline on core 0 with priority 0
161DAI_ADD(sof/pipe-dai-capture.m4,
162        SMART_REF_PPL_ID, ALH, eval(SMART_ALH_INDEX + 1), SMART_ALH_CAPTURE_NAME,
163        SMART_PIPE_SINK, 2, s24le,
164        1000, 0, SMART_AMP_CORE, SCHEDULE_TIME_DOMAIN_TIMER)
165',
166`
167# playback DAI is SSP(SPP_INDEX) using 2 periods
168# Buffers use s32le format, 1000us deadline on core 0 with priority 0
169DAI_ADD(sof/pipe-dai-playback.m4,
170	SMART_PB_PPL_ID, SSP, SMART_SSP_INDEX, SMART_SSP_NAME,
171	SMART_PIPE_SOURCE, 2, s32le,
172	1000, 0, SMART_AMP_CORE, SCHEDULE_TIME_DOMAIN_TIMER)
173
174# capture DAI is SSP(SSP_INDEX) using 2 periods
175# Buffers use s32le format, 1000us deadline on core 0 with priority 0
176DAI_ADD(sof/pipe-dai-capture.m4,
177	SMART_REF_PPL_ID, SSP, SMART_SSP_INDEX, SMART_SSP_NAME,
178	SMART_PIPE_SINK, 2, s32le,
179	1000, 0, SMART_AMP_CORE, SCHEDULE_TIME_DOMAIN_TIMER)
180')
181
182# Connect demux to smart_amp
183ifdef(`N_SMART_REF_BUF',`',`errprint(note: Need to define ref buffer name for connection
184)')
185ifdef(`N_SMART_DEMUX',`',`errprint(note: Need to define demux widget name for connection
186)')
187SectionGraph."PIPE_SMART_AMP" {
188	index "0"
189
190	lines [
191		# demux to smart_amp
192		dapm(N_SMART_REF_BUF, N_SMART_DEMUX)
193	]
194}
195
196# PCM for SMART_AMP Playback and EchoRef.
197ifelse(SDW, `1',
198`
199PCM_PLAYBACK_ADD(SMART_PCM_NAME, SMART_PCM_ID, SMART_PB_PPL_NAME)
200PCM_CAPTURE_ADD(echo, eval(SMART_PCM_ID + 1), SMART_REF_PPL_NAME)
201',
202`
203dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture)
204PCM_DUPLEX_ADD(SMART_PCM_NAME, SMART_PCM_ID, SMART_PB_PPL_NAME, SMART_REF_PPL_NAME)
205')
206
207#
208# BE configurations - overrides config in ACPI if present
209#
210
211ifelse(SDW, `1',
212`
213#ALH ALH Pin2 (ID: SMART_BE_ID)
214DAI_CONFIG(ALH, SMART_ALH_INDEX, SMART_BE_ID, SMART_ALH_PLAYBACK_NAME,
215        ALH_CONFIG(ALH_CONFIG_DATA(ALH, SMART_ALH_INDEX, 48000, SMART_TX_CHANNELS)))
216
217#ALH ALH Pin3 (ID: SMART_BE_ID + 1)
218DAI_CONFIG(ALH, eval(SMART_ALH_INDEX + 1), eval(SMART_BE_ID + 1), SMART_ALH_CAPTURE_NAME,
219        ALH_CONFIG(ALH_CONFIG_DATA(ALH, eval(SMART_ALH_INDEX + 1), 48000, SMART_RX_CHANNELS)))
220',
221`
222#SSP SSP_INDEX (ID: SMART_BE_ID)
223DAI_CONFIG(SSP, SMART_SSP_INDEX, SMART_BE_ID, SMART_SSP_NAME,
224	SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, SSP_MCLK, codec_mclk_in),
225		      SSP_CLOCK(bclk, 12288000, codec_slave),
226		      SSP_CLOCK(fsync, 48000, codec_slave),
227		      SSP_TDM(8, 32, 15, 255),
228		      SSP_CONFIG_DATA(SSP, SMART_SSP_INDEX, 32, 0, SMART_SSP_QUIRK)))
229')
230
231DEBUG_END
232