1e149ca29SPierre-Louis Bossart /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2ee1e79b7SRanjani Sridharan /*
3ee1e79b7SRanjani Sridharan * This file is provided under a dual BSD/GPLv2 license. When using or
4ee1e79b7SRanjani Sridharan * redistributing this file, you may do so under either license.
5ee1e79b7SRanjani Sridharan *
6ee1e79b7SRanjani Sridharan * Copyright(c) 2019 Intel Corporation. All rights reserved.
7ee1e79b7SRanjani Sridharan *
8ee1e79b7SRanjani Sridharan * Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
9ee1e79b7SRanjani Sridharan */
10ee1e79b7SRanjani Sridharan
11ee1e79b7SRanjani Sridharan #ifndef __SOUND_SOC_SOF_AUDIO_H
12ee1e79b7SRanjani Sridharan #define __SOUND_SOC_SOF_AUDIO_H
13ee1e79b7SRanjani Sridharan
149ef91cadSGuennadi Liakhovetski #include <linux/workqueue.h>
159ef91cadSGuennadi Liakhovetski
16ee1e79b7SRanjani Sridharan #include <sound/soc.h>
17ee1e79b7SRanjani Sridharan #include <sound/control.h>
18ee1e79b7SRanjani Sridharan #include <sound/sof/stream.h> /* needs to be included before control.h */
19ee1e79b7SRanjani Sridharan #include <sound/sof/control.h>
20ee1e79b7SRanjani Sridharan #include <sound/sof/dai.h>
21ee1e79b7SRanjani Sridharan #include <sound/sof/topology.h>
22ee1e79b7SRanjani Sridharan #include "sof-priv.h"
23ee1e79b7SRanjani Sridharan
24ee1e79b7SRanjani Sridharan #define SOF_AUDIO_PCM_DRV_NAME "sof-audio-component"
25ee1e79b7SRanjani Sridharan
266327c729SChao Song /*
276327c729SChao Song * The ipc4 firmware only supports up to 8 sink or source pins
286327c729SChao Song * per widget, because only 3 bits are used for queue(pin) ID
296327c729SChao Song * in ipc4 protocol.
306327c729SChao Song */
316327c729SChao Song #define SOF_WIDGET_MAX_NUM_PINS 8
326327c729SChao Song
33bb79f2a6SRanjani Sridharan /* Widget pin type */
34bb79f2a6SRanjani Sridharan #define SOF_PIN_TYPE_INPUT 0
35bb79f2a6SRanjani Sridharan #define SOF_PIN_TYPE_OUTPUT 1
363b3acedbSChao Song
37ee1e79b7SRanjani Sridharan /* max number of FE PCMs before BEs */
38ee1e79b7SRanjani Sridharan #define SOF_BE_PCM_BASE 16
39ee1e79b7SRanjani Sridharan
40ee1e79b7SRanjani Sridharan #define DMA_CHAN_INVALID 0xFFFFFFFF
41ee1e79b7SRanjani Sridharan
425fcdbb2dSRanjani Sridharan #define WIDGET_IS_DAI(id) ((id) == snd_soc_dapm_dai_in || (id) == snd_soc_dapm_dai_out)
435da0590aSRanjani Sridharan #define WIDGET_IS_AIF(id) ((id) == snd_soc_dapm_aif_in || (id) == snd_soc_dapm_aif_out)
445da0590aSRanjani Sridharan #define WIDGET_IS_AIF_OR_DAI(id) (WIDGET_IS_DAI(id) || WIDGET_IS_AIF(id))
4511f60563SBard Liao #define WIDGET_IS_COPIER(id) (WIDGET_IS_AIF_OR_DAI(id) || (id) == snd_soc_dapm_buffer)
465fcdbb2dSRanjani Sridharan
4785f7a8b6SRanjani Sridharan #define SOF_DAI_CLK_INTEL_SSP_MCLK 0
4885f7a8b6SRanjani Sridharan #define SOF_DAI_CLK_INTEL_SSP_BCLK 1
4985f7a8b6SRanjani Sridharan
505da0590aSRanjani Sridharan enum sof_widget_op {
5166344c6dSRanjani Sridharan SOF_WIDGET_PREPARE,
525da0590aSRanjani Sridharan SOF_WIDGET_SETUP,
5366344c6dSRanjani Sridharan SOF_WIDGET_FREE,
5466344c6dSRanjani Sridharan SOF_WIDGET_UNPREPARE,
555da0590aSRanjani Sridharan };
565da0590aSRanjani Sridharan
57b5cee8feSRanjani Sridharan /*
58b5cee8feSRanjani Sridharan * Volume fractional word length define to 16 sets
59b5cee8feSRanjani Sridharan * the volume linear gain value to use Qx.16 format
60b5cee8feSRanjani Sridharan */
61b5cee8feSRanjani Sridharan #define VOLUME_FWL 16
62b5cee8feSRanjani Sridharan
6348d2a1ceSRanjani Sridharan #define SOF_TLV_ITEMS 3
6448d2a1ceSRanjani Sridharan
mixer_to_ipc(unsigned int value,u32 * volume_map,int size)657b3a5be5SRanjani Sridharan static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
667b3a5be5SRanjani Sridharan {
677b3a5be5SRanjani Sridharan if (value >= size)
687b3a5be5SRanjani Sridharan return volume_map[size - 1];
697b3a5be5SRanjani Sridharan
707b3a5be5SRanjani Sridharan return volume_map[value];
717b3a5be5SRanjani Sridharan }
727b3a5be5SRanjani Sridharan
ipc_to_mixer(u32 value,u32 * volume_map,int size)737b3a5be5SRanjani Sridharan static inline u32 ipc_to_mixer(u32 value, u32 *volume_map, int size)
747b3a5be5SRanjani Sridharan {
757b3a5be5SRanjani Sridharan int i;
767b3a5be5SRanjani Sridharan
777b3a5be5SRanjani Sridharan for (i = 0; i < size; i++) {
787b3a5be5SRanjani Sridharan if (volume_map[i] >= value)
797b3a5be5SRanjani Sridharan return i;
807b3a5be5SRanjani Sridharan }
817b3a5be5SRanjani Sridharan
827b3a5be5SRanjani Sridharan return i - 1;
837b3a5be5SRanjani Sridharan }
847b3a5be5SRanjani Sridharan
85226abb75SRanjani Sridharan struct snd_sof_widget;
86226abb75SRanjani Sridharan struct snd_sof_route;
87b5cee8feSRanjani Sridharan struct snd_sof_control;
8885f7a8b6SRanjani Sridharan struct snd_sof_dai;
897201a3d4SRanjani Sridharan struct snd_sof_pcm;
90226abb75SRanjani Sridharan
91051744b1SRanjani Sridharan struct snd_sof_dai_config_data {
92051744b1SRanjani Sridharan int dai_index;
93051744b1SRanjani Sridharan int dai_data; /* contains DAI-specific information */
94051744b1SRanjani Sridharan };
95051744b1SRanjani Sridharan
96226abb75SRanjani Sridharan /**
97967885eeSRanjani Sridharan * struct sof_ipc_pcm_ops - IPC-specific PCM ops
98967885eeSRanjani Sridharan * @hw_params: Function pointer for hw_params
99967885eeSRanjani Sridharan * @hw_free: Function pointer for hw_free
100967885eeSRanjani Sridharan * @trigger: Function pointer for trigger
101967885eeSRanjani Sridharan * @dai_link_fixup: Function pointer for DAI link fixup
1027201a3d4SRanjani Sridharan * @pcm_setup: Function pointer for IPC-specific PCM set up that can be used for allocating
1037201a3d4SRanjani Sridharan * additional memory in the SOF PCM stream structure
1047201a3d4SRanjani Sridharan * @pcm_free: Function pointer for PCM free that can be used for freeing any
1057201a3d4SRanjani Sridharan * additional memory in the SOF PCM stream structure
10627c2100bSRander Wang * @delay: Function pointer for pcm delay calculation
1077d6f623cSRanjani Sridharan * @reset_hw_params_during_stop: Flag indicating whether the hw_params should be reset during the
1087d6f623cSRanjani Sridharan * STOP pcm trigger
10951ce3e6eSRanjani Sridharan * @ipc_first_on_start: Send IPC before invoking platform trigger during
11051ce3e6eSRanjani Sridharan * START/PAUSE_RELEASE triggers
1116d0a21ddSRanjani Sridharan * @platform_stop_during_hw_free: Invoke the platform trigger during hw_free. This is needed for
1126d0a21ddSRanjani Sridharan * IPC4 where a pipeline is only paused during stop/pause/suspend
1136d0a21ddSRanjani Sridharan * triggers. The FW keeps the host DMA running in this case and
1146d0a21ddSRanjani Sridharan * therefore the host must do the same and should stop the DMA during
1156d0a21ddSRanjani Sridharan * hw_free.
116*58872c44SRanjani Sridharan * @d0i3_supported_in_s0ix: Allow DSP D0I3 during S0iX
117967885eeSRanjani Sridharan */
118967885eeSRanjani Sridharan struct sof_ipc_pcm_ops {
119967885eeSRanjani Sridharan int (*hw_params)(struct snd_soc_component *component, struct snd_pcm_substream *substream,
120967885eeSRanjani Sridharan struct snd_pcm_hw_params *params,
121967885eeSRanjani Sridharan struct snd_sof_platform_stream_params *platform_params);
122967885eeSRanjani Sridharan int (*hw_free)(struct snd_soc_component *component, struct snd_pcm_substream *substream);
123967885eeSRanjani Sridharan int (*trigger)(struct snd_soc_component *component, struct snd_pcm_substream *substream,
124967885eeSRanjani Sridharan int cmd);
125967885eeSRanjani Sridharan int (*dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
1267201a3d4SRanjani Sridharan int (*pcm_setup)(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm);
1277201a3d4SRanjani Sridharan void (*pcm_free)(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm);
12827c2100bSRander Wang snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
12927c2100bSRander Wang struct snd_pcm_substream *substream);
1307d6f623cSRanjani Sridharan bool reset_hw_params_during_stop;
13151ce3e6eSRanjani Sridharan bool ipc_first_on_start;
1326d0a21ddSRanjani Sridharan bool platform_stop_during_hw_free;
133*58872c44SRanjani Sridharan bool d0i3_supported_in_s0ix;
134967885eeSRanjani Sridharan };
135967885eeSRanjani Sridharan
136967885eeSRanjani Sridharan /**
13710f461d7SRanjani Sridharan * struct sof_ipc_tplg_control_ops - IPC-specific ops for topology kcontrol IO
138a0149a6bSRanjani Sridharan */
13910f461d7SRanjani Sridharan struct sof_ipc_tplg_control_ops {
140a0149a6bSRanjani Sridharan bool (*volume_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
141a0149a6bSRanjani Sridharan int (*volume_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
142a0149a6bSRanjani Sridharan bool (*switch_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
143a0149a6bSRanjani Sridharan int (*switch_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
144a0149a6bSRanjani Sridharan bool (*enum_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
145a0149a6bSRanjani Sridharan int (*enum_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
146a0149a6bSRanjani Sridharan int (*bytes_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
147a0149a6bSRanjani Sridharan int (*bytes_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
148a0149a6bSRanjani Sridharan int (*bytes_ext_get)(struct snd_sof_control *scontrol,
149a0149a6bSRanjani Sridharan const unsigned int __user *binary_data, unsigned int size);
150a0149a6bSRanjani Sridharan int (*bytes_ext_volatile_get)(struct snd_sof_control *scontrol,
151a0149a6bSRanjani Sridharan const unsigned int __user *binary_data, unsigned int size);
152a0149a6bSRanjani Sridharan int (*bytes_ext_put)(struct snd_sof_control *scontrol,
153a0149a6bSRanjani Sridharan const unsigned int __user *binary_data, unsigned int size);
154a0149a6bSRanjani Sridharan /* update control data based on notification from the DSP */
155a0149a6bSRanjani Sridharan void (*update)(struct snd_sof_dev *sdev, void *ipc_control_message);
156e394ffb8SPeter Ujfalusi /* Optional callback to setup kcontrols associated with an swidget */
157e394ffb8SPeter Ujfalusi int (*widget_kcontrol_setup)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
15848d2a1ceSRanjani Sridharan /* mandatory callback to set up volume table for volume kcontrols */
15948d2a1ceSRanjani Sridharan int (*set_up_volume_table)(struct snd_sof_control *scontrol, int tlv[SOF_TLV_ITEMS],
16048d2a1ceSRanjani Sridharan int size);
161a0149a6bSRanjani Sridharan };
162a0149a6bSRanjani Sridharan
163a0149a6bSRanjani Sridharan /**
164226abb75SRanjani Sridharan * struct sof_ipc_tplg_widget_ops - IPC-specific ops for topology widgets
165226abb75SRanjani Sridharan * @ipc_setup: Function pointer for setting up widget IPC params
166226abb75SRanjani Sridharan * @ipc_free: Function pointer for freeing widget IPC params
167226abb75SRanjani Sridharan * @token_list: List of token ID's that should be parsed for the widget
168226abb75SRanjani Sridharan * @token_list_size: number of elements in token_list
169226abb75SRanjani Sridharan * @bind_event: Function pointer for binding events to the widget
17066344c6dSRanjani Sridharan * @ipc_prepare: Optional op for preparing a widget for set up
17166344c6dSRanjani Sridharan * @ipc_unprepare: Optional op for unpreparing a widget
172226abb75SRanjani Sridharan */
173226abb75SRanjani Sridharan struct sof_ipc_tplg_widget_ops {
174226abb75SRanjani Sridharan int (*ipc_setup)(struct snd_sof_widget *swidget);
175226abb75SRanjani Sridharan void (*ipc_free)(struct snd_sof_widget *swidget);
176226abb75SRanjani Sridharan enum sof_tokens *token_list;
177226abb75SRanjani Sridharan int token_list_size;
178226abb75SRanjani Sridharan int (*bind_event)(struct snd_soc_component *scomp, struct snd_sof_widget *swidget,
179226abb75SRanjani Sridharan u16 event_type);
18066344c6dSRanjani Sridharan int (*ipc_prepare)(struct snd_sof_widget *swidget,
18166344c6dSRanjani Sridharan struct snd_pcm_hw_params *fe_params,
18266344c6dSRanjani Sridharan struct snd_sof_platform_stream_params *platform_params,
18366344c6dSRanjani Sridharan struct snd_pcm_hw_params *source_params, int dir);
18466344c6dSRanjani Sridharan void (*ipc_unprepare)(struct snd_sof_widget *swidget);
185226abb75SRanjani Sridharan };
186226abb75SRanjani Sridharan
187226abb75SRanjani Sridharan /**
188226abb75SRanjani Sridharan * struct sof_ipc_tplg_ops - IPC-specific topology ops
189226abb75SRanjani Sridharan * @widget: Array of pointers to IPC-specific ops for widgets. This should always be of size
190226abb75SRanjani Sridharan * SND_SOF_DAPM_TYPE_COUNT i.e one per widget type. Unsupported widget types will be
191226abb75SRanjani Sridharan * initialized to 0.
192a0149a6bSRanjani Sridharan * @control: Pointer to the IPC-specific ops for topology kcontrol IO
193226abb75SRanjani Sridharan * @route_setup: Function pointer for setting up pipeline connections
1947cbb1559SPeter Ujfalusi * @route_free: Function pointer for freeing pipeline connections.
195226abb75SRanjani Sridharan * @token_list: List of all tokens supported by the IPC version. The size of the token_list
196226abb75SRanjani Sridharan * array should be SOF_TOKEN_COUNT. The unused elements in the array will be
197226abb75SRanjani Sridharan * initialized to 0.
198b5cee8feSRanjani Sridharan * @control_setup: Function pointer for setting up kcontrol IPC-specific data
199b5cee8feSRanjani Sridharan * @control_free: Function pointer for freeing kcontrol IPC-specific data
20061ad28ffSRanjani Sridharan * @pipeline_complete: Function pointer for pipeline complete IPC
201051744b1SRanjani Sridharan * @widget_setup: Function pointer for setting up setup in the DSP
202051744b1SRanjani Sridharan * @widget_free: Function pointer for freeing widget in the DSP
203051744b1SRanjani Sridharan * @dai_config: Function pointer for sending DAI config IPC to the DSP
20485f7a8b6SRanjani Sridharan * @dai_get_clk: Function pointer for getting the DAI clock setting
20531cd6e46SRanjani Sridharan * @set_up_all_pipelines: Function pointer for setting up all topology pipelines
20631cd6e46SRanjani Sridharan * @tear_down_all_pipelines: Function pointer for tearing down all topology pipelines
2077cbb1559SPeter Ujfalusi * @parse_manifest: Function pointer for ipc4 specific parsing of topology manifest
208e380c907SRanjani Sridharan * @link_setup: Function pointer for IPC-specific DAI link set up
2097cbb1559SPeter Ujfalusi *
2107cbb1559SPeter Ujfalusi * Note: function pointers (ops) are optional
211226abb75SRanjani Sridharan */
212226abb75SRanjani Sridharan struct sof_ipc_tplg_ops {
213226abb75SRanjani Sridharan const struct sof_ipc_tplg_widget_ops *widget;
21410f461d7SRanjani Sridharan const struct sof_ipc_tplg_control_ops *control;
215226abb75SRanjani Sridharan int (*route_setup)(struct snd_sof_dev *sdev, struct snd_sof_route *sroute);
216d77d7795SRanjani Sridharan int (*route_free)(struct snd_sof_dev *sdev, struct snd_sof_route *sroute);
217226abb75SRanjani Sridharan const struct sof_token_info *token_list;
218b5cee8feSRanjani Sridharan int (*control_setup)(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol);
219b5cee8feSRanjani Sridharan int (*control_free)(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol);
22061ad28ffSRanjani Sridharan int (*pipeline_complete)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
221051744b1SRanjani Sridharan int (*widget_setup)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
222051744b1SRanjani Sridharan int (*widget_free)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
223051744b1SRanjani Sridharan int (*dai_config)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget,
224051744b1SRanjani Sridharan unsigned int flags, struct snd_sof_dai_config_data *data);
22585f7a8b6SRanjani Sridharan int (*dai_get_clk)(struct snd_sof_dev *sdev, struct snd_sof_dai *dai, int clk_type);
22631cd6e46SRanjani Sridharan int (*set_up_all_pipelines)(struct snd_sof_dev *sdev, bool verify);
22731cd6e46SRanjani Sridharan int (*tear_down_all_pipelines)(struct snd_sof_dev *sdev, bool verify);
228323aa1f0SRanjani Sridharan int (*parse_manifest)(struct snd_soc_component *scomp, int index,
229323aa1f0SRanjani Sridharan struct snd_soc_tplg_manifest *man);
230e380c907SRanjani Sridharan int (*link_setup)(struct snd_sof_dev *sdev, struct snd_soc_dai_link *link);
231226abb75SRanjani Sridharan };
232226abb75SRanjani Sridharan
233c7b655adSRanjani Sridharan /** struct snd_sof_tuple - Tuple info
234c7b655adSRanjani Sridharan * @token: Token ID
235c7b655adSRanjani Sridharan * @value: union of a string or a u32 values
236c7b655adSRanjani Sridharan */
237c7b655adSRanjani Sridharan struct snd_sof_tuple {
238c7b655adSRanjani Sridharan u32 token;
239c7b655adSRanjani Sridharan union {
240c7b655adSRanjani Sridharan u32 v;
241c7b655adSRanjani Sridharan const char *s;
242c7b655adSRanjani Sridharan } value;
243c7b655adSRanjani Sridharan };
244c7b655adSRanjani Sridharan
245d87524bfSRanjani Sridharan /*
246d87524bfSRanjani Sridharan * List of SOF token ID's. The order of ID's does not matter as token arrays are looked up based on
247d87524bfSRanjani Sridharan * the ID.
248d87524bfSRanjani Sridharan */
249d87524bfSRanjani Sridharan enum sof_tokens {
250d87524bfSRanjani Sridharan SOF_PCM_TOKENS,
251d87524bfSRanjani Sridharan SOF_PIPELINE_TOKENS,
252d87524bfSRanjani Sridharan SOF_SCHED_TOKENS,
253d87524bfSRanjani Sridharan SOF_ASRC_TOKENS,
254d87524bfSRanjani Sridharan SOF_SRC_TOKENS,
255d87524bfSRanjani Sridharan SOF_COMP_TOKENS,
256d87524bfSRanjani Sridharan SOF_BUFFER_TOKENS,
257d87524bfSRanjani Sridharan SOF_VOLUME_TOKENS,
258d87524bfSRanjani Sridharan SOF_PROCESS_TOKENS,
259d87524bfSRanjani Sridharan SOF_DAI_TOKENS,
260d87524bfSRanjani Sridharan SOF_DAI_LINK_TOKENS,
261d87524bfSRanjani Sridharan SOF_HDA_TOKENS,
262d87524bfSRanjani Sridharan SOF_SSP_TOKENS,
263d87524bfSRanjani Sridharan SOF_ALH_TOKENS,
264d87524bfSRanjani Sridharan SOF_DMIC_TOKENS,
265d87524bfSRanjani Sridharan SOF_DMIC_PDM_TOKENS,
266d87524bfSRanjani Sridharan SOF_ESAI_TOKENS,
267d87524bfSRanjani Sridharan SOF_SAI_TOKENS,
268d87524bfSRanjani Sridharan SOF_AFE_TOKENS,
269d87524bfSRanjani Sridharan SOF_CORE_TOKENS,
270d87524bfSRanjani Sridharan SOF_COMP_EXT_TOKENS,
2712cabd02bSRanjani Sridharan SOF_IN_AUDIO_FORMAT_TOKENS,
2722cabd02bSRanjani Sridharan SOF_OUT_AUDIO_FORMAT_TOKENS,
273594c1bb9SRanjani Sridharan SOF_COPIER_DEEP_BUFFER_TOKENS,
2742cabd02bSRanjani Sridharan SOF_COPIER_TOKENS,
2752cabd02bSRanjani Sridharan SOF_AUDIO_FMT_NUM_TOKENS,
2762cabd02bSRanjani Sridharan SOF_COPIER_FORMAT_TOKENS,
2774f838ab2SRanjani Sridharan SOF_GAIN_TOKENS,
278689614ceSAjit Kumar Pandey SOF_ACPDMIC_TOKENS,
27975af4199SV sujith kumar Reddy SOF_ACPI2S_TOKENS,
280d87524bfSRanjani Sridharan
281d87524bfSRanjani Sridharan /* this should be the last */
282d87524bfSRanjani Sridharan SOF_TOKEN_COUNT,
283d87524bfSRanjani Sridharan };
284d87524bfSRanjani Sridharan
285d87524bfSRanjani Sridharan /**
286d87524bfSRanjani Sridharan * struct sof_topology_token - SOF topology token definition
287d87524bfSRanjani Sridharan * @token: Token number
288d87524bfSRanjani Sridharan * @type: Token type
289d87524bfSRanjani Sridharan * @get_token: Function pointer to parse the token value and save it in a object
290d87524bfSRanjani Sridharan * @offset: Offset within an object to save the token value into
291d87524bfSRanjani Sridharan */
292d87524bfSRanjani Sridharan struct sof_topology_token {
293d87524bfSRanjani Sridharan u32 token;
294d87524bfSRanjani Sridharan u32 type;
295d87524bfSRanjani Sridharan int (*get_token)(void *elem, void *object, u32 offset);
296d87524bfSRanjani Sridharan u32 offset;
297d87524bfSRanjani Sridharan };
298d87524bfSRanjani Sridharan
299d87524bfSRanjani Sridharan struct sof_token_info {
300d87524bfSRanjani Sridharan const char *name;
301d87524bfSRanjani Sridharan const struct sof_topology_token *tokens;
302d87524bfSRanjani Sridharan int count;
303d87524bfSRanjani Sridharan };
304d87524bfSRanjani Sridharan
305ba223b3aSRanjani Sridharan /**
306ba223b3aSRanjani Sridharan * struct snd_sof_pcm_stream_pipeline_list - List of pipelines associated with a PCM stream
307ba223b3aSRanjani Sridharan * @count: number of pipeline widgets in the @pipe_widgets array
3089c04363dSRanjani Sridharan * @pipelines: array of pipelines
309ba223b3aSRanjani Sridharan */
310ba223b3aSRanjani Sridharan struct snd_sof_pcm_stream_pipeline_list {
311ba223b3aSRanjani Sridharan u32 count;
3129c04363dSRanjani Sridharan struct snd_sof_pipeline **pipelines;
313ba223b3aSRanjani Sridharan };
314ba223b3aSRanjani Sridharan
315ee1e79b7SRanjani Sridharan /* PCM stream, mapped to FW component */
316ee1e79b7SRanjani Sridharan struct snd_sof_pcm_stream {
317ee1e79b7SRanjani Sridharan u32 comp_id;
318ee1e79b7SRanjani Sridharan struct snd_dma_buffer page_table;
319ee1e79b7SRanjani Sridharan struct sof_ipc_stream_posn posn;
320ee1e79b7SRanjani Sridharan struct snd_pcm_substream *substream;
321858f7a5cSDaniel Baluta struct snd_compr_stream *cstream;
322ee1e79b7SRanjani Sridharan struct work_struct period_elapsed_work;
3235fcdbb2dSRanjani Sridharan struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */
324ee1e79b7SRanjani Sridharan bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
325ee1e79b7SRanjani Sridharan /*
326ee1e79b7SRanjani Sridharan * flag to indicate that the DSP pipelines should be kept
327ee1e79b7SRanjani Sridharan * active or not while suspending the stream
328ee1e79b7SRanjani Sridharan */
329ee1e79b7SRanjani Sridharan bool suspend_ignored;
330ba223b3aSRanjani Sridharan struct snd_sof_pcm_stream_pipeline_list pipeline_list;
33165a8ef49SRander Wang
33265a8ef49SRander Wang /* used by IPC implementation and core does not touch it */
33365a8ef49SRander Wang void *private;
334ee1e79b7SRanjani Sridharan };
335ee1e79b7SRanjani Sridharan
336ee1e79b7SRanjani Sridharan /* ALSA SOF PCM device */
337ee1e79b7SRanjani Sridharan struct snd_sof_pcm {
338ee1e79b7SRanjani Sridharan struct snd_soc_component *scomp;
339ee1e79b7SRanjani Sridharan struct snd_soc_tplg_pcm pcm;
340ee1e79b7SRanjani Sridharan struct snd_sof_pcm_stream stream[2];
341ee1e79b7SRanjani Sridharan struct list_head list; /* list in sdev pcm list */
342ee1e79b7SRanjani Sridharan struct snd_pcm_hw_params params[2];
343ee1e79b7SRanjani Sridharan bool prepared[2]; /* PCM_PARAMS set successfully */
344ee1e79b7SRanjani Sridharan };
345ee1e79b7SRanjani Sridharan
346ee1e79b7SRanjani Sridharan struct snd_sof_led_control {
347ee1e79b7SRanjani Sridharan unsigned int use_led;
348ee1e79b7SRanjani Sridharan unsigned int direction;
34949c22696SKai-Heng Feng int led_value;
350ee1e79b7SRanjani Sridharan };
351ee1e79b7SRanjani Sridharan
352ee1e79b7SRanjani Sridharan /* ALSA SOF Kcontrol device */
353ee1e79b7SRanjani Sridharan struct snd_sof_control {
354ee1e79b7SRanjani Sridharan struct snd_soc_component *scomp;
355b5cee8feSRanjani Sridharan const char *name;
356ee1e79b7SRanjani Sridharan int comp_id;
357ee1e79b7SRanjani Sridharan int min_volume_step; /* min volume step for volume_table */
358ee1e79b7SRanjani Sridharan int max_volume_step; /* max volume step for volume_table */
359ee1e79b7SRanjani Sridharan int num_channels;
360199a3754SRanjani Sridharan unsigned int access;
361b5cee8feSRanjani Sridharan int info_type;
362b5cee8feSRanjani Sridharan int index; /* pipeline ID */
363b5cee8feSRanjani Sridharan void *priv; /* private data copied from topology */
364b5cee8feSRanjani Sridharan size_t priv_size; /* size of private data */
365b5cee8feSRanjani Sridharan size_t max_size;
366b5cee8feSRanjani Sridharan void *ipc_control_data;
367299f6c75SPaul Olaru void *old_ipc_control_data;
368b5cee8feSRanjani Sridharan int max; /* applicable to volume controls */
369ee1e79b7SRanjani Sridharan u32 size; /* cdata size */
370ee1e79b7SRanjani Sridharan u32 *volume_table; /* volume table computed from tlv data*/
371ee1e79b7SRanjani Sridharan
372ee1e79b7SRanjani Sridharan struct list_head list; /* list in sdev control list */
373ee1e79b7SRanjani Sridharan
374ee1e79b7SRanjani Sridharan struct snd_sof_led_control led_ctl;
375756bbe42SPeter Ujfalusi
376756bbe42SPeter Ujfalusi /* if true, the control's data needs to be updated from Firmware */
377756bbe42SPeter Ujfalusi bool comp_data_dirty;
378ee1e79b7SRanjani Sridharan };
379ee1e79b7SRanjani Sridharan
3800af0f463SRanjani Sridharan /** struct snd_sof_dai_link - DAI link info
3810af0f463SRanjani Sridharan * @tuples: array of parsed tuples
3820af0f463SRanjani Sridharan * @num_tuples: number of tuples in the tuples array
3830af0f463SRanjani Sridharan * @link: Pointer to snd_soc_dai_link
3840af0f463SRanjani Sridharan * @hw_configs: Pointer to hw configs in topology
3850af0f463SRanjani Sridharan * @num_hw_configs: Number of hw configs in topology
3860af0f463SRanjani Sridharan * @default_hw_cfg_id: Default hw config ID
3870af0f463SRanjani Sridharan * @type: DAI type
3880af0f463SRanjani Sridharan * @list: item in snd_sof_dev dai_link list
3890af0f463SRanjani Sridharan */
3900af0f463SRanjani Sridharan struct snd_sof_dai_link {
3910af0f463SRanjani Sridharan struct snd_sof_tuple *tuples;
3920af0f463SRanjani Sridharan int num_tuples;
3930af0f463SRanjani Sridharan struct snd_soc_dai_link *link;
3940af0f463SRanjani Sridharan struct snd_soc_tplg_hw_config *hw_configs;
3950af0f463SRanjani Sridharan int num_hw_configs;
3960af0f463SRanjani Sridharan int default_hw_cfg_id;
3970af0f463SRanjani Sridharan int type;
3980af0f463SRanjani Sridharan struct list_head list;
3990af0f463SRanjani Sridharan };
4002c28ecadSRanjani Sridharan
401ee1e79b7SRanjani Sridharan /* ASoC SOF DAPM widget */
402ee1e79b7SRanjani Sridharan struct snd_sof_widget {
403ee1e79b7SRanjani Sridharan struct snd_soc_component *scomp;
404ee1e79b7SRanjani Sridharan int comp_id;
405ee1e79b7SRanjani Sridharan int pipeline_id;
406463a809bSRanjani Sridharan /*
40766344c6dSRanjani Sridharan * the prepared flag is used to indicate that a widget has been prepared for getting set
40866344c6dSRanjani Sridharan * up in the DSP.
40966344c6dSRanjani Sridharan */
41066344c6dSRanjani Sridharan bool prepared;
411f94f3915SPeter Ujfalusi
412f94f3915SPeter Ujfalusi struct mutex setup_mutex; /* to protect the swidget setup and free operations */
413f94f3915SPeter Ujfalusi
414f94f3915SPeter Ujfalusi /*
415f94f3915SPeter Ujfalusi * use_count is protected by the PCM mutex held by the core and the
416f94f3915SPeter Ujfalusi * setup_mutex against non stream domain races (kcontrol access for
417f94f3915SPeter Ujfalusi * example)
418f94f3915SPeter Ujfalusi */
419f94f3915SPeter Ujfalusi int use_count;
420f94f3915SPeter Ujfalusi
421d1c6c4a9SGuennadi Liakhovetski int core;
42236cbc9dfSRanjani Sridharan int id; /* id is the DAPM widget type */
42336cbc9dfSRanjani Sridharan /*
42436cbc9dfSRanjani Sridharan * Instance ID is set dynamically when the widget gets set up in the FW. It should be
42536cbc9dfSRanjani Sridharan * unique for each module type across all pipelines. This will not be used in SOF_IPC.
42636cbc9dfSRanjani Sridharan */
42736cbc9dfSRanjani Sridharan int instance_id;
428ee1e79b7SRanjani Sridharan
4292c28ecadSRanjani Sridharan /*
4302c28ecadSRanjani Sridharan * Flag indicating if the widget should be set up dynamically when a PCM is opened.
4312c28ecadSRanjani Sridharan * This flag is only set for the scheduler type widget in topology. During topology
4322c28ecadSRanjani Sridharan * loading, this flag is propagated to all the widgets belonging to the same pipeline.
4332c28ecadSRanjani Sridharan * When this flag is not set, a widget is set up at the time of topology loading
4342c28ecadSRanjani Sridharan * and retained until the DSP enters D3. It will need to be set up again when resuming
4352c28ecadSRanjani Sridharan * from D3.
4362c28ecadSRanjani Sridharan */
4372c28ecadSRanjani Sridharan bool dynamic_pipeline_widget;
4382c28ecadSRanjani Sridharan
439ee1e79b7SRanjani Sridharan struct snd_soc_dapm_widget *widget;
440ee1e79b7SRanjani Sridharan struct list_head list; /* list in sdev widget list */
4419c04363dSRanjani Sridharan struct snd_sof_pipeline *spipe;
44236cbc9dfSRanjani Sridharan void *module_info;
443ee1e79b7SRanjani Sridharan
4447a976552SRanjani Sridharan const guid_t uuid;
445f970a77fSKeyon Jie
446c7b655adSRanjani Sridharan int num_tuples;
447c7b655adSRanjani Sridharan struct snd_sof_tuple *tuples;
448c7b655adSRanjani Sridharan
4496327c729SChao Song /*
450bb79f2a6SRanjani Sridharan * The allowed range for num_input/output_pins is [0, SOF_WIDGET_MAX_NUM_PINS].
451bb79f2a6SRanjani Sridharan * Widgets may have zero input or output pins, for example the tone widget has
452bb79f2a6SRanjani Sridharan * zero input pins.
4536327c729SChao Song */
454bb79f2a6SRanjani Sridharan u32 num_input_pins;
455bb79f2a6SRanjani Sridharan u32 num_output_pins;
4566327c729SChao Song
4573b3acedbSChao Song /*
458bb79f2a6SRanjani Sridharan * The input/output pin binding array, it takes the form of
4593b3acedbSChao Song * [widget_name_connected_to_pin0, widget_name_connected_to_pin1, ...],
4603b3acedbSChao Song * with the index as the queue ID.
4613b3acedbSChao Song *
4623b3acedbSChao Song * The array is used for special pin binding. Note that even if there
463bb79f2a6SRanjani Sridharan * is only one input/output pin requires special pin binding, pin binding
464bb79f2a6SRanjani Sridharan * should be defined for all input/output pins in topology, for pin(s) that
4653b3acedbSChao Song * are not used, give the value "NotConnected".
4663b3acedbSChao Song *
4673b3acedbSChao Song * If pin binding is not defined in topology, nothing to parse in the kernel,
468bb79f2a6SRanjani Sridharan * input_pin_binding and output_pin_binding shall be NULL.
4693b3acedbSChao Song */
470bb79f2a6SRanjani Sridharan char **input_pin_binding;
471bb79f2a6SRanjani Sridharan char **output_pin_binding;
4723b3acedbSChao Song
473bb79f2a6SRanjani Sridharan struct ida output_queue_ida;
474bb79f2a6SRanjani Sridharan struct ida input_queue_ida;
475c84443dbSChao Song
476ee1e79b7SRanjani Sridharan void *private; /* core does not touch this */
477ee1e79b7SRanjani Sridharan };
478ee1e79b7SRanjani Sridharan
4799c04363dSRanjani Sridharan /** struct snd_sof_pipeline - ASoC SOF pipeline
4809c04363dSRanjani Sridharan * @pipe_widget: Pointer to the pipeline widget
4819c04363dSRanjani Sridharan * @started_count: Count of number of PCM's that have started this pipeline
4829c04363dSRanjani Sridharan * @paused_count: Count of number of PCM's that have started and have currently paused this
4839c04363dSRanjani Sridharan pipeline
4849c04363dSRanjani Sridharan * @complete: flag used to indicate that pipeline set up is complete.
485e8879e7aSRanjani Sridharan * @core_mask: Mask containing target cores for all modules in the pipeline
4869c04363dSRanjani Sridharan * @list: List item in sdev pipeline_list
4879c04363dSRanjani Sridharan */
4889c04363dSRanjani Sridharan struct snd_sof_pipeline {
4899c04363dSRanjani Sridharan struct snd_sof_widget *pipe_widget;
4909c04363dSRanjani Sridharan int started_count;
4919c04363dSRanjani Sridharan int paused_count;
4929c04363dSRanjani Sridharan int complete;
493e8879e7aSRanjani Sridharan unsigned long core_mask;
4949c04363dSRanjani Sridharan struct list_head list;
4959c04363dSRanjani Sridharan };
4969c04363dSRanjani Sridharan
497ee1e79b7SRanjani Sridharan /* ASoC SOF DAPM route */
498ee1e79b7SRanjani Sridharan struct snd_sof_route {
499ee1e79b7SRanjani Sridharan struct snd_soc_component *scomp;
500ee1e79b7SRanjani Sridharan
501ee1e79b7SRanjani Sridharan struct snd_soc_dapm_route *route;
502ee1e79b7SRanjani Sridharan struct list_head list; /* list in sdev route list */
5030a2dea1fSRanjani Sridharan struct snd_sof_widget *src_widget;
5040a2dea1fSRanjani Sridharan struct snd_sof_widget *sink_widget;
5050a2dea1fSRanjani Sridharan bool setup;
506ee1e79b7SRanjani Sridharan
507c84443dbSChao Song int src_queue_id;
508c84443dbSChao Song int dst_queue_id;
509c84443dbSChao Song
510ee1e79b7SRanjani Sridharan void *private;
511ee1e79b7SRanjani Sridharan };
512ee1e79b7SRanjani Sridharan
513ee1e79b7SRanjani Sridharan /* ASoC DAI device */
514ee1e79b7SRanjani Sridharan struct snd_sof_dai {
515ee1e79b7SRanjani Sridharan struct snd_soc_component *scomp;
516ee1e79b7SRanjani Sridharan const char *name;
517ee1e79b7SRanjani Sridharan
518c1c03888SJaska Uimonen int number_configs;
519c1c03888SJaska Uimonen int current_config;
520ee1e79b7SRanjani Sridharan struct list_head list; /* list in sdev dai list */
5212ae49c6fSRanjani Sridharan /* core should not touch this */
5222ae49c6fSRanjani Sridharan const void *platform_private;
523839e484fSRanjani Sridharan void *private;
524ee1e79b7SRanjani Sridharan };
525ee1e79b7SRanjani Sridharan
526ee1e79b7SRanjani Sridharan /*
527ee1e79b7SRanjani Sridharan * Kcontrols.
528ee1e79b7SRanjani Sridharan */
529ee1e79b7SRanjani Sridharan
530ee1e79b7SRanjani Sridharan int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
531ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
532ee1e79b7SRanjani Sridharan int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
533ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
534fca18e62SJaska Uimonen int snd_sof_volume_info(struct snd_kcontrol *kcontrol,
535518a760cSPierre-Louis Bossart struct snd_ctl_elem_info *uinfo);
536ee1e79b7SRanjani Sridharan int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
537ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
538ee1e79b7SRanjani Sridharan int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
539ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
540ee1e79b7SRanjani Sridharan int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
541ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
542ee1e79b7SRanjani Sridharan int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
543ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
544ee1e79b7SRanjani Sridharan int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
545ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
546ee1e79b7SRanjani Sridharan int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
547ee1e79b7SRanjani Sridharan struct snd_ctl_elem_value *ucontrol);
548ee1e79b7SRanjani Sridharan int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
549ee1e79b7SRanjani Sridharan const unsigned int __user *binary_data,
550ee1e79b7SRanjani Sridharan unsigned int size);
551ee1e79b7SRanjani Sridharan int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
552ee1e79b7SRanjani Sridharan unsigned int __user *binary_data,
553ee1e79b7SRanjani Sridharan unsigned int size);
554783560d0SDharageswari R int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data,
555783560d0SDharageswari R unsigned int size);
556756bbe42SPeter Ujfalusi void snd_sof_control_notify(struct snd_sof_dev *sdev,
557756bbe42SPeter Ujfalusi struct sof_ipc_ctrl_data *cdata);
558ee1e79b7SRanjani Sridharan
559ee1e79b7SRanjani Sridharan /*
560ee1e79b7SRanjani Sridharan * Topology.
561ee1e79b7SRanjani Sridharan * There is no snd_sof_free_topology since topology components will
562ee1e79b7SRanjani Sridharan * be freed by snd_soc_unregister_component,
563ee1e79b7SRanjani Sridharan */
564ee1e79b7SRanjani Sridharan int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file);
565ee1e79b7SRanjani Sridharan
566ee1e79b7SRanjani Sridharan /*
567ee1e79b7SRanjani Sridharan * Stream IPC
568ee1e79b7SRanjani Sridharan */
569ee1e79b7SRanjani Sridharan int snd_sof_ipc_stream_posn(struct snd_soc_component *scomp,
570ee1e79b7SRanjani Sridharan struct snd_sof_pcm *spcm, int direction,
571ee1e79b7SRanjani Sridharan struct sof_ipc_stream_posn *posn);
572ee1e79b7SRanjani Sridharan
573ee1e79b7SRanjani Sridharan struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp,
574ee1e79b7SRanjani Sridharan const char *name);
575ee1e79b7SRanjani Sridharan struct snd_sof_widget *
576ee1e79b7SRanjani Sridharan snd_sof_find_swidget_sname(struct snd_soc_component *scomp,
577ee1e79b7SRanjani Sridharan const char *pcm_name, int dir);
578ee1e79b7SRanjani Sridharan struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp,
579ee1e79b7SRanjani Sridharan const char *name);
580ee1e79b7SRanjani Sridharan
581ee1e79b7SRanjani Sridharan static inline
snd_sof_find_spcm_dai(struct snd_soc_component * scomp,struct snd_soc_pcm_runtime * rtd)582ee1e79b7SRanjani Sridharan struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_soc_component *scomp,
583ee1e79b7SRanjani Sridharan struct snd_soc_pcm_runtime *rtd)
584ee1e79b7SRanjani Sridharan {
585ee1e79b7SRanjani Sridharan struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
586d516e96bSPierre-Louis Bossart struct snd_sof_pcm *spcm;
587ee1e79b7SRanjani Sridharan
588ee1e79b7SRanjani Sridharan list_for_each_entry(spcm, &sdev->pcm_list, list) {
589ee1e79b7SRanjani Sridharan if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id)
590ee1e79b7SRanjani Sridharan return spcm;
591ee1e79b7SRanjani Sridharan }
592ee1e79b7SRanjani Sridharan
593ee1e79b7SRanjani Sridharan return NULL;
594ee1e79b7SRanjani Sridharan }
595ee1e79b7SRanjani Sridharan
596ee1e79b7SRanjani Sridharan struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp,
597ee1e79b7SRanjani Sridharan const char *name);
598ee1e79b7SRanjani Sridharan struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
599ee1e79b7SRanjani Sridharan unsigned int comp_id,
600ee1e79b7SRanjani Sridharan int *direction);
601ee1e79b7SRanjani Sridharan void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
602858f7a5cSDaniel Baluta void snd_sof_pcm_init_elapsed_work(struct work_struct *work);
603858f7a5cSDaniel Baluta
604858f7a5cSDaniel Baluta #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
605858f7a5cSDaniel Baluta void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream);
606858f7a5cSDaniel Baluta void snd_sof_compr_init_elapsed_work(struct work_struct *work);
607858f7a5cSDaniel Baluta #else
snd_sof_compr_fragment_elapsed(struct snd_compr_stream * cstream)608858f7a5cSDaniel Baluta static inline void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream) { }
snd_sof_compr_init_elapsed_work(struct work_struct * work)609858f7a5cSDaniel Baluta static inline void snd_sof_compr_init_elapsed_work(struct work_struct *work) { }
610858f7a5cSDaniel Baluta #endif
611ee1e79b7SRanjani Sridharan
612f805e7e0SRanjani Sridharan /* DAI link fixup */
613f805e7e0SRanjani Sridharan int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
614f805e7e0SRanjani Sridharan
615ee1e79b7SRanjani Sridharan /* PM */
616700d1677SRanjani Sridharan bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
617de23a838SRanjani Sridharan bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);
618ee1e79b7SRanjani Sridharan
619285880a2SDaniel Baluta /* Machine driver enumeration */
620285880a2SDaniel Baluta int sof_machine_register(struct snd_sof_dev *sdev, void *pdata);
621285880a2SDaniel Baluta void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata);
622285880a2SDaniel Baluta
6238b001416SRanjani Sridharan int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
6248b001416SRanjani Sridharan int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
6253816bbeaSRanjani Sridharan int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsource,
6263816bbeaSRanjani Sridharan struct snd_soc_dapm_widget *wsink);
6278b001416SRanjani Sridharan
6285fcdbb2dSRanjani Sridharan /* PCM */
62966344c6dSRanjani Sridharan int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm,
63066344c6dSRanjani Sridharan struct snd_pcm_hw_params *fe_params,
63166344c6dSRanjani Sridharan struct snd_sof_platform_stream_params *platform_params,
63266344c6dSRanjani Sridharan int dir);
6335fcdbb2dSRanjani Sridharan int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir);
63496da1740SRanjani Sridharan int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev,
63596da1740SRanjani Sridharan struct snd_sof_pcm *spcm);
636d9a72465SRanjani Sridharan int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
637d9a72465SRanjani Sridharan struct snd_sof_pcm *spcm, int dir, bool free_widget_list);
638ea7e5ee6SRanjani Sridharan int get_token_u32(void *elem, void *object, u32 offset);
639ea7e5ee6SRanjani Sridharan int get_token_u16(void *elem, void *object, u32 offset);
640ea7e5ee6SRanjani Sridharan int get_token_comp_format(void *elem, void *object, u32 offset);
641ea7e5ee6SRanjani Sridharan int get_token_dai_type(void *elem, void *object, u32 offset);
642ea7e5ee6SRanjani Sridharan int get_token_uuid(void *elem, void *object, u32 offset);
6433b3acedbSChao Song int get_token_string(void *elem, void *object, u32 offset);
644d87524bfSRanjani Sridharan int sof_update_ipc_object(struct snd_soc_component *scomp, void *object, enum sof_tokens token_id,
645d87524bfSRanjani Sridharan struct snd_sof_tuple *tuples, int num_tuples,
646d87524bfSRanjani Sridharan size_t object_size, int token_instance_num);
64748d2a1ceSRanjani Sridharan u32 vol_compute_gain(u32 value, int *tlv);
648ee1e79b7SRanjani Sridharan #endif
649