AHAL: enable audio hal for linux platform

Change-Id: I7de481eb7b04985f232dfe833d76e80907081bdb
Signed-off-by: Hexuan Zhu <hexuzhu@codeaurora.org>
This commit is contained in:
Fei Tong 2021-06-21 16:42:38 +08:00 committed by Hexuan Zhu
parent 4202f6db1a
commit c20ce93633
10 changed files with 486 additions and 62 deletions

2
Makefile.am Normal file → Executable file
View File

@ -1,4 +1,4 @@
SUBDIRS = hal post_proc
SUBDIRS = hal hal/audio_extn
if QAHW_SUPPORT
SUBDIRS += qahw_api qahw_api/test

9
configs/msmnile_au/mixer_paths_adp.xml Normal file → Executable file
View File

@ -2955,11 +2955,6 @@
<path name="incall_music_uplink bt-a2dp">
<path name="incall_music_uplink" />
</path>
<path name="incall_music_uplink afe-proxy">
<path name="incall_music_uplink" />
</path>
<path name="incall_music_uplink2">
<ctl name="Incall_Music_2 Audio Mixer MultiMedia9" value="1" />
</path>
@ -3031,8 +3026,4 @@
<path name="incall_music_uplink2 bt-a2dp">
<path name="incall_music_uplink2" />
</path>
<path name="incall_music_uplink2 afe-proxy">
<path name="incall_music_uplink2" />
</path>
</mixer>

View File

