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