xref: /linux/sound/soc/sof/sof-priv.h (revision 501e94b52aeda5841a60ceead5984ff575aeefa0)
1 /* SPDX-License-Identifier: (GPL-2.0 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) 2018 Intel Corporation. All rights reserved.
7  *
8  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9  */
10 
11 #ifndef __SOUND_SOC_SOF_PRIV_H
12 #define __SOUND_SOC_SOF_PRIV_H
13 
14 #include <linux/device.h>
15 
16 #include <sound/hdaudio.h>
17 #include <sound/soc.h>
18 
19 #include <sound/sof.h>
20 #include <sound/sof/stream.h> /* needs to be included before control.h */
21 #include <sound/sof/control.h>
22 #include <sound/sof/dai.h>
23 #include <sound/sof/info.h>
24 #include <sound/sof/pm.h>
25 #include <sound/sof/topology.h>
26 #include <sound/sof/trace.h>
27 
28 #include <uapi/sound/sof/fw.h>
29 
30 /* debug flags */
31 #define SOF_DBG_REGS	BIT(1)
32 #define SOF_DBG_MBOX	BIT(2)
33 #define SOF_DBG_TEXT	BIT(3)
34 #define SOF_DBG_PCI	BIT(4)
35 
36 /* max BARs mmaped devices can use */
37 #define SND_SOF_BARS	8
38 
39 /* time in ms for runtime suspend delay */
40 #define SND_SOF_SUSPEND_DELAY_MS	2000
41 
42 /* DMA buffer size for trace */
43 #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16)
44 
45 /* max number of FE PCMs before BEs */
46 #define SOF_BE_PCM_BASE		16
47 
48 #define SOF_IPC_DSP_REPLY		0
49 #define SOF_IPC_HOST_REPLY		1
50 
51 /* convenience constructor for DAI driver streams */
52 #define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \
53 	{.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \
54 	 .rates = srates, .formats = sfmt}
55 
56 #define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
57 	SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)
58 
59 #define ENABLE_DEBUGFS_CACHEBUF \
60 	(IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \
61 	 IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST))
62 
63 #define DMA_CHAN_INVALID	0xFFFFFFFF
64 
65 struct snd_sof_dev;
66 struct snd_sof_ipc_msg;
67 struct snd_sof_ipc;
68 struct snd_sof_debugfs_map;
69 struct snd_soc_tplg_ops;
70 struct snd_soc_component;
71 struct snd_sof_pdata;
72 
73 /*
74  * SOF DSP HW abstraction operations.
75  * Used to abstract DSP HW architecture and any IO busses between host CPU
76  * and DSP device(s).
77  */
78 struct snd_sof_dsp_ops {
79 
80 	/* probe and remove */
81 	int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */
82 	int (*remove)(struct snd_sof_dev *sof_dev); /* optional */
83 
84 	/* DSP core boot / reset */
85 	int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
86 	int (*stall)(struct snd_sof_dev *sof_dev); /* optional */
87 	int (*reset)(struct snd_sof_dev *sof_dev); /* optional */
88 	int (*core_power_up)(struct snd_sof_dev *sof_dev,
89 			     unsigned int core_mask); /* optional */
90 	int (*core_power_down)(struct snd_sof_dev *sof_dev,
91 			       unsigned int core_mask); /* optional */
92 
93 	/*
94 	 * Register IO: only used by respective drivers themselves,
95 	 * TODO: consider removing these operations and calling respective
96 	 * implementations directly
97 	 */
98 	void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
99 		      u32 value); /* optional */
100 	u32 (*read)(struct snd_sof_dev *sof_dev,
101 		    void __iomem *addr); /* optional */
102 	void (*write64)(struct snd_sof_dev *sof_dev, void __iomem *addr,
103 			u64 value); /* optional */
104 	u64 (*read64)(struct snd_sof_dev *sof_dev,
105 		      void __iomem *addr); /* optional */
106 
107 	/* memcpy IO */
108 	void (*block_read)(struct snd_sof_dev *sof_dev, u32 bar,
109 			   u32 offset, void *dest,
110 			   size_t size); /* mandatory */
111 	void (*block_write)(struct snd_sof_dev *sof_dev, u32 bar,
112 			    u32 offset, void *src,
113 			    size_t size); /* mandatory */
114 
115 	/* doorbell */
116 	irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
117 	irqreturn_t (*irq_thread)(int irq, void *context); /* optional */
118 
119 	/* ipc */
120 	int (*send_msg)(struct snd_sof_dev *sof_dev,
121 			struct snd_sof_ipc_msg *msg); /* mandatory */
122 
123 	/* FW loading */
124 	int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
125 	int (*load_module)(struct snd_sof_dev *sof_dev,
126 			   struct snd_sof_mod_hdr *hdr); /* optional */
127 	/*
128 	 * FW ready checks for ABI compatibility and creates
129 	 * memory windows at first boot
130 	 */
131 	int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id); /* optional */
132 
133 	/* connect pcm substream to a host stream */
134 	int (*pcm_open)(struct snd_sof_dev *sdev,
135 			struct snd_pcm_substream *substream); /* optional */
136 	/* disconnect pcm substream to a host stream */
137 	int (*pcm_close)(struct snd_sof_dev *sdev,
138 			 struct snd_pcm_substream *substream); /* optional */
139 
140 	/* host stream hw params */
141 	int (*pcm_hw_params)(struct snd_sof_dev *sdev,
142 			     struct snd_pcm_substream *substream,
143 			     struct snd_pcm_hw_params *params,
144 			     struct sof_ipc_stream_params *ipc_params); /* optional */
145 
146 	/* host stream hw_free */
147 	int (*pcm_hw_free)(struct snd_sof_dev *sdev,
148 			   struct snd_pcm_substream *substream); /* optional */
149 
150 	/* host stream trigger */
151 	int (*pcm_trigger)(struct snd_sof_dev *sdev,
152 			   struct snd_pcm_substream *substream,
153 			   int cmd); /* optional */
154 
155 	/* host stream pointer */
156 	snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
157 					 struct snd_pcm_substream *substream); /* optional */
158 
159 	/* host read DSP stream data */
160 	void (*ipc_msg_data)(struct snd_sof_dev *sdev,
161 			     struct snd_pcm_substream *substream,
162 			     void *p, size_t sz); /* mandatory */
163 
164 	/* host configure DSP HW parameters */
165 	int (*ipc_pcm_params)(struct snd_sof_dev *sdev,
166 			      struct snd_pcm_substream *substream,
167 			      const struct sof_ipc_pcm_params_reply *reply); /* mandatory */
168 
169 	/* pre/post firmware run */
170 	int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
171 	int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
172 
173 	/* DSP PM */
174 	int (*suspend)(struct snd_sof_dev *sof_dev, int state); /* optional */
175 	int (*resume)(struct snd_sof_dev *sof_dev); /* optional */
176 	int (*runtime_suspend)(struct snd_sof_dev *sof_dev,
177 			       int state); /* optional */
178 	int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */
179 	int (*set_hw_params_upon_resume)(struct snd_sof_dev *sdev); /* optional */
180 
181 	/* DSP clocking */
182 	int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
183 
184 	/* debug */
185 	const struct snd_sof_debugfs_map *debug_map; /* optional */
186 	int debug_map_count; /* optional */
187 	void (*dbg_dump)(struct snd_sof_dev *sof_dev,
188 			 u32 flags); /* optional */
189 	void (*ipc_dump)(struct snd_sof_dev *sof_dev); /* optional */
190 
191 	/* host DMA trace initialization */
192 	int (*trace_init)(struct snd_sof_dev *sdev,
193 			  u32 *stream_tag); /* optional */
194 	int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
195 	int (*trace_trigger)(struct snd_sof_dev *sdev,
196 			     int cmd); /* optional */
197 
198 	/* DAI ops */
199 	struct snd_soc_dai_driver *drv;
200 	int num_drv;
201 };
202 
203 /* DSP architecture specific callbacks for oops and stack dumps */
204 struct sof_arch_ops {
205 	void (*dsp_oops)(struct snd_sof_dev *sdev, void *oops);
206 	void (*dsp_stack)(struct snd_sof_dev *sdev, void *oops,
207 			  u32 *stack, u32 stack_words);
208 };
209 
210 #define sof_arch_ops(sdev) ((sdev)->pdata->desc->arch_ops)
211 
212 /* DSP device HW descriptor mapping between bus ID and ops */
213 struct sof_ops_table {
214 	const struct sof_dev_desc *desc;
215 	const struct snd_sof_dsp_ops *ops;
216 };
217 
218 enum sof_dfsentry_type {
219 	SOF_DFSENTRY_TYPE_IOMEM = 0,
220 	SOF_DFSENTRY_TYPE_BUF,
221 };
222 
223 enum sof_debugfs_access_type {
224 	SOF_DEBUGFS_ACCESS_ALWAYS = 0,
225 	SOF_DEBUGFS_ACCESS_D0_ONLY,
226 };
227 
228 /* FS entry for debug files that can expose DSP memories, registers */
229 struct snd_sof_dfsentry {
230 	struct dentry *dfsentry;
231 	size_t size;
232 	enum sof_dfsentry_type type;
233 	/*
234 	 * access_type specifies if the
235 	 * memory -> DSP resource (memory, register etc) is always accessible
236 	 * or if it is accessible only when the DSP is in D0.
237 	 */
238 	enum sof_debugfs_access_type access_type;
239 #if ENABLE_DEBUGFS_CACHEBUF
240 	char *cache_buf; /* buffer to cache the contents of debugfs memory */
241 #endif
242 	struct snd_sof_dev *sdev;
243 	struct list_head list;  /* list in sdev dfsentry list */
244 	union {
245 		void __iomem *io_mem;
246 		void *buf;
247 	};
248 };
249 
250 /* Debug mapping for any DSP memory or registers that can used for debug */
251 struct snd_sof_debugfs_map {
252 	const char *name;
253 	u32 bar;
254 	u32 offset;
255 	u32 size;
256 	/*
257 	 * access_type specifies if the memory is always accessible
258 	 * or if it is accessible only when the DSP is in D0.
259 	 */
260 	enum sof_debugfs_access_type access_type;
261 };
262 
263 /* mailbox descriptor, used for host <-> DSP IPC */
264 struct snd_sof_mailbox {
265 	u32 offset;
266 	size_t size;
267 };
268 
269 /* IPC message descriptor for host <-> DSP IO */
270 struct snd_sof_ipc_msg {
271 	/* message data */
272 	u32 header;
273 	void *msg_data;
274 	void *reply_data;
275 	size_t msg_size;
276 	size_t reply_size;
277 	int reply_error;
278 
279 	wait_queue_head_t waitq;
280 	bool ipc_complete;
281 };
282 
283 /* PCM stream, mapped to FW component  */
284 struct snd_sof_pcm_stream {
285 	u32 comp_id;
286 	struct snd_dma_buffer page_table;
287 	struct sof_ipc_stream_posn posn;
288 	struct snd_pcm_substream *substream;
289 	struct work_struct period_elapsed_work;
290 };
291 
292 /* ALSA SOF PCM device */
293 struct snd_sof_pcm {
294 	struct snd_sof_dev *sdev;
295 	struct snd_soc_tplg_pcm pcm;
296 	struct snd_sof_pcm_stream stream[2];
297 	struct list_head list;	/* list in sdev pcm list */
298 	struct snd_pcm_hw_params params[2];
299 	int hw_params_upon_resume[2]; /* set up hw_params upon resume */
300 };
301 
302 /* ALSA SOF Kcontrol device */
303 struct snd_sof_control {
304 	struct snd_sof_dev *sdev;
305 	int comp_id;
306 	int min_volume_step; /* min volume step for volume_table */
307 	int max_volume_step; /* max volume step for volume_table */
308 	int num_channels;
309 	u32 readback_offset; /* offset to mmaped data if used */
310 	struct sof_ipc_ctrl_data *control_data;
311 	u32 size;	/* cdata size */
312 	enum sof_ipc_ctrl_cmd cmd;
313 	u32 *volume_table; /* volume table computed from tlv data*/
314 
315 	struct list_head list;	/* list in sdev control list */
316 };
317 
318 /* ASoC SOF DAPM widget */
319 struct snd_sof_widget {
320 	struct snd_sof_dev *sdev;
321 	int comp_id;
322 	int pipeline_id;
323 	int complete;
324 	int id;
325 
326 	struct snd_soc_dapm_widget *widget;
327 	struct list_head list;	/* list in sdev widget list */
328 
329 	void *private;		/* core does not touch this */
330 };
331 
332 /* ASoC SOF DAPM route */
333 struct snd_sof_route {
334 	struct snd_sof_dev *sdev;
335 
336 	struct snd_soc_dapm_route *route;
337 	struct list_head list;	/* list in sdev route list */
338 
339 	void *private;
340 };
341 
342 /* ASoC DAI device */
343 struct snd_sof_dai {
344 	struct snd_sof_dev *sdev;
345 	const char *name;
346 	const char *cpu_dai_name;
347 
348 	struct sof_ipc_comp_dai comp_dai;
349 	struct sof_ipc_dai_config *dai_config;
350 	struct list_head list;	/* list in sdev dai list */
351 };
352 
353 /*
354  * SOF Device Level.
355  */
356 struct snd_sof_dev {
357 	struct device *dev;
358 	spinlock_t ipc_lock;	/* lock for IPC users */
359 	spinlock_t hw_lock;	/* lock for HW IO access */
360 
361 	/*
362 	 * ASoC components. plat_drv fields are set dynamically so
363 	 * can't use const
364 	 */
365 	struct snd_soc_component_driver plat_drv;
366 
367 	/* DSP firmware boot */
368 	wait_queue_head_t boot_wait;
369 	u32 boot_complete;
370 	u32 first_boot;
371 
372 	/* work queue in case the probe is implemented in two steps */
373 	struct work_struct probe_work;
374 
375 	/* DSP HW differentiation */
376 	struct snd_sof_pdata *pdata;
377 
378 	/* IPC */
379 	struct snd_sof_ipc *ipc;
380 	struct snd_sof_mailbox dsp_box;		/* DSP initiated IPC */
381 	struct snd_sof_mailbox host_box;	/* Host initiated IPC */
382 	struct snd_sof_mailbox stream_box;	/* Stream position update */
383 	struct snd_sof_ipc_msg *msg;
384 	int ipc_irq;
385 	u32 next_comp_id; /* monotonic - reset during S3 */
386 
387 	/* memory bases for mmaped DSPs - set by dsp_init() */
388 	void __iomem *bar[SND_SOF_BARS];	/* DSP base address */
389 	int mmio_bar;
390 	int mailbox_bar;
391 	size_t dsp_oops_offset;
392 
393 	/* debug */
394 	struct dentry *debugfs_root;
395 	struct list_head dfsentry_list;
396 
397 	/* firmware loader */
398 	struct snd_dma_buffer dmab;
399 	struct snd_dma_buffer dmab_bdl;
400 	struct sof_ipc_fw_ready fw_ready;
401 	struct sof_ipc_fw_version fw_version;
402 
403 	/* topology */
404 	struct snd_soc_tplg_ops *tplg_ops;
405 	struct list_head pcm_list;
406 	struct list_head kcontrol_list;
407 	struct list_head widget_list;
408 	struct list_head dai_list;
409 	struct list_head route_list;
410 	struct snd_soc_component *component;
411 	u32 enabled_cores_mask; /* keep track of enabled cores */
412 
413 	/* FW configuration */
414 	struct sof_ipc_dma_buffer_data *info_buffer;
415 	struct sof_ipc_window *info_window;
416 
417 	/* IPC timeouts in ms */
418 	int ipc_timeout;
419 	int boot_timeout;
420 
421 	/* Wait queue for code loading */
422 	wait_queue_head_t waitq;
423 	int code_loading;
424 
425 	/* DMA for Trace */
426 	struct snd_dma_buffer dmatb;
427 	struct snd_dma_buffer dmatp;
428 	int dma_trace_pages;
429 	wait_queue_head_t trace_sleep;
430 	u32 host_offset;
431 	u32 dtrace_is_enabled;
432 	u32 dtrace_error;
433 	u32 dtrace_draining;
434 
435 	u32 msi_enabled;
436 
437 	void *private;			/* core does not touch this */
438 };
439 
440 /*
441  * Device Level.
442  */
443 
444 int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data);
445 int snd_sof_device_remove(struct device *dev);
446 
447 int snd_sof_runtime_suspend(struct device *dev);
448 int snd_sof_runtime_resume(struct device *dev);
449 int snd_sof_resume(struct device *dev);
450 int snd_sof_suspend(struct device *dev);
451 
452 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
453 
454 int snd_sof_create_page_table(struct snd_sof_dev *sdev,
455 			      struct snd_dma_buffer *dmab,
456 			      unsigned char *page_table, size_t size);
457 
458 /*
459  * Firmware loading.
460  */
461 int snd_sof_load_firmware(struct snd_sof_dev *sdev);
462 int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev);
463 int snd_sof_load_firmware_memcpy(struct snd_sof_dev *sdev);
464 int snd_sof_run_firmware(struct snd_sof_dev *sdev);
465 int snd_sof_parse_module_memcpy(struct snd_sof_dev *sdev,
466 				struct snd_sof_mod_hdr *module);
467 void snd_sof_fw_unload(struct snd_sof_dev *sdev);
468 int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset);
469 
470 /*
471  * IPC low level APIs.
472  */
473 struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev);
474 void snd_sof_ipc_free(struct snd_sof_dev *sdev);
475 int snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id);
476 void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev);
477 int snd_sof_ipc_stream_pcm_params(struct snd_sof_dev *sdev,
478 				  struct sof_ipc_pcm_params *params);
479 int snd_sof_dsp_mailbox_init(struct snd_sof_dev *sdev, u32 dspbox,
480 			     size_t dspbox_size, u32 hostbox,
481 			     size_t hostbox_size);
482 int snd_sof_ipc_valid(struct snd_sof_dev *sdev);
483 int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header,
484 		       void *msg_data, size_t msg_bytes, void *reply_data,
485 		       size_t reply_bytes);
486 struct snd_sof_widget *snd_sof_find_swidget(struct snd_sof_dev *sdev,
487 					    const char *name);
488 struct snd_sof_widget *snd_sof_find_swidget_sname(struct snd_sof_dev *sdev,
489 						  const char *pcm_name,
490 						  int dir);
491 struct snd_sof_dai *snd_sof_find_dai(struct snd_sof_dev *sdev,
492 				     const char *name);
493 
494 static inline
495 struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_sof_dev *sdev,
496 					  struct snd_soc_pcm_runtime *rtd)
497 {
498 	struct snd_sof_pcm *spcm = NULL;
499 
500 	list_for_each_entry(spcm, &sdev->pcm_list, list) {
501 		if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id)
502 			return spcm;
503 	}
504 
505 	return NULL;
506 }
507 
508 struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_sof_dev *sdev,
509 					   const char *name);
510 struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_sof_dev *sdev,
511 					   unsigned int comp_id,
512 					   int *direction);
513 struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_sof_dev *sdev,
514 					     unsigned int pcm_id);
515 void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
516 
517 /*
518  * Stream IPC
519  */
520 int snd_sof_ipc_stream_posn(struct snd_sof_dev *sdev,
521 			    struct snd_sof_pcm *spcm, int direction,
522 			    struct sof_ipc_stream_posn *posn);
523 
524 /*
525  * Mixer IPC
526  */
527 int snd_sof_ipc_set_get_comp_data(struct snd_sof_ipc *ipc,
528 				  struct snd_sof_control *scontrol, u32 ipc_cmd,
529 				  enum sof_ipc_ctrl_type ctrl_type,
530 				  enum sof_ipc_ctrl_cmd ctrl_cmd,
531 				  bool send);
532 
533 /*
534  * Topology.
535  * There is no snd_sof_free_topology since topology components will
536  * be freed by snd_soc_unregister_component,
537  */
538 int snd_sof_init_topology(struct snd_sof_dev *sdev,
539 			  struct snd_soc_tplg_ops *ops);
540 int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file);
541 int snd_sof_complete_pipeline(struct snd_sof_dev *sdev,
542 			      struct snd_sof_widget *swidget);
543 
544 int sof_load_pipeline_ipc(struct snd_sof_dev *sdev,
545 			  struct sof_ipc_pipe_new *pipeline,
546 			  struct sof_ipc_comp_reply *r);
547 
548 /*
549  * Trace/debug
550  */
551 int snd_sof_init_trace(struct snd_sof_dev *sdev);
552 void snd_sof_release_trace(struct snd_sof_dev *sdev);
553 void snd_sof_free_trace(struct snd_sof_dev *sdev);
554 int snd_sof_dbg_init(struct snd_sof_dev *sdev);
555 void snd_sof_free_debug(struct snd_sof_dev *sdev);
556 int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev,
557 			    void __iomem *base, size_t size,
558 			    const char *name,
559 			    enum sof_debugfs_access_type access_type);
560 int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
561 			     void *base, size_t size,
562 			     const char *name, mode_t mode);
563 int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
564 			     struct sof_ipc_dma_trace_posn *posn);
565 void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev);
566 void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
567 			u32 tracep_code, void *oops,
568 			struct sof_ipc_panic_info *panic_info,
569 			void *stack, size_t stack_words);
570 int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev);
571 
572 /*
573  * Platform specific ops.
574  */
575 extern struct snd_compr_ops sof_compressed_ops;
576 
577 /*
578  * Kcontrols.
579  */
580 
581 int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
582 		       struct snd_ctl_elem_value *ucontrol);
583 int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
584 		       struct snd_ctl_elem_value *ucontrol);
585 int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
586 		       struct snd_ctl_elem_value *ucontrol);
587 int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
588 		       struct snd_ctl_elem_value *ucontrol);
589 int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
590 		     struct snd_ctl_elem_value *ucontrol);
591 int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
592 		     struct snd_ctl_elem_value *ucontrol);
593 int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
594 		      struct snd_ctl_elem_value *ucontrol);
595 int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
596 		      struct snd_ctl_elem_value *ucontrol);
597 int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
598 			  const unsigned int __user *binary_data,
599 			  unsigned int size);
600 int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
601 			  unsigned int __user *binary_data,
602 			  unsigned int size);
603 
604 /*
605  * DSP Architectures.
606  */
607 static inline void sof_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack,
608 			     u32 stack_words)
609 {
610 	if (sof_arch_ops(sdev)->dsp_stack)
611 		sof_arch_ops(sdev)->dsp_stack(sdev, oops, stack, stack_words);
612 }
613 
614 static inline void sof_oops(struct snd_sof_dev *sdev, void *oops)
615 {
616 	if (sof_arch_ops(sdev)->dsp_oops)
617 		sof_arch_ops(sdev)->dsp_oops(sdev, oops);
618 }
619 
620 extern const struct sof_arch_ops sof_xtensa_arch_ops;
621 
622 /*
623  * Utilities
624  */
625 void sof_io_write(struct snd_sof_dev *sdev, void __iomem *addr, u32 value);
626 void sof_io_write64(struct snd_sof_dev *sdev, void __iomem *addr, u64 value);
627 u32 sof_io_read(struct snd_sof_dev *sdev, void __iomem *addr);
628 u64 sof_io_read64(struct snd_sof_dev *sdev, void __iomem *addr);
629 void sof_mailbox_write(struct snd_sof_dev *sdev, u32 offset,
630 		       void *message, size_t bytes);
631 void sof_mailbox_read(struct snd_sof_dev *sdev, u32 offset,
632 		      void *message, size_t bytes);
633 void sof_block_write(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *src,
634 		     size_t size);
635 void sof_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *dest,
636 		    size_t size);
637 
638 void intel_ipc_msg_data(struct snd_sof_dev *sdev,
639 			struct snd_pcm_substream *substream,
640 			void *p, size_t sz);
641 int intel_ipc_pcm_params(struct snd_sof_dev *sdev,
642 			 struct snd_pcm_substream *substream,
643 			 const struct sof_ipc_pcm_params_reply *reply);
644 
645 int intel_pcm_open(struct snd_sof_dev *sdev,
646 		   struct snd_pcm_substream *substream);
647 int intel_pcm_close(struct snd_sof_dev *sdev,
648 		    struct snd_pcm_substream *substream);
649 
650 #endif
651