From a3da380a82ae62da2090fe75730a2e13caa9faf0 Mon Sep 17 00:00:00 2001 From: Sachin Mohan Gadag Date: Thu, 3 Nov 2016 16:32:05 +0530 Subject: [PATCH] audio: hal: Add new get_param_data api Implement get_param_data api to store Sourcetracking parameters in payload. Change-Id: Idd8c3ddbe053237ea642c61dcc8441ed404e9c75 --- Makefile.am | 7 ++++++- configure.ac | 2 ++ hal/audio_extn/audio_defs.h | 26 ++++++++++++++++++++++++++ hal/audio_extn/source_track.c | 30 ++++++++++++++++++++++++++++++ hal/audio_hw_extn_api.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 57c0c821..299385d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1,7 @@ -SUBDIRS = hal qahw_api qahw_api/test +SUBDIRS = hal + +if QAHW_SUPPORT +SUBDIRS += qahw_api qahw_api/test +endif + ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index b3fe8cc0..cbc082ca 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,8 @@ fi AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") +AM_CONDITIONAL([QAHW_SUPPORT], [test x$BOARD_SUPPORTS_QAHW = xtrue]) + AM_CONDITIONAL([HDMI_EDID], [test x$AUDIO_FEATURE_ENABLED_HDMI_EDID = xtrue]) AM_CONDITIONAL([FM_POWER_OPT], [test x$AUDIO_FEATURE_ENABLED_FM_POWER_OPT = xtrue]) AM_CONDITIONAL([USBAUDIO], [test x$AUDIO_FEATURE_ENABLED_USBAUDIO = xtrue]) diff --git a/hal/audio_extn/audio_defs.h b/hal/audio_extn/audio_defs.h index cfd29e0b..ee4f7d4d 100644 --- a/hal/audio_extn/audio_defs.h +++ b/hal/audio_extn/audio_defs.h @@ -111,4 +111,30 @@ */ #define AUDIO_INPUT_FLAG_TIMESTAMP 0x80000000 +/* MAX SECTORS for sourcetracking feature */ +#define MAX_SECTORS 8 + +struct qahw_source_tracking_param { + uint8_t vad[MAX_SECTORS]; + uint16_t doa_speech; + uint16_t doa_noise[3]; + uint8_t polar_activity[360]; +}; + +struct qahw_sound_focus_param { + uint16_t start_angle[MAX_SECTORS]; + uint8_t enable[MAX_SECTORS]; + uint16_t gain_step; +}; + +typedef union { + struct qahw_source_tracking_param st_params; + struct qahw_sound_focus_param sf_params; +} qahw_param_payload; + +typedef enum { + QAHW_PARAM_SOURCE_TRACK, + QAHW_PARAM_SOUND_FOCUS +} qahw_param_id; + #endif /* AUDIO_DEFS_H */ diff --git a/hal/audio_extn/source_track.c b/hal/audio_extn/source_track.c index 0a0b9702..d34ed6ba 100644 --- a/hal/audio_extn/source_track.c +++ b/hal/audio_extn/source_track.c @@ -502,6 +502,36 @@ static void send_soundfocus_sourcetracking_params(struct str_parms *reply, } } +int audio_extn_get_soundfocus_data(const struct audio_device *adev, + struct sound_focus_param *payload) +{ + int ret = 0; + int bitmask =0; + struct sound_focus_param *sound_focus_data = payload; + + bitmask = BITMASK_AUDIO_PARAMETER_KEYS_SOUND_FOCUS; + + ret = get_soundfocus_sourcetracking_data(adev, bitmask, + sound_focus_data, NULL); + + return ret ; +} + +int audio_extn_get_sourcetrack_data(const struct audio_device *adev, + struct source_tracking_param *payload) +{ + int ret = 0; + int bitmask = 0; + struct source_tracking_param *source_tracking_data = payload; + + bitmask = BITMASK_AUDIO_PARAMETER_KEYS_SOURCE_TRACKING; + + ret = get_soundfocus_sourcetracking_data(adev, bitmask, + NULL, source_tracking_data); + + return ret ; +} + void audio_extn_source_track_get_parameters(const struct audio_device *adev, struct str_parms *query, struct str_parms *reply) diff --git a/hal/audio_hw_extn_api.c b/hal/audio_hw_extn_api.c index bfeda9b3..c4a3cdfe 100644 --- a/hal/audio_hw_extn_api.c +++ b/hal/audio_hw_extn_api.c @@ -48,6 +48,39 @@ uint64_t timestamp; }; #endif +int qahwi_get_param_data(const struct audio_device *adev, + qahw_param_id param_id, qahw_param_payload *payload) +{ + int ret = 0; + + if (adev == NULL) { + ALOGE("%s::INVALID PARAM\n",__func__); + return -EINVAL; + } + + if (payload == NULL) { + ALOGE("%s::INVALID PAYLOAD VALUE\n",__func__); + return -EINVAL; + } + + switch (param_id) { + case QAHW_PARAM_SOUND_FOCUS: + ret = audio_extn_get_soundfocus_data(adev, + (struct qahw_sound_focus_param *)payload); + break; + case QAHW_PARAM_SOURCE_TRACK: + ret = audio_extn_get_sourcetrack_data(adev, + (struct qahw_source_tracking_param*)payload); + break; + default: + ALOGE("%s::INVALID PARAM ID:%d\n",__func__,param_id); + ret = -EINVAL; + break; + + return ret; + } +} + ssize_t qahwi_in_read_v2(struct audio_stream_in *stream, void* buffer, size_t bytes, uint64_t *timestamp) {