Merge "hal: enable audio zoom feature dynamically"

This commit is contained in:
qctecmdr 2019-05-09 02:59:17 -07:00 committed by Gerrit - the friendly Code Review server
commit 99c1fc0d8b
15 changed files with 211 additions and 30 deletions

View File

@ -70,6 +70,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<flag name="a2dp_offload_enabled" value="true" />
<flag name="anc_headset_enabled" value="true" />
<flag name="audiosphere_enabled" value="true" />
<flag name="audio_zoom_enabled" value="false" />
<flag name="battery_listener_enabled" value="true" />
<flag name="compress_capture_enabled" value="false" />
<flag name="compress_in_enabled" value="true" />

View File

@ -32,6 +32,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<flag name="a2dp_offload_enabled" value="true" />
<flag name="afe_proxy_enabled" value="false" />
<flag name="anc_headset_enabled" value="false" />
<flag name="audio_zoom_enabled" value="false" />
<flag name="audiosphere_enabled" value="false" />
<flag name="battery_listener_enabled" value="false" />
<flag name="compress_capture_enabled" value="false" />

View File

@ -69,6 +69,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- AHAL Configs -->
<flag name="a2dp_offload_enabled" value="true" />
<flag name="anc_headset_enabled" value="true" />
<flag name="audio_zoom_enabled" value="false" />
<flag name="audiosphere_enabled" value="true" />
<flag name="battery_listener_enabled" value="true" />
<flag name="compress_capture_enabled" value="false" />

View File

@ -32,6 +32,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<flag name="a2dp_offload_enabled" value="true" />
<flag name="afe_proxy_enabled" value="false" />
<flag name="anc_headset_enabled" value="false" />
<flag name="audio_zoom_enabled" value="true" />
<flag name="audiosphere_enabled" value="false" />
<flag name="battery_listener_enabled" value="false" />
<flag name="compress_capture_enabled" value="false" />

View File

@ -340,12 +340,6 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_GCOV)),true)
LOCAL_STATIC_LIBRARIES += libprofile_rt
endif
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUDIO_ZOOM)), true)
LOCAL_CFLAGS += -DAUDIOZOOM_QDSP_ENABLED
LOCAL_SRC_FILES += audio_extn/audiozoom.c
endif
#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUTO_HAL)),true)
# LOCAL_CFLAGS += -DAUDIO_EXTN_AUTO_HAL_ENABLED
# LOCAL_SRC_FILES += audio_extn/auto_hal.c

View File

@ -109,7 +109,8 @@ void AHalConfigHelper::initConfigHelper(bool isVendorEnhancedFwk)
true, /* COMPRESS_METADATA_NEEDED */
false, /* INCALL_MUSIC */
false, /* COMPRESS_VOIP */
true /* DYNAMIC_ECNS */
true, /* DYNAMIC_ECNS */
false, /* AUDIO_ZOOM */
};
#else
if (isVendorEnhancedFwk) {
@ -155,6 +156,7 @@ void AHalConfigHelper::initConfigHelper(bool isVendorEnhancedFwk)
true, /* INCALL_MUSIC */
false, /* COMPRESS_VOIP */
true, /* DYNAMIC_ECNS */
false, /* AUDIO_ZOOM */
};
} else {
defaultConfigs = {
@ -198,7 +200,8 @@ void AHalConfigHelper::initConfigHelper(bool isVendorEnhancedFwk)
false, /* COMPRESS_METADATA_NEEDED */
true, /* INCALL_MUSIC */
false, /* COMPRESS_VOIP */
false /* DYNAMIC_ECNS */
false, /* DYNAMIC_ECNS */
true, /* AUDIO_ZOOM */
};
}
#endif

View File

@ -76,6 +76,7 @@ typedef struct {
bool incall_music_enabled;
bool compress_voip_enabled;
bool dynamic_ecns_enabled;
bool audio_zoom_enabled;
} AHalValues;
#ifdef __cplusplus

View File

