Skip to content

Commit c60b613

Browse files
lrgirdwobroonie
authored andcommitted
ASoC: topology: Give more data to clients via callbacks
Give topology clients more access to the topology data by passing index, pcm, link_config and dai_driver to clients. This allows clients to fully instantiate and track topology objects. The SOF driver is the first user of these new APIs and needs them to build component topology driver and FW objects. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ce397d2 commit c60b613

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

include/sound/soc-topology.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ struct snd_soc_dapm_context;
3030
struct snd_soc_card;
3131
struct snd_kcontrol_new;
3232
struct snd_soc_dai_link;
33+
struct snd_soc_dai_driver;
34+
struct snd_soc_dai;
3335

3436
/* object scan be loaded and unloaded in groups with identfying indexes */
3537
#define SND_SOC_TPLG_INDEX_ALL 0 /* ID that matches all FW objects */
@@ -109,35 +111,38 @@ struct snd_soc_tplg_widget_events {
109111
struct snd_soc_tplg_ops {
110112

111113
/* external kcontrol init - used for any driver specific init */
112-
int (*control_load)(struct snd_soc_component *,
114+
int (*control_load)(struct snd_soc_component *, int index,
113115
struct snd_kcontrol_new *, struct snd_soc_tplg_ctl_hdr *);
114116
int (*control_unload)(struct snd_soc_component *,
115117
struct snd_soc_dobj *);
116118

117119
/* external widget init - used for any driver specific init */
118-
int (*widget_load)(struct snd_soc_component *,
120+
int (*widget_load)(struct snd_soc_component *, int index,
119121
struct snd_soc_dapm_widget *,
120122
struct snd_soc_tplg_dapm_widget *);
121-
int (*widget_ready)(struct snd_soc_component *,
123+
int (*widget_ready)(struct snd_soc_component *, int index,
122124
struct snd_soc_dapm_widget *,
123125
struct snd_soc_tplg_dapm_widget *);
124126
int (*widget_unload)(struct snd_soc_component *,
125127
struct snd_soc_dobj *);
126128

127129
/* FE DAI - used for any driver specific init */
128-
int (*dai_load)(struct snd_soc_component *,
129-
struct snd_soc_dai_driver *dai_drv);
130+
int (*dai_load)(struct snd_soc_component *, int index,
131+
struct snd_soc_dai_driver *dai_drv,
132+
struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai);
133+
130134
int (*dai_unload)(struct snd_soc_component *,
131135
struct snd_soc_dobj *);
132136

133137
/* DAI link - used for any driver specific init */
134-
int (*link_load)(struct snd_soc_component *,
135-
struct snd_soc_dai_link *link);
138+
int (*link_load)(struct snd_soc_component *, int index,
139+
struct snd_soc_dai_link *link,
140+
struct snd_soc_tplg_link_config *cfg);
136141
int (*link_unload)(struct snd_soc_component *,
137142
struct snd_soc_dobj *);
138143

139144
/* callback to handle vendor bespoke data */
140-
int (*vendor_load)(struct snd_soc_component *,
145+
int (*vendor_load)(struct snd_soc_component *, int index,
141146
struct snd_soc_tplg_hdr *);
142147
int (*vendor_unload)(struct snd_soc_component *,
143148
struct snd_soc_tplg_hdr *);
@@ -146,7 +151,7 @@ struct snd_soc_tplg_ops {
146151
void (*complete)(struct snd_soc_component *);
147152

148153
/* manifest - optional to inform component of manifest */
149-
int (*manifest)(struct snd_soc_component *,
154+
int (*manifest)(struct snd_soc_component *, int index,
150155
struct snd_soc_tplg_manifest *);
151156

152157
/* vendor specific kcontrol handlers available for binding */

sound/soc/intel/skylake/skl-pcm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,11 @@ static struct snd_soc_dai_driver skl_platform_dai[] = {
10171017
},
10181018
};
10191019

1020-
int skl_dai_load(struct snd_soc_component *cmp,
1021-
struct snd_soc_dai_driver *pcm_dai)
1020+
int skl_dai_load(struct snd_soc_component *cmp, int index,
1021+
struct snd_soc_dai_driver *dai_drv,
1022+
struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
10221023
{
1023-
pcm_dai->ops = &skl_pcm_dai_ops;
1024+
dai_drv->ops = &skl_pcm_dai_ops;
10241025

10251026
return 0;
10261027
}

sound/soc/intel/skylake/skl-topology.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,7 +3024,7 @@ void skl_cleanup_resources(struct skl *skl)
30243024
* information to the driver about module and pipeline parameters which DSP
30253025
* FW expects like ids, resource values, formats etc
30263026
*/
3027-
static int skl_tplg_widget_load(struct snd_soc_component *cmpnt,
3027+
static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, int index,
30283028
struct snd_soc_dapm_widget *w,
30293029
struct snd_soc_tplg_dapm_widget *tplg_w)
30303030
{
@@ -3131,6 +3131,7 @@ static int skl_init_enum_data(struct device *dev, struct soc_enum *se,
31313131
}
31323132

31333133
static int skl_tplg_control_load(struct snd_soc_component *cmpnt,
3134+
int index,
31343135
struct snd_kcontrol_new *kctl,
31353136
struct snd_soc_tplg_ctl_hdr *hdr)
31363137
{
@@ -3619,7 +3620,7 @@ static int skl_tplg_get_manifest_data(struct snd_soc_tplg_manifest *manifest,
36193620
return 0;
36203621
}
36213622

3622-
static int skl_manifest_load(struct snd_soc_component *cmpnt,
3623+
static int skl_manifest_load(struct snd_soc_component *cmpnt, int index,
36233624
struct snd_soc_tplg_manifest *manifest)
36243625
{
36253626
struct hdac_ext_bus *ebus = snd_soc_component_get_drvdata(cmpnt);

sound/soc/intel/skylake/skl-topology.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,9 @@ int skl_pcm_host_dma_prepare(struct device *dev,
512512
int skl_pcm_link_dma_prepare(struct device *dev,
513513
struct skl_pipe_params *params);
514514

515-
int skl_dai_load(struct snd_soc_component *cmp,
516-
struct snd_soc_dai_driver *pcm_dai);
515+
int skl_dai_load(struct snd_soc_component *cmp, int index,
516+
struct snd_soc_dai_driver *dai_drv,
517+
struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai);
517518
void skl_tplg_add_moduleid_in_bind_params(struct skl *skl,
518519
struct snd_soc_dapm_widget *w);
519520
#endif

sound/soc/soc-topology.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int soc_tplg_vendor_load_(struct soc_tplg *tplg,
259259
int ret = 0;
260260

261261
if (tplg->comp && tplg->ops && tplg->ops->vendor_load)
262-
ret = tplg->ops->vendor_load(tplg->comp, hdr);
262+
ret = tplg->ops->vendor_load(tplg->comp, tplg->index, hdr);
263263
else {
264264
dev_err(tplg->dev, "ASoC: no vendor load callback for ID %d\n",
265265
hdr->vendor_type);
@@ -291,7 +291,8 @@ static int soc_tplg_widget_load(struct soc_tplg *tplg,
291291
struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w)
292292
{
293293
if (tplg->comp && tplg->ops && tplg->ops->widget_load)
294-
return tplg->ops->widget_load(tplg->comp, w, tplg_w);
294+
return tplg->ops->widget_load(tplg->comp, tplg->index, w,
295+
tplg_w);
295296

296297
return 0;
297298
}
@@ -302,27 +303,30 @@ static int soc_tplg_widget_ready(struct soc_tplg *tplg,
302303
struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w)
303304
{
304305
if (tplg->comp && tplg->ops && tplg->ops->widget_ready)
305-
return tplg->ops->widget_ready(tplg->comp, w, tplg_w);
306+
return tplg->ops->widget_ready(tplg->comp, tplg->index, w,
307+
tplg_w);
306308

307309
return 0;
308310
}
309311

310312
/* pass DAI configurations to component driver for extra initialization */
311313
static int soc_tplg_dai_load(struct soc_tplg *tplg,
312-
struct snd_soc_dai_driver *dai_drv)
314+
struct snd_soc_dai_driver *dai_drv,
315+
struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai)
313316
{
314317
if (tplg->comp && tplg->ops && tplg->ops->dai_load)
315-
return tplg->ops->dai_load(tplg->comp, dai_drv);
318+
return tplg->ops->dai_load(tplg->comp, tplg->index, dai_drv,
319+
pcm, dai);
316320

317321
return 0;
318322
}
319323

320324
/* pass link configurations to component driver for extra initialization */
321325
static int soc_tplg_dai_link_load(struct soc_tplg *tplg,
322-
struct snd_soc_dai_link *link)
326+
struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg)
323327
{
324328
if (tplg->comp && tplg->ops && tplg->ops->link_load)
325-
return tplg->ops->link_load(tplg->comp, link);
329+
return tplg->ops->link_load(tplg->comp, tplg->index, link, cfg);
326330

327331
return 0;
328332
}
@@ -643,7 +647,8 @@ static int soc_tplg_init_kcontrol(struct soc_tplg *tplg,
643647
struct snd_kcontrol_new *k, struct snd_soc_tplg_ctl_hdr *hdr)
644648
{
645649
if (tplg->comp && tplg->ops && tplg->ops->control_load)
646-
return tplg->ops->control_load(tplg->comp, k, hdr);
650+
return tplg->ops->control_load(tplg->comp, tplg->index, k,
651+
hdr);
647652

648653
return 0;
649654
}
@@ -1702,7 +1707,7 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
17021707
dai_drv->compress_new = snd_soc_new_compress;
17031708

17041709
/* pass control to component driver for optional further init */
1705-
ret = soc_tplg_dai_load(tplg, dai_drv);
1710+
ret = soc_tplg_dai_load(tplg, dai_drv, pcm, NULL);
17061711
if (ret < 0) {
17071712
dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
17081713
kfree(dai_drv);
@@ -1772,7 +1777,7 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
17721777
set_link_flags(link, pcm->flag_mask, pcm->flags);
17731778

17741779
/* pass control to component driver for optional further init */
1775-
ret = soc_tplg_dai_link_load(tplg, link);
1780+
ret = soc_tplg_dai_link_load(tplg, link, NULL);
17761781
if (ret < 0) {
17771782
dev_err(tplg->comp->dev, "ASoC: FE link loading failed\n");
17781783
kfree(link);
@@ -2080,7 +2085,7 @@ static int soc_tplg_link_config(struct soc_tplg *tplg,
20802085
set_link_flags(link, cfg->flag_mask, cfg->flags);
20812086

20822087
/* pass control to component driver for optional further init */
2083-
ret = soc_tplg_dai_link_load(tplg, link);
2088+
ret = soc_tplg_dai_link_load(tplg, link, cfg);
20842089
if (ret < 0) {
20852090
dev_err(tplg->dev, "ASoC: physical link loading failed\n");
20862091
return ret;
@@ -2202,7 +2207,7 @@ static int soc_tplg_dai_config(struct soc_tplg *tplg,
22022207
set_dai_flags(dai_drv, d->flag_mask, d->flags);
22032208

22042209
/* pass control to component driver for optional further init */
2205-
ret = soc_tplg_dai_load(tplg, dai_drv);
2210+
ret = soc_tplg_dai_load(tplg, dai_drv, NULL, dai);
22062211
if (ret < 0) {
22072212
dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
22082213
return ret;
@@ -2311,7 +2316,7 @@ static int soc_tplg_manifest_load(struct soc_tplg *tplg,
23112316

23122317
/* pass control to component driver for optional further init */
23132318
if (tplg->comp && tplg->ops && tplg->ops->manifest)
2314-
return tplg->ops->manifest(tplg->comp, _manifest);
2319+
return tplg->ops->manifest(tplg->comp, tplg->index, _manifest);
23152320

23162321
if (!abi_match) /* free the duplicated one */
23172322
kfree(_manifest);

0 commit comments

Comments
 (0)