summaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0022-ASoC-Modify-check-condition-of-multiple-bindings-of-.patch
blob: 73e21503bfd884f6518a7f62f5d6e554605ad5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 2fc4f16b075264fae016ea3db1f1f81d30cb0ab6 Mon Sep 17 00:00:00 2001
From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Date: Tue, 13 Dec 2016 18:08:39 +0300
Subject: [PATCH] ASoC: Modify check condition of multiple bindings of
 components

https://patchwork.kernel.org/patch/7385501/
...and some more hacks to bind one component (with several DAIs)
to more than one sound card.

KF has 4 sound cards (pcm3168a, ak4613, radio, wl18xx) and just one 
compinent ec500000.sound that can not be bound to all 4 cards.
This is a lack of current implementation of sound/soc/sh/rcar/* ASoC stack
The ec500000.sound resources (PCM/DMA, dais) needs to be shared between
all 4 sound cards if we want all cards work runtime.
Or we have to enable only one of them in dts file as it is designed.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
---
 sound/soc/soc-core.c            |    6 ++++--
 sound/soc/soc-pcm.c             |    9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 16369ca..899d013 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1373,7 +1373,8 @@ static int soc_probe_component(struct snd_soc_card *card,
 		return 0;
 
 	if (component->card) {
-		if (component->card != card) {
+		if (component->card != card &&
+		    component->registered_as_component) {
 			dev_err(component->dev,
 				"Trying to bind component to card \"%s\" but is already bound to card \"%s\"\n",
 				card->name, component->card->name);
@@ -3049,7 +3050,8 @@ int snd_soc_register_component(struct device *dev,
 		goto err_free;
 
 	cmpnt->ignore_pmdown_time = true;
-	cmpnt->registered_as_component = true;
+	if (num_dai == 1)
+		cmpnt->registered_as_component = true;
 
 	ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, true);
 	if (ret < 0) {
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index f6667e4..719c866 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2632,11 +2632,16 @@ static void soc_pcm_free(struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
 	struct snd_soc_component *component;
+	struct snd_soc_platform *platform = rtd->platform;
 
 	list_for_each_entry(component, &rtd->card->component_dev_list,
 			    card_list) {
+		if (!component->registered_as_component)
+			component = &platform->component;
 		if (component->pcm_free)
 			component->pcm_free(pcm);
+		if (!component->registered_as_component)
+			break;
 	}
 }
 
@@ -2756,6 +2761,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
 
 	list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
+		if (!component->registered_as_component)
+			component = &platform->component;
 		if (component->pcm_new) {
 			ret = component->pcm_new(rtd);
 			if (ret < 0) {
@@ -2765,6 +2772,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 				return ret;
 			}
 		}
+		if (!component->registered_as_component)
+			break;
 	}
 	pcm->private_free = soc_pcm_free;
 out:
-- 
1.7.10.4