Merge "policy_hal: Update custom policy manager to new base class"
diff --git a/hal/Android.mk b/hal/Android.mk
index 0dff2ae..1af245a 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -150,6 +150,15 @@
LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true)
+ LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED
+ifneq ($(strip $(DOLBY_DDP)),true)
+ ifneq ($(strip $(DOLBY_DAP)),true)
+ LOCAL_SRC_FILES += audio_extn/dolby.c
+ endif
+endif
+endif
+
LOCAL_SHARED_LIBRARIES := \
liblog \
libcutils \
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index dd6063f..02add40 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -259,22 +259,27 @@
#define audio_extn_dolby_set_license(adev) (0)
#endif
-#ifndef DS1_DOLBY_DDP_ENABLED
+#ifndef DS1_DOLBY_DAP_ENABLED
#define audio_extn_dolby_set_endpoint(adev) (0)
#else
void audio_extn_dolby_set_endpoint(struct audio_device *adev);
#endif
-#ifndef DS1_DOLBY_DDP_ENABLED
-#define audio_extn_ddp_set_parameters(adev, parms) (0)
-#define audio_extn_is_dolby_format(format) (0)
-#define audio_extn_dolby_get_snd_codec_id(adev, out, format) (0)
-#define audio_extn_dolby_send_ddp_endp_params(adev) (0)
-#else
+
+#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS2_DOLBY_DAP_ENABLED)
bool audio_extn_is_dolby_format(audio_format_t format);
int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev,
struct stream_out *out,
audio_format_t format);
+#else
+#define audio_extn_is_dolby_format(format) (0)
+#define audio_extn_dolby_get_snd_codec_id(adev, out, format) (0)
+#endif
+
+#ifndef DS1_DOLBY_DDP_ENABLED
+#define audio_extn_ddp_set_parameters(adev, parms) (0)
+#define audio_extn_dolby_send_ddp_endp_params(adev) (0)
+#else
void audio_extn_ddp_set_parameters(struct audio_device *adev,
struct str_parms *parms);
void audio_extn_dolby_send_ddp_endp_params(struct audio_device *adev);
@@ -318,5 +323,39 @@
int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase);
void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
struct audio_usecase *usecase);
+#ifdef DS2_DOLBY_DAP_ENABLED
+#define LIB_DS2_DAP_HAL "vendor/lib/libhwdaphal.so"
+#define SET_HW_INFO_FUNC "dap_hal_set_hw_info"
+typedef enum {
+ SND_CARD = 0,
+ HW_ENDPOINT = 1,
+ DMID = 2,
+ DEVICE_BE_ID_MAP = 3,
+ DAP_BYPASS = 4,
+} dap_hal_hw_info_t;
+typedef int (*dap_hal_set_hw_info_t)(int32_t hw_info, void* data);
+typedef struct {
+ int (*device_id_to_be_id)[2];
+ int len;
+} dap_hal_device_be_id_map_t;
+int audio_extn_dap_hal_init(int snd_card);
+int audio_extn_dap_hal_deinit();
+void audio_extn_dolby_ds2_set_endpoint(struct audio_device *adev);
+int audio_extn_ds2_enable(struct audio_device *adev);
+int audio_extn_dolby_set_dap_bypass(struct audio_device *adev, int state);
+#else
+#define audio_extn_dap_hal_init(snd_card) (0)
+#define audio_extn_dap_hal_deinit() (0)
+#define audio_extn_dolby_ds2_set_endpoint(adev) (0)
+#define audio_extn_ds2_enable(adev) (0)
+#define audio_extn_dolby_set_dap_bypass(adev, state) (0)
+#endif
+typedef enum {
+ DAP_STATE_ON = 0,
+ DAP_STATE_BYPASS,
+};
+#ifndef AUDIO_FORMAT_E_AC3_JOC
+#define AUDIO_FORMAT_E_AC3_JOC 0x19000000UL
+#endif
#endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index ddd2380..8670367 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -243,7 +243,8 @@
(usecase->devices & ddp_dev) &&
(usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
((usecase->stream.out->format == AUDIO_FORMAT_AC3) ||
- (usecase->stream.out->format == AUDIO_FORMAT_E_AC3))) {
+ (usecase->stream.out->format == AUDIO_FORMAT_E_AC3) ||
+ (usecase->stream.out->format == AUDIO_FORMAT_E_AC3_JOC))) {
send_ddp_endp_params_stream(usecase->stream.out, ddp_dev,
dev_ch_cap, false /* set cache */);
}
@@ -260,7 +261,8 @@
(usecase->devices & AUDIO_DEVICE_OUT_ALL) &&
(usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
((usecase->stream.out->format == AUDIO_FORMAT_AC3) ||
- (usecase->stream.out->format == AUDIO_FORMAT_E_AC3))) {
+ (usecase->stream.out->format == AUDIO_FORMAT_E_AC3) ||
+ (usecase->stream.out->format == AUDIO_FORMAT_E_AC3_JOC))) {
/*
* Use wfd /hdmi sink channel cap for dolby params if device is wfd
* or hdmi. Otherwise use stereo configuration
@@ -352,7 +354,9 @@
*/
send_ddp_endp_params(adev, ddp_dev, dev_ch_cap);
}
+#endif /* DS1_DOLBY_DDP_ENABLED */
+#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS2_DOLBY_DAP_ENABLED)
int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev,
struct stream_out *out,
audio_format_t format)
@@ -370,19 +374,20 @@
switch (format) {
case AUDIO_FORMAT_AC3:
id = SND_AUDIOCODEC_AC3;
+#ifdef DS1_DOLBY_DDP_ENABLED
send_ddp_endp_params_stream(out, out->devices,
channel_cap, true /* set_cache */);
-#ifndef DS1_DOLBY_DAP_ENABLED
- audio_extn_dolby_set_dmid(adev);
#endif
+ audio_extn_dolby_set_dmid(adev);
break;
case AUDIO_FORMAT_E_AC3:
+ case AUDIO_FORMAT_E_AC3_JOC:
id = SND_AUDIOCODEC_EAC3;
+#ifdef DS1_DOLBY_DDP_ENABLED
send_ddp_endp_params_stream(out, out->devices,
channel_cap, true /* set_cache */);
-#ifndef DS1_DOLBY_DAP_ENABLED
- audio_extn_dolby_set_dmid(adev);
#endif
+ audio_extn_dolby_set_dmid(adev);
break;
default:
ALOGE("%s: Unsupported audio format :%x", __func__, format);
@@ -394,13 +399,13 @@
bool audio_extn_is_dolby_format(audio_format_t format)
{
if (format == AUDIO_FORMAT_AC3 ||
- format == AUDIO_FORMAT_E_AC3)
+ format == AUDIO_FORMAT_E_AC3 ||
+ format == AUDIO_FORMAT_E_AC3_JOC)
return true;
else
return false;
}
-
-#endif /* DS1_DOLBY_DDP_ENABLED */
+#endif /* DS1_DOLBY_DDP_ENABLED || DS2_DOLBY_DAP_ENABLED */
#ifdef DS1_DOLBY_DAP_ENABLED
void audio_extn_dolby_set_endpoint(struct audio_device *adev)
@@ -499,3 +504,135 @@
return;
}
#endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */
+
+#ifdef DS2_DOLBY_DAP_ENABLED
+struct ds2_extn_module {
+ void *ds2_handle;
+ dap_hal_set_hw_info_t dap_hal_set_hw_info;
+};
+
+static struct ds2_extn_module ds2extnmod = {
+ .ds2_handle = NULL,
+ .dap_hal_set_hw_info = NULL,
+};
+
+int audio_extn_dap_hal_init(int snd_card) {
+ char c_dmid[128] = {0};
+ void *handle = NULL;
+ int i_dmid, ret = -EINVAL;
+ dap_hal_device_be_id_map_t device_be_id_map;
+
+ ALOGV("%s: opening DAP HAL lib\n", __func__);
+ ds2extnmod.ds2_handle = dlopen(LIB_DS2_DAP_HAL, RTLD_NOW);
+ if (ds2extnmod.ds2_handle == NULL) {
+ ALOGE("%s: DLOPEN failed for %s error %s", __func__, LIB_DS2_DAP_HAL,
+ dlerror());
+ goto ret;
+ }
+ ds2extnmod.dap_hal_set_hw_info = (dap_hal_set_hw_info_t)dlsym(ds2extnmod.ds2_handle, SET_HW_INFO_FUNC);
+ if (ds2extnmod.dap_hal_set_hw_info == NULL) {
+ ALOGE("%s: dlsym error %s for %s", __func__, SET_HW_INFO_FUNC,
+ dlerror());
+ goto close;
+ }
+ ds2extnmod.dap_hal_set_hw_info(SND_CARD, (void*)(&snd_card));
+ ALOGV("%s Sound card number is:%d",__func__,snd_card);
+
+ property_get("dmid",c_dmid,"0");
+ i_dmid = atoi(c_dmid);
+ ds2extnmod.dap_hal_set_hw_info(DMID, (void*)(&i_dmid));
+ ALOGV("%s Dolby device manufacturer id is:%d",__func__,i_dmid);
+
+ platform_get_device_to_be_id_map(&device_be_id_map.device_id_to_be_id, &device_be_id_map.len);
+ ds2extnmod.dap_hal_set_hw_info(DEVICE_BE_ID_MAP, (void*)(&device_be_id_map));
+ ALOGV("%s Set be id map len:%d",__func__,device_be_id_map.len);
+ ret = 0;
+ goto ret;
+
+close:
+ dlclose(ds2extnmod.ds2_handle);
+ ds2extnmod.ds2_handle = NULL;
+ ds2extnmod.dap_hal_set_hw_info = NULL;
+ret:
+ return ret;
+}
+
+int audio_extn_dap_hal_deinit() {
+ if (ds2extnmod.ds2_handle != NULL) {
+ dlclose(ds2extnmod.ds2_handle);
+ ds2extnmod.ds2_handle = NULL;
+ }
+ ds2extnmod.dap_hal_set_hw_info = NULL;
+ return 0;
+}
+
+void audio_extn_dolby_ds2_set_endpoint(struct audio_device *adev) {
+ struct listnode *node;
+ struct audio_usecase *usecase;
+ struct mixer_ctl *ctl;
+ const char *mixer_ctl_name = "DS1 DAP Endpoint";
+ int endpoint = 0, ret;
+ bool send = false;
+
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if ((usecase->type == PCM_PLAYBACK) &&
+ (usecase->id != USECASE_AUDIO_PLAYBACK_LOW_LATENCY)) {
+ endpoint |= usecase->devices & AUDIO_DEVICE_OUT_ALL;
+ send = true;
+ }
+ }
+ if (!send)
+ return;
+
+ if (ds2extnmod.dap_hal_set_hw_info) {
+ ds2extnmod.dap_hal_set_hw_info(HW_ENDPOINT, (void*)(&endpoint));
+ ALOGE("%s: Dolby set endpint :0x%x",__func__, endpoint);
+ } else {
+ ALOGE("%s: dap_hal_set_hw_info is NULL",__func__);
+ }
+
+ return;
+}
+
+int audio_extn_ds2_enable(struct audio_device *adev) {
+
+ char value[PROPERTY_VALUE_MAX] = {0};
+ bool ds2_enabled = false;
+ const char *mixer_ctl_name = "DS2 OnOff";
+ struct mixer_ctl *ctl;
+
+ property_get("audio.dolby.ds2.enabled", value, NULL);
+ ds2_enabled = atoi(value) || !strncmp("true", value, 4);
+
+ ALOGV("%s:", __func__);
+ if(ds2_enabled) {
+ ALOGD("%s:ds2_enabled %d", __func__, ds2_enabled);
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (!ctl) {
+ ALOGE("%s: Could not get ctl for mixer cmd - %s",
+ __func__, mixer_ctl_name);
+ return -EINVAL;
+ }
+
+ if (mixer_ctl_set_value(ctl, 0, ds2_enabled) < 0) {
+ ALOGE("%s: Could not set ds2 enable %d",
+ __func__, ds2_enabled);
+ return -EINVAL;
+ }
+ }
+ return 0;
+}
+
+int audio_extn_dolby_set_dap_bypass(struct audio_device *adev, int state) {
+
+ ALOGV("%s: state %d", __func__, state);
+ if (ds2extnmod.dap_hal_set_hw_info) {
+ ds2extnmod.dap_hal_set_hw_info(DAP_BYPASS, (void*)(&state));
+ ALOGV("%s: Dolby set bypas :0x%x", __func__, state);
+ } else {
+ ALOGV("%s: dap_hal_set_hw_info is NULL", __func__);
+ }
+ return 0;
+}
+#endif
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 6818161..8bd98a0 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -436,6 +436,9 @@
if ((24 == bit_width) &&
(devices & AUDIO_DEVICE_OUT_SPEAKER)) {
+ int32_t bw = platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
+ if (-ENOSYS != bw)
+ bit_width = (uint32_t)bw;
sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
ALOGI("%s Allowing 24-bit playback on speaker ONLY at default sampling rate", __func__);
}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index eb53f40..9e841df 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -210,6 +210,12 @@
STRING_TO_ENUM(AUDIO_CHANNEL_OUT_7POINT1),
};
+static const struct string_to_enum out_formats_name_to_enum_table[] = {
+ STRING_TO_ENUM(AUDIO_FORMAT_AC3),
+ STRING_TO_ENUM(AUDIO_FORMAT_E_AC3),
+ STRING_TO_ENUM(AUDIO_FORMAT_E_AC3_JOC),
+};
+
static struct audio_device *adev = NULL;
static pthread_mutex_t adev_init_lock;
static unsigned int audio_device_ref_count;
@@ -360,6 +366,7 @@
audio_extn_dolby_set_dmid(adev);
audio_extn_dolby_set_endpoint(adev);
#endif
+ audio_extn_dolby_ds2_set_endpoint(adev);
audio_extn_sound_trigger_update_stream_status(usecase, ST_EVENT_STREAM_BUSY);
audio_extn_listen_update_stream_status(usecase, LISTEN_EVENT_STREAM_BUSY);
audio_extn_utils_send_audio_calibration(adev, usecase);
@@ -3405,6 +3412,7 @@
adev->bt_wb_speech_enabled = false;
+ audio_extn_ds2_enable(adev);
*device = &adev->device.common;
audio_extn_utils_update_streams_output_cfg_list(adev->platform, adev->mixer,
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 3bfa405..cf64878 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -456,6 +456,64 @@
{TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)},
};
+#define NO_COLS 2
+static int msm_be_id_array_len;
+static int (*msm_device_to_be_id)[];
+
+/* Below table lists output device to BE_ID mapping*/
+/* Update the table based on the board configuration*/
+
+static int msm_device_to_be_id_internal_codec [][NO_COLS] = {
+ {AUDIO_DEVICE_OUT_EARPIECE , 34},
+ {AUDIO_DEVICE_OUT_SPEAKER , 34},
+ {AUDIO_DEVICE_OUT_WIRED_HEADSET , 34},
+ {AUDIO_DEVICE_OUT_WIRED_HEADPHONE , 34},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER , -1},
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL , 4},
+ {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_USB_ACCESSORY , -1},
+ {AUDIO_DEVICE_OUT_USB_DEVICE , -1},
+ {AUDIO_DEVICE_OUT_REMOTE_SUBMIX , 9},
+ {AUDIO_DEVICE_OUT_PROXY , 9},
+ {AUDIO_DEVICE_OUT_FM , 7},
+ {AUDIO_DEVICE_OUT_FM_TX , 8},
+ {AUDIO_DEVICE_OUT_ALL , -1},
+ {AUDIO_DEVICE_NONE , -1},
+ {AUDIO_DEVICE_OUT_DEFAULT , -1},
+};
+
+static int msm_device_to_be_id_external_codec [][NO_COLS] = {
+ {AUDIO_DEVICE_OUT_EARPIECE , 2},
+ {AUDIO_DEVICE_OUT_SPEAKER , 2},
+ {AUDIO_DEVICE_OUT_WIRED_HEADSET , 2},
+ {AUDIO_DEVICE_OUT_WIRED_HEADPHONE , 2},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER , -1},
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL , 4},
+ {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_USB_ACCESSORY , -1},
+ {AUDIO_DEVICE_OUT_USB_DEVICE , -1},
+ {AUDIO_DEVICE_OUT_REMOTE_SUBMIX , 9},
+ {AUDIO_DEVICE_OUT_PROXY , 9},
+ {AUDIO_DEVICE_OUT_FM , 7},
+ {AUDIO_DEVICE_OUT_FM_TX , 8},
+ {AUDIO_DEVICE_OUT_ALL , -1},
+ {AUDIO_DEVICE_NONE , -1},
+ {AUDIO_DEVICE_OUT_DEFAULT , -1},
+};
+
+
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
@@ -466,41 +524,89 @@
sizeof("msm8x16-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, "msm8x16-skuh-snd-card",
sizeof("msm8x16-skuh-snd-card"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUH,
sizeof(MIXER_XML_PATH_QRD_SKUH));
+
+ 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, "msm8x16-skui-snd-card",
sizeof("msm8x16-skui-snd-card"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUI,
sizeof(MIXER_XML_PATH_QRD_SKUI));
+
+ 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, "msm8x16-skuhf-snd-card",
sizeof("msm8x16-skuhf-snd-card"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUHF,
sizeof(MIXER_XML_PATH_QRD_SKUHF));
+
+ 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, "msm8939-snd-card-mtp",
sizeof("msm8939-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, "msm8939-snd-card-skuk",
sizeof("msm8939-snd-card-skuk"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUK,
sizeof(MIXER_XML_PATH_SKUK));
+ 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, "msm8939-tapan-snd-card",
sizeof("msm8939-tapan-snd-card"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9306,
sizeof(MIXER_XML_PATH_WCD9306));
+ 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 if (!strncmp(snd_card_name, "msm8939-tapan9302-snd-card",
sizeof("msm8939-tapan9302-snd-card"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9306,
sizeof(MIXER_XML_PATH_WCD9306));
+
+ 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 if (!strncmp(snd_card_name, "msm8939-tomtom9330-snd-card",
sizeof("msm8939-tomtom9330-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));
+
+ 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]);
+
}
}
@@ -1159,6 +1265,18 @@
return acdb_device_table[snd_device];
}
+int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width)
+{
+ ALOGE("%s: Not implemented", __func__);
+ return -ENOSYS;
+}
+
+int platform_get_snd_device_bit_width(snd_device_t snd_device)
+{
+ ALOGE("%s: Not implemented", __func__);
+ return -ENOSYS;
+}
+
int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
int app_type, int sample_rate)
{
@@ -2448,6 +2566,16 @@
return fragment_size;
}
+void platform_get_device_to_be_id_map(int **device_to_be_id, int *length)
+{
+ *device_to_be_id = msm_device_to_be_id;
+ *length = msm_be_id_array_len;
+}
+
+bool platform_check_24_bit_support() {
+ return false;
+}
+
bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev __unused,
struct audio_usecase *usecase __unused)
{
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index f3ed191..941d39f 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -421,6 +421,18 @@
return -ENOSYS;
}
+int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width)
+{
+ ALOGE("%s: Not implemented", __func__);
+ return -ENOSYS;
+}
+
+int platform_get_snd_device_bit_width(snd_device_t snd_device)
+{
+ ALOGE("%s: Not implemented", __func__);
+ return -ENOSYS;
+}
+
int platform_switch_voice_call_enable_device_config(void *platform __unused,
snd_device_t out_snd_device __unused,
snd_device_t in_snd_device __unused)
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 5344e71..e0d8a39 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -319,6 +319,9 @@
[SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = "speaker-dmic-broadside",
};
+// Platform specific backend bit width table
+static int backend_bit_width_table[SND_DEVICE_MAX] = {0};
+
/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
static int acdb_device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_NONE] = -1,
@@ -519,6 +522,67 @@
{TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)},
};
+#define NO_COLS 2
+#ifdef PLATFORM_APQ8084
+static int msm_device_to_be_id [][NO_COLS] = {
+ {AUDIO_DEVICE_OUT_EARPIECE , 2},
+ {AUDIO_DEVICE_OUT_SPEAKER , 2},
+ {AUDIO_DEVICE_OUT_WIRED_HEADSET , 2},
+ {AUDIO_DEVICE_OUT_WIRED_HEADPHONE , 2},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT , 11},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER , -1},
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL , 4},
+ {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_USB_ACCESSORY , -1},
+ {AUDIO_DEVICE_OUT_USB_DEVICE , -1},
+ {AUDIO_DEVICE_OUT_REMOTE_SUBMIX , 9},
+ {AUDIO_DEVICE_OUT_PROXY , 9},
+ {AUDIO_DEVICE_OUT_FM , 7},
+ {AUDIO_DEVICE_OUT_FM_TX , 8},
+ {AUDIO_DEVICE_OUT_ALL , -1},
+ {AUDIO_DEVICE_NONE , -1},
+ {AUDIO_DEVICE_OUT_DEFAULT , -1},
+};
+#elif PLATFORM_MSM8994
+static int msm_device_to_be_id [][NO_COLS] = {
+ {AUDIO_DEVICE_OUT_EARPIECE , 2},
+ {AUDIO_DEVICE_OUT_SPEAKER , 2},
+ {AUDIO_DEVICE_OUT_WIRED_HEADSET , 2},
+ {AUDIO_DEVICE_OUT_WIRED_HEADPHONE , 2},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO , 38},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET , 38},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT , 38},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES , -1},
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER , -1},
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL , 4},
+ {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET , 9},
+ {AUDIO_DEVICE_OUT_USB_ACCESSORY , -1},
+ {AUDIO_DEVICE_OUT_USB_DEVICE , -1},
+ {AUDIO_DEVICE_OUT_REMOTE_SUBMIX , 9},
+ {AUDIO_DEVICE_OUT_PROXY , 9},
+/* Add the correct be ids */
+ {AUDIO_DEVICE_OUT_FM , 7},
+ {AUDIO_DEVICE_OUT_FM_TX , 8},
+ {AUDIO_DEVICE_OUT_ALL , -1},
+ {AUDIO_DEVICE_NONE , -1},
+ {AUDIO_DEVICE_OUT_DEFAULT , -1},
+};
+#else
+static int msm_device_to_be_id [][NO_COLS] = {
+ {AUDIO_DEVICE_NONE, -1},
+};
+#endif
+static int msm_be_id_array_len =
+ sizeof(msm_device_to_be_id) / sizeof(msm_device_to_be_id[0]);
+
+
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
@@ -717,6 +781,9 @@
for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
backend_table[dev] = NULL;
}
+ for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
+ backend_bit_width_table[dev] = 16;
+ }
// TBD - do these go to the platform-info.xml file.
// will help in avoiding strdups here
@@ -1056,6 +1123,9 @@
/* update sound cards appropriately */
audio_extn_usb_set_proxy_sound_card(adev->snd_card);
+ /* init dap hal */
+ audio_extn_dap_hal_init(adev->snd_card);
+
/* Read one time ssr property */
audio_extn_ssr_update_enabled();
audio_extn_spkr_prot_init(adev);
@@ -1090,6 +1160,7 @@
free(platform);
/* deinit usb */
audio_extn_usb_deinit();
+ audio_extn_dap_hal_deinit();
}
const char *platform_get_snd_device_name(snd_device_t snd_device)
@@ -1278,6 +1349,31 @@
return acdb_device_table[snd_device];
}
+int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width)
+{
+ int ret = 0;
+
+ if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) {
+ ALOGE("%s: Invalid snd_device = %d",
+ __func__, snd_device);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ backend_bit_width_table[snd_device] = bit_width;
+done:
+ return ret;
+}
+
+int platform_get_snd_device_bit_width(snd_device_t snd_device)
+{
+ if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) {
+ ALOGE("%s: Invalid snd_device = %d", __func__, snd_device);
+ return DEFAULT_OUTPUT_SAMPLING_RATE;
+ }
+ return backend_bit_width_table[snd_device];
+}
+
int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
int app_type, int sample_rate)
{
@@ -2662,11 +2758,15 @@
}
}
- // 24 bit playback on speakers and all 16 bit playbacks is allowed through
- // 16 bit/48 khz backend only
- if ((16 == bit_width) ||
- ((24 == bit_width) &&
- (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER))) {
+ // 16 bit playback on speakers is allowed through 48 khz backend only
+ if (16 == bit_width) {
+ sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ }
+ // 24 bit playback on speakers is allowed through 48 khz backend only
+ // bit width re-configured based on platform info
+ if ((24 == bit_width) &&
+ (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
+ bit_width = (uint32_t)platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
}
// Force routing if the expected bitwdith or samplerate
@@ -2739,3 +2839,9 @@
done:
return ret;
}
+
+void platform_get_device_to_be_id_map(int **device_to_be_id, int *length)
+{
+ *device_to_be_id = msm_device_to_be_id;
+ *length = msm_be_id_array_len;
+}
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 520b27b..368677b 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -36,6 +36,8 @@
int platform_get_fluence_type(void *platform, char *value, uint32_t len);
int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id);
int platform_get_snd_device_acdb_id(snd_device_t snd_device);
+int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width);
+int platform_get_snd_device_bit_width(snd_device_t snd_device);
int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
int app_type, int sample_rate);
int platform_get_default_app_type(void *platform);
@@ -92,5 +94,6 @@
int platform_get_usecase_index(const char * usecase);
int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id);
void platform_set_echo_reference(void *platform, bool enable);
+void platform_get_device_to_be_id_map(int **be_id_map, int *length);
#endif // AUDIO_PLATFORM_API_H
diff --git a/hal/platform_info.c b/hal/platform_info.c
index 615b9f3..a176177 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -43,6 +43,7 @@
typedef enum {
ROOT,
ACDB,
+ BITWIDTH,
PCM_ID,
BACKEND_NAME,
} section_t;
@@ -50,6 +51,7 @@
typedef void (* section_process_fn)(const XML_Char **attr);
static void process_acdb_id(const XML_Char **attr);
+static void process_bit_width(const XML_Char **attr);
static void process_pcm_id(const XML_Char **attr);
static void process_backend_name(const XML_Char **attr);
static void process_root(const XML_Char **attr);
@@ -57,6 +59,7 @@
static section_process_fn section_table[] = {
[ROOT] = process_root,
[ACDB] = process_acdb_id,
+ [BITWIDTH] = process_bit_width,
[PCM_ID] = process_pcm_id,
[BACKEND_NAME] = process_backend_name,
};
@@ -202,6 +205,38 @@
return;
}
+static void process_bit_width(const XML_Char **attr)
+{
+ int index;
+
+ if (strcmp(attr[0], "name") != 0) {
+ ALOGE("%s: 'name' not found, no ACDB ID set!", __func__);
+ goto done;
+ }
+
+ index = platform_get_snd_device_index((char *)attr[1]);
+ if (index < 0) {
+ ALOGE("%s: Device %s in platform info xml not found, no ACDB ID set!",
+ __func__, attr[1]);
+ goto done;
+ }
+
+ if (strcmp(attr[2], "bit_width") != 0) {
+ ALOGE("%s: Device %s in platform info xml has no bit_width, no ACDB ID set!",
+ __func__, attr[1]);
+ goto done;
+ }
+
+ if (platform_set_snd_device_bit_width(index, atoi((char *)attr[3])) < 0) {
+ ALOGE("%s: Device %s, ACDB ID %d was not set!",
+ __func__, attr[1], atoi((char *)attr[3]));
+ goto done;
+ }
+
+done:
+ return;
+}
+
static void start_tag(void *userdata __unused, const XML_Char *tag_name,
const XML_Char **attr)
{
@@ -209,14 +244,16 @@
const XML_Char *attr_value = NULL;
unsigned int i;
- if (strcmp(tag_name, "acdb_ids") == 0) {
+ if (strcmp(tag_name, "bit_width_configs") == 0) {
+ section = BITWIDTH;
+ } else if (strcmp(tag_name, "acdb_ids") == 0) {
section = ACDB;
} else if (strcmp(tag_name, "pcm_ids") == 0) {
section = PCM_ID;
} else if (strcmp(tag_name, "backend_names") == 0) {
section = BACKEND_NAME;
} else if (strcmp(tag_name, "device") == 0) {
- if ((section != ACDB) && (section != BACKEND_NAME)) {
+ if ((section != ACDB) && (section != BACKEND_NAME) && (section != BITWIDTH)) {
ALOGE("device tag only supported for acdb/backend names");
return;
}
@@ -239,7 +276,9 @@
static void end_tag(void *userdata __unused, const XML_Char *tag_name)
{
- if (strcmp(tag_name, "acdb_ids") == 0) {
+ if (strcmp(tag_name, "bit_width_configs") == 0) {
+ section = ROOT;
+ } else if (strcmp(tag_name, "acdb_ids") == 0) {
section = ROOT;
} else if (strcmp(tag_name, "pcm_ids") == 0) {
section = ROOT;