@ -765,3 +765,62 @@ endif
LOCAL_HEADER_LIBRARIES += libhardware_headers
LOCAL_HEADER_LIBRARIES += libsystem_headers
include $(BUILD_SHARED_LIBRARY)
#-------------------------------------------
# Build AUDIOZOOM
#-------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE:= libaudiozoom
LOCAL_VENDOR_MODULE := true
PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
ifneq ($(filter sdm845 sdm710 msmnile kona sdm660 msm8937 $(MSMSTEPPE),$(TARGET_BOARD_PLATFORM)),)
# B-family platform uses msm8974 code base
AUDIO_PLATFORM = msm8974
MULTIPLE_HW_VARIANTS_ENABLED := true
endif
LOCAL_SRC_FILES:= \
audiozoom.c
LOCAL_CFLAGS += \
-Wall \
-Werror \
-Wno-unused-function \
-Wno-unused-variable
LOCAL_SHARED_LIBRARIES := \
libaudioutils \
libcutils \
liblog \
libtinyalsa \
libtinycompress \
libaudioroute \
libdl \
libexpat
LOCAL_C_INCLUDES := \
$(PRIMARY_HAL_PATH) \
$(PRIMARY_HAL_PATH)/$(AUDIO_PLATFORM) \
external/tinyalsa/include \
external/tinycompress/include \
external/expat/lib \
system/media/audio_utils/include \
$(call include-path-for, audio-route) \
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
LOCAL_HEADER_LIBRARIES += audio_kernel_headers
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
endif
LOCAL_HEADER_LIBRARIES += libhardware_headers
LOCAL_HEADER_LIBRARIES += libsystem_headers
include $(BUILD_SHARED_LIBRARY)

View File

@ -191,6 +191,7 @@ static bool audio_extn_concurrent_capture_enabled = false;
static bool audio_extn_compress_in_enabled = false;
static bool audio_extn_battery_listener_enabled = false;
static bool audio_extn_maxx_audio_enabled = false;
static bool audio_extn_audiozoom_enabled = false;
#define AUDIO_PARAMETER_KEY_AANC_NOISE_LEVEL "aanc_noise_level"
#define AUDIO_PARAMETER_KEY_ANC "anc_enabled"
@ -4762,6 +4763,105 @@ bool audio_extn_battery_properties_is_charging()
}
// END: BATTERY_LISTENER ================================================================
// START: AUDIOZOOM_FEATURE =====================================================================
#ifdef __LP64__
#define AUDIOZOOM_LIB_PATH "/vendor/lib64/libaudiozoom.so"
#else
#define AUDIOZOOM_LIB_PATH "/vendor/lib/libaudiozoom.so"
#endif
static void *audiozoom_lib_handle = NULL;
typedef int (*audiozoom_init_t)(audiozoom_init_config_t);
static audiozoom_init_t audiozoom_init;
typedef int (*audiozoom_set_microphone_direction_t)(struct stream_in *,
audio_microphone_direction_t);
static audiozoom_set_microphone_direction_t audiozoom_set_microphone_direction;
typedef int (*audiozoom_set_microphone_field_dimension_t)(struct stream_in *, float);
static audiozoom_set_microphone_field_dimension_t audiozoom_set_microphone_field_dimension;
int audiozoom_feature_init(bool is_feature_enabled)
{
audio_extn_audiozoom_enabled = is_feature_enabled;
ALOGD("%s: Called with feature %s", __func__,
is_feature_enabled ? "Enabled" : "NOT Enabled");
if (is_feature_enabled) {
// dlopen lib
audiozoom_lib_handle = dlopen(AUDIOZOOM_LIB_PATH, RTLD_NOW);
if (!audiozoom_lib_handle) {
ALOGE("%s: dlopen failed", __func__);
goto feature_disabled;
}
if (!(audiozoom_init =
(audiozoom_init_t)dlsym(audiozoom_lib_handle, "audiozoom_init")) ||
!(audiozoom_set_microphone_direction =
(audiozoom_set_microphone_direction_t)dlsym(audiozoom_lib_handle,
"audiozoom_set_microphone_direction")) ||
!(audiozoom_set_microphone_field_dimension =
(audiozoom_set_microphone_field_dimension_t)dlsym(audiozoom_lib_handle,
"audiozoom_set_microphone_field_dimension"))) {
ALOGE("%s: dlsym failed", __func__);
goto feature_disabled;
}
ALOGD("%s:: ---- Feature AUDIOZOOM is Enabled ----", __func__);
return 0;
}
feature_disabled:
if (audiozoom_lib_handle) {
dlclose(audiozoom_lib_handle);
audiozoom_lib_handle = NULL;
}
audiozoom_init = NULL;
audiozoom_set_microphone_direction = NULL;
audiozoom_set_microphone_field_dimension = NULL;
ALOGW(":: %s: ---- Feature AUDIOZOOM is disabled ----", __func__);
return -ENOSYS;
}
bool audio_extn_is_audiozoom_enabled()
{
return audio_extn_audiozoom_enabled;
}
int audio_extn_audiozoom_init()
{
int ret_val = 0;
if (audiozoom_init) {
audiozoom_init_config_t init_config;
init_config.fp_platform_set_parameters = platform_set_parameters;
ret_val = audiozoom_init(init_config);
}
return ret_val;
}
int audio_extn_audiozoom_set_microphone_direction(struct stream_in *stream,
audio_microphone_direction_t dir)
{
int ret_val = -ENOSYS;
if (audiozoom_set_microphone_direction)
ret_val = audiozoom_set_microphone_direction(stream, dir);
return ret_val;
}
int audio_extn_audiozoom_set_microphone_field_dimension(struct stream_in *stream,
float zoom)
{
int ret_val = -ENOSYS;
if (audiozoom_set_microphone_field_dimension)
ret_val = audiozoom_set_microphone_field_dimension(stream, zoom);
return ret_val;
}
// END: AUDIOZOOM_FEATURE =====================================================================
// START: MAXX_AUDIO =====================================================================
#ifdef __LP64__
#define MAXX_AUDIO_LIB_PATH "/vendor/lib64/libmaxxaudio.so"
@ -5000,6 +5100,8 @@ void audio_extn_feature_init(int is_running_with_enhanced_fwk)
case MAXX_AUDIO:
maxx_audio_feature_init(enable);
break;
case AUDIO_ZOOM:
audiozoom_feature_init(enable);
default:
break;
}

