hal: retrieve license info during init.
FFV/Allplay requires licensing info during init.
- Retrieve Product_Id using "meta_info_key" from platfrom xml file during HAL-Init.
- Retrieve Product_License using "audio_calibration_info" from ACDB.
- Extend QAHW GetParam API to access AllPlay License information.
Change-Id: Ie759f795d76e0038cba3f14ee9084f1c46b64c0a
diff --git a/hal/audio_extn/audio_defs.h b/hal/audio_extn/audio_defs.h
index 3921f49..1b34c53 100755
--- a/hal/audio_extn/audio_defs.h
+++ b/hal/audio_extn/audio_defs.h
@@ -117,6 +117,10 @@
/* MAX SECTORS for sourcetracking feature */
#define MAX_SECTORS 8
+/* Max length for license string */
+#define AUDIO_PRODUCT_STR_MAX_LENGTH (64)
+#define AUDIO_LICENSE_STR_MAX_LENGTH (64)
+
struct source_tracking_param {
uint8_t vad[MAX_SECTORS];
uint16_t doa_speech;
@@ -255,6 +259,13 @@
uint32_t mixer_coeffs[AUDIO_CHANNEL_COUNT_MAX][AUDIO_CHANNEL_COUNT_MAX];
} mix_matrix_params_t;
+
+typedef struct audio_license_params {
+ char product[AUDIO_PRODUCT_STR_MAX_LENGTH + 1];
+ int key;
+ char license[AUDIO_LICENSE_STR_MAX_LENGTH + 1];
+} audio_license_params_t;
+
typedef union {
struct source_tracking_param st_params;
struct sound_focus_param sf_params;
@@ -268,6 +279,7 @@
struct audio_out_channel_map_param channel_map_param;
struct audio_device_cfg_param device_cfg;
struct mix_matrix_params mm_params;
+ struct audio_license_params license_params;
} audio_extn_param_payload;
typedef enum {
@@ -288,7 +300,9 @@
/* Pan/scale params to be set on ASM */
AUDIO_EXTN_PARAM_OUT_MIX_MATRIX_PARAMS,
/* Downmix params to be set on ADM */
- AUDIO_EXTN_PARAM_CH_MIX_MATRIX_PARAMS
+ AUDIO_EXTN_PARAM_CH_MIX_MATRIX_PARAMS,
+ /* License information */
+ AUDIO_EXTN_PARAM_LICENSE_PARAMS,
} audio_extn_param_id;
#endif /* AUDIO_DEFS_H */
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index faf4e4f..c6c0924 100755
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -1329,7 +1329,15 @@
if (ssr_supported) {
return audio_extn_ssr_set_usecase(in, config, update_params);
} else if (audio_extn_ffv_check_usecase(in)) {
- return audio_extn_ffv_set_usecase(in);
+ char ffv_lic[LICENSE_STR_MAX_LEN + 1] = {0};
+ int ffv_key = 0;
+ if(platform_get_license_by_product(adev->platform, PRODUCT_FFV, &ffv_key, ffv_lic))
+ {
+ ALOGD("%s: Valid licence not availble for %s ", __func__, PRODUCT_FFV);
+ return -EINVAL;
+ }
+ ALOGD("%s: KEY: %d LICENSE: %s ", __func__, ffv_key, ffv_lic);
+ return audio_extn_ffv_set_usecase(in, ffv_key, ffv_lic);
} else {
return audio_extn_set_multichannel_mask(adev, in, config,
update_params);
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 4a0b8ce..894d80e 100755
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -998,8 +998,8 @@
#define audio_extn_ffv_init(adev) (0)
#define audio_extn_ffv_deinit() (0)
#define audio_extn_ffv_check_usecase(in) (0)
-#define audio_extn_ffv_set_usecase(in) (0)
-#define audio_extn_ffv_stream_init(in) (0)
+#define audio_extn_ffv_set_usecase(in, key, lic) (0)
+#define audio_extn_ffv_stream_init(in, key, lic) (0)
#define audio_extn_ffv_stream_deinit() (0)
#define audio_extn_ffv_update_enabled() (0)
#define audio_extn_ffv_get_enabled() (0)
@@ -1016,8 +1016,8 @@
int32_t audio_extn_ffv_init(struct audio_device *adev);
int32_t audio_extn_ffv_deinit();
bool audio_extn_ffv_check_usecase(struct stream_in *in);
-int audio_extn_ffv_set_usecase(struct stream_in *in);
-int32_t audio_extn_ffv_stream_init(struct stream_in *in);
+int audio_extn_ffv_set_usecase( struct stream_in *in, int key, char* lic);
+int32_t audio_extn_ffv_stream_init(struct stream_in *in, int key, char* lic);
int32_t audio_extn_ffv_stream_deinit();
void audio_extn_ffv_update_enabled();
bool audio_extn_ffv_get_enabled();
@@ -1041,4 +1041,5 @@
#else
void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out);
#endif
+int audio_extn_utils_get_license_params(const struct audio_device *adev, struct audio_license_params *lic_params);
#endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_extn/ffv.c b/hal/audio_extn/ffv.c
old mode 100644
new mode 100755
index 027849c..be95b70
--- a/hal/audio_extn/ffv.c
+++ b/hal/audio_extn/ffv.c
@@ -100,7 +100,8 @@
static FfvStatusType (*ffv_init_fn)(void** handle, int num_tx_in_ch,
int num_out_ch, int num_ec_ref_ch, int frame_len, int sample_rate,
const char *config_file_name, char *svaModelBuffer,
- uint32_t svaModelSize, int* totMemSize);
+ uint32_t svaModelSize, int* totMemSize,
+ int product_id, const char* prduct_license);
static void (*ffv_deinit_fn)(void* handle);
static void (*ffv_process_fn)(void *handle, const int16_t *in_pcm,
int16_t *out_pcm, const int16_t *ec_ref_pcm);
@@ -365,12 +366,12 @@
return ret;
}
-int audio_extn_ffv_set_usecase(struct stream_in *in)
+int audio_extn_ffv_set_usecase(struct stream_in *in, int ffv_key, char* ffv_lic)
{
int ret = -EINVAL;
if (audio_extn_ffv_check_usecase(in)) {
- if (!audio_extn_ffv_stream_init(in)) {
+ if (!audio_extn_ffv_stream_init(in, ffv_key, ffv_lic)) {
ALOGD("%s: Created FFV session succesfully", __func__);
ret = 0;
} else {
@@ -414,7 +415,7 @@
return 0;
}
-int32_t audio_extn_ffv_stream_init(struct stream_in *in)
+int32_t audio_extn_ffv_stream_init(struct stream_in *in, int key, char* lic)
{
uint32_t ret = -EINVAL;
int num_tx_in_ch, num_out_ch, num_ec_ref_ch;
@@ -473,7 +474,7 @@
ALOGD("%s: config file path %s", __func__, config_file_path);
status_type = ffv_init_fn(&ffvmod.handle, num_tx_in_ch, num_out_ch, num_ec_ref_ch,
frame_len, sample_rate, config_file_path, sm_buffer, 0,
- &total_mem_size);
+ &total_mem_size, key, lic);
if (status_type) {
ALOGE("%s: ERROR. ffv_init returned %d", __func__, status_type);
ret = -EINVAL;
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
old mode 100644
new mode 100755
index e03fdc8..0d6008c
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -2452,3 +2452,15 @@
return -EINVAL;
}
+
+int audio_extn_utils_get_license_params
+(
+const struct audio_device *adev,
+struct audio_license_params *license_params
+)
+{
+ if(!license_params)
+ return -EINVAL;
+ return platform_get_license_by_product(adev->platform, (const char*)license_params->product, &license_params->key, license_params->license);
+}
+
diff --git a/hal/audio_hw_extn_api.c b/hal/audio_hw_extn_api.c
old mode 100644
new mode 100755
index 4e49a83..550a06b
--- a/hal/audio_hw_extn_api.c
+++ b/hal/audio_hw_extn_api.c
@@ -140,6 +140,10 @@
ret = audio_extn_get_sourcetrack_data(dev,
(struct source_tracking_param*)payload);
break;
+ case AUDIO_EXTN_PARAM_LICENSE_PARAMS:
+ ret = audio_extn_utils_get_license_params(dev,
+ (struct audio_license_params *)(payload));
+ break;
default:
ALOGE("%s::INVALID PARAM ID:%d\n",__func__,param_id);
ret = -EINVAL;
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
old mode 100644
new mode 100755
index 21b6bce..2f6b01b
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -3073,6 +3073,59 @@
return 0;
}
+int platform_get_license_by_product
+(
+ void *platform,
+ const char* product_name,
+ int* product_id,
+ char* product_license
+)
+{
+ int ret = 0;
+ int id = 0;
+ acdb_audio_cal_cfg_t cal;
+ uint32_t param_len = LICENSE_STR_MAX_LEN;
+ struct platform_data *my_data = (struct platform_data *)platform;
+
+ if ((NULL == platform) || (NULL == product_name) || (NULL == product_id)) {
+ ALOGE("[%s] Invalid input parameters",__func__);
+ ret = -EINVAL;
+ goto on_error;
+ }
+
+ id = platform_get_meta_info_key_from_list(platform, (char*)product_name);
+ if(0 == id)
+ {
+ ALOGE("%s:Id not found for %s", __func__, product_name);
+ ret = -EINVAL;
+ goto on_error;
+ }
+
+ ALOGD("%s: Found Id[%d] for %s", __func__, id, product_name);
+ if(NULL == my_data->acdb_get_audio_cal){
+ ALOGE("[%s] acdb_get_audio_cal is NULL.",__func__);
+ ret = -ENOSYS;
+ goto on_error;
+ }
+
+ memset(&cal, 0, sizeof(cal));
+ cal.persist = 1;
+ cal.cal_type = AUDIO_CORE_METAINFO_CAL_TYPE;
+ cal.acdb_dev_id = (uint32_t) id;
+ ret = my_data->acdb_get_audio_cal((void*)&cal, (void*)product_license, ¶m_len);
+
+ if (0 == ret) {
+ ALOGD("%s: Got Length[%d] License[%s]", __func__, param_len, product_license );
+ *product_id = id;
+ return 0;
+ }
+ ALOGD("%s: License not found for %s", __func__, product_name);
+
+on_error:
+ *product_id = 0;
+ return ret;
+}
+
int platform_get_meta_info_key_from_list(void *platform, char *mod_name)
{
struct listnode *node;
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
old mode 100644
new mode 100755
index 43aeaed..f4132c2
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1374,3 +1374,8 @@
{
return -ENOSYS;
}
+
+int platform_get_license_by_product(void *platform, const char* product_name, int *product_id, char* product_license)
+{
+ return -ENOSYS;
+}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
old mode 100644
new mode 100755
index 475e438..4a9c43a
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -7905,3 +7905,8 @@
return id_string;
}
+
+int platform_get_license_by_product(void *platform, const char* product_name, int *product_id, char* product_license)
+{
+ return -ENOSYS;
+}
diff --git a/hal/platform_api.h b/hal/platform_api.h
old mode 100644
new mode 100755
index 0fec452..ed62e35
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -31,6 +31,9 @@
#define SAMPLE_RATE_11025 11025
#define sample_rate_multiple(sr, base) ((sr % base)== 0?true:false)
#define MAX_VOLUME_CAL_STEPS 15
+#define LICENSE_STR_MAX_LEN (64)
+#define PRODUCT_FFV "ffv"
+#define PRODUCT_ALLPLAY "allplay"
typedef enum {
PLATFORM,
@@ -261,4 +264,5 @@
int *fd, uint32_t *size);
int platform_get_ec_ref_loopback_snd_device(int channel_count);
const char * platform_get_snd_card_name_for_acdb_loader(const char *snd_card_name);
+int platform_get_license_by_product(void *platform, const char* product_name, int *product_id, char* product_license);
#endif // AUDIO_PLATFORM_API_H
diff --git a/qahw/inc/qahw_defs.h b/qahw/inc/qahw_defs.h
old mode 100644
new mode 100755
index c13a1a4..e67c91e
--- a/qahw/inc/qahw_defs.h
+++ b/qahw/inc/qahw_defs.h
@@ -354,6 +354,14 @@
float mixer_coeffs[AUDIO_CHANNEL_COUNT_MAX][AUDIO_CHANNEL_COUNT_MAX];
} qahw_mix_matrix_params_t;
+#define QAHW_LICENCE_STR_MAX_LENGTH (64)
+#define QAHW_PRODUCT_STR_MAX_LENGTH (64)
+typedef struct qahw_license_params {
+ char product[QAHW_PRODUCT_STR_MAX_LENGTH + 1];
+ int key;
+ char license[QAHW_LICENCE_STR_MAX_LENGTH + 1];
+} qahw_license_params_t;
+
typedef union {
struct qahw_source_tracking_param st_params;
struct qahw_sound_focus_param sf_params;
@@ -367,6 +375,7 @@
struct qahw_out_channel_map_param channel_map_params;
struct qahw_device_cfg_param device_cfg_params;
struct qahw_mix_matrix_params mix_matrix_params;
+ struct qahw_license_params license_params;
} qahw_param_payload;
typedef enum {
@@ -385,6 +394,7 @@
QAHW_PARAM_DEVICE_CONFIG, /* PARAM to set device config */
QAHW_PARAM_OUT_MIX_MATRIX_PARAMS,
QAHW_PARAM_CH_MIX_MATRIX_PARAMS,
+ QAHW_PARAM_LICENSE_PARAMS,
} qahw_param_id;
__END_DECLS
diff --git a/qahw_api/inc/qahw_defs.h b/qahw_api/inc/qahw_defs.h
old mode 100644
new mode 100755
index a33caf6..c708ce0
--- a/qahw_api/inc/qahw_defs.h
+++ b/qahw_api/inc/qahw_defs.h
@@ -354,6 +354,15 @@
float mixer_coeffs[AUDIO_CHANNEL_COUNT_MAX][AUDIO_CHANNEL_COUNT_MAX];
} qahw_mix_matrix_params_t;
+
+#define QAHW_LICENCE_STR_MAX_LENGTH (64)
+#define QAHW_PRODUCT_STR_MAX_LENGTH (64)
+typedef struct qahw_license_params {
+ char product[QAHW_PRODUCT_STR_MAX_LENGTH + 1];
+ int key;
+ char license[QAHW_LICENCE_STR_MAX_LENGTH + 1];
+} qahw_license_params_t;
+
typedef union {
struct qahw_source_tracking_param st_params;
struct qahw_sound_focus_param sf_params;
@@ -367,6 +376,7 @@
struct qahw_out_channel_map_param channel_map_params;
struct qahw_device_cfg_param device_cfg_params;
struct qahw_mix_matrix_params mix_matrix_params;
+ struct qahw_license_params license_params;
} qahw_param_payload;
typedef enum {
@@ -385,6 +395,7 @@
QAHW_PARAM_DEVICE_CONFIG, /* PARAM to set device config */
QAHW_PARAM_OUT_MIX_MATRIX_PARAMS,
QAHW_PARAM_CH_MIX_MATRIX_PARAMS,
+ QAHW_PARAM_LICENSE_PARAMS,
} qahw_param_id;
__END_DECLS