summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAravind Retnakaran <aravind.retnakaran@knowles.com>2019-05-09 18:07:11 +0530
committerRoger Fang <rogerfang@google.com>2019-06-05 07:30:26 +0000
commitf9dbaf763267a55bfd39bdab2788e86f86f04931 (patch)
treecb2632bd8d0485a96eebacaef165c81663c089bc
parentd5e65b4078445d40ea344f847917e70d219ed2d1 (diff)
downloadandroid_hardware_knowles_athletico_sound_trigger_hal-f9dbaf763267a55bfd39bdab2788e86f86f04931.tar.gz
android_hardware_knowles_athletico_sound_trigger_hal-f9dbaf763267a55bfd39bdab2788e86f86f04931.tar.bz2
android_hardware_knowles_athletico_sound_trigger_hal-f9dbaf763267a55bfd39bdab2788e86f86f04931.zip
sthal: delayed core shutdown logic to optimize route switching
+ Powering up/down of processor cores logic is moved to driver space and the decisions would predicate on FW status and states. Hence its not needed to manage the same in HAL. Testing Done: + Verified various use cases and switching, hot word, recording, switching etc. Need to be compatible with pa/1383793 Bug:132845751 Bug:134372472 Test: Manually test Change-Id: I7d3e6f6e81c18cc7bb51302918bc221b51816c80 Signed-off-by: Aravind Retnakaran <aravind.retnakaran@knowles.com> Signed-off-by: rogerfang <rogerfang@google.com>
-rw-r--r--cvq_ioctl.h18
-rw-r--r--cvq_util.c143
-rw-r--r--sound_trigger_hw_iaxxx.c41
3 files changed, 1 insertions, 201 deletions
diff --git a/cvq_ioctl.h b/cvq_ioctl.h
index 749aac9..4413379 100644
--- a/cvq_ioctl.h
+++ b/cvq_ioctl.h
@@ -139,19 +139,6 @@
#define AMBIENT_WITHOUT_BARGEIN_ROUTE "ambient-route-without-bargein"
#define BUFFER_WITH_BARGEIN_ROUTE "buffer-route-with-bargein"
#define BUFFER_WITHOUT_BARGEIN_ROUTE "buffer-route-without-bargein"
-#define POWER_DOWN_ROUTE "pwr-dwn-all-non-ctrl-proc-mem"
-#define POWER_ON_HMD_PROC_MEM "pwr-up-hmd-proc-mem"
-#define POWER_ON_SSP_PROC_MEM "pwr-up-ssp-proc-mem"
-#define POWER_ON_DMX_PROC_MEM "pwr-up-dmx-proc-mem"
-#define POWER_OFF_HMD_PROC_MEM "pwr-dwn-hmd-proc-mem"
-#define POWER_OFF_SSP_PROC_MEM "pwr-dwn-ssp-proc-mem"
-#define POWER_OFF_DMX_PROC_MEM "pwr-dwn-dmx-proc-mem"
-#define POWER_OFF_SSP_PROC_MEM_IN_RETN "pwr-dwn-ssp-proc-mem-in-retn"
-#define POWER_OFF_DMX_PROC_MEM_IN_RETN "pwr-dwn-dmx-proc-mem-in-retn"
-#define POWER_OFF_HMD_PROC_MEM_IN_RETN "pwr-dwn-hmd-proc-mem-in-retn"
-#define POWER_ON_HMD_PROC_MEM_OUT_OFF_RETN "pwr-on-hmd-proc-mem-out-off-retn"
-#define POWER_ON_DMX_PROC_MEM_OUT_OFF_RETN "pwr-on-dmx-proc-mem-out-off-retn"
-#define POWER_ON_SSP_PROC_MEM_OUT_OFF_RETN "pwr-on-ssp-proc-mem-out-off-retn"
enum clock_type {
INTERNAL_OSCILLATOR,
@@ -234,12 +221,7 @@ int tear_music_buffer_route(struct audio_route *route_hdl, bool downlink);
int flush_model(struct iaxxx_odsp_hw *odsp_hdl, int kw_type);
int get_entity_param_blk(struct iaxxx_odsp_hw *odsp_hdl, void *payload, unsigned int payload_size);
int get_wakeup_param_blk(struct iaxxx_odsp_hw *odsp_hdl, void *payload, unsigned int payload_size);
-int power_down_all_non_ctrl_proc_mem(struct mixer *mixer);
int set_default_apll_clk(struct mixer *mixer);
-int power_on_proc_mem(struct audio_route *route_hdl, int enable, int core);
-int power_off_proc_mem(struct audio_route *route_hdl, int enable, int core);
-int power_off_proc_mem_in_retn(struct audio_route *route_hdl, int enable, int core);
-int power_on_proc_mem_out_off_retn(struct audio_route *route_hdl, int enable, int core);
int get_fw_status(struct iaxxx_odsp_hw *odsp_hdl, unsigned int *status);
int reset_fw(struct iaxxx_odsp_hw *odsp_hdl);
int trigger_sensor_destroy_event(struct iaxxx_odsp_hw *odsp_hdl);
diff --git a/cvq_util.c b/cvq_util.c
index c2ffa27..7ab6cc9 100644
--- a/cvq_util.c
+++ b/cvq_util.c
@@ -1683,149 +1683,6 @@ int set_default_apll_clk(struct mixer *mixer) {
return ret;
}
-int power_down_all_non_ctrl_proc_mem(struct mixer *mixer)
-{
- int ret = 0;
- struct mixer_ctl* ctl;
-
- ALOGD("+Entering %s+", __func__);
-
- if (!mixer) {
- ALOGE("%s mixer is NULL", __func__);
- return -EINVAL;
- }
-
- ctl = mixer_get_ctl_by_name(mixer, "SSP Core Boot");
- if (ctl) {
- ret = mixer_ctl_set_enum_by_string(ctl, "CoreMemOff");
- if (ret)
- ALOGE("%s: update SSP fail! ret = %d", __func__, ret);
- } else {
- ALOGE("%s: get SSP control fail", __func__);
- ret = -ENODEV;
- }
-
- ctl = mixer_get_ctl_by_name(mixer, "HMD Core Boot");
- if (ctl) {
- ret = mixer_ctl_set_enum_by_string(ctl, "CoreMemOff");
- if (ret)
- ALOGE("%s: update HMD fail! ret = %d", __func__, ret);
- } else {
- ALOGE("%s: get HMD control fail", __func__);
- ret = -ENODEV;
- }
-
- ctl = mixer_get_ctl_by_name(mixer, "DMX Core Boot");
- if (ctl) {
- ret = mixer_ctl_set_enum_by_string(ctl, "CoreMemOff");
- if (ret)
- ALOGE("%s: update DMX fail! ret = %d", __func__, ret);
- } else {
- ALOGE("%s: get DMX control fail", __func__);
- ret = -ENODEV;
- }
-
- ALOGD("-Exiting %s-", __func__);
- return ret;
-}
-
-int power_on_proc_mem(struct audio_route *route_hdl, int enable, int core)
-{
- ALOGD("+Entering %s+", __func__);
- if (enable) {
- if (core == IAXXX_SSP_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_ON_SSP_PROC_MEM);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_ON_HMD_PROC_MEM);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_ON_DMX_PROC_MEM);
- }
- } else {
- if (core == IAXXX_SSP_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_ON_SSP_PROC_MEM);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_ON_HMD_PROC_MEM);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_ON_DMX_PROC_MEM);
- }
- }
- ALOGD("-Exiting %s-", __func__);
- return 0;
-}
-
-int power_off_proc_mem(struct audio_route *route_hdl, int enable, int core)
-{
- ALOGD("+Entering %s+", __func__);
- if (enable) {
- if (core == IAXXX_SSP_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_OFF_SSP_PROC_MEM);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_OFF_HMD_PROC_MEM);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_OFF_DMX_PROC_MEM);
- }
- } else {
- if (core == IAXXX_SSP_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_OFF_SSP_PROC_MEM);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_OFF_HMD_PROC_MEM);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_OFF_DMX_PROC_MEM);
- }
- }
- ALOGD("-Exiting %s-", __func__);
- return 0;
-}
-
-int power_off_proc_mem_in_retn(struct audio_route *route_hdl, int enable, int core)
-{
- ALOGD("+Entering %s+", __func__);
- if (enable) {
- if (core == IAXXX_SSP_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_OFF_SSP_PROC_MEM_IN_RETN);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_OFF_HMD_PROC_MEM_IN_RETN);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_OFF_DMX_PROC_MEM_IN_RETN);
- }
- } else {
- if (core == IAXXX_SSP_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_OFF_SSP_PROC_MEM_IN_RETN);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_OFF_HMD_PROC_MEM_IN_RETN);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_OFF_DMX_PROC_MEM_IN_RETN);
- }
- }
- ALOGD("-Exiting %s-", __func__);
- return 0;
-}
-
-int power_on_proc_mem_out_off_retn(struct audio_route *route_hdl, int enable, int core)
-{
- ALOGD("+Entering %s+", __func__);
- if (enable) {
- if (core == IAXXX_SSP_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_ON_SSP_PROC_MEM_OUT_OFF_RETN);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_ON_HMD_PROC_MEM_OUT_OFF_RETN);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_apply_and_update_path(route_hdl, POWER_ON_DMX_PROC_MEM_OUT_OFF_RETN);
- }
-
- } else {
- if (core == IAXXX_SSP_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_ON_SSP_PROC_MEM_OUT_OFF_RETN);
- } else if (core == IAXXX_HMD_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_ON_HMD_PROC_MEM_OUT_OFF_RETN);
- } else if (core == IAXXX_DMX_ID) {
- audio_route_reset_and_update_path(route_hdl, POWER_ON_DMX_PROC_MEM_OUT_OFF_RETN);
- }
- }
- ALOGD("-Exiting %s-", __func__);
- return 0;
-}
-
int get_fw_status(struct iaxxx_odsp_hw *odsp_hdl, unsigned int *status)
{
int err;
diff --git a/sound_trigger_hw_iaxxx.c b/sound_trigger_hw_iaxxx.c
index feb3d56..519f41c 100644
--- a/sound_trigger_hw_iaxxx.c
+++ b/sound_trigger_hw_iaxxx.c
@@ -155,8 +155,6 @@ struct knowles_sound_trigger_device {
bool is_sensor_route_enabled;
bool is_src_package_loaded;
bool is_st_hal_ready;
- bool is_hmd_proc_on;
- bool is_dmx_proc_on;
int hotword_buffer_enable;
int music_buffer_enable;
bool is_sensor_destroy_in_prog;
@@ -1205,11 +1203,6 @@ static int restart_recognition(struct knowles_sound_trigger_device *stdev)
stdev->hotword_buffer_enable = 0;
stdev->music_buffer_enable = 0;
- if (stdev->is_hmd_proc_on == true) {
- power_on_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID);
- power_on_proc_mem(stdev->route_hdl, true, IAXXX_HMD_ID);
- }
-
if (stdev->is_music_playing == true &&
stdev->is_bargein_route_enabled == true) {
ct = EXTERNAL_OSCILLATOR;
@@ -1403,7 +1396,7 @@ static int crash_recovery(struct knowles_sound_trigger_device *stdev)
int err = 0;
set_default_apll_clk(stdev->mixer);
- power_down_all_non_ctrl_proc_mem(stdev->mixer);
+
// Redownload the keyword model files and start recognition
err = restart_recognition(stdev);
if (err != 0) {
@@ -1419,19 +1412,6 @@ exit:
return err;
}
-static void check_and_turn_off_hmd(struct knowles_sound_trigger_device *stdev)
-{
- ALOGD("+%s+", __func__);
-
- // Switch the processor off only if all packages are unloaded
- if (!is_any_model_loaded(stdev) && stdev->is_hmd_proc_on) {
- power_on_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID);
- stdev->is_hmd_proc_on = false;
- }
-
- ALOGD("-%s-", __func__);
-}
-
static void remove_buffer(struct knowles_sound_trigger_device *stdev)
{
ALOGD("+%s+", __func__);
@@ -1478,7 +1458,6 @@ static void destroy_sensor_model(struct knowles_sound_trigger_device *stdev)
stdev->is_sensor_destroy_in_prog = false;
remove_buffer(stdev);
- check_and_turn_off_hmd(stdev);
// There could be another thread waiting for us to destroy so signal that
// thread, if no one is waiting then this signal will have no effect
@@ -1650,7 +1629,6 @@ static void *callback_thread_loop(void *context)
}
set_default_apll_clk(stdev->mixer);
- power_down_all_non_ctrl_proc_mem(stdev->mixer);
stdev->is_st_hal_ready = true;
}
@@ -1749,7 +1727,6 @@ static void *callback_thread_loop(void *context)
ALOGD("Firmware downloaded successfully");
stdev->is_st_hal_ready = true;
set_default_apll_clk(stdev->mixer);
- power_down_all_non_ctrl_proc_mem(stdev->mixer);
} else if (strstr(msg + i, IAXXX_FW_CRASH_EVENT_STR)) {
ALOGD("Firmware has crashed");
// Don't allow any op on ST HAL until recovery is complete
@@ -2027,11 +2004,6 @@ static int stdev_load_sound_model(const struct sound_trigger_hw_device *dev,
stdev->models[i].data_sz = kw_model_sz;
}
- if (stdev->is_hmd_proc_on == false) {
- power_on_proc_mem(stdev->route_hdl, true, IAXXX_HMD_ID);
- stdev->is_hmd_proc_on = true;
- }
-
if (stdev->is_buffer_package_loaded == false) {
ret = setup_buffer_package(stdev->odsp_hdl);
if (ret != 0) {
@@ -2113,10 +2085,6 @@ exit:
destory_src_package(stdev->odsp_hdl);
stdev->is_src_package_loaded = false;
}
- if (!is_any_model_loaded(stdev) && stdev->is_hmd_proc_on) {
- power_on_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID);
- stdev->is_hmd_proc_on = false;
- }
}
pthread_mutex_unlock(&stdev->lock);
ALOGD("-%s handle %d-", __func__, *handle);
@@ -2232,11 +2200,6 @@ static int stdev_unload_sound_model(const struct sound_trigger_hw_device *dev,
stdev->is_src_package_loaded = false;
}
- if (!is_any_model_loaded(stdev) && stdev->is_hmd_proc_on) {
- power_on_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID);
- stdev->is_hmd_proc_on = false;
- }
-
ALOGD("%s: Successfully unloaded the model, handle - %d",
__func__, handle);
exit:
@@ -2793,8 +2756,6 @@ static int stdev_open(const hw_module_t *module, const char *name,
stdev->current_enable = 0;
stdev->is_sensor_route_enabled = false;
stdev->recover_model_list = 0;
- stdev->is_hmd_proc_on = false;
- stdev->is_dmx_proc_on = false;
stdev->is_media_recording = false;
stdev->is_concurrent_capture = hw_properties.concurrent_capture;