alsa/0039-topology-Add-operations-parser.patch
OBS User mrdocs 37a7c30e09 Accepting request 320429 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes: surround41/50 chmap fix, UCM documents,
  config string fix, PCM timestamp query API, replacement of list.h
  with LGPL:
  0023-surround41-50.conf-Use-chmap-syntax-for-better-flexi.patch
  0024-ucm-docs-fix-doxygen-exclude-patch-for-UCM-local-hea.patch
  0025-ucm-docs-Fix-doxygen-formatting-for-UCM-main-page.patch
  0026-docs-Add-UCM-link-to-main-doxygen-page.patch
  0027-Replace-unsafe-characters-with-_-in-card-name.patch
  0028-pcm-add-helper-functions-to-query-timestamping-capab.patch
  0029-pcm-add-support-for-get-set_audio_htstamp_config.patch
  0030-pcm-add-support-for-new-STATUS_EXT-ioctl.patch
  0031-test-fix-audio_time-with-new-get-set-audio_tstamp_co.patch
  0032-test-audio_time-show-report-validity-and-accuracy.patch
  0033-pcm-restore-hw-params-on-set-latency-failed.patch
  0034-Replace-list.h-with-its-own-version.patch
- Backport topology API addition patches:
  0035-topology-uapi-Add-UAPI-headers-for-topology-ABI.patch
  0036-topology-Add-topology-core-parser.patch
  0037-topology-Add-text-section-parser.patch
  0038-topology-Add-PCM-parser.patch
  0039-topology-Add-operations-parser.patch
  0040-topology-Add-private-data-parser.patch
  0041-topology-Add-DAPM-object-parser.patch
  0042-topology-Add-CTL-parser.patch
  0043-topology-Add-Channel-map-parser.patch
  0044-topology-Add-binary-file-builder.patch
  0045-topology-autotools-Add-build-support-for-topology-co.patch
  0046-topology-doxygen-Add-doxygen-support-for-topology-co.patch
  0047-conf-topology-Add-topology-file-for-broadwell-audio-.patch
  0048-topology-Fix-missing-inclusion-of-ctype.h.patch

OBS-URL: https://build.opensuse.org/request/show/320429
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=186
2015-08-05 05:28:10 +00:00

108 lines
3.0 KiB
Diff

From 353f1eddb608a837157342155fc061f85bf0a5f8 Mon Sep 17 00:00:00 2001
From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Date: Wed, 29 Jul 2015 17:45:17 +0100
Subject: [PATCH 39/49] topology: Add operations parser
Parse operations so we can bind them to kcontrols in the kernel.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/topology/ops.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 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 000000000000..243d8c5e2bbc
--- /dev/null
+++ b/src/topology/ops.c
@@ -0,0 +1,84 @@
+/*
+ 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
+ */
+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.5.0