Promotion of av-userspace.lnx.1.0-00047.
CRs Change ID Subject
--------------------------------------------------------------------------------------------------------------
975668 Ie121ea3e37697ee14e24d8ccd68c697c0220f0ab hal: spkr_prot: read temperature once during calibration
978396 Ibe0f3639ac4825330a710e86abc31d609136c924 audiopolicy: do not set FM volume during device connecti
979685 Id1cc27db8ddbbdbf1dffc02c07ce7785b184770b hal: Fix the device disable/enable sequence for capture
Change-Id: I925c58ffc5b9409492ce749eb0844d9c5494a1f7
CRs-Fixed: 979685, 978396, 975668
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index fdfbfad..2a246cd 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -66,9 +66,6 @@
#define MIN_RESISTANCE_SPKR_Q24 (2 * (1 << 24))
#define MAX_RESISTANCE_SPKR_Q24 (40 * (1 << 24))
-/*Number of Attempts for WSA equilibrium t0 reads*/
-#define NUM_ATTEMPTS 5
-
/*Path where the calibration file will be stored*/
#define CALIB_FILE "/data/misc/audio/audio.cal"
@@ -646,7 +643,6 @@
int i = 0;
int t0_spk_1 = 0;
int t0_spk_2 = 0;
- int t0_spk_prior = 0;
bool goahead = false;
struct audio_cal_info_spk_prot_cfg protCfg;
FILE *fp;
@@ -769,92 +765,46 @@
thermal_fd = -1;
thermal_fd = open(wsa_path, O_RDONLY);
if (thermal_fd > 0) {
- for (i = 0; i < NUM_ATTEMPTS; i++) {
- if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0) {
- t0_spk_1 = atoi(buf);
- if (i > 0 && (t0_spk_1 != t0_spk_prior)) {
- ALOGE("%s: spkr1 curr temp: %d, prev temp: %d\n",
- __func__, t0_spk_1, t0_spk_prior);
- break;
- }
- t0_spk_prior = t0_spk_1;
- pthread_mutex_unlock(&adev->lock);
- sleep(1);
- pthread_mutex_lock(&adev->lock);
- if (is_speaker_in_use(&sec))
- break;
- } else {
- ALOGE("%s: read fail for %s err:%d\n", __func__, wsa_path, ret);
- break;
- }
- }
- close(thermal_fd);
+ if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0)
+ t0_spk_1 = atoi(buf);
+ else
+ ALOGE("%s: read fail for %s err:%d\n", __func__, wsa_path, ret);
+ close(thermal_fd);
} else {
ALOGE("%s: fd for %s is NULL\n", __func__, wsa_path);
}
- if (i == NUM_ATTEMPTS) {
- if (t0_spk_1 < TZ_TEMP_MIN_THRESHOLD ||
- t0_spk_1 > TZ_TEMP_MAX_THRESHOLD) {
- pthread_mutex_unlock(&adev->lock);
- sleep(WAKEUP_MIN_IDLE_CHECK);
- continue;
- }
- ALOGD("%s: temp T0 for spkr1 %d\n", __func__, t0_spk_1);
- /*Convert temp into q6 format*/
- t0_spk_1 = (t0_spk_1 * (1 << 6));
- } else {
- ALOGV("%s: thermal equilibrium failed for spkr1 in %d/%d readings\n",
- __func__, i, NUM_ATTEMPTS);
+ if (t0_spk_1 < TZ_TEMP_MIN_THRESHOLD ||
+ t0_spk_1 > TZ_TEMP_MAX_THRESHOLD) {
pthread_mutex_unlock(&adev->lock);
sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
+ ALOGD("%s: temp T0 for spkr1 %d\n", __func__, t0_spk_1);
+ /*Convert temp into q6 format*/
+ t0_spk_1 = (t0_spk_1 * (1 << 6));
}
if (spk_2_tzn >= 0) {
snprintf(wsa_path, MAX_PATH, TZ_WSA, spk_2_tzn);
ALOGV("%s: wsa_path: %s\n", __func__, wsa_path);
thermal_fd = open(wsa_path, O_RDONLY);
if (thermal_fd > 0) {
- for (i = 0; i < NUM_ATTEMPTS; i++) {
- if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0) {
- t0_spk_2 = atoi(buf);
- if (i > 0 && (t0_spk_2 != t0_spk_prior)) {
- ALOGE("%s: spkr2 curr temp: %d, prev temp: %d\n",
- __func__, t0_spk_2, t0_spk_prior);
- break;
- }
- t0_spk_prior = t0_spk_2;
- pthread_mutex_unlock(&adev->lock);
- sleep(1);
- pthread_mutex_lock(&adev->lock);
- if (is_speaker_in_use(&sec))
- break;
- } else {
- ALOGE("%s: read fail for %s err:%d\n", __func__, wsa_path, ret);
- break;
- }
- }
- close(thermal_fd);
+ if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0)
+ t0_spk_2 = atoi(buf);
+ else
+ ALOGE("%s: read fail for %s err:%d\n", __func__, wsa_path, ret);
+ close(thermal_fd);
} else {
ALOGE("%s: fd for %s is NULL\n", __func__, wsa_path);
}
- if (i == NUM_ATTEMPTS) {
- if (t0_spk_2 < TZ_TEMP_MIN_THRESHOLD ||
- t0_spk_2 > TZ_TEMP_MAX_THRESHOLD) {
- pthread_mutex_unlock(&adev->lock);
- sleep(WAKEUP_MIN_IDLE_CHECK);
- continue;
- }
- ALOGD("%s: temp T0 for spkr2 %d\n", __func__, t0_spk_2);
- /*Convert temp into q6 format*/
- t0_spk_2 = (t0_spk_2 * (1 << 6));
- } else {
- ALOGV("%s: thermal equilibrium failed for spkr2 in %d/%d readings\n",
- __func__, i, NUM_ATTEMPTS);
+ if (t0_spk_2 < TZ_TEMP_MIN_THRESHOLD ||
+ t0_spk_2 > TZ_TEMP_MAX_THRESHOLD) {
pthread_mutex_unlock(&adev->lock);
sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
+ ALOGD("%s: temp T0 for spkr2 %d\n", __func__, t0_spk_2);
+ /*Convert temp into q6 format*/
+ t0_spk_2 = (t0_spk_2 * (1 << 6));
}
}
pthread_mutex_unlock(&adev->lock);
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e4b8a37..0526e9b 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -754,7 +754,8 @@
usecase != uc_info &&
usecase->in_snd_device != snd_device &&
((uc_info->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) &&
- ((usecase->devices & ~AUDIO_DEVICE_BIT_IN) & AUDIO_DEVICE_IN_ALL_CODEC_BACKEND)) &&
+ (((usecase->devices & ~AUDIO_DEVICE_BIT_IN) & AUDIO_DEVICE_IN_ALL_CODEC_BACKEND) ||
+ (usecase->type == VOICE_CALL))) &&
(usecase->id != USECASE_AUDIO_SPKR_CALIB_TX)) {
ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..",
__func__, use_case_table[usecase->id],
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 3c3686f..dee4e8b 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -291,9 +291,6 @@
mPrimaryOutput->changeRefCount(AUDIO_STREAM_MUSIC, -1);
}
AudioParameter param = AudioParameter();
- float volumeDb = mPrimaryOutput->mCurVolume[AUDIO_STREAM_MUSIC];
- mPrevFMVolumeDb = volumeDb;
- param.addFloat(String8("fm_volume"), Volume::DbToAmpl(volumeDb));
param.addInt(String8("handle_fm"), (int)newDevice);
mpClientInterface->setParameters(mPrimaryOutput->mIoHandle, param.toString());
}