Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dc77808 authored by Arun Mirpuri's avatar Arun Mirpuri Committed by Weiyin Jiang
Browse files

hal: Fixes for initalizing audio_extn features

1) Fixes for initializing audio_extn features such as speaker_prot,
fm,etc.
2) Runtime detection using vndk_fwkdetect lib has been
changed to dynamic loading instead of static linking

Change-Id: I4deef5e9ffefc17e427ecf5a271ed7bcd18dbb0f
parent d3b68131
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -358,7 +358,6 @@ LOCAL_SHARED_LIBRARIES := \
    libdl \
    libaudioutils \
    libexpat \
    libqti_vndfwk_detect \
    libhwbinder \
    libhidlbase \
    libhidltransport \
+12 −0
Original line number Diff line number Diff line
@@ -74,6 +74,12 @@ void AHalConfigHelper::initDefaultConfig(bool isVendorEnhancedFwk)
            true,        /* FLUENCE */
            true,        /* CUSTOM_STEREO */
            true,        /* ANC_HEADSET */
            true,        /* SPKR_PROT */
            true,        /* FM_POWER_OPT */
            false,       /* EXTERNAL_QDSP */
            false,       /* EXTERNAL_SPEAKER */
            false,       /* EXTERNAL_SPEAKER_TFA */
            false,       /* HWDEP_CAL */
            false,       /* DSM_FEEDBACK */
            true,        /* USB_OFFLOAD */
            false,       /* USB_OFFLOAD_BURST_MODE */
@@ -102,6 +108,12 @@ void AHalConfigHelper::initDefaultConfig(bool isVendorEnhancedFwk)
            false,       /* FLUENCE */
            false,       /* CUSTOM_STEREO */
            false,       /* ANC_HEADSET */
            true,        /* SPKR_PROT */
            false,       /* FM_POWER_OPT */
            true,        /* EXTERNAL_QDSP */
            true,        /* EXTERNAL_SPEAKER */
            false,       /* EXTERNAL_SPEAKER_TFA */
            true,        /* HWDEP_CAL */
            false,       /* DSM_FEEDBACK */
            true,        /* USB_OFFLOAD */
            false,       /* USB_OFFLOAD_BURST_MODE */
+6 −0
Original line number Diff line number Diff line
@@ -46,6 +46,12 @@ struct AHalValues_t {
    bool fluence_enabled;
    bool custom_stereo_enabled;
    bool anc_headset_enabled;
    bool spkr_prot_enabled;
    bool fm_power_opt_enabled;
    bool ext_qdsp_enabled;
    bool ext_spkr_enabled;
    bool ext_spkr_tfa_enabled;
    bool hwdep_cal_enabled;
    bool dsm_feedback_enabled;
    bool usb_offload_enabled;
    bool usb_offload_burst_mode;
+1 −2
Original line number Diff line number Diff line
@@ -373,8 +373,7 @@ LOCAL_SHARED_LIBRARIES := \
    libtinycompress \
    libaudioroute \
    libdl \
    libexpat \
    libqti_vndfwk_detect
    libexpat

LOCAL_C_INCLUDES := \
    $(PRIMARY_HAL_PATH) \
+80 −39
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <log/log.h>
#include <dlfcn.h>
#include <pthread.h>
#include <vndfwk-detect.h>
#include "audio_hw.h"
#include "platform.h"
#include "platform_api.h"
@@ -142,6 +141,19 @@
#define CH_MONO                         1
#define SOURCE 0
#define SINK   1
#define UNINITIALIZED -1

#ifdef __LP64__
#define VNDK_FWK_LIB_PATH "/vendor/lib64/libqti_vndfwk_detect.so"
#else
#define VNDK_FWK_LIB_PATH "/vendor/lib/libqti_vndfwk_detect.so"
#endif

static void *vndk_fwk_lib_handle = NULL;
static int is_running_with_enhanced_fwk = UNINITIALIZED;

typedef int (*vndk_fwk_isVendorEnhancedFwk_t)();
static vndk_fwk_isVendorEnhancedFwk_t vndk_fwk_isVendorEnhancedFwk;

/*
 * Below enum values are extended from audio_base.h to
@@ -810,6 +822,26 @@ fail:
    return -ENOSYS;
}

static int check_if_enhanced_fwk() {

    int is_enhanced_fwk = 1;
    //dlopen lib
    vndk_fwk_lib_handle = dlopen(VNDK_FWK_LIB_PATH, RTLD_NOW);
    if (vndk_fwk_lib_handle != NULL) {
        vndk_fwk_isVendorEnhancedFwk = (vndk_fwk_isVendorEnhancedFwk_t)
                    dlsym(vndk_fwk_lib_handle, "isRunningWithVendorEnhancedFramework");
        if (vndk_fwk_isVendorEnhancedFwk == NULL) {
            ALOGW("%s: VNDK_FWK_LIB not found, defaulting to enhanced_fwk configuration",
                                                                            __func__);
            is_enhanced_fwk = 1;
        } else {
            is_enhanced_fwk = vndk_fwk_isVendorEnhancedFwk();
        }
    }
    ALOGV("%s: vndk_fwk_isVendorEnhancedFwk=%d", __func__, is_enhanced_fwk);
    return is_enhanced_fwk;
}

/* API to open BT IPC library to start IPC communication for BT Source*/
static void open_a2dp_source()
{
@@ -817,7 +849,9 @@ static void open_a2dp_source()

    ALOGD(" Open A2DP source start ");
    if (a2dp.bt_lib_source_handle == NULL) {
        if(!isRunningWithVendorEnhancedFramework()) {
        if (is_running_with_enhanced_fwk == UNINITIALIZED)
            is_running_with_enhanced_fwk = check_if_enhanced_fwk();
        if (!is_running_with_enhanced_fwk) {
            ALOGD(" Requesting for BT lib handle");
            a2dp.bt_lib_source_handle = dlopen(BT_IPC_SOURCE_LIB_NAME, RTLD_NOW);
            if (a2dp.bt_lib_source_handle == NULL) {
@@ -884,6 +918,10 @@ init_fail:
        dlclose(a2dp.bt_lib_source_handle);
        a2dp.bt_lib_source_handle = NULL;
    }
    if (vndk_fwk_lib_handle != NULL) {
        dlclose(vndk_fwk_lib_handle);
        vndk_fwk_lib_handle = NULL;
    }
}

/* API to open BT IPC library to start IPC communication for BT Sink*/
@@ -2687,7 +2725,10 @@ void a2dp_init(void *adev,
  a2dp.a2dp_sink_started = false;
  a2dp.bt_state_sink = A2DP_STATE_DISCONNECTED;
  a2dp.a2dp_sink_total_active_session_requests = 0;
  if (isRunningWithVendorEnhancedFramework())

  if (is_running_with_enhanced_fwk == UNINITIALIZED)
      is_running_with_enhanced_fwk = check_if_enhanced_fwk();
  if (is_running_with_enhanced_fwk)
      open_a2dp_sink();

  a2dp.is_a2dp_offload_supported = false;
Loading