View File

@ -327,6 +327,22 @@ struct a2dp_offload_init_config {
};
typedef struct a2dp_offload_init_config a2dp_offload_init_config_t;
// END: A2DP_OFFLOAD FEATURE ====================================================
typedef int (*fp_platform_set_parameters_t)(void*, struct str_parms*);
// START: AUDIOZOOM FEATURE ==================================================
int audio_extn_audiozoom_init();
int audio_extn_audiozoom_set_microphone_direction(struct stream_in *stream,
audio_microphone_direction_t dir);
int audio_extn_audiozoom_set_microphone_field_dimension(struct stream_in *stream, float zoom);
bool audio_extn_is_audiozoom_enabled();
struct audiozoom_init_config {
fp_platform_set_parameters_t fp_platform_set_parameters;
};
typedef struct audiozoom_init_config audiozoom_init_config_t;
// END: AUDIOZOOM FEATURE ==================================================
// START: MAXX_AUDIO FEATURE ==================================================
void audio_extn_ma_init(void *platform);
void audio_extn_ma_deinit();
@ -337,7 +353,6 @@ void audio_extn_ma_set_parameters(struct audio_device *adev,
struct str_parms *parms);
bool audio_extn_ma_supported_usb();
bool audio_extn_is_maxx_audio_enabled();
typedef int (*fp_platform_set_parameters_t)(void*, struct str_parms*);
// --- Function pointers from audio_extn needed by MAXX_AUDIO
struct maxx_audio_init_config {
fp_platform_set_parameters_t fp_platform_set_parameters;

View File

@ -178,6 +178,8 @@ bool audio_feature_manager_is_feature_enabled(audio_ext_feature feature)
return confValues->compress_voip_enabled;
case DYNAMIC_ECNS:
return confValues->dynamic_ecns_enabled;
case AUDIO_ZOOM:
return confValues->audio_zoom_enabled;
default:
return false;
}

View File

