return 0;
}
-/* pass dynamic FEs configurations to component driver */
-static int soc_tplg_pcm_dai_load(struct soc_tplg *tplg,
- struct snd_soc_tplg_pcm_dai *pcm_dai, int num_pcm_dai)
+/* pass DAI configurations to component driver for extra intialization */
+static int soc_tplg_dai_load(struct soc_tplg *tplg,
+ struct snd_soc_dai_driver *dai_drv)
{
- if (tplg->comp && tplg->ops && tplg->ops->pcm_dai_load)
- return tplg->ops->pcm_dai_load(tplg->comp, pcm_dai, num_pcm_dai);
+ if (tplg->comp && tplg->ops && tplg->ops->dai_load)
+ return tplg->ops->dai_load(tplg->comp, dai_drv);
return 0;
}
/* widget w is freed by soc-dapm.c */
}
-/* remove PCM DAI configurations */
-static void remove_pcm_dai(struct snd_soc_component *comp,
+/* remove DAI configurations */
+static void remove_dai(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
+ struct snd_soc_dai_driver *dai_drv =
+ container_of(dobj, struct snd_soc_dai_driver, dobj);
+
if (pass != SOC_TPLG_PASS_PCM_DAI)
return;
- if (dobj->ops && dobj->ops->pcm_dai_unload)
- dobj->ops->pcm_dai_unload(comp, dobj);
+ if (dobj->ops && dobj->ops->dai_unload)
+ dobj->ops->dai_unload(comp, dobj);
list_del(&dobj->list);
- kfree(dobj);
+ kfree(dai_drv);
}
/* bind a kcontrol to it's IO handlers */
return 0;
}
-static int soc_tplg_pcm_dai_elems_load(struct soc_tplg *tplg,
+static int soc_tplg_dai_create(struct soc_tplg *tplg,
+ struct snd_soc_tplg_pcm *pcm)
+{
+ struct snd_soc_dai_driver *dai_drv;
+ struct snd_soc_pcm_stream *stream;
+ struct snd_soc_tplg_stream_caps *caps;
+ int ret;
+
+ dai_drv = kzalloc(sizeof(struct snd_soc_dai_driver), GFP_KERNEL);
+ if (dai_drv == NULL)
+ return -ENOMEM;
+
+ dai_drv->name = pcm->dai_name;
+ dai_drv->id = pcm->dai_id;
+
+ if (pcm->playback) {
+ stream = &dai_drv->playback;
+ caps = &pcm->caps[SND_SOC_TPLG_STREAM_PLAYBACK];
+
+ stream->stream_name = kstrdup(caps->name, GFP_KERNEL);
+ stream->channels_min = caps->channels_min;
+ stream->channels_max = caps->channels_max;
+ stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+ caps->rate_max);
+ stream->formats = caps->formats;
+ }
+
+ if (pcm->capture) {
+ stream = &dai_drv->capture;
+ caps = &pcm->caps[SND_SOC_TPLG_STREAM_CAPTURE];
+
+ stream->stream_name = kstrdup(caps->name, GFP_KERNEL);
+ stream->channels_min = caps->channels_min;
+ stream->channels_max = caps->channels_max;
+ stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+ caps->rate_max);
+ stream->formats = caps->formats;
+ }
+
+ /* pass control to component driver for optional further init */
+ ret = soc_tplg_dai_load(tplg, dai_drv);
+ if (ret < 0) {
+ dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
+ kfree(dai_drv);
+ return ret;
+ }
+
+ dai_drv->dobj.index = tplg->index;
+ dai_drv->dobj.ops = tplg->ops;
+ dai_drv->dobj.type = SND_SOC_DOBJ_PCM;
+ list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);
+
+ /* register the DAI to the component */
+ return snd_soc_register_dai(tplg->comp, dai_drv);
+}
+
+static int soc_tplg_pcm_create(struct soc_tplg *tplg,
+ struct snd_soc_tplg_pcm *pcm)
+{
+ return soc_tplg_dai_create(tplg, pcm);
+}
+
+static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
struct snd_soc_tplg_hdr *hdr)
{
- struct snd_soc_tplg_pcm_dai *pcm_dai;
- struct snd_soc_dobj *dobj;
+ struct snd_soc_tplg_pcm *pcm;
int count = hdr->count;
- int ret;
+ int i;
if (tplg->pass != SOC_TPLG_PASS_PCM_DAI)
return 0;
- pcm_dai = (struct snd_soc_tplg_pcm_dai *)tplg->pos;
+ pcm = (struct snd_soc_tplg_pcm *)tplg->pos;
if (soc_tplg_check_elem_count(tplg,
sizeof(struct snd_soc_tplg_pcm), count,
return -EINVAL;
}
+ /* create the FE DAIs and DAI links */
+ for (i = 0; i < count; i++) {
+ soc_tplg_pcm_create(tplg, pcm);
+ pcm++;
+ }
+
dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count);
tplg->pos += sizeof(struct snd_soc_tplg_pcm) * count;
- dobj = kzalloc(sizeof(struct snd_soc_dobj), GFP_KERNEL);
- if (dobj == NULL)
- return -ENOMEM;
-
- /* Call the platform driver call back to register the dais */
- ret = soc_tplg_pcm_dai_load(tplg, pcm_dai, count);
- if (ret < 0) {
- dev_err(tplg->comp->dev, "ASoC: PCM DAI loading failed\n");
- goto err;
- }
-
- dobj->type = get_dobj_type(hdr, NULL);
- dobj->pcm_dai.count = count;
- dobj->pcm_dai.pd = pcm_dai;
- dobj->ops = tplg->ops;
- dobj->index = tplg->index;
- list_add(&dobj->list, &tplg->comp->dobj_list);
return 0;
-
-err:
- kfree(dobj);
- return ret;
}
static int soc_tplg_manifest_load(struct soc_tplg *tplg,
case SND_SOC_TPLG_TYPE_DAPM_WIDGET:
return soc_tplg_dapm_widget_elems_load(tplg, hdr);
case SND_SOC_TPLG_TYPE_PCM:
- case SND_SOC_TPLG_TYPE_DAI_LINK:
- case SND_SOC_TPLG_TYPE_CODEC_LINK:
- return soc_tplg_pcm_dai_elems_load(tplg, hdr);
+ return soc_tplg_pcm_elems_load(tplg, hdr);
case SND_SOC_TPLG_TYPE_MANIFEST:
return soc_tplg_manifest_load(tplg, hdr);
default:
remove_widget(comp, dobj, pass);
break;
case SND_SOC_DOBJ_PCM:
- case SND_SOC_DOBJ_DAI_LINK:
- case SND_SOC_DOBJ_CODEC_LINK:
- remove_pcm_dai(comp, dobj, pass);
+ remove_dai(comp, dobj, pass);
break;
default:
dev_err(comp->dev, "ASoC: invalid component type %d for removal\n",