1
2
3
4
5
6
7
8
9
10
11#ifndef __SOUND_SOC_SOF_AUDIO_H
12#define __SOUND_SOC_SOF_AUDIO_H
13
14#include <linux/workqueue.h>
15
16#include <sound/soc.h>
17#include <sound/control.h>
18#include <sound/sof/stream.h>
19#include <sound/sof/control.h>
20#include <sound/sof/dai.h>
21#include <sound/sof/topology.h>
22#include "sof-priv.h"
23
24#define SOF_AUDIO_PCM_DRV_NAME "sof-audio-component"
25
26
27#define SOF_BE_PCM_BASE 16
28
29#define DMA_CHAN_INVALID 0xFFFFFFFF
30
31
32struct snd_sof_pcm_stream {
33 u32 comp_id;
34 struct snd_dma_buffer page_table;
35 struct sof_ipc_stream_posn posn;
36 struct snd_pcm_substream *substream;
37 struct work_struct period_elapsed_work;
38 bool d0i3_compatible;
39
40
41
42
43 bool suspend_ignored;
44};
45
46
47struct snd_sof_pcm {
48 struct snd_soc_component *scomp;
49 struct snd_soc_tplg_pcm pcm;
50 struct snd_sof_pcm_stream stream[2];
51 struct list_head list;
52 struct snd_pcm_hw_params params[2];
53 bool prepared[2];
54};
55
56struct snd_sof_led_control {
57 unsigned int use_led;
58 unsigned int direction;
59 int led_value;
60};
61
62
63struct snd_sof_control {
64 struct snd_soc_component *scomp;
65 int comp_id;
66 int min_volume_step;
67 int max_volume_step;
68 int num_channels;
69 u32 readback_offset;
70 struct sof_ipc_ctrl_data *control_data;
71 u32 size;
72 enum sof_ipc_ctrl_cmd cmd;
73 u32 *volume_table;
74
75 struct list_head list;
76
77 struct snd_sof_led_control led_ctl;
78};
79
80
81struct snd_sof_widget {
82 struct snd_soc_component *scomp;
83 int comp_id;
84 int pipeline_id;
85 int complete;
86 int core;
87 int id;
88
89 struct snd_soc_dapm_widget *widget;
90 struct list_head list;
91
92
93 struct sof_ipc_comp_ext comp_ext;
94
95 void *private;
96};
97
98
99struct snd_sof_route {
100 struct snd_soc_component *scomp;
101
102 struct snd_soc_dapm_route *route;
103 struct list_head list;
104
105 void *private;
106};
107
108
109struct snd_sof_dai {
110 struct snd_soc_component *scomp;
111 const char *name;
112 const char *cpu_dai_name;
113
114 struct sof_ipc_comp_dai comp_dai;
115 int number_configs;
116 int current_config;
117 struct sof_ipc_dai_config *dai_config;
118 struct list_head list;
119};
120
121
122
123
124
125int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
126 struct snd_ctl_elem_value *ucontrol);
127int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
128 struct snd_ctl_elem_value *ucontrol);
129int snd_sof_volume_info(struct snd_kcontrol *kcontrol,
130 struct snd_ctl_elem_info *uinfo);
131int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
132 struct snd_ctl_elem_value *ucontrol);
133int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
134 struct snd_ctl_elem_value *ucontrol);
135int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
136 struct snd_ctl_elem_value *ucontrol);
137int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
138 struct snd_ctl_elem_value *ucontrol);
139int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
140 struct snd_ctl_elem_value *ucontrol);
141int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
142 struct snd_ctl_elem_value *ucontrol);
143int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
144 const unsigned int __user *binary_data,
145 unsigned int size);
146int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
147 unsigned int __user *binary_data,
148 unsigned int size);
149int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data,
150 unsigned int size);
151
152
153
154
155
156
157int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file);
158int snd_sof_complete_pipeline(struct device *dev,
159 struct snd_sof_widget *swidget);
160
161int sof_load_pipeline_ipc(struct device *dev,
162 struct sof_ipc_pipe_new *pipeline,
163 struct sof_ipc_comp_reply *r);
164int sof_pipeline_core_enable(struct snd_sof_dev *sdev,
165 const struct snd_sof_widget *swidget);
166
167
168
169
170int snd_sof_ipc_stream_posn(struct snd_soc_component *scomp,
171 struct snd_sof_pcm *spcm, int direction,
172 struct sof_ipc_stream_posn *posn);
173
174struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp,
175 const char *name);
176struct snd_sof_widget *
177snd_sof_find_swidget_sname(struct snd_soc_component *scomp,
178 const char *pcm_name, int dir);
179struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp,
180 const char *name);
181
182static inline
183struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_soc_component *scomp,
184 struct snd_soc_pcm_runtime *rtd)
185{
186 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
187
188 struct snd_sof_pcm *spcm = NULL;
189
190 list_for_each_entry(spcm, &sdev->pcm_list, list) {
191 if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id)
192 return spcm;
193 }
194
195 return NULL;
196}
197
198struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp,
199 const char *name);
200struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
201 unsigned int comp_id,
202 int *direction);
203struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp,
204 unsigned int pcm_id);
205const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
206 int pipeline_id);
207void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
208void snd_sof_pcm_period_elapsed_work(struct work_struct *work);
209
210
211
212
213int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
214 u32 ipc_cmd,
215 enum sof_ipc_ctrl_type ctrl_type,
216 enum sof_ipc_ctrl_cmd ctrl_cmd,
217 bool send);
218
219
220int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
221
222
223int sof_restore_pipelines(struct device *dev);
224int sof_set_hw_params_upon_resume(struct device *dev);
225bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
226bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);
227
228
229int sof_machine_register(struct snd_sof_dev *sdev, void *pdata);
230void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata);
231
232#endif
233