From e4237a250de8fd415a5f118f2993a8a6ba4260c1 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Fri, 4 Nov 2016 07:07:58 +0800 Subject: [PATCH] topology: Define a function to build a single PCM element Code refactoring. Rename tplg_build_pcm() to tplg_build_pcms() to build all PCM (FE DAI & DAI link) elements. It will call a new function build_pcm() to build a single PCM elemement. build_pcm() will be extended to handle more properties of a PCM. Signed-off-by: Mengdong Lin Signed-off-by: Takashi Iwai --- src/topology/parser.c | 2 +- src/topology/pcm.c | 18 +++++++++++++++--- src/topology/tplg_local.h | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/topology/parser.c b/src/topology/parser.c index 3ab64f4f..7b2c8799 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -267,7 +267,7 @@ static int tplg_build_integ(snd_tplg_t *tplg) if (err < 0) return err; - err = tplg_build_pcm(tplg, SND_TPLG_TYPE_PCM); + err = tplg_build_pcms(tplg, SND_TPLG_TYPE_PCM); if (err < 0) return err; diff --git a/src/topology/pcm.c b/src/topology/pcm.c index bd70dc95..77b76056 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -70,8 +70,20 @@ static int tplg_build_stream_caps(snd_tplg_t *tplg, return 0; } -/* build FE DAI/PCM configurations */ -int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type) +/* build a PCM (FE DAI & DAI link) element */ +static int build_pcm(snd_tplg_t *tplg, struct tplg_elem *elem) +{ + int err; + + err = tplg_build_stream_caps(tplg, elem->id, elem->pcm->caps); + if (err < 0) + return err; + + return 0; +} + +/* build all PCM (FE DAI & DAI link) elements */ +int tplg_build_pcms(snd_tplg_t *tplg, unsigned int type) { struct list_head *base, *pos; struct tplg_elem *elem; @@ -86,7 +98,7 @@ int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type) return -EINVAL; } - err = tplg_build_stream_caps(tplg, elem->id, elem->pcm->caps); + err = build_pcm(tplg, elem); if (err < 0) return err; diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index cfde4cc5..7b30b849 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -284,7 +284,7 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, int tplg_add_bytes(snd_tplg_t *tplg, struct snd_tplg_bytes_template *bytes_ctl, struct tplg_elem **e); -int tplg_build_pcm(snd_tplg_t *tplg, unsigned int type); +int tplg_build_pcms(snd_tplg_t *tplg, unsigned int type); int tplg_build_link_cfg(snd_tplg_t *tplg, unsigned int type); int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t); int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t); -- 2.47.1