From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Mark Brown <broonie@kernel.org>
Subject: [PATCH 06/13] topology: Add operations parser
Date: Mon, 29 Jun 2015 17:32:51 +0100 [thread overview]
Message-ID: <1435595578-6899-6-git-send-email-liam.r.girdwood@linux.intel.com> (raw)
In-Reply-To: <1435595578-6899-1-git-send-email-liam.r.girdwood@linux.intel.com>
Parse operations so we can bind them to kcontrols in the kernel.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
---
src/topology/ops.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
create mode 100644 src/topology/ops.c
diff --git a/src/topology/ops.c b/src/topology/ops.c
new file mode 100644
index 0000000..d3f4a28
--- /dev/null
+++ b/src/topology/ops.c
@@ -0,0 +1,90 @@
+/*
+ Copyright(c) 2014-2015 Intel Corporation
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ Authors: Mengdong Lin <mengdong.lin@intel.com>
+ Yao Jin <yao.jin@intel.com>
+ Liam Girdwood <liam.r.girdwood@linux.intel.com>
+*/
+
+#include "list.h"
+#include "tplg_local.h"
+
+/* mapping of kcontrol text names to types */
+static const struct map_elem control_map[] = {
+ {"volsw", SND_SOC_TPLG_CTL_VOLSW},
+ {"volsw_sx", SND_SOC_TPLG_CTL_VOLSW_SX},
+ {"volsw_xr_sx", SND_SOC_TPLG_CTL_VOLSW_XR_SX},
+ {"enum", SND_SOC_TPLG_CTL_ENUM},
+ {"bytes", SND_SOC_TPLG_CTL_BYTES},
+ {"enum_value", SND_SOC_TPLG_CTL_ENUM_VALUE},
+ {"range", SND_SOC_TPLG_CTL_RANGE},
+ {"strobe", SND_SOC_TPLG_CTL_STROBE},
+};
+
+static int lookup_ops(const char *c)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(control_map); i++) {
+ if (strcmp(control_map[i].name, c) == 0)
+ return control_map[i].id;
+ }
+
+ /* cant find string name in our table so we use its ID number */
+ return atoi(c);
+}
+
+/* Parse Control operations. Ops can come from standard names above or
+ * bespoke driver controls with numbers >= 256
+ *
+ * ops."name" {
+ * info "volsw"
+ * get "256"
+ * put "256"
+ * }
+ */
+int tplg_parse_ops(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
+ snd_config_t *cfg, void *private)
+{
+ snd_config_iterator_t i, next;
+ snd_config_t *n;
+ struct snd_soc_tplg_ctl_hdr *hdr = private;
+ const char *id, *value;
+
+ tplg_dbg("\tOps\n");
+ hdr->size = sizeof(*hdr);
+
+ snd_config_for_each(i, next, cfg) {
+
+ n = snd_config_iterator_entry(i);
+
+ /* get id */
+ if (snd_config_get_id(n, &id) < 0)
+ continue;
+
+ /* get value - try strings then ints */
+ if (snd_config_get_string(n, &value) < 0)
+ continue;
+
+ if (strcmp(id, "info") == 0)
+ hdr->ops.info = lookup_ops(value);
+ else if (strcmp(id, "put") == 0)
+ hdr->ops.put = lookup_ops(value);
+ else if (strcmp(id, "get") == 0)
+ hdr->ops.get = lookup_ops(value);
+
+ tplg_dbg("\t\t%s = %s\n", id, value);
+ }
+
+ return 0;
+}
--
2.1.4
next prev parent reply other threads:[~2015-06-29 16:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-29 16:32 [PATCH 01/13] topology: uapi: Add UAPI headers for topology ABI Liam Girdwood
2015-06-29 16:32 ` [PATCH 02/13] conf: topology: Add topology file for broadwell audio DSP Liam Girdwood
2015-06-29 16:32 ` [PATCH 03/13] topology: Add topology core parser Liam Girdwood
2015-06-29 16:32 ` [PATCH 04/13] topology: Add text section parser Liam Girdwood
2015-06-29 16:32 ` [PATCH 05/13] topology: Add PCM parser Liam Girdwood
2015-06-29 18:37 ` Takashi Iwai
2015-06-29 16:32 ` Liam Girdwood [this message]
2015-06-29 16:32 ` [PATCH 07/13] topology: Add private data parser Liam Girdwood
2015-06-29 18:41 ` Takashi Iwai
2015-06-29 16:32 ` [PATCH 08/13] topology: Add DAPM object parser Liam Girdwood
2015-06-29 18:43 ` Takashi Iwai
2015-06-29 16:32 ` [PATCH 09/13] topology: Add CTL parser Liam Girdwood
2015-06-29 16:32 ` [PATCH 10/13] topology: Add Channel map parser Liam Girdwood
2015-06-29 16:32 ` [PATCH 11/13] topology: Add binary file builder Liam Girdwood
2015-06-29 16:32 ` [PATCH 12/13] topology: autotools: Add build support for topology core Liam Girdwood
2015-06-29 16:32 ` [PATCH 13/13] topology: doxygen: Add doxygen " Liam Girdwood
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=1435595578-6899-6-git-send-email-liam.r.girdwood@linux.intel.com \
--to=liam.r.girdwood@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox