Merge "hal: Fix ANR if In-Call recording is started at end of voice call"
diff --git a/Android.mk b/Android.mk
index 36a85f9..6e129a1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,4 +1,4 @@
-ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916 msm8994 msm8992 msm8909 thulium,$(TARGET_BOARD_PLATFORM)),)
+ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916 msm8994 msm8992 msm8909 msm8996 msm8952,$(TARGET_BOARD_PLATFORM)),)
MY_LOCAL_PATH := $(call my-dir)
diff --git a/hal/Android.mk b/hal/Android.mk
index c67f390..9fa30c6 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -8,7 +8,7 @@
AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
-ifneq ($(filter msm8974 msm8226 msm8610 apq8084 msm8994 msm8992 thulium,$(TARGET_BOARD_PLATFORM)),)
+ifneq ($(filter msm8974 msm8226 msm8610 apq8084 msm8994 msm8992 msm8996,$(TARGET_BOARD_PLATFORM)),)
# B-family platform uses msm8974 code base
AUDIO_PLATFORM = msm8974
MULTIPLE_HW_VARIANTS_ENABLED := true
@@ -27,12 +27,12 @@
ifneq ($(filter msm8992,$(TARGET_BOARD_PLATFORM)),)
LOCAL_CFLAGS := -DPLATFORM_MSM8994
endif
-ifneq ($(filter thulium,$(TARGET_BOARD_PLATFORM)),)
- LOCAL_CFLAGS := -DPLATFORM_THULIUM
+ifneq ($(filter msm8996,$(TARGET_BOARD_PLATFORM)),)
+ LOCAL_CFLAGS := -DPLATFORM_MSM8996
endif
endif
-ifneq ($(filter msm8916 msm8909,$(TARGET_BOARD_PLATFORM)),)
+ifneq ($(filter msm8916 msm8909 msm8952,$(TARGET_BOARD_PLATFORM)),)
AUDIO_PLATFORM = msm8916
MULTIPLE_HW_VARIANTS_ENABLED := true
LOCAL_CFLAGS := -DPLATFORM_MSM8916
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index ff485e5..de51542 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -332,7 +332,7 @@
int channel_count)
{
struct mixer_ctl *ctl;
- const char *mixer_ctl_name = "Playback Channel Map";
+ const char *mixer_ctl_name = "Playback Device Channel Map";
int set_values[8] = {0};
int ret;
ALOGV("%s channel_count:%d",__func__, channel_count);
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c2d3400..33e48c9 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -660,6 +660,7 @@
if (usecase->type != PCM_PLAYBACK &&
usecase != uc_info &&
usecase->in_snd_device != snd_device &&
+ (usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) &&
(usecase->id != USECASE_AUDIO_SPKR_CALIB_TX)) {
ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..",
__func__, use_case_table[usecase->id],
diff --git a/hal/msm8916/hw_info.c b/hal/msm8916/hw_info.c
index 689e834..5fb5606 100644
--- a/hal/msm8916/hw_info.c
+++ b/hal/msm8916/hw_info.c
@@ -216,8 +216,26 @@
hw_info->snd_devices = NULL;
hw_info->num_snd_devices = 0;
strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn));
+ } else if (!strcmp(snd_card_name, "msm8952-snd-card")) {
+ strlcpy(hw_info->type, "", sizeof(hw_info->type));
+ strlcpy(hw_info->name, "msm8952", sizeof(hw_info->name));
+ hw_info->snd_devices = NULL;
+ hw_info->num_snd_devices = 0;
+ strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn));
+ } else if (!strcmp(snd_card_name, "msm8952-snd-card-mtp")) {
+ strlcpy(hw_info->type, "", sizeof(hw_info->type));
+ strlcpy(hw_info->name, "msm8952", sizeof(hw_info->name));
+ hw_info->snd_devices = NULL;
+ hw_info->num_snd_devices = 0;
+ strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn));
+ } else if (!strcmp(snd_card_name, "msm8952-tomtom-snd-card")) {
+ strlcpy(hw_info->type, "", sizeof(hw_info->type));
+ strlcpy(hw_info->name, "msm8952", sizeof(hw_info->name));
+ hw_info->snd_devices = NULL;
+ hw_info->num_snd_devices = 0;
+ strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn));
} else {
- ALOGW("%s: Not an 8x16/8939/8909 device", __func__);
+ ALOGW("%s: Not an 8x16/8939/8909/8952 device", __func__);
}
}
@@ -232,7 +250,7 @@
}
if (strstr(snd_card_name, "msm8x16") || strstr(snd_card_name, "msm8939") ||
- strstr(snd_card_name, "msm8909")) {
+ strstr(snd_card_name, "msm8909") || strstr(snd_card_name, "msm8952")) {
ALOGV("8x16 - variant soundcard");
update_hardware_info_8x16(hw_info, snd_card_name);
} else {
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
old mode 100644
new mode 100755
index deec058..cfca1d5
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -36,6 +36,7 @@
#include "edid.h"
#include "sound/compress_params.h"
#include "sound/msmcal-hwdep.h"
+#include <dirent.h>
#define SOUND_TRIGGER_DEVICE_HANDSET_MONO_LOW_POWER_ACDB_ID (100)
#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
@@ -187,6 +188,7 @@
bool slowtalk;
bool hd_voice;
bool ec_ref_enabled;
+ bool is_wsa_speaker;
/* Audio calibration related functions */
void *acdb_handle;
int voice_feature_set;
@@ -281,6 +283,7 @@
[SND_DEVICE_OUT_SPEAKER] = "speaker",
[SND_DEVICE_OUT_SPEAKER_EXTERNAL_1] = "speaker-ext-1",
[SND_DEVICE_OUT_SPEAKER_EXTERNAL_2] = "speaker-ext-2",
+ [SND_DEVICE_OUT_SPEAKER_WSA] = "wsa-speaker",
[SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
[SND_DEVICE_OUT_HEADPHONES] = "headphones",
[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
@@ -288,6 +291,7 @@
[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2] = "speaker-and-headphones-ext-2",
[SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset",
[SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
+ [SND_DEVICE_OUT_VOICE_SPEAKER_WSA] = "wsa-voice-speaker",
[SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
[SND_DEVICE_OUT_HDMI] = "hdmi",
[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi",
@@ -383,6 +387,7 @@
[SND_DEVICE_OUT_SPEAKER] = 14,
[SND_DEVICE_OUT_SPEAKER_EXTERNAL_1] = 14,
[SND_DEVICE_OUT_SPEAKER_EXTERNAL_2] = 14,
+ [SND_DEVICE_OUT_SPEAKER_WSA] = 135,
[SND_DEVICE_OUT_SPEAKER_REVERSE] = 14,
[SND_DEVICE_OUT_HEADPHONES] = 10,
[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
@@ -390,6 +395,7 @@
[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2] = 10,
[SND_DEVICE_OUT_VOICE_HANDSET] = 7,
[SND_DEVICE_OUT_VOICE_SPEAKER] = 14,
+ [SND_DEVICE_OUT_VOICE_SPEAKER_WSA] = 135,
[SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
[SND_DEVICE_OUT_HDMI] = 18,
[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14,
@@ -487,6 +493,7 @@
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)},
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_EXTERNAL_1)},
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_EXTERNAL_2)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_WSA)},
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)},
{TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)},
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)},
@@ -494,6 +501,7 @@
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2)},
{TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)},
{TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_WSA)},
{TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)},
{TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)},
{TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)},
@@ -789,6 +797,21 @@
msm_device_to_be_id = msm_device_to_be_id_internal_codec;
msm_be_id_array_len =
sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_internal_codec[0]);
+ } else if (!strncmp(snd_card_name, "msm8952-snd-card-mtp",
+ sizeof("msm8952-snd-card-mtpmsm8952-snd-card-mtp"))) {
+ strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP,
+ sizeof(MIXER_XML_PATH_MTP));
+ msm_device_to_be_id = msm_device_to_be_id_internal_codec;
+ msm_be_id_array_len =
+ sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]);
+ } else if (!strncmp(snd_card_name, "msm8952-tomtom-snd-card",
+ sizeof("msm8952-tomtom-snd-card"))) {
+ strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9330,
+ sizeof(MIXER_XML_PATH_WCD9330));
+ msm_device_to_be_id = msm_device_to_be_id_external_codec;
+ msm_be_id_array_len =
+ sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]);
+
} else {
strlcpy(mixer_xml_path, MIXER_XML_PATH,
sizeof(MIXER_XML_PATH));
@@ -1196,6 +1219,7 @@
my_data->slowtalk = false;
my_data->hd_voice = false;
my_data->edid_info = NULL;
+ my_data->is_wsa_speaker = false;
property_get("ro.qc.sdk.audio.fluencetype", my_data->fluence_cap, "");
if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) {
@@ -1235,6 +1259,7 @@
property_get("persist.audio.FFSP.enable", ffspEnable, "");
if (!strncmp("true", ffspEnable, sizeof("true"))) {
acdb_device_table[SND_DEVICE_OUT_SPEAKER] = 131;
+ acdb_device_table[SND_DEVICE_OUT_SPEAKER_WSA] = 131;
acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE] = 131;
acdb_device_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 131;
acdb_device_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 131;
@@ -1309,6 +1334,25 @@
}
audio_extn_pm_vote();
+ // Check if WSA speaker is supported in codec
+ char CodecPeek[1024] = "/sys/kernel/debug/asoc/";
+ DIR *dir;
+ struct dirent *dirent;
+ char file_name[10] = "wsa";
+ strcat(CodecPeek, snd_card_name);
+
+ dir = opendir(CodecPeek);
+ if (dir != NULL) {
+ while (NULL != (dirent = readdir(dir))) {
+ if (strstr (dirent->d_name,file_name))
+ {
+ my_data->is_wsa_speaker = true;
+ break;
+ }
+ }
+ closedir(dir);
+ }
+
acdb_init_fail:
set_platform_defaults();
@@ -1966,7 +2010,10 @@
else
snd_device = SND_DEVICE_OUT_BT_SCO;
} else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
- snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
+ if (my_data->is_wsa_speaker)
+ snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_WSA;
+ else
+ snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
} else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
snd_device = SND_DEVICE_OUT_USB_HEADSET;
@@ -2019,7 +2066,12 @@
if (adev->speaker_lr_swap)
snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
else
- snd_device = SND_DEVICE_OUT_SPEAKER;
+ {
+ if (my_data->is_wsa_speaker)
+ snd_device = SND_DEVICE_OUT_SPEAKER_WSA;
+ else
+ snd_device = SND_DEVICE_OUT_SPEAKER;
+ }
}
} else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
if (adev->bt_wb_speech_enabled)
diff --git a/hal/msm8916/platform.h b/hal/msm8916/platform.h
index 8b67714..c37fab7 100644
--- a/hal/msm8916/platform.h
+++ b/hal/msm8916/platform.h
@@ -58,12 +58,14 @@
SND_DEVICE_OUT_SPEAKER_EXTERNAL_1,
SND_DEVICE_OUT_SPEAKER_EXTERNAL_2,
SND_DEVICE_OUT_SPEAKER_REVERSE,
+ SND_DEVICE_OUT_SPEAKER_WSA,
SND_DEVICE_OUT_HEADPHONES,
SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1,
SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2,
SND_DEVICE_OUT_VOICE_HANDSET,
SND_DEVICE_OUT_VOICE_SPEAKER,
+ SND_DEVICE_OUT_VOICE_SPEAKER_WSA,
SND_DEVICE_OUT_VOICE_HEADPHONES,
SND_DEVICE_OUT_HDMI,
SND_DEVICE_OUT_SPEAKER_AND_HDMI,
@@ -219,17 +221,6 @@
#define PLAYBACK_OFFLOAD_DEVICE 9
#ifdef MULTIPLE_OFFLOAD_ENABLED
-#ifdef PLATFORM_APQ8084
-#define PLAYBACK_OFFLOAD_DEVICE2 17
-#define PLAYBACK_OFFLOAD_DEVICE3 18
-#define PLAYBACK_OFFLOAD_DEVICE4 34
-#define PLAYBACK_OFFLOAD_DEVICE5 35
-#define PLAYBACK_OFFLOAD_DEVICE6 36
-#define PLAYBACK_OFFLOAD_DEVICE7 37
-#define PLAYBACK_OFFLOAD_DEVICE8 38
-#define PLAYBACK_OFFLOAD_DEVICE9 39
-#endif
-#if defined (PLATFORM_MSM8994) || defined (PLATFORM_THULIUM)
#define PLAYBACK_OFFLOAD_DEVICE2 17
#define PLAYBACK_OFFLOAD_DEVICE3 18
#define PLAYBACK_OFFLOAD_DEVICE4 37
@@ -239,7 +230,6 @@
#define PLAYBACK_OFFLOAD_DEVICE8 41
#define PLAYBACK_OFFLOAD_DEVICE9 42
#endif
-#endif
#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
diff --git a/hal/msm8974/hw_info.c b/hal/msm8974/hw_info.c
index 50e8f97..c96d11e 100644
--- a/hal/msm8974/hw_info.c
+++ b/hal/msm8974/hw_info.c
@@ -87,7 +87,7 @@
SND_DEVICE_IN_HANDSET_MIC,
};
-static const snd_device_t tomtom_thulium_CDP_variant_devices[] = {
+static const snd_device_t tomtom_8996_CDP_variant_devices[] = {
};
static const snd_device_t tomtom_liquid_variant_devices[] = {
@@ -252,34 +252,34 @@
}
}
-static void update_hardware_info_thulium(struct hardware_info *hw_info, const char *snd_card_name)
+static void update_hardware_info_8996(struct hardware_info *hw_info, const char *snd_card_name)
{
- if (!strcmp(snd_card_name, "msmthulium-tomtom-mtp-snd-card")) {
+ if (!strcmp(snd_card_name, "msm8996-tomtom-mtp-snd-card")) {
strlcpy(hw_info->type, " mtp", sizeof(hw_info->type));
- strlcpy(hw_info->name, "msmthulium", sizeof(hw_info->name));
+ strlcpy(hw_info->name, "msm8996", sizeof(hw_info->name));
hw_info->snd_devices = NULL;
hw_info->num_snd_devices = 0;
strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn));
- } else if (!strcmp(snd_card_name, "msmthulium-tomtom-cdp-snd-card")) {
+ } else if (!strcmp(snd_card_name, "msm8996-tomtom-cdp-snd-card")) {
strlcpy(hw_info->type, " cdp", sizeof(hw_info->type));
- strlcpy(hw_info->name, "msmthulium", sizeof(hw_info->name));
- hw_info->snd_devices = (snd_device_t *)tomtom_thulium_CDP_variant_devices;
- hw_info->num_snd_devices = ARRAY_SIZE(tomtom_thulium_CDP_variant_devices);
+ strlcpy(hw_info->name, "msm8996", sizeof(hw_info->name));
+ hw_info->snd_devices = (snd_device_t *)tomtom_8996_CDP_variant_devices;
+ hw_info->num_snd_devices = ARRAY_SIZE(tomtom_8996_CDP_variant_devices);
strlcpy(hw_info->dev_extn, "-cdp", sizeof(hw_info->dev_extn));
- } else if (!strcmp(snd_card_name, "msmthulium-tomtom-stp-snd-card")) {
+ } else if (!strcmp(snd_card_name, "msm8996-tomtom-stp-snd-card")) {
strlcpy(hw_info->type, " stp", sizeof(hw_info->type));
- strlcpy(hw_info->name, "msmthulium", sizeof(hw_info->name));
+ strlcpy(hw_info->name, "msm8996", sizeof(hw_info->name));
hw_info->snd_devices = (snd_device_t *)tomtom_stp_variant_devices;
hw_info->num_snd_devices = ARRAY_SIZE(tomtom_stp_variant_devices);
strlcpy(hw_info->dev_extn, "-stp", sizeof(hw_info->dev_extn));
- } else if (!strcmp(snd_card_name, "msmthulium-tomtom-liquid-snd-card")) {
+ } else if (!strcmp(snd_card_name, "msm8996-tomtom-liquid-snd-card")) {
strlcpy(hw_info->type, " liquid", sizeof(hw_info->type));
- strlcpy(hw_info->name, "msmthulium", sizeof(hw_info->name));
+ strlcpy(hw_info->name, "msm8996", sizeof(hw_info->name));
hw_info->snd_devices = (snd_device_t *)tomtom_liquid_variant_devices;
hw_info->num_snd_devices = ARRAY_SIZE(tomtom_liquid_variant_devices);
strlcpy(hw_info->dev_extn, "-liquid", sizeof(hw_info->dev_extn));
} else {
- ALOGW("%s: Not a thulium device", __func__);
+ ALOGW("%s: Not a 8996 device", __func__);
}
}
@@ -408,9 +408,9 @@
} else if(strstr(snd_card_name, "msm8994")) {
ALOGV("8994 - variant soundcard");
update_hardware_info_8994(hw_info, snd_card_name);
- } else if(strstr(snd_card_name, "thulium")) {
- ALOGV("thulium - variant soundcard");
- update_hardware_info_thulium(hw_info, snd_card_name);
+ } else if(strstr(snd_card_name, "msm8996")) {
+ ALOGV("8996 - variant soundcard");
+ update_hardware_info_8996(hw_info, snd_card_name);
} else {
ALOGE("%s: Unsupported target %s:",__func__, snd_card_name);
free(hw_info);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index d6261c1..d9d9d8e 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -3366,10 +3366,15 @@
ALOGE("%s: Invalid channel mapping used", __func__);
return -EINVAL;
}
- strlcpy(mixer_ctl_name, "Playback Channel Map", sizeof(mixer_ctl_name));
+
+ /*
+ * If snd_id is greater than 0, stream channel mapping
+ * If snd_id is below 0, typically -1, device channel mapping
+ */
if (snd_id >= 0) {
- snprintf(device_num, sizeof(device_num), "%d", snd_id);
- strncat(mixer_ctl_name, device_num, 13);
+ snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "Playback Channel Map%d", snd_id);
+ } else {
+ strlcpy(mixer_ctl_name, "Playback Device Channel Map", sizeof(mixer_ctl_name));
}
ALOGD("%s mixer_ctl_name:%s", __func__, mixer_ctl_name);
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index c7d7f0e..7deb6da 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -229,7 +229,7 @@
#define PLAYBACK_OFFLOAD_DEVICE8 38
#define PLAYBACK_OFFLOAD_DEVICE9 39
#endif
-#if defined (PLATFORM_MSM8994) || defined (PLATFORM_THULIUM)
+#if defined (PLATFORM_MSM8994) || defined (PLATFORM_MSM8996)
#define PLAYBACK_OFFLOAD_DEVICE2 17
#define PLAYBACK_OFFLOAD_DEVICE3 18
#define PLAYBACK_OFFLOAD_DEVICE4 37
@@ -303,7 +303,7 @@
#define FM_RX_VOLUME "Quat MI2S FM RX Volume"
#elif PLATFORM_MSM8994
#define FM_RX_VOLUME "PRI MI2S LOOPBACK Volume"
-#elif PLATFORM_THULIUM
+#elif PLATFORM_MSM8996
#define FM_RX_VOLUME "Tert MI2S LOOPBACK Volume"
#else
#define FM_RX_VOLUME "Internal FM RX Volume"
diff --git a/post_proc/bundle.c b/post_proc/bundle.c
index 410e17b..606c66b 100644
--- a/post_proc/bundle.c
+++ b/post_proc/bundle.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -713,8 +713,8 @@
/* Stub function for effect interface: never called for offloaded effects */
/* called for hw accelerated effects */
int effect_process(effect_handle_t self,
- audio_buffer_t *inBuffer,
- audio_buffer_t *outBuffer)
+ audio_buffer_t *inBuffer __unused,
+ audio_buffer_t *outBuffer __unused)
{
effect_context_t * context = (effect_context_t *)self;
int status = 0;
@@ -847,6 +847,8 @@
} break;
case EFFECT_CMD_SET_PARAM: {
if (pCmdData == NULL ||
+ cmdSize > (int)(sizeof(effect_param_t) + sizeof(uint32_t) +
+ sizeof(uint32_t)) ||
cmdSize < (int)(sizeof(effect_param_t) + sizeof(uint32_t) +
sizeof(uint16_t)) ||
pReplyData == NULL || *replySize != sizeof(int32_t)) {
diff --git a/post_proc/virtualizer.c b/post_proc/virtualizer.c
index f6e2881..2748568 100644
--- a/post_proc/virtualizer.c
+++ b/post_proc/virtualizer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -69,6 +69,197 @@
return 0;
}
+/*
+ * Check if an audio device is supported by this implementation
+ *
+ * [in]
+ * device device that is intented for processing (e.g. for binaural vs transaural)
+ * [out]
+ * false device is not applicable for effect
+ * true device is applicable for effect
+ */
+bool virtualizer_is_device_supported(audio_devices_t device) {
+ switch (device) {
+ case AUDIO_DEVICE_OUT_SPEAKER:
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
+ case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
+#ifdef AFE_PROXY_ENABLED
+ case AUDIO_DEVICE_OUT_PROXY:
+#endif
+ case AUDIO_DEVICE_OUT_AUX_DIGITAL:
+ case AUDIO_DEVICE_OUT_USB_ACCESSORY:
+ case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET:
+ return false;
+ default :
+ return true;
+ }
+}
+
+/*
+ * Check if a channel mask + audio device is supported by this implementation
+ *
+ * [in]
+ * channel_mask channel mask of input buffer
+ * device device that is intented for processing (e.g. for binaural vs transaural)
+ * [out]
+ * false if the configuration is not supported or it is unknown
+ * true if the configuration is supported
+ */
+bool virtualizer_is_configuration_supported(audio_channel_mask_t channel_mask,
+ audio_devices_t device) {
+ uint32_t channelCount = audio_channel_count_from_out_mask(channel_mask);
+ if ((channelCount == 0) || (channelCount > 2)) {
+ return false;
+ }
+
+ return virtualizer_is_device_supported(device);
+}
+
+/*
+ * Force the virtualization mode to that of the given audio device
+ *
+ * [in]
+ * context effect engine context
+ * forced_device device whose virtualization mode we'll always use
+ * [out]
+ * -EINVAL if the device is not supported or is unknown
+ * 0 if the device is supported and the virtualization mode forced
+ */
+int virtualizer_force_virtualization_mode(virtualizer_context_t *context,
+ audio_devices_t forced_device) {
+ virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context;
+ int status = 0;
+ bool use_virt = false;
+ int is_virt_enabled =
+ offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt));
+
+ ALOGV("%s: ctxt %p, forcedDev=0x%x enabled=%d tmpDisabled=%d", __func__, virt_ctxt,
+ forced_device, is_virt_enabled, virt_ctxt->temp_disabled);
+
+ if (virtualizer_is_device_supported(forced_device) == false) {
+ if (forced_device != AUDIO_DEVICE_NONE) {
+ //forced device is not supported, make it behave as a reset of forced mode
+ forced_device = AUDIO_DEVICE_NONE;
+ // but return an error
+ status = -EINVAL;
+ }
+ }
+
+ if (forced_device == AUDIO_DEVICE_NONE) {
+ // disabling forced virtualization mode:
+ // verify whether the virtualization should be enabled or disabled
+ if (virtualizer_is_device_supported(virt_ctxt->device)) {
+ use_virt = (is_virt_enabled == true);
+ }
+ virt_ctxt->forced_device = AUDIO_DEVICE_NONE;
+ } else {
+ // forcing virtualization mode:
+ // TODO: we assume device is supported, so hard coded a fixed one.
+ virt_ctxt->forced_device = AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
+ // TODO: only enable for a supported mode, when the effect is enabled
+ use_virt = (is_virt_enabled == true);
+ }
+
+ if (use_virt) {
+ if (virt_ctxt->temp_disabled == true) {
+ if (effect_is_active(&virt_ctxt->common)) {
+ offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), true);
+ if (virt_ctxt->ctl)
+ offload_virtualizer_send_params(virt_ctxt->ctl,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ if (virt_ctxt->hw_acc_fd > 0)
+ hw_acc_virtualizer_send_params(virt_ctxt->hw_acc_fd,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ }
+ ALOGV("%s: re-enable VIRTUALIZER", __func__);
+ virt_ctxt->temp_disabled = false;
+ } else {
+ ALOGV("%s: leaving VIRTUALIZER enabled", __func__);
+ }
+ } else {
+ if (virt_ctxt->temp_disabled == false) {
+ if (effect_is_active(&virt_ctxt->common)) {
+ offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), false);
+ if (virt_ctxt->ctl)
+ offload_virtualizer_send_params(virt_ctxt->ctl,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ if (virt_ctxt->hw_acc_fd > 0)
+ hw_acc_virtualizer_send_params(virt_ctxt->hw_acc_fd,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ }
+ ALOGV("%s: disable VIRTUALIZER", __func__);
+ virt_ctxt->temp_disabled = true;
+ } else {
+ ALOGV("%s: leaving VIRTUALIZER disabled", __func__);
+ }
+ }
+
+ ALOGV("after %s: ctxt %p, enabled=%d tmpDisabled=%d", __func__, virt_ctxt,
+ is_virt_enabled, virt_ctxt->temp_disabled);
+
+ return status;
+}
+
+/*
+ * Get the virtual speaker angles for a channel mask + audio device configuration
+ * which is guaranteed to be supported by this implementation
+ *
+ * [in]
+ * channel_mask the channel mask of the input to virtualize
+ * device the type of device that affects the processing (e.g. for binaural vs transaural)
+ * [in/out]
+ * speaker_angles the array of integer where each speaker angle is written as a triplet in the
+ * following format:
+ * int32_t a bit mask with a single value selected for each speaker, following
+ * the convention of the audio_channel_mask_t type
+ * int32_t a value in degrees expressing the speaker azimuth, where 0 is in front
+ * of the user, 180 behind, -90 to the left, 90 to the right of the user
+ * int32_t a value in degrees expressing the speaker elevation, where 0 is the
+ * horizontal plane, +90 is directly above the user, -90 below
+ *
+ */
+void virtualizer_get_speaker_angles(audio_channel_mask_t channel_mask __unused,
+ audio_devices_t device __unused, int32_t *speaker_angles) {
+ // the channel count is guaranteed to be 1 or 2
+ // the device is guaranteed to be of type headphone
+ // this virtualizer is always 2in with speakers at -90 and 90deg of azimuth, 0deg of elevation
+ *speaker_angles++ = (int32_t) AUDIO_CHANNEL_OUT_FRONT_LEFT;
+ *speaker_angles++ = -90; // azimuth
+ *speaker_angles++ = 0; // elevation
+ *speaker_angles++ = (int32_t) AUDIO_CHANNEL_OUT_FRONT_RIGHT;
+ *speaker_angles++ = 90; // azimuth
+ *speaker_angles = 0; // elevation
+}
+
+/*
+ * Retrieve the current device whose processing mode is used by this effect
+ *
+ * [out]
+ * AUDIO_DEVICE_NONE if the effect is not virtualizing
+ * or the device type if the effect is virtualizing
+ */
+audio_devices_t virtualizer_get_virtualization_mode(virtualizer_context_t *context) {
+ virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context;
+ audio_devices_t device = AUDIO_DEVICE_NONE;
+
+ if ((offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt)))
+ && (virt_ctxt->temp_disabled == false)) {
+ if (virt_ctxt->forced_device != AUDIO_DEVICE_NONE) {
+ // virtualization mode is forced, return that device
+ device = virt_ctxt->forced_device;
+ } else {
+ // no forced mode, return the current device
+ device = virt_ctxt->device;
+ }
+ }
+ ALOGV("%s: returning 0x%x", __func__, device);
+ return device;
+}
+
int virtualizer_get_parameter(effect_context_t *context, effect_param_t *p,
uint32_t *size)
{
@@ -94,6 +285,15 @@
p->status = -EINVAL;
p->vsize = sizeof(int16_t);
break;
+ case VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES:
+ // return value size can only be interpreted as relative to input value,
+ // deferring validity check to below
+ break;
+ case VIRTUALIZER_PARAM_VIRTUALIZATION_MODE:
+ if (p->vsize != sizeof(uint32_t))
+ p->status = -EINVAL;
+ p->vsize = sizeof(uint32_t);
+ break;
default:
p->status = -EINVAL;
}
@@ -112,6 +312,31 @@
*(int16_t *)value = virtualizer_get_strength(virt_ctxt);
break;
+ case VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES:
+ {
+ const audio_channel_mask_t channel_mask = (audio_channel_mask_t) *param_tmp++;
+ const audio_devices_t device = (audio_devices_t) *param_tmp;
+ uint32_t channel_cnt = audio_channel_count_from_out_mask(channel_mask);
+
+ if (p->vsize < 3 * channel_cnt * sizeof(int32_t)){
+ p->status = -EINVAL;
+ break;
+ }
+ // verify the configuration is supported
+ if(virtualizer_is_configuration_supported(channel_mask, device)) {
+ // configuration is supported, get the angles
+ virtualizer_get_speaker_angles(channel_mask, device, (int32_t *)value);
+ } else {
+ p->status = -EINVAL;
+ }
+
+ break;
+ }
+
+ case VIRTUALIZER_PARAM_VIRTUALIZATION_MODE:
+ *(uint32_t *)value = (uint32_t) virtualizer_get_virtualization_mode(virt_ctxt);
+ break;
+
default:
p->status = -EINVAL;
break;
@@ -121,7 +346,7 @@
}
int virtualizer_set_parameter(effect_context_t *context, effect_param_t *p,
- uint32_t size)
+ uint32_t size __unused)
{
virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context;
int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
@@ -139,6 +364,14 @@
strength = (uint32_t)(*(int16_t *)value);
virtualizer_set_strength(virt_ctxt, strength);
break;
+ case VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE:
+ {
+ const audio_devices_t device = *(audio_devices_t *)value;
+ if (0 != virtualizer_force_virtualization_mode(virt_ctxt, device)) {
+ p->status = -EINVAL;
+ }
+ break;
+ }
default:
p->status = -EINVAL;
break;
@@ -153,46 +386,44 @@
ALOGV("%s: ctxt %p, device: 0x%x", __func__, virt_ctxt, device);
virt_ctxt->device = device;
- if((device == AUDIO_DEVICE_OUT_SPEAKER) ||
- (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) ||
- (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) ||
-#ifdef AFE_PROXY_ENABLED
- (device == AUDIO_DEVICE_OUT_PROXY) ||
-#endif
- (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) ||
- (device == AUDIO_DEVICE_OUT_USB_ACCESSORY) ||
- (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) {
- if (!virt_ctxt->temp_disabled) {
- if (effect_is_active(&virt_ctxt->common)) {
- offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), false);
- if (virt_ctxt->ctl)
- offload_virtualizer_send_params(virt_ctxt->ctl,
- &virt_ctxt->offload_virt,
- OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
- if (virt_ctxt->hw_acc_fd > 0)
- hw_acc_virtualizer_send_params(virt_ctxt->hw_acc_fd,
- &virt_ctxt->offload_virt,
- OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+
+ if (virt_ctxt->forced_device == AUDIO_DEVICE_NONE) {
+ // default case unless configuration is forced
+ if (virtualizer_is_device_supported(device) == false) {
+ if (!virt_ctxt->temp_disabled) {
+ if (effect_is_active(&virt_ctxt->common)) {
+ offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), false);
+ if (virt_ctxt->ctl)
+ offload_virtualizer_send_params(virt_ctxt->ctl,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ if (virt_ctxt->hw_acc_fd > 0)
+ hw_acc_virtualizer_send_params(virt_ctxt->hw_acc_fd,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ }
+ virt_ctxt->temp_disabled = true;
+ ALOGI("%s: ctxt %p, disabled based on device", __func__, virt_ctxt);
}
- virt_ctxt->temp_disabled = true;
- ALOGI("%s: ctxt %p, disabled based on device", __func__, virt_ctxt);
- }
- } else {
- if (virt_ctxt->temp_disabled) {
- if (effect_is_active(&virt_ctxt->common)) {
- offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), true);
- if (virt_ctxt->ctl)
- offload_virtualizer_send_params(virt_ctxt->ctl,
- &virt_ctxt->offload_virt,
- OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
- if (virt_ctxt->hw_acc_fd > 0)
- hw_acc_virtualizer_send_params(virt_ctxt->hw_acc_fd,
- &virt_ctxt->offload_virt,
- OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ } else {
+ if (virt_ctxt->temp_disabled) {
+ if (effect_is_active(&virt_ctxt->common)) {
+ offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), true);
+ if (virt_ctxt->ctl)
+ offload_virtualizer_send_params(virt_ctxt->ctl,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ if (virt_ctxt->hw_acc_fd > 0)
+ hw_acc_virtualizer_send_params(virt_ctxt->hw_acc_fd,
+ &virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG);
+ }
+ virt_ctxt->temp_disabled = false;
}
- virt_ctxt->temp_disabled = false;
}
}
+ // else virtualization mode is forced to a certain device, nothing to do
+
offload_virtualizer_set_device(&(virt_ctxt->offload_virt), device);
return 0;
}
@@ -230,6 +461,8 @@
virt_ctxt->temp_disabled = false;
virt_ctxt->hw_acc_fd = -1;
+ virt_ctxt->forced_device = AUDIO_DEVICE_NONE;
+ virt_ctxt->device = AUDIO_DEVICE_NONE;
memset(&(virt_ctxt->offload_virt), 0, sizeof(struct virtualizer_params));
return 0;
diff --git a/post_proc/virtualizer.h b/post_proc/virtualizer.h
index 440c8a2..b5293fb 100644
--- a/post_proc/virtualizer.h
+++ b/post_proc/virtualizer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -33,7 +33,8 @@
struct mixer_ctl *ctl;
int hw_acc_fd;
bool temp_disabled;
- uint32_t device;
+ audio_devices_t forced_device;
+ audio_devices_t device;
struct virtualizer_params offload_virt;
} virtualizer_context_t;