xref: /openbmc/linux/sound/soc/sof/sof-audio.h (revision 5626af8f)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /*
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.
5  *
6  * Copyright(c) 2019 Intel Corporation. All rights reserved.
7  *
8  * Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
9  */
10 
11 #ifndef __SOUND_SOC_SOF_AUDIO_H
12 #define __SOUND_SOC_SOF_AUDIO_H
13 
14 #include <linux/workqueue.h>
15 
16 #include <sound/soc.h>
17 #include <sound/control.h>
18 #include <sound/sof/stream.h> /* needs to be included before control.h */
19 #include <sound/sof/control.h>
20 #include <sound/sof/dai.h>
21 #include <sound/sof/topology.h>
22 #include "sof-priv.h"
23 
24 #define SOF_AUDIO_PCM_DRV_NAME	"sof-audio-component"
25 
26 /*
27  * The ipc4 firmware only supports up to 8 sink or source pins
28  * per widget, because only 3 bits are used for queue(pin) ID
29  * in ipc4 protocol.
30  */
31 #define SOF_WIDGET_MAX_NUM_PINS	8
32 
33 /* The type of a widget pin is either sink or source */
34 #define SOF_PIN_TYPE_SINK	0
35 #define SOF_PIN_TYPE_SOURCE	1
36 
37 /* max number of FE PCMs before BEs */
38 #define SOF_BE_PCM_BASE		16
39 
40 #define DMA_CHAN_INVALID	0xFFFFFFFF
41 
42 #define WIDGET_IS_DAI(id) ((id) == snd_soc_dapm_dai_in || (id) == snd_soc_dapm_dai_out)
43 #define WIDGET_IS_AIF(id) ((id) == snd_soc_dapm_aif_in || (id) == snd_soc_dapm_aif_out)
44 #define WIDGET_IS_AIF_OR_DAI(id) (WIDGET_IS_DAI(id) || WIDGET_IS_AIF(id))
45 
46 #define SOF_DAI_CLK_INTEL_SSP_MCLK	0
47 #define SOF_DAI_CLK_INTEL_SSP_BCLK	1
48 
49 enum sof_widget_op {
50 	SOF_WIDGET_PREPARE,
51 	SOF_WIDGET_SETUP,
52 	SOF_WIDGET_FREE,
53 	SOF_WIDGET_UNPREPARE,
54 };
55 
56 /*
57  * Volume fractional word length define to 16 sets
58  * the volume linear gain value to use Qx.16 format
59  */
60 #define VOLUME_FWL	16
61 
62 #define SOF_TLV_ITEMS 3
63 
64 static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
65 {
66 	if (value >= size)
67 		return volume_map[size - 1];
68 
69 	return volume_map[value];
70 }
71 
72 static inline u32 ipc_to_mixer(u32 value, u32 *volume_map, int size)
73 {
74 	int i;
75 
76 	for (i = 0; i < size; i++) {
77 		if (volume_map[i] >= value)
78 			return i;
79 	}
80 
81 	return i - 1;
82 }
83 
84 struct snd_sof_widget;
85 struct snd_sof_route;
86 struct snd_sof_control;
87 struct snd_sof_dai;
88 
89 struct snd_sof_dai_config_data {
90 	int dai_index;
91 	int dai_data; /* contains DAI-specific information */
92 };
93 
94 /**
95  * struct sof_ipc_pcm_ops - IPC-specific PCM ops
96  * @hw_params: Function pointer for hw_params
97  * @hw_free: Function pointer for hw_free
98  * @trigger: Function pointer for trigger
99  * @dai_link_fixup: Function pointer for DAI link fixup
100  */
101 struct sof_ipc_pcm_ops {
102 	int (*hw_params)(struct snd_soc_component *component, struct snd_pcm_substream *substream,
103 			 struct snd_pcm_hw_params *params,
104 			 struct snd_sof_platform_stream_params *platform_params);
105 	int (*hw_free)(struct snd_soc_component *component, struct snd_pcm_substream *substream);
106 	int (*trigger)(struct snd_soc_component *component,  struct snd_pcm_substream *substream,
107 		       int cmd);
108 	int (*dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
109 };
110 
111 /**
112  * struct sof_ipc_tplg_control_ops - IPC-specific ops for topology kcontrol IO
113  */
114 struct sof_ipc_tplg_control_ops {
115 	bool (*volume_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
116 	int (*volume_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
117 	bool (*switch_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
118 	int (*switch_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
119 	bool (*enum_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
120 	int (*enum_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
121 	int (*bytes_put)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
122 	int (*bytes_get)(struct snd_sof_control *scontrol, struct snd_ctl_elem_value *ucontrol);
123 	int (*bytes_ext_get)(struct snd_sof_control *scontrol,
124 			     const unsigned int __user *binary_data, unsigned int size);
125 	int (*bytes_ext_volatile_get)(struct snd_sof_control *scontrol,
126 				      const unsigned int __user *binary_data, unsigned int size);
127 	int (*bytes_ext_put)(struct snd_sof_control *scontrol,
128 			     const unsigned int __user *binary_data, unsigned int size);
129 	/* update control data based on notification from the DSP */
130 	void (*update)(struct snd_sof_dev *sdev, void *ipc_control_message);
131 	/* Optional callback to setup kcontrols associated with an swidget */
132 	int (*widget_kcontrol_setup)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
133 	/* mandatory callback to set up volume table for volume kcontrols */
134 	int (*set_up_volume_table)(struct snd_sof_control *scontrol, int tlv[SOF_TLV_ITEMS],
135 				   int size);
136 };
137 
138 /**
139  * struct sof_ipc_tplg_widget_ops - IPC-specific ops for topology widgets
140  * @ipc_setup: Function pointer for setting up widget IPC params
141  * @ipc_free: Function pointer for freeing widget IPC params
142  * @token_list: List of token ID's that should be parsed for the widget
143  * @token_list_size: number of elements in token_list
144  * @bind_event: Function pointer for binding events to the widget
145  * @ipc_prepare: Optional op for preparing a widget for set up
146  * @ipc_unprepare: Optional op for unpreparing a widget
147  */
148 struct sof_ipc_tplg_widget_ops {
149 	int (*ipc_setup)(struct snd_sof_widget *swidget);
150 	void (*ipc_free)(struct snd_sof_widget *swidget);
151 	enum sof_tokens *token_list;
152 	int token_list_size;
153 	int (*bind_event)(struct snd_soc_component *scomp, struct snd_sof_widget *swidget,
154 			  u16 event_type);
155 	int (*ipc_prepare)(struct snd_sof_widget *swidget,
156 			   struct snd_pcm_hw_params *fe_params,
157 			   struct snd_sof_platform_stream_params *platform_params,
158 			   struct snd_pcm_hw_params *source_params, int dir);
159 	void (*ipc_unprepare)(struct snd_sof_widget *swidget);
160 };
161 
162 /**
163  * struct sof_ipc_tplg_ops - IPC-specific topology ops
164  * @widget: Array of pointers to IPC-specific ops for widgets. This should always be of size
165  *	    SND_SOF_DAPM_TYPE_COUNT i.e one per widget type. Unsupported widget types will be
166  *	    initialized to 0.
167  * @control: Pointer to the IPC-specific ops for topology kcontrol IO
168  * @route_setup: Function pointer for setting up pipeline connections
169  * @route_free: Optional op for freeing pipeline connections.
170  * @token_list: List of all tokens supported by the IPC version. The size of the token_list
171  *		array should be SOF_TOKEN_COUNT. The unused elements in the array will be
172  *		initialized to 0.
173  * @control_setup: Function pointer for setting up kcontrol IPC-specific data
174  * @control_free: Function pointer for freeing kcontrol IPC-specific data
175  * @pipeline_complete: Function pointer for pipeline complete IPC
176  * @widget_setup: Function pointer for setting up setup in the DSP
177  * @widget_free: Function pointer for freeing widget in the DSP
178  * @dai_config: Function pointer for sending DAI config IPC to the DSP
179  * @dai_get_clk: Function pointer for getting the DAI clock setting
180  * @set_up_all_pipelines: Function pointer for setting up all topology pipelines
181  * @tear_down_all_pipelines: Function pointer for tearing down all topology pipelines
182  * @parse_manifest: Optional function pointer for ipc4 specific parsing of topology manifest
183  */
184 struct sof_ipc_tplg_ops {
185 	const struct sof_ipc_tplg_widget_ops *widget;
186 	const struct sof_ipc_tplg_control_ops *control;
187 	int (*route_setup)(struct snd_sof_dev *sdev, struct snd_sof_route *sroute);
188 	int (*route_free)(struct snd_sof_dev *sdev, struct snd_sof_route *sroute);
189 	const struct sof_token_info *token_list;
190 	int (*control_setup)(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol);
191 	int (*control_free)(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol);
192 	int (*pipeline_complete)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
193 	int (*widget_setup)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
194 	int (*widget_free)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
195 	int (*dai_config)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget,
196 			  unsigned int flags, struct snd_sof_dai_config_data *data);
197 	int (*dai_get_clk)(struct snd_sof_dev *sdev, struct snd_sof_dai *dai, int clk_type);
198 	int (*set_up_all_pipelines)(struct snd_sof_dev *sdev, bool verify);
199 	int (*tear_down_all_pipelines)(struct snd_sof_dev *sdev, bool verify);
200 	int (*parse_manifest)(struct snd_soc_component *scomp, int index,
201 			      struct snd_soc_tplg_manifest *man);
202 };
203 
204 /** struct snd_sof_tuple - Tuple info
205  * @token:	Token ID
206  * @value:	union of a string or a u32 values
207  */
208 struct snd_sof_tuple {
209 	u32 token;
210 	union {
211 		u32 v;
212 		const char *s;
213 	} value;
214 };
215 
216 /*
217  * List of SOF token ID's. The order of ID's does not matter as token arrays are looked up based on
218  * the ID.
219  */
220 enum sof_tokens {
221 	SOF_PCM_TOKENS,
222 	SOF_PIPELINE_TOKENS,
223 	SOF_SCHED_TOKENS,
224 	SOF_ASRC_TOKENS,
225 	SOF_SRC_TOKENS,
226 	SOF_COMP_TOKENS,
227 	SOF_BUFFER_TOKENS,
228 	SOF_VOLUME_TOKENS,
229 	SOF_PROCESS_TOKENS,
230 	SOF_DAI_TOKENS,
231 	SOF_DAI_LINK_TOKENS,
232 	SOF_HDA_TOKENS,
233 	SOF_SSP_TOKENS,
234 	SOF_ALH_TOKENS,
235 	SOF_DMIC_TOKENS,
236 	SOF_DMIC_PDM_TOKENS,
237 	SOF_ESAI_TOKENS,
238 	SOF_SAI_TOKENS,
239 	SOF_AFE_TOKENS,
240 	SOF_CORE_TOKENS,
241 	SOF_COMP_EXT_TOKENS,
242 	SOF_IN_AUDIO_FORMAT_TOKENS,
243 	SOF_OUT_AUDIO_FORMAT_TOKENS,
244 	SOF_AUDIO_FORMAT_BUFFER_SIZE_TOKENS,
245 	SOF_COPIER_GATEWAY_CFG_TOKENS,
246 	SOF_COPIER_TOKENS,
247 	SOF_AUDIO_FMT_NUM_TOKENS,
248 	SOF_COPIER_FORMAT_TOKENS,
249 	SOF_GAIN_TOKENS,
250 	SOF_ACPDMIC_TOKENS,
251 	SOF_ACPI2S_TOKENS,
252 
253 	/* this should be the last */
254 	SOF_TOKEN_COUNT,
255 };
256 
257 /**
258  * struct sof_topology_token - SOF topology token definition
259  * @token:		Token number
260  * @type:		Token type
261  * @get_token:		Function pointer to parse the token value and save it in a object
262  * @offset:		Offset within an object to save the token value into
263  */
264 struct sof_topology_token {
265 	u32 token;
266 	u32 type;
267 	int (*get_token)(void *elem, void *object, u32 offset);
268 	u32 offset;
269 };
270 
271 struct sof_token_info {
272 	const char *name;
273 	const struct sof_topology_token *tokens;
274 	int count;
275 };
276 
277 /* PCM stream, mapped to FW component  */
278 struct snd_sof_pcm_stream {
279 	u32 comp_id;
280 	struct snd_dma_buffer page_table;
281 	struct sof_ipc_stream_posn posn;
282 	struct snd_pcm_substream *substream;
283 	struct snd_compr_stream *cstream;
284 	struct work_struct period_elapsed_work;
285 	struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */
286 	bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
287 	/*
288 	 * flag to indicate that the DSP pipelines should be kept
289 	 * active or not while suspending the stream
290 	 */
291 	bool suspend_ignored;
292 };
293 
294 /* ALSA SOF PCM device */
295 struct snd_sof_pcm {
296 	struct snd_soc_component *scomp;
297 	struct snd_soc_tplg_pcm pcm;
298 	struct snd_sof_pcm_stream stream[2];
299 	struct list_head list;	/* list in sdev pcm list */
300 	struct snd_pcm_hw_params params[2];
301 	bool prepared[2]; /* PCM_PARAMS set successfully */
302 };
303 
304 struct snd_sof_led_control {
305 	unsigned int use_led;
306 	unsigned int direction;
307 	int led_value;
308 };
309 
310 /* ALSA SOF Kcontrol device */
311 struct snd_sof_control {
312 	struct snd_soc_component *scomp;
313 	const char *name;
314 	int comp_id;
315 	int min_volume_step; /* min volume step for volume_table */
316 	int max_volume_step; /* max volume step for volume_table */
317 	int num_channels;
318 	unsigned int access;
319 	int info_type;
320 	int index; /* pipeline ID */
321 	void *priv; /* private data copied from topology */
322 	size_t priv_size; /* size of private data */
323 	size_t max_size;
324 	void *ipc_control_data;
325 	int max; /* applicable to volume controls */
326 	u32 size;	/* cdata size */
327 	u32 *volume_table; /* volume table computed from tlv data*/
328 
329 	struct list_head list;	/* list in sdev control list */
330 
331 	struct snd_sof_led_control led_ctl;
332 
333 	/* if true, the control's data needs to be updated from Firmware */
334 	bool comp_data_dirty;
335 };
336 
337 /** struct snd_sof_dai_link - DAI link info
338  * @tuples: array of parsed tuples
339  * @num_tuples: number of tuples in the tuples array
340  * @link: Pointer to snd_soc_dai_link
341  * @hw_configs: Pointer to hw configs in topology
342  * @num_hw_configs: Number of hw configs in topology
343  * @default_hw_cfg_id: Default hw config ID
344  * @type: DAI type
345  * @list: item in snd_sof_dev dai_link list
346  */
347 struct snd_sof_dai_link {
348 	struct snd_sof_tuple *tuples;
349 	int num_tuples;
350 	struct snd_soc_dai_link *link;
351 	struct snd_soc_tplg_hw_config *hw_configs;
352 	int num_hw_configs;
353 	int default_hw_cfg_id;
354 	int type;
355 	struct list_head list;
356 };
357 
358 /* ASoC SOF DAPM widget */
359 struct snd_sof_widget {
360 	struct snd_soc_component *scomp;
361 	int comp_id;
362 	int pipeline_id;
363 	/*
364 	 * complete flag is used to indicate that pipeline set up is complete for scheduler type
365 	 * widgets. It is unused for all other widget types.
366 	 */
367 	int complete;
368 	/*
369 	 * the prepared flag is used to indicate that a widget has been prepared for getting set
370 	 * up in the DSP.
371 	 */
372 	bool prepared;
373 	int use_count; /* use_count will be protected by the PCM mutex held by the core */
374 	int core;
375 	int id; /* id is the DAPM widget type */
376 	/*
377 	 * Instance ID is set dynamically when the widget gets set up in the FW. It should be
378 	 * unique for each module type across all pipelines. This will not be used in SOF_IPC.
379 	 */
380 	int instance_id;
381 
382 	/*
383 	 * Flag indicating if the widget should be set up dynamically when a PCM is opened.
384 	 * This flag is only set for the scheduler type widget in topology. During topology
385 	 * loading, this flag is propagated to all the widgets belonging to the same pipeline.
386 	 * When this flag is not set, a widget is set up at the time of topology loading
387 	 * and retained until the DSP enters D3. It will need to be set up again when resuming
388 	 * from D3.
389 	 */
390 	bool dynamic_pipeline_widget;
391 
392 	struct snd_soc_dapm_widget *widget;
393 	struct list_head list;	/* list in sdev widget list */
394 	struct snd_sof_widget *pipe_widget;
395 	void *module_info;
396 
397 	const guid_t uuid;
398 
399 	int num_tuples;
400 	struct snd_sof_tuple *tuples;
401 
402 	/*
403 	 * The allowed range for num_sink/source_pins is [0, SOF_WIDGET_MAX_NUM_PINS].
404 	 * Widgets may have zero sink or source pins, for example the tone widget has
405 	 * zero sink pins.
406 	 */
407 	u32 num_sink_pins;
408 	u32 num_source_pins;
409 
410 	/*
411 	 * The sink/source pin binding array, it takes the form of
412 	 * [widget_name_connected_to_pin0, widget_name_connected_to_pin1, ...],
413 	 * with the index as the queue ID.
414 	 *
415 	 * The array is used for special pin binding. Note that even if there
416 	 * is only one sink/source pin requires special pin binding, pin binding
417 	 * should be defined for all sink/source pins in topology, for pin(s) that
418 	 * are not used, give the value "NotConnected".
419 	 *
420 	 * If pin binding is not defined in topology, nothing to parse in the kernel,
421 	 * sink_pin_binding and src_pin_binding shall be NULL.
422 	 */
423 	char **sink_pin_binding;
424 	char **src_pin_binding;
425 
426 	struct ida src_queue_ida;
427 	struct ida sink_queue_ida;
428 
429 	void *private;		/* core does not touch this */
430 };
431 
432 /* ASoC SOF DAPM route */
433 struct snd_sof_route {
434 	struct snd_soc_component *scomp;
435 
436 	struct snd_soc_dapm_route *route;
437 	struct list_head list;	/* list in sdev route list */
438 	struct snd_sof_widget *src_widget;
439 	struct snd_sof_widget *sink_widget;
440 	bool setup;
441 
442 	int src_queue_id;
443 	int dst_queue_id;
444 
445 	void *private;
446 };
447 
448 /* ASoC DAI device */
449 struct snd_sof_dai {
450 	struct snd_soc_component *scomp;
451 	const char *name;
452 
453 	int number_configs;
454 	int current_config;
455 	struct list_head list;	/* list in sdev dai list */
456 	void *private;
457 };
458 
459 /*
460  * Kcontrols.
461  */
462 
463 int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
464 		       struct snd_ctl_elem_value *ucontrol);
465 int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
466 		       struct snd_ctl_elem_value *ucontrol);
467 int snd_sof_volume_info(struct snd_kcontrol *kcontrol,
468 			struct snd_ctl_elem_info *uinfo);
469 int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
470 		       struct snd_ctl_elem_value *ucontrol);
471 int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
472 		       struct snd_ctl_elem_value *ucontrol);
473 int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
474 		     struct snd_ctl_elem_value *ucontrol);
475 int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
476 		     struct snd_ctl_elem_value *ucontrol);
477 int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
478 		      struct snd_ctl_elem_value *ucontrol);
479 int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
480 		      struct snd_ctl_elem_value *ucontrol);
481 int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
482 			  const unsigned int __user *binary_data,
483 			  unsigned int size);
484 int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
485 			  unsigned int __user *binary_data,
486 			  unsigned int size);
487 int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data,
488 				   unsigned int size);
489 void snd_sof_control_notify(struct snd_sof_dev *sdev,
490 			    struct sof_ipc_ctrl_data *cdata);
491 
492 /*
493  * Topology.
494  * There is no snd_sof_free_topology since topology components will
495  * be freed by snd_soc_unregister_component,
496  */
497 int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file);
498 
499 /*
500  * Stream IPC
501  */
502 int snd_sof_ipc_stream_posn(struct snd_soc_component *scomp,
503 			    struct snd_sof_pcm *spcm, int direction,
504 			    struct sof_ipc_stream_posn *posn);
505 
506 struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp,
507 					    const char *name);
508 struct snd_sof_widget *
509 snd_sof_find_swidget_sname(struct snd_soc_component *scomp,
510 			   const char *pcm_name, int dir);
511 struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp,
512 				     const char *name);
513 
514 static inline
515 struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_soc_component *scomp,
516 					  struct snd_soc_pcm_runtime *rtd)
517 {
518 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
519 	struct snd_sof_pcm *spcm;
520 
521 	list_for_each_entry(spcm, &sdev->pcm_list, list) {
522 		if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id)
523 			return spcm;
524 	}
525 
526 	return NULL;
527 }
528 
529 struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp,
530 					   const char *name);
531 struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
532 					   unsigned int comp_id,
533 					   int *direction);
534 void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
535 void snd_sof_pcm_init_elapsed_work(struct work_struct *work);
536 
537 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
538 void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream);
539 void snd_sof_compr_init_elapsed_work(struct work_struct *work);
540 #else
541 static inline void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream) { }
542 static inline void snd_sof_compr_init_elapsed_work(struct work_struct *work) { }
543 #endif
544 
545 /* DAI link fixup */
546 int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
547 
548 /* PM */
549 bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
550 bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);
551 
552 /* Machine driver enumeration */
553 int sof_machine_register(struct snd_sof_dev *sdev, void *pdata);
554 void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata);
555 
556 int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
557 int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
558 int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsource,
559 		    struct snd_soc_dapm_widget *wsink);
560 
561 /* PCM */
562 int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm,
563 			  struct snd_pcm_hw_params *fe_params,
564 			  struct snd_sof_platform_stream_params *platform_params,
565 			  int dir);
566 int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir);
567 int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev,
568 			 struct snd_sof_pcm *spcm);
569 int sof_pcm_stream_free(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
570 			struct snd_sof_pcm *spcm, int dir, bool free_widget_list);
571 int get_token_u32(void *elem, void *object, u32 offset);
572 int get_token_u16(void *elem, void *object, u32 offset);
573 int get_token_comp_format(void *elem, void *object, u32 offset);
574 int get_token_dai_type(void *elem, void *object, u32 offset);
575 int get_token_uuid(void *elem, void *object, u32 offset);
576 int get_token_string(void *elem, void *object, u32 offset);
577 int sof_update_ipc_object(struct snd_soc_component *scomp, void *object, enum sof_tokens token_id,
578 			  struct snd_sof_tuple *tuples, int num_tuples,
579 			  size_t object_size, int token_instance_num);
580 u32 vol_compute_gain(u32 value, int *tlv);
581 #endif
582