summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2013-12-10 03:08:43 -0600
committerGerrit Code Review2014-01-24 14:19:39 -0600
commitdd771e9d1674b0e09fa832a7729a25f5af9bc3da (patch)
tree3dec3a89e81443d4d07578c0e0e5a9c1351cb06e /audio/multizone/AudioHw.cpp
parentf5884e73b0e4af502bfc6c18b074e95552d77db6 (diff)
downloaddevice-ti-jacinto6evm-dd771e9d1674b0e09fa832a7729a25f5af9bc3da.tar.gz
device-ti-jacinto6evm-dd771e9d1674b0e09fa832a7729a25f5af9bc3da.tar.xz
device-ti-jacinto6evm-dd771e9d1674b0e09fa832a7729a25f5af9bc3da.zip
audio: Multizone: Bluetooth slave mode workaround
The PCM ports used for Bluetooth SCO are in slave mode in Jacinto6 EVM board. So the BT side masters the BCLK and FSYNC. The BT side could cut the BCLK and FSYNC while the ALSA PCM ports are not closed, which leads to blocking read() and write() calls. They would eventually timeout and cause an I/O error. The workaround consists of switching the BT DAI link to slave mode (McASP is master, BT is slave) while leaving the call, it guarantees that the BCLK and FSYNC are present as they are generated from an internal source, the actual rate of the clock is irrelevant. For the new source to take effect, the ALSA PCM ports used for BT are explicitly stopped. Change-Id: Ifadb8b1348529d404d06d4b043c5fe686f85a49a Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Diffstat (limited to 'audio/multizone/AudioHw.cpp')
-rw-r--r--audio/multizone/AudioHw.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/audio/multizone/AudioHw.cpp b/audio/multizone/AudioHw.cpp
index 5432c07..f25bb43 100644
--- a/audio/multizone/AudioHw.cpp
+++ b/audio/multizone/AudioHw.cpp
@@ -599,6 +599,7 @@ uint32_t AudioStreamIn::getInputFramesLost()
599 599
600const char *AudioHwDevice::kCabinVolumeHP = "HP DAC Playback Volume"; 600const char *AudioHwDevice::kCabinVolumeHP = "HP DAC Playback Volume";
601const char *AudioHwDevice::kCabinVolumeLine = "Line DAC Playback Volume"; 601const char *AudioHwDevice::kCabinVolumeLine = "Line DAC Playback Volume";
602const char *AudioHwDevice::kBTMode = "Bluetooth Mode";
602 603
603AudioHwDevice::AudioHwDevice(uint32_t card) 604AudioHwDevice::AudioHwDevice(uint32_t card)
604 : mCardId(card), mMixer(mCardId), mMicMute(false), mMode(AUDIO_MODE_NORMAL) 605 : mCardId(card), mMixer(mCardId), mMicMute(false), mMode(AUDIO_MODE_NORMAL)
@@ -907,6 +908,12 @@ int AudioHwDevice::enterVoiceCall()
907 return ret; 908 return ret;
908 } 909 }
909 910
911 /* Bluetooth is master, provides BCLK and FSYNC */
912 mMixer.set(ALSAControl(kBTMode, "Master"), true);
913
914 mULPipe->shutdown(false);
915 mDLPipe->shutdown(false);
916
910 /* Uplink input stream: Mic -> Pipe */ 917 /* Uplink input stream: Mic -> Pipe */
911 ret = mVoiceULInStream->start(); 918 ret = mVoiceULInStream->start();
912 if (ret) { 919 if (ret) {
@@ -950,18 +957,36 @@ void AudioHwDevice::leaveVoiceCall()
950{ 957{
951 ALOGI("AudioHwDevice: leave voice call"); 958 ALOGI("AudioHwDevice: leave voice call");
952 959
953 if (mVoiceDLOutStream->isStarted()) 960 /*
954 mVoiceDLOutStream->stop(); 961 * The PCM ports used for Bluetooth are slaves and they can lose the
962 * BCLK and FSYNC while still active. That leads to blocking read() and
963 * write() calls, which is prevented by switching the clock source to
964 * an internal one and explicitly stopping both ports for the new source
965 * to take effect at kernel level
966 */
967 mMixer.set(ALSAControl(kBTMode, "Slave"), true);
968
969 mULPipe->shutdown(true);
970 mDLPipe->shutdown(true);
955 971
972 /* Uplink input stream: Mic -> Pipe */
956 if (mVoiceULInStream->isStarted()) 973 if (mVoiceULInStream->isStarted())
957 mVoiceULInStream->stop(); 974 mVoiceULInStream->stop();
958 975
959 if (mVoiceULOutStream->isStarted()) 976 /* Downlink input stream: Bluetooth -> Pipe */
960 mVoiceULOutStream->stop(); 977 mInPorts[kBTPortId]->stop();
961
962 if (mVoiceDLInStream->isStarted()) 978 if (mVoiceDLInStream->isStarted())
963 mVoiceDLInStream->stop(); 979 mVoiceDLInStream->stop();
964 980
981 /* Downlink output stream: Pipe -> Speaker */
982 if (mVoiceDLOutStream->isStarted())
983 mVoiceDLOutStream->stop();
984
985 /* Uplink output stream: Pipe -> Bluetooth */
986 mOutPorts[kBTPortId]->stop();
987 if (mVoiceULOutStream->isStarted())
988 mVoiceULOutStream->stop();
989
965 disableVoiceCall(); 990 disableVoiceCall();
966 991
967 /* Reset the cabin volume for media */ 992 /* Reset the cabin volume for media */