HAL: Add synth enablement control

Add synth enablement control, create hostless loopback for synth playback case

Change-Id: I0d4da24975e2fe7f28f30adba1a604c85451eeaa
This commit is contained in:
Fei Tong 2020-02-20 20:39:05 +08:00 committed by Gerrit - the friendly Code Review server
parent 3286026722
commit affdf73100
10 changed files with 525 additions and 5 deletions

68
hal/audio_extn/Android.mk Normal file → Executable file
View File

@ -672,6 +672,74 @@ LOCAL_SANITIZE := integer_overflow
endif
include $(BUILD_SHARED_LIBRARY)
#-------------------------------------------
# Build SYNTH LIB
#-------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := libsynth
LOCAL_VENDOR_MODULE := true
PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona lito bengal atoll sdm660 msm8937 msm8998 $(MSMSTEPPE) $(TRINKET),$(TARGET_BOARD_PLATFORM)),)
# B-family platform uses msm8974 code base
AUDIO_PLATFORM := msm8974
MULTIPLE_HW_VARIANTS_ENABLED := true
endif
ifeq ($(TARGET_BOARD_AUTO),true)
LOCAL_CFLAGS += -DPLATFORM_AUTO
endif
LOCAL_SRC_FILES:= \
synth.c \
device_utils.c
LOCAL_CFLAGS += \
-Wall \
-Werror \
-Wno-unused-function \
-Wno-unused-variable
LOCAL_SHARED_LIBRARIES := \
libaudioroute \
libaudioutils \
libcutils \
libdl \
libexpat \
liblog \
libtinyalsa \
libtinycompress
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/include/audio
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
LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
endif
LOCAL_HEADER_LIBRARIES += libhardware_headers
LOCAL_HEADER_LIBRARIES += libsystem_headers
ifneq ($(filter kona,$(TARGET_BOARD_PLATFORM)),)
LOCAL_SANITIZE := integer_overflow
endif
include $(BUILD_SHARED_LIBRARY)
#-------------------------------------------
# Build HDMI PASSTHROUGH
#-------------------------------------------

88
hal/audio_extn/audio_extn.c Normal file → Executable file
View File

