Merge "hal: spk_prot: update initial calibration idle time check"
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index c5c757b..aab9f74 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -77,6 +77,7 @@
#define WAIT_TIME_SPKR_CALIB (60 * 1000 * 1000)
#define MIN_SPKR_IDLE_SEC (60 * 30)
+#define WAKEUP_MIN_IDLE_CHECK 30
/*Once calibration is started sleep for 1 sec to allow
the calibration to kick off*/
@@ -587,7 +588,7 @@
}
break;
} else if (status.status == -EAGAIN) {
- ALOGD("%s: spkr_prot_thread try again", __func__);
+ ALOGV("%s: spkr_prot_thread try again", __func__);
usleep(WAIT_FOR_GET_CALIB_STATUS);
} else {
ALOGE("%s: spkr_prot_thread get failed status %d",
@@ -767,18 +768,22 @@
if (is_speaker_in_use(&sec)) {
ALOGV("%s: WSA Speaker in use retry calibration", __func__);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
} else {
+ ALOGD("%s: wsa speaker idle %ld,minimum time %ld", __func__, sec, min_idle_time);
if (sec < min_idle_time) {
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
- ALOGV("%s: wsa speaker idle %ld min time %ld", __func__, sec, min_idle_time);
goahead = true;
}
if (!list_empty(&adev->usecase_list)) {
ALOGD("%s: Usecase active re-try calibration", __func__);
- goahead = false;
+ pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
+ continue;
}
if (goahead) {
if (spk_1_tzn >= 0) {
@@ -810,15 +815,17 @@
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));
- ALOGD("%s: temp T0 for spkr1 %d\n", __func__, t0_spk_1);
} else {
ALOGV("%s: thermal equilibrium failed for spkr1 in %d/%d readings\n",
__func__, i, NUM_ATTEMPTS);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
}
@@ -850,15 +857,17 @@
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));
- ALOGD("%s: temp T0 for spkr2 %d\n", __func__, t0_spk_2);
} else {
ALOGV("%s: thermal equilibrium failed for spkr2 in %d/%d readings\n",
__func__, i, NUM_ATTEMPTS);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
}
@@ -892,19 +901,22 @@
if (is_speaker_in_use(&sec)) {
ALOGV("%s: Speaker in use retry calibration", __func__);
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
} else {
if (sec < min_idle_time) {
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
continue;
}
- ALOGD("%s: speaker idle %ld min time %ld", __func__, sec, min_idle_time);
goahead = true;
}
if (!list_empty(&adev->usecase_list)) {
ALOGD("%s: Usecase active re-try calibration", __func__);
goahead = false;
pthread_mutex_unlock(&adev->lock);
+ sleep(WAKEUP_MIN_IDLE_CHECK);
+ continue;
}
if (goahead) {
int status;