[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230715083046.108674-2-fido_max@inbox.ru>
Date: Sat, 15 Jul 2023 11:30:42 +0300
From: Maxim Kochetkov <fido_max@...ox.ru>
To: alsa-devel@...a-project.org
Cc: Maxim Kochetkov <fido_max@...ox.ru>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>,
Sameer Pujar <spujar@...dia.com>,
Linus Walleij <linus.walleij@...aro.org>,
Aidan MacDonald <aidanmacdonald.0x0@...il.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Astrid Rost <astrid.rost@...s.com>,
Herve Codina <herve.codina@...tlin.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2] ASoC: simple-card-utils: introduce asoc_simple_parse_triggers()
This function parses DT DAI link triggers params and assigns
the appropriate fields in struct snd_soc_dai_link.
It supports two triggers trigger-stop and trigger-start.
Signed-off-by: Maxim Kochetkov <fido_max@...ox.ru>
---
include/sound/simple_card_utils.h | 3 ++
sound/soc/generic/simple-card-utils.c | 45 +++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index b450d5873227..ea8c17f7b280 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -180,6 +180,9 @@ int asoc_simple_parse_widgets(struct snd_soc_card *card,
char *prefix);
int asoc_simple_parse_pin_switches(struct snd_soc_card *card,
char *prefix);
+int asoc_simple_parse_triggers(struct device_node *node,
+ char *prefix,
+ struct snd_soc_dai_link *dai_link);
int asoc_simple_init_jack(struct snd_soc_card *card,
struct asoc_simple_jack *sjack,
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 3019626b0592..58f5c672184a 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -737,6 +737,51 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card *card,
}
EXPORT_SYMBOL_GPL(asoc_simple_parse_pin_switches);
+static enum snd_soc_trigger_order asoc_simple_parse_trigger(
+ struct device_node *node,
+ char *prefix,
+ char *trigger_name)
+{
+ enum snd_soc_trigger_order trigger = SND_SOC_TRIGGER_ORDER_DEFAULT;
+ struct {
+ char *name;
+ unsigned int val;
+ } of_trigger_table[] = {
+ { "default", SND_SOC_TRIGGER_ORDER_DEFAULT },
+ { "ldc", SND_SOC_TRIGGER_ORDER_LDC },
+ };
+ const char *str;
+ char prop[128];
+ int ret;
+
+ if (!prefix)
+ prefix = "";
+
+ snprintf(prop, sizeof(prop), "%s%s", prefix, trigger_name);
+
+ ret = of_property_read_string(node, prop, &str);
+ if (ret == 0) {
+ for (int i = 0; i < ARRAY_SIZE(of_trigger_table); i++) {
+ if (strcmp(str, of_trigger_table[i].name) == 0) {
+ trigger = of_trigger_table[i].val;
+ break;
+ }
+ }
+ }
+
+ return trigger;
+}
+
+int asoc_simple_parse_triggers(struct device_node *node,
+ char *prefix,
+ struct snd_soc_dai_link *dai_link)
+{
+ dai_link->trigger_stop = asoc_simple_parse_trigger(node, prefix, "trigger-stop");
+ dai_link->trigger_start = asoc_simple_parse_trigger(node, prefix, "trigger-start");
+ return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_parse_triggers);
+
int asoc_simple_init_jack(struct snd_soc_card *card,
struct asoc_simple_jack *sjack,
int is_hp, char *prefix,
--
2.40.1
Powered by blists - more mailing lists