summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>2021-04-26 13:26:08 -0700
committerJaroslav Kysela <perex@perex.cz>2021-05-25 18:26:51 +0200
commit4bc386bb715ea303dfffe46d1da4d242ca1d3914 (patch)
treee2d3563bcf04b8909b08a6ffaab37fbbf78bd8a2
parentb0be2350244bd427aef448bf79336ee0f70648e0 (diff)
downloadalsa-utils-4bc386bb715ea303dfffe46d1da4d242ca1d3914.tar.gz
topology: pre-process-dai: add support for hwcfg objects
Add supprt for hwcfg objects: For ex: Object.Base.hw_config."SSP0 hw_config 0" { id 0 mclk_freq 24000000 bclk_freq 4800000 tdm_slot_width 25 } would get converted to: SectionHWConfig { 'SSP0 hw_config 0' { id 0 format I2S bclk codec_consumer bclk_freq 4800000 fsync codec_consumer fsync_freq 48000 mclk codec_mclk_in mclk_freq 24000000 tdm_slots 2 tdm_slot_width 25 tx_slots 3 rx_slots 3 } } and the corresponding SectionBE will be updated with the hwcfgs reference as: hw_configs [ 'SSP0 hw_config 0' ] Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--topology/Makefile.am2
-rw-r--r--topology/pre-process-dai.c47
-rw-r--r--topology/pre-process-object.c9
-rw-r--r--topology/pre-processor.h2
4 files changed, 59 insertions, 1 deletions
diff --git a/topology/Makefile.am b/topology/Makefile.am
index 7c9392c..7f77fdd 100644
--- a/topology/Makefile.am
+++ b/topology/Makefile.am
@@ -9,7 +9,7 @@ endif
rst2man $< > $@
alsatplg_SOURCES = topology.c pre-processor.c pre-process-class.c pre-process-object.c \
- pre-process-dapm.c
+ pre-process-dapm.c pre-process-dai.c
noinst_HEADERS = topology.h pre-processor.h
diff --git a/topology/pre-process-dai.c b/topology/pre-process-dai.c
new file mode 100644
index 0000000..a8e7901
--- /dev/null
+++ b/topology/pre-process-dai.c
@@ -0,0 +1,47 @@
+/*
+ Copyright(c) 2021 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ The full GNU General Public License is included in this distribution
+ in the file called LICENSE.GPL.
+*/
+#include <errno.h>
+#include <stdio.h>
+#include <alsa/input.h>
+#include <alsa/output.h>
+#include <alsa/conf.h>
+#include <alsa/error.h>
+#include "topology.h"
+#include "pre-processor.h"
+
+int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp,
+ snd_config_t *obj_cfg, snd_config_t *parent)
+{
+ snd_config_t *hw_cfg, *obj;
+ const char *name;
+ int ret;
+
+ obj = tplg_object_get_instance_config(tplg_pp, obj_cfg);
+
+ name = tplg_object_get_name(tplg_pp, obj);
+ if (!name)
+ return -EINVAL;
+
+ ret = tplg_build_object_from_template(tplg_pp, obj_cfg, &hw_cfg, NULL, false);
+ if (ret < 0)
+ return ret;
+
+ return tplg_parent_update(tplg_pp, parent, "hw_configs", name);
+}
diff --git a/topology/pre-process-object.c b/topology/pre-process-object.c
index 5a8f472..cbbdd63 100644
--- a/topology/pre-process-object.c
+++ b/topology/pre-process-object.c
@@ -858,6 +858,13 @@ static int tplg_build_generic_object(struct tplg_pre_processor *tplg_pp, snd_con
return ret;
}
+const struct config_template_items hwcfg_config = {
+ .int_config_ids = {"id", "bclk_freq", "bclk_invert", "fsync_invert", "fsync_freq",
+ "mclk_freq", "pm_gate_clocks", "tdm_slots", "tdm_slot_width",
+ "tx_slots", "rx_slots", "tx_channels", "rx_channels"},
+ .string_config_ids = {"format", "bclk", "fsync", "mclk"},
+};
+
const struct config_template_items be_dai_config = {
.int_config_ids = {"id", "default_hw_conf_id", "symmertic_rates", "symmetric_channels",
"symmetric_sample_bits"},
@@ -910,6 +917,8 @@ const struct build_function_map object_build_map[] = {
{"Base", "extops", "extops" ,&tplg_build_ops_object, &ops_config},
{"Base", "channel", "channel", &tplg_build_channel_object, &channel_config},
{"Base", "VendorToken", "SectionVendorTokens", &tplg_build_vendor_token_object, NULL},
+ {"Base", "hw_config", "SectionHWConfig", &tplg_build_hw_cfg_object,
+ &hwcfg_config},
{"Base", "route", "SectionGraph", &tplg_build_dapm_route_object, NULL},
{"Widget", "", "SectionWidget", &tplg_build_generic_object, &widget_config},
{"Control", "mixer", "SectionControlMixer", &tplg_build_mixer_control,
diff --git a/topology/pre-processor.h b/topology/pre-processor.h
index 9c31107..fd6e115 100644
--- a/topology/pre-processor.h
+++ b/topology/pre-processor.h
@@ -67,6 +67,8 @@ int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *o
snd_config_t *parent);
int tplg_build_dapm_route_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
snd_config_t *parent);
+int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp,
+ snd_config_t *obj_cfg, snd_config_t *parent);
int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
const char *section_name, const char *item_name);