@ -42,6 +42,17 @@ AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, Build against glib. Use this when building for HLOS systems which use glib]))
AC_ARG_ENABLE(target,
[AS_HELP_STRING([--enable-target=TARGET_SUPPORT],
[Specify the target product to build])],
[AS_CASE([$enableval],
[qtiquingvm], [TARGET_SUPPORT=msmnile_au],
[sa81*], [TARGET_SUPPORT=msmnile_au],
[sa61*], [TARGET_SUPPORT=msmsteppe_au],
[TARGET_SUPPORT=none])],
[TARGET_SUPPORT=none]
)
if (test "x${with_glib}" = "xyes"); then
PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
AC_MSG_ERROR(GThread >= 2.16 is required))
@ -93,6 +104,14 @@ if (test x$TARGET_SUPPORT = xsdmsteppe); then
AC_SUBST([TARGET_PLATFORM], ["msm8974"])
TARGET_CFLAGS="-DPLATFORM_MSMSTEPPE"
fi
if (test x$TARGET_SUPPORT = xmsmnile_au); then
AC_SUBST([TARGET_PLATFORM], ["msm8974"])
TARGET_CFLAGS="-DPLATFORM_MSMNILE"
fi
if (test x$TARGET_SUPPORT = xmsmsteppe_au); then
AC_SUBST([TARGET_PLATFORM], ["msm8974"])
TARGET_CFLAGS="-DPLATFORM_MSMSTEPPE"
fi
AC_SUBST([TARGET_CFLAGS])
AM_CONDITIONAL([QTI_AUDIO_SERVER_ENABLED],[test x$BOARD_SUPPORTS_QTI_AUDIO_SERVER = xtrue])
@ -146,6 +165,7 @@ AM_CONDITIONAL([QAHW_V1], [test x$AUDIO_FEATURE_ENABLED_QAHW_1_0 = xtrue])
AC_CONFIG_FILES([ \
Makefile \
hal/Makefile \
hal/audio_extn/Makefile \
post_proc/Makefile \
qahw_api/Makefile \
qahw_api/test/Makefile \

74
hal/Makefile.am Normal file → Executable file
View File

@ -1,24 +1,20 @@
AM_CFLAGS = -I ${WORKSPACE}/external/tinyalsa/include \
-I ${WORKSPACE}/system/media/audio_effects/include \
-I ${WORKSPACE}/system/media/audio_utils/include \
-I $(top_srcdir)/hal \
AM_CFLAGS = -I $(top_srcdir)/hal \
-I $(top_srcdir)/hal/audio_extn \
-I $(top_srcdir)/hal/voice_extn \
-I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/audio-kernel \
-I $(PKG_CONFIG_SYSROOT_DIR)/usr/include \
-I $(top_srcdir)/hal/${TARGET_PLATFORM}
c_sources = audio_hw.c \
voice.c \
platform_info.c \
voice.c \
acdb.c \
${TARGET_PLATFORM}/platform.c \
audio_extn/audio_extn.c \
audio_extn/utils.c \
acdb.c
audio_extn/audio_extn.c \
audio_extn/device_utils.c \
audio_extn/audio_stub.c
if HDMI_EDID
AM_CFLAGS += -DHDMI_EDID
c_sources += edid.c
endif
if FM_POWER_OPT
AM_CFLAGS += -DFM_POWER_OPT
@ -30,17 +26,6 @@ AM_CFLAGS += -DUSB_TUNNEL_ENABLED
c_sources += audio_extn/usb.c
endif
if HFP
AM_CFLAGS += -DHFP_ENABLED
c_sources += audio_extn/hfp.c
endif
if SSR
AM_CFLAGS += -DSSR_ENABLED
c_sources += audio_extn/ssr.c
AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio-external-noship/surround_sound_3mic/libsurround_3mic_proc/surround_rec_interface/inc/
endif
if MULTI_VOICE_SESSIONS
AM_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED
c_sources += voice_extn/voice_extn.c
@ -51,21 +36,15 @@ AM_CFLAGS += -DCOMPRESS_VOIP_ENABLED
c_sources += voice_extn/compress_voip.c
endif
if SPKR_PROTECTION
AM_CFLAGS += -DSPKR_PROT_ENABLED
c_sources += audio_extn/spkr_protection.c
endif
AM_CFLAGS += -DAUDIO_GKI_ENABLED
if HW_VARIANTS
AM_CFLAGS += -DHW_VARIANTS_ENABLED
c_sources += ${TARGET_PLATFORM}/hw_info.c
endif
if COMPRESS_CAPTURE
AM_CFLAGS += -DCOMPRESS_CAPTURE_ENABLED
c_sources += audio_extn/compress_capture.c
endif
if DTS_EAGLE
AM_CFLAGS += -DDTS_EAGLE
c_sources += audio_extn/dts_eagle.c
@ -93,36 +72,34 @@ AM_CFLAGS += -DSOURCE_TRACKING_ENABLED
c_sources += audio_extn/source_track.c
endif
#if LISTEN
#AM_CFLAGS += -DAUDIO_LISTEN_ENABLED
#AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio-external-noship/audio-listen
#c_sources += audio_extn/listen.c
#endif
if LISTEN
AM_CFLAGS += -DAUDIO_LISTEN_ENABLED
c_sources += audio_extn/listen.c
endif
if SOUND_TRIGGER
AM_CFLAGS += -DSOUND_TRIGGER_ENABLED
AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio/sound_trigger/
c_sources += audio_extn/soundtrigger.c
endif
if FLAC_SUPPORT
AM_CFLAGS += -DFLAC_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if ALAC_SUPPORT
AM_CFLAGS += -DALAC_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if VORBIS_SUPPORT
AM_CFLAGS += -DVORBIS_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if WMA_SUPPORT
AM_CFLAGS += -DWMA_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if COMPRESS_INPUT
@ -136,7 +113,6 @@ c_sources += audio_extn/passthru.c
endif
if AUDIO_PARSER
AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio/audio-parsers/inc/
if DTSHD_PARSER
AM_CFLAGS += -DDTSHD_PARSER_ENABLED
endif
@ -170,11 +146,6 @@ AM_CFLAGS += -DAUDIO_EXTN_ADSP_HDLR_ENABLED
c_sources += audio_extn/adsp_hdlr.c
endif
if A2DP_OFFLOAD
AM_CFLAGS += -DA2DP_OFFLOAD_ENABLED
c_sources += audio_extn/a2dp.c
endif
if AUDIO_IP_HDLR
AM_CFLAGS += -DAUDIO_EXTN_IP_HDLR_ENABLED
c_sources += audio_extn/ip_hdlr_intf.c
@ -209,6 +180,10 @@ if INSTANCE_ID
AM_CFLAGS += -DINSTANCE_ID_ENABLED
endif
if HFP
AM_CFLAGS += -DHFP_ENABLED
endif
if LL_AS_PRIMARY_OUTPUT
AM_CFLAGS += -DUSE_LL_AS_PRIMARY_OUTPUT
endif
@ -225,13 +200,16 @@ lib_LTLIBRARIES = audio.primary.default.la
audio_primary_default_la_SOURCES = $(c_sources)
audio_primary_default_la_LIBADD = $(GLIB_LIBS) -llog -lcutils -ltinyalsa
audio_primary_default_la_LIBADD += -ltinycompress -laudioroute -ldl -lexpat -laudioutils
audio_primary_default_la_LIBADD += -lm -lc -lresolv
if AUDIO_PARSER
audio_primary_default_la_LIBADD += -laudioparsers
endif
audio_primary_default_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
audio_primary_default_la_CFLAGS += -Dstrlcat=g_strlcat
audio_primary_default_la_CFLAGS += -DINT_MAX=0x7fffffff
audio_primary_default_la_CFLAGS += -DINT_MAX=0x7fffffff -Wno-error=deprecated-declarations -DPATH_MAX=1024 -DULONG_MAX=0xFFFFFFFFFFFFFFFFUL
audio_primary_default_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
audio_primary_default_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
audio_primary_default_la_CFLAGS += -DNDEBUG
audio_primary_default_la_LDFLAGS = -module -shared -avoid-version
audio_primary_default_la_CPPFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
audio_primary_default_la_CPPFLAGS += -DLINUX_ENABLED

234
hal/audio_extn/Makefile.am Executable file
View File

@ -0,0 +1,234 @@
AM_CFLAGS = -I $(top_srcdir)/hal \
-I $(top_srcdir)/hal/audio_extn \
-I $(top_srcdir)/hal/voice_extn \
-I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/audio-kernel \
-I $(PKG_CONFIG_SYSROOT_DIR)/usr/include \
-I $(top_srcdir)/hal/${TARGET_PLATFORM}
AM_CFLAGS += -DAUDIO_GKI_ENABLED
c_sources = $(top_srcdir)/hal/audio_hw.c \
$(top_srcdir)/hal/platform_info.c \
$(top_srcdir)/hal/voice.c \
$(top_srcdir)/hal/acdb.c \
$(top_srcdir)/hal/${TARGET_PLATFORM}/platform.c \
utils.c \
audio_extn.c \
device_utils.c \
audio_stub.c
if FM_POWER_OPT
AM_CFLAGS += -DFM_POWER_OPT
c_sources += fm.c
endif
if USBAUDIO
AM_CFLAGS += -DUSB_TUNNEL_ENABLED
c_sources += usb.c
endif
if SSR
AM_CFLAGS += -DSSR_ENABLED
c_sources += ssr.c
endif
if MULTI_VOICE_SESSIONS
AM_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED
c_sources += $(top_srcdir)/hal/voice_extn/voice_extn.c
endif
if COMPRESS_VOIP
AM_CFLAGS += -DCOMPRESS_VOIP_ENABLED
c_sources += $(top_srcdir)/hal/voice_extn/compress_voip.c
endif
if SPKR_PROTECTION
AM_CFLAGS += -DSPKR_PROT_ENABLED
c_sources += spkr_protection.c
endif
if HW_VARIANTS
AM_CFLAGS += -DHW_VARIANTS_ENABLED
c_sources += $(top_srcdir)/hal/${TARGET_PLATFORM}/hw_info.c
endif
if COMPRESS_CAPTURE
AM_CFLAGS += -DCOMPRESS_CAPTURE_ENABLED
c_sources += compress_capture.c
endif
if DTS_EAGLE
AM_CFLAGS += -DDTS_EAGLE
c_sources += dts_eagle.c
endif
if DOLBY_DDP
AM_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
c_sources += dolby.c
endif
if DS1_DOLBY_DAP
AM_CFLAGS += -DDS1_DOLBY_DAP_ENABLED
if DOLBY_DDP
c_sources += dolby.c
endif
endif
if DEV_ARBI
AM_CFLAGS += -DDEV_ARBI_ENABLED
c_sources += dev_arbi.c
endif
if SOURCE_TRACKING
AM_CFLAGS += -DSOURCE_TRACKING_ENABLED
c_sources += source_track.c
endif
if LISTEN
AM_CFLAGS += -DAUDIO_LISTEN_ENABLED
c_sources += listen.c
endif
if SOUND_TRIGGER
AM_CFLAGS += -DSOUND_TRIGGER_ENABLED
c_sources += soundtrigger.c
endif
if FLAC_SUPPORT
AM_CFLAGS += -DFLAC_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if ALAC_SUPPORT
AM_CFLAGS += -DALAC_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if VORBIS_SUPPORT
AM_CFLAGS += -DVORBIS_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if WMA_SUPPORT
AM_CFLAGS += -DWMA_OFFLOAD_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
endif
if COMPRESS_INPUT
AM_CFLAGS += -DCOMPRESS_INPUT_ENABLED
c_sources += compress_in.c
endif
if COMPRESS_PASSTHROUGH
AM_CFLAGS += -DHDMI_PASSTHROUGH_ENABLED
c_sources += passthru.c
endif
if AUDIO_PARSER
if DTSHD_PARSER
AM_CFLAGS += -DDTSHD_PARSER_ENABLED
endif
endif
if KEEP_ALIVE
AM_CFLAGS += -DKEEP_ALIVE_ENABLED
c_sources += keep_alive.c
endif
if AUDIO_HW_EXTN_API
AM_CFLAGS += -DAUDIO_HW_EXTN_API_ENABLED
c_sources += $(top_srcdir)/hal/audio_hw_extn_api.c
endif
if GEF
AM_CFLAGS += -DAUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
c_sources += gef.c
endif
if APTX_DECODER
AM_CFLAGS += -DAPTX_DECODER_ENABLED
endif
if AFE_PROXY
AM_CFLAGS += -DAFE_PROXY_ENABLED
endif
if ADSP_HDLR
AM_CFLAGS += -DAUDIO_EXTN_ADSP_HDLR_ENABLED
c_sources += adsp_hdlr.c
endif
if AUDIO_IP_HDLR
AM_CFLAGS += -DAUDIO_EXTN_IP_HDLR_ENABLED
c_sources += ip_hdlr_intf.c
endif
if QAF_SUPPORT
AM_CFLAGS += -DQAF_EXTN_ENABLED
c_sources += qaf.c
endif
if AUDIO_HW_LOOPBACK
AM_CFLAGS += -DAUDIO_HW_LOOPBACK_ENABLED
AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
c_sources += hw_loopback.c
endif
if RUN_KEEP_ALIVE_IN_ARM_FFV
AM_CFLAGS += -DRUN_KEEP_ALIVE_IN_ARM_FFV
endif
if AUDIO_HW_FFV
AM_CFLAGS += -DFFV_ENABLED \
-I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/ffv/
c_sources += ffv.c
endif
if CUSTOM_STEREO
AM_CFLAGS += -DCUSTOM_STEREO_ENABLED
endif
if INSTANCE_ID
AM_CFLAGS += -DINSTANCE_ID_ENABLED
endif
if LL_AS_PRIMARY_OUTPUT
AM_CFLAGS += -DUSE_LL_AS_PRIMARY_OUTPUT
endif
lib_LTLIBRARIES = libautohal.la
c_sources += auto_hal.c
libautohal_la_SOURCES = $(c_sources)
libautohal_la_LIBADD = $(GLIB_LIBS) -llog -lcutils -ltinyalsa
libautohal_la_LIBADD += -ltinycompress -laudioroute -ldl -lexpat -laudioutils
libautohal_la_LIBADD += -lm -lc -lresolv
libautohal_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
libautohal_la_CFLAGS += -Dstrlcat=g_strlcat
libautohal_la_CFLAGS += -DINT_MAX=0x7fffffff -Wno-error=deprecated-declarations -DPATH_MAX=1024 -DULONG_MAX=0xFFFFFFFFFFFFFFFFUL
libautohal_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
libautohal_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
libautohal_la_CFLAGS += -DNDEBUG
libautohal_la_LDFLAGS = -module -shared -avoid-version
libautohal_la_CPPFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
libautohal_la_CPPFLAGS += -DLINUX_ENABLED
if HFP
AM_CFLAGS += -DHFP_ENABLED
c_sources += hfp.c
lib_LTLIBRARIES += libhfp.la
libhfp_la_SOURCES = $(c_sources)
libhfp_la_LIBADD = $(GLIB_LIBS) -llog -lcutils -ltinyalsa
libhfp_la_LIBADD += -ltinycompress -laudioroute -ldl -lexpat -laudioutils
libhfp_la_LIBADD += -lm -lc -lresolv
libhfp_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
libhfp_la_CFLAGS += -Dstrlcat=g_strlcat
libhfp_la_CFLAGS += -DINT_MAX=0x7fffffff
libhfp_la_CFLAGS += -DULONG_MAX=\(__LONG_MAX__*2UL+1UL\)
libhfp_la_CFLAGS += -DPATH_MAX=4096
libhfp_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
libhfp_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
libhfp_la_CFLAGS += -DNDEBUG
libhfp_la_CFLAGS += -D_GNU_SOURCE
libhfp_la_LDFLAGS = -module -shared -avoid-version
endif

View File

@ -67,6 +67,10 @@
#include <log_utils.h>
#endif
#ifdef LINUX_ENABLED
#include "audio_stub.h"
#endif
#define MAX_SLEEP_RETRY 100
#define WIFI_INIT_WAIT_SLEEP 50
#define MAX_NUM_CHANNELS 8
@ -4871,10 +4875,18 @@ void audio_extn_sco_reset_configuration()
// START: HFP ======================================================================
#ifdef __LP64__
#ifdef LINUX_ENABLED
#define HFP_LIB_PATH "/usr/lib64/libhfp.so"
#else
#define HFP_LIB_PATH "/vendor/lib64/libhfp.so"
#endif
#else
#ifdef LINUX_ENABLED
#define HFP_LIB_PATH "/usr/lib/libhfp.so"
#else
#define HFP_LIB_PATH "/vendor/lib/libhfp.so"
#endif
#endif
static void *hfp_lib_handle = NULL;
@ -4965,7 +4977,6 @@ feature_disabled:
hfp_set_mic_mute = NULL;
hfp_set_mic_mute2 = NULL;
hfp_set_parameters = NULL;
ALOGW(":: %s: ---- Feature HFP is disabled ----", __func__);
return -ENOSYS;
}
@ -6066,11 +6077,19 @@ bool audio_extn_ma_supported_usb()
// END: MAXX_AUDIO =====================================================================
// START: AUTO_HAL ===================================================================
#ifdef LINUX_ENABLED
#ifdef __LP64__
#define AUTO_HAL_LIB_PATH "/usr/lib64/libautohal.so"
#else
#define AUTO_HAL_LIB_PATH "/usr/lib/libautohal.so"
#endif
#else
#ifdef __LP64__
#define AUTO_HAL_LIB_PATH "/vendor/lib64/libautohal.so"
#else
#define AUTO_HAL_LIB_PATH "/vendor/lib/libautohal.so"
#endif
#endif
static void *auto_hal_lib_handle = NULL;
@ -6147,6 +6166,11 @@ int auto_hal_feature_init(bool is_feature_enabled)
{
ALOGD("%s: Called with feature %s", __func__,
is_feature_enabled ? "Enabled" : "NOT Enabled");
#ifdef LINUX_ENABLED
is_feature_enabled = true;
#endif
if (is_feature_enabled) {
// dlopen lib
auto_hal_lib_handle = dlopen(AUTO_HAL_LIB_PATH, RTLD_NOW);
@ -6543,7 +6567,6 @@ feature_disabled:
void audio_extn_feature_init()
{
vendor_enhanced_info = audio_extn_utils_get_vendor_enhanced_info();
// register feature init functions here
// each feature needs a vendor property
// default value added is for GSI (non vendor modified images)
@ -6628,9 +6651,17 @@ void audio_extn_feature_init()
hwdep_cal_feature_init(
property_get_bool("vendor.audio.feature.hwdep_cal.enable",
false));
#ifdef LINUX_ENABLED
#ifdef HFP_ENABLED
hfp_feature_init(true);
#else
hfp_feature_init(false);
#endif
#else
hfp_feature_init(
property_get_bool("vendor.audio.feature.hfp.enable",
false));
#endif
icc_feature_init(
property_get_bool("vendor.audio.feature.icc.enable",
false));

70
hal/audio_extn/audio_stub.c Executable file
View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2021 The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef LINUX_ENABLED
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int32_t property_get_int32(const char *key, int32_t default_value) {
return 0;
}
int64_t property_get_int64(const char *key, int64_t default_value) {
return 0;
}
int audio_extn_hidl_init() {
return 0;
}
int audio_streaming_hint_start() {
return 0;
}
int audio_streaming_hint_end() {
return 0;
}
int audio_low_latency_hint_start() {
return 0;
}
int audio_low_latency_hint_end() {
return 0;
}
#endif

42
hal/audio_extn/audio_stub.h Executable file
View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2021 The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef LINUX_ENABLED
#ifndef _AUDIO_STUB_H_
#define _AUDIO_STUB_H_
#ifdef __LP64__
#define CPU_SETSIZE 1024
#else
#define CPU_SETSIZE 32
#endif
#define CPU_ZERO(cpusetp) \
memset((cpusetp), 0, sizeof(cpu_set_t))
#endif
#endif

3
hal/platform_info.c Normal file → Executable file
View File

@ -42,6 +42,9 @@
#include "audio_extn.h"
#include <platform.h>
#include <math.h>
#ifdef LINUX_ENABLED
#include <float.h>
#endif
#ifdef DYNAMIC_LOG_ENABLED
#include <log_xml_parser.h>

57
qahw_api/test/qahw_playback_test.c Normal file → Executable file
View File

@ -2117,6 +2117,7 @@ int main(int argc, char* argv[]) {
{"ec-ref", no_argument, 0, 'L'},
{"help", no_argument, 0, 'h'},
{"bt-wbs", no_argument, 0, 'z'},
{"HFP-call", no_argument, 0, 'H'},
{0, 0, 0, 0}
};
@ -2139,13 +2140,67 @@ int main(int argc, char* argv[]) {
while ((opt = getopt_long(argc,
argv,
"-f:r:c:b:d:s:v:V:l:t:a:w:k:PD:KF:Ee:A:u:m:S:C:p::x:y:qQzLh:i:h:g:O:",
"-f:r:c:b:d:s:v:V:l:t:a:w:k:PD:KF:Ee:A:u:m:S:C:p::x:y:qQzLh:i:h:g:H:O:",
long_options,
&option_index)) != -1) {
fprintf(log_file, "for argument %c, value is %s\n", opt, optarg);
switch (opt) {
case 'H':
{
int hfp_test_rc;
qahw_module_handle_t* qap_out_hal_handle = NULL;
qahw_stream_handle_t* out_handle;
const char* hfp_set_sampling_rate = "hfp_set_sampling_rate=16000";
const char* hfp_volume = "hfp_volume=15";
const char* hfp_enable = "hfp_enable=true";
const char* hfp_disable = "hfp_enable=false";
audio_config_t config;
config.sample_rate = 48000;
config.channel_mask = 0x3;
config.format = 1;
config.frame_count = 0;
config.offload_info.version = AUDIO_OFFLOAD_INFO_VERSION_CURRENT;
config.offload_info.size = sizeof(audio_offload_info_t);
wakelock_acquired = request_wake_lock(wakelock_acquired, true);
qap_out_hal_handle = load_hal(AUDIO_DEVICE_NONE);
hfp_test_rc = qahw_open_output_stream(qap_out_hal_handle,
0x999,
AUDIO_DEVICE_OUT_BUS,
AUDIO_OUTPUT_FLAG_PRIMARY,
&config,
&out_handle,
"BUS00_MEDIA");
fprintf(stderr, "hfp_test: qahw_open_output_stream result %d\n", hfp_test_rc);
hfp_test_rc = qahw_set_parameters(qap_out_hal_handle, hfp_set_sampling_rate);
fprintf(stderr, "hfp_test: hfp_set_sampling_rate result %d\n", hfp_test_rc);
hfp_test_rc = qahw_set_parameters(qap_out_hal_handle, hfp_volume);
fprintf(stderr, "hfp_test: hfp_volume result %d\n", hfp_test_rc);
hfp_test_rc = qahw_set_parameters(qap_out_hal_handle, hfp_enable);
fprintf(stderr, "hfp_test: hfp_enable result %d\n", hfp_test_rc);
sleep(10);
hfp_test_rc = qahw_set_parameters(qap_out_hal_handle, hfp_disable);
fprintf(stderr, "hfp_test: hfp_disable result %d\n", hfp_test_rc);
hfp_test_rc = qahw_close_output_stream(out_handle);
unload_hals();
wakelock_acquired = request_wake_lock(wakelock_acquired, false);
fprintf(stderr, "\nADL: BYE BYE\n");
return 0;
}
case 'f':
stream_param[i].filename = optarg;
break;