1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
6 // Copyright(c) 2021 Intel Corporation. All rights reserved.
10 #include <uapi/sound/sof/tokens.h>
11 #include <sound/pcm_params.h>
13 #include "sof-audio.h"
14 #include "ipc3-priv.h"
17 /* Full volume for default values */
18 #define VOL_ZERO_DB BIT(VOLUME_FWL)
20 /* size of tplg ABI in bytes */
21 #define SOF_IPC3_TPLG_ABI_SIZE 3
23 struct sof_widget_data {
28 struct snd_sof_control *control;
31 struct sof_process_types {
33 enum sof_ipc_process_type type;
34 enum sof_comp_type comp_type;
37 static const struct sof_process_types sof_process[] = {
38 {"EQFIR", SOF_PROCESS_EQFIR, SOF_COMP_EQ_FIR},
39 {"EQIIR", SOF_PROCESS_EQIIR, SOF_COMP_EQ_IIR},
40 {"KEYWORD_DETECT", SOF_PROCESS_KEYWORD_DETECT, SOF_COMP_KEYWORD_DETECT},
41 {"KPB", SOF_PROCESS_KPB, SOF_COMP_KPB},
42 {"CHAN_SELECTOR", SOF_PROCESS_CHAN_SELECTOR, SOF_COMP_SELECTOR},
43 {"MUX", SOF_PROCESS_MUX, SOF_COMP_MUX},
44 {"DEMUX", SOF_PROCESS_DEMUX, SOF_COMP_DEMUX},
45 {"DCBLOCK", SOF_PROCESS_DCBLOCK, SOF_COMP_DCBLOCK},
46 {"SMART_AMP", SOF_PROCESS_SMART_AMP, SOF_COMP_SMART_AMP},
49 static enum sof_ipc_process_type find_process(const char *name)
53 for (i = 0; i < ARRAY_SIZE(sof_process); i++) {
54 if (strcmp(name, sof_process[i].name) == 0)
55 return sof_process[i].type;
58 return SOF_PROCESS_NONE;
61 static int get_token_process_type(void *elem, void *object, u32 offset)
63 u32 *val = (u32 *)((u8 *)object + offset);
65 *val = find_process((const char *)elem);
70 static const struct sof_topology_token buffer_tokens[] = {
71 {SOF_TKN_BUF_SIZE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
72 offsetof(struct sof_ipc_buffer, size)},
73 {SOF_TKN_BUF_CAPS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
74 offsetof(struct sof_ipc_buffer, caps)},
78 static const struct sof_topology_token dai_tokens[] = {
79 {SOF_TKN_DAI_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_dai_type,
80 offsetof(struct sof_ipc_comp_dai, type)},
81 {SOF_TKN_DAI_INDEX, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
82 offsetof(struct sof_ipc_comp_dai, dai_index)},
83 {SOF_TKN_DAI_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
84 offsetof(struct sof_ipc_comp_dai, direction)},
88 static const struct sof_topology_token dai_link_tokens[] = {
89 {SOF_TKN_DAI_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_dai_type,
90 offsetof(struct sof_ipc_dai_config, type)},
91 {SOF_TKN_DAI_INDEX, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
92 offsetof(struct sof_ipc_dai_config, dai_index)},
96 static const struct sof_topology_token sched_tokens[] = {
97 {SOF_TKN_SCHED_PERIOD, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
98 offsetof(struct sof_ipc_pipe_new, period)},
99 {SOF_TKN_SCHED_PRIORITY, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
100 offsetof(struct sof_ipc_pipe_new, priority)},
101 {SOF_TKN_SCHED_MIPS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
102 offsetof(struct sof_ipc_pipe_new, period_mips)},
103 {SOF_TKN_SCHED_CORE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
104 offsetof(struct sof_ipc_pipe_new, core)},
105 {SOF_TKN_SCHED_FRAMES, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
106 offsetof(struct sof_ipc_pipe_new, frames_per_sched)},
107 {SOF_TKN_SCHED_TIME_DOMAIN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
108 offsetof(struct sof_ipc_pipe_new, time_domain)},
111 static const struct sof_topology_token pipeline_tokens[] = {
112 {SOF_TKN_SCHED_DYNAMIC_PIPELINE, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
113 offsetof(struct snd_sof_widget, dynamic_pipeline_widget)},
118 static const struct sof_topology_token volume_tokens[] = {
119 {SOF_TKN_VOLUME_RAMP_STEP_TYPE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
120 offsetof(struct sof_ipc_comp_volume, ramp)},
121 {SOF_TKN_VOLUME_RAMP_STEP_MS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
122 offsetof(struct sof_ipc_comp_volume, initial_ramp)},
126 static const struct sof_topology_token src_tokens[] = {
127 {SOF_TKN_SRC_RATE_IN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
128 offsetof(struct sof_ipc_comp_src, source_rate)},
129 {SOF_TKN_SRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
130 offsetof(struct sof_ipc_comp_src, sink_rate)},
134 static const struct sof_topology_token asrc_tokens[] = {
135 {SOF_TKN_ASRC_RATE_IN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
136 offsetof(struct sof_ipc_comp_asrc, source_rate)},
137 {SOF_TKN_ASRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
138 offsetof(struct sof_ipc_comp_asrc, sink_rate)},
139 {SOF_TKN_ASRC_ASYNCHRONOUS_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
140 offsetof(struct sof_ipc_comp_asrc, asynchronous_mode)},
141 {SOF_TKN_ASRC_OPERATION_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
142 offsetof(struct sof_ipc_comp_asrc, operation_mode)},
146 static const struct sof_topology_token process_tokens[] = {
147 {SOF_TKN_PROCESS_TYPE, SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_process_type,
148 offsetof(struct sof_ipc_comp_process, type)},
152 static const struct sof_topology_token pcm_tokens[] = {
153 {SOF_TKN_PCM_DMAC_CONFIG, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
154 offsetof(struct sof_ipc_comp_host, dmac_config)},
157 /* Generic components */
158 static const struct sof_topology_token comp_tokens[] = {
159 {SOF_TKN_COMP_PERIOD_SINK_COUNT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
160 offsetof(struct sof_ipc_comp_config, periods_sink)},
161 {SOF_TKN_COMP_PERIOD_SOURCE_COUNT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
162 offsetof(struct sof_ipc_comp_config, periods_source)},
163 {SOF_TKN_COMP_FORMAT,
164 SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format,
165 offsetof(struct sof_ipc_comp_config, frame_fmt)},
169 static const struct sof_topology_token ssp_tokens[] = {
170 {SOF_TKN_INTEL_SSP_CLKS_CONTROL, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
171 offsetof(struct sof_ipc_dai_ssp_params, clks_control)},
172 {SOF_TKN_INTEL_SSP_MCLK_ID, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
173 offsetof(struct sof_ipc_dai_ssp_params, mclk_id)},
174 {SOF_TKN_INTEL_SSP_SAMPLE_BITS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
175 offsetof(struct sof_ipc_dai_ssp_params, sample_valid_bits)},
176 {SOF_TKN_INTEL_SSP_FRAME_PULSE_WIDTH, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
177 offsetof(struct sof_ipc_dai_ssp_params, frame_pulse_width)},
178 {SOF_TKN_INTEL_SSP_QUIRKS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
179 offsetof(struct sof_ipc_dai_ssp_params, quirks)},
180 {SOF_TKN_INTEL_SSP_TDM_PADDING_PER_SLOT, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16,
181 offsetof(struct sof_ipc_dai_ssp_params, tdm_per_slot_padding_flag)},
182 {SOF_TKN_INTEL_SSP_BCLK_DELAY, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
183 offsetof(struct sof_ipc_dai_ssp_params, bclk_delay)},
187 static const struct sof_topology_token alh_tokens[] = {
188 {SOF_TKN_INTEL_ALH_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
189 offsetof(struct sof_ipc_dai_alh_params, rate)},
190 {SOF_TKN_INTEL_ALH_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
191 offsetof(struct sof_ipc_dai_alh_params, channels)},
195 static const struct sof_topology_token dmic_tokens[] = {
196 {SOF_TKN_INTEL_DMIC_DRIVER_VERSION, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
197 offsetof(struct sof_ipc_dai_dmic_params, driver_ipc_version)},
198 {SOF_TKN_INTEL_DMIC_CLK_MIN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
199 offsetof(struct sof_ipc_dai_dmic_params, pdmclk_min)},
200 {SOF_TKN_INTEL_DMIC_CLK_MAX, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
201 offsetof(struct sof_ipc_dai_dmic_params, pdmclk_max)},
202 {SOF_TKN_INTEL_DMIC_SAMPLE_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
203 offsetof(struct sof_ipc_dai_dmic_params, fifo_fs)},
204 {SOF_TKN_INTEL_DMIC_DUTY_MIN, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
205 offsetof(struct sof_ipc_dai_dmic_params, duty_min)},
206 {SOF_TKN_INTEL_DMIC_DUTY_MAX, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
207 offsetof(struct sof_ipc_dai_dmic_params, duty_max)},
208 {SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
209 offsetof(struct sof_ipc_dai_dmic_params, num_pdm_active)},
210 {SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
211 offsetof(struct sof_ipc_dai_dmic_params, fifo_bits)},
212 {SOF_TKN_INTEL_DMIC_UNMUTE_RAMP_TIME_MS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
213 offsetof(struct sof_ipc_dai_dmic_params, unmute_ramp_time)},
217 static const struct sof_topology_token esai_tokens[] = {
218 {SOF_TKN_IMX_ESAI_MCLK_ID, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
219 offsetof(struct sof_ipc_dai_esai_params, mclk_id)},
223 static const struct sof_topology_token sai_tokens[] = {
224 {SOF_TKN_IMX_SAI_MCLK_ID, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
225 offsetof(struct sof_ipc_dai_sai_params, mclk_id)},
230 * SOF_TKN_INTEL_DMIC_PDM_CTRL_ID should be the first token
231 * as it increments the index while parsing the array of pdm tokens
232 * and determines the correct offset
234 static const struct sof_topology_token dmic_pdm_tokens[] = {
235 {SOF_TKN_INTEL_DMIC_PDM_CTRL_ID, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
236 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, id)},
237 {SOF_TKN_INTEL_DMIC_PDM_MIC_A_Enable, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
238 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, enable_mic_a)},
239 {SOF_TKN_INTEL_DMIC_PDM_MIC_B_Enable, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
240 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, enable_mic_b)},
241 {SOF_TKN_INTEL_DMIC_PDM_POLARITY_A, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
242 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, polarity_mic_a)},
243 {SOF_TKN_INTEL_DMIC_PDM_POLARITY_B, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
244 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, polarity_mic_b)},
245 {SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
246 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, clk_edge)},
247 {SOF_TKN_INTEL_DMIC_PDM_SKEW, SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
248 offsetof(struct sof_ipc_dai_dmic_pdm_ctrl, skew)},
252 static const struct sof_topology_token hda_tokens[] = {
253 {SOF_TKN_INTEL_HDA_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
254 offsetof(struct sof_ipc_dai_hda_params, rate)},
255 {SOF_TKN_INTEL_HDA_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
256 offsetof(struct sof_ipc_dai_hda_params, channels)},
260 static const struct sof_topology_token afe_tokens[] = {
261 {SOF_TKN_MEDIATEK_AFE_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
262 offsetof(struct sof_ipc_dai_mtk_afe_params, rate)},
263 {SOF_TKN_MEDIATEK_AFE_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
264 offsetof(struct sof_ipc_dai_mtk_afe_params, channels)},
265 {SOF_TKN_MEDIATEK_AFE_FORMAT, SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format,
266 offsetof(struct sof_ipc_dai_mtk_afe_params, format)},
270 static const struct sof_topology_token acpdmic_tokens[] = {
271 {SOF_TKN_AMD_ACPDMIC_RATE,
272 SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
273 offsetof(struct sof_ipc_dai_acpdmic_params, pdm_rate)},
274 {SOF_TKN_AMD_ACPDMIC_CH,
275 SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
276 offsetof(struct sof_ipc_dai_acpdmic_params, pdm_ch)},
280 static const struct sof_topology_token acpi2s_tokens[] = {
281 {SOF_TKN_AMD_ACPI2S_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
282 offsetof(struct sof_ipc_dai_acp_params, fsync_rate)},
283 {SOF_TKN_AMD_ACPI2S_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
284 offsetof(struct sof_ipc_dai_acp_params, tdm_slots)},
285 {SOF_TKN_AMD_ACPI2S_TDM_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
286 offsetof(struct sof_ipc_dai_acp_params, tdm_mode)},
290 static const struct sof_topology_token core_tokens[] = {
291 {SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
292 offsetof(struct sof_ipc_comp, core)},
295 /* Component extended tokens */
296 static const struct sof_topology_token comp_ext_tokens[] = {
297 {SOF_TKN_COMP_UUID, SND_SOC_TPLG_TUPLE_TYPE_UUID, get_token_uuid,
298 offsetof(struct snd_sof_widget, uuid)},
301 static const struct sof_token_info ipc3_token_list[SOF_TOKEN_COUNT] = {
302 [SOF_PCM_TOKENS] = {"PCM tokens", pcm_tokens, ARRAY_SIZE(pcm_tokens)},
303 [SOF_PIPELINE_TOKENS] = {"Pipeline tokens", pipeline_tokens, ARRAY_SIZE(pipeline_tokens)},
304 [SOF_SCHED_TOKENS] = {"Scheduler tokens", sched_tokens, ARRAY_SIZE(sched_tokens)},
305 [SOF_COMP_TOKENS] = {"Comp tokens", comp_tokens, ARRAY_SIZE(comp_tokens)},
306 [SOF_CORE_TOKENS] = {"Core tokens", core_tokens, ARRAY_SIZE(core_tokens)},
307 [SOF_COMP_EXT_TOKENS] = {"AFE tokens", comp_ext_tokens, ARRAY_SIZE(comp_ext_tokens)},
308 [SOF_BUFFER_TOKENS] = {"Buffer tokens", buffer_tokens, ARRAY_SIZE(buffer_tokens)},
309 [SOF_VOLUME_TOKENS] = {"Volume tokens", volume_tokens, ARRAY_SIZE(volume_tokens)},
310 [SOF_SRC_TOKENS] = {"SRC tokens", src_tokens, ARRAY_SIZE(src_tokens)},
311 [SOF_ASRC_TOKENS] = {"ASRC tokens", asrc_tokens, ARRAY_SIZE(asrc_tokens)},
312 [SOF_PROCESS_TOKENS] = {"Process tokens", process_tokens, ARRAY_SIZE(process_tokens)},
313 [SOF_DAI_TOKENS] = {"DAI tokens", dai_tokens, ARRAY_SIZE(dai_tokens)},
314 [SOF_DAI_LINK_TOKENS] = {"DAI link tokens", dai_link_tokens, ARRAY_SIZE(dai_link_tokens)},
315 [SOF_HDA_TOKENS] = {"HDA tokens", hda_tokens, ARRAY_SIZE(hda_tokens)},
316 [SOF_SSP_TOKENS] = {"SSP tokens", ssp_tokens, ARRAY_SIZE(ssp_tokens)},
317 [SOF_ALH_TOKENS] = {"ALH tokens", alh_tokens, ARRAY_SIZE(alh_tokens)},
318 [SOF_DMIC_TOKENS] = {"DMIC tokens", dmic_tokens, ARRAY_SIZE(dmic_tokens)},
319 [SOF_DMIC_PDM_TOKENS] = {"DMIC PDM tokens", dmic_pdm_tokens, ARRAY_SIZE(dmic_pdm_tokens)},
320 [SOF_ESAI_TOKENS] = {"ESAI tokens", esai_tokens, ARRAY_SIZE(esai_tokens)},
321 [SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)},
322 [SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)},
323 [SOF_ACPDMIC_TOKENS] = {"ACPDMIC tokens", acpdmic_tokens, ARRAY_SIZE(acpdmic_tokens)},
324 [SOF_ACPI2S_TOKENS] = {"ACPI2S tokens", acpi2s_tokens, ARRAY_SIZE(acpi2s_tokens)},
328 * sof_comp_alloc - allocate and initialize buffer for a new component
329 * @swidget: pointer to struct snd_sof_widget containing extended data
330 * @ipc_size: IPC payload size that will be updated depending on valid
332 * @index: ID of the pipeline the component belongs to
334 * Return: The pointer to the new allocated component, NULL if failed.
336 static void *sof_comp_alloc(struct snd_sof_widget *swidget, size_t *ipc_size,
339 struct sof_ipc_comp *comp;
340 size_t total_size = *ipc_size;
341 size_t ext_size = sizeof(swidget->uuid);
343 /* only non-zero UUID is valid */
344 if (!guid_is_null(&swidget->uuid))
345 total_size += ext_size;
347 comp = kzalloc(total_size, GFP_KERNEL);
351 /* configure comp new IPC message */
352 comp->hdr.size = total_size;
353 comp->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW;
354 comp->id = swidget->comp_id;
355 comp->pipeline_id = index;
356 comp->core = swidget->core;
358 /* handle the extended data if needed */
359 if (total_size > *ipc_size) {
360 /* append extended data to the end of the component */
361 memcpy((u8 *)comp + *ipc_size, &swidget->uuid, ext_size);
362 comp->ext_data_length = ext_size;
365 /* update ipc_size and return */
366 *ipc_size = total_size;
370 static void sof_dbg_comp_config(struct snd_soc_component *scomp, struct sof_ipc_comp_config *config)
372 dev_dbg(scomp->dev, " config: periods snk %d src %d fmt %d\n",
373 config->periods_sink, config->periods_source,
377 static int sof_ipc3_widget_setup_comp_host(struct snd_sof_widget *swidget)
379 struct snd_soc_component *scomp = swidget->scomp;
380 struct sof_ipc_comp_host *host;
381 size_t ipc_size = sizeof(*host);
384 host = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
387 swidget->private = host;
389 /* configure host comp IPC message */
390 host->comp.type = SOF_COMP_HOST;
391 host->config.hdr.size = sizeof(host->config);
393 if (swidget->id == snd_soc_dapm_aif_out)
394 host->direction = SOF_IPC_STREAM_CAPTURE;
396 host->direction = SOF_IPC_STREAM_PLAYBACK;
398 /* parse one set of pcm_tokens */
399 ret = sof_update_ipc_object(scomp, host, SOF_PCM_TOKENS, swidget->tuples,
400 swidget->num_tuples, sizeof(*host), 1);
404 /* parse one set of comp_tokens */
405 ret = sof_update_ipc_object(scomp, &host->config, SOF_COMP_TOKENS, swidget->tuples,
406 swidget->num_tuples, sizeof(host->config), 1);
410 dev_dbg(scomp->dev, "loaded host %s\n", swidget->widget->name);
411 sof_dbg_comp_config(scomp, &host->config);
415 kfree(swidget->private);
416 swidget->private = NULL;
421 static void sof_ipc3_widget_free_comp(struct snd_sof_widget *swidget)
423 kfree(swidget->private);
426 static int sof_ipc3_widget_setup_comp_tone(struct snd_sof_widget *swidget)
428 struct snd_soc_component *scomp = swidget->scomp;
429 struct sof_ipc_comp_tone *tone;
430 size_t ipc_size = sizeof(*tone);
433 tone = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
437 swidget->private = tone;
439 /* configure siggen IPC message */
440 tone->comp.type = SOF_COMP_TONE;
441 tone->config.hdr.size = sizeof(tone->config);
443 /* parse one set of comp tokens */
444 ret = sof_update_ipc_object(scomp, &tone->config, SOF_COMP_TOKENS, swidget->tuples,
445 swidget->num_tuples, sizeof(tone->config), 1);
447 kfree(swidget->private);
448 swidget->private = NULL;
452 dev_dbg(scomp->dev, "tone %s: frequency %d amplitude %d\n",
453 swidget->widget->name, tone->frequency, tone->amplitude);
454 sof_dbg_comp_config(scomp, &tone->config);
459 static int sof_ipc3_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
461 struct snd_soc_component *scomp = swidget->scomp;
462 struct sof_ipc_comp_mixer *mixer;
463 size_t ipc_size = sizeof(*mixer);
466 mixer = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
470 swidget->private = mixer;
472 /* configure mixer IPC message */
473 mixer->comp.type = SOF_COMP_MIXER;
474 mixer->config.hdr.size = sizeof(mixer->config);
476 /* parse one set of comp tokens */
477 ret = sof_update_ipc_object(scomp, &mixer->config, SOF_COMP_TOKENS,
478 swidget->tuples, swidget->num_tuples,
479 sizeof(mixer->config), 1);
481 kfree(swidget->private);
482 swidget->private = NULL;
487 dev_dbg(scomp->dev, "loaded mixer %s\n", swidget->widget->name);
488 sof_dbg_comp_config(scomp, &mixer->config);
493 static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
495 struct snd_soc_component *scomp = swidget->scomp;
496 struct sof_ipc_pipe_new *pipeline;
497 struct snd_sof_widget *comp_swidget;
500 pipeline = kzalloc(sizeof(*pipeline), GFP_KERNEL);
504 /* configure pipeline IPC message */
505 pipeline->hdr.size = sizeof(*pipeline);
506 pipeline->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_PIPE_NEW;
507 pipeline->pipeline_id = swidget->pipeline_id;
508 pipeline->comp_id = swidget->comp_id;
510 swidget->private = pipeline;
512 /* component at start of pipeline is our stream id */
513 comp_swidget = snd_sof_find_swidget(scomp, swidget->widget->sname);
515 dev_err(scomp->dev, "scheduler %s refers to non existent widget %s\n",
516 swidget->widget->name, swidget->widget->sname);
521 pipeline->sched_id = comp_swidget->comp_id;
523 /* parse one set of scheduler tokens */
524 ret = sof_update_ipc_object(scomp, pipeline, SOF_SCHED_TOKENS, swidget->tuples,
525 swidget->num_tuples, sizeof(*pipeline), 1);
529 /* parse one set of pipeline tokens */
530 ret = sof_update_ipc_object(scomp, swidget, SOF_PIPELINE_TOKENS, swidget->tuples,
531 swidget->num_tuples, sizeof(*swidget), 1);
535 if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE))
536 pipeline->core = SOF_DSP_PRIMARY_CORE;
538 if (sof_debug_check_flag(SOF_DBG_DYNAMIC_PIPELINES_OVERRIDE))
539 swidget->dynamic_pipeline_widget =
540 sof_debug_check_flag(SOF_DBG_DYNAMIC_PIPELINES_ENABLE);
542 dev_dbg(scomp->dev, "pipeline %s: period %d pri %d mips %d core %d frames %d dynamic %d\n",
543 swidget->widget->name, pipeline->period, pipeline->priority,
544 pipeline->period_mips, pipeline->core, pipeline->frames_per_sched,
545 swidget->dynamic_pipeline_widget);
547 swidget->core = pipeline->core;
552 kfree(swidget->private);
553 swidget->private = NULL;
558 static int sof_ipc3_widget_setup_comp_buffer(struct snd_sof_widget *swidget)
560 struct snd_soc_component *scomp = swidget->scomp;
561 struct sof_ipc_buffer *buffer;
564 buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
568 swidget->private = buffer;
570 /* configure dai IPC message */
571 buffer->comp.hdr.size = sizeof(*buffer);
572 buffer->comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_BUFFER_NEW;
573 buffer->comp.id = swidget->comp_id;
574 buffer->comp.type = SOF_COMP_BUFFER;
575 buffer->comp.pipeline_id = swidget->pipeline_id;
576 buffer->comp.core = swidget->core;
578 /* parse one set of buffer tokens */
579 ret = sof_update_ipc_object(scomp, buffer, SOF_BUFFER_TOKENS, swidget->tuples,
580 swidget->num_tuples, sizeof(*buffer), 1);
582 kfree(swidget->private);
583 swidget->private = NULL;
587 dev_dbg(scomp->dev, "buffer %s: size %d caps 0x%x\n",
588 swidget->widget->name, buffer->size, buffer->caps);
593 static int sof_ipc3_widget_setup_comp_src(struct snd_sof_widget *swidget)
595 struct snd_soc_component *scomp = swidget->scomp;
596 struct sof_ipc_comp_src *src;
597 size_t ipc_size = sizeof(*src);
600 src = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
604 swidget->private = src;
606 /* configure src IPC message */
607 src->comp.type = SOF_COMP_SRC;
608 src->config.hdr.size = sizeof(src->config);
610 /* parse one set of src tokens */
611 ret = sof_update_ipc_object(scomp, src, SOF_SRC_TOKENS, swidget->tuples,
612 swidget->num_tuples, sizeof(*src), 1);
616 /* parse one set of comp tokens */
617 ret = sof_update_ipc_object(scomp, &src->config, SOF_COMP_TOKENS,
618 swidget->tuples, swidget->num_tuples, sizeof(src->config), 1);
622 dev_dbg(scomp->dev, "src %s: source rate %d sink rate %d\n",
623 swidget->widget->name, src->source_rate, src->sink_rate);
624 sof_dbg_comp_config(scomp, &src->config);
628 kfree(swidget->private);
629 swidget->private = NULL;
634 static int sof_ipc3_widget_setup_comp_asrc(struct snd_sof_widget *swidget)
636 struct snd_soc_component *scomp = swidget->scomp;
637 struct sof_ipc_comp_asrc *asrc;
638 size_t ipc_size = sizeof(*asrc);
641 asrc = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
645 swidget->private = asrc;
647 /* configure ASRC IPC message */
648 asrc->comp.type = SOF_COMP_ASRC;
649 asrc->config.hdr.size = sizeof(asrc->config);
651 /* parse one set of asrc tokens */
652 ret = sof_update_ipc_object(scomp, asrc, SOF_ASRC_TOKENS, swidget->tuples,
653 swidget->num_tuples, sizeof(*asrc), 1);
657 /* parse one set of comp tokens */
658 ret = sof_update_ipc_object(scomp, &asrc->config, SOF_COMP_TOKENS,
659 swidget->tuples, swidget->num_tuples, sizeof(asrc->config), 1);
663 dev_dbg(scomp->dev, "asrc %s: source rate %d sink rate %d asynch %d operation %d\n",
664 swidget->widget->name, asrc->source_rate, asrc->sink_rate,
665 asrc->asynchronous_mode, asrc->operation_mode);
667 sof_dbg_comp_config(scomp, &asrc->config);
671 kfree(swidget->private);
672 swidget->private = NULL;
680 static int sof_ipc3_widget_setup_comp_mux(struct snd_sof_widget *swidget)
682 struct snd_soc_component *scomp = swidget->scomp;
683 struct sof_ipc_comp_mux *mux;
684 size_t ipc_size = sizeof(*mux);
687 mux = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
691 swidget->private = mux;
693 /* configure mux IPC message */
694 mux->comp.type = SOF_COMP_MUX;
695 mux->config.hdr.size = sizeof(mux->config);
697 /* parse one set of comp tokens */
698 ret = sof_update_ipc_object(scomp, &mux->config, SOF_COMP_TOKENS,
699 swidget->tuples, swidget->num_tuples, sizeof(mux->config), 1);
701 kfree(swidget->private);
702 swidget->private = NULL;
706 dev_dbg(scomp->dev, "loaded mux %s\n", swidget->widget->name);
707 sof_dbg_comp_config(scomp, &mux->config);
716 static int sof_ipc3_widget_setup_comp_pga(struct snd_sof_widget *swidget)
718 struct snd_soc_component *scomp = swidget->scomp;
719 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
720 struct sof_ipc_comp_volume *volume;
721 struct snd_sof_control *scontrol;
722 size_t ipc_size = sizeof(*volume);
723 int min_step, max_step;
726 volume = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
730 swidget->private = volume;
732 /* configure volume IPC message */
733 volume->comp.type = SOF_COMP_VOLUME;
734 volume->config.hdr.size = sizeof(volume->config);
736 /* parse one set of volume tokens */
737 ret = sof_update_ipc_object(scomp, volume, SOF_VOLUME_TOKENS, swidget->tuples,
738 swidget->num_tuples, sizeof(*volume), 1);
742 /* parse one set of comp tokens */
743 ret = sof_update_ipc_object(scomp, &volume->config, SOF_COMP_TOKENS,
744 swidget->tuples, swidget->num_tuples,
745 sizeof(volume->config), 1);
749 dev_dbg(scomp->dev, "loaded PGA %s\n", swidget->widget->name);
750 sof_dbg_comp_config(scomp, &volume->config);
752 list_for_each_entry(scontrol, &sdev->kcontrol_list, list) {
753 if (scontrol->comp_id == swidget->comp_id &&
754 scontrol->volume_table) {
755 min_step = scontrol->min_volume_step;
756 max_step = scontrol->max_volume_step;
757 volume->min_value = scontrol->volume_table[min_step];
758 volume->max_value = scontrol->volume_table[max_step];
759 volume->channels = scontrol->num_channels;
766 kfree(swidget->private);
767 swidget->private = NULL;
772 static int sof_get_control_data(struct snd_soc_component *scomp,
773 struct snd_soc_dapm_widget *widget,
774 struct sof_widget_data *wdata, size_t *size)
776 const struct snd_kcontrol_new *kc;
777 struct sof_ipc_ctrl_data *cdata;
778 struct soc_mixer_control *sm;
779 struct soc_bytes_ext *sbe;
785 for (i = 0; i < widget->num_kcontrols; i++) {
786 kc = &widget->kcontrol_news[i];
788 switch (widget->dobj.widget.kcontrol_type[i]) {
789 case SND_SOC_TPLG_TYPE_MIXER:
790 sm = (struct soc_mixer_control *)kc->private_value;
791 wdata[i].control = sm->dobj.private;
793 case SND_SOC_TPLG_TYPE_BYTES:
794 sbe = (struct soc_bytes_ext *)kc->private_value;
795 wdata[i].control = sbe->dobj.private;
797 case SND_SOC_TPLG_TYPE_ENUM:
798 se = (struct soc_enum *)kc->private_value;
799 wdata[i].control = se->dobj.private;
802 dev_err(scomp->dev, "Unknown kcontrol type %u in widget %s\n",
803 widget->dobj.widget.kcontrol_type[i], widget->name);
807 if (!wdata[i].control) {
808 dev_err(scomp->dev, "No scontrol for widget %s\n", widget->name);
812 cdata = wdata[i].control->ipc_control_data;
814 if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES) {
815 /* make sure data is valid - data can be updated at runtime */
816 if (cdata->data->magic != SOF_ABI_MAGIC)
819 wdata[i].pdata = cdata->data->data;
820 wdata[i].pdata_size = cdata->data->size;
822 /* points to the control data union */
823 wdata[i].pdata = cdata->chanv;
825 * wdata[i].control->size is calculated with struct_size
826 * and includes the size of struct sof_ipc_ctrl_data
828 wdata[i].pdata_size = wdata[i].control->size -
829 sizeof(struct sof_ipc_ctrl_data);
832 *size += wdata[i].pdata_size;
835 switch (cdata->cmd) {
836 case SOF_CTRL_CMD_VOLUME:
837 case SOF_CTRL_CMD_ENUM:
838 case SOF_CTRL_CMD_SWITCH:
839 wdata[i].ipc_cmd = SOF_IPC_COMP_SET_VALUE;
840 wdata[i].ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET;
842 case SOF_CTRL_CMD_BINARY:
843 wdata[i].ipc_cmd = SOF_IPC_COMP_SET_DATA;
844 wdata[i].ctrl_type = SOF_CTRL_TYPE_DATA_SET;
854 static int sof_process_load(struct snd_soc_component *scomp,
855 struct snd_sof_widget *swidget, int type)
857 struct snd_soc_dapm_widget *widget = swidget->widget;
858 struct sof_ipc_comp_process *process;
859 struct sof_widget_data *wdata = NULL;
860 size_t ipc_data_size = 0;
866 /* allocate struct for widget control data sizes and types */
867 if (widget->num_kcontrols) {
868 wdata = kcalloc(widget->num_kcontrols, sizeof(*wdata), GFP_KERNEL);
872 /* get possible component controls and get size of all pdata */
873 ret = sof_get_control_data(scomp, widget, wdata, &ipc_data_size);
878 ipc_size = sizeof(struct sof_ipc_comp_process) + ipc_data_size;
880 /* we are exceeding max ipc size, config needs to be sent separately */
881 if (ipc_size > SOF_IPC_MSG_MAX_SIZE) {
882 ipc_size -= ipc_data_size;
886 process = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
892 swidget->private = process;
894 /* configure iir IPC message */
895 process->comp.type = type;
896 process->config.hdr.size = sizeof(process->config);
898 /* parse one set of comp tokens */
899 ret = sof_update_ipc_object(scomp, &process->config, SOF_COMP_TOKENS,
900 swidget->tuples, swidget->num_tuples,
901 sizeof(process->config), 1);
905 dev_dbg(scomp->dev, "loaded process %s\n", swidget->widget->name);
906 sof_dbg_comp_config(scomp, &process->config);
909 * found private data in control, so copy it.
910 * get possible component controls - get size of all pdata,
911 * then memcpy with headers
914 for (i = 0; i < widget->num_kcontrols; i++) {
915 if (!wdata[i].pdata_size)
918 memcpy(&process->data[offset], wdata[i].pdata,
919 wdata[i].pdata_size);
920 offset += wdata[i].pdata_size;
924 process->size = ipc_data_size;
930 kfree(swidget->private);
931 swidget->private = NULL;
937 static enum sof_comp_type find_process_comp_type(enum sof_ipc_process_type type)
941 for (i = 0; i < ARRAY_SIZE(sof_process); i++) {
942 if (sof_process[i].type == type)
943 return sof_process[i].comp_type;
946 return SOF_COMP_NONE;
950 * Processing Component Topology - can be "effect", "codec", or general
954 static int sof_widget_update_ipc_comp_process(struct snd_sof_widget *swidget)
956 struct snd_soc_component *scomp = swidget->scomp;
957 struct sof_ipc_comp_process config;
960 memset(&config, 0, sizeof(config));
961 config.comp.core = swidget->core;
963 /* parse one set of process tokens */
964 ret = sof_update_ipc_object(scomp, &config, SOF_PROCESS_TOKENS, swidget->tuples,
965 swidget->num_tuples, sizeof(config), 1);
969 /* now load process specific data and send IPC */
970 return sof_process_load(scomp, swidget, find_process_comp_type(config.type));
973 static int sof_link_hda_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
974 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
976 struct sof_dai_private_data *private = dai->private;
977 u32 size = sizeof(*config);
981 memset(&config->hda, 0, sizeof(config->hda));
982 config->hdr.size = size;
984 /* parse one set of HDA tokens */
985 ret = sof_update_ipc_object(scomp, &config->hda, SOF_HDA_TOKENS, slink->tuples,
986 slink->num_tuples, size, 1);
990 dev_dbg(scomp->dev, "HDA config rate %d channels %d\n",
991 config->hda.rate, config->hda.channels);
993 config->hda.link_dma_ch = DMA_CHAN_INVALID;
995 dai->number_configs = 1;
996 dai->current_config = 0;
997 private->dai_config = kmemdup(config, size, GFP_KERNEL);
998 if (!private->dai_config)
1004 static void sof_dai_set_format(struct snd_soc_tplg_hw_config *hw_config,
1005 struct sof_ipc_dai_config *config)
1007 /* clock directions wrt codec */
1008 config->format &= ~SOF_DAI_FMT_CLOCK_PROVIDER_MASK;
1009 if (hw_config->bclk_provider == SND_SOC_TPLG_BCLK_CP) {
1010 /* codec is bclk provider */
1011 if (hw_config->fsync_provider == SND_SOC_TPLG_FSYNC_CP)
1012 config->format |= SOF_DAI_FMT_CBP_CFP;
1014 config->format |= SOF_DAI_FMT_CBP_CFC;
1016 /* codec is bclk consumer */
1017 if (hw_config->fsync_provider == SND_SOC_TPLG_FSYNC_CP)
1018 config->format |= SOF_DAI_FMT_CBC_CFP;
1020 config->format |= SOF_DAI_FMT_CBC_CFC;
1023 /* inverted clocks ? */
1024 config->format &= ~SOF_DAI_FMT_INV_MASK;
1025 if (hw_config->invert_bclk) {
1026 if (hw_config->invert_fsync)
1027 config->format |= SOF_DAI_FMT_IB_IF;
1029 config->format |= SOF_DAI_FMT_IB_NF;
1031 if (hw_config->invert_fsync)
1032 config->format |= SOF_DAI_FMT_NB_IF;
1034 config->format |= SOF_DAI_FMT_NB_NF;
1038 static int sof_link_sai_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1039 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1041 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1042 struct sof_dai_private_data *private = dai->private;
1043 u32 size = sizeof(*config);
1046 /* handle master/slave and inverted clocks */
1047 sof_dai_set_format(hw_config, config);
1050 memset(&config->sai, 0, sizeof(config->sai));
1051 config->hdr.size = size;
1053 /* parse one set of SAI tokens */
1054 ret = sof_update_ipc_object(scomp, &config->sai, SOF_SAI_TOKENS, slink->tuples,
1055 slink->num_tuples, size, 1);
1059 config->sai.mclk_rate = le32_to_cpu(hw_config->mclk_rate);
1060 config->sai.bclk_rate = le32_to_cpu(hw_config->bclk_rate);
1061 config->sai.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
1062 config->sai.mclk_direction = hw_config->mclk_direction;
1064 config->sai.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
1065 config->sai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width);
1066 config->sai.rx_slots = le32_to_cpu(hw_config->rx_slots);
1067 config->sai.tx_slots = le32_to_cpu(hw_config->tx_slots);
1069 dev_info(scomp->dev,
1070 "tplg: config SAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n",
1071 config->dai_index, config->format,
1072 config->sai.mclk_rate, config->sai.tdm_slot_width,
1073 config->sai.tdm_slots, config->sai.mclk_id);
1075 if (config->sai.tdm_slots < 1 || config->sai.tdm_slots > 8) {
1076 dev_err(scomp->dev, "Invalid channel count for SAI%d\n", config->dai_index);
1080 dai->number_configs = 1;
1081 dai->current_config = 0;
1082 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1083 if (!private->dai_config)
1089 static int sof_link_esai_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1090 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1092 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1093 struct sof_dai_private_data *private = dai->private;
1094 u32 size = sizeof(*config);
1097 /* handle master/slave and inverted clocks */
1098 sof_dai_set_format(hw_config, config);
1101 memset(&config->esai, 0, sizeof(config->esai));
1102 config->hdr.size = size;
1104 /* parse one set of ESAI tokens */
1105 ret = sof_update_ipc_object(scomp, &config->esai, SOF_ESAI_TOKENS, slink->tuples,
1106 slink->num_tuples, size, 1);
1110 config->esai.mclk_rate = le32_to_cpu(hw_config->mclk_rate);
1111 config->esai.bclk_rate = le32_to_cpu(hw_config->bclk_rate);
1112 config->esai.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
1113 config->esai.mclk_direction = hw_config->mclk_direction;
1114 config->esai.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
1115 config->esai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width);
1116 config->esai.rx_slots = le32_to_cpu(hw_config->rx_slots);
1117 config->esai.tx_slots = le32_to_cpu(hw_config->tx_slots);
1119 dev_info(scomp->dev,
1120 "tplg: config ESAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n",
1121 config->dai_index, config->format,
1122 config->esai.mclk_rate, config->esai.tdm_slot_width,
1123 config->esai.tdm_slots, config->esai.mclk_id);
1125 if (config->esai.tdm_slots < 1 || config->esai.tdm_slots > 8) {
1126 dev_err(scomp->dev, "Invalid channel count for ESAI%d\n", config->dai_index);
1130 dai->number_configs = 1;
1131 dai->current_config = 0;
1132 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1133 if (!private->dai_config)
1139 static int sof_link_acp_dmic_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1140 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1142 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1143 struct sof_dai_private_data *private = dai->private;
1144 u32 size = sizeof(*config);
1147 /* handle master/slave and inverted clocks */
1148 sof_dai_set_format(hw_config, config);
1150 config->hdr.size = size;
1152 /* parse the required set of ACPDMIC tokens based on num_hw_cfgs */
1153 ret = sof_update_ipc_object(scomp, &config->acpdmic, SOF_ACPDMIC_TOKENS, slink->tuples,
1154 slink->num_tuples, size, slink->num_hw_configs);
1158 dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n",
1159 config->dai_index, config->acpdmic.pdm_ch,
1160 config->acpdmic.pdm_rate);
1162 dai->number_configs = 1;
1163 dai->current_config = 0;
1164 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1165 if (!private->dai_config)
1171 static int sof_link_acp_bt_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1172 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1174 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1175 struct sof_dai_private_data *private = dai->private;
1176 u32 size = sizeof(*config);
1178 /* handle master/slave and inverted clocks */
1179 sof_dai_set_format(hw_config, config);
1182 memset(&config->acpbt, 0, sizeof(config->acpbt));
1183 config->hdr.size = size;
1185 config->acpbt.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
1186 config->acpbt.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
1188 dev_info(scomp->dev, "ACP_BT config ACP%d channel %d rate %d\n",
1189 config->dai_index, config->acpbt.tdm_slots,
1190 config->acpbt.fsync_rate);
1192 dai->number_configs = 1;
1193 dai->current_config = 0;
1194 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1195 if (!private->dai_config)
1201 static int sof_link_acp_sp_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1202 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1204 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1205 struct sof_dai_private_data *private = dai->private;
1206 u32 size = sizeof(*config);
1209 /* handle master/slave and inverted clocks */
1210 sof_dai_set_format(hw_config, config);
1213 memset(&config->acpsp, 0, sizeof(config->acpsp));
1214 config->hdr.size = size;
1216 ret = sof_update_ipc_object(scomp, &config->acpsp, SOF_ACPI2S_TOKENS, slink->tuples,
1217 slink->num_tuples, size, slink->num_hw_configs);
1222 dev_info(scomp->dev, "ACP_SP config ACP%d channel %d rate %d tdm_mode %d\n",
1223 config->dai_index, config->acpsp.tdm_slots,
1224 config->acpsp.fsync_rate, config->acpsp.tdm_mode);
1226 dai->number_configs = 1;
1227 dai->current_config = 0;
1228 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1229 if (!private->dai_config)
1235 static int sof_link_acp_hs_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1236 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1238 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1239 struct sof_dai_private_data *private = dai->private;
1240 u32 size = sizeof(*config);
1243 /* Configures the DAI hardware format and inverted clocks */
1244 sof_dai_set_format(hw_config, config);
1247 memset(&config->acphs, 0, sizeof(config->acphs));
1248 config->hdr.size = size;
1250 ret = sof_update_ipc_object(scomp, &config->acphs, SOF_ACPI2S_TOKENS, slink->tuples,
1251 slink->num_tuples, size, slink->num_hw_configs);
1255 dev_info(scomp->dev, "ACP_HS config ACP%d channel %d rate %d tdm_mode %d\n",
1256 config->dai_index, config->acphs.tdm_slots,
1257 config->acphs.fsync_rate, config->acphs.tdm_mode);
1259 dai->number_configs = 1;
1260 dai->current_config = 0;
1261 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1262 if (!private->dai_config)
1268 static int sof_link_afe_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1269 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1271 struct sof_dai_private_data *private = dai->private;
1272 u32 size = sizeof(*config);
1275 config->hdr.size = size;
1277 /* parse the required set of AFE tokens based on num_hw_cfgs */
1278 ret = sof_update_ipc_object(scomp, &config->afe, SOF_AFE_TOKENS, slink->tuples,
1279 slink->num_tuples, size, slink->num_hw_configs);
1283 dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n",
1284 config->afe.rate, config->afe.channels, config->afe.format);
1286 config->afe.stream_id = DMA_CHAN_INVALID;
1288 dai->number_configs = 1;
1289 dai->current_config = 0;
1290 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1291 if (!private->dai_config)
1297 static int sof_link_ssp_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1298 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1300 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
1301 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1302 struct sof_dai_private_data *private = dai->private;
1303 u32 size = sizeof(*config);
1304 int current_config = 0;
1308 * Parse common data, we should have 1 common data per hw_config.
1310 ret = sof_update_ipc_object(scomp, &config->ssp, SOF_SSP_TOKENS, slink->tuples,
1311 slink->num_tuples, size, slink->num_hw_configs);
1315 /* process all possible hw configs */
1316 for (i = 0; i < slink->num_hw_configs; i++) {
1317 if (le32_to_cpu(hw_config[i].id) == slink->default_hw_cfg_id)
1320 /* handle master/slave and inverted clocks */
1321 sof_dai_set_format(&hw_config[i], &config[i]);
1323 config[i].hdr.size = size;
1325 if (sdev->mclk_id_override) {
1326 dev_dbg(scomp->dev, "tplg: overriding topology mclk_id %d by quirk %d\n",
1327 config[i].ssp.mclk_id, sdev->mclk_id_quirk);
1328 config[i].ssp.mclk_id = sdev->mclk_id_quirk;
1331 /* copy differentiating hw configs to ipc structs */
1332 config[i].ssp.mclk_rate = le32_to_cpu(hw_config[i].mclk_rate);
1333 config[i].ssp.bclk_rate = le32_to_cpu(hw_config[i].bclk_rate);
1334 config[i].ssp.fsync_rate = le32_to_cpu(hw_config[i].fsync_rate);
1335 config[i].ssp.tdm_slots = le32_to_cpu(hw_config[i].tdm_slots);
1336 config[i].ssp.tdm_slot_width = le32_to_cpu(hw_config[i].tdm_slot_width);
1337 config[i].ssp.mclk_direction = hw_config[i].mclk_direction;
1338 config[i].ssp.rx_slots = le32_to_cpu(hw_config[i].rx_slots);
1339 config[i].ssp.tx_slots = le32_to_cpu(hw_config[i].tx_slots);
1341 dev_dbg(scomp->dev, "tplg: config SSP%d fmt %#x mclk %d bclk %d fclk %d width (%d)%d slots %d mclk id %d quirks %d clks_control %#x\n",
1342 config[i].dai_index, config[i].format,
1343 config[i].ssp.mclk_rate, config[i].ssp.bclk_rate,
1344 config[i].ssp.fsync_rate, config[i].ssp.sample_valid_bits,
1345 config[i].ssp.tdm_slot_width, config[i].ssp.tdm_slots,
1346 config[i].ssp.mclk_id, config[i].ssp.quirks, config[i].ssp.clks_control);
1348 /* validate SSP fsync rate and channel count */
1349 if (config[i].ssp.fsync_rate < 8000 || config[i].ssp.fsync_rate > 192000) {
1350 dev_err(scomp->dev, "Invalid fsync rate for SSP%d\n", config[i].dai_index);
1354 if (config[i].ssp.tdm_slots < 1 || config[i].ssp.tdm_slots > 8) {
1355 dev_err(scomp->dev, "Invalid channel count for SSP%d\n",
1356 config[i].dai_index);
1361 dai->number_configs = slink->num_hw_configs;
1362 dai->current_config = current_config;
1363 private->dai_config = kmemdup(config, size * slink->num_hw_configs, GFP_KERNEL);
1364 if (!private->dai_config)
1370 static int sof_link_dmic_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1371 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1373 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
1374 struct sof_dai_private_data *private = dai->private;
1375 struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
1376 struct sof_ipc_fw_version *v = &ready->version;
1377 size_t size = sizeof(*config);
1380 /* Ensure the entire DMIC config struct is zeros */
1381 memset(&config->dmic, 0, sizeof(config->dmic));
1383 /* parse the required set of DMIC tokens based on num_hw_cfgs */
1384 ret = sof_update_ipc_object(scomp, &config->dmic, SOF_DMIC_TOKENS, slink->tuples,
1385 slink->num_tuples, size, slink->num_hw_configs);
1389 /* parse the required set of DMIC PDM tokens based on number of active PDM's */
1390 ret = sof_update_ipc_object(scomp, &config->dmic.pdm[0], SOF_DMIC_PDM_TOKENS,
1391 slink->tuples, slink->num_tuples,
1392 sizeof(struct sof_ipc_dai_dmic_pdm_ctrl),
1393 config->dmic.num_pdm_active);
1397 /* set IPC header size */
1398 config->hdr.size = size;
1400 /* debug messages */
1401 dev_dbg(scomp->dev, "tplg: config DMIC%d driver version %d\n",
1402 config->dai_index, config->dmic.driver_ipc_version);
1403 dev_dbg(scomp->dev, "pdmclk_min %d pdm_clkmax %d duty_min %d\n",
1404 config->dmic.pdmclk_min, config->dmic.pdmclk_max,
1405 config->dmic.duty_min);
1406 dev_dbg(scomp->dev, "duty_max %d fifo_fs %d num_pdms active %d\n",
1407 config->dmic.duty_max, config->dmic.fifo_fs,
1408 config->dmic.num_pdm_active);
1409 dev_dbg(scomp->dev, "fifo word length %d\n", config->dmic.fifo_bits);
1411 for (i = 0; i < config->dmic.num_pdm_active; i++) {
1412 dev_dbg(scomp->dev, "pdm %d mic a %d mic b %d\n",
1413 config->dmic.pdm[i].id,
1414 config->dmic.pdm[i].enable_mic_a,
1415 config->dmic.pdm[i].enable_mic_b);
1416 dev_dbg(scomp->dev, "pdm %d polarity a %d polarity b %d\n",
1417 config->dmic.pdm[i].id,
1418 config->dmic.pdm[i].polarity_mic_a,
1419 config->dmic.pdm[i].polarity_mic_b);
1420 dev_dbg(scomp->dev, "pdm %d clk_edge %d skew %d\n",
1421 config->dmic.pdm[i].id,
1422 config->dmic.pdm[i].clk_edge,
1423 config->dmic.pdm[i].skew);
1427 * this takes care of backwards compatible handling of fifo_bits_b.
1428 * It is deprecated since firmware ABI version 3.0.1.
1430 if (SOF_ABI_VER(v->major, v->minor, v->micro) < SOF_ABI_VER(3, 0, 1))
1431 config->dmic.fifo_bits_b = config->dmic.fifo_bits;
1433 dai->number_configs = 1;
1434 dai->current_config = 0;
1435 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1436 if (!private->dai_config)
1442 static int sof_link_alh_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink,
1443 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai)
1445 struct sof_dai_private_data *private = dai->private;
1446 u32 size = sizeof(*config);
1449 /* parse the required set of ALH tokens based on num_hw_cfgs */
1450 ret = sof_update_ipc_object(scomp, &config->alh, SOF_ALH_TOKENS, slink->tuples,
1451 slink->num_tuples, size, slink->num_hw_configs);
1456 config->hdr.size = size;
1458 /* set config for all DAI's with name matching the link name */
1459 dai->number_configs = 1;
1460 dai->current_config = 0;
1461 private->dai_config = kmemdup(config, size, GFP_KERNEL);
1462 if (!private->dai_config)
1468 static int sof_ipc3_widget_setup_comp_dai(struct snd_sof_widget *swidget)
1470 struct snd_soc_component *scomp = swidget->scomp;
1471 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
1472 struct snd_sof_dai *dai = swidget->private;
1473 struct sof_dai_private_data *private;
1474 struct sof_ipc_comp_dai *comp_dai;
1475 size_t ipc_size = sizeof(*comp_dai);
1476 struct sof_ipc_dai_config *config;
1477 struct snd_sof_dai_link *slink;
1480 private = kzalloc(sizeof(*private), GFP_KERNEL);
1484 dai->private = private;
1486 private->comp_dai = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
1487 if (!private->comp_dai) {
1492 /* configure dai IPC message */
1493 comp_dai = private->comp_dai;
1494 comp_dai->comp.type = SOF_COMP_DAI;
1495 comp_dai->config.hdr.size = sizeof(comp_dai->config);
1497 /* parse one set of DAI tokens */
1498 ret = sof_update_ipc_object(scomp, comp_dai, SOF_DAI_TOKENS, swidget->tuples,
1499 swidget->num_tuples, sizeof(*comp_dai), 1);
1503 /* update comp_tokens */
1504 ret = sof_update_ipc_object(scomp, &comp_dai->config, SOF_COMP_TOKENS,
1505 swidget->tuples, swidget->num_tuples,
1506 sizeof(comp_dai->config), 1);
1510 dev_dbg(scomp->dev, "dai %s: type %d index %d\n",
1511 swidget->widget->name, comp_dai->type, comp_dai->dai_index);
1512 sof_dbg_comp_config(scomp, &comp_dai->config);
1514 /* now update DAI config */
1515 list_for_each_entry(slink, &sdev->dai_link_list, list) {
1516 struct sof_ipc_dai_config common_config;
1519 if (strcmp(slink->link->name, dai->name))
1522 /* Reserve memory for all hw configs, eventually freed by widget */
1523 config = kcalloc(slink->num_hw_configs, sizeof(*config), GFP_KERNEL);
1529 /* parse one set of DAI link tokens */
1530 ret = sof_update_ipc_object(scomp, &common_config, SOF_DAI_LINK_TOKENS,
1531 slink->tuples, slink->num_tuples,
1532 sizeof(common_config), 1);
1536 for (i = 0; i < slink->num_hw_configs; i++) {
1537 config[i].hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG;
1538 config[i].format = le32_to_cpu(slink->hw_configs[i].fmt);
1539 config[i].type = common_config.type;
1540 config[i].dai_index = comp_dai->dai_index;
1543 switch (common_config.type) {
1544 case SOF_DAI_INTEL_SSP:
1545 ret = sof_link_ssp_load(scomp, slink, config, dai);
1547 case SOF_DAI_INTEL_DMIC:
1548 ret = sof_link_dmic_load(scomp, slink, config, dai);
1550 case SOF_DAI_INTEL_HDA:
1551 ret = sof_link_hda_load(scomp, slink, config, dai);
1553 case SOF_DAI_INTEL_ALH:
1554 ret = sof_link_alh_load(scomp, slink, config, dai);
1556 case SOF_DAI_IMX_SAI:
1557 ret = sof_link_sai_load(scomp, slink, config, dai);
1559 case SOF_DAI_IMX_ESAI:
1560 ret = sof_link_esai_load(scomp, slink, config, dai);
1562 case SOF_DAI_AMD_BT:
1563 ret = sof_link_acp_bt_load(scomp, slink, config, dai);
1565 case SOF_DAI_AMD_SP:
1566 case SOF_DAI_AMD_SP_VIRTUAL:
1567 ret = sof_link_acp_sp_load(scomp, slink, config, dai);
1569 case SOF_DAI_AMD_HS:
1570 case SOF_DAI_AMD_HS_VIRTUAL:
1571 ret = sof_link_acp_hs_load(scomp, slink, config, dai);
1573 case SOF_DAI_AMD_DMIC:
1574 ret = sof_link_acp_dmic_load(scomp, slink, config, dai);
1576 case SOF_DAI_MEDIATEK_AFE:
1577 ret = sof_link_afe_load(scomp, slink, config, dai);
1583 dev_err(scomp->dev, "failed to load config for dai %s\n", dai->name);
1597 dai->private = NULL;
1601 static void sof_ipc3_widget_free_comp_dai(struct snd_sof_widget *swidget)
1603 switch (swidget->id) {
1604 case snd_soc_dapm_dai_in:
1605 case snd_soc_dapm_dai_out:
1607 struct snd_sof_dai *dai = swidget->private;
1608 struct sof_dai_private_data *dai_data;
1613 dai_data = dai->private;
1615 kfree(dai_data->comp_dai);
1616 kfree(dai_data->dai_config);
1627 static int sof_ipc3_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *sroute)
1629 struct sof_ipc_pipe_comp_connect connect;
1630 struct sof_ipc_reply reply;
1633 connect.hdr.size = sizeof(connect);
1634 connect.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT;
1635 connect.source_id = sroute->src_widget->comp_id;
1636 connect.sink_id = sroute->sink_widget->comp_id;
1638 dev_dbg(sdev->dev, "setting up route %s -> %s\n",
1639 sroute->src_widget->widget->name,
1640 sroute->sink_widget->widget->name);
1643 ret = sof_ipc_tx_message(sdev->ipc, &connect, sizeof(connect), &reply, sizeof(reply));
1645 dev_err(sdev->dev, "%s: route %s -> %s failed\n", __func__,
1646 sroute->src_widget->widget->name, sroute->sink_widget->widget->name);
1651 static int sof_ipc3_control_load_bytes(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
1653 struct sof_ipc_ctrl_data *cdata;
1654 size_t priv_size_check;
1657 if (scontrol->max_size < (sizeof(*cdata) + sizeof(struct sof_abi_hdr))) {
1658 dev_err(sdev->dev, "%s: insufficient size for a bytes control: %zu.\n",
1659 __func__, scontrol->max_size);
1663 if (scontrol->priv_size > scontrol->max_size - sizeof(*cdata)) {
1665 "%s: bytes data size %zu exceeds max %zu.\n", __func__,
1666 scontrol->priv_size, scontrol->max_size - sizeof(*cdata));
1670 scontrol->ipc_control_data = kzalloc(scontrol->max_size, GFP_KERNEL);
1671 if (!scontrol->ipc_control_data)
1674 scontrol->size = sizeof(struct sof_ipc_ctrl_data) + scontrol->priv_size;
1676 cdata = scontrol->ipc_control_data;
1677 cdata->cmd = SOF_CTRL_CMD_BINARY;
1678 cdata->index = scontrol->index;
1680 if (scontrol->priv_size > 0) {
1681 memcpy(cdata->data, scontrol->priv, scontrol->priv_size);
1682 kfree(scontrol->priv);
1683 scontrol->priv = NULL;
1685 if (cdata->data->magic != SOF_ABI_MAGIC) {
1686 dev_err(sdev->dev, "Wrong ABI magic 0x%08x.\n", cdata->data->magic);
1691 if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi)) {
1692 dev_err(sdev->dev, "Incompatible ABI version 0x%08x.\n",
1698 priv_size_check = cdata->data->size + sizeof(struct sof_abi_hdr);
1699 if (priv_size_check != scontrol->priv_size) {
1700 dev_err(sdev->dev, "Conflict in bytes (%zu) vs. priv size (%zu).\n",
1701 priv_size_check, scontrol->priv_size);
1709 kfree(scontrol->ipc_control_data);
1710 scontrol->ipc_control_data = NULL;
1714 static int sof_ipc3_control_load_volume(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
1716 struct sof_ipc_ctrl_data *cdata;
1719 /* init the volume get/put data */
1720 scontrol->size = struct_size(cdata, chanv, scontrol->num_channels);
1722 scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL);
1723 if (!scontrol->ipc_control_data)
1726 cdata = scontrol->ipc_control_data;
1727 cdata->index = scontrol->index;
1729 /* set cmd for mixer control */
1730 if (scontrol->max == 1) {
1731 cdata->cmd = SOF_CTRL_CMD_SWITCH;
1735 cdata->cmd = SOF_CTRL_CMD_VOLUME;
1737 /* set default volume values to 0dB in control */
1738 for (i = 0; i < scontrol->num_channels; i++) {
1739 cdata->chanv[i].channel = i;
1740 cdata->chanv[i].value = VOL_ZERO_DB;
1746 static int sof_ipc3_control_load_enum(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
1748 struct sof_ipc_ctrl_data *cdata;
1750 /* init the enum get/put data */
1751 scontrol->size = struct_size(cdata, chanv, scontrol->num_channels);
1753 scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL);
1754 if (!scontrol->ipc_control_data)
1757 cdata = scontrol->ipc_control_data;
1758 cdata->index = scontrol->index;
1759 cdata->cmd = SOF_CTRL_CMD_ENUM;
1764 static int sof_ipc3_control_setup(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
1766 switch (scontrol->info_type) {
1767 case SND_SOC_TPLG_CTL_VOLSW:
1768 case SND_SOC_TPLG_CTL_VOLSW_SX:
1769 case SND_SOC_TPLG_CTL_VOLSW_XR_SX:
1770 return sof_ipc3_control_load_volume(sdev, scontrol);
1771 case SND_SOC_TPLG_CTL_BYTES:
1772 return sof_ipc3_control_load_bytes(sdev, scontrol);
1773 case SND_SOC_TPLG_CTL_ENUM:
1774 case SND_SOC_TPLG_CTL_ENUM_VALUE:
1775 return sof_ipc3_control_load_enum(sdev, scontrol);
1783 static int sof_ipc3_control_free(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
1785 struct sof_ipc_free fcomp;
1787 fcomp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_FREE;
1788 fcomp.hdr.size = sizeof(fcomp);
1789 fcomp.id = scontrol->comp_id;
1791 /* send IPC to the DSP */
1792 return sof_ipc_tx_message(sdev->ipc, &fcomp, sizeof(fcomp), NULL, 0);
1795 /* send pcm params ipc */
1796 static int sof_ipc3_keyword_detect_pcm_params(struct snd_sof_widget *swidget, int dir)
1798 struct snd_soc_component *scomp = swidget->scomp;
1799 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
1800 struct sof_ipc_pcm_params_reply ipc_params_reply;
1801 struct snd_pcm_hw_params *params;
1802 struct sof_ipc_pcm_params pcm;
1803 struct snd_sof_pcm *spcm;
1806 /* get runtime PCM params using widget's stream name */
1807 spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname);
1809 dev_err(scomp->dev, "Cannot find PCM for %s\n", swidget->widget->name);
1813 params = &spcm->params[dir];
1815 /* set IPC PCM params */
1816 memset(&pcm, 0, sizeof(pcm));
1817 pcm.hdr.size = sizeof(pcm);
1818 pcm.hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_PARAMS;
1819 pcm.comp_id = swidget->comp_id;
1820 pcm.params.hdr.size = sizeof(pcm.params);
1821 pcm.params.direction = dir;
1822 pcm.params.sample_valid_bytes = params_width(params) >> 3;
1823 pcm.params.buffer_fmt = SOF_IPC_BUFFER_INTERLEAVED;
1824 pcm.params.rate = params_rate(params);
1825 pcm.params.channels = params_channels(params);
1826 pcm.params.host_period_bytes = params_period_bytes(params);
1829 switch (params_format(params)) {
1830 case SNDRV_PCM_FORMAT_S16:
1831 pcm.params.frame_fmt = SOF_IPC_FRAME_S16_LE;
1833 case SNDRV_PCM_FORMAT_S24:
1834 pcm.params.frame_fmt = SOF_IPC_FRAME_S24_4LE;
1836 case SNDRV_PCM_FORMAT_S32:
1837 pcm.params.frame_fmt = SOF_IPC_FRAME_S32_LE;
1843 /* send IPC to the DSP */
1844 ret = sof_ipc_tx_message(sdev->ipc, &pcm, sizeof(pcm),
1845 &ipc_params_reply, sizeof(ipc_params_reply));
1847 dev_err(scomp->dev, "%s: PCM params failed for %s\n", __func__,
1848 swidget->widget->name);
1853 /* send stream trigger ipc */
1854 static int sof_ipc3_keyword_detect_trigger(struct snd_sof_widget *swidget, int cmd)
1856 struct snd_soc_component *scomp = swidget->scomp;
1857 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
1858 struct sof_ipc_stream stream;
1859 struct sof_ipc_reply reply;
1862 /* set IPC stream params */
1863 stream.hdr.size = sizeof(stream);
1864 stream.hdr.cmd = SOF_IPC_GLB_STREAM_MSG | cmd;
1865 stream.comp_id = swidget->comp_id;
1867 /* send IPC to the DSP */
1868 ret = sof_ipc_tx_message(sdev->ipc, &stream, sizeof(stream), &reply, sizeof(reply));
1870 dev_err(scomp->dev, "%s: Failed to trigger %s\n", __func__, swidget->widget->name);
1875 static int sof_ipc3_keyword_dapm_event(struct snd_soc_dapm_widget *w,
1876 struct snd_kcontrol *k, int event)
1878 struct snd_sof_widget *swidget = w->dobj.private;
1879 struct snd_soc_component *scomp;
1880 int stream = SNDRV_PCM_STREAM_CAPTURE;
1881 struct snd_sof_pcm *spcm;
1887 scomp = swidget->scomp;
1889 dev_dbg(scomp->dev, "received event %d for widget %s\n",
1892 /* get runtime PCM params using widget's stream name */
1893 spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname);
1895 dev_err(scomp->dev, "%s: Cannot find PCM for %s\n", __func__,
1896 swidget->widget->name);
1900 /* process events */
1902 case SND_SOC_DAPM_PRE_PMU:
1903 if (spcm->stream[stream].suspend_ignored) {
1904 dev_dbg(scomp->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n");
1908 /* set pcm params */
1909 ret = sof_ipc3_keyword_detect_pcm_params(swidget, stream);
1911 dev_err(scomp->dev, "%s: Failed to set pcm params for widget %s\n",
1912 __func__, swidget->widget->name);
1917 ret = sof_ipc3_keyword_detect_trigger(swidget, SOF_IPC_STREAM_TRIG_START);
1919 dev_err(scomp->dev, "%s: Failed to trigger widget %s\n", __func__,
1920 swidget->widget->name);
1922 case SND_SOC_DAPM_POST_PMD:
1923 if (spcm->stream[stream].suspend_ignored) {
1925 "POST_PMD event ignored, KWD pipeline will remain RUNNING\n");
1930 ret = sof_ipc3_keyword_detect_trigger(swidget, SOF_IPC_STREAM_TRIG_STOP);
1932 dev_err(scomp->dev, "%s: Failed to trigger widget %s\n", __func__,
1933 swidget->widget->name);
1936 ret = sof_ipc3_keyword_detect_trigger(swidget, SOF_IPC_STREAM_PCM_FREE);
1938 dev_err(scomp->dev, "%s: Failed to free PCM for widget %s\n", __func__,
1939 swidget->widget->name);
1948 /* event handlers for keyword detect component */
1949 static const struct snd_soc_tplg_widget_events sof_kwd_events[] = {
1950 {SOF_KEYWORD_DETECT_DAPM_EVENT, sof_ipc3_keyword_dapm_event},
1953 static int sof_ipc3_widget_bind_event(struct snd_soc_component *scomp,
1954 struct snd_sof_widget *swidget, u16 event_type)
1956 struct sof_ipc_comp *ipc_comp;
1958 /* validate widget event type */
1959 switch (event_type) {
1960 case SOF_KEYWORD_DETECT_DAPM_EVENT:
1961 /* only KEYWORD_DETECT comps should handle this */
1962 if (swidget->id != snd_soc_dapm_effect)
1965 ipc_comp = swidget->private;
1966 if (ipc_comp && ipc_comp->type != SOF_COMP_KEYWORD_DETECT)
1969 /* bind event to keyword detect comp */
1970 return snd_soc_tplg_widget_bind_event(swidget->widget, sof_kwd_events,
1971 ARRAY_SIZE(sof_kwd_events), event_type);
1976 dev_err(scomp->dev, "Invalid event type %d for widget %s\n", event_type,
1977 swidget->widget->name);
1982 static int sof_ipc3_complete_pipeline(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
1984 struct sof_ipc_pipe_ready ready;
1985 struct sof_ipc_reply reply;
1988 dev_dbg(sdev->dev, "tplg: complete pipeline %s id %d\n",
1989 swidget->widget->name, swidget->comp_id);
1991 memset(&ready, 0, sizeof(ready));
1992 ready.hdr.size = sizeof(ready);
1993 ready.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_PIPE_COMPLETE;
1994 ready.comp_id = swidget->comp_id;
1996 ret = sof_ipc_tx_message(sdev->ipc, &ready, sizeof(ready), &reply, sizeof(reply));
2003 static int sof_ipc3_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
2005 struct sof_ipc_free ipc_free = {
2007 .size = sizeof(ipc_free),
2008 .cmd = SOF_IPC_GLB_TPLG_MSG,
2010 .id = swidget->comp_id,
2012 struct sof_ipc_reply reply;
2015 if (!swidget->private)
2018 switch (swidget->id) {
2019 case snd_soc_dapm_scheduler:
2021 ipc_free.hdr.cmd |= SOF_IPC_TPLG_PIPE_FREE;
2024 case snd_soc_dapm_buffer:
2025 ipc_free.hdr.cmd |= SOF_IPC_TPLG_BUFFER_FREE;
2028 ipc_free.hdr.cmd |= SOF_IPC_TPLG_COMP_FREE;
2032 ret = sof_ipc_tx_message(sdev->ipc, &ipc_free, sizeof(ipc_free),
2033 &reply, sizeof(reply));
2035 dev_err(sdev->dev, "failed to free widget %s\n", swidget->widget->name);
2040 static int sof_ipc3_dai_config(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget,
2041 unsigned int flags, struct snd_sof_dai_config_data *data)
2043 struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
2044 struct snd_sof_dai *dai = swidget->private;
2045 struct sof_dai_private_data *private;
2046 struct sof_ipc_dai_config *config;
2047 struct sof_ipc_reply reply;
2050 if (!dai || !dai->private) {
2051 dev_err(sdev->dev, "No private data for DAI %s\n", swidget->widget->name);
2055 private = dai->private;
2056 if (!private->dai_config) {
2057 dev_err(sdev->dev, "No config for DAI %s\n", dai->name);
2061 config = &private->dai_config[dai->current_config];
2063 dev_err(sdev->dev, "Invalid current config for DAI %s\n", dai->name);
2067 switch (config->type) {
2068 case SOF_DAI_INTEL_SSP:
2070 * DAI_CONFIG IPC during hw_params/hw_free for SSP DAI's is not supported in older
2073 if (v->abi_version < SOF_ABI_VER(3, 18, 0) &&
2074 ((flags & SOF_DAI_CONFIG_FLAGS_HW_PARAMS) ||
2075 (flags & SOF_DAI_CONFIG_FLAGS_HW_FREE)))
2078 case SOF_DAI_INTEL_HDA:
2080 config->hda.link_dma_ch = data->dai_data;
2082 case SOF_DAI_INTEL_ALH:
2084 config->dai_index = data->dai_index;
2085 config->alh.stream_id = data->dai_data;
2092 config->flags = flags;
2094 /* only send the IPC if the widget is set up in the DSP */
2095 if (swidget->use_count > 0) {
2096 ret = sof_ipc_tx_message(sdev->ipc, config, config->hdr.size,
2097 &reply, sizeof(reply));
2099 dev_err(sdev->dev, "Failed to set dai config for %s\n", dai->name);
2105 static int sof_ipc3_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
2107 struct sof_ipc_comp_reply reply;
2110 if (!swidget->private)
2113 switch (swidget->id) {
2114 case snd_soc_dapm_dai_in:
2115 case snd_soc_dapm_dai_out:
2117 struct snd_sof_dai *dai = swidget->private;
2118 struct sof_dai_private_data *dai_data = dai->private;
2119 struct sof_ipc_comp *comp = &dai_data->comp_dai->comp;
2121 ret = sof_ipc_tx_message(sdev->ipc, dai_data->comp_dai,
2122 comp->hdr.size, &reply, sizeof(reply));
2125 case snd_soc_dapm_scheduler:
2127 struct sof_ipc_pipe_new *pipeline;
2129 pipeline = swidget->private;
2130 ret = sof_ipc_tx_message(sdev->ipc, pipeline, sizeof(*pipeline),
2131 &reply, sizeof(reply));
2136 struct sof_ipc_cmd_hdr *hdr;
2138 hdr = swidget->private;
2139 ret = sof_ipc_tx_message(sdev->ipc, swidget->private, hdr->size,
2140 &reply, sizeof(reply));
2145 dev_err(sdev->dev, "Failed to setup widget %s\n", swidget->widget->name);
2150 static int sof_ipc3_set_up_all_pipelines(struct snd_sof_dev *sdev, bool verify)
2152 struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
2153 struct snd_sof_widget *swidget;
2154 struct snd_sof_route *sroute;
2157 /* restore pipeline components */
2158 list_for_each_entry(swidget, &sdev->widget_list, list) {
2159 /* only set up the widgets belonging to static pipelines */
2160 if (!verify && swidget->dynamic_pipeline_widget)
2164 * For older firmware, skip scheduler widgets in this loop,
2165 * sof_widget_setup() will be called in the 'complete pipeline' loop
2167 if (v->abi_version < SOF_ABI_VER(3, 19, 0) &&
2168 swidget->id == snd_soc_dapm_scheduler)
2171 /* update DAI config. The IPC will be sent in sof_widget_setup() */
2172 if (WIDGET_IS_DAI(swidget->id)) {
2173 struct snd_sof_dai *dai = swidget->private;
2174 struct sof_dai_private_data *private;
2175 struct sof_ipc_dai_config *config;
2177 if (!dai || !dai->private)
2179 private = dai->private;
2180 if (!private->dai_config)
2183 config = private->dai_config;
2185 * The link DMA channel would be invalidated for running
2186 * streams but not for streams that were in the PAUSED
2187 * state during suspend. So invalidate it here before setting
2188 * the dai config in the DSP.
2190 if (config->type == SOF_DAI_INTEL_HDA)
2191 config->hda.link_dma_ch = DMA_CHAN_INVALID;
2194 ret = sof_widget_setup(sdev, swidget);
2199 /* restore pipeline connections */
2200 list_for_each_entry(sroute, &sdev->route_list, list) {
2201 /* only set up routes belonging to static pipelines */
2202 if (!verify && (sroute->src_widget->dynamic_pipeline_widget ||
2203 sroute->sink_widget->dynamic_pipeline_widget))
2207 * For virtual routes, both sink and source are not buffer. IPC3 only supports
2208 * connections between a buffer and a component. Ignore the rest.
2210 if (sroute->src_widget->id != snd_soc_dapm_buffer &&
2211 sroute->sink_widget->id != snd_soc_dapm_buffer)
2214 ret = sof_route_setup(sdev, sroute->src_widget->widget,
2215 sroute->sink_widget->widget);
2217 dev_err(sdev->dev, "%s: route set up failed\n", __func__);
2222 /* complete pipeline */
2223 list_for_each_entry(swidget, &sdev->widget_list, list) {
2224 switch (swidget->id) {
2225 case snd_soc_dapm_scheduler:
2226 /* only complete static pipelines */
2227 if (!verify && swidget->dynamic_pipeline_widget)
2230 if (v->abi_version < SOF_ABI_VER(3, 19, 0)) {
2231 ret = sof_widget_setup(sdev, swidget);
2236 swidget->spipe->complete = sof_ipc3_complete_pipeline(sdev, swidget);
2237 if (swidget->spipe->complete < 0)
2238 return swidget->spipe->complete;
2249 * Free the PCM, its associated widgets and set the prepared flag to false for all PCMs that
2250 * did not get suspended(ex: paused streams) so the widgets can be set up again during resume.
2252 static int sof_tear_down_left_over_pipelines(struct snd_sof_dev *sdev)
2254 struct snd_sof_widget *swidget;
2255 struct snd_sof_pcm *spcm;
2259 * free all PCMs and their associated DAPM widgets if their connected DAPM widget
2260 * list is not NULL. This should only be true for paused streams at this point.
2261 * This is equivalent to the handling of FE DAI suspend trigger for running streams.
2263 list_for_each_entry(spcm, &sdev->pcm_list, list) {
2264 for_each_pcm_streams(dir) {
2265 struct snd_pcm_substream *substream = spcm->stream[dir].substream;
2267 if (!substream || !substream->runtime || spcm->stream[dir].suspend_ignored)
2270 if (spcm->stream[dir].list) {
2271 ret = sof_pcm_stream_free(sdev, substream, spcm, dir, true);
2279 * free any left over DAI widgets. This is equivalent to the handling of suspend trigger
2280 * for the BE DAI for running streams.
2282 list_for_each_entry(swidget, &sdev->widget_list, list)
2283 if (WIDGET_IS_DAI(swidget->id) && swidget->use_count == 1) {
2284 ret = sof_widget_free(sdev, swidget);
2293 * For older firmware, this function doesn't free widgets for static pipelines during suspend.
2294 * It only resets use_count for all widgets.
2296 static int sof_ipc3_tear_down_all_pipelines(struct snd_sof_dev *sdev, bool verify)
2298 struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
2299 struct snd_sof_widget *swidget;
2300 struct snd_sof_route *sroute;
2301 bool dyn_widgets = false;
2305 * This function is called during suspend and for one-time topology verification during
2306 * first boot. In both cases, there is no need to protect swidget->use_count and
2307 * sroute->setup because during suspend all running streams are suspended and during
2308 * topology loading the sound card unavailable to open PCMs.
2310 list_for_each_entry(swidget, &sdev->widget_list, list) {
2311 if (swidget->dynamic_pipeline_widget) {
2316 /* Do not free widgets for static pipelines with FW older than SOF2.2 */
2317 if (!verify && !swidget->dynamic_pipeline_widget &&
2318 SOF_FW_VER(v->major, v->minor, v->micro) < SOF_FW_VER(2, 2, 0)) {
2319 mutex_lock(&swidget->setup_mutex);
2320 swidget->use_count = 0;
2321 mutex_unlock(&swidget->setup_mutex);
2323 swidget->spipe->complete = 0;
2327 ret = sof_widget_free(sdev, swidget);
2333 * Tear down all pipelines associated with PCMs that did not get suspended
2334 * and unset the prepare flag so that they can be set up again during resume.
2335 * Skip this step for older firmware unless topology has any
2336 * dynamic pipeline (in which case the step is mandatory).
2338 if (!verify && (dyn_widgets || SOF_FW_VER(v->major, v->minor, v->micro) >=
2339 SOF_FW_VER(2, 2, 0))) {
2340 ret = sof_tear_down_left_over_pipelines(sdev);
2342 dev_err(sdev->dev, "failed to tear down paused pipelines\n");
2347 list_for_each_entry(sroute, &sdev->route_list, list)
2348 sroute->setup = false;
2351 * before suspending, make sure the refcounts are all zeroed out. There's no way
2352 * to recover at this point but this will help root cause bad sequences leading to
2353 * more issues on resume
2355 list_for_each_entry(swidget, &sdev->widget_list, list) {
2356 if (swidget->use_count != 0) {
2357 dev_err(sdev->dev, "%s: widget %s is still in use: count %d\n",
2358 __func__, swidget->widget->name, swidget->use_count);
2365 static int sof_ipc3_dai_get_clk(struct snd_sof_dev *sdev, struct snd_sof_dai *dai, int clk_type)
2367 struct sof_dai_private_data *private = dai->private;
2369 if (!private || !private->dai_config)
2372 switch (private->dai_config->type) {
2373 case SOF_DAI_INTEL_SSP:
2375 case SOF_DAI_CLK_INTEL_SSP_MCLK:
2376 return private->dai_config->ssp.mclk_rate;
2377 case SOF_DAI_CLK_INTEL_SSP_BCLK:
2378 return private->dai_config->ssp.bclk_rate;
2382 dev_err(sdev->dev, "fail to get SSP clk %d rate\n", clk_type);
2385 /* not yet implemented for platforms other than the above */
2386 dev_err(sdev->dev, "DAI type %d not supported yet!\n", private->dai_config->type);
2393 static int sof_ipc3_parse_manifest(struct snd_soc_component *scomp, int index,
2394 struct snd_soc_tplg_manifest *man)
2396 u32 size = le32_to_cpu(man->priv.size);
2399 /* backward compatible with tplg without ABI info */
2401 dev_dbg(scomp->dev, "No topology ABI info\n");
2405 if (size != SOF_IPC3_TPLG_ABI_SIZE) {
2406 dev_err(scomp->dev, "%s: Invalid topology ABI size: %u\n",
2411 dev_info(scomp->dev,
2412 "Topology: ABI %d:%d:%d Kernel ABI %d:%d:%d\n",
2413 man->priv.data[0], man->priv.data[1], man->priv.data[2],
2414 SOF_ABI_MAJOR, SOF_ABI_MINOR, SOF_ABI_PATCH);
2416 abi_version = SOF_ABI_VER(man->priv.data[0], man->priv.data[1], man->priv.data[2]);
2418 if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, abi_version)) {
2419 dev_err(scomp->dev, "%s: Incompatible topology ABI version\n", __func__);
2423 if (IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS) &&
2424 SOF_ABI_VERSION_MINOR(abi_version) > SOF_ABI_MINOR) {
2425 dev_err(scomp->dev, "%s: Topology ABI is more recent than kernel\n", __func__);
2432 static int sof_ipc3_link_setup(struct snd_sof_dev *sdev, struct snd_soc_dai_link *link)
2438 * set default trigger order for all links. Exceptions to
2439 * the rule will be handled in sof_pcm_dai_link_fixup()
2440 * For playback, the sequence is the following: start FE,
2441 * start BE, stop BE, stop FE; for Capture the sequence is
2442 * inverted start BE, start FE, stop FE, stop BE
2444 link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = SND_SOC_DPCM_TRIGGER_PRE;
2445 link->trigger[SNDRV_PCM_STREAM_CAPTURE] = SND_SOC_DPCM_TRIGGER_POST;
2450 /* token list for each topology object */
2451 static enum sof_tokens host_token_list[] = {
2453 SOF_COMP_EXT_TOKENS,
2458 static enum sof_tokens comp_generic_token_list[] = {
2460 SOF_COMP_EXT_TOKENS,
2464 static enum sof_tokens buffer_token_list[] = {
2468 static enum sof_tokens pipeline_token_list[] = {
2470 SOF_COMP_EXT_TOKENS,
2471 SOF_PIPELINE_TOKENS,
2475 static enum sof_tokens asrc_token_list[] = {
2477 SOF_COMP_EXT_TOKENS,
2482 static enum sof_tokens src_token_list[] = {
2484 SOF_COMP_EXT_TOKENS,
2489 static enum sof_tokens pga_token_list[] = {
2491 SOF_COMP_EXT_TOKENS,
2496 static enum sof_tokens dai_token_list[] = {
2498 SOF_COMP_EXT_TOKENS,
2503 static enum sof_tokens process_token_list[] = {
2505 SOF_COMP_EXT_TOKENS,
2510 static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TYPE_COUNT] = {
2511 [snd_soc_dapm_aif_in] = {sof_ipc3_widget_setup_comp_host, sof_ipc3_widget_free_comp,
2512 host_token_list, ARRAY_SIZE(host_token_list), NULL},
2513 [snd_soc_dapm_aif_out] = {sof_ipc3_widget_setup_comp_host, sof_ipc3_widget_free_comp,
2514 host_token_list, ARRAY_SIZE(host_token_list), NULL},
2516 [snd_soc_dapm_dai_in] = {sof_ipc3_widget_setup_comp_dai, sof_ipc3_widget_free_comp_dai,
2517 dai_token_list, ARRAY_SIZE(dai_token_list), NULL},
2518 [snd_soc_dapm_dai_out] = {sof_ipc3_widget_setup_comp_dai, sof_ipc3_widget_free_comp_dai,
2519 dai_token_list, ARRAY_SIZE(dai_token_list), NULL},
2520 [snd_soc_dapm_buffer] = {sof_ipc3_widget_setup_comp_buffer, sof_ipc3_widget_free_comp,
2521 buffer_token_list, ARRAY_SIZE(buffer_token_list), NULL},
2522 [snd_soc_dapm_mixer] = {sof_ipc3_widget_setup_comp_mixer, sof_ipc3_widget_free_comp,
2523 comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
2525 [snd_soc_dapm_src] = {sof_ipc3_widget_setup_comp_src, sof_ipc3_widget_free_comp,
2526 src_token_list, ARRAY_SIZE(src_token_list), NULL},
2527 [snd_soc_dapm_asrc] = {sof_ipc3_widget_setup_comp_asrc, sof_ipc3_widget_free_comp,
2528 asrc_token_list, ARRAY_SIZE(asrc_token_list), NULL},
2529 [snd_soc_dapm_siggen] = {sof_ipc3_widget_setup_comp_tone, sof_ipc3_widget_free_comp,
2530 comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
2532 [snd_soc_dapm_scheduler] = {sof_ipc3_widget_setup_comp_pipeline, sof_ipc3_widget_free_comp,
2533 pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL},
2534 [snd_soc_dapm_pga] = {sof_ipc3_widget_setup_comp_pga, sof_ipc3_widget_free_comp,
2535 pga_token_list, ARRAY_SIZE(pga_token_list), NULL},
2536 [snd_soc_dapm_mux] = {sof_ipc3_widget_setup_comp_mux, sof_ipc3_widget_free_comp,
2537 comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list), NULL},
2538 [snd_soc_dapm_demux] = {sof_ipc3_widget_setup_comp_mux, sof_ipc3_widget_free_comp,
2539 comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
2541 [snd_soc_dapm_effect] = {sof_widget_update_ipc_comp_process, sof_ipc3_widget_free_comp,
2542 process_token_list, ARRAY_SIZE(process_token_list),
2543 sof_ipc3_widget_bind_event},
2546 const struct sof_ipc_tplg_ops ipc3_tplg_ops = {
2547 .widget = tplg_ipc3_widget_ops,
2548 .control = &tplg_ipc3_control_ops,
2549 .route_setup = sof_ipc3_route_setup,
2550 .control_setup = sof_ipc3_control_setup,
2551 .control_free = sof_ipc3_control_free,
2552 .pipeline_complete = sof_ipc3_complete_pipeline,
2553 .token_list = ipc3_token_list,
2554 .widget_free = sof_ipc3_widget_free,
2555 .widget_setup = sof_ipc3_widget_setup,
2556 .dai_config = sof_ipc3_dai_config,
2557 .dai_get_clk = sof_ipc3_dai_get_clk,
2558 .set_up_all_pipelines = sof_ipc3_set_up_all_pipelines,
2559 .tear_down_all_pipelines = sof_ipc3_tear_down_all_pipelines,
2560 .parse_manifest = sof_ipc3_parse_manifest,
2561 .link_setup = sof_ipc3_link_setup,