Merge "policy_hal: Correct device selection in STRATEGY_ENFORCED_AUDIBLE"
diff --git a/hal/Android.mk b/hal/Android.mk
index 037be56..a7e0a02 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -26,6 +26,7 @@
LOCAL_SRC_FILES := \
audio_hw.c \
voice.c \
+ platform_info.c \
$(AUDIO_PLATFORM)/platform.c
LOCAL_SRC_FILES += audio_extn/audio_extn.c
@@ -97,19 +98,30 @@
LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+ LOCAL_SRC_FILES += audio_extn/dolby.c
endif
+ifneq ($(strip $(AUDIO_FEATURE_DISABLED_DS1_DOLBY_DAP)),true)
+ LOCAL_CFLAGS += -DDS1_DOLBY_DAP_ENABLED
+ifeq ($(strip $(AUDIO_FEATURE_DISABLED_DS1_DOLBY_DDP)),true)
+ LOCAL_SRC_FILES += audio_extn/dolby.c
+endif
+endif
+
+
LOCAL_SHARED_LIBRARIES := \
liblog \
libcutils \
libtinyalsa \
libtinycompress \
libaudioroute \
- libdl
+ libdl \
+ libexpat
LOCAL_C_INCLUDES += \
external/tinyalsa/include \
external/tinycompress/include \
+ external/expat/lib \
$(call include-path-for, audio-route) \
$(call include-path-for, audio-effects) \
$(LOCAL_PATH)/$(AUDIO_PLATFORM) \
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 80ce063..89903ba 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -29,8 +29,6 @@
#include "audio_hw.h"
#include "audio_extn.h"
-#include "sound/compress_params.h"
-
#define MAX_SLEEP_RETRY 100
#define WIFI_INIT_WAIT_SLEEP 50
@@ -321,6 +319,7 @@
audio_extn_fm_set_parameters(adev, parms);
audio_extn_listen_set_parameters(adev, parms);
audio_extn_hfp_set_parameters(adev, parms);
+ audio_extn_ddp_set_parameters(adev, parms);
}
void audio_extn_get_parameters(const struct audio_device *adev,
@@ -359,57 +358,3 @@
return 0;
}
#endif /* AUXPCM_BT_ENABLED */
-
-
-#ifdef DS1_DOLBY_DDP_ENABLED
-
-bool audio_extn_dolby_is_supported_format(audio_format_t format)
-{
- if (format == AUDIO_FORMAT_AC3 ||
- format == AUDIO_FORMAT_EAC3)
- return true;
- else
- return false;
-}
-
-int audio_extn_dolby_get_snd_codec_id(audio_format_t format)
-{
- int id = 0;
-
- switch (format) {
- case AUDIO_FORMAT_AC3:
- id = SND_AUDIOCODEC_AC3;
- break;
- case AUDIO_FORMAT_EAC3:
- id = SND_AUDIOCODEC_EAC3;
- break;
- default:
- ALOGE("%s: Unsupported audio format :%x", __func__, format);
- }
-
- return id;
-}
-
-int audio_extn_dolby_set_DMID(struct audio_device *adev)
-{
- struct mixer_ctl *ctl;
- const char *mixer_ctl_name = "DS1 Security";
- char c_dmid[128] = {0};
- int i_dmid, ret;
-
- property_get("dmid",c_dmid,"0");
- i_dmid = atoi(c_dmid);
-
- 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;
- }
- ALOGV("%s Dolby device manufacturer id is:%d",__func__,i_dmid);
- ret = mixer_ctl_set_value(ctl, 0, i_dmid);
-
- return ret;
-}
-#endif /* DS1_DOLBY_DDP_ENABLED */
-
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 72f8642..fb428db 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -155,14 +155,31 @@
void audio_extn_compr_cap_deinit();
#endif
-#ifndef DS1_DOLBY_DDP_ENABLED
-#define audio_extn_dolby_is_supported_format(format) (0)
-#define audio_extn_dolby_get_snd_codec_id(format) (0)
-#define audio_extn_dolby_set_DMID(adev) (0)
+#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED)
+void audio_extn_dolby_set_dmid(struct audio_device *adev);
#else
-bool audio_extn_dolby_is_supported_format(audio_format_t format);
-int audio_extn_dolby_get_snd_codec_id(audio_format_t format);
-int audio_extn_dolby_set_DMID(struct audio_device *adev);
+#define audio_extn_dolby_set_dmid(adev) (0)
+#endif
+
+#ifndef DS1_DOLBY_DDP_ENABLED
+#define audio_extn_dolby_set_endpoint() (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(format) (0)
+#define audio_extn_dolby_send_ddp_endp_params(adev) (0)
+#else
+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);
+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);
#endif
#ifndef HFP_ENABLED
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
new file mode 100644
index 0000000..bcc7381
--- /dev/null
+++ b/hal/audio_extn/dolby.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "audio_hw_dolby"
+/*#define LOG_NDEBUG 0*/
+#define LOG_NDDEBUG 0
+
+#include <errno.h>
+#include <cutils/properties.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <cutils/str_parms.h>
+#include <cutils/log.h>
+
+#include "audio_hw.h"
+#include "platform.h"
+#include "platform_api.h"
+#include "audio_extn.h"
+#include "sound/compress_params.h"
+
+#ifdef DS1_DOLBY_DDP_ENABLED
+
+#define AUDIO_PARAMETER_DDP_DEV "ddp_device"
+#define AUDIO_PARAMETER_DDP_CH_CAP "ddp_chancap"
+#define AUDIO_PARAMETER_DDP_MAX_OUT_CHAN "ddp_maxoutchan"
+#define AUDIO_PARAMETER_DDP_OUT_MODE "ddp_outmode"
+#define AUDIO_PARAMETER_DDP_OUT_LFE_ON "ddp_outlfeon"
+#define AUDIO_PARAMETER_DDP_COMP_MODE "ddp_compmode"
+#define AUDIO_PARAMETER_DDP_STEREO_MODE "ddp_stereomode"
+
+#define PARAM_ID_MAX_OUTPUT_CHANNELS 0x00010DE2
+#define PARAM_ID_CTL_RUNNING_MODE 0x0
+#define PARAM_ID_CTL_ERROR_CONCEAL 0x00010DE3
+#define PARAM_ID_CTL_ERROR_MAX_RPTS 0x00010DE4
+#define PARAM_ID_CNV_ERROR_CONCEAL 0x00010DE5
+#define PARAM_ID_CTL_SUBSTREAM_SELECT 0x00010DE6
+#define PARAM_ID_CTL_INPUT_MODE 0x0
+#define PARAM_ID_OUT_CTL_OUTMODE 0x00010DE0
+#define PARAM_ID_OUT_CTL_OUTLFE_ON 0x00010DE1
+#define PARAM_ID_OUT_CTL_COMPMODE 0x00010D74
+#define PARAM_ID_OUT_CTL_STEREO_MODE 0x00010D76
+#define PARAM_ID_OUT_CTL_DUAL_MODE 0x00010D75
+#define PARAM_ID_OUT_CTL_DRCSCALE_HIGH 0x00010D7A
+#define PARAM_ID_OUT_CTL_DRCSCALE_LOW 0x00010D79
+#define PARAM_ID_OUT_CTL_OUT_PCMSCALE 0x00010D78
+#define PARAM_ID_OUT_CTL_MDCT_BANDLIMIT 0x00010DE7
+#define PARAM_ID_OUT_CTL_DRC_SUPPRESS 0x00010DE8
+
+/* DS1-DDP Endp Params */
+#define DDP_ENDP_NUM_PARAMS 17
+#define DDP_ENDP_NUM_DEVICES 22
+static int ddp_endp_params_id[DDP_ENDP_NUM_PARAMS] = {
+ PARAM_ID_MAX_OUTPUT_CHANNELS, PARAM_ID_CTL_RUNNING_MODE,
+ PARAM_ID_CTL_ERROR_CONCEAL, PARAM_ID_CTL_ERROR_MAX_RPTS,
+ PARAM_ID_CNV_ERROR_CONCEAL, PARAM_ID_CTL_SUBSTREAM_SELECT,
+ PARAM_ID_CTL_INPUT_MODE, PARAM_ID_OUT_CTL_OUTMODE,
+ PARAM_ID_OUT_CTL_OUTLFE_ON, PARAM_ID_OUT_CTL_COMPMODE,
+ PARAM_ID_OUT_CTL_STEREO_MODE, PARAM_ID_OUT_CTL_DUAL_MODE,
+ PARAM_ID_OUT_CTL_DRCSCALE_HIGH, PARAM_ID_OUT_CTL_DRCSCALE_LOW,
+ PARAM_ID_OUT_CTL_OUT_PCMSCALE, PARAM_ID_OUT_CTL_MDCT_BANDLIMIT,
+ PARAM_ID_OUT_CTL_DRC_SUPPRESS
+};
+
+static struct ddp_endp_params {
+ int device;
+ int dev_ch_cap;
+ int param_val[DDP_ENDP_NUM_PARAMS];
+ bool is_param_valid[DDP_ENDP_NUM_PARAMS];
+} ddp_endp_params[DDP_ENDP_NUM_DEVICES] = {
+ {AUDIO_DEVICE_OUT_EARPIECE, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 } },
+ {AUDIO_DEVICE_OUT_SPEAKER, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_WIRED_HEADSET, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_WIRED_HEADPHONE, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL, 6,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_AUX_DIGITAL, 8,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_USB_ACCESSORY, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_USB_DEVICE, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_FM, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_FM_TX, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_ANC_HEADSET, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_ANC_HEADPHONE, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+ {AUDIO_DEVICE_OUT_PROXY, 2,
+ {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
+};
+
+int update_ddp_endp_table(int device, int dev_ch_cap, int param_id,
+ int param_val)
+{
+ int idx = 0;
+ int param_idx = 0;
+ ALOGV("%s: dev 0x%x dev_ch_cap %d param_id 0x%x param_val %d",
+ __func__, device, dev_ch_cap , param_id, param_val);
+
+ for(idx=0; idx<DDP_ENDP_NUM_DEVICES; idx++) {
+ if(ddp_endp_params[idx].device == device) {
+ if(ddp_endp_params[idx].dev_ch_cap == dev_ch_cap) {
+ break;
+ }
+ }
+ }
+
+ if(idx>=DDP_ENDP_NUM_DEVICES) {
+ ALOGE("%s: device not available in DDP endp config table", __func__);
+ return -EINVAL;
+ }
+
+ for(param_idx=0; param_idx<DDP_ENDP_NUM_PARAMS; param_idx++) {
+ if (ddp_endp_params_id[param_idx] == param_id) {
+ break;
+ }
+ }
+
+ if(param_idx>=DDP_ENDP_NUM_PARAMS) {
+ ALOGE("param not available in DDP endp config table");
+ return -EINVAL;
+ }
+
+ ALOGV("ddp_endp_params[%d].param_val[%d] = %d", idx, param_idx, param_val);
+ ddp_endp_params[idx].param_val[param_idx] = param_val;
+ return 0;
+}
+
+void send_ddp_endp_params_stream(struct stream_out *out,
+ int device, int dev_ch_cap,
+ bool set_cache)
+{
+ int idx, i;
+ int ddp_endp_params_data[2*DDP_ENDP_NUM_PARAMS + 1];
+ int length = 0;
+ for(idx=0; idx<DDP_ENDP_NUM_DEVICES; idx++) {
+ if(ddp_endp_params[idx].device & device) {
+ if(ddp_endp_params[idx].dev_ch_cap == dev_ch_cap) {
+ break;
+ }
+ }
+ }
+ if(idx>=DDP_ENDP_NUM_DEVICES) {
+ ALOGE("device not available in DDP endp config table");
+ return;
+ }
+
+ length += 1; /* offset 0 is for num of parameter. increase offset by 1 */
+ for (i=0; i<DDP_ENDP_NUM_PARAMS; i++) {
+ if(ddp_endp_params[idx].is_param_valid[i]) {
+ ddp_endp_params_data[length++] = ddp_endp_params_id[i];
+ ddp_endp_params_data[length++] = ddp_endp_params[idx].param_val[i];
+ }
+ }
+ ddp_endp_params_data[0] = (length-1)/2;
+ if(length) {
+ char mixer_ctl_name[128];
+ struct audio_device *adev = out->dev;
+ struct mixer_ctl *ctl;
+ int pcm_device_id = platform_get_pcm_device_id(out->usecase,
+ PCM_PLAYBACK);
+ snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
+ "Audio Stream %d Dec Params", pcm_device_id);
+ 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;
+ }
+ mixer_ctl_set_array(ctl, ddp_endp_params_data, length);
+ }
+ return;
+}
+
+void send_ddp_endp_params(struct audio_device *adev,
+ int ddp_dev, int dev_ch_cap)
+{
+ struct listnode *node;
+ struct audio_usecase *usecase;
+
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if ((usecase->type == PCM_PLAYBACK) &&
+ (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_EAC3))) {
+ send_ddp_endp_params_stream(usecase->stream.out, ddp_dev,
+ dev_ch_cap, false /* set cache */);
+ }
+ }
+}
+
+void audio_extn_dolby_send_ddp_endp_params(struct audio_device *adev)
+{
+ struct listnode *node;
+ struct audio_usecase *usecase;
+ list_for_each(node, &adev->usecase_list) {
+ usecase = node_to_item(node, struct audio_usecase, list);
+ if ((usecase->type == PCM_PLAYBACK) &&
+ (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_EAC3))) {
+ send_ddp_endp_params_stream(usecase->stream.out, usecase->devices,
+ usecase->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ?
+ adev->cur_hdmi_channels : 2, false /* set cache */);
+ }
+ }
+}
+
+void audio_extn_ddp_set_parameters(struct audio_device *adev,
+ struct str_parms *parms)
+{
+ int ddp_dev, dev_ch_cap;
+ int val, ret;
+ char value[32]={0};
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_DEV, value,
+ sizeof(value));
+ if (ret >= 0) {
+ ddp_dev = atoi(value);
+ if (!(AUDIO_DEVICE_OUT_ALL & ddp_dev))
+ return;
+ } else
+ return;
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_CH_CAP, value,
+ sizeof(value));
+ if (ret >= 0) {
+ dev_ch_cap = atoi(value);
+ if ((dev_ch_cap != 2) && (dev_ch_cap != 6) && (dev_ch_cap != 8))
+ return;
+ } else
+ return;
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_MAX_OUT_CHAN, value,
+ sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ update_ddp_endp_table(ddp_dev, dev_ch_cap,
+ PARAM_ID_MAX_OUTPUT_CHANNELS, val);
+ }
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_OUT_MODE, value,
+ sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ update_ddp_endp_table(ddp_dev, dev_ch_cap,
+ PARAM_ID_OUT_CTL_OUTMODE, val);
+ }
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_OUT_LFE_ON, value,
+ sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ update_ddp_endp_table(ddp_dev, dev_ch_cap,
+ PARAM_ID_OUT_CTL_OUTLFE_ON, val);
+ }
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_COMP_MODE, value,
+ sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ update_ddp_endp_table(ddp_dev, dev_ch_cap,
+ PARAM_ID_OUT_CTL_COMPMODE, val);
+ }
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_STEREO_MODE, value,
+ sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ update_ddp_endp_table(ddp_dev, dev_ch_cap,
+ PARAM_ID_OUT_CTL_STEREO_MODE, val);
+ }
+
+ send_ddp_endp_params(adev, ddp_dev, dev_ch_cap);
+}
+
+int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev,
+ struct stream_out *out,
+ audio_format_t format)
+{
+ int id = 0;
+
+ switch (format) {
+ case AUDIO_FORMAT_AC3:
+ id = SND_AUDIOCODEC_AC3;
+ send_ddp_endp_params_stream(out, out->devices,
+ out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ?
+ adev->cur_hdmi_channels : 2, true /* set_cache */);
+#ifndef DS1_DOLBY_DAP_ENABLED
+ audio_extn_dolby_set_dmid(adev);
+#endif
+ break;
+ case AUDIO_FORMAT_EAC3:
+ id = SND_AUDIOCODEC_EAC3;
+ send_ddp_endp_params_stream(out, out->devices,
+ out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ?
+ adev->cur_hdmi_channels : 2, true /* set_cache */);
+#ifndef DS1_DOLBY_DAP_ENABLED
+ audio_extn_dolby_set_dmid(adev);
+#endif
+ break;
+ default:
+ ALOGE("%s: Unsupported audio format :%x", __func__, format);
+ }
+
+ return id;
+}
+
+bool audio_extn_is_dolby_format(audio_format_t format)
+{
+ if (format == AUDIO_FORMAT_AC3 ||
+ format == AUDIO_FORMAT_EAC3)
+ return true;
+ else
+ return false;
+}
+
+#endif /* DS1_DOLBY_DDP_ENABLED */
+
+#ifdef DS1_DOLBY_DAP_ENABLED
+void audio_extn_dolby_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;
+
+ 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;
+ }
+ ret = mixer_ctl_set_value(ctl, 0, endpoint);
+ if (ret)
+ ALOGE("%s: Dolby set endpint cannot be set error:%d",__func__, ret);
+
+ return;
+}
+#endif /* DS1_DOLBY_DAP_ENABLED */
+
+
+#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED)
+void audio_extn_dolby_set_dmid(struct audio_device *adev)
+{
+ struct listnode *node;
+ struct audio_usecase *usecase;
+ struct mixer_ctl *ctl;
+ const char *mixer_ctl_name = "DS1 Security";
+ char c_dmid[128] = {0};
+ int i_dmid, 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))
+ send = true;
+ }
+ if (!send)
+ return;
+
+ property_get("dmid",c_dmid,"0");
+ i_dmid = atoi(c_dmid);
+
+ 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;
+ }
+ ALOGV("%s Dolby device manufacturer id is:%d",__func__,i_dmid);
+ ret = mixer_ctl_set_value(ctl, 0, i_dmid);
+ if (ret)
+ ALOGE("%s: Dolby DMID cannot be set error:%d",__func__, ret);
+
+ return;
+}
+#endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 61e291d..1b008db 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2,7 +2,7 @@
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
- * Copyright (C) 2013-2014 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -152,8 +152,55 @@
static unsigned int audio_device_ref_count;
static int set_voice_volume_l(struct audio_device *adev, float volume);
-static uint32_t get_offload_buffer_size();
-static int set_gapless_mode(struct audio_device *adev);
+
+/* Read offload buffer size from a property.
+ * If value is not power of 2 round it to
+ * power of 2.
+ */
+static uint32_t get_offload_buffer_size()
+{
+ char value[PROPERTY_VALUE_MAX] = {0};
+ uint32_t fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE;
+ if((property_get("audio.offload.buffer.size.kb", value, "")) &&
+ atoi(value)) {
+ fragment_size = atoi(value) * 1024;
+ //ring buffer size needs to be 4k aligned.
+ CHECK(!(fragment_size * COMPRESS_OFFLOAD_NUM_FRAGMENTS % 4096));
+ }
+ if(fragment_size < MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE)
+ fragment_size = MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE;
+ else if(fragment_size > MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE)
+ fragment_size = MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE;
+ ALOGVV("%s: fragment_size %d", __func__, fragment_size);
+ return fragment_size;
+}
+
+static int check_and_set_gapless_mode(struct audio_device *adev) {
+
+
+ char value[PROPERTY_VALUE_MAX] = {0};
+ bool gapless_enabled = false;
+ const char *mixer_ctl_name = "Compress Gapless Playback";
+ struct mixer_ctl *ctl;
+
+ ALOGV("%s:", __func__);
+ property_get("audio.offload.gapless.enabled", value, NULL);
+ gapless_enabled = atoi(value) || !strncmp("true", value, 4);
+
+ 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, gapless_enabled) < 0) {
+ ALOGE("%s: Could not set gapless mode %d",
+ __func__, gapless_enabled);
+ return -EINVAL;
+ }
+ return 0;
+}
static bool is_supported_format(audio_format_t format)
{
@@ -199,6 +246,10 @@
else
snd_device = usecase->out_snd_device;
+#ifdef DS1_DOLBY_DAP_ENABLED
+ audio_extn_dolby_set_dmid(adev);
+ audio_extn_dolby_set_endpoint(adev);
+#endif
strcpy(mixer_path, use_case_table[usecase->id]);
platform_add_backend_name(mixer_path, snd_device);
ALOGV("%s: apply mixer path: %s", __func__, mixer_path);
@@ -831,6 +882,7 @@
{
struct stream_out *out = (struct stream_out *) context;
struct listnode *item;
+ int ret = 0;
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
set_sched_policy(0, SP_FOREGROUND);
@@ -880,8 +932,14 @@
event = STREAM_CBK_EVENT_WRITE_READY;
break;
case OFFLOAD_CMD_PARTIAL_DRAIN:
- compress_next_track(out->compr);
- compress_partial_drain(out->compr);
+ ret = compress_next_track(out->compr);
+ if(ret == 0)
+ compress_partial_drain(out->compr);
+ else if(ret == -ETIMEDOUT)
+ compress_drain(out->compr);
+ else
+ ALOGE("%s: Next track returned error %d",__func__, ret);
+
send_callback = true;
event = STREAM_CBK_EVENT_DRAIN_READY;
break;
@@ -1116,6 +1174,11 @@
if (out->offload_callback)
compress_nonblock(out->compr, out->non_blocking);
+#ifdef DS1_DOLBY_DDP_ENABLED
+ if (audio_extn_is_dolby_format(out->format))
+ audio_extn_dolby_send_ddp_endp_params(adev);
+#endif
+
if (adev->visualizer_start_output != NULL)
adev->visualizer_start_output(out->handle, out->pcm_device_id);
if (adev->offload_effects_start_output != NULL)
@@ -2053,7 +2116,7 @@
goto error_open;
}
if (!is_supported_format(config->offload_info.format) &&
- !audio_extn_dolby_is_supported_format(config->offload_info.format)) {
+ !audio_extn_is_dolby_format(config->offload_info.format)) {
ALOGE("%s: Unsupported audio format", __func__);
ret = -EINVAL;
goto error_open;
@@ -2076,9 +2139,10 @@
out->stream.drain = out_drain;
out->stream.flush = out_flush;
- if (audio_extn_dolby_is_supported_format(config->offload_info.format))
+ if (audio_extn_is_dolby_format(config->offload_info.format))
out->compr_config.codec->id =
- audio_extn_dolby_get_snd_codec_id(config->offload_info.format);
+ audio_extn_dolby_get_snd_codec_id(adev, out,
+ config->offload_info.format);
else
out->compr_config.codec->id =
get_snd_codec_id(config->offload_info.format);
@@ -2103,18 +2167,8 @@
ALOGV("%s: offloaded output offload_info version %04x bit rate %d",
__func__, config->offload_info.version,
config->offload_info.bit_rate);
-
- if (audio_extn_dolby_is_supported_format(out->format)) {
- ret = audio_extn_dolby_set_DMID(adev);
- if (ret != 0) {
- ALOGE("%s: Dolby DMID cannot be set error:%d",
- __func__, ret);
- goto error_open;
- }
- }
-
//Decide if we need to use gapless mode by default
- set_gapless_mode(adev);
+ check_and_set_gapless_mode(adev);
} else if (out->flags & AUDIO_OUTPUT_FLAG_INCALL_MUSIC) {
ret = voice_check_and_set_incall_music_usecase(adev, out);
@@ -2650,55 +2704,6 @@
return 0;
}
-/* Read offload buffer size from a property.
- * If value is not power of 2 round it to
- * power of 2.
- */
-static uint32_t get_offload_buffer_size()
-{
- char value[PROPERTY_VALUE_MAX] = {0};
- uint32_t fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE;
- if((property_get("audio.offload.buffer.size.kb", value, "")) &&
- atoi(value)) {
- fragment_size = atoi(value) * 1024;
- //ring buffer size needs to be 4k aligned.
- CHECK(!(fragment_size * COMPRESS_OFFLOAD_NUM_FRAGMENTS % 4096));
- }
- if(fragment_size < MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE)
- fragment_size = MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE;
- else if(fragment_size > MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE)
- fragment_size = MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE;
- ALOGVV("%s: fragment_size %d", __func__, fragment_size);
- return fragment_size;
-}
-
-static int set_gapless_mode(struct audio_device *adev) {
-
-
- char value[PROPERTY_VALUE_MAX] = {0};
- bool gapless_enabled = false;
- const char *mixer_ctl_name = "Compress Gapless Playback";
- struct mixer_ctl *ctl;
-
- ALOGV("%s:", __func__);
- property_get("audio.offload.gapless.enabled", value, NULL);
- gapless_enabled = atoi(value) || !strncmp("true", value, 4);
-
- 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, gapless_enabled) < 0) {
- ALOGE("%s: Could not set gapless mode %d",
- __func__, gapless_enabled);
- return -EINVAL;
- }
- return 0;
-
-}
static struct hw_module_methods_t hal_module_methods = {
.open = adev_open,
};
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 298c60d..c1ba595 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -391,6 +391,16 @@
return device_id;
}
+int platform_get_snd_device_index(char *snd_device_index_name)
+{
+ return -ENODEV;
+}
+
+int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id)
+{
+ return -ENODEV;
+}
+
int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
{
struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 807ede4..a25991f 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2,7 +2,7 @@
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
- * Copyright (C) 2013-2014 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -222,7 +222,7 @@
};
/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
-static const int acdb_device_table[SND_DEVICE_MAX] = {
+static int acdb_device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_NONE] = -1,
[SND_DEVICE_OUT_HANDSET] = 7,
[SND_DEVICE_OUT_SPEAKER] = 14,
@@ -240,7 +240,7 @@
[SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
[SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
[SND_DEVICE_OUT_AFE_PROXY] = 0,
- [SND_DEVICE_OUT_USB_HEADSET] = 0,
+ [SND_DEVICE_OUT_USB_HEADSET] = 45,
[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14,
[SND_DEVICE_OUT_TRANSMISSION_FM] = 0,
[SND_DEVICE_OUT_ANC_HEADSET] = 26,
@@ -294,6 +294,84 @@
[SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = 102,
};
+struct snd_device_index {
+ char name[100];
+ unsigned int index;
+};
+
+#define TO_NAME_INDEX(X) #X, X
+
+/* Used to get index from parsed sting */
+struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = {
+ {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_AFE_PROXY)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_USB_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_TRANSMISSION_FM)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_FB_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_ANC_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_HANDSET)},
+ {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC_FLUENCE)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_QMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_USB_HEADSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_FM)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_AANC_HANDSET_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_QUAD_MIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_STEREO_DMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_STEREO_DMIC)},
+ {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)},
+};
+
#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
@@ -572,6 +650,9 @@
my_data->acdb_init();
}
+ /* Initialize ACDB ID's */
+ platform_info_init();
+
/* If platform is apq8084 and baseband is MDM, load CSD Client specific
* symbols. Voice call is handled by MDM and apps processor talks to
* MDM through CSD Client
@@ -669,6 +750,46 @@
return device_id;
}
+int platform_get_snd_device_index(char *snd_device_index_name)
+{
+ int ret = 0;
+ int i;
+
+ if (snd_device_index_name == NULL) {
+ ALOGE("%s: snd_device_index_name is NULL", __func__);
+ ret = -ENODEV;
+ goto done;
+ }
+
+ for (i=0; i < SND_DEVICE_MAX; i++) {
+ if(strcmp(snd_device_name_index[i].name, snd_device_index_name) == 0) {
+ ret = snd_device_name_index[i].index;
+ goto done;
+ }
+ }
+ ALOGE("%s: Could not find index for snd_device_index_name = %s",
+ __func__, snd_device_index_name);
+ ret = -ENODEV;
+done:
+ return ret;
+}
+
+int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id)
+{
+ 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;
+ }
+
+ acdb_device_table[snd_device] = acdb_id;
+done:
+ return ret;
+}
+
int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
{
struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index bb1f787..ca8469a 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -147,7 +147,7 @@
* the buffer size of an input/output stream
*/
#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
-#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 8
+#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4
#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 4096ef0..a5f5074 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -17,8 +17,8 @@
* limitations under the License.
*/
-#ifndef QCOM_AUDIO_PLATFORM_API_H
-#define QCOM_AUDIO_PLATFORM_API_H
+#ifndef AUDIO_PLATFORM_API_H
+#define AUDIO_PLATFORM_API_H
void *platform_init(struct audio_device *adev);
void platform_deinit(void *platform);
@@ -27,6 +27,8 @@
char *device_name);
void platform_add_backend_name(char *mixer_path, snd_device_t snd_device);
int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type);
+int platform_get_snd_device_index(char *snd_device_index_name);
+int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id);
int platform_send_audio_calibration(void *platform, snd_device_t snd_device);
int platform_switch_voice_call_device_pre(void *platform);
int platform_switch_voice_call_device_post(void *platform,
@@ -57,4 +59,7 @@
bool platform_listen_update_status(snd_device_t snd_device);
-#endif // QCOM_AUDIO_PLATFORM_API_H
+/* From platform_info_parser.c */
+int platform_info_init(void);
+
+#endif // AUDIO_PLATFORM_API_H
diff --git a/hal/platform_info.c b/hal/platform_info.c
new file mode 100644
index 0000000..8f56107
--- /dev/null
+++ b/hal/platform_info.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2014, 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 "platform_info"
+#define LOG_NDDEBUG 0
+
+#include <errno.h>
+#include <stdio.h>
+#include <expat.h>
+#include <cutils/log.h>
+#include <audio_hw.h>
+#include "platform_api.h"
+#include <platform.h>
+
+#define PLATFORM_INFO_XML_PATH "/system/etc/audio_platform_info.xml"
+#define BUF_SIZE 1024
+
+static void process_device(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 %s not found, no ACDB ID set!",
+ __func__, attr[1], PLATFORM_INFO_XML_PATH);
+ goto done;
+ }
+
+ if (strcmp(attr[2], "acdb_id") != 0) {
+ ALOGE("%s: Device %s in %s has no acdb_id, no ACDB ID set!",
+ __func__, attr[1], PLATFORM_INFO_XML_PATH);
+ goto done;
+ }
+
+ if(platform_set_snd_device_acdb_id(index, atoi((char *)attr[3])) < 0) {
+ ALOGE("%s: Device %s in %s, ACDB ID %d was not set!",
+ __func__, attr[1], PLATFORM_INFO_XML_PATH, atoi((char *)attr[3]));
+ goto done;
+ }
+
+done:
+ return;
+}
+
+static void start_tag(void *userdata, const XML_Char *tag_name,
+ const XML_Char **attr)
+{
+ const XML_Char *attr_name = NULL;
+ const XML_Char *attr_value = NULL;
+ unsigned int i;
+
+ if (strcmp(tag_name, "device") == 0)
+ process_device(attr);
+
+ return;
+}
+
+static void end_tag(void *userdata, const XML_Char *tag_name)
+{
+
+}
+
+int platform_info_init(void)
+{
+ XML_Parser parser;
+ FILE *file;
+ int ret = 0;
+ int bytes_read;
+ void *buf;
+
+ file = fopen(PLATFORM_INFO_XML_PATH, "r");
+ if (!file) {
+ ALOGD("%s: Failed to open %s, using defaults.",
+ __func__, PLATFORM_INFO_XML_PATH);
+ ret = -ENODEV;
+ goto done;
+ }
+
+ parser = XML_ParserCreate(NULL);
+ if (!parser) {
+ ALOGE("%s: Failed to create XML parser!", __func__);
+ ret = -ENODEV;
+ goto err_close_file;
+ }
+
+ XML_SetElementHandler(parser, start_tag, end_tag);
+
+ while (1) {
+ buf = XML_GetBuffer(parser, BUF_SIZE);
+ if (buf == NULL) {
+ ALOGE("%s: XML_GetBuffer failed", __func__);
+ ret = -ENOMEM;
+ goto err_free_parser;
+ }
+
+ bytes_read = fread(buf, 1, BUF_SIZE, file);
+ if (bytes_read < 0) {
+ ALOGE("%s: fread failed, bytes read = %d", __func__, bytes_read);
+ ret = bytes_read;
+ goto err_free_parser;
+ }
+
+ if (XML_ParseBuffer(parser, bytes_read,
+ bytes_read == 0) == XML_STATUS_ERROR) {
+ ALOGE("%s: XML_ParseBuffer failed, for %s",
+ __func__, PLATFORM_INFO_XML_PATH);
+ ret = -EINVAL;
+ goto err_free_parser;
+ }
+
+ if (bytes_read == 0)
+ break;
+ }
+
+err_free_parser:
+ XML_ParserFree(parser);
+err_close_file:
+ fclose(file);
+done:
+ return ret;
+}
diff --git a/hal/voice.c b/hal/voice.c
index 74d1978..8783f01 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -2,7 +2,7 @@
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
- * Copyright (C) 2013-2014 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -424,6 +424,7 @@
adev->voice.tty_mode = TTY_MODE_OFF;
adev->voice.volume = 1.0f;
adev->voice.mic_mute = false;
+ adev->voice.voice_device_set = false;
for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
adev->voice.session[i].pcm_rx = NULL;
adev->voice.session[i].pcm_tx = NULL;
diff --git a/hal/voice.h b/hal/voice.h
index 38b304e..a7733b1 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -60,6 +60,7 @@
int tty_mode;
bool mic_mute;
float volume;
+ bool voice_device_set;
};
enum {
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index d119ff5..5c87c9c 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -2,7 +2,7 @@
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
- * Copyright (C) 2013-2014 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,6 +60,7 @@
struct pcm *pcm_tx;
struct stream_out *out_stream;
int ref_count;
+ int out_stream_count;
};
#define MODE_IS127 0x2
@@ -76,12 +77,14 @@
#define AUDIO_PARAMETER_KEY_VOIP_DTX_MODE "dtx_on"
#define AUDIO_PARAMETER_VALUE_VOIP_TRUE "true"
#define AUDIO_PARAMETER_KEY_VOIP_CHECK "voip_flag"
+#define AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT "voip_out_stream_count"
static struct voip_data voip_data = {
.pcm_rx = NULL,
.pcm_tx = NULL,
.out_stream = NULL,
- .ref_count = 0
+ .ref_count = 0,
+ .out_stream_count = 0
};
static int voip_set_volume(struct audio_device *adev, int volume);
@@ -453,6 +456,22 @@
return ret;
}
+void voice_extn_compress_voip_get_parameters(const struct audio_device *adev,
+ struct str_parms *query,
+ struct str_parms *reply)
+{
+ int ret;
+ char value[32]={0};
+ char *str = NULL;
+
+ ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
+ value, sizeof(value));
+ if (ret >= 0) {
+ str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_OUT_STREAM_COUNT,
+ voip_data.out_stream_count);
+ }
+}
+
void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
struct str_parms *query,
struct str_parms *reply)
@@ -554,6 +573,7 @@
ret = voip_stop_call(adev);
voip_data.out_stream = NULL;
+ voip_data.out_stream_count--;
ALOGV("%s: exit: status(%d)", __func__, ret);
return ret;
@@ -574,6 +594,7 @@
out->config = pcm_config_voip_nb;
voip_data.out_stream = out;
+ voip_data.out_stream_count++;
ret = voip_set_mode(out->dev, out->format);
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index 12fce09..b8bc2df 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -2,7 +2,7 @@
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
- * Copyright (C) 2013-2014 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -143,6 +143,7 @@
struct voice_session *session = NULL;
int fd = 0;
int ret = 0;
+ bool is_in_call = false;
ALOGD("%s: enter:", __func__);
@@ -202,6 +203,10 @@
ALOGE("%s: voice_end_call() failed for usecase: %d\n",
__func__, usecase_id);
} else {
+ voice_extn_is_in_call(adev, &is_in_call);
+ if (!is_in_call) {
+ adev->voice.voice_device_set = false;
+ }
session->state.current = session->state.new;
}
break;
@@ -274,6 +279,7 @@
struct voice_session *session = NULL;
int i = 0;
bool is_in_call;
+ int no_of_calls_active = 0;
for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
if (vsid == adev->voice.session[i].vsid) {
@@ -282,17 +288,27 @@
}
}
+ for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
+ if (CALL_INACTIVE != adev->voice.session[i].state.current)
+ no_of_calls_active++;
+ }
+
+ /* When there is only one call active, wait for audio policy manager to set
+ * the mode to AUDIO_MODE_NORMAL and trigger routing to end the last call.
+ */
+ if (no_of_calls_active == 1 && call_state == CALL_INACTIVE)
+ return 0;
+
if (session) {
session->state.new = call_state;
voice_extn_is_in_call(adev, &is_in_call);
- ALOGD("%s is_in_call:%d mode:%d\n", __func__, is_in_call, adev->mode);
+ ALOGD("%s is_in_call:%d voice_device_set:%d, mode:%d\n",
+ __func__, is_in_call, adev->voice.voice_device_set, adev->mode);
/* Dont start voice call before device routing for voice usescases has
* occured, otherwise voice calls will be started unintendedly on
* speaker.
*/
- if (is_in_call ||
- (adev->mode == AUDIO_MODE_IN_CALL &&
- adev->primary_output->devices != AUDIO_DEVICE_OUT_SPEAKER)) {
+ if (is_in_call || adev->voice.voice_device_set) {
/* Device routing is not triggered for voice calls on the subsequent
* subs, Hence update the call states if voice call is already
* active on other sub.
@@ -377,6 +393,7 @@
* udpated.
*/
ALOGV("%s: enter:", __func__);
+ adev->voice.voice_device_set = true;
return update_calls(adev);
}
@@ -488,6 +505,8 @@
}
str_parms_add_str(reply, AUDIO_PARAMETER_KEY_ALL_CALL_STATES, value);
}
+ voice_extn_compress_voip_get_parameters(adev, query, reply);
+
ALOGV("%s: exit: returns \"%s\"", __func__, str_parms_to_str(reply));
}
diff --git a/hal/voice_extn/voice_extn.h b/hal/voice_extn/voice_extn.h
index adee939..f7d20e4 100644
--- a/hal/voice_extn/voice_extn.h
+++ b/hal/voice_extn/voice_extn.h
@@ -2,7 +2,7 @@
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a contribution.
*
- * Copyright (C) 2013-2014 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -130,6 +130,9 @@
snd_device_t *in_snd_device);
int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
struct str_parms *parms);
+void voice_extn_compress_voip_get_parameters(const struct audio_device *adev,
+ struct str_parms *query,
+ struct str_parms *reply);
void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
struct str_parms *query,
@@ -166,7 +169,7 @@
return -ENOSYS;
}
-static int voice_extn_compress_voip_out_get_buffer_size(struct audio_stream *stream)
+static int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *stream)
{
ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
return -ENOSYS;
@@ -217,6 +220,13 @@
return -ENOSYS;
}
+static void voice_extn_compress_voip_get_parameters(const struct audio_device *adev,
+ struct str_parms *query,
+ struct str_parms *reply)
+{
+ ALOGE("%s: COMPRESS_VOIP_ENABLED is not defined", __func__);
+}
+
static void voice_extn_compress_voip_out_get_parameters(struct stream_out *out,
struct str_parms *query,
struct str_parms *reply)
diff --git a/hal_mpq/audio_stream_out.c b/hal_mpq/audio_stream_out.c
index 7ef3255..454b1d6 100644
--- a/hal_mpq/audio_stream_out.c
+++ b/hal_mpq/audio_stream_out.c
@@ -1051,23 +1051,19 @@
}
/*TODO: do we need to apply volume at the session open*/
-static int set_compress_volume(struct alsa_handle *handle, int left, int right)
+static int set_compress_volume(struct alsa_handle *handle, float left, float right)
{
struct audio_device *adev = handle->out->dev;
struct mixer_ctl *ctl;
int volume[2];
- char mixer_ctl_name[44]; // max length of name is 44 as defined
- char device_id[STRING_LENGTH_OF_INTEGER+1];
+ char mixer_ctl_name[MIXER_PATH_MAX_LENGTH];
+ ALOGV("%s:setting volume l %f r %f ", __func__, left, right);
memset(mixer_ctl_name, 0, sizeof(mixer_ctl_name));
- strlcpy(mixer_ctl_name, "Compress Playback Volume", sizeof(mixer_ctl_name));
-
- memset(device_id, 0, sizeof(device_id));
- snprintf(device_id, "%d", handle->device_id, sizeof(device_id));
-
- strlcat(mixer_ctl_name, device_id, sizeof(mixer_ctl_name));
+ snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
+ "Compress Playback %d Volume", handle->device_id);
ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
if (!ctl) {
@@ -1075,8 +1071,8 @@
__func__, mixer_ctl_name);
return -EINVAL;
}
- volume[0] = (int)(left * COMPRESS_PLAYBACK_VOLUME_MAX);
- volume[1] = (int)(right * COMPRESS_PLAYBACK_VOLUME_MAX);
+ volume[0] = (int)(left * (float) COMPRESS_PLAYBACK_VOLUME_MAX);
+ volume[1] = (int)(right * (float) COMPRESS_PLAYBACK_VOLUME_MAX);
mixer_ctl_set_array(ctl, volume, sizeof(volume)/sizeof(volume[0]));
return 0;
@@ -1709,8 +1705,8 @@
uc_info->out_snd_device = SND_DEVICE_NONE;
/* This must be called before adding this usecase to the list */
- //if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)
- // check_and_set_hdmi_channels(adev, out->config.channels);
+ if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)
+ check_and_set_hdmi_channels(adev, handle->config.channels);
list_add_tail(&adev->usecase_list, &uc_info->list);
@@ -2105,7 +2101,7 @@
struct alsa_handle *handle;
struct audio_device *adev = out->dev;
int ret = -ENOSYS;
- ALOGV("%s", __func__);
+ ALOGV("%s:setting volume l %f r %f ", __func__, left, right);
pthread_mutex_lock(&out->lock);
list_for_each(node, &out->session_list) {
handle = node_to_item(node, struct alsa_handle, list);
@@ -2118,7 +2114,7 @@
out->left_volume = left;
out->right_volume = right;
- //ret = set_compress_volume(handle, left, right);
+ ret = set_compress_volume(handle, left, right);
}
}
pthread_mutex_unlock(&out->lock);
@@ -2139,6 +2135,7 @@
/* TODO:disnable this if ms12 */
if (ret >= 0 && ret < (ssize_t)bytes) {
+ handle->cmd_pending = true;
send_offload_cmd_l(out, OFFLOAD_CMD_WAIT_FOR_BUFFER);
}
return ret;
diff --git a/hal_mpq/mpq8092/platform.c b/hal_mpq/mpq8092/platform.c
index 3c1b4f7..6c50034 100644
--- a/hal_mpq/mpq8092/platform.c
+++ b/hal_mpq/mpq8092/platform.c
@@ -176,6 +176,7 @@
[SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = "speaker-and-anc-headphones",
[SND_DEVICE_OUT_ANC_HANDSET] = "anc-handset",
[SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected",
+ [SND_DEVICE_OUT_SPDIF] = "spdif",
/* Capture sound devices */
[SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@@ -249,6 +250,7 @@
[SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = 26,
[SND_DEVICE_OUT_ANC_HANDSET] = 103,
[SND_DEVICE_OUT_SPEAKER_PROTECTED] = 101,
+ [SND_DEVICE_OUT_SPDIF] = 18,
[SND_DEVICE_IN_HANDSET_MIC] = 4,
[SND_DEVICE_IN_HANDSET_MIC_AEC] = 106,
@@ -607,6 +609,8 @@
strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH);
else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM)
strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH);
+ else if (snd_device == SND_DEVICE_OUT_SPDIF)
+ strlcat(mixer_path, " spdif", MIXER_PATH_MAX_LENGTH);
}
int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
@@ -897,6 +901,8 @@
snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
} else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
snd_device = SND_DEVICE_OUT_HANDSET;
+ } else if (devices & AUDIO_DEVICE_OUT_SPDIF) {
+ snd_device = SND_DEVICE_OUT_SPDIF;
} else {
ALOGE("%s: Unknown device(s) %#x", __func__, devices);
}
diff --git a/hal_mpq/mpq8092/platform.h b/hal_mpq/mpq8092/platform.h
index 2a81df5..562f979 100644
--- a/hal_mpq/mpq8092/platform.h
+++ b/hal_mpq/mpq8092/platform.h
@@ -74,6 +74,7 @@
SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
SND_DEVICE_OUT_ANC_HANDSET,
SND_DEVICE_OUT_SPEAKER_PROTECTED,
+ SND_DEVICE_OUT_SPDIF,
SND_DEVICE_OUT_END,
/*
diff --git a/post_proc/bass_boost.c b/post_proc/bass_boost.c
index c64ba6b..c724b58 100644
--- a/post_proc/bass_boost.c
+++ b/post_proc/bass_boost.c
@@ -239,6 +239,11 @@
ALOGV("%s", __func__);
bass_ctxt->ctl = output->ctl;
ALOGV("output->ctl: %p", output->ctl);
+ if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)))
+ if (bass_ctxt->ctl)
+ offload_bassboost_send_params(bass_ctxt->ctl, bass_ctxt->offload_bass,
+ OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG |
+ OFFLOAD_SEND_BASSBOOST_STRENGTH);
return 0;
}
diff --git a/post_proc/equalizer.c b/post_proc/equalizer.c
index e31d2b9..7c7ced2 100644
--- a/post_proc/equalizer.c
+++ b/post_proc/equalizer.c
@@ -491,6 +491,11 @@
ALOGV("%s: %p", __func__, output->ctl);
eq_ctxt->ctl = output->ctl;
+ if (offload_eq_get_enable_flag(&(eq_ctxt->offload_eq)))
+ if (eq_ctxt->ctl)
+ offload_eq_send_params(eq_ctxt->ctl, eq_ctxt->offload_eq,
+ OFFLOAD_SEND_EQ_ENABLE_FLAG |
+ OFFLOAD_SEND_EQ_BANDS_LEVEL);
return 0;
}
diff --git a/post_proc/reverb.c b/post_proc/reverb.c
index 4fc8c83..d104073 100644
--- a/post_proc/reverb.c
+++ b/post_proc/reverb.c
@@ -236,9 +236,14 @@
void reverb_set_preset(reverb_context_t *context, int16_t preset)
{
+ bool enable;
ALOGV("%s: preset: %d", __func__, preset);
context->next_preset = preset;
offload_reverb_set_preset(&(context->offload_reverb), preset);
+
+ enable = (preset == REVERB_PRESET_NONE) ? false: true;
+ offload_reverb_set_enable_flag(&(context->offload_reverb), enable);
+
if (context->ctl)
offload_reverb_send_params(context->ctl, context->offload_reverb,
OFFLOAD_SEND_REVERB_ENABLE_FLAG |
diff --git a/post_proc/virtualizer.c b/post_proc/virtualizer.c
index 2f0ca6b..e9eb728 100644
--- a/post_proc/virtualizer.c
+++ b/post_proc/virtualizer.c
@@ -237,6 +237,11 @@
ALOGV("%s", __func__);
virt_ctxt->ctl = output->ctl;
+ if (offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt)))
+ if (virt_ctxt->ctl)
+ offload_virtualizer_send_params(virt_ctxt->ctl, virt_ctxt->offload_virt,
+ OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG |
+ OFFLOAD_SEND_VIRTUALIZER_STRENGTH);
return 0;
}