From aa4fa6a6147315a87d7950c7de2c1da1226d140b Mon Sep 17 00:00:00 2001 From: Sidipotu Ashok Date: Fri, 21 Dec 2018 09:19:26 +0530 Subject: [PATCH] hal: add support for FFV get params -Audio HAL to support FFV get_paramters via sound trigger callback. -FFV needs clients to pass down the SM handle info to get a few paramerters with respect to the given SM handle but standard get_parameters doesn't support kvpairs for input keys, it does support for return of kvpairs, add support for a new delimiter which will be used while sending keys in get_parameter. -Enable Keep alive for Red Dragon -Adjust volume gains based on the systems team tuned values Change-Id: I96c7214b4a084568862e3550eaabbb9d51e253d9 --- configs/sdm710/sdm710.mk | 4 ++ .../sound_trigger_mixer_paths_wcd9340.xml | 4 ++ hal/audio_extn/soundtrigger.c | 58 +++++++++++++++---- hal/audio_hw.c | 4 +- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/configs/sdm710/sdm710.mk b/configs/sdm710/sdm710.mk index 6db48b6e..04aac8aa 100644 --- a/configs/sdm710/sdm710.mk +++ b/configs/sdm710/sdm710.mk @@ -268,6 +268,10 @@ vendor.audio.offload.pstimeout.secs=3 PRODUCT_PROPERTY_OVERRIDES += \ ro.af.client_heap_size_kbyte=7168 +#keep alive is needed by default for ffv +PRODUCT_PROPERTY_OVERRIDES += \ +vendor.audio.keep_alive.disabled=false + # for HIDL related packages PRODUCT_PACKAGES += \ android.hardware.audio@2.0-service \ diff --git a/configs/sdm710/sound_trigger_mixer_paths_wcd9340.xml b/configs/sdm710/sound_trigger_mixer_paths_wcd9340.xml index 4d1bb31a..df61226a 100644 --- a/configs/sdm710/sound_trigger_mixer_paths_wcd9340.xml +++ b/configs/sdm710/sound_trigger_mixer_paths_wcd9340.xml @@ -342,15 +342,19 @@ + + + + diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c index 95907f36..aa1f7c00 100644 --- a/hal/audio_extn/soundtrigger.c +++ b/hal/audio_extn/soundtrigger.c @@ -176,6 +176,8 @@ do {\ #define SVA_PARAM_DIRECTION_OF_ARRIVAL "st_direction_of_arrival" #define SVA_PARAM_CHANNEL_INDEX "st_channel_index" +#define MAX_STR_LENGTH_FFV_PARAMS 30 +#define MAX_FFV_SESSION_ID 100 /* * Current proprietary API version used by AHAL. Queried by STHAL * for compatibility check with AHAL @@ -620,12 +622,46 @@ void audio_extn_sound_trigger_set_parameters(struct audio_device *adev __unused, } } +static int extract_sm_handle(const char *keys, char *paramstr) { + char *tmpstr, *token; + char *inputstr = NULL; + int value = -EINVAL; + + if (keys == NULL || paramstr == NULL) + goto exit; + + inputstr = strdup(keys); + token =strtok_r(inputstr,":", &tmpstr); + + if (token == NULL) + goto exit; + + ALOGD("%s input string <%s> param string <%s>", __func__, keys,token); + strlcpy(paramstr, token, MAX_STR_LENGTH_FFV_PARAMS); + token =strtok_r(NULL,":=",&tmpstr); + + if (token == NULL) + goto exit; + + value = atoi(token); + if (value > 0 && value < MAX_FFV_SESSION_ID) + ALOGD(" %s SVA sm handle<=%d>",__func__, value); + +exit: + if (inputstr != NULL) + free(inputstr); + + return value; +} void audio_extn_sound_trigger_get_parameters(const struct audio_device *adev __unused, - struct str_parms *query, struct str_parms *reply) + struct str_parms *query, + struct str_parms *reply) { audio_event_info_t event; - int ret, val; - char value[32]; + int ret; + char value[32], paramstr[MAX_STR_LENGTH_FFV_PARAMS]; + + ALOGD("%s input string<%s>", __func__, str_parms_to_str(query)); ret = str_parms_get_str(query, "SVA_EXEC_MODE_STATUS", value, sizeof(value)); @@ -634,17 +670,17 @@ void audio_extn_sound_trigger_get_parameters(const struct audio_device *adev __u str_parms_add_int(reply, "SVA_EXEC_MODE_STATUS", event.u.value); } - ret = str_parms_get_int(query, SVA_PARAM_DIRECTION_OF_ARRIVAL, &val); - if (ret >= 0) { - event.u.st_get_param_data.sm_handle = val; + ret = extract_sm_handle(str_parms_to_str(query), paramstr); + + if ((ret >= 0) && !strncmp(paramstr, SVA_PARAM_DIRECTION_OF_ARRIVAL, + MAX_STR_LENGTH_FFV_PARAMS)) { + event.u.st_get_param_data.sm_handle = ret; event.u.st_get_param_data.param = SVA_PARAM_DIRECTION_OF_ARRIVAL; event.u.st_get_param_data.reply = reply; st_dev->st_callback(AUDIO_EVENT_GET_PARAM, &event); - } - - ret = str_parms_get_int(query, SVA_PARAM_CHANNEL_INDEX, &val); - if (ret >= 0) { - event.u.st_get_param_data.sm_handle = val; + } else if ((ret >=0) && !strncmp(paramstr, SVA_PARAM_CHANNEL_INDEX, + MAX_STR_LENGTH_FFV_PARAMS)) { + event.u.st_get_param_data.sm_handle = ret; event.u.st_get_param_data.param = SVA_PARAM_CHANNEL_INDEX; event.u.st_get_param_data.reply = reply; st_dev->st_callback(AUDIO_EVENT_GET_PARAM, &event); diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 7f417631..2f0ed583 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -6893,6 +6893,8 @@ error: static char* adev_get_parameters(const struct audio_hw_device *dev, const char *keys) { + ALOGD("%s:%s", __func__, keys); + struct audio_device *adev = (struct audio_device *)dev; struct str_parms *reply = str_parms_create(); struct str_parms *query = str_parms_create_str(keys); @@ -6947,7 +6949,7 @@ exit: str_parms_destroy(query); str_parms_destroy(reply); - ALOGV("%s: exit: returns - %s", __func__, str); + ALOGD("%s: exit: returns - %s", __func__, str); return str; }