diff options
author | Mengdong Lin <mengdong.lin@linux.intel.com> | 2016-11-06 13:14:34 +0800 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-11-08 16:33:22 +0100 |
commit | a182ab29c677311e288b7bba115f497c194187f7 (patch) | |
tree | 27ef4e5d004c155bbaf43c37e8d736321430ded6 | |
parent | c33b3a0ea2f9e9241b2f80a15a5944c50a6798e0 (diff) | |
download | alsa-lib-a182ab29c677311e288b7bba115f497c194187f7.tar.gz |
topology: Parse name and stream name of physical DAI links
Parse name and stream name of physical links defined by text conf file
or C API. Add name and stream name to C API template of physical DAI
links.
These two fields will help topology kernel driver to find an existing
physical link to configure, since the id of links are often the default
value ZERO and useless for match.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/topology.h | 6 | ||||
-rw-r--r-- | src/topology/pcm.c | 19 |
2 files changed, 24 insertions, 1 deletions
diff --git a/include/topology.h b/include/topology.h index ad84c155..66dd084f 100644 --- a/include/topology.h +++ b/include/topology.h @@ -631,6 +631,8 @@ extern "C" { * * id "0" # used for binding to the link * + * stream_name "name" # used for binding to the link + * * hw_configs [ # runtime supported HW configurations, optional * "config1" * "config2" @@ -985,8 +987,10 @@ struct snd_tplg_hw_config_template { * \brief Template type for BE and CC DAI Links. */ struct snd_tplg_link_template { - const char *name; /*!< link name */ + const char *name; /*!< link name, used to match */ int id; /*!< unique ID - used to match with existing BE and CC links */ + const char *stream_name; /*!< link stream name, used to match */ + int num_streams; /*!< number of configs */ struct snd_tplg_stream_template *stream; /*!< supported configs */ diff --git a/src/topology/pcm.c b/src/topology/pcm.c index 1d70396f..a9d32772 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -622,6 +622,7 @@ int tplg_parse_link(snd_tplg_t *tplg, link = elem->link; link->size = elem->size; + elem_copy_text(link->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); tplg_dbg(" Link: %s\n", elem->id); @@ -655,6 +656,16 @@ int tplg_parse_link(snd_tplg_t *tplg, continue; } + if (strcmp(id, "stream_name") == 0) { + if (snd_config_get_string(n, &val) < 0) + return -EINVAL; + + elem_copy_text(link->stream_name, val, + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + tplg_dbg("\t%s: %s\n", id, val); + continue; + } + if (strcmp(id, "hw_configs") == 0) { err = parse_hw_config_refs(tplg, n, elem); if (err < 0) @@ -1030,7 +1041,15 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) link = elem->link; link->size = elem->size; + /* ID and names */ link->id = link_tpl->id; + if (link->name) + elem_copy_text(link->name, link_tpl->name, + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + if (link->stream_name) + elem_copy_text(link->stream_name, link_tpl->stream_name, + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + /* stream configs */ if (link_tpl->num_streams > SND_SOC_TPLG_STREAM_CONFIG_MAX) return -EINVAL; |