summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMargarita Olaya Cabrera <magi.olaya@ti.com>2011-05-31 09:23:04 +0100
committerAndy Green <andy.green@linaro.org>2011-05-31 11:04:33 +0100
commit5a1279c7cf21470ccb2cc8a63c35f007cf297563 (patch)
tree3c2a83c98f62faffef4459f7465214f0ff577974 /sound
parent6f12c3a1ce5d42fdda355e488c3fee58ff960a73 (diff)
ASoC: sdp4430: Set McBSP format for voice call
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>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/sdp4430.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c
index 68041d2b3e7..637d8e42f74 100644
--- a/sound/soc/omap/sdp4430.c
+++ b/sound/soc/omap/sdp4430.c
@@ -45,6 +45,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 = {
@@ -68,13 +69,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;
@@ -91,11 +133,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,
@@ -165,11 +227,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 */