hal: Fix closure of hardware dependent node
Closing of hardware dependent node immediately after sending the cal.
is causing issues as the driver release function being called inturn
resetting all the cal_bits. To fix this, close hardware dependent
node at platform deinit.
CRs-Fixed: 959131
Change-Id: If18e352971e92e82f4b67178924675a4a39c8460
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index f243790..179593d 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -243,6 +243,7 @@
char ec_ref_mixer_path[64];
codec_backend_cfg_t current_backend_cfg[MAX_CODEC_BACKENDS];
char codec_version[CODEC_VERSION_MAX_LENGTH];
+ int hw_dep_fd;
};
static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
@@ -1212,9 +1213,10 @@
static void audio_hwdep_send_cal(struct platform_data *plat_data)
{
- int fd;
+ int fd = plat_data->hw_dep_fd;
- fd = hw_util_open(plat_data->adev->snd_card);
+ if (fd < 0)
+ fd = hw_util_open(plat_data->adev->snd_card);
if (fd == -1) {
ALOGE("%s error open\n", __func__);
return;
@@ -1226,11 +1228,15 @@
if (acdb_loader_get_calibration == NULL) {
ALOGE("%s: ERROR. dlsym Error:%s acdb_loader_get_calibration", __func__,
dlerror());
+ if (fd >= 0) {
+ close(fd);
+ plat_data->hw_dep_fd = -1;
+ }
return;
}
send_codec_cal(acdb_loader_get_calibration, plat_data, fd);
- close(fd);
+ plat_data->hw_dep_fd = fd;
}
static int platform_acdb_init(void *platform)
@@ -1405,6 +1411,7 @@
my_data->slowtalk = false;
my_data->hd_voice = false;
my_data->edid_info = NULL;
+ my_data->hw_dep_fd = -1;
property_get("ro.qc.sdk.audio.fluencetype", my_data->fluence_cap, "");
if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) {
@@ -1621,6 +1628,11 @@
my_data->edid_info = NULL;
}
+ if (my_data->hw_dep_fd >= 0) {
+ close(my_data->hw_dep_fd);
+ my_data->hw_dep_fd = -1;
+ }
+
hw_info_deinit(my_data->hw_info);
close_csd_client(my_data->csd);