summaryrefslogtreecommitdiff
path: root/cvq_util.c
diff options
context:
space:
mode:
authorJJ Lee <leejj@google.com>2019-06-13 17:15:19 -0700
committerJJ Lee <leejj@google.com>2019-06-18 23:31:10 +0800
commit290e4c3c1a536173d94eeced53a3c0c8aa6c3b3c (patch)
treebf74822c391a86e2de295f503e6b34bc423e2359 /cvq_util.c
parent629ba3e02279bf95099f2e1ec49f85e65753ee8e (diff)
downloadsound_trigger_hal-290e4c3c1a536173d94eeced53a3c0c8aa6c3b3c.tar.gz
sthal: Destroy CHRE asynchronously
+ Inform the Host 1 that Host 0 is about to teardown CHRE routes and packages. Wait for the CHRE_EP_DISCONNECT event from the Host 1, once the event has been received, teardown the route and destroy the packages. + To ensure that sensor create doesn't happen before the previous CHRE destroy is completed, have a wait condition for the previous CHRE destroy to finish. Wait for a max 1 second, if by then the destroy is not completed then go ahead and destroy it and then create it. The wait is done in chunks of 1 second to ensure that we check if the destroy has happened asynchronously, either by timer expiry or by receipt of the event. + Also create a timer of 1 second, if Host 1 doesn't respond within 1 second, then force destroy the CHRE plugins + During crash recovery, there is nothing to destroy, so send a signal to any waiting threads and delete the timer if it has been created. Bug:133509251 Bug:134894194 Test: Build pass, basic function test - Oslo/CHRE/hotword/MusicIQ Change-Id: I5cb3672ad8c1df4608a0e8c1506e9c587c361340 Signed-off-by: JJ Lee <leejj@google.com>
Diffstat (limited to 'cvq_util.c')
-rw-r--r--cvq_util.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/cvq_util.c b/cvq_util.c
index 3313ed1..9b1fa7b 100644
--- a/cvq_util.c
+++ b/cvq_util.c
@@ -953,9 +953,17 @@ int setup_chre_package(struct iaxxx_odsp_hw *odsp_hdl)
goto exit;
}
+ err = iaxxx_odsp_evt_subscribe(odsp_hdl, IAXXX_SYSID_HOST_1,
+ CHRE_EP_DISCONNECT, IAXXX_SYSID_HOST_0, 0);
+ if (err == -1) {
+ ALOGE("%s: ERROR: CHRE event subscription (CHRE EP disconnect) failed "
+ " with error %d(%s)", __func__, errno, strerror(errno));
+ goto exit;
+ }
+
err = iaxxx_odsp_evt_trigger(odsp_hdl, CHRE_EVT_SRC_ID, CHRE_CONFIGURED, 0);
if (err != 0) {
- ALOGE("%s: ERROR: Oslo event trigger (chre configured) failed %d(%s)",
+ ALOGE("%s: ERROR: CHRE event trigger (chre configured) failed %d(%s)",
__func__, errno, strerror(errno));
goto exit;
}
@@ -972,14 +980,6 @@ int destroy_chre_package(struct iaxxx_odsp_hw *odsp_hdl)
ALOGD("+%s+", __func__);
- err = iaxxx_odsp_evt_trigger(odsp_hdl, CHRE_EVT_SRC_ID, CHRE_DESTROYED, 0);
- if (err != 0) {
- ALOGE("%s: ERROR: Oslo event trigger (chre destroyed) failed %d(%s)",
- __func__, errno, strerror(errno));
- goto exit;
- }
-
-
err = iaxxx_odsp_evt_unsubscribe(odsp_hdl, CHRE_EVT_SRC_ID, CHRE_EVT_ID,
IAXXX_SYSID_HOST_1);
if (err != 0) {
@@ -1007,6 +1007,15 @@ int destroy_chre_package(struct iaxxx_odsp_hw *odsp_hdl)
goto exit;
}
+ err = iaxxx_odsp_evt_unsubscribe(odsp_hdl, IAXXX_SYSID_HOST_1,
+ CHRE_EP_DISCONNECT, IAXXX_SYSID_HOST_0);
+ if (err == -1) {
+ ALOGE("%s: ERROR: ODSP_EVENT_UNSUBSCRIBE (for event_id %d, src_id %d)"
+ " IOCTL failed with error %d(%s)", __func__, CHRE_EP_DISCONNECT,
+ IAXXX_SYSID_HOST_1, errno, strerror(errno));
+ goto exit;
+ }
+
err = iaxxx_odsp_plugin_destroy(odsp_hdl, CHRE_INSTANCE_ID,
IAXXX_HMD_BLOCK_ID);
if (err != 0) {
@@ -1021,6 +1030,23 @@ exit:
return err;
}
+int trigger_chre_destroy_event(struct iaxxx_odsp_hw *odsp_hdl) {
+ int err = 0;
+
+ ALOGD("+%s+", __func__);
+
+ err = iaxxx_odsp_evt_trigger(odsp_hdl, CHRE_EVT_SRC_ID, CHRE_DESTROYED, 0);
+ if (err == -1) {
+ ALOGE("%s: ERROR: CHRE event trigger (chre destroyed) failed with "
+ "error %d(%s)", __func__, errno, strerror(errno));
+ goto exit;
+ }
+
+exit:
+ ALOGD("-%s-", __func__);
+ return err;
+}
+
int setup_sensor_package(struct iaxxx_odsp_hw *odsp_hdl)
{
int err = 0;