@ -6351,6 +6351,90 @@ snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(int car_aud
}
// END: AUTO_HAL ===================================================================
// START: Synth ======================================================================
#ifdef __LP64__
#define SYNTH_LIB_PATH "/vendor/lib64/libsynth.so"
#else
#define SYNTH_LIB_PATH "/vendor/lib/libsynth.so"
#endif
static void *synth_lib_handle = NULL;
typedef void (*synth_init_t)(synth_init_config_t);
static synth_init_t synth_init;
typedef bool (*synth_is_active_t)(struct audio_device *adev);
static synth_is_active_t synth_is_active;
typedef void (*synth_set_parameters_t)(struct audio_device *adev,
struct str_parms *parms);
static synth_set_parameters_t synth_set_parameters;
int synth_feature_init(bool is_feature_enabled)
{
ALOGD("%s: Called with feature %s", __func__,
is_feature_enabled ? "Enabled" : "NOT Enabled");
if (is_feature_enabled) {
// dlopen lib
synth_lib_handle = dlopen(SYNTH_LIB_PATH, RTLD_NOW);
if (!synth_lib_handle) {
ALOGE("%s: dlopen failed", __func__);
goto feature_disabled;
}
if (!(synth_init = (synth_init_t)dlsym(
synth_lib_handle, "synth_init")) ||
!(synth_is_active =
(synth_is_active_t)dlsym(
synth_lib_handle, "synth_is_active")) ||
!(synth_set_parameters =
(synth_set_parameters_t)dlsym(
synth_lib_handle, "synth_set_parameters"))) {
ALOGE("%s: dlsym failed", __func__);
goto feature_disabled;
}
synth_init_config_t init_config;
init_config.fp_platform_get_pcm_device_id = platform_get_pcm_device_id;
init_config.fp_get_usecase_from_list = get_usecase_from_list;
init_config.fp_select_devices = select_devices;
init_config.fp_disable_audio_route = disable_audio_route;
init_config.fp_disable_snd_device = disable_snd_device;
synth_init(init_config);
ALOGD("%s:: ---- Feature Synth is Enabled ----", __func__);
return 0;
}
feature_disabled:
if (synth_lib_handle) {
dlclose(synth_lib_handle);
synth_lib_handle = NULL;
}
synth_init = NULL;
synth_is_active = NULL;
synth_set_parameters = NULL;
ALOGW(":: %s: ---- Feature Synth is disabled ----", __func__);
return -ENOSYS;
}
bool audio_extn_synth_is_active(struct audio_device *adev)
{
return ((synth_is_active) ?
synth_is_active(adev): false);
}
void audio_extn_synth_set_parameters(struct audio_device *adev,
struct str_parms *parms)
{
((synth_set_parameters) ?
synth_set_parameters(adev, parms): NULL);
}
// END: Synth ========================================================================
void audio_extn_feature_init()
{
vendor_enhanced_info = audio_extn_utils_get_vendor_enhanced_info();
@ -6472,6 +6556,9 @@ void audio_extn_feature_init()
auto_hal_feature_init(
property_get_bool("vendor.audio.feature.auto_hal.enable",
false));
synth_feature_init(
property_get_bool("vendor.audio.feature.synth.enable",
false));
}
void audio_extn_set_parameters(struct audio_device *adev,
@ -6505,6 +6592,7 @@ void audio_extn_set_parameters(struct audio_device *adev,
audio_extn_ffv_set_parameters(adev, parms);
audio_extn_ext_hw_plugin_set_parameters(adev->ext_hw_plugin, parms);
audio_extn_icc_set_parameters(adev, parms);
audio_extn_synth_set_parameters(adev, parms);
}
void audio_extn_get_parameters(const struct audio_device *adev,

14
hal/audio_extn/audio_extn.h Normal file → Executable file
View File

@ -1415,6 +1415,20 @@ typedef struct auto_hal_init_config {
} auto_hal_init_config_t;
// END: AUTO_HAL FEATURE ==================================================
// START: SYNTH_HAL FEATURE ==================================================
bool audio_extn_synth_is_active(struct audio_device *adev);
void audio_extn_synth_set_parameters(struct audio_device *adev,
struct str_parms *parms);
typedef struct synth_init_config {
fp_get_usecase_from_list_t fp_get_usecase_from_list;
fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
fp_disable_audio_route_t fp_disable_audio_route;
fp_disable_snd_device_t fp_disable_snd_device;
fp_select_devices_t fp_select_devices;
} synth_init_config_t;
// END: SYNTH_HAL FEATURE ==================================================
bool audio_extn_edid_is_supported_sr(edid_audio_info* info, int sr);
bool audio_extn_edid_is_supported_bps(edid_audio_info* info, int bps);
int audio_extn_edid_get_highest_supported_sr(edid_audio_info* info);

6
hal/audio_extn/auto_hal.c Normal file → Executable file
View File

@ -775,6 +775,9 @@ snd_device_t auto_hal_get_input_snd_device(struct audio_device *adev,
case USECASE_ICC_CALL:
snd_device = SND_DEVICE_IN_ICC;
break;
case USECASE_AUDIO_PLAYBACK_SYNTHESIZER:
snd_device = SND_DEVICE_IN_SYNTH_MIC;
break;
default:
ALOGE("%s: Usecase (%d) not supported", __func__, uc_id);
return -EINVAL;
@ -870,6 +873,9 @@ snd_device_t auto_hal_get_output_snd_device(struct audio_device *adev,
case USECASE_ICC_CALL:
snd_device = SND_DEVICE_OUT_ICC;
break;
case USECASE_AUDIO_PLAYBACK_SYNTHESIZER:
snd_device = SND_DEVICE_OUT_SYNTH_SPKR;
break;
default:
ALOGE("%s: Usecase (%d) not supported", __func__, uc_id);
return -EINVAL;

249
hal/audio_extn/synth.c Executable file
View File

@ -0,0 +1,249 @@
/* synth.c
Copyright (c) 2012-2015,2016,2020 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.*/
#define LOG_TAG "audio_hw_synth"
/*#define LOG_NDEBUG 0*/
#define LOG_NDDEBUG 0
#include <errno.h>
#include <math.h>
#include <log/log.h>
#include <unistd.h>
#include "audio_hw.h"
#include "platform.h"
#include "platform_api.h"
#include <stdlib.h>
#include <cutils/str_parms.h>
#include <audio_extn.h>
#ifdef DYNAMIC_LOG_ENABLED
#include <log_xml_parser.h>
#define LOG_MASK HAL_MOD_FILE_FM
#include <log_utils.h>
#endif
#define AUDIO_PARAMETER_KEY_SYNTH_ENABLE "synth_enable"
static int32_t synth_start(struct audio_device *adev);
static int32_t synth_stop(struct audio_device *adev);
static struct pcm_config pcm_config_synth = {
.channels = 4,
.rate = 16000,
.period_size = 240,
.period_count = 2,
.format = PCM_FORMAT_S16_LE,
.start_threshold = 0,
.stop_threshold = INT_MAX,
.avail_min = 0,
};
struct synth_module {
struct pcm *pcm_rx;
struct pcm *pcm_tx;
bool is_synth_running;
audio_usecase_t ucid;
};
static struct synth_module synthmod = {
.pcm_rx = NULL,
.pcm_tx = NULL,
.is_synth_running = 0,
.ucid = USECASE_AUDIO_PLAYBACK_SYNTHESIZER,
};
static fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
static fp_get_usecase_from_list_t fp_get_usecase_from_list;
static fp_select_devices_t fp_select_devices;
static fp_platform_get_pcm_device_id_t fp_platform_get_pcm_device_id;
static fp_platform_send_audio_calibration_t fp_platform_send_audio_calibration;
static fp_disable_audio_route_t fp_disable_audio_route;
static fp_disable_snd_device_t fp_disable_snd_device;
int32_t synth_start(struct audio_device *adev)
{
int32_t ret = 0;
int pcm_dev_rx = -1, pcm_dev_tx = -1;
char mixer_path[MIXER_PATH_MAX_LENGTH];
struct audio_usecase *uc_info = NULL;
ALOGD("%s: Enable Synth", __func__);
// select devices
uc_info = (struct audio_usecase *)calloc(1, sizeof(*uc_info));
if (!uc_info) {
ALOGE("%s: allocate memory failed", __func__);
return -ENOMEM;
}
uc_info->id = synthmod.ucid;
uc_info->type = SYNTH_LOOPBACK;
uc_info->stream.out = adev->primary_output;
list_init(&uc_info->device_list);
assign_devices(&uc_info->device_list, &adev->primary_output->device_list);
uc_info->in_snd_device = SND_DEVICE_NONE;
uc_info->out_snd_device = SND_DEVICE_OUT_SPEAKER;
list_add_tail(&adev->usecase_list, &uc_info->list);
fp_select_devices(adev, synthmod.ucid);
// open pcm rx/tx
pcm_dev_tx = fp_platform_get_pcm_device_id(USECASE_AUDIO_PLAYBACK_SYNTHESIZER, PCM_CAPTURE);
pcm_dev_rx = fp_platform_get_pcm_device_id(USECASE_AUDIO_PLAYBACK_SYNTHESIZER, PCM_PLAYBACK);
if (pcm_dev_tx < 0 || pcm_dev_rx < 0 ) {
ALOGE("%s: Invalid PCM devices (rx: %d tx: %d) for the usecase(%d)",
__func__, pcm_dev_rx, pcm_dev_tx, uc_info->id);
ret = -EIO;
goto exit;
}
//open pcm rx/tx
synthmod.pcm_tx = pcm_open(adev->snd_card,
pcm_dev_tx,
PCM_IN, &pcm_config_synth);
if (synthmod.pcm_tx &&
!pcm_is_ready(synthmod.pcm_tx)) {
ALOGE("%s: pcm_tx %s", __func__,
pcm_get_error(synthmod.pcm_tx));
ret = -EIO;
goto exit;
}
synthmod.pcm_rx = pcm_open(adev->snd_card,
pcm_dev_rx,
PCM_OUT, &pcm_config_synth);
if (synthmod.pcm_rx &&
!pcm_is_ready(synthmod.pcm_rx)) {
ALOGE("%s: pcm_rx %s", __func__,
pcm_get_error(synthmod.pcm_rx));
ret = -EIO;
goto exit;
}
if (pcm_start(synthmod.pcm_tx) < 0) {
ALOGE("%s: pcm start for pcm tx failed", __func__);
ret = -EIO;
goto exit;
}
if (pcm_start(synthmod.pcm_rx) < 0) {
ALOGE("%s: pcm start for pcm rx failed", __func__);
ret = -EIO;
goto exit;
}
synthmod.is_synth_running = true;
return ret;
exit:
synth_stop(adev);
ALOGE("%s: Problem in Synth start: status(%d)", __func__, ret);
return ret;
}
int32_t synth_stop(struct audio_device *adev)
{
int32_t ret = 0;
struct audio_usecase *uc_info;
ALOGD("Enter %s:", __func__);
synthmod.is_synth_running = false;
if (synthmod.pcm_tx) {
pcm_close(synthmod.pcm_tx);
synthmod.pcm_tx = NULL;
}
if (synthmod.pcm_rx) {
pcm_close(synthmod.pcm_rx);
synthmod.pcm_rx = NULL;
}
uc_info = fp_get_usecase_from_list(adev, synthmod.ucid);
if (uc_info == NULL) {
ALOGE("%s: Could not find the usecase (%d) in the list",
__func__, synthmod.ucid);
return -EINVAL;
}
/* 3. Get and set stream specific mixer controls */
fp_disable_audio_route(adev, uc_info);
/* 4. Disable the rx and tx devices */
fp_disable_snd_device(adev, uc_info->out_snd_device);
fp_disable_snd_device(adev, uc_info->in_snd_device);
list_remove(&uc_info->list);
free(uc_info);
ALOGD("%s: exit: status(%d)", __func__, ret);
return ret;
}
bool synth_is_active(struct audio_device *adev) {
struct audio_usecase *synth_usecase = NULL;
synth_usecase = fp_get_usecase_from_list(adev, synthmod.ucid);
if (synth_usecase != NULL)
return true;
else
return false;
}
void synth_set_parameters(struct audio_device *adev,
struct str_parms *parms)
{
int ret, val;
char value[32]={0};
ALOGD("%s: enter", __func__);
ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SYNTH_ENABLE, value, sizeof(value));
if (ret >= 0) {
if (!strncmp(value,"true",sizeof(value)) && !synthmod.is_synth_running) {
synth_start(adev);
}
else if (!strncmp(value,"false",sizeof(value)) && synthmod.is_synth_running) {
synth_stop(adev);
} else {
ALOGE("Not support key value");
}
}
ALOGD("%s: exit", __func__);
}
void synth_init(synth_init_config_t init_config)
{
fp_platform_get_pcm_device_id = init_config.fp_platform_get_pcm_device_id;
fp_get_usecase_from_list = init_config.fp_get_usecase_from_list;
fp_select_devices = init_config.fp_select_devices;
fp_disable_audio_route = init_config.fp_disable_audio_route;
fp_disable_snd_device = init_config.fp_disable_snd_device;
}

78
hal/audio_extn/utils.c Normal file → Executable file
View File

@ -998,6 +998,22 @@ void audio_extn_utils_update_stream_app_type_cfg_for_usecase(
ALOGV("%s Selected apptype: playback %d capture %d",
__func__, usecase->out_app_type_cfg.app_type, usecase->in_app_type_cfg.app_type);
break;
case SYNTH_LOOPBACK:
/* update out_app_type_cfg */
usecase->out_app_type_cfg.sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
usecase->out_app_type_cfg.bit_width =
platform_get_snd_device_bit_width(usecase->out_snd_device);
usecase->out_app_type_cfg.app_type =
platform_get_default_app_type_v2(adev->platform, PCM_PLAYBACK);
/* update in_app_type_cfg */
usecase->in_app_type_cfg.sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
usecase->in_app_type_cfg.bit_width =
platform_get_snd_device_bit_width(usecase->in_snd_device);
usecase->in_app_type_cfg.app_type =
platform_get_default_app_type_v2(adev->platform, PCM_CAPTURE);
ALOGV("%s Selected apptype: playback %d capture %d",
__func__, usecase->out_app_type_cfg.app_type, usecase->in_app_type_cfg.app_type);
break;
default:
ALOGE("%s: app type cfg not supported for usecase type (%d)",
__func__, usecase->type);
@ -1217,6 +1233,64 @@ exit_send_app_type_cfg:
return rc;
}
static int audio_extn_utils_send_app_type_cfg_synth(struct audio_device *adev,
struct audio_usecase *usecase)
{
int pcm_device_id, acdb_dev_id = 0, snd_device = usecase->out_snd_device;
int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
int app_type = 0, rc = 0;
bool is_bus_dev_usecase = false;
ALOGV("%s", __func__);
if (usecase->type != SYNTH_LOOPBACK) {
ALOGV("%s: not a SYNTH path, no need to cfg app type", __func__);
rc = 0;
goto exit_send_app_type_cfg;
}
if (usecase->id != USECASE_AUDIO_PLAYBACK_SYNTHESIZER) {
ALOGV("%s: a usecase where app type cfg is not required", __func__);
rc = 0;
goto exit_send_app_type_cfg;
}
if (compare_device_type(&usecase->device_list, AUDIO_DEVICE_OUT_BUS)) {
is_bus_dev_usecase = true;
}
snd_device = usecase->out_snd_device;
pcm_device_id = platform_get_pcm_device_id(usecase->id, PCM_PLAYBACK);
acdb_dev_id = platform_get_snd_device_acdb_id(snd_device);
if (acdb_dev_id < 0) {
ALOGE("%s: Couldn't get the acdb dev id", __func__);
rc = -EINVAL;
goto exit_send_app_type_cfg;
}
if (usecase->type == SYNTH_LOOPBACK) {
/* config SYNTH session: playback path */
if (is_bus_dev_usecase) {
app_type = usecase->out_app_type_cfg.app_type;
sample_rate= usecase->out_app_type_cfg.sample_rate;
} else {
snd_device = SND_DEVICE_NONE; // use legacy behavior
app_type = platform_get_default_app_type_v2(adev->platform, PCM_PLAYBACK);
sample_rate= CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
}
rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
acdb_dev_id, sample_rate,
PCM_PLAYBACK,
snd_device);
if (rc < 0)
goto exit_send_app_type_cfg;
}
rc = 0;
exit_send_app_type_cfg:
return rc;
}
int audio_extn_utils_get_app_sample_rate_for_device(
struct audio_device *adev,
struct audio_usecase *usecase, int snd_device)
@ -1564,6 +1638,8 @@ int audio_extn_utils_send_app_type_cfg(struct audio_device *adev,
return audio_extn_utils_send_app_type_cfg_hfp(adev, usecase);
} else if (usecase->type == ICC_CALL) {
return audio_extn_utils_send_app_type_cfg_icc(adev, usecase);
} else if (usecase->type == SYNTH_LOOPBACK) {
return audio_extn_utils_send_app_type_cfg_synth(adev, usecase);
}
switch (usecase->type) {
@ -1966,7 +2042,7 @@ void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
usecase->stream.in->app_type_cfg.app_type);
} else if ((type == PCM_HFP_CALL) || (type == PCM_CAPTURE) ||
(type == TRANSCODE_LOOPBACK_RX && usecase->stream.inout != NULL) ||
(type == ICC_CALL)) {
(type == ICC_CALL) || (type == SYNTH_LOOPBACK)) {
platform_send_audio_calibration(adev->platform, usecase,
platform_get_default_app_type_v2(adev->platform, usecase->type));
} else {

4
hal/audio_hw.c Normal file → Executable file
View File

@ -426,6 +426,7 @@ const char * const use_case_table[AUDIO_USECASE_MAX] = {
[USECASE_AUDIO_RECORD_BUS] = "audio-record",
[USECASE_AUDIO_RECORD_BUS_FRONT_PASSENGER] = "front-passenger-record",
[USECASE_AUDIO_RECORD_BUS_REAR_SEAT] = "rear-seat-record",
[USECASE_AUDIO_PLAYBACK_SYNTHESIZER] = "synth-loopback",
};
static const audio_usecase_t offload_usecases[] = {
@ -2723,7 +2724,8 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
if ((usecase->type == VOICE_CALL) ||
(usecase->type == VOIP_CALL) ||
(usecase->type == PCM_HFP_CALL)||
(usecase->type == ICC_CALL)) {
(usecase->type == ICC_CALL) ||
(usecase->type == SYNTH_LOOPBACK)) {
if(usecase->stream.out == NULL) {
ALOGE("%s: stream.out is NULL", __func__);
return -EINVAL;

3
hal/audio_hw.h Normal file → Executable file
View File

@ -248,6 +248,8 @@ enum {
USECASE_AUDIO_RECORD_BUS_FRONT_PASSENGER,
USECASE_AUDIO_RECORD_BUS_REAR_SEAT,
USECASE_AUDIO_PLAYBACK_SYNTHESIZER,
/*Audio FM Tuner usecase*/
USECASE_AUDIO_FM_TUNER_EXT,
/*voip usecase with low latency path*/
@ -558,6 +560,7 @@ typedef enum {
TRANSCODE_LOOPBACK_TX,
PCM_PASSTHROUGH,
ICC_CALL,
SYNTH_LOOPBACK,
USECASE_TYPE_MAX
} usecase_type_t;

18
hal/msm8974/platform.c Normal file → Executable file
View File

@ -528,6 +528,7 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
[USECASE_AUDIO_RECORD_BUS] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
[USECASE_AUDIO_RECORD_BUS_FRONT_PASSENGER] = {FRONT_PASSENGER_PCM_DEVICE, FRONT_PASSENGER_PCM_DEVICE},
[USECASE_AUDIO_RECORD_BUS_REAR_SEAT] = {REAR_SEAT_PCM_DEVICE, REAR_SEAT_PCM_DEVICE},
[USECASE_AUDIO_PLAYBACK_SYNTHESIZER] = {-1, -1},
};
/* Array to store sound devices */
@ -640,6 +641,7 @@ static const char * const device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_OUT_CALL_PROXY] = "call-proxy",
[SND_DEVICE_OUT_HAPTICS] = "haptics",
[SND_DEVICE_OUT_ICC] = "bus-speaker",
[SND_DEVICE_OUT_SYNTH_SPKR] = "bus-speaker",
/* Capture sound devices */
[SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@ -792,6 +794,7 @@ static const char * const device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK] = "handset-8mic-and-ec-ref-loopback",
[SND_DEVICE_IN_CALL_PROXY] = "call-proxy-in",
[SND_DEVICE_IN_ICC] = "speaker-mic",
[SND_DEVICE_IN_SYNTH_MIC] = "speaker-mic",
};
// Platform specific backend bit width table
@ -938,6 +941,7 @@ static int acdb_device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_OUT_CALL_PROXY] = 32,
[SND_DEVICE_OUT_HAPTICS] = 200,
[SND_DEVICE_OUT_ICC] = 16,
[SND_DEVICE_OUT_SYNTH_SPKR] = 134,
[SND_DEVICE_IN_HANDSET_MIC] = 4,
[SND_DEVICE_IN_HANDSET_MIC_SB] = 163,
[SND_DEVICE_IN_HANDSET_MIC_NN] = 183,
@ -1080,6 +1084,7 @@ static int acdb_device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_IN_BUS_RSE] = 11,
[SND_DEVICE_IN_CALL_PROXY] = 33,
[SND_DEVICE_IN_ICC] = 46,
[SND_DEVICE_IN_SYNTH_MIC] = 11,
};
struct name_to_index {
@ -1342,6 +1347,8 @@ static struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = {
/* ICC */
{TO_NAME_INDEX(SND_DEVICE_IN_ICC)},
{TO_NAME_INDEX(SND_DEVICE_OUT_ICC)},
{TO_NAME_INDEX(SND_DEVICE_OUT_SYNTH_SPKR)},
{TO_NAME_INDEX(SND_DEVICE_IN_SYNTH_MIC)},
};
static char * backend_tag_table[SND_DEVICE_MAX] = {0};
@ -1417,6 +1424,7 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
{TO_NAME_INDEX(USECASE_AUDIO_RECORD_BUS)},
{TO_NAME_INDEX(USECASE_AUDIO_RECORD_BUS_FRONT_PASSENGER)},
{TO_NAME_INDEX(USECASE_AUDIO_RECORD_BUS_REAR_SEAT)},
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_SYNTHESIZER)},
};
static const struct name_to_index usecase_type_index[USECASE_TYPE_MAX] = {
@ -2637,6 +2645,8 @@ static void set_platform_defaults(struct platform_data * my_data)
hw_interface_table[SND_DEVICE_IN_CALL_PROXY] = strdup("CALL_PROXY_TX");
hw_interface_table[SND_DEVICE_IN_ICC] = strdup("TERT_TDM_TX_0");
hw_interface_table[SND_DEVICE_OUT_ICC] = strdup("TERT_TDM_RX_0");
hw_interface_table[SND_DEVICE_OUT_SYNTH_SPKR] = strdup("TERT_TDM_RX_0");
hw_interface_table[SND_DEVICE_IN_SYNTH_MIC] = strdup("TERT_TDM_TX_0");
my_data->max_mic_count = PLATFORM_DEFAULT_MIC_COUNT;
/*remove ALAC & APE from DSP decoder list based on software decoder availability*/
@ -5426,7 +5436,7 @@ int platform_send_audio_calibration(void *platform, struct audio_usecase *usecas
else if ((usecase->type == PCM_CAPTURE) && is_incall_rec_usecase)
snd_device = voice_get_incall_rec_snd_device(usecase->in_snd_device);
else if ((usecase->type == PCM_HFP_CALL) || (usecase->type == PCM_CAPTURE)||
(usecase->type == ICC_CALL))
(usecase->type == ICC_CALL) || (usecase->type == SYNTH_LOOPBACK))
snd_device = usecase->in_snd_device;
else if (usecase->type == TRANSCODE_LOOPBACK_RX)
snd_device = usecase->out_snd_device;
@ -5450,7 +5460,8 @@ int platform_send_audio_calibration(void *platform, struct audio_usecase *usecas
new_snd_device[0] = snd_device;
}
}
if (((usecase->type == PCM_HFP_CALL) || (usecase->type == ICC_CALL)) &&
if (((usecase->type == PCM_HFP_CALL) || (usecase->type == ICC_CALL) ||
(usecase->type == SYNTH_LOOPBACK)) &&
is_bus_dev_usecase) {
num_devices = 2;
new_snd_device[0] = usecase->in_snd_device;
@ -5475,7 +5486,8 @@ int platform_send_audio_calibration(void *platform, struct audio_usecase *usecas
if ((usecase->type == PCM_CAPTURE) && (app_type == DEFAULT_APP_TYPE_RX_PATH)) {
ALOGD("Resetting app type for Tx path to default");
app_type = DEFAULT_APP_TYPE_TX_PATH;
} else if (((usecase->type == PCM_HFP_CALL) || (usecase->type == ICC_CALL)) &&
} else if (((usecase->type == PCM_HFP_CALL) || (usecase->type == ICC_CALL) ||
(usecase->type == SYNTH_LOOPBACK)) &&
is_bus_dev_usecase) {
if (new_snd_device[i] >= SND_DEVICE_OUT_BEGIN &&
new_snd_device[i] < SND_DEVICE_OUT_END) {

2
hal/msm8974/platform.h Normal file → Executable file
View File

@ -206,6 +206,7 @@ enum {
SND_DEVICE_OUT_CALL_PROXY,
SND_DEVICE_OUT_HAPTICS,
SND_DEVICE_OUT_ICC,
SND_DEVICE_OUT_SYNTH_SPKR,
SND_DEVICE_OUT_END,
/*
@ -362,6 +363,7 @@ enum {
SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK,
SND_DEVICE_IN_CALL_PROXY,
SND_DEVICE_IN_ICC,
SND_DEVICE_IN_SYNTH_MIC,
SND_DEVICE_IN_END,
SND_DEVICE_MAX = SND_DEVICE_IN_END,