Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: simple-card / audio-graph:

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Introduce the ability for sound cards to manually order the startup of
the various components in the card.

+146
+9
Documentation/devicetree/bindings/sound/audio-graph-port.yaml
··· 25 25 capture-only: 26 26 description: port connection used only for capture 27 27 $ref: /schemas/types.yaml#/definitions/flag 28 + link-trigger-order: 29 + description: trigger order for both start/stop 30 + $ref: /schemas/types.yaml#/definitions/uint32-array 31 + link-trigger-order-start: 32 + description: trigger order for start 33 + $ref: /schemas/types.yaml#/definitions/uint32-array 34 + link-trigger-order-stop: 35 + description: trigger order for stop 36 + $ref: /schemas/types.yaml#/definitions/uint32-array 28 37 29 38 endpoint-base: 30 39 allOf:
+26
include/dt-bindings/sound/audio-graph.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 2 + * 3 + * audio-graph.h 4 + * 5 + * Copyright (c) 2024 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 + */ 7 + #ifndef __AUDIO_GRAPH_H 8 + #define __AUDIO_GRAPH_H 9 + 10 + /* 11 + * used in 12 + * link-trigger-order 13 + * link-trigger-order-start 14 + * link-trigger-order-stop 15 + * 16 + * default is 17 + * link-trigger-order = <SND_SOC_TRIGGER_LINK 18 + * SND_SOC_TRIGGER_COMPONENT 19 + * SND_SOC_TRIGGER_DAI>; 20 + */ 21 + #define SND_SOC_TRIGGER_LINK 0 22 + #define SND_SOC_TRIGGER_COMPONENT 1 23 + #define SND_SOC_TRIGGER_DAI 2 24 + #define SND_SOC_TRIGGER_SIZE 3 /* shoud be last */ 25 + 26 + #endif /* __AUDIO_GRAPH_H */
+4
include/sound/simple_card_utils.h
··· 199 199 200 200 void graph_util_parse_link_direction(struct device_node *np, 201 201 bool *is_playback_only, bool *is_capture_only); 202 + void graph_util_parse_trigger_order(struct simple_util_priv *priv, 203 + struct device_node *np, 204 + enum snd_soc_trigger_order *trigger_start, 205 + enum snd_soc_trigger_order *trigger_stop); 202 206 203 207 #ifdef DEBUG 204 208 static inline void simple_util_debug_dai(struct simple_util_priv *priv,
+13
sound/soc/generic/audio-graph-card.c
··· 143 143 struct device_node *port_codec = ep_to_port(ep_codec); 144 144 struct device_node *ports_cpu = port_to_ports(port_cpu); 145 145 struct device_node *ports_codec = port_to_ports(port_codec); 146 + enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; 147 + enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT; 146 148 bool playback_only = 0, capture_only = 0; 147 149 int ret; 148 150 ··· 167 165 of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs); 168 166 of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs); 169 167 168 + graph_util_parse_trigger_order(priv, top, &trigger_start, &trigger_stop); 169 + graph_util_parse_trigger_order(priv, ports_cpu, &trigger_start, &trigger_stop); 170 + graph_util_parse_trigger_order(priv, ports_codec, &trigger_start, &trigger_stop); 171 + graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop); 172 + graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop); 173 + graph_util_parse_trigger_order(priv, ep_cpu, &trigger_start, &trigger_stop); 174 + graph_util_parse_trigger_order(priv, ep_codec, &trigger_start, &trigger_stop); 175 + 170 176 dai_link->playback_only = playback_only; 171 177 dai_link->capture_only = capture_only; 178 + 179 + dai_link->trigger_start = trigger_start; 180 + dai_link->trigger_stop = trigger_stop; 172 181 173 182 dai_link->init = simple_util_dai_init; 174 183 dai_link->ops = &graph_ops;
+13
sound/soc/generic/audio-graph-card2.c
··· 759 759 struct device_node *ports_cpu, *ports_codec; 760 760 unsigned int daifmt = 0, daiclk = 0; 761 761 bool playback_only = 0, capture_only = 0; 762 + enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; 763 + enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT; 762 764 unsigned int bit_frame = 0; 763 765 764 766 of_node_get(port_cpu); ··· 808 806 of_property_read_u32(ep_cpu, "mclk-fs", &dai_props->mclk_fs); 809 807 of_property_read_u32(ep_codec, "mclk-fs", &dai_props->mclk_fs); 810 808 809 + graph_util_parse_trigger_order(priv, lnk, &trigger_start, &trigger_stop); 810 + graph_util_parse_trigger_order(priv, ports_cpu, &trigger_start, &trigger_stop); 811 + graph_util_parse_trigger_order(priv, ports_codec, &trigger_start, &trigger_stop); 812 + graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop); 813 + graph_util_parse_trigger_order(priv, port_cpu, &trigger_start, &trigger_stop); 814 + graph_util_parse_trigger_order(priv, ep_cpu, &trigger_start, &trigger_stop); 815 + graph_util_parse_trigger_order(priv, ep_codec, &trigger_start, &trigger_stop); 816 + 811 817 /* 812 818 * convert bit_frame 813 819 * We need to flip clock_provider if it was CPU node, ··· 827 817 828 818 dai_link->playback_only = playback_only; 829 819 dai_link->capture_only = capture_only; 820 + 821 + dai_link->trigger_start = trigger_start; 822 + dai_link->trigger_stop = trigger_stop; 830 823 831 824 dai_link->dai_fmt = daifmt | daiclk; 832 825 dai_link->init = simple_util_dai_init;
+71
sound/soc/generic/simple-card-utils.c
··· 4 4 // 5 5 // Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 6 7 + #include <dt-bindings/sound/audio-graph.h> 7 8 #include <linux/clk.h> 8 9 #include <linux/gpio/consumer.h> 9 10 #include <linux/module.h> ··· 1156 1155 *capture_only = is_capture_only; 1157 1156 } 1158 1157 EXPORT_SYMBOL_GPL(graph_util_parse_link_direction); 1158 + 1159 + static enum snd_soc_trigger_order 1160 + __graph_util_parse_trigger_order(struct simple_util_priv *priv, 1161 + struct device_node *np, 1162 + const char *prop) 1163 + { 1164 + u32 val[SND_SOC_TRIGGER_SIZE]; 1165 + int ret; 1166 + 1167 + ret = of_property_read_u32_array(np, prop, val, SND_SOC_TRIGGER_SIZE); 1168 + if (ret == 0) { 1169 + struct device *dev = simple_priv_to_dev(priv); 1170 + u32 order = (val[0] << 8) + 1171 + (val[1] << 4) + 1172 + (val[2]); 1173 + 1174 + switch (order) { 1175 + case (SND_SOC_TRIGGER_LINK << 8) + 1176 + (SND_SOC_TRIGGER_COMPONENT << 4) + 1177 + (SND_SOC_TRIGGER_DAI): 1178 + return SND_SOC_TRIGGER_ORDER_DEFAULT; 1179 + 1180 + case (SND_SOC_TRIGGER_LINK << 8) + 1181 + (SND_SOC_TRIGGER_DAI << 4) + 1182 + (SND_SOC_TRIGGER_COMPONENT): 1183 + return SND_SOC_TRIGGER_ORDER_LDC; 1184 + 1185 + default: 1186 + dev_err(dev, "unsupported trigger order [0x%x]\n", order); 1187 + } 1188 + } 1189 + 1190 + /* SND_SOC_TRIGGER_ORDER_MAX means error */ 1191 + return SND_SOC_TRIGGER_ORDER_MAX; 1192 + } 1193 + 1194 + void graph_util_parse_trigger_order(struct simple_util_priv *priv, 1195 + struct device_node *np, 1196 + enum snd_soc_trigger_order *trigger_start, 1197 + enum snd_soc_trigger_order *trigger_stop) 1198 + { 1199 + static enum snd_soc_trigger_order order; 1200 + 1201 + /* 1202 + * We can use it like below 1203 + * 1204 + * #include <dt-bindings/sound/audio-graph.h> 1205 + * 1206 + * link-trigger-order = <SND_SOC_TRIGGER_LINK 1207 + * SND_SOC_TRIGGER_COMPONENT 1208 + * SND_SOC_TRIGGER_DAI>; 1209 + */ 1210 + 1211 + order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order"); 1212 + if (order < SND_SOC_TRIGGER_ORDER_MAX) { 1213 + *trigger_start = order; 1214 + *trigger_stop = order; 1215 + } 1216 + 1217 + order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-start"); 1218 + if (order < SND_SOC_TRIGGER_ORDER_MAX) 1219 + *trigger_start = order; 1220 + 1221 + order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-stop"); 1222 + if (order < SND_SOC_TRIGGER_ORDER_MAX) 1223 + *trigger_stop = order; 1224 + 1225 + return; 1226 + } 1227 + EXPORT_SYMBOL_GPL(graph_util_parse_trigger_order); 1159 1228 1160 1229 /* Module information */ 1161 1230 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
+10
sound/soc/generic/simple-card.c
··· 176 176 struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); 177 177 struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link); 178 178 struct device_node *node = of_get_parent(cpu); 179 + enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT; 180 + enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT; 179 181 bool playback_only = 0, capture_only = 0; 180 182 int ret; 181 183 ··· 200 198 of_property_read_u32(codec, "mclk-fs", &dai_props->mclk_fs); 201 199 of_property_read_u32(codec, PREFIX "mclk-fs", &dai_props->mclk_fs); 202 200 201 + graph_util_parse_trigger_order(priv, top, &trigger_start, &trigger_stop); 202 + graph_util_parse_trigger_order(priv, node, &trigger_start, &trigger_stop); 203 + graph_util_parse_trigger_order(priv, cpu, &trigger_start, &trigger_stop); 204 + graph_util_parse_trigger_order(priv, codec, &trigger_start, &trigger_stop); 205 + 203 206 dai_link->playback_only = playback_only; 204 207 dai_link->capture_only = capture_only; 208 + 209 + dai_link->trigger_start = trigger_start; 210 + dai_link->trigger_stop = trigger_stop; 205 211 206 212 dai_link->init = simple_util_dai_init; 207 213 dai_link->ops = &simple_ops;