From 7aea99d563f8ebc4867276834b970935b99a53f9 Mon Sep 17 00:00:00 2001 From: Praveen Bharathi Date: Mon, 24 Jan 2011 08:01:11 -0600 Subject: [PATCH] mfd: cpcap: audio: Fix loss of audio over headset When the 3.5mm headset is unplugged and plugged back in, cpcap gets into a wierd state and audio is not routed to any speaker, neither headset nor main speaker. This is a solution from Droid days. The cpcap sends a callback to audio driver when such a plug/unplug is detected and forces the audio path setup back to headset. Change-Id: I91afda628e14ec20d589fc9b3e844d29f9f96fca Signed-off-by: Praveen Bharathi --- drivers/mfd/tegra-cpcap-audio.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mfd/tegra-cpcap-audio.c b/drivers/mfd/tegra-cpcap-audio.c index 5838a7da7766..dd5e917bfc7b 100644 --- a/drivers/mfd/tegra-cpcap-audio.c +++ b/drivers/mfd/tegra-cpcap-audio.c @@ -467,6 +467,29 @@ void tegra_cpcap_audio_dock_state(bool connected) } EXPORT_SYMBOL(tegra_cpcap_audio_dock_state); +static void cpcap_audio_callback(int status) +{ + mutex_lock(&cpcap_lock); + if (status == 1 || status == 2) { + if (pdata->state->stdac_primary_speaker == + CPCAP_AUDIO_OUT_STEREO_HEADSET) + tegra_setup_audio_out_headset_on(); + if (pdata->state->microphone == + CPCAP_AUDIO_IN_HEADSET) + tegra_setup_audio_in_headset_on(); + } + if (status == 0) { + if (pdata->state->stdac_primary_speaker == + CPCAP_AUDIO_OUT_STEREO_HEADSET) + tegra_setup_audio_output_off(); + if (pdata->state->microphone == + CPCAP_AUDIO_IN_HEADSET) + tegra_setup_audio_in_mute(); + } + + mutex_unlock(&cpcap_lock); +} + static int cpcap_audio_probe(struct platform_device *pdev) { int rc; @@ -503,6 +526,8 @@ static int cpcap_audio_probe(struct platform_device *pdev) if (cpcap_audio_init(pdata->state, pdata->regulator)) goto fail3; + cpcap->h2w_new_state = &cpcap_audio_callback; + rc = misc_register(&cpcap_audio_ctl); if (rc < 0) { pr_err("%s: failed to register misc device: %d\n", __func__, -- 2.34.1