Skip to content

Commit

Permalink
audio: Support STE/Sony FM Radio
Browse files Browse the repository at this point in the history
Change-Id: I1ba0a65ae6f461dfbf8e3e9ffd90e4dd70ae5394
  • Loading branch information
Giulio Cervera committed Jan 30, 2013
1 parent efa5d14 commit 92e8b9e
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 37 deletions.
2 changes: 1 addition & 1 deletion alsa_sound/ALSADevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ char* ALSADevice::getUCMDevice(uint32_t devices, int input, char *rxDevice)
if (strncmp(mCurTxUCMDevice, "None", 4)) {
return strdup(mCurTxUCMDevice);
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
} else if ((devices & AudioSystem::DEVICE_IN_FM_RX) ||
(devices & AudioSystem::DEVICE_IN_FM_RX_A2DP)) {
/* Nothing to be done, use current tx device or set dummy device */
Expand Down
15 changes: 8 additions & 7 deletions alsa_sound/AudioHardwareALSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ status_t AudioHardwareALSA::doRouting(int device)
bool isRouted = false;

if ((device == AudioSystem::DEVICE_IN_VOICE_CALL)
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
|| (device == AudioSystem::DEVICE_IN_FM_RX)
|| (device == AudioSystem::DEVICE_OUT_DIRECTOUTPUT)
|| (device == AudioSystem::DEVICE_IN_FM_RX_A2DP)
Expand Down Expand Up @@ -1231,20 +1231,20 @@ AudioHardwareALSA::openInputStream(uint32_t devices,
if((0 == strncmp(itDev->useCase, SND_USE_CASE_VERB_HIFI_REC, MAX_UC_LEN))
||(0 == strncmp(itDev->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, MAX_UC_LEN))
||(0 == strncmp(itDev->useCase, SND_USE_CASE_MOD_CAPTURE_FM, MAX_UC_LEN))
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
||(0 == strncmp(itDev->useCase, SND_USE_CASE_VERB_FM_REC, MAX_UC_LEN))
#endif
)
{
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if(!(devices == AudioSystem::DEVICE_IN_FM_RX_A2DP)){
ALOGD("Input stream already exists, new stream not permitted: useCase:%s, devices:0x%x, module:%p",
itDev->useCase, itDev->devices, itDev->module);
return in;
}
#endif
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
else if ((0 == strncmp(itDev->useCase, SND_USE_CASE_VERB_FM_A2DP_REC, MAX_UC_LEN))
||(0 == strncmp(itDev->useCase, SND_USE_CASE_MOD_CAPTURE_A2DP_FM, MAX_UC_LEN)))
{
Expand Down Expand Up @@ -1296,7 +1296,7 @@ AudioHardwareALSA::openInputStream(uint32_t devices,
sizeof(alsa_handle.useCase));
}
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
} else if((devices == AudioSystem::DEVICE_IN_FM_RX)) {
strlcpy(alsa_handle.useCase, SND_USE_CASE_MOD_CAPTURE_FM, sizeof(alsa_handle.useCase));
} else if(devices == AudioSystem::DEVICE_IN_FM_RX_A2DP) {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ AudioHardwareALSA::openInputStream(uint32_t devices,
sizeof(alsa_handle.useCase));
}
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
} else if(devices == AudioSystem::DEVICE_IN_FM_RX) {
strlcpy(alsa_handle.useCase, SND_USE_CASE_VERB_FM_REC, sizeof(alsa_handle.useCase));
} else if (devices == AudioSystem::DEVICE_IN_FM_RX_A2DP) {
Expand Down Expand Up @@ -1384,7 +1384,7 @@ AudioHardwareALSA::openInputStream(uint32_t devices,
}

if(!strcmp(it->useCase, SND_USE_CASE_VERB_HIFI_REC) ||
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
!strcmp(it->useCase, SND_USE_CASE_VERB_FM_REC) ||
!strcmp(it->useCase, SND_USE_CASE_VERB_FM_A2DP_REC) ||
#endif
Expand Down Expand Up @@ -1493,6 +1493,7 @@ size_t AudioHardwareALSA::getInputBufferSize(uint32_t sampleRate, int format, in
return bufferSize;
}

//#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
#ifdef QCOM_FM_ENABLED
void AudioHardwareALSA::handleFm(int device)
{
Expand Down
8 changes: 8 additions & 0 deletions alsa_sound/AudioPolicyManagerALSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,14 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(int inputSource)
device = AudioSystem::DEVICE_IN_VOICE_CALL;
}
break;
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
case AUDIO_SOURCE_FM_RX:
device = AudioSystem::DEVICE_IN_FM_RX;
break;
case AUDIO_SOURCE_FM_RX_A2DP:
device = AudioSystem::DEVICE_IN_FM_RX_A2DP;
break;
#endif
default:
ALOGW("getDeviceForInputSource() invalid input source %d", inputSource);
break;
Expand Down
4 changes: 2 additions & 2 deletions alsa_sound/AudioStreamInALSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
sizeof(mHandle->useCase));
}
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
} else if(mHandle->devices == AudioSystem::DEVICE_IN_FM_RX) {
strlcpy(mHandle->useCase, SND_USE_CASE_MOD_CAPTURE_FM, sizeof(mHandle->useCase));
} else if (mHandle->devices == AudioSystem::DEVICE_IN_FM_RX_A2DP) {
Expand Down Expand Up @@ -213,7 +213,7 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
sizeof(mHandle->useCase));
}
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
} else if(mHandle->devices == AudioSystem::DEVICE_IN_FM_RX) {
strlcpy(mHandle->useCase, SND_USE_CASE_VERB_FM_REC, sizeof(mHandle->useCase));
} else if (mHandle->devices == AudioSystem::DEVICE_IN_FM_RX_A2DP) {
Expand Down
4 changes: 2 additions & 2 deletions alsa_sound/audio_hw_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static uint32_t adev_get_supported_devices(const struct audio_hw_device *dev)
#endif
AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
AUDIO_DEVICE_OUT_FM |
#endif
#ifdef QCOM_FM_TX_ENABLED
Expand All @@ -405,7 +405,7 @@ static uint32_t adev_get_supported_devices(const struct audio_hw_device *dev)
#ifdef QCOM_ANC_HEADSET_ENABLED
AUDIO_DEVICE_IN_ANC_HEADSET |
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
AUDIO_DEVICE_IN_FM_RX |
AUDIO_DEVICE_IN_FM_RX_A2DP |
#endif
Expand Down
2 changes: 1 addition & 1 deletion alsa_sound/audio_policy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ audio_hw_modules {
sampling_rates 44100
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE_OUT_ALL_A2DP
devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL|AUDIO_DEVICE_OUT_PROXY|AUDIO_DEVICE_OUT_FM|AUDIO_DEVICE_OUT_FM_TX|AUDIO_DEVICE_OUT_ALL_A2DP
flags AUDIO_OUTPUT_FLAG_PRIMARY
}
lpa {
Expand Down
43 changes: 24 additions & 19 deletions msm8660/AudioHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@

#ifdef QCOM_FM_ENABLED
#define FM_DEVICE "/dev/msm_fm"
#endif

#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
#define FM_A2DP_REC 1
#define FM_FILE_REC 2
#endif
Expand Down Expand Up @@ -248,7 +251,7 @@ enum STREAM_TYPES {
#ifdef QCOM_VOIP_ENABLED
VOIP_CALL,
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
FM_RADIO,
FM_REC,
FM_A2DP,
Expand All @@ -264,7 +267,7 @@ typedef struct ComboDeviceType
CurrentComboDeviceStruct CurrentComboDeviceData;
Mutex mComboDeviceLock;

#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
enum FM_STATE {
FM_INVALID=1,
FM_OFF,
Expand Down Expand Up @@ -534,7 +537,7 @@ static status_t updateDeviceInfo(int rx_device,int tx_device) {
#ifdef QCOM_TUNNEL_LPA_ENABLED
case LPA_DECODE:
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
case FM_RADIO:
case FM_A2DP:
#endif
Expand Down Expand Up @@ -1748,7 +1751,7 @@ static status_t do_route_audio_rpc(uint32_t device,
new_tx_device = DEVICE_HANDSET_TX;
ALOGV("In NO MIC HEADSET");
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
else if (device == SND_DEVICE_FM_HANDSET) {
fm_device = DEVICE_FMRADIO_HANDSET_RX;
ALOGV("In FM HANDSET");
Expand Down Expand Up @@ -1852,7 +1855,7 @@ static status_t do_route_audio_rpc(uint32_t device,
ALOGI("In ANC HEADPhone");
}
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
else if(device == SND_DEVICE_FM_TX){
new_rx_device = DEVICE_FMRADIO_STEREO_RX;
ALOGI("In DEVICE_FMRADIO_STEREO_RX and cur_tx");
Expand Down Expand Up @@ -2354,7 +2357,7 @@ status_t AudioHardware::doRouting(AudioStreamInMSM8x60 *input)
// call
// Recording will happen through currently active tx device
if((inputDevice == AudioSystem::DEVICE_IN_VOICE_CALL)
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
|| (inputDevice == AudioSystem::DEVICE_IN_FM_RX)
|| (inputDevice == AudioSystem::DEVICE_IN_FM_RX_A2DP)
#endif
Expand Down Expand Up @@ -2398,7 +2401,7 @@ status_t AudioHardware::doRouting(AudioStreamInMSM8x60 *input)
ALOGI("Routing audio to Speakerphone\n");
sndDevice = SND_DEVICE_NO_MIC_HEADSET;
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
else if (outputDevices & AudioSystem::DEVICE_OUT_FM_TX) {
ALOGE("Routing audio_rx to Speaker\n");
sndDevice = SND_DEVICE_SPEAKER_TX;
Expand Down Expand Up @@ -2463,7 +2466,7 @@ status_t AudioHardware::doRouting(AudioStreamInMSM8x60 *input)
sndDevice = SND_DEVICE_HEADSET_AND_SPEAKER;
audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE);
} else
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if ((outputDevices & AudioSystem::DEVICE_OUT_FM_TX) &&
(outputDevices & AudioSystem::DEVICE_OUT_SPEAKER)) {
ALOGI("Routing audio to FM Tx and Speaker\n");
Expand Down Expand Up @@ -2507,7 +2510,7 @@ status_t AudioHardware::doRouting(AudioStreamInMSM8x60 *input)
sndDevice = SND_DEVICE_SPEAKER;
audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE);
} else
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if (outputDevices & AudioSystem::DEVICE_OUT_FM_TX){
ALOGI("Routing audio to FM Tx Device\n");
sndDevice = SND_DEVICE_FM_TX;
Expand Down Expand Up @@ -2573,7 +2576,9 @@ status_t AudioHardware::doRouting(AudioStreamInMSM8x60 *input)
if ((mFmFd != -1) && !(outputDevices & AudioSystem::DEVICE_OUT_FM)){
disableFM();
}
#endif

#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if ((CurrentComboDeviceData.DeviceId == INVALID_DEVICE) &&
(sndDevice == SND_DEVICE_FM_TX_AND_SPEAKER )){
/* speaker rx is already enabled change snd device to the fm tx
Expand Down Expand Up @@ -2627,7 +2632,7 @@ status_t AudioHardware::enableComboDevice(uint32_t sndDevice, bool enableOrDisab
ALOGE("enableDevice failed for device %d", DEVICE_SPEAKER_RX);
return -1;
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if(SND_DEVICE_FM_TX_AND_SPEAKER == sndDevice){

if(getNodeByStreamType(VOICE_CALL) || getNodeByStreamType(FM_RADIO) ||
Expand Down Expand Up @@ -2987,7 +2992,7 @@ ssize_t AudioHardware::AudioStreamOutMSM8x60::write(const void* buffer, size_t b
return 0;
}
Mutex::Autolock lock_1(mComboDeviceLock);
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if(CurrentComboDeviceData.DeviceId == SND_DEVICE_FM_TX_AND_SPEAKER){
#ifdef QCOM_TUNNEL_LPA_ENABLED
Routing_table *LpaNode = getNodeByStreamType(LPA_DECODE);
Expand Down Expand Up @@ -3053,7 +3058,7 @@ status_t AudioHardware::AudioStreamOutMSM8x60::standby()
#ifdef QCOM_TUNNEL_LPA_ENABLED
&& !getNodeByStreamType(LPA_DECODE)
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
&& !getNodeByStreamType(FM_RADIO)
#endif
#ifdef QCOM_VOIP_ENABLED
Expand Down Expand Up @@ -4111,7 +4116,7 @@ status_t AudioHardware::AudioSessionOutLPA::start( )
}

Mutex::Autolock lock_1(mComboDeviceLock);
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if(CurrentComboDeviceData.DeviceId == SND_DEVICE_FM_TX_AND_SPEAKER){
ALOGD("Routing LPA steam to speaker for combo device");
ALOGD("combo:msm_route_stream(LPA_DECODE,session id:%d,dev id:%d,1)",sessionId,
Expand Down Expand Up @@ -4256,7 +4261,7 @@ void AudioHardware::AudioSessionOutLPA::reset()
}
deleteFromTable(LPA_DECODE);
if (!getNodeByStreamType(VOICE_CALL) && !getNodeByStreamType(PCM_PLAY)
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
&& !getNodeByStreamType(FM_RADIO)
#endif
#ifdef QCOM_VOIP_ENABLED
Expand Down Expand Up @@ -4608,7 +4613,7 @@ ssize_t AudioHardware::AudioStreamInMSM8x60::read( void* buffer, ssize_t bytes)
hw->mLock.unlock();
return -1;
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if((mDevices == AudioSystem::DEVICE_IN_FM_RX) || (mDevices == AudioSystem::DEVICE_IN_FM_RX_A2DP) ){
if(ioctl(mFdin, AUDIO_GET_SESSION_ID, &dec_id)) {
ALOGE("AUDIO_GET_SESSION_ID failed*********");
Expand Down Expand Up @@ -4677,7 +4682,7 @@ ssize_t AudioHardware::AudioStreamInMSM8x60::read( void* buffer, ssize_t bytes)
if (mState < AUDIO_INPUT_STARTED) {
if (!(mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK ||
mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK)) {
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
// force routing to input device
// for FM recording, no need to reconfigure afe loopback path
if (mFmRec != FM_FILE_REC) {
Expand All @@ -4691,7 +4696,7 @@ ssize_t AudioHardware::AudioStreamInMSM8x60::read( void* buffer, ssize_t bytes)
mHardware->do_aic3254_control(snd_dev);
}
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
}
#endif
}
Expand Down Expand Up @@ -4760,7 +4765,7 @@ status_t AudioHardware::AudioStreamInMSM8x60::standby()
}
mState = AUDIO_INPUT_CLOSED;
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if (mFmRec == FM_A2DP_REC) {
//A2DP Recording
temp = getNodeByStreamType(FM_A2DP);
Expand Down Expand Up @@ -5186,7 +5191,7 @@ status_t AudioHardware::AudioStreamInVoip::standby()
&& !getNodeByStreamType(LPA_DECODE)
#endif /*QCOM_TUNNEL_LPA_ENABLED*/
&& !getNodeByStreamType(PCM_PLAY)
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
&& !getNodeByStreamType(FM_RADIO)
#endif /*QCOM_FM_ENABLED*/
) {
Expand Down
8 changes: 4 additions & 4 deletions msm8660/AudioPolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
}
break;
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if (mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM) {
device |= AudioSystem::DEVICE_OUT_FM;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_ANC_HEADSET;
}
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if (device2 == 0) {
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM_TX;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
break;
}
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
if (mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM) {
device |= AudioSystem::DEVICE_OUT_FM;
}
Expand Down Expand Up @@ -885,7 +885,7 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(int inputSource)
device = AudioSystem::DEVICE_IN_VOICE_CALL;
}
break;
#ifdef QCOM_FM_ENABLED
#if defined (QCOM_FM_ENABLED) || defined(STE_FM)
case AUDIO_SOURCE_FM_RX:
device = AudioSystem::DEVICE_IN_FM_RX;
break;
Expand Down
4 changes: 3 additions & 1 deletion msm8660/audio_hw_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,10 @@ static uint32_t adev_get_supported_devices(const struct audio_hw_device *dev)
#ifdef QCOM_ANC_HEADSET_ENABLED
AUDIO_DEVICE_IN_ANC_HEADSET |
#endif
#ifdef QCOM_FM_ENABLED
#if defined(QCOM_FM_ENABLED) || defined(STE_FM)
AUDIO_DEVICE_IN_FM_RX |
#endif
#ifdef QCOM_FM_ENABLED
AUDIO_DEVICE_IN_FM_RX_A2DP |
#endif
AUDIO_DEVICE_IN_DEFAULT);
Expand Down

0 comments on commit 92e8b9e

Please sign in to comment.