aboutsummaryrefslogtreecommitdiffstats
path: root/bsp/pandaboard/ASoC-sdp4430-Set-McBSP-format-for-voice-call.patch
blob: 5cff94d97e45d76f8bd2534a98584d84b0415b18 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
From 51b2975381a3d2c034169183fb14c8f3f57589eb Mon Sep 17 00:00:00 2001
From: Margarita Olaya Cabrera <magi.olaya@ti.com>
Date: Mon, 25 Oct 2010 22:32:04 -0500
Subject: [PATCH 46/60] ASoC: sdp4430: Set McBSP format for voice call

commit 2f4c063d48e97efed2192a518be072b093397463 upstream

MODEM frontend can be used with different backends
like McPDM or DMIC. McBSP2 needs to be configured
for modem voice call regardless of selected backend.

Change-Id: I6eaf1da312b4cb513a39fea5d5ed4dc7249865de
Signed-off-by: Francois Mazard <f-mazard@ti.com>
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com>
Integrated-by: Jingdong Lu <jingdong.lu@windriver.com>
---
 sound/soc/omap/sdp4430.c |   85 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c
index a5f9988..a385e79 100644
--- a/sound/soc/omap/sdp4430.c
+++ b/sound/soc/omap/sdp4430.c
@@ -43,6 +43,7 @@
 #endif
 
 static int twl6040_power_mode;
+static int mcbsp_cfg;
 
 static struct i2c_client *tps6130x_client;
 static struct i2c_board_info tps6130x_hwmon_info = {
@@ -66,13 +67,54 @@ static int sdp4430_tps6130x_configure(void)
 	return 0;
 }
 
+static int sdp4430_modem_mcbsp_configure(struct snd_pcm_substream *substream,
+					 int flag)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_pcm_substream *modem_substream;
+	struct snd_soc_pcm_runtime *modem_rtd;
+	int ret = 0;
+
+	/* already configured, nothing to do */
+	if (mcbsp_cfg == flag)
+		return ret;
+
+	if (flag) {
+		modem_substream = snd_soc_get_dai_substream(rtd->card,
+					OMAP_ABE_BE_MM_EXT1,
+					substream->stream);
+		if (unlikely(modem_substream == NULL)) {
+			ret = -ENODEV;
+			goto exit;
+		}
+
+		modem_rtd = modem_substream->private_data;
+
+		/* Set cpu DAI configuration */
+		ret = snd_soc_dai_set_fmt(modem_rtd->cpu_dai,
+					  SND_SOC_DAIFMT_I2S |
+					  SND_SOC_DAIFMT_NB_NF |
+					  SND_SOC_DAIFMT_CBM_CFM);
+		if (unlikely(ret < 0)) {
+			printk(KERN_ERR "can't set Modem cpu DAI configuration\n");
+			goto exit;
+		}
+		mcbsp_cfg = 1;
+	} else {
+		mcbsp_cfg = 0;
+	}
+
+exit:
+	return ret;
+}
+
 static int sdp4430_mcpdm_hw_params(struct snd_pcm_substream *substream,
 	struct snd_pcm_hw_params *params)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int clk_id, freq;
-	int ret;
+	int ret = 0;
 
 	if (twl6040_power_mode) {
 		clk_id = TWL6040_SYSCLK_SEL_HPPLL;
@@ -89,11 +131,31 @@ static int sdp4430_mcpdm_hw_params(struct snd_pcm_substream *substream,
 		printk(KERN_ERR "can't set codec system clock\n");
 		return ret;
 	}
+
+	if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
+		/* set Modem McBSP configuration  */
+		ret = sdp4430_modem_mcbsp_configure(substream, 1);
+	}
+
+	return ret;
+}
+
+static int sdp4430_mcpdm_hw_free(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
+	if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
+		/* freed Modem McBSP configuration */
+		ret = sdp4430_modem_mcbsp_configure(substream, 0);
+	}
+
 	return ret;
 }
 
 static struct snd_soc_ops sdp4430_mcpdm_ops = {
 	.hw_params = sdp4430_mcpdm_hw_params,
+	.hw_free = sdp4430_mcpdm_hw_free,
 };
 
 static int sdp4430_mcbsp_hw_params(struct snd_pcm_substream *substream,
@@ -163,11 +225,30 @@ static int sdp4430_dmic_hw_params(struct snd_pcm_substream *substream,
 		return ret;
 	}
 
-	return 0;
+	if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
+		/* set Modem McBSP configuration  */
+		ret = sdp4430_modem_mcbsp_configure(substream, 1);
+	}
+
+	return ret;
+}
+
+static int sdp4430_dmic_hw_free(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
+	if (rtd->current_fe == ABE_FRONTEND_DAI_MODEM) {
+		/* freed Modem McBSP configuration */
+		ret = sdp4430_modem_mcbsp_configure(substream, 0);
+	}
+
+	return ret;
 }
 
 static struct snd_soc_ops sdp4430_dmic_ops = {
 	.hw_params = sdp4430_dmic_hw_params,
+	.hw_free = sdp4430_dmic_hw_free,
 };
 
 /* Headset jack */
-- 
1.7.4.1