Promotion of audio-userspace.lnx.2.2-00017.
CRs Change ID Subject
--------------------------------------------------------------------------------------------------------------
1113338 I8e750c92d61fa03c1397acb611e8eb87b41cd5d7 hal: add interface to enable volume based audio calibrat
1111739 I63c482920ee778beb806e3138c93e005e15ca897 hal: Add support to set SVA execution mode
Change-Id: I21809a62c89df7fa9769efe790b03666f2e649f8
CRs-Fixed: 1111739, 1113338
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index f159083..d2e5434 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -813,6 +813,7 @@
audio_extn_hpx_get_parameters(query, reply);
audio_extn_source_track_get_parameters(adev, query, reply);
audio_extn_fbsp_get_parameters(query, reply);
+ audio_extn_sound_trigger_get_parameters(adev, query, reply);
if (adev->offload_effects_get_parameters != NULL)
adev->offload_effects_get_parameters(query, reply);
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 8bf165a..9a2f825 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -302,6 +302,7 @@
#define audio_extn_sound_trigger_update_device_status(snd_dev, event) (0)
#define audio_extn_sound_trigger_update_stream_status(uc_info, event) (0)
#define audio_extn_sound_trigger_set_parameters(adev, parms) (0)
+#define audio_extn_sound_trigger_get_parameters(adev, query, reply) (0)
#define audio_extn_sound_trigger_check_and_get_session(in) (0)
#define audio_extn_sound_trigger_stop_lab(in) (0)
#define audio_extn_sound_trigger_read(in, buffer, bytes) (0)
@@ -327,6 +328,8 @@
void audio_extn_sound_trigger_stop_lab(struct stream_in *in);
int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
size_t bytes);
+void audio_extn_sound_trigger_get_parameters(const struct audio_device *adev,
+ struct str_parms *query, struct str_parms *reply);
#endif
#ifndef AUXPCM_BT_ENABLED
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index aff7532..1f9c3a9 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 2016-2017 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -361,6 +361,27 @@
event.u.value = val;
st_dev->st_callback(AUDIO_EVENT_DEVICE_DISCONNECT, &event);
}
+
+ ret = str_parms_get_str(params, "SVA_EXEC_MODE", value, sizeof(value));
+ if (ret >= 0) {
+ strlcpy(event.u.str_value, value, sizeof(event.u.str_value));
+ st_dev->st_callback(AUDIO_EVENT_SVA_EXEC_MODE, &event);
+ }
+}
+
+void audio_extn_sound_trigger_get_parameters(const struct audio_device *adev __unused,
+ struct str_parms *query, struct str_parms *reply)
+{
+ audio_event_info_t event;
+ int ret;
+ char value[32];
+
+ ret = str_parms_get_str(query, "SVA_EXEC_MODE_STATUS", value,
+ sizeof(value));
+ if (ret >= 0) {
+ st_dev->st_callback(AUDIO_EVENT_SVA_EXEC_MODE_STATUS, &event);
+ str_parms_add_int(reply, "SVA_EXEC_MODE_STATUS", event.u.value);
+ }
}
int audio_extn_sound_trigger_init(struct audio_device *adev)
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index b3599ab..87ca990 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -37,6 +37,7 @@
#include "sound/compress_params.h"
#include "sound/msmcal-hwdep.h"
#include <dirent.h>
+#include <linux/msm_audio.h>
#define SOUND_TRIGGER_DEVICE_HANDSET_MONO_LOW_POWER_ACDB_ID (100)
#define MAX_MIXER_XML_PATH 100
#define MIXER_XML_PATH_QRD_SKUH "/system/etc/mixer_paths_qrd_skuh.xml"
@@ -202,6 +203,12 @@
uint32_t param_id;
} acdb_audio_cal_cfg_t;
+enum {
+ CAL_MODE_SEND = 0x1,
+ CAL_MODE_PERSIST = 0x2,
+ CAL_MODE_RTAC = 0x4
+};
+
/* Audio calibration related functions */
typedef void (*acdb_deallocate_t)();
typedef int (*acdb_init_t)(const char *, char *, int);
@@ -216,6 +223,7 @@
typedef int (*acdb_send_common_top_t) (void);
typedef int (*acdb_set_codec_data_t) (void *, char *);
typedef int (*acdb_reload_t) (char *, char *, char *, int);
+typedef int (*acdb_send_gain_dep_cal_t)(int, int, int, int, int);
typedef struct codec_backend_cfg {
uint32_t sample_rate;
@@ -269,6 +277,7 @@
bool rec_play_conc_set;
#endif
void *hw_info;
+ acdb_send_gain_dep_cal_t acdb_send_gain_dep_cal;
struct csd_data *csd;
void *edid_info;
bool edid_valid;
@@ -1988,6 +1997,11 @@
ALOGE("%s: Could not find the symbol acdb_get_default_app_type from %s",
__func__, LIB_ACDB_LOADER);
+ my_data->acdb_send_gain_dep_cal = (acdb_send_gain_dep_cal_t)dlsym(my_data->acdb_handle,
+ "acdb_loader_send_gain_dep_cal");
+ if (!my_data->acdb_send_gain_dep_cal)
+ ALOGV("%s: Could not find the symbol acdb_loader_send_gain_dep_cal from %s",
+ __func__, LIB_ACDB_LOADER);
my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
"acdb_loader_init_v2");
@@ -5831,10 +5845,60 @@
return 0;
}
-bool platform_send_gain_dep_cal(void *platform __unused,
- int level __unused)
+bool platform_send_gain_dep_cal(void *platform,
+ int level )
{
- return 0;
+ bool ret_val = false;
+ struct platform_data *my_data = (struct platform_data *)platform;
+ struct audio_device *adev = my_data->adev;
+ int acdb_dev_id, app_type;
+ int acdb_dev_type = MSM_SNDDEV_CAP_RX;
+ int mode = CAL_MODE_RTAC;
+ struct listnode *node;
+ struct audio_usecase *usecase;
+
+ if (my_data->acdb_send_gain_dep_cal == NULL) {
+ ALOGE("%s: dlsym error for acdb_send_gain_dep_cal", __func__);
+ return ret_val;
+ }
+
+ if (!voice_is_in_call(adev)) {
+ ALOGV("%s: Not Voice call usecase, apply new cal for level %d",
+ __func__, level);
+
+ // find the current active sound device
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+
+ if (usecase != NULL &&
+ usecase->type == PCM_PLAYBACK &&
+ usecase->stream.out->devices == AUDIO_DEVICE_OUT_SPEAKER) {
+
+ ALOGV("%s: out device is %d", __func__, usecase->out_snd_device);
+ app_type = usecase->stream.out->app_type_cfg.app_type;
+
+ if (audio_extn_spkr_prot_is_enabled()) {
+ acdb_dev_id = platform_get_spkr_prot_acdb_id(usecase->out_snd_device);
+ } else {
+ acdb_dev_id = acdb_device_table[usecase->out_snd_device];
+ }
+
+ if (!my_data->acdb_send_gain_dep_cal(acdb_dev_id, app_type,
+ acdb_dev_type, mode, level)) {
+ // set ret_val true if at least one calibration is set successfully
+ ret_val = true;
+ } else {
+ ALOGE("%s: my_data->acdb_send_gain_dep_cal failed ", __func__);
+ }
+ } else {
+ ALOGW("%s: Usecase list is empty", __func__);
+ }
+ }
+ } else {
+ ALOGW("%s: Voice call in progress .. ignore setting new cal",
+ __func__);
+ }
+ return ret_val;
}
bool platform_can_enable_spkr_prot_on_device(snd_device_t snd_device)