diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2019-03-20 00:55:52 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-03-21 10:51:57 -0400 |
commit | ad934ca8010843482d61fda46786449a9bc99e10 (patch) | |
tree | f52c293b6aff971f7fb7833d9939198b9b53b278 /sound/soc/generic | |
parent | f48dcbb6d47d870cf3a03f453c923dd262158c66 (diff) |
ASoC: simple-card-utils: share asoc_simple_dai_init()
The difference between simple-card / audio-graph are just using
OF graph style, or not. In other words, other things should be same.
This means, simple-card/audio-graph common functions should be
implemented at simple-card-utils, and its own functions should be
implemented at each files.
Current simple-card / audio-graph have almost same functions.
This patch shares asoc_simple_dai_init() between in these 2 drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r-- | sound/soc/generic/audio-graph-card.c | 23 | ||||
-rw-r--r-- | sound/soc/generic/simple-card-utils.c | 25 | ||||
-rw-r--r-- | sound/soc/generic/simple-card.c | 25 |
3 files changed, 27 insertions, 46 deletions
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 51160adaf5bb..b1ceefc60879 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c | |||
@@ -62,25 +62,6 @@ static const struct snd_soc_ops graph_ops = { | |||
62 | .hw_params = asoc_simple_hw_params, | 62 | .hw_params = asoc_simple_hw_params, |
63 | }; | 63 | }; |
64 | 64 | ||
65 | static int graph_dai_init(struct snd_soc_pcm_runtime *rtd) | ||
66 | { | ||
67 | struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); | ||
68 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); | ||
69 | int ret = 0; | ||
70 | |||
71 | ret = asoc_simple_card_init_dai(rtd->codec_dai, | ||
72 | dai_props->codec_dai); | ||
73 | if (ret < 0) | ||
74 | return ret; | ||
75 | |||
76 | ret = asoc_simple_card_init_dai(rtd->cpu_dai, | ||
77 | dai_props->cpu_dai); | ||
78 | if (ret < 0) | ||
79 | return ret; | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, | 65 | static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
85 | struct snd_pcm_hw_params *params) | 66 | struct snd_pcm_hw_params *params) |
86 | { | 67 | { |
@@ -255,7 +236,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
255 | dai_link->dpcm_playback = 1; | 236 | dai_link->dpcm_playback = 1; |
256 | dai_link->dpcm_capture = 1; | 237 | dai_link->dpcm_capture = 1; |
257 | dai_link->ops = &graph_ops; | 238 | dai_link->ops = &graph_ops; |
258 | dai_link->init = graph_dai_init; | 239 | dai_link->init = asoc_simple_dai_init; |
259 | 240 | ||
260 | return 0; | 241 | return 0; |
261 | } | 242 | } |
@@ -327,7 +308,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv, | |||
327 | return ret; | 308 | return ret; |
328 | 309 | ||
329 | dai_link->ops = &graph_ops; | 310 | dai_link->ops = &graph_ops; |
330 | dai_link->init = graph_dai_init; | 311 | dai_link->init = asoc_simple_dai_init; |
331 | 312 | ||
332 | asoc_simple_card_canonicalize_platform(dai_link); | 313 | asoc_simple_card_canonicalize_platform(dai_link); |
333 | asoc_simple_card_canonicalize_cpu(dai_link, | 314 | asoc_simple_card_canonicalize_cpu(dai_link, |
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index de23cf8bffbd..c9b53b340028 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c | |||
@@ -436,8 +436,8 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep, | |||
436 | } | 436 | } |
437 | EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai); | 437 | EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai); |
438 | 438 | ||
439 | int asoc_simple_card_init_dai(struct snd_soc_dai *dai, | 439 | static int asoc_simple_card_init_dai(struct snd_soc_dai *dai, |
440 | struct asoc_simple_dai *simple_dai) | 440 | struct asoc_simple_dai *simple_dai) |
441 | { | 441 | { |
442 | int ret; | 442 | int ret; |
443 | 443 | ||
@@ -467,7 +467,26 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai, | |||
467 | 467 | ||
468 | return 0; | 468 | return 0; |
469 | } | 469 | } |
470 | EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai); | 470 | |
471 | int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) | ||
472 | { | ||
473 | struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); | ||
474 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); | ||
475 | int ret; | ||
476 | |||
477 | ret = asoc_simple_card_init_dai(rtd->codec_dai, | ||
478 | dai_props->codec_dai); | ||
479 | if (ret < 0) | ||
480 | return ret; | ||
481 | |||
482 | ret = asoc_simple_card_init_dai(rtd->cpu_dai, | ||
483 | dai_props->cpu_dai); | ||
484 | if (ret < 0) | ||
485 | return ret; | ||
486 | |||
487 | return 0; | ||
488 | } | ||
489 | EXPORT_SYMBOL_GPL(asoc_simple_dai_init); | ||
471 | 490 | ||
472 | void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link) | 491 | void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link) |
473 | { | 492 | { |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 7e836473eb11..bf4482ecfe3e 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -32,25 +32,6 @@ static const struct snd_soc_ops simple_ops = { | |||
32 | .hw_params = asoc_simple_hw_params, | 32 | .hw_params = asoc_simple_hw_params, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | static int simple_dai_init(struct snd_soc_pcm_runtime *rtd) | ||
36 | { | ||
37 | struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); | ||
38 | struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); | ||
39 | int ret; | ||
40 | |||
41 | ret = asoc_simple_card_init_dai(rtd->codec_dai, | ||
42 | dai_props->codec_dai); | ||
43 | if (ret < 0) | ||
44 | return ret; | ||
45 | |||
46 | ret = asoc_simple_card_init_dai(rtd->cpu_dai, | ||
47 | dai_props->cpu_dai); | ||
48 | if (ret < 0) | ||
49 | return ret; | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, | 35 | static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
55 | struct snd_pcm_hw_params *params) | 36 | struct snd_pcm_hw_params *params) |
56 | { | 37 | { |
@@ -221,7 +202,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, | |||
221 | dai_link->dpcm_playback = 1; | 202 | dai_link->dpcm_playback = 1; |
222 | dai_link->dpcm_capture = 1; | 203 | dai_link->dpcm_capture = 1; |
223 | dai_link->ops = &simple_ops; | 204 | dai_link->ops = &simple_ops; |
224 | dai_link->init = simple_dai_init; | 205 | dai_link->init = asoc_simple_dai_init; |
225 | 206 | ||
226 | return 0; | 207 | return 0; |
227 | } | 208 | } |
@@ -316,7 +297,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, | |||
316 | goto dai_link_of_err; | 297 | goto dai_link_of_err; |
317 | 298 | ||
318 | dai_link->ops = &simple_ops; | 299 | dai_link->ops = &simple_ops; |
319 | dai_link->init = simple_dai_init; | 300 | dai_link->init = asoc_simple_dai_init; |
320 | 301 | ||
321 | asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); | 302 | asoc_simple_card_canonicalize_cpu(dai_link, single_cpu); |
322 | asoc_simple_card_canonicalize_platform(dai_link); | 303 | asoc_simple_card_canonicalize_platform(dai_link); |
@@ -694,7 +675,7 @@ static int simple_probe(struct platform_device *pdev) | |||
694 | dai_link->stream_name = cinfo->name; | 675 | dai_link->stream_name = cinfo->name; |
695 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; | 676 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; |
696 | dai_link->dai_fmt = cinfo->daifmt; | 677 | dai_link->dai_fmt = cinfo->daifmt; |
697 | dai_link->init = simple_dai_init; | 678 | dai_link->init = asoc_simple_dai_init; |
698 | memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai, | 679 | memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai, |
699 | sizeof(*priv->dai_props->cpu_dai)); | 680 | sizeof(*priv->dai_props->cpu_dai)); |
700 | memcpy(priv->dai_props->codec_dai, &cinfo->codec_dai, | 681 | memcpy(priv->dai_props->codec_dai, &cinfo->codec_dai, |