summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2013-12-13 01:58:52 -0600
committerGerrit Code Review2014-02-02 21:28:37 -0600
commit3e7221e16ebf33969e00b804532fc2ead8d31fbd (patch)
treec799dacb8be32316872014c99d0d0ec86e55fb1b /audio/multizone
parent76b680d6dcf3a08c0e4701729ff8c9e641054353 (diff)
downloaddevice-ti-jacinto6evm-3e7221e16ebf33969e00b804532fc2ead8d31fbd.tar.gz
device-ti-jacinto6evm-3e7221e16ebf33969e00b804532fc2ead8d31fbd.tar.xz
device-ti-jacinto6evm-3e7221e16ebf33969e00b804532fc2ead8d31fbd.zip
audio: Multizone: Dynamic JAMR3 support
JAMR3 board may not always be present in the system, the port usage is being changed dynamically to: - JAMR3 is present o Cabin : port 1, slots 0 & 1 o Mic : port 1, slot 2 o Back Mic: port 1, slot 3 - JAMR3 is not present o Cabin : port 0, slots 0 & 1 o Mic : port 0, slots 0 & 1 Above port allocation allows: - Relinquish McASP3 (port 0) when JAMR3 is connected. This allows DSP Radio to own that McASP instance for its rendering. - Hardware setups that don't have JAMR3 fall back to the port 0 that is present in the main Jacinto6 EVM board (CPU board). The default hardware setup is assumed to have JAMR3 connected. When it's not connected, the property "persist.audio.use_jamr" must be set to "0" or "false" and system has to be rebooted (or media server restarted). This is meant to be a development option. Change-Id: Icc5399b370e2247a1a0d5a967dcd47e0ef4947ac Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Diffstat (limited to 'audio/multizone')
-rw-r--r--audio/multizone/Android.mk1
-rw-r--r--audio/multizone/AudioHw.cpp97
-rw-r--r--audio/multizone/AudioHw.h2
-rw-r--r--audio/multizone/dra7evm_paths.xml19
4 files changed, 67 insertions, 52 deletions
diff --git a/audio/multizone/Android.mk b/audio/multizone/Android.mk
index 46ec26a..061e20f 100644
--- a/audio/multizone/Android.mk
+++ b/audio/multizone/Android.mk
@@ -48,6 +48,7 @@ LOCAL_C_INCLUDES += \
48LOCAL_SHARED_LIBRARIES := \ 48LOCAL_SHARED_LIBRARIES := \
49 liblog \ 49 liblog \
50 libtiaudioutils \ 50 libtiaudioutils \
51 libcutils \
51 libutils 52 libutils
52 53
53LOCAL_SHARED_LIBRARIES += libstlport 54LOCAL_SHARED_LIBRARIES += libstlport
diff --git a/audio/multizone/AudioHw.cpp b/audio/multizone/AudioHw.cpp
index a532abd..7b237a0 100644
--- a/audio/multizone/AudioHw.cpp
+++ b/audio/multizone/AudioHw.cpp
@@ -24,7 +24,7 @@
24#endif 24#endif
25 25
26#include <cutils/log.h> 26#include <cutils/log.h>
27 27#include <cutils/properties.h>
28#include <media/AudioParameter.h> 28#include <media/AudioParameter.h>
29 29
30#include <AudioHw.h> 30#include <AudioHw.h>
@@ -426,8 +426,6 @@ int AudioStreamIn::setFormat(audio_format_t format)
426/* must be called with mLock */ 426/* must be called with mLock */
427int AudioStreamIn::resume() 427int AudioStreamIn::resume()
428{ 428{
429 mHwDev->mMixer.setPath(mDevices, true);
430
431 int ret = mReader->registerStream(mStream); 429 int ret = mReader->registerStream(mStream);
432 if (ret) { 430 if (ret) {
433 ALOGE("AudioStreamIn: failed to register Dest %d", ret); 431 ALOGE("AudioStreamIn: failed to register Dest %d", ret);
@@ -448,7 +446,6 @@ void AudioStreamIn::idle()
448{ 446{
449 mStream->stop(); 447 mStream->stop();
450 mReader->unregisterStream(mStream); 448 mReader->unregisterStream(mStream);
451 mHwDev->mMixer.setPath(mDevices, false);
452} 449}
453 450
454int AudioStreamIn::standby() 451int AudioStreamIn::standby()
@@ -603,7 +600,27 @@ const char *AudioHwDevice::kBTMode = "Bluetooth Mode";
603AudioHwDevice::AudioHwDevice(uint32_t card) 600AudioHwDevice::AudioHwDevice(uint32_t card)
604 : mCardId(card), mMixer(mCardId), mMicMute(false), mMode(AUDIO_MODE_NORMAL) 601 : mCardId(card), mMixer(mCardId), mMicMute(false), mMode(AUDIO_MODE_NORMAL)
605{ 602{
606 ALOGI("AudioHwDevice: create hw device for card hw:%u", card); 603 /*
604 * "multizone_audio.use_jamr" property is used to indicate if JAMR3
605 * board is available in the system:
606 * - Present
607 * o Cabin : port 1, slots 0 & 1
608 * o Mic : port 1, slot 2
609 * o Back Mic: port 1, slot 3
610 * - Not present
611 * o Cabin : port 0, slots 0 & 1
612 * o Mic : port 0, slots 0 & 1
613 */
614 char value[PROPERTY_VALUE_MAX];
615 if ((property_get("persist.audio.use_jamr", value, NULL) == 0) ||
616 !strcmp(value, "1") || !strcasecmp(value, "true")) {
617 mMediaPortId = kJAMR3PortId;
618 } else {
619 mMediaPortId = kCPUPortId;
620 }
621
622 ALOGI("AudioHwDevice: create hw device for card hw:%u Jacinto6 EVM %s",
623 card, usesJAMR3() ? "+ JAMR3" : "");
607 624
608 /* Mixer for dra7evm and input/output ports for JAMR3 PCM device */ 625 /* Mixer for dra7evm and input/output ports for JAMR3 PCM device */
609 for (uint32_t i = 0; i < kNumPorts; i++) { 626 for (uint32_t i = 0; i < kNumPorts; i++) {
@@ -646,12 +663,22 @@ AudioHwDevice::AudioHwDevice(uint32_t card)
646 slots[0] = 0; 663 slots[0] = 0;
647 slots[1] = 0; 664 slots[1] = 0;
648 665
666 /* Microphone slots are different in JAMR3 and CPU board */
667 SlotMap micSlots;
668 if (usesJAMR3()) {
669 micSlots[0] = 2;
670 micSlots[1] = 2;
671 } else {
672 micSlots[0] = 0;
673 micSlots[1] = 0;
674 }
675
649 /* Voice call uplink */ 676 /* Voice call uplink */
650 mULPipe = new tiaudioutils::MonoPipe(paramsBT, 677 mULPipe = new tiaudioutils::MonoPipe(paramsBT,
651 (kVoiceCallPipeMs * paramsBT.sampleRate) / 1000); 678 (kVoiceCallPipeMs * paramsBT.sampleRate) / 1000);
652 mULPipeWriter = new PipeWriter(mULPipe); 679 mULPipeWriter = new PipeWriter(mULPipe);
653 mULPipeReader = new PipeReader(mULPipe); 680 mULPipeReader = new PipeReader(mULPipe);
654 mVoiceULInStream = new InStream(paramsBT, slots, mULPipeWriter); 681 mVoiceULInStream = new InStream(paramsBT, micSlots, mULPipeWriter);
655 mVoiceULOutStream = new OutStream(paramsBT, slots, mULPipeReader); 682 mVoiceULOutStream = new OutStream(paramsBT, slots, mULPipeReader);
656 683
657 /* Voice call downlink */ 684 /* Voice call downlink */
@@ -844,7 +871,7 @@ int AudioHwDevice::enableVoiceCall()
844 outStream->setVoiceCall(true); 871 outStream->setVoiceCall(true);
845 872
846 /* Uplink input stream: Mic -> Pipe */ 873 /* Uplink input stream: Mic -> Pipe */
847 int ret = mReaders[kCPUPortId]->registerStream(mVoiceULInStream); 874 int ret = mReaders[mMediaPortId]->registerStream(mVoiceULInStream);
848 if (ret) { 875 if (ret) {
849 ALOGE("AudioHwDevice: failed to register uplink in stream %d", ret); 876 ALOGE("AudioHwDevice: failed to register uplink in stream %d", ret);
850 return ret; 877 return ret;
@@ -892,8 +919,8 @@ void AudioHwDevice::disableVoiceCall()
892 if (mWriters[kBTPortId]->isStreamRegistered(mVoiceULOutStream)) 919 if (mWriters[kBTPortId]->isStreamRegistered(mVoiceULOutStream))
893 mWriters[kBTPortId]->unregisterStream(mVoiceULOutStream); 920 mWriters[kBTPortId]->unregisterStream(mVoiceULOutStream);
894 921
895 if (mReaders[kCPUPortId]->isStreamRegistered(mVoiceULInStream)) 922 if (mReaders[mMediaPortId]->isStreamRegistered(mVoiceULInStream))
896 mReaders[kCPUPortId]->unregisterStream(mVoiceULInStream); 923 mReaders[mMediaPortId]->unregisterStream(mVoiceULInStream);
897} 924}
898 925
899int AudioHwDevice::enterVoiceCall() 926int AudioHwDevice::enterVoiceCall()
@@ -1061,45 +1088,47 @@ AudioStreamIn* AudioHwDevice::openInputStream(audio_io_handle_t handle,
1061 audio_devices_t devices, 1088 audio_devices_t devices,
1062 struct audio_config *config) 1089 struct audio_config *config)
1063{ 1090{
1064 uint32_t port = 0; 1091 uint32_t port = mMediaPortId;
1092 uint32_t srcSlot0, srcSlot1;
1065 uint32_t channels = popcount(config->channel_mask); 1093 uint32_t channels = popcount(config->channel_mask);
1066 1094
1067 ALOGV("AudioHwDevice: openInputStream()"); 1095 ALOGV("AudioHwDevice: openInputStream()");
1068 1096
1069 uint32_t srcMask, dstMask;
1070 switch (devices) { 1097 switch (devices) {
1071 case AUDIO_DEVICE_IN_BUILTIN_MIC: 1098 case AUDIO_DEVICE_IN_BUILTIN_MIC:
1072 case AUDIO_DEVICE_IN_VOICE_CALL: 1099 case AUDIO_DEVICE_IN_VOICE_CALL:
1073 if (channels == 1) { 1100 if (usesJAMR3()) {
1074 /* Mic is in slots 0&1 (mask = 0x03) on port 0, but AF wants 1101 srcSlot0 = 2;
1075 * only mono so take only one channel here */ 1102 srcSlot1 = 2;
1076 srcMask = 0x01; 1103 } else {
1077 dstMask = 0x01; 1104 srcSlot0 = 0;
1105 srcSlot1 = 1;
1078 } 1106 }
1079 else {
1080 srcMask = 0x03;
1081 dstMask = 0x03;
1082 }
1083 port = 0;
1084 break; 1107 break;
1085 case AUDIO_DEVICE_IN_BACK_MIC: 1108 case AUDIO_DEVICE_IN_BACK_MIC:
1086 if (channels == 1) { 1109 if (usesJAMR3()) {
1087 srcMask = 0x08; 1110 srcSlot0 = 3;
1088 dstMask = 0x01; 1111 srcSlot1 = 3;
1112 } else {
1113 srcSlot0 = 0;
1114 srcSlot1 = 1;
1089 } 1115 }
1090 else {
1091 ALOGE("AudioHwDevice: device 0x%08x only supports 1 channel",
1092 devices);
1093 return NULL;
1094 }
1095 port = 1;
1096 break; 1116 break;
1097 default: 1117 default:
1098 ALOGE("AudioHwDevice: device 0x%08x is not supported", devices); 1118 ALOGE("AudioHwDevice: device 0x%08x is not supported", devices);
1099 return NULL; 1119 return NULL;
1100 } 1120 }
1101 1121
1102 SlotMap slotMap(srcMask, dstMask); 1122 SlotMap slotMap;
1123 if (channels >= 1)
1124 slotMap[0] = srcSlot0;
1125 if (channels == 2)
1126 slotMap[1] = srcSlot1;
1127 if (channels > 2) {
1128 ALOGE("AudioHwDevice: %u channels are not supported", channels);
1129 return NULL;
1130 }
1131
1103 if (!slotMap.isValid()) { 1132 if (!slotMap.isValid()) {
1104 ALOGE("AudioHwDevice: failed to create slot map"); 1133 ALOGE("AudioHwDevice: failed to create slot map");
1105 return NULL; 1134 return NULL;
@@ -1153,16 +1182,16 @@ AudioStreamOut* AudioHwDevice::openOutputStream(audio_io_handle_t handle,
1153 uint32_t destMask; 1182 uint32_t destMask;
1154 switch (devices) { 1183 switch (devices) {
1155 case AUDIO_DEVICE_OUT_SPEAKER: 1184 case AUDIO_DEVICE_OUT_SPEAKER:
1156 port = 0; 1185 port = mMediaPortId;
1157 destMask = 0x03; 1186 destMask = 0x03;
1158 break; 1187 break;
1159 case AUDIO_DEVICE_OUT_WIRED_HEADPHONE: 1188 case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
1160 case AUDIO_DEVICE_OUT_WIRED_HEADSET: 1189 case AUDIO_DEVICE_OUT_WIRED_HEADSET:
1161 port = 1; 1190 port = kJAMR3PortId;
1162 destMask = 0x0c; 1191 destMask = 0x0c;
1163 break; 1192 break;
1164 case AUDIO_DEVICE_OUT_WIRED_HEADPHONE2: 1193 case AUDIO_DEVICE_OUT_WIRED_HEADPHONE2:
1165 port = 1; 1194 port = kJAMR3PortId;
1166 destMask = 0x30; 1195 destMask = 0x30;
1167 break; 1196 break;
1168 default: 1197 default:
diff --git a/audio/multizone/AudioHw.h b/audio/multizone/AudioHw.h
index 375b208..0d475da 100644
--- a/audio/multizone/AudioHw.h
+++ b/audio/multizone/AudioHw.h
@@ -214,6 +214,7 @@ class AudioHwDevice {
214 typedef vector<PcmReader*> ReaderVect; 214 typedef vector<PcmReader*> ReaderVect;
215 typedef vector<PcmWriter*> WriterVect; 215 typedef vector<PcmWriter*> WriterVect;
216 216
217 bool usesJAMR3() const { return mMediaPortId == kJAMR3PortId; }
217 const char *getModeName(audio_mode_t mode) const; 218 const char *getModeName(audio_mode_t mode) const;
218 int enterVoiceCall(); 219 int enterVoiceCall();
219 void leaveVoiceCall(); 220 void leaveVoiceCall();
@@ -230,6 +231,7 @@ class AudioHwDevice {
230 StreamOutSet mOutStreams; 231 StreamOutSet mOutStreams;
231 bool mMicMute; 232 bool mMicMute;
232 audio_mode_t mMode; 233 audio_mode_t mMode;
234 uint32_t mMediaPortId;
233 wp<AudioStreamOut> mPrimaryStreamOut; 235 wp<AudioStreamOut> mPrimaryStreamOut;
234 tiaudioutils::MonoPipe *mULPipe; 236 tiaudioutils::MonoPipe *mULPipe;
235 tiaudioutils::MonoPipe *mDLPipe; 237 tiaudioutils::MonoPipe *mDLPipe;
diff --git a/audio/multizone/dra7evm_paths.xml b/audio/multizone/dra7evm_paths.xml
index 7b5f057..06419be 100644
--- a/audio/multizone/dra7evm_paths.xml
+++ b/audio/multizone/dra7evm_paths.xml
@@ -41,7 +41,7 @@
41<!-- JAMR3 board, codec-B input: Mic --> 41<!-- JAMR3 board, codec-B input: Mic -->
42<ctl name="J3B Left PGA Mixer Line1L Switch" value="1" /> 42<ctl name="J3B Left PGA Mixer Line1L Switch" value="1" />
43<ctl name="J3B Right PGA Mixer Line1R Switch" value="1" /> 43<ctl name="J3B Right PGA Mixer Line1R Switch" value="1" />
44<ctl name="J3B PGA Capture Switch" value="0" /> 44<ctl name="J3B PGA Capture Switch" value="1" />
45<ctl name="J3B PGA Capture Volume" value="0" /> 45<ctl name="J3B PGA Capture Volume" value="0" />
46<ctl name="J3B Left Line1L Mux" value="differential" /> 46<ctl name="J3B Left Line1L Mux" value="differential" />
47<ctl name="J3B Right Line1L Mux" value="differential" /> 47<ctl name="J3B Right Line1L Mux" value="differential" />
@@ -75,21 +75,4 @@
75<ctl name="J3C Line Playback Switch" value="1" /> 75<ctl name="J3C Line Playback Switch" value="1" />
76<ctl name="J3C PCM Playback Volume" value="127" /> 76<ctl name="J3C PCM Playback Volume" value="127" />
77 77
78<!-- Device specific routes -->
79
80<!-- JAMR3 codec A input: Line-In -->
81<path name="AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET">
82<ctl name="J3A PGA Capture Switch" value="1" />
83</path>
84
85<!-- On-board input: Stereo mic -->
86<path name="AUDIO_DEVICE_IN_BUILTIN_MIC">
87<ctl name="PGA Capture Switch" value="1" />
88</path>
89
90<!-- JAMR3 codec B input: Mono mic right -->
91<path name="AUDIO_DEVICE_IN_BACK_MIC">
92<ctl name="J3B PGA Capture Switch" id="1" value="1" />
93</path>
94
95</mixer> 78</mixer>