@ -33,6 +33,7 @@
#include <ahal_config_helper.h>
enum audio_ext_feature_t {
// Start Audio feature flags
SND_MONITOR = 0,
COMPRESS_CAPTURE,
SOURCE_TRACK,
@ -71,10 +72,14 @@ enum audio_ext_feature_t {
BATTERY_LISTENER,
COMPRESS_METADATA_NEEDED,
MAXX_AUDIO,
AUDIO_ZOOM,
// End Audio feature flags
// Start Voice feature flags
COMPRESS_VOIP,
VOICE_START = COMPRESS_VOIP,
DYNAMIC_ECNS,
INCALL_MUSIC,
// End Voice feature flags
MAX_SUPPORTED_FEATURE
};

View File

@ -23,7 +23,6 @@
#include <expat.h>
#include <audio_hw.h>
#include <system/audio.h>
#include <platform_api.h>
#include "audio_extn.h"
#include "audiozoom.h"
@ -32,6 +31,9 @@
#define AUDIOZOOM_PRESET_FILE "/vendor/etc/audiozoom.xml"
// --- external function dependency ---
fp_platform_set_parameters_t fp_platform_set_parameters;
typedef struct qdsp_audiozoom_cfg {
uint32_t topo_id;
uint32_t module_id;
@ -116,7 +118,7 @@ static void end_tag(void *userdata __unused, const XML_Char *tag_name)
}
}
static int audio_extn_audiozoom_parse_info(const char *filename)
static int audiozoom_parse_info(const char *filename)
{
XML_Parser parser;
FILE *file;
@ -176,7 +178,7 @@ done:
return ret;
}
int audio_extn_audiozoom_set_microphone_direction(
int audiozoom_set_microphone_direction(
struct stream_in *in, audio_microphone_direction_t dir)
{
(void)in;
@ -184,7 +186,7 @@ int audio_extn_audiozoom_set_microphone_direction(
return 0;
}
static int audio_extn_audiozoom_set_microphone_field_dimension_zoom(
static int audiozoom_set_microphone_field_dimension_zoom(
struct stream_in *in, float zoom)
{
struct audio_device *adev = in->dev;
@ -212,7 +214,7 @@ static int audio_extn_audiozoom_set_microphone_field_dimension_zoom(
if (ret > 0) {
str_parms_add_str(parms, "cal_data", data);
platform_set_parameters(adev->platform, parms);
fp_platform_set_parameters(adev->platform, parms);
} else {
ALOGE("%s: failed to convert data to string, ret %d", __func__, ret);
}
@ -222,7 +224,7 @@ static int audio_extn_audiozoom_set_microphone_field_dimension_zoom(
return 0;
}
static int audio_extn_audiozoom_set_microphone_field_dimension_wide_angle(
static int audiozoom_set_microphone_field_dimension_wide_angle(
struct stream_in *in, float zoom)
{
(void)in;
@ -230,24 +232,25 @@ static int audio_extn_audiozoom_set_microphone_field_dimension_wide_angle(
return 0;
}
int audio_extn_audiozoom_set_microphone_field_dimension(
int audiozoom_set_microphone_field_dimension(
struct stream_in *in, float zoom)
{
if (zoom > 1.0 || zoom < -1.0)
return -EINVAL;
if (zoom >= 0 && zoom <= 1.0)
return audio_extn_audiozoom_set_microphone_field_dimension_zoom(in, zoom);
return audiozoom_set_microphone_field_dimension_zoom(in, zoom);
if (zoom >= -1.0 && zoom <= 0)
return audio_extn_audiozoom_set_microphone_field_dimension_wide_angle(in, zoom);
return audiozoom_set_microphone_field_dimension_wide_angle(in, zoom);
return 0;
}
int audio_extn_audiozoom_init()
int audiozoom_init(audiozoom_init_config_t init_config)
{
audio_extn_audiozoom_parse_info(AUDIOZOOM_PRESET_FILE);
fp_platform_set_parameters = init_config.fp_platform_set_parameters;
audiozoom_parse_info(AUDIOZOOM_PRESET_FILE);
ALOGV("%s: topo_id=%d, module_id=%d, instance_id=%d, zoom__id=%d, dir_id=%d, app_type=%d",
__func__, qdsp_audiozoom.topo_id, qdsp_audiozoom.module_id, qdsp_audiozoom.instance_id,

View File

@ -17,15 +17,9 @@
#ifndef AUDIOZOOM_H_
#define AUDIOZOOM_H_
#ifndef AUDIOZOOM_QDSP_ENABLED
#define audio_extn_audiozoom_init() (0)
#define audio_extn_audiozoom_set_microphone_direction(stream, dir) (-ENOSYS)
#define audio_extn_audiozoom_set_microphone_field_dimension(stream, zoom) (-ENOSYS)
#else
int audio_extn_audiozoom_init();
int audio_extn_audiozoom_set_microphone_direction(struct stream_in *stream,
int audiozoom_init(audiozoom_init_config_t init_config);
int audiozoom_set_microphone_direction(struct stream_in *stream,
audio_microphone_direction_t dir);
int audio_extn_audiozoom_set_microphone_field_dimension(struct stream_in *stream, float zoom);
#endif
int audiozoom_set_microphone_field_dimension(struct stream_in *stream, float zoom);
#endif /* AUDIOZOOM_H_ */

View File

@ -75,7 +75,6 @@
#include "voice_extn.h"
#include "ip_hdlr_intf.h"
#include "audio_feature_manager.h"
#include "audio_extn/audiozoom.h"
#include "sound/compress_params.h"
#include "sound/asound.h"