* [PATCH 1/5] ASoC: audio-graph-port: add link-trigger-order
2024-06-07 4:07 [PATCH 0/5] ASoC: simple-card / audio-graph: Kuninori Morimoto
@ 2024-06-07 4:15 ` Kuninori Morimoto
2024-06-10 22:09 ` Rob Herring
2024-06-07 4:15 ` [PATCH 2/5] ASoC: simple-card-utils: add link-trigger-order support Kuninori Morimoto
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2024-06-07 4:15 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski
Cc: Linux-ALSA, devicetree, Maxim Kochetkov
Some Sound Card might need special trigger ordering which is based on
CPU/Codec connection. It is already supported on ASoC, but Simple Audio
Card / Audio Graph Card still not support it. Let's support it.
Cc: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
.../devicetree/bindings/sound/audio-graph-port.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index 28b27e7e45de6..d1cbfc5edd3ac 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -25,6 +25,15 @@ definitions:
capture-only:
description: port connection used only for capture
$ref: /schemas/types.yaml#/definitions/flag
+ link-trigger-order:
+ description: trigger order for both start/stop
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ link-trigger-order-start:
+ description: trigger order for start
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ link-trigger-order-stop:
+ description: trigger order for stop
+ $ref: /schemas/types.yaml#/definitions/uint32-array
endpoint-base:
allOf:
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 1/5] ASoC: audio-graph-port: add link-trigger-order
2024-06-07 4:15 ` [PATCH 1/5] ASoC: audio-graph-port: add link-trigger-order Kuninori Morimoto
@ 2024-06-10 22:09 ` Rob Herring
2024-06-10 23:34 ` Kuninori Morimoto
0 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2024-06-10 22:09 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Mark Brown, Krzysztof Kozlowski, Linux-ALSA, devicetree,
Maxim Kochetkov
On Fri, Jun 07, 2024 at 04:15:01AM +0000, Kuninori Morimoto wrote:
> Some Sound Card might need special trigger ordering which is based on
> CPU/Codec connection. It is already supported on ASoC, but Simple Audio
> Card / Audio Graph Card still not support it. Let's support it.
I have no idea what trigger order means reading this patch.
>
> Cc: Maxim Kochetkov <fido_max@inbox.ru>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> .../devicetree/bindings/sound/audio-graph-port.yaml | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
> index 28b27e7e45de6..d1cbfc5edd3ac 100644
> --- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
> +++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
> @@ -25,6 +25,15 @@ definitions:
> capture-only:
> description: port connection used only for capture
> $ref: /schemas/types.yaml#/definitions/flag
> + link-trigger-order:
> + description: trigger order for both start/stop
> + $ref: /schemas/types.yaml#/definitions/uint32-array
> + link-trigger-order-start:
> + description: trigger order for start
> + $ref: /schemas/types.yaml#/definitions/uint32-array
> + link-trigger-order-stop:
> + description: trigger order for stop
> + $ref: /schemas/types.yaml#/definitions/uint32-array
constraints?
These are just definitions. Where are the properties defined?
>
> endpoint-base:
> allOf:
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/5] ASoC: audio-graph-port: add link-trigger-order
2024-06-10 22:09 ` Rob Herring
@ 2024-06-10 23:34 ` Kuninori Morimoto
0 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2024-06-10 23:34 UTC (permalink / raw)
To: Rob Herring
Cc: Mark Brown, Krzysztof Kozlowski, Linux-ALSA, devicetree,
Maxim Kochetkov
Hi Rob
> > Some Sound Card might need special trigger ordering which is based on
> > CPU/Codec connection. It is already supported on ASoC, but Simple Audio
> > Card / Audio Graph Card still not support it. Let's support it.
>
> I have no idea what trigger order means reading this patch.
Sound Card need to consider/adjust HW control ordering by the combination
of CPU vs Codec. It is called as trigger in this patch.
I will update git-log to more understandable it.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/5] ASoC: simple-card-utils: add link-trigger-order support
2024-06-07 4:07 [PATCH 0/5] ASoC: simple-card / audio-graph: Kuninori Morimoto
2024-06-07 4:15 ` [PATCH 1/5] ASoC: audio-graph-port: add link-trigger-order Kuninori Morimoto
@ 2024-06-07 4:15 ` Kuninori Morimoto
2024-06-10 22:09 ` Rob Herring
2024-06-07 4:15 ` [PATCH 3/5] ASoC: simple-audio-card: " Kuninori Morimoto
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2024-06-07 4:15 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski
Cc: Linux-ALSA, devicetree, Maxim Kochetkov
Some Sound Card might need special trigger ordering which is based on
CPU/Codec connection. It is already supported on ASoC, but Simple Audio
Card / Audio Graph Card still not support it. Let's support it.
Cc: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
include/dt-bindings/sound/audio-graph.h | 21 ++++++++
include/sound/simple_card_utils.h | 4 ++
sound/soc/generic/simple-card-utils.c | 71 +++++++++++++++++++++++++
3 files changed, 96 insertions(+)
create mode 100644 include/dt-bindings/sound/audio-graph.h
diff --git a/include/dt-bindings/sound/audio-graph.h b/include/dt-bindings/sound/audio-graph.h
new file mode 100644
index 0000000000000..7679f1c1c12ae
--- /dev/null
+++ b/include/dt-bindings/sound/audio-graph.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * audio-graph.h
+ *
+ * Copyright (c) 2024 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ */
+#ifndef __AUDIO_GRAPH_H
+#define __AUDIO_GRAPH_H
+
+/*
+ * used in
+ * link-trigger-order
+ * link-trigger-order-start
+ * link-trigger-order-stop
+ */
+#define SND_SOC_TRIGGER_LINK 0
+#define SND_SOC_TRIGGER_COMPONENT 1
+#define SND_SOC_TRIGGER_DAI 2
+#define SND_SOC_TRIGGER_SIZE 3 /* shoud be last */
+
+#endif /* __AUDIO_GRAPH_H */
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 0a6435ac5c5fe..3360d9eab068d 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -199,6 +199,10 @@ int graph_util_parse_dai(struct device *dev, struct device_node *ep,
void graph_util_parse_link_direction(struct device_node *np,
bool *is_playback_only, bool *is_capture_only);
+void graph_util_parse_trigger_order(struct simple_util_priv *priv,
+ struct device_node *np,
+ enum snd_soc_trigger_order *trigger_start,
+ enum snd_soc_trigger_order *trigger_stop);
#ifdef DEBUG
static inline void simple_util_debug_dai(struct simple_util_priv *priv,
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index dcd0569157cef..a18de86b3c882 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -4,6 +4,7 @@
//
// Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+#include <dt-bindings/sound/audio-graph.h>
#include <linux/clk.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
@@ -1156,6 +1157,76 @@ void graph_util_parse_link_direction(struct device_node *np,
}
EXPORT_SYMBOL_GPL(graph_util_parse_link_direction);
+static enum snd_soc_trigger_order
+__graph_util_parse_trigger_order(struct simple_util_priv *priv,
+ struct device_node *np,
+ const char *prop)
+{
+ u32 val[SND_SOC_TRIGGER_SIZE];
+ int ret;
+
+ ret = of_property_read_u32_array(np, prop, val, SND_SOC_TRIGGER_SIZE);
+ if (ret == 0) {
+ struct device *dev = simple_priv_to_dev(priv);
+ u32 order = (val[0] << 8) +
+ (val[1] << 4) +
+ (val[2]);
+
+ switch (order) {
+ case (SND_SOC_TRIGGER_LINK << 8) +
+ (SND_SOC_TRIGGER_COMPONENT << 4) +
+ (SND_SOC_TRIGGER_DAI):
+ return SND_SOC_TRIGGER_ORDER_DEFAULT;
+
+ case (SND_SOC_TRIGGER_LINK << 8) +
+ (SND_SOC_TRIGGER_DAI << 4) +
+ (SND_SOC_TRIGGER_COMPONENT):
+ return SND_SOC_TRIGGER_ORDER_LDC;
+
+ default:
+ dev_err(dev, "unsupported trigger order [0x%x]\n", order);
+ }
+ }
+
+ /* SND_SOC_TRIGGER_ORDER_MAX means error */
+ return SND_SOC_TRIGGER_ORDER_MAX;
+}
+
+void graph_util_parse_trigger_order(struct simple_util_priv *priv,
+ struct device_node *np,
+ enum snd_soc_trigger_order *trigger_start,
+ enum snd_soc_trigger_order *trigger_stop)
+{
+ static enum snd_soc_trigger_order order;
+
+ /*
+ * We can use it like below
+ *
+ * #include <dt-bindings/sound/audio-graph.h>
+ *
+ * link-trigger-order = <SND_SOC_TRIGGER_LINK
+ * SND_SOC_TRIGGER_COMPONENT
+ * SND_SOC_TRIGGER_DAI>;
+ */
+
+ order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order");
+ if (order < SND_SOC_TRIGGER_ORDER_MAX) {
+ *trigger_start = order;
+ *trigger_stop = order;
+ }
+
+ order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-start");
+ if (order < SND_SOC_TRIGGER_ORDER_MAX)
+ *trigger_start = order;
+
+ order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-stop");
+ if (order < SND_SOC_TRIGGER_ORDER_MAX)
+ *trigger_stop = order;
+
+ return;
+}
+EXPORT_SYMBOL_GPL(graph_util_parse_trigger_order);
+
/* Module information */
MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 2/5] ASoC: simple-card-utils: add link-trigger-order support
2024-06-07 4:15 ` [PATCH 2/5] ASoC: simple-card-utils: add link-trigger-order support Kuninori Morimoto
@ 2024-06-10 22:09 ` Rob Herring
0 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2024-06-10 22:09 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Mark Brown, Krzysztof Kozlowski, Linux-ALSA, devicetree,
Maxim Kochetkov
On Fri, Jun 07, 2024 at 04:15:10AM +0000, Kuninori Morimoto wrote:
> Some Sound Card might need special trigger ordering which is based on
> CPU/Codec connection. It is already supported on ASoC, but Simple Audio
> Card / Audio Graph Card still not support it. Let's support it.
>
> Cc: Maxim Kochetkov <fido_max@inbox.ru>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> include/dt-bindings/sound/audio-graph.h | 21 ++++++++
Belongs in the binding.
> include/sound/simple_card_utils.h | 4 ++
> sound/soc/generic/simple-card-utils.c | 71 +++++++++++++++++++++++++
> 3 files changed, 96 insertions(+)
> create mode 100644 include/dt-bindings/sound/audio-graph.h
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/5] ASoC: simple-audio-card: add link-trigger-order support
2024-06-07 4:07 [PATCH 0/5] ASoC: simple-card / audio-graph: Kuninori Morimoto
2024-06-07 4:15 ` [PATCH 1/5] ASoC: audio-graph-port: add link-trigger-order Kuninori Morimoto
2024-06-07 4:15 ` [PATCH 2/5] ASoC: simple-card-utils: add link-trigger-order support Kuninori Morimoto
@ 2024-06-07 4:15 ` Kuninori Morimoto
2024-06-07 4:15 ` [PATCH 4/5] ASoC: audio-graph-card: " Kuninori Morimoto
2024-06-07 4:15 ` [PATCH 5/5] ASoC: audio-graph-card2: " Kuninori Morimoto
4 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2024-06-07 4:15 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski
Cc: Linux-ALSA, devicetree, Maxim Kochetkov
Some Sound Card might need special trigger ordering which is based on
CPU/Codec connection. It is already supported on ASoC, but Simple Audio
Card still not yet support it. Let's support it.
Cc: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/generic/simple-card.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 2de5e6efe947f..edbb6322e9be2 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -176,6 +176,8 @@ static int simple_link_init(struct simple_util_priv *priv,
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
struct device_node *node = of_get_parent(cpu);
+ enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT;
+ enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT;
bool playback_only = 0, capture_only = 0;
int ret;
@@ -198,9 +200,17 @@ static int simple_link_init(struct simple_util_priv *priv,
of_property_read_u32(codec, "mclk-fs", &dai_props->mclk_fs);
of_property_read_u32(codec, PREFIX "mclk-fs", &dai_props->mclk_fs);
+ graph_util_parse_trigger_order(priv, top, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, node, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, codec, &trigger_start, &trigger_stop);
+
dai_link->playback_only = playback_only;
dai_link->capture_only = capture_only;
+ dai_link->trigger_start = trigger_start;
+ dai_link->trigger_stop = trigger_stop;
+
dai_link->init = simple_util_dai_init;
dai_link->ops = &simple_ops;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/5] ASoC: audio-graph-card: add link-trigger-order support
2024-06-07 4:07 [PATCH 0/5] ASoC: simple-card / audio-graph: Kuninori Morimoto
` (2 preceding siblings ...)
2024-06-07 4:15 ` [PATCH 3/5] ASoC: simple-audio-card: " Kuninori Morimoto
@ 2024-06-07 4:15 ` Kuninori Morimoto
2024-06-07 4:15 ` [PATCH 5/5] ASoC: audio-graph-card2: " Kuninori Morimoto
4 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2024-06-07 4:15 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski
Cc: Linux-ALSA, devicetree, Maxim Kochetkov
Some Sound Card might need special trigger ordering which is based on
CPU/Codec connection. It is already supported on ASoC, but Audio Graph
Card still not yet support it. Let's support it.
Cc: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/generic/audio-graph-card.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 7b981aa8690ac..acf7d92d21e60 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -143,6 +143,8 @@ static int graph_link_init(struct simple_util_priv *priv,
struct device_node *port_codec = ep_to_port(ep_codec);
struct device_node *ports_cpu = port_to_ports(port_cpu);
struct device_node *ports_codec = port_to_ports(port_codec);
+ enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT;
+ enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT;
bool playback_only = 0, capture_only = 0;
int ret;
@@ -165,9 +167,20 @@ static int graph_link_init(struct simple_util_priv *priv,
of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs);
of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs);
+ graph_util_parse_trigger_order(priv, top, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ports_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ports_codec, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ep_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ep_codec, &trigger_start, &trigger_stop);
+
dai_link->playback_only = playback_only;
dai_link->capture_only = capture_only;
+ dai_link->trigger_start = trigger_start;
+ dai_link->trigger_stop = trigger_stop;
+
dai_link->init = simple_util_dai_init;
dai_link->ops = &graph_ops;
if (priv->ops)
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/5] ASoC: audio-graph-card2: add link-trigger-order support
2024-06-07 4:07 [PATCH 0/5] ASoC: simple-card / audio-graph: Kuninori Morimoto
` (3 preceding siblings ...)
2024-06-07 4:15 ` [PATCH 4/5] ASoC: audio-graph-card: " Kuninori Morimoto
@ 2024-06-07 4:15 ` Kuninori Morimoto
4 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2024-06-07 4:15 UTC (permalink / raw)
To: Mark Brown, Rob Herring, Krzysztof Kozlowski
Cc: Linux-ALSA, devicetree, Maxim Kochetkov
Some Sound Card might need special trigger ordering which is based on
CPU/Codec connection. It is already supported on ASoC, but Audio Graph
Card2 still not yet support it. Let's support it.
Cc: Maxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/generic/audio-graph-card2.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 8eea818887580..abaf3c1719f31 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -759,6 +759,8 @@ static void graph_link_init(struct simple_util_priv *priv,
struct device_node *ports_cpu, *ports_codec;
unsigned int daifmt = 0, daiclk = 0;
bool playback_only = 0, capture_only = 0;
+ enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT;
+ enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT;
unsigned int bit_frame = 0;
of_node_get(port_cpu);
@@ -806,6 +808,14 @@ static void graph_link_init(struct simple_util_priv *priv,
of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs);
of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs);
+ graph_util_parse_trigger_order(priv, lnk, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ports_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ports_codec, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ep_cpu, &trigger_start, &trigger_stop);
+ graph_util_parse_trigger_order(priv, ep_codec, &trigger_start, &trigger_stop);
+
/*
* convert bit_frame
* We need to flip clock_provider if it was CPU node,
@@ -818,6 +828,9 @@ static void graph_link_init(struct simple_util_priv *priv,
dai_link->playback_only = playback_only;
dai_link->capture_only = capture_only;
+ dai_link->trigger_start = trigger_start;
+ dai_link->trigger_stop = trigger_stop;
+
dai_link->dai_fmt = daifmt | daiclk;
dai_link->init = simple_util_dai_init;
dai_link->ops = &graph_ops;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread