hal: Update DS2 implementation to support ACDB based license mechanism
-Add ACDB based licenese mechanism for Dolby DS2 implementation.
-Add device to back end mapping for MSM8916
Change-Id: I0de4bd67fbfc26c21c4751e32ae2c45278a226d0
CRs-Fixed: 761339
diff --git a/hal/Android.mk b/hal/Android.mk
index ec47740..797bcb7 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -154,6 +154,10 @@
LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ACDB_LICENSE)), true)
+ LOCAL_CFLAGS += -DDOLBY_ACDB_LICENSE
+endif
+
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true)
LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED
ifneq ($(strip $(DOLBY_DDP)),true)
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 3cb18f5..8c52eaa 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -438,6 +438,7 @@
audio_extn_listen_set_parameters(adev, parms);
audio_extn_hfp_set_parameters(adev, parms);
audio_extn_ddp_set_parameters(adev, parms);
+ audio_extn_ds2_set_parameters(adev, parms);
audio_extn_customstereo_set_parameters(adev, parms);
}
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 9476486..8345c96 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -253,9 +253,14 @@
#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED)
void audio_extn_dolby_set_dmid(struct audio_device *adev);
-void audio_extn_dolby_set_license(struct audio_device *adev);
#else
#define audio_extn_dolby_set_dmid(adev) (0)
+#endif
+
+
+#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED) || defined(DS2_DOLBY_DAP_ENABLED)
+void audio_extn_dolby_set_license(struct audio_device *adev);
+#else
#define audio_extn_dolby_set_license(adev) (0)
#endif
@@ -344,12 +349,16 @@
void audio_extn_dolby_ds2_set_endpoint(struct audio_device *adev);
int audio_extn_ds2_enable(struct audio_device *adev);
int audio_extn_dolby_set_dap_bypass(struct audio_device *adev, int state);
+void audio_extn_ds2_set_parameters(struct audio_device *adev,
+ struct str_parms *parms);
+
#else
#define audio_extn_dap_hal_init(snd_card) (0)
#define audio_extn_dap_hal_deinit() (0)
#define audio_extn_dolby_ds2_set_endpoint(adev) (0)
#define audio_extn_ds2_enable(adev) (0)
#define audio_extn_dolby_set_dap_bypass(adev, state) (0)
+#define audio_extn_ds2_set_parameters(adev, parms); (0)
#endif
typedef enum {
DAP_STATE_ON = 0,
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index 8670367..abbfe62 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -18,8 +18,8 @@
*/
#define LOG_TAG "audio_hw_dolby"
-/*#define LOG_NDEBUG 0*/
-#define LOG_NDDEBUG 0
+//#define LOG_NDEBUG 0
+//#define LOG_NDDEBUG 0
#include <errno.h>
#include <cutils/properties.h>
@@ -33,6 +33,7 @@
#include "platform_api.h"
#include "audio_extn.h"
#include "sound/compress_params.h"
+#include "sound/devdep_params.h"
#ifdef DS1_DOLBY_DDP_ENABLED
@@ -479,6 +480,7 @@
return;
}
+#ifndef DS2_DOLBY_DAP_ENABLED
void audio_extn_dolby_set_license(struct audio_device *adev)
{
int ret, key=0;
@@ -494,8 +496,9 @@
}
property_get("audio.ds1.metainfo.key",value,"0");
+#ifdef DOLBY_ACDB_LICENSE
key = atoi(value);
-
+#endif
ALOGV("%s Setting DS1 License, key:0x%x",__func__, key);
ret = mixer_ctl_set_value(ctl, 0, key);
if (ret)
@@ -503,6 +506,7 @@
return;
}
+#endif
#endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */
#ifdef DS2_DOLBY_DAP_ENABLED
@@ -538,11 +542,6 @@
ds2extnmod.dap_hal_set_hw_info(SND_CARD, (void*)(&snd_card));
ALOGV("%s Sound card number is:%d",__func__,snd_card);
- property_get("dmid",c_dmid,"0");
- i_dmid = atoi(c_dmid);
- ds2extnmod.dap_hal_set_hw_info(DMID, (void*)(&i_dmid));
- ALOGV("%s Dolby device manufacturer id is:%d",__func__,i_dmid);
-
platform_get_device_to_be_id_map(&device_be_id_map.device_id_to_be_id, &device_be_id_map.len);
ds2extnmod.dap_hal_set_hw_info(DEVICE_BE_ID_MAP, (void*)(&device_be_id_map));
ALOGV("%s Set be id map len:%d",__func__,device_be_id_map.len);
@@ -635,4 +634,50 @@
}
return 0;
}
+
+void audio_extn_dolby_set_license(struct audio_device *adev)
+{
+ int i_key;
+ char c_key[128] = {0};
+ char c_dmid[128] = {0};
+ int i_dmid, ret = -EINVAL;
+ struct dolby_param_license dolby_license;
+
+#ifdef DOLBY_ACDB_LICENSE
+ property_get("audio.ds1.metainfo.key",c_key,"0");
+ i_key = atoi(c_key);
+#else
+ /* As ACDB based license mechanism is disabled, force set the license key to 0*/
+ i_key = 0;
+#endif
+ property_get("dmid",c_dmid,"0");
+ i_dmid = atoi(c_dmid);
+ ALOGV("%s Setting DS1 License, key:0x%x dmid %d",__func__, i_key,i_dmid);
+ dolby_license.dmid = i_dmid;
+ dolby_license.license_key = i_key;
+ if (ds2extnmod.dap_hal_set_hw_info) {
+ ds2extnmod.dap_hal_set_hw_info(DMID, (void*)(&dolby_license.dmid));
+ } else {
+ ALOGV("%s: dap_hal_set_hw_info is NULL", __func__);
+ return ret;
+ }
+ return 0;
+}
+
+
+void audio_extn_ds2_set_parameters(struct audio_device *adev,
+ struct str_parms *parms)
+{
+ int val, ret;
+ char value[32]={0};
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SND_CARD_STATUS, value,
+ sizeof(value));
+ if (ret >= 0) {
+ char *snd_card_status = value + 2;
+ if (strncmp(snd_card_status, "ONLINE", sizeof("ONLINE")) == 0){
+ audio_extn_dolby_set_license(adev);
+ }
+ }
+}
#endif
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index a3abf9e..a589425 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -1072,6 +1072,9 @@
audio_extn_ssr_update_enabled();
audio_extn_spkr_prot_init(adev);
+ /* init dap hal */
+ audio_extn_dap_hal_init(adev->snd_card);
+
audio_extn_dolby_set_license(adev);
audio_hwdep_send_cal(my_data);
@@ -1088,6 +1091,7 @@
free(platform);
/* deinit usb */
audio_extn_usb_deinit();
+ audio_extn_dap_hal_deinit();
}
const char *platform_get_snd_device_name(snd_device_t snd_device)