Skip to content

Commit d72d3d1

Browse files
committed
ASoC: SOF: partition audio-specific parts from the SOF core
This patch makes elaborate changes to the SOF core device structure and IPC RX/TX. At the high-level, the changes fall into 3 main categories: Audio-related members in the struct snd_sof_dev: These are now partiioned into struct sof_audio_dev that is created , maintained and used by the audio client. Along with these, all the other topology related structs for such as snd_sof_widget, snd_sof_route etc have all been moved to sof-audio.h. The snd_sof_dev member in all the topology related structs has been replaced with a member that represents the component driver that creates the topology. The sof_audio_dev handle that is created by the audio client is stored as private data in the MFD client struct but the core should never touch this. IPC TX/RX for MFD clients: IPC TX/RX for MFD clients can be performed by calling the sof_client_tx_message() API. If the clients want to receive IPC's from the DSP, they should register for the type of IPC's they'd like to receive. Audio-specific PM sequence: Previously, when the PCI device was resumed, the topology was reconstructed in its resume callback. But this will now be handled by the audio client device's resume callback. Also, the audio client's suspend callback should handle suspending streams. Signed-off-by: Ranjani Sridharan <[email protected]>
1 parent 8e3acba commit d72d3d1

17 files changed

+1299
-1121
lines changed

sound/soc/sof/control.c

+38-47
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/pm_runtime.h>
1414
#include "sof-priv.h"
15+
#include "sof-audio.h"
1516

1617
static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
1718
{
@@ -57,7 +58,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
5758
struct soc_mixer_control *sm =
5859
(struct soc_mixer_control *)kcontrol->private_value;
5960
struct snd_sof_control *scontrol = sm->dobj.private;
60-
struct snd_sof_dev *sdev = scontrol->sdev;
61+
struct snd_soc_component *scomp = scontrol->scomp;
6162
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
6263
unsigned int i, channels = scontrol->num_channels;
6364

@@ -70,12 +71,10 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
7071
}
7172

7273
/* notify DSP of mixer updates */
73-
if (pm_runtime_active(sdev->dev))
74-
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
75-
SOF_IPC_COMP_SET_VALUE,
76-
SOF_CTRL_TYPE_VALUE_CHAN_GET,
77-
SOF_CTRL_CMD_VOLUME,
78-
true);
74+
snd_sof_ipc_set_get_comp_data(scomp, scontrol,
75+
SOF_IPC_COMP_SET_VALUE,
76+
SOF_CTRL_TYPE_VALUE_CHAN_GET,
77+
SOF_CTRL_CMD_VOLUME, true);
7978

8079
return 0;
8180
}
@@ -102,7 +101,7 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
102101
struct soc_mixer_control *sm =
103102
(struct soc_mixer_control *)kcontrol->private_value;
104103
struct snd_sof_control *scontrol = sm->dobj.private;
105-
struct snd_sof_dev *sdev = scontrol->sdev;
104+
struct snd_soc_component *scomp = scontrol->scomp;
106105
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
107106
unsigned int i, channels = scontrol->num_channels;
108107

@@ -113,12 +112,10 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
113112
}
114113

115114
/* notify DSP of mixer updates */
116-
if (pm_runtime_active(sdev->dev))
117-
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
118-
SOF_IPC_COMP_SET_VALUE,
119-
SOF_CTRL_TYPE_VALUE_CHAN_GET,
120-
SOF_CTRL_CMD_SWITCH,
121-
true);
115+
snd_sof_ipc_set_get_comp_data(scomp, scontrol,
116+
SOF_IPC_COMP_SET_VALUE,
117+
SOF_CTRL_TYPE_VALUE_CHAN_GET,
118+
SOF_CTRL_CMD_SWITCH, true);
122119

123120
return 0;
124121
}
@@ -145,7 +142,7 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
145142
struct soc_enum *se =
146143
(struct soc_enum *)kcontrol->private_value;
147144
struct snd_sof_control *scontrol = se->dobj.private;
148-
struct snd_sof_dev *sdev = scontrol->sdev;
145+
struct snd_soc_component *scomp = scontrol->scomp;
149146
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
150147
unsigned int i, channels = scontrol->num_channels;
151148

@@ -156,12 +153,10 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
156153
}
157154

158155
/* notify DSP of enum updates */
159-
if (pm_runtime_active(sdev->dev))
160-
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
161-
SOF_IPC_COMP_SET_VALUE,
162-
SOF_CTRL_TYPE_VALUE_CHAN_GET,
163-
SOF_CTRL_CMD_ENUM,
164-
true);
156+
snd_sof_ipc_set_get_comp_data(scomp, scontrol,
157+
SOF_IPC_COMP_SET_VALUE,
158+
SOF_CTRL_TYPE_VALUE_CHAN_GET,
159+
SOF_CTRL_CMD_ENUM, true);
165160

166161
return 0;
167162
}
@@ -172,22 +167,22 @@ int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
172167
struct soc_bytes_ext *be =
173168
(struct soc_bytes_ext *)kcontrol->private_value;
174169
struct snd_sof_control *scontrol = be->dobj.private;
175-
struct snd_sof_dev *sdev = scontrol->sdev;
170+
struct snd_soc_component *scomp = scontrol->scomp;
176171
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
177172
struct sof_abi_hdr *data = cdata->data;
178173
size_t size;
179174
int ret = 0;
180175

