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