diff options
author | Ethan Chen <intervigil@gmail.com> | 2015-07-03 21:52:38 -0700 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2015-07-15 12:20:34 -0700 |
commit | ab07ccc667cbf260e144dc3adacace576fa3bc11 (patch) | |
tree | f19ede45a8037edbfa6d482e0f4af62f301f2508 | |
parent | 83136ef9c4a2142bc9f1ede36a8f314fee2d4448 (diff) | |
download | android_hardware_qcom_audio-stable/cm-12.1-caf-8960-YOG4P.tar.gz android_hardware_qcom_audio-stable/cm-12.1-caf-8960-YOG4P.tar.bz2 android_hardware_qcom_audio-stable/cm-12.1-caf-8960-YOG4P.zip |
audio: Notify amplifier of device enable/disablestable/cm-12.1-caf-8960-YOG4P
Change-Id: I1b9ed8943743e77efafb110d678cd380e78555ae
Ticket: CYNGNOS-452
-rw-r--r-- | legacy/alsa_sound/ALSADevice.cpp | 26 | ||||
-rw-r--r-- | legacy/alsa_sound/audio_hw_hal.cpp | 17 |
2 files changed, 41 insertions, 2 deletions
diff --git a/legacy/alsa_sound/ALSADevice.cpp b/legacy/alsa_sound/ALSADevice.cpp index 8933214c..9d1a1368 100644 --- a/legacy/alsa_sound/ALSADevice.cpp +++ b/legacy/alsa_sound/ALSADevice.cpp @@ -534,8 +534,14 @@ status_t ALSADevice::setSoftwareParams(alsa_handle_t *handle) extern "C" { extern int amplifier_set_devices(uint32_t devices); +extern int amplifier_enable_devices(uint32_t devices, bool enable); }; +/* HACK: decoding the mCurTxUCMDevice/mCurRxUCMDevice back to uint32_t isn't + possible, just store the previous state instead. */ +static uint32_t current_rx_devices = 0; +static uint32_t current_tx_devices = 0; + void ALSADevice::switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t mode) { const char **mods_list; @@ -632,6 +638,12 @@ void ALSADevice::switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t #endif amplifier_set_devices(devices); + if (current_tx_devices == 0) { + current_tx_devices = devices & AudioSystem::DEVICE_IN_ALL; + } + if (current_rx_devices == 0) { + current_rx_devices = devices & AudioSystem::DEVICE_OUT_ALL; + } rxDevice = getUCMDevice(devices & AudioSystem::DEVICE_OUT_ALL, 0, NULL); ALOGV("%s: rxDevice %s devices:0x%x", __FUNCTION__, rxDevice,devices); @@ -690,6 +702,7 @@ void ALSADevice::switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t } } snd_use_case_set(handle->ucMgr, "_disdev", mCurRxUCMDevice); + amplifier_enable_devices(current_rx_devices, false); } } if (txDevice != NULL) { @@ -717,6 +730,7 @@ void ALSADevice::switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t } } snd_use_case_set(handle->ucMgr, "_disdev", mCurTxUCMDevice); + amplifier_enable_devices(current_tx_devices, false); } } @@ -728,12 +742,16 @@ void ALSADevice::switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t setEmuAntipop(0); } #endif + amplifier_enable_devices(devices, true); snd_use_case_set(handle->ucMgr, "_enadev", rxDevice); strlcpy(mCurRxUCMDevice, rxDevice, sizeof(mCurRxUCMDevice)); + current_rx_devices = devices & AudioSystem::DEVICE_OUT_ALL; } if (txDevice != NULL) { + amplifier_enable_devices(devices, true); snd_use_case_set(handle->ucMgr, "_enadev", txDevice); strlcpy(mCurTxUCMDevice, txDevice, sizeof(mCurTxUCMDevice)); + current_tx_devices = devices & AudioSystem::DEVICE_IN_ALL; } #ifdef QCOM_CSDCLIENT_ENABLED if (isPlatformFusion3() && (inCallDevSwitch == true)) { @@ -1643,10 +1661,14 @@ void ALSADevice::disableDevice(alsa_handle_t *handle) } } ALOGV("usecase_type is %d\n", usecase_type); - if (!(usecase_type & USECASE_TYPE_TX) && (strncmp(mCurTxUCMDevice, "None", 4))) + if (!(usecase_type & USECASE_TYPE_TX) && (strncmp(mCurTxUCMDevice, "None", 4))) { snd_use_case_set(handle->ucMgr, "_disdev", mCurTxUCMDevice); - if (!(usecase_type & USECASE_TYPE_RX) && (strncmp(mCurRxUCMDevice, "None", 4))) + amplifier_enable_devices(current_tx_devices, false); + } + if (!(usecase_type & USECASE_TYPE_RX) && (strncmp(mCurRxUCMDevice, "None", 4))) { snd_use_case_set(handle->ucMgr, "_disdev", mCurRxUCMDevice); + amplifier_enable_devices(current_rx_devices, false); + } } else { ALOGE("Invalid state, no valid use case found to disable"); } diff --git a/legacy/alsa_sound/audio_hw_hal.cpp b/legacy/alsa_sound/audio_hw_hal.cpp index fa976186..f5cd8894 100644 --- a/legacy/alsa_sound/audio_hw_hal.cpp +++ b/legacy/alsa_sound/audio_hw_hal.cpp @@ -202,6 +202,23 @@ int amplifier_set_devices(uint32_t devices) return 0; } +/* Must expose for ALSADevice.cpp */ +int amplifier_enable_devices(uint32_t devices, bool enable) +{ + amplifier_device_t *amp = get_amplifier_device(); + bool is_output = devices & AudioSystem::DEVICE_OUT_ALL; + + if (amp && amp->enable_output_devices && is_output) { + amp->enable_output_devices(amp, devices, enable); + } + + if (amp && amp->enable_input_devices && !is_output) { + amp->enable_input_devices(amp, devices, enable); + } + + return 0; +} + static int amplifier_set_mode(audio_mode_t mode) { amplifier_device_t *amp = get_amplifier_device(); |