diff options
author | yixuanjiang <yixuanjiang@google.com> | 2019-04-17 18:08:50 -0700 |
---|---|---|
committer | Yixuan Jiang <yixuanjiang@google.com> | 2019-05-02 17:30:19 +0000 |
commit | 0c5f3f6ccf40192ed45f5dee2145d03d4cf39337 (patch) | |
tree | 8b373c7357b232e69f88ae02a40f6d72df0911e7 | |
parent | 8c8309fc2d48f7e8208c8df5c1ad00413d824f90 (diff) | |
download | android_hardware_knowles_athletico_sound_trigger_hal-0c5f3f6ccf40192ed45f5dee2145d03d4cf39337.tar.gz android_hardware_knowles_athletico_sound_trigger_hal-0c5f3f6ccf40192ed45f5dee2145d03d4cf39337.tar.bz2 android_hardware_knowles_athletico_sound_trigger_hal-0c5f3f6ccf40192ed45f5dee2145d03d4cf39337.zip |
sthal: change to use mixer control on reset proc_mem
audio_route should use enable/disalbe pair control
or it will cause abnormal ref count in audio_route,
so mixer sending will be abnormal.
Change related control by mixer control directly.
Bug: 130741706
Test: local test
Change-Id: Iaa14727855e1bb365b6f6c42adfd938a6fd9dad5
Signed-off-by: yixuanjiang <yixuanjiang@google.com>
-rw-r--r-- | cvq_ioctl.h | 2 | ||||
-rw-r--r-- | cvq_util.c | 44 | ||||
-rw-r--r-- | sound_trigger_hw_iaxxx.c | 27 |
3 files changed, 60 insertions, 13 deletions
diff --git a/cvq_ioctl.h b/cvq_ioctl.h index ce34bf7..2adc215 100644 --- a/cvq_ioctl.h +++ b/cvq_ioctl.h @@ -200,7 +200,7 @@ int enable_downlink_audio_route(struct audio_route *route_hdl, bool enable); 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 audio_route *route_hdl); +int power_down_all_non_ctrl_proc_mem(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); @@ -1453,12 +1453,50 @@ int get_wakeup_param_blk(struct iaxxx_odsp_hw *odsp_hdl, void *payload, return err; } -int power_down_all_non_ctrl_proc_mem(struct audio_route *route_hdl) +int power_down_all_non_ctrl_proc_mem(struct mixer *mixer) { + int ret = 0; + struct mixer_ctl* ctl; + ALOGD("+Entering %s+", __func__); - audio_route_apply_and_update_path(route_hdl, POWER_DOWN_ROUTE); + + 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 0; + return ret; } int power_on_proc_mem(struct audio_route *route_hdl, int enable, int core) diff --git a/sound_trigger_hw_iaxxx.c b/sound_trigger_hw_iaxxx.c index 8e774d2..2551c90 100644 --- a/sound_trigger_hw_iaxxx.c +++ b/sound_trigger_hw_iaxxx.c @@ -157,6 +157,7 @@ struct knowles_sound_trigger_device { enum buffer_configuration bc; struct audio_route *route_hdl; + struct mixer *mixer; struct iaxxx_odsp_hw *odsp_hdl; void *audio_hal_handle; @@ -913,6 +914,7 @@ static int restart_recognition(struct knowles_sound_trigger_device *stdev) stdev->current_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); } @@ -1034,7 +1036,7 @@ static int fw_crash_recovery(struct knowles_sound_trigger_device *stdev) { int err = 0; - power_down_all_non_ctrl_proc_mem(stdev->route_hdl); + power_down_all_non_ctrl_proc_mem(stdev->mixer); // Redownload the keyword model files and start recognition err = restart_recognition(stdev); if (err != 0) { @@ -1092,7 +1094,7 @@ static void *callback_thread_loop(void *context) ge.event_id = -1; - power_down_all_non_ctrl_proc_mem(stdev->route_hdl); + power_down_all_non_ctrl_proc_mem(stdev->mixer); pthread_mutex_unlock(&stdev->lock); while (1) { @@ -1496,7 +1498,7 @@ exit: } if (!is_any_model_loaded(stdev) && stdev->is_hmd_proc_on) { - power_off_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID); + power_on_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID); stdev->is_hmd_proc_on = false; } } @@ -1575,7 +1577,7 @@ static int stdev_unload_sound_model(const struct sound_trigger_hw_device *dev, } if (!is_any_model_loaded(stdev) && stdev->is_hmd_proc_on) { - power_off_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID); + power_on_proc_mem(stdev->route_hdl, false, IAXXX_HMD_ID); stdev->is_hmd_proc_on = false; } @@ -1862,7 +1864,7 @@ static int open_streaming_lib(struct knowles_sound_trigger_device *stdev) { return ret; } -static void find_stdev_mixer_path(int card_num, char *mixer_path_xml) +static struct mixer* find_stdev_mixer_path(int card_num, char *mixer_path_xml) { struct mixer *mixer = NULL; const char *in_snd_card_name; @@ -1877,7 +1879,7 @@ static void find_stdev_mixer_path(int card_num, char *mixer_path_xml) if (!mixer) { ALOGE("%s: Unable to open the mixer: %d", __func__, card_num); - return; + return NULL; } in_snd_card_name = mixer_get_name(mixer); @@ -1913,10 +1915,9 @@ static void find_stdev_mixer_path(int card_num, char *mixer_path_xml) ALOGD("%s: using %s", __func__, mixer_path_xml); on_error: - if (mixer) - mixer_close(mixer); if (snd_card_name) free(snd_card_name); + return mixer; } static int find_sound_card() { @@ -2117,7 +2118,13 @@ static int stdev_open(const hw_module_t *module, const char *name, ret = -EIO; goto error; } - find_stdev_mixer_path(snd_card_num, mixer_path_xml); + stdev->mixer = find_stdev_mixer_path(snd_card_num, mixer_path_xml); + if (stdev->mixer == NULL) { + ALOGE("Failed to init the mixer"); + ret = -EAGAIN; + goto error; + } + stdev->route_hdl = audio_route_init(snd_card_num, mixer_path_xml); if (stdev->route_hdl == NULL) { ALOGE("Failed to init the audio_route library"); @@ -2146,6 +2153,8 @@ error: audio_route_free(stdev->route_hdl); if (stdev->odsp_hdl) iaxxx_odsp_deinit(stdev->odsp_hdl); + if (stdev->mixer) + mixer_close(stdev->mixer); pthread_mutex_unlock(&stdev->lock); return ret; |