181176
if (be->max > sizeof(ucontrol->value.bytes.data)) {
182-
dev_err_ratelimited(sdev->dev,
177+
dev_err_ratelimited(scomp->dev,
183178
"error: data max %d exceeds ucontrol data array size\n",
184179
be->max);
185180
return -EINVAL;
186181
}
187182

188183
size = data->size + sizeof(*data);
189184
if (size > be->max) {
190-
dev_err_ratelimited(sdev->dev,
185+
dev_err_ratelimited(scomp->dev,
191186
"error: DSP sent %zu bytes max is %d\n",
192187
size, be->max);
193188
ret = -EINVAL;
@@ -207,20 +202,20 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
207202
struct soc_bytes_ext *be =
208203
(struct soc_bytes_ext *)kcontrol->private_value;
209204
struct snd_sof_control *scontrol = be->dobj.private;
210-
struct snd_sof_dev *sdev = scontrol->sdev;
205+
struct snd_soc_component *scomp = scontrol->scomp;
211206
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
212207
struct sof_abi_hdr *data = cdata->data;
213208
size_t size = data->size + sizeof(*data);
214209

215210
if (be->max > sizeof(ucontrol->value.bytes.data)) {
216-
dev_err_ratelimited(sdev->dev,
211+
dev_err_ratelimited(scomp->dev,
217212
"error: data max %d exceeds ucontrol data array size\n",
218213
be->max);
219214
return -EINVAL;
220215
}
221216

222217
if (size > be->max) {
223-
dev_err_ratelimited(sdev->dev,
218+
dev_err_ratelimited(scomp->dev,
224219
"error: size too big %zu bytes max is %d\n",
225220
size, be->max);
226221
return -EINVAL;
@@ -230,12 +225,10 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
230225
memcpy(data, ucontrol->value.bytes.data, size);
231226

232227
/* notify DSP of byte control updates */
233-
if (pm_runtime_active(sdev->dev))
234-
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
235-
SOF_IPC_COMP_SET_DATA,
236-
SOF_CTRL_TYPE_DATA_SET,
237-
scontrol->cmd,
238-
true);
228+
snd_sof_ipc_set_get_comp_data(scomp, scontrol,
229+
SOF_IPC_COMP_SET_DATA,
230+
SOF_CTRL_TYPE_DATA_SET,
231+
scontrol->cmd, true);
239232

240233
return 0;
241234
}
@@ -247,7 +240,7 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
247240
struct soc_bytes_ext *be =
248241
(struct soc_bytes_ext *)kcontrol->private_value;
249242
struct snd_sof_control *scontrol = be->dobj.private;
250-
struct snd_sof_dev *sdev = scontrol->sdev;
243+
struct snd_soc_component *scomp = scontrol->scomp;
251244
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
252245
struct snd_ctl_tlv header;
253246
const struct snd_ctl_tlv __user *tlvd =
@@ -263,14 +256,14 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
263256

264257
/* be->max is coming from topology */
265258
if (header.length > be->max) {
266-
dev_err_ratelimited(sdev->dev, "error: Bytes data size %d exceeds max %d.\n",
259+
dev_err_ratelimited(scomp->dev, "error: Bytes data size %d exceeds max %d.\n",
267260
header.length, be->max);
268261
return -EINVAL;
269262
}
270263

271264
/* Check that header id matches the command */
272265
if (header.numid != scontrol->cmd) {
273-
dev_err_ratelimited(sdev->dev,
266+
dev_err_ratelimited(scomp->dev,
274267
"error: incorrect numid %d\n",
275268
header.numid);
276269
return -EINVAL;
@@ -280,30 +273,28 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
280273
return -EFAULT;
281274

282275
if (cdata->data->magic != SOF_ABI_MAGIC) {
283-
dev_err_ratelimited(sdev->dev,
276+
dev_err_ratelimited(scomp->dev,
284277
"error: Wrong ABI magic 0x%08x.\n",
285278
cdata->data->magic);
286279
return -EINVAL;
287280
}
288281

289282
if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi)) {
290-
dev_err_ratelimited(sdev->dev, "error: Incompatible ABI version 0x%08x.\n",
283+
dev_err_ratelimited(scomp->dev, "error: Incompatible ABI version 0x%08x.\n",
291284
cdata->data->abi);
292285
return -EINVAL;
293286
}
294287

295288
if (cdata->data->size + sizeof(const struct sof_abi_hdr) > be->max) {
296-
dev_err_ratelimited(sdev->dev, "error: Mismatch in ABI data size (truncated?).\n");
289+
dev_err_ratelimited(scomp->dev, "error: Mismatch in ABI data size (truncated?).\n");
297290
return -EINVAL;
298291
}
299292

300293
/* notify DSP of byte control updates */
301-
if (pm_runtime_active(sdev->dev))
302-
snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
303-
SOF_IPC_COMP_SET_DATA,
304-
SOF_CTRL_TYPE_DATA_SET,
305-
scontrol->cmd,
306-
true);
294+
snd_sof_ipc_set_get_comp_data(scomp, scontrol,
295+
SOF_IPC_COMP_SET_DATA,
296+
SOF_CTRL_TYPE_DATA_SET,
297+
scontrol->cmd, true);
307298

308299
return 0;
309300
}
@@ -315,7 +306,7 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
315306
struct soc_bytes_ext *be =
316307
(struct soc_bytes_ext *)kcontrol->private_value;
317308
struct snd_sof_control *scontrol = be->dobj.private;
318-
struct snd_sof_dev *sdev = scontrol->sdev;
309+
struct snd_soc_component *scomp = scontrol->scomp;
319310
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
320311
struct snd_ctl_tlv header;
321312
struct snd_ctl_tlv __user *tlvd =
@@ -338,7 +329,7 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
338329

339330
/* check data size doesn't exceed max coming from topology */
340331
if (data_size > be->max) {
341-
dev_err_ratelimited(sdev->dev, "error: user data size %d exceeds max size %d.\n",
332+
dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %d.\n",
342333
data_size, be->max);
343334
ret = -EINVAL;
344335
goto out;

0 commit comments

Comments
 (0)