Skip to content

Commit 753132f

Browse files
committed
Introduce IPC abstraction for SOF topology parsing
Merge series from Ranjani Sridharan <ranjani.sridharan@linux.intel.com>: This patchset makes the topology parsing layer in the SOF driver IPC-agnostic in preparation for supporting the new IPC version introduced in the SOF firmware. These patches purely contain abstraction changes for the current IPC version (IPC3) supported and do not introduce any functional changes.
2 parents 835ca59 + 61ad28f commit 753132f

9 files changed

Lines changed: 2941 additions & 2399 deletions

File tree

sound/soc/sof/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
22

33
snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\
4-
control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o
4+
control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\
5+
ipc3-topology.o
56
ifneq ($(CONFIG_SND_SOC_SOF_CLIENT),)
67
snd-sof-objs += sof-client.o
78
endif

sound/soc/sof/control.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static inline u32 ipc_to_mixer(u32 value, u32 *volume_map, int size)
6767

6868
static void snd_sof_refresh_control(struct snd_sof_control *scontrol)
6969
{
70-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
70+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
7171
struct snd_soc_component *scomp = scontrol->scomp;
7272
int ret;
7373

@@ -97,7 +97,7 @@ int snd_sof_volume_get(struct snd_kcontrol *kcontrol,
9797
struct soc_mixer_control *sm =
9898
(struct soc_mixer_control *)kcontrol->private_value;
9999
struct snd_sof_control *scontrol = sm->dobj.private;
100-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
100+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
101101
unsigned int i, channels = scontrol->num_channels;
102102

103103
snd_sof_refresh_control(scontrol);
@@ -118,7 +118,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
118118
(struct soc_mixer_control *)kcontrol->private_value;
119119
struct snd_sof_control *scontrol = sm->dobj.private;
120120
struct snd_soc_component *scomp = scontrol->scomp;
121-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
121+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
122122
unsigned int i, channels = scontrol->num_channels;
123123
bool change = false;
124124
u32 value;
@@ -166,7 +166,7 @@ int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
166166
struct soc_mixer_control *sm =
167167
(struct soc_mixer_control *)kcontrol->private_value;
168168
struct snd_sof_control *scontrol = sm->dobj.private;
169-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
169+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
170170
unsigned int i, channels = scontrol->num_channels;
171171

172172
snd_sof_refresh_control(scontrol);
@@ -185,7 +185,7 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
185185
(struct soc_mixer_control *)kcontrol->private_value;
186186
struct snd_sof_control *scontrol = sm->dobj.private;
187187
struct snd_soc_component *scomp = scontrol->scomp;
188-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
188+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
189189
unsigned int i, channels = scontrol->num_channels;
190190
bool change = false;
191191
u32 value;
@@ -214,7 +214,7 @@ int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
214214
struct soc_enum *se =
215215
(struct soc_enum *)kcontrol->private_value;
216216
struct snd_sof_control *scontrol = se->dobj.private;
217-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
217+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
218218
unsigned int i, channels = scontrol->num_channels;
219219

220220
snd_sof_refresh_control(scontrol);
@@ -233,7 +233,7 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
233233
(struct soc_enum *)kcontrol->private_value;
234234
struct snd_sof_control *scontrol = se->dobj.private;
235235
struct snd_soc_component *scomp = scontrol->scomp;
236-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
236+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
237237
unsigned int i, channels = scontrol->num_channels;
238238
bool change = false;
239239
u32 value;
@@ -260,7 +260,7 @@ int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,
260260
(struct soc_bytes_ext *)kcontrol->private_value;
261261
struct snd_sof_control *scontrol = be->dobj.private;
262262
struct snd_soc_component *scomp = scontrol->scomp;
263-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
263+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
264264
struct sof_abi_hdr *data = cdata->data;
265265
size_t size;
266266

@@ -296,7 +296,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
296296
(struct soc_bytes_ext *)kcontrol->private_value;
297297
struct snd_sof_control *scontrol = be->dobj.private;
298298
struct snd_soc_component *scomp = scontrol->scomp;
299-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
299+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
300300
struct sof_abi_hdr *data = cdata->data;
301301
size_t size;
302302

@@ -335,7 +335,7 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
335335
(struct soc_bytes_ext *)kcontrol->private_value;
336336
struct snd_sof_control *scontrol = be->dobj.private;
337337
struct snd_soc_component *scomp = scontrol->scomp;
338-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
338+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
339339
struct snd_ctl_tlv header;
340340
const struct snd_ctl_tlv __user *tlvd =
341341
(const struct snd_ctl_tlv __user *)binary_data;
@@ -409,7 +409,7 @@ int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _
409409
struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value;
410410
struct snd_sof_control *scontrol = be->dobj.private;
411411
struct snd_soc_component *scomp = scontrol->scomp;
412-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
412+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
413413
struct snd_ctl_tlv header;
414414
struct snd_ctl_tlv __user *tlvd = (struct snd_ctl_tlv __user *)binary_data;
415415
size_t data_size;
@@ -482,7 +482,7 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
482482
(struct soc_bytes_ext *)kcontrol->private_value;
483483
struct snd_sof_control *scontrol = be->dobj.private;
484484
struct snd_soc_component *scomp = scontrol->scomp;
485-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
485+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
486486
struct snd_ctl_tlv header;
487487
struct snd_ctl_tlv __user *tlvd =
488488
(struct snd_ctl_tlv __user *)binary_data;
@@ -534,7 +534,7 @@ static void snd_sof_update_control(struct snd_sof_control *scontrol,
534534
struct sof_ipc_ctrl_data *local_cdata;
535535
int i;
536536

537-
local_cdata = scontrol->control_data;
537+
local_cdata = scontrol->ipc_control_data;
538538

539539
if (cdata->cmd == SOF_CTRL_CMD_BINARY) {
540540
if (cdata->num_elems != local_cdata->data->size) {

sound/soc/sof/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
370370
INIT_LIST_HEAD(&sdev->kcontrol_list);
371371
INIT_LIST_HEAD(&sdev->widget_list);
372372
INIT_LIST_HEAD(&sdev->dai_list);
373+
INIT_LIST_HEAD(&sdev->dai_link_list);
373374
INIT_LIST_HEAD(&sdev->route_list);
374375
INIT_LIST_HEAD(&sdev->ipc_client_list);
375376
INIT_LIST_HEAD(&sdev->ipc_rx_handler_list);

sound/soc/sof/ipc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
812812
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, bool set)
813813
{
814814
struct snd_soc_component *scomp = scontrol->scomp;
815-
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
815+
struct sof_ipc_ctrl_data *cdata = scontrol->ipc_control_data;
816816
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
817817
struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
818818
struct sof_ipc_fw_version *v = &ready->version;
@@ -1023,6 +1023,18 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
10231023

10241024
init_waitqueue_head(&msg->waitq);
10251025

1026+
/*
1027+
* Use IPC3 ops as it is the only available version now. With the addition of new IPC
1028+
* versions, this will need to be modified to use the selected version at runtime.
1029+
*/
1030+
ipc->ops = &ipc3_ops;
1031+
1032+
/* check for mandatory ops */
1033+
if (!ipc->ops->tplg || !ipc->ops->tplg->widget) {
1034+
dev_err(sdev->dev, "Invalid topology IPC ops\n");
1035+
return NULL;
1036+
}
1037+
10261038
return ipc;
10271039
}
10281040
EXPORT_SYMBOL(snd_sof_ipc_init);

0 commit comments

Comments
 (0)