From edb6a91d76c27719f29cf4e7acb5e805a8e085c0 Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Thu, 16 Oct 2014 13:56:28 +0530 Subject: [PATCH] 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 --- hal/Android.mk | 4 +++ hal/audio_extn/audio_extn.c | 1 + hal/audio_extn/audio_extn.h | 11 ++++++- hal/audio_extn/dolby.c | 61 ++++++++++++++++++++++++++++++++----- hal/msm8916/platform.c | 4 +++ 5 files changed, 73 insertions(+), 8 deletions(-) diff --git a/hal/Android.mk b/hal/Android.mk index 45ae0db7..fef47ded 100644 --- a/hal/Android.mk +++ b/hal/Android.mk @@ -150,6 +150,10 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true) 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 4ac3156f..846a816b 100644 --- a/hal/audio_extn/audio_extn.c +++ b/hal/audio_extn/audio_extn.c @@ -461,6 +461,7 @@ void audio_extn_set_parameters(struct audio_device *adev, 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); audio_extn_pm_set_parameters(parms); } diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h index effe8ee9..8224a445 100644 --- a/hal/audio_extn/audio_extn.h +++ b/hal/audio_extn/audio_extn.h @@ -253,9 +253,14 @@ void audio_extn_compr_cap_deinit(); #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 @@ -354,12 +359,16 @@ int audio_extn_dap_hal_deinit(); 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 8670367e..6e0b0ee6 100644 --- a/hal/audio_extn/dolby.c +++ b/hal/audio_extn/dolby.c @@ -18,7 +18,7 @@ */ #define LOG_TAG "audio_hw_dolby" -/*#define LOG_NDEBUG 0*/ +#define LOG_NDEBUG 0 #define LOG_NDDEBUG 0 #include @@ -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 @@ void audio_extn_dolby_set_dmid(struct audio_device *adev) return; } +#ifndef DS2_DOLBY_DAP_ENABLED void audio_extn_dolby_set_license(struct audio_device *adev) { int ret, key=0; @@ -494,8 +496,11 @@ void audio_extn_dolby_set_license(struct audio_device *adev) } property_get("audio.ds1.metainfo.key",value,"0"); +#ifdef DOLBY_ACDB_LICENSE key = atoi(value); - +#else + key = 0; +#endif ALOGV("%s Setting DS1 License, key:0x%x",__func__, key); ret = mixer_ctl_set_value(ctl, 0, key); if (ret) @@ -503,6 +508,7 @@ void audio_extn_dolby_set_license(struct audio_device *adev) return; } +#endif #endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */ #ifdef DS2_DOLBY_DAP_ENABLED @@ -538,11 +544,6 @@ int audio_extn_dap_hal_init(int snd_card) { 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 +636,50 @@ int audio_extn_dolby_set_dap_bypass(struct audio_device *adev, int state) { } return 0; } + +void audio_extn_dolby_set_license(struct audio_device *adev) +{ + int i_key=0; + 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 446778ae..88ee1dbf 100644 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -1090,6 +1090,9 @@ acdb_init_fail: 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); @@ -1106,6 +1109,7 @@ void platform_deinit(void *platform) 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)