hal: Send temperature initialization mixer control
Send temperature initialization mixer control to WSA881x codec
temperature sensor driver before reading the temperature for
proper temperature result.
Change-Id: I7c4073f32e47dfc1a5518256cf68e39085daa515
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index abbdc8e..e7c3661 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -1007,6 +1007,7 @@
int ret;
bool spv3_enable = false;
unsigned int afe_api_version = 0;
+ struct mixer_ctl *ctl;
memset(&protCfg, 0, sizeof(protCfg));
/* If the value of this persist.vendor.audio.spkr.cal.duration is 0
@@ -1114,9 +1115,18 @@
}
if (goahead) {
if (spk_1_tzn >= 0) {
+ const char *mixer_ctl_name = "SpkrLeft WSA T0 Init";
snprintf(wsa_path, MAX_PATH, TZ_WSA, spk_1_tzn);
ALOGV("%s: wsa_path: %s\n", __func__, wsa_path);
thermal_fd = -1;
+
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (ctl) {
+ ALOGD("%s: Got ctl for mixer cmd %s",
+ __func__, mixer_ctl_name);
+ mixer_ctl_set_value(ctl, 0, 1);
+ }
+
thermal_fd = open(wsa_path, O_RDONLY);
if (thermal_fd > 0) {
if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0)
@@ -1127,6 +1137,9 @@
} else {
ALOGE("%s: fd for %s is NULL\n", __func__, wsa_path);
}
+ if (ctl) {
+ mixer_ctl_set_value(ctl, 0, 0);
+ }
if (t0_spk_1 < TZ_TEMP_MIN_THRESHOLD ||
t0_spk_1 > TZ_TEMP_MAX_THRESHOLD) {
pthread_mutex_unlock(&adev->lock);
@@ -1138,8 +1151,15 @@
t0_spk_1 = (t0_spk_1 * (1 << 6));
}
if (spk_2_tzn >= 0) {
+ const char *mixer_ctl_name = "SpkrRight WSA T0 Init";
snprintf(wsa_path, MAX_PATH, TZ_WSA, spk_2_tzn);
ALOGV("%s: wsa_path: %s\n", __func__, wsa_path);
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (ctl) {
+ ALOGD("%s: Got ctl for mixer cmd %s",
+ __func__, mixer_ctl_name);
+ mixer_ctl_set_value(ctl, 0, 1);
+ }
thermal_fd = open(wsa_path, O_RDONLY);
if (thermal_fd > 0) {
if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0)
@@ -1150,6 +1170,9 @@
} else {
ALOGE("%s: fd for %s is NULL\n", __func__, wsa_path);
}
+ if (ctl) {
+ mixer_ctl_set_value(ctl, 0, 0);
+ }
if (t0_spk_2 < TZ_TEMP_MIN_THRESHOLD ||
t0_spk_2 > TZ_TEMP_MAX_THRESHOLD) {
pthread_mutex_unlock(&adev->lock);