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