summaryrefslogtreecommitdiff
path: root/src/topology
diff options
context:
space:
mode:
authorVedang Patel <vedang.patel@intel.com>2015-11-05 20:49:23 +0800
committerJaroslav Kysela <perex@perex.cz>2015-11-05 14:53:24 +0100
commit2286a6fd4de6e2eb4e16b50ceb253a9f934ae4b1 (patch)
treedc82473e0ee4d3bddf3529772df7a2ff20e5d440 /src/topology
parented5ee7ec2e00d8c2fe4d55a1c84946859b652f68 (diff)
downloadalsa-lib-2286a6fd4de6e2eb4e16b50ceb253a9f934ae4b1.tar.gz
topology: Add C API support for BE and CC Links.
Adding BE and CC Link support for C API reference. This will be used to populate the .hw_params element for BE and .params for CC, enabling us to update already existing DAI Links created by the kernel. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'src/topology')
-rw-r--r--src/topology/builder.c4
-rw-r--r--src/topology/parser.c3
-rw-r--r--src/topology/pcm.c46
3 files changed, 51 insertions, 2 deletions
diff --git a/src/topology/builder.c b/src/topology/builder.c
index 8d57a8b7..154bd630 100644
--- a/src/topology/builder.c
+++ b/src/topology/builder.c
@@ -221,10 +221,10 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base,
SND_SOC_TPLG_TYPE_PCM, "pcm");
case SND_TPLG_TYPE_BE:
return write_elem_block(tplg, base, size,
- SND_SOC_TPLG_TYPE_DAI_LINK, "be");
+ SND_SOC_TPLG_TYPE_BACKEND_LINK, "be");
case SND_TPLG_TYPE_CC:
return write_elem_block(tplg, base, size,
- SND_SOC_TPLG_TYPE_DAI_LINK, "cc");
+ SND_SOC_TPLG_TYPE_CODEC_LINK, "cc");
case SND_TPLG_TYPE_DATA:
return write_elem_block(tplg, base, size,
SND_SOC_TPLG_TYPE_PDATA, "data");
diff --git a/src/topology/parser.c b/src/topology/parser.c
index ab5ca1bc..1851459f 100644
--- a/src/topology/parser.c
+++ b/src/topology/parser.c
@@ -311,6 +311,9 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
return tplg_add_widget_object(tplg, t);
case SND_TPLG_TYPE_DAPM_GRAPH:
return tplg_add_graph_object(tplg, t);
+ case SND_TPLG_TYPE_BE:
+ case SND_TPLG_TYPE_CC:
+ return tplg_add_link_object(tplg, t);
default:
SNDERR("error: invalid object type %d\n", t->type);
return -EINVAL;
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index ec26f9c5..c2b2b981 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -480,3 +480,49 @@ int tplg_parse_cc(snd_tplg_t *tplg,
return 0;
}
+
+/* copy stream object */
+static void tplg_add_stream_object(struct snd_soc_tplg_stream *strm,
+ struct snd_tplg_stream_template *strm_tpl)
+{
+ elem_copy_text(strm->name, strm_tpl->name,
+ SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+ strm->format = strm_tpl->format;
+ strm->rate = strm_tpl->rate;
+ strm->period_bytes = strm_tpl->period_bytes;
+ strm->buffer_bytes = strm_tpl->buffer_bytes;
+ strm->channels = strm_tpl->channels;
+}
+
+int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
+{
+ struct snd_tplg_link_template *link = t->link;
+ struct snd_soc_tplg_link_config *lk;
+ struct tplg_elem *elem;
+ int i;
+
+ if (t->type != SND_TPLG_TYPE_BE && t->type != SND_TPLG_TYPE_CC)
+ return -EINVAL;
+
+ /* here type can be either BE or CC. */
+ elem = tplg_elem_new_common(tplg, NULL, link->name, t->type);
+ if (!elem)
+ return -ENOMEM;
+
+ if (t->type == SND_TPLG_TYPE_BE) {
+ tplg_dbg("BE Link: %s", link->name);
+ lk = elem->be;
+ } else {
+ tplg_dbg("CC Link: %s", link->name);
+ lk = elem->cc;
+ }
+
+ lk->size = elem->size;
+ lk->id = link->id;
+ lk->num_streams = link->num_streams;
+
+ for (i = 0; i < lk->num_streams; i++)
+ tplg_add_stream_object(&lk->stream[i], &link->stream[i]);
+
+ return 0;
+}