All of lore.kernel.org
 help / color / mirror / Atom feed
From: mengdong.lin@linux.intel.com
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Mengdong Lin <mengdong.lin@linux.intel.com>,
	tiwai@suse.de, mengdong.lin@intel.com,
	guneshwor.o.singh@intel.com, liam.r.girdwood@intel.com,
	hardik.t.shah@intel.com
Subject: [PATCH v2 5/6] topology: Parse front-end DAI name and ID for the PCM
Date: Fri, 29 Apr 2016 11:03:37 +0800	[thread overview]
Message-ID: <8258fa6bb9d5009dc9f2bb73194defc7251907cd.1461898635.git.mengdong.lin@linux.intel.com> (raw)
In-Reply-To: <cover.1461898635.git.mengdong.lin@linux.intel.com>

From: Mengdong Lin <mengdong.lin@linux.intel.com>

These two fields are necessary to create the front-end DAIs
in kernel but the support is missing in text conf previously.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/topology.h b/include/topology.h
index b47f422..9d57ce3 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -533,6 +533,10 @@ extern "C" {
  *
  *	id "0"				# used for binding to the PCM
  *
+ *	dai."name of front-end DAI" {
+ *		id "0"		# used for binding to the front-end DAI
+ *	}
+ *
  *	pcm."playback" {
  *		capabilities "capabilities1"	# capabilities for playback
  *
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 1661821..efee58b 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -320,6 +320,51 @@ static int tplg_parse_streams(snd_tplg_t *tplg, snd_config_t *cfg,
 	return 0;
 }
 
+/* Parse name and id of a front-end DAI (ie. cpu dai of a FE DAI link) */
+static int tplg_parse_fe_dai(snd_tplg_t *tplg, snd_config_t *cfg,
+	void *private)
+{
+	struct tplg_elem *elem = private;
+	struct snd_soc_tplg_pcm *pcm = elem->pcm;
+	snd_config_iterator_t i, next;
+	snd_config_t *n;
+	const char *id, *value = NULL;
+	unsigned long int id_val;
+	int err;
+
+	snd_config_get_id(cfg, &id);
+	tplg_dbg("\t\tFE DAI %s:\n", id);
+	elem_copy_text(pcm->dai_name, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+
+	snd_config_for_each(i, next, cfg) {
+
+		n = snd_config_iterator_entry(i);
+
+		/* get id */
+		if (snd_config_get_id(n, &id) < 0)
+			continue;
+
+		if (strcmp(id, "id") == 0) {
+			if (snd_config_get_string(n, &value) < 0)
+				continue;
+			errno = 0;
+			/* no support for negative value */
+			id_val = strtoul(value, NULL, 0);
+			if ((errno == ERANGE && id_val == ULONG_MAX)
+				|| (errno != 0 && id_val == 0)
+				|| id_val > UINT_MAX) {
+				SNDERR("error: invalid fe dai ID\n");
+				return -EINVAL;
+			}
+
+			pcm->dai_id = (int) id_val;
+			tplg_dbg("\t\t\tindex: %d\n", pcm->dai_id);
+		}
+	}
+
+	return 0;
+}
+
 /* Parse pcm (for front end DAI & DAI link) */
 int tplg_parse_pcm(snd_tplg_t *tplg,
 	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
@@ -378,6 +423,14 @@ int tplg_parse_pcm(snd_tplg_t *tplg,
 				return err;
 			continue;
 		}
+
+		if (strcmp(id, "dai") == 0) {
+			err = tplg_parse_compound(tplg, n,
+				tplg_parse_fe_dai, elem);
+			if (err < 0)
+				return err;
+			continue;
+		}
 	}
 
 	return 0;
-- 
2.5.0

  parent reply	other threads:[~2016-04-29  3:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29  3:02 [PATCH v2 0/6] topology: complete PCM parsing and code refactoring mengdong.lin
2016-04-29  3:02 ` [PATCH v2 1/6] topology: Set manifest size for ABI mengdong.lin
2016-04-29  3:03 ` [PATCH v2 2/6] topology: Refactor functions to parse and build streams mengdong.lin
2016-04-29  3:03 ` [PATCH v2 3/6] topology: Use generic pointer to realloc buffer for private data mengdong.lin
2016-04-29  3:03 ` [PATCH v2 4/6] topology: Fix pcm ID & name parsing mengdong.lin
2016-04-29  3:03 ` mengdong.lin [this message]
2016-04-29  3:03 ` [PATCH v2 6/6] topology: Update PCM configurations in Broadwell text conf file mengdong.lin
2016-05-09  8:34 ` [PATCH v2 0/6] topology: complete PCM parsing and code refactoring Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8258fa6bb9d5009dc9f2bb73194defc7251907cd.1461898635.git.mengdong.lin@linux.intel.com \
    --to=mengdong.lin@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=guneshwor.o.singh@intel.com \
    --cc=hardik.t.shah@intel.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=mengdong.lin@intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.