Skip to content

Commit 9d49925

Browse files
committed
ASoC: extra format on each DAI
Merge series from Kuninori Morimoto <[email protected]>: Current clock provider/consumer setting is set by dai_link->dai_fmt, and it is Codec base on Sound Card driver (= SND_SOC_DAIFMT_CBx_CFx). Current CPU/Codec drivers are already based on its own base (= SND_SOC_DAIFMT_Bx_Fx). So, Codec clock setting uses dai_link->dai_fmt as-is, and CPU side clock setting is created from Codec base setting by flipping. Because of this, we can't set both CPU/Codec clock consumer for example. To solve this issue, this patch-set adds new ext_fmt on each DAI. It can keep compatible with legacy style. 1. SND_SOC_DAIFMT_FORMAT_MASK 2. SND_SOC_DAIFMT_CLOCK 3. SND_SOC_DAIFMT_INV 4. SND_SOC_DAIFMT_CLOCK_PROVIDER dai_fmt : dai_link->dai_fmt = common settings ext_fmt : each DAI settings Legacy dai_fmt includes 1, 2, 3, 4 New style dai_fmt includes 1, 2, 3 ext_fmt includes 4 Audio-Graph-Card2 will use this new style by this patch-set. By this patch, Card2 default behavior (= no "clock-master / frame-master" settings on DT) will be changed, but no drivers are using it. In case of no DAI has "clock-master / frame-master" property on DT, it will be... Legacy CPU : provider (because flipped from Codec) Codec: consumer New style CPU : consumer Codec: consumer One note is that Simple-Card, Audio-Graph-Card don't implement this new style to keep compatiblily. In Overlay case, port order can be random, so we shouldn't use get_next() function to get next port.
2 parents 292284f + 365865b commit 9d49925

File tree

5 files changed

+179
-230
lines changed

5 files changed

+179
-230
lines changed

include/sound/soc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,17 @@ struct snd_soc_dai_link_component {
681681
struct device_node *of_node;
682682
const char *dai_name;
683683
const struct of_phandle_args *dai_args;
684+
685+
/*
686+
* Extra format = SND_SOC_DAIFMT_Bx_Fx
687+
*
688+
* [Note] it is Bx_Fx base, not CBx_CFx
689+
*
690+
* It will be used with dai_link->dai_fmt
691+
* see
692+
* snd_soc_runtime_set_dai_fmt()
693+
*/
694+
unsigned int ext_fmt;
684695
};
685696

686697
/*

sound/soc/generic/audio-graph-card.c

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,14 @@ static void graph_parse_convert(struct device *dev,
8181
struct simple_util_data *adata)
8282
{
8383
struct device_node *top = dev->of_node;
84-
struct device_node *port = ep_to_port(ep);
85-
struct device_node *ports = port_to_ports(port);
86-
struct device_node *node = of_graph_get_port_parent(ep);
84+
struct device_node *port __free(device_node) = ep_to_port(ep);
85+
struct device_node *ports __free(device_node) = port_to_ports(port);
86+
struct device_node *node __free(device_node) = of_graph_get_port_parent(ep);
8787

8888
simple_util_parse_convert(top, NULL, adata);
8989
simple_util_parse_convert(ports, NULL, adata);
9090
simple_util_parse_convert(port, NULL, adata);
9191
simple_util_parse_convert(ep, NULL, adata);
92-
93-
of_node_put(port);
94-
of_node_put(ports);
95-
of_node_put(node);
9692
}
9793

9894
static int graph_parse_node(struct simple_util_priv *priv,
@@ -140,10 +136,10 @@ static int graph_link_init(struct simple_util_priv *priv,
140136
struct device_node *top = dev->of_node;
141137
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
142138
struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
143-
struct device_node *port_cpu = ep_to_port(ep_cpu);
144-
struct device_node *port_codec = ep_to_port(ep_codec);
145-
struct device_node *ports_cpu = port_to_ports(port_cpu);
146-
struct device_node *ports_codec = port_to_ports(port_codec);
139+
struct device_node *port_cpu __free(device_node) = ep_to_port(ep_cpu);
140+
struct device_node *port_codec __free(device_node) = ep_to_port(ep_codec);
141+
struct device_node *ports_cpu __free(device_node) = port_to_ports(port_cpu);
142+
struct device_node *ports_codec __free(device_node) = port_to_ports(port_codec);
147143
enum snd_soc_trigger_order trigger_start = SND_SOC_TRIGGER_ORDER_DEFAULT;
148144
enum snd_soc_trigger_order trigger_stop = SND_SOC_TRIGGER_ORDER_DEFAULT;
149145
bool playback_only = 0, capture_only = 0;
@@ -152,7 +148,7 @@ static int graph_link_init(struct simple_util_priv *priv,
152148
ret = simple_util_parse_daifmt(dev, ep_cpu, ep_codec,
153149
NULL, &dai_link->dai_fmt);
154150
if (ret < 0)
155-
goto init_end;
151+
return ret;
156152

157153
graph_util_parse_link_direction(top, &playback_only, &capture_only);
158154
graph_util_parse_link_direction(port_cpu, &playback_only, &capture_only);
@@ -187,14 +183,7 @@ static int graph_link_init(struct simple_util_priv *priv,
187183
if (priv->ops)
188184
dai_link->ops = priv->ops;
189185

190-
ret = simple_util_set_dailink_name(dev, dai_link, name);
191-
init_end:
192-
of_node_put(ports_cpu);
193-
of_node_put(ports_codec);
194-
of_node_put(port_cpu);
195-
of_node_put(port_codec);
196-
197-
return ret;
186+
return simple_util_set_dailink_name(dev, dai_link, name);
198187
}
199188

200189
static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
@@ -250,8 +239,6 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
250239
} else {
251240
struct snd_soc_codec_conf *cconf = simple_props_to_codec_conf(dai_props, 0);
252241
struct snd_soc_dai_link_component *codecs = snd_soc_link_to_codec(dai_link, 0);
253-
struct device_node *port;
254-
struct device_node *ports;
255242

256243
/* CPU is dummy */
257244

@@ -267,14 +254,12 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
267254
"be.%pOFP.%s", codecs->of_node, codecs->dai_name);
268255

269256
/* check "prefix" from top node */
270-
port = ep_to_port(ep);
271-
ports = port_to_ports(port);
257+
struct device_node *port __free(device_node) = ep_to_port(ep);
258+
struct device_node *ports __free(device_node) = port_to_ports(port);
259+
272260
snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, "prefix");
273261
snd_soc_of_parse_node_prefix(ports, cconf, codecs->of_node, "prefix");
274262
snd_soc_of_parse_node_prefix(port, cconf, codecs->of_node, "prefix");
275-
276-
of_node_put(ports);
277-
of_node_put(port);
278263
}
279264

280265
graph_parse_convert(dev, ep, &dai_props->adata);
@@ -361,8 +346,6 @@ static int __graph_for_each_link(struct simple_util_priv *priv,
361346
struct device *dev = simple_priv_to_dev(priv);
362347
struct device_node *node = dev->of_node;
363348
struct device_node *cpu_port;
364-
struct device_node *codec_ep;
365-
struct device_node *codec_port;
366349
struct device_node *codec_port_old = NULL;
367350
struct simple_util_data adata;
368351
int rc, ret = 0;
@@ -374,8 +357,8 @@ static int __graph_for_each_link(struct simple_util_priv *priv,
374357
/* loop for all CPU endpoint */
375358
for_each_of_graph_port_endpoint(cpu_port, cpu_ep) {
376359
/* get codec */
377-
codec_ep = of_graph_get_remote_endpoint(cpu_ep);
378-
codec_port = ep_to_port(codec_ep);
360+
struct device_node *codec_ep __free(device_node) = of_graph_get_remote_endpoint(cpu_ep);
361+
struct device_node *codec_port __free(device_node) = ep_to_port(codec_ep);
379362

380363
/* get convert-xxx property */
381364
memset(&adata, 0, sizeof(adata));
@@ -399,9 +382,6 @@ static int __graph_for_each_link(struct simple_util_priv *priv,
399382
ret = func_noml(priv, cpu_ep, codec_ep, li);
400383
}
401384

402-
of_node_put(codec_ep);
403-
of_node_put(codec_port);
404-
405385
if (ret < 0)
406386
return ret;
407387

0 commit comments

Comments
 (0)