Merge tag 'LA.UM.8.6.r1-02900-89xx.0' of https://source.codeaurora.cn/quic/la/platform/hardware/qcom/audio into HEAD
"LA.UM.8.6.r1-02900-89xx.0"
Change-Id: Idd795b59803a42c331416871be0fcd998b5454c8
diff --git a/Android.mk b/Android.mk
index 7fb0864..997c543 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,3 +1,5 @@
+ifeq ($(call my-dir),$(call project-path-for,qcom-audio))
+
ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916 msm8994 msm8992 msm8909 msm8996 msm8952 msm8937 thorium msm8953 msmgold msm8998 sdm660 sdm845 sdm710 apq8098_latv qcs605 msmnile $(MSMSTEPPE) $(TRINKET) kona,$(TARGET_BOARD_PLATFORM)),)
MY_LOCAL_PATH := $(call my-dir)
@@ -23,3 +25,5 @@
endif
endif
+
+endif
diff --git a/hal/Android.mk b/hal/Android.mk
index 3fcd87e..88e0107 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -95,6 +95,10 @@
LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT)),true)
+ LOCAL_CFLAGS += -DENABLE_EXTENDED_COMPRESS_FORMAT
+endif
+
LOCAL_CFLAGS += -DUSE_VENDOR_EXTN
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_EDID)),true)
@@ -318,28 +322,18 @@
LOCAL_SRC_FILES += audio_extn/bt_hal.c
endif
-ifeq ($(strip $(USE_LIB_PROCESS_GROUP)),true)
LOCAL_SHARED_LIBRARIES := \
liblog \
libcutils \
libtinyalsa \
- libtinycompress_vendor \
+ libhardware \
+ libtinycompress \
libaudioroute \
libdl \
libaudioutils \
libexpat \
libhidltransport \
libprocessgroup
-else
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libcutils \
- libtinyalsa \
- libaudioroute \
- libdl \
- libaudioutils \
- libexpat
-endif
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAP)),true)
LOCAL_CFLAGS += -DQAP_EXTN_ENABLED -Wno-tautological-pointer-compare
@@ -349,10 +343,9 @@
LOCAL_SHARED_LIBRARIES += libqap_wrapper liblog
endif
-ifneq ($(strip $(TARGET_USES_AOSP_FOR_AUDIO)),true)
- LOCAL_SHARED_LIBRARIES += libtinycompress_vendor
-else
- LOCAL_SHARED_LIBRARIES += libtinycompress
+ifneq ($(strip $(AUDIO_FEATURE_ENABLED_EXT_AMPLIFIER)),false)
+ LOCAL_CFLAGS += -DEXT_AMPLIFIER_ENABLED
+ LOCAL_SRC_FILES += audio_extn/audio_amplifier.c
endif
LOCAL_C_INCLUDES += \
@@ -360,6 +353,7 @@
external/tinycompress/include \
system/media/audio_utils/include \
external/expat/lib \
+ hardware/libhardware/include \
$(call include-path-for, audio-route) \
$(call include-path-for, audio-effects) \
$(LOCAL_PATH)/$(AUDIO_PLATFORM) \
@@ -462,8 +456,14 @@
LOCAL_SRC_FILES += audio_extn/ffv.c
endif
+ifeq ($(strip $(AUDIO_FEATURE_ELLIPTIC_ULTRASOUND_SUPPORT)),true)
+ LOCAL_CFLAGS += -DELLIPTIC_ULTRASOUND_ENABLED
+ LOCAL_SRC_FILES += audio_extn/ultrasound.c
+endif
+
LOCAL_CFLAGS += -D_GNU_SOURCE
LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CLANG_CFLAGS += -Wno-unused-variable -Wno-unused-function -Wno-missing-field-initializers
LOCAL_COPY_HEADERS_TO := mm-audio
LOCAL_COPY_HEADERS := audio_extn/audio_defs.h
diff --git a/hal/acdb.c b/hal/acdb.c
index 8f3ea83..7394906 100644
--- a/hal/acdb.c
+++ b/hal/acdb.c
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/list.h>
#include <time.h>
#include "acdb.h"
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index 4b4abbe..8bcf5cd 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -30,7 +30,7 @@
/*#define LOG_NDEBUG 0*/
#define LOG_NDDEBUG 0
#include <errno.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <dlfcn.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/adsp_hdlr.c b/hal/audio_extn/adsp_hdlr.c
index 3b073c3..31a6b16 100644
--- a/hal/audio_extn/adsp_hdlr.c
+++ b/hal/audio_extn/adsp_hdlr.c
@@ -42,7 +42,7 @@
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/prctl.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/sched_policy.h>
#include <system/thread_defs.h>
#include <sound/asound.h>
diff --git a/hal/audio_extn/audio_amplifier.c b/hal/audio_extn/audio_amplifier.c
new file mode 100644
index 0000000..7634e63
--- /dev/null
+++ b/hal/audio_extn/audio_amplifier.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2016 The CyanogenMod 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_amplifier"
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <log/log.h>
+
+#include "audio_hw.h"
+#include "platform.h"
+
+struct amplifier_data {
+ struct audio_device *adev;
+ amplifier_device_t *hw;
+};
+
+struct amplifier_data amp;
+
+int amplifier_open(void* adev)
+{
+ int rc;
+ amplifier_module_t *module;
+ amp.adev = (struct audio_device *)adev;
+
+ rc = hw_get_module(AMPLIFIER_HARDWARE_MODULE_ID,
+ (const hw_module_t **) &module);
+ if (rc) {
+ ALOGV("%s: Failed to obtain reference to amplifier module: %s\n",
+ __func__, strerror(-rc));
+ return -ENODEV;
+ }
+
+ rc = amplifier_device_open((const hw_module_t *) module, &.hw);
+ if (rc) {
+ ALOGV("%s: Failed to open amplifier hardware device: %s\n",
+ __func__, strerror(-rc));
+ amp.hw = NULL;
+
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+int amplifier_set_input_devices(uint32_t devices)
+{
+ if (amp.hw && amp.hw->set_input_devices)
+ return amp.hw->set_input_devices(amp.hw, devices);
+
+ return 0;
+}
+
+int amplifier_set_output_devices(uint32_t devices)
+{
+ if (amp.hw && amp.hw->set_output_devices)
+ return amp.hw->set_output_devices(amp.hw, devices);
+
+ return 0;
+}
+
+int amplifier_enable_devices(uint32_t devices, bool enable)
+{
+ bool is_output = devices < SND_DEVICE_OUT_END;
+
+ if (amp.hw && amp.hw->enable_output_devices && is_output)
+ return amp.hw->enable_output_devices(amp.hw, devices, enable);
+
+ if (amp.hw && amp.hw->enable_input_devices && !is_output)
+ return amp.hw->enable_input_devices(amp.hw, devices, enable);
+
+ return 0;
+}
+
+int amplifier_set_mode(audio_mode_t mode)
+{
+ if (amp.hw && amp.hw->set_mode)
+ return amp.hw->set_mode(amp.hw, mode);
+
+ return 0;
+}
+
+int amplifier_output_stream_start(struct audio_stream_out *stream,
+ bool offload)
+{
+ if (amp.hw && amp.hw->output_stream_start)
+ return amp.hw->output_stream_start(amp.hw, stream, offload);
+
+ return 0;
+}
+
+int amplifier_input_stream_start(struct audio_stream_in *stream)
+{
+ if (amp.hw && amp.hw->input_stream_start)
+ return amp.hw->input_stream_start(amp.hw, stream);
+
+ return 0;
+}
+
+int amplifier_output_stream_standby(struct audio_stream_out *stream)
+{
+ if (amp.hw && amp.hw->output_stream_standby)
+ return amp.hw->output_stream_standby(amp.hw, stream);
+
+ return 0;
+}
+
+int amplifier_input_stream_standby(struct audio_stream_in *stream)
+{
+ if (amp.hw && amp.hw->input_stream_standby)
+ return amp.hw->input_stream_standby(amp.hw, stream);
+
+ return 0;
+}
+
+int amplifier_set_parameters(struct str_parms *parms)
+{
+ if (amp.hw && amp.hw->set_parameters)
+ return amp.hw->set_parameters(amp.hw, parms);
+
+ return 0;
+}
+
+int amplifier_close(void)
+{
+ if (amp.hw)
+ amplifier_device_close(amp.hw);
+
+ amp.hw = NULL;
+
+ return 0;
+}
diff --git a/hal/audio_extn/audio_amplifier.h b/hal/audio_extn/audio_amplifier.h
new file mode 100644
index 0000000..c43af28
--- /dev/null
+++ b/hal/audio_extn/audio_amplifier.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 The CyanogenMod 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.
+ */
+
+#ifndef EXTN_AMPLIFIER_H
+#define EXTN_AMPLIFIER_H
+
+#ifndef EXT_AMPLIFIER_ENABLED
+#define amplifier_open(adev) (0)
+#define amplifier_set_input_devices(devices) (0)
+#define amplifier_set_output_devices(devices) (0)
+#define amplifier_enable_devices(devices, enable) (0)
+#define amplifier_set_mode(mode) (0)
+#define amplifier_output_stream_start(stream, offload) (0)
+#define amplifier_input_stream_start(stream) (0)
+#define amplifier_output_stream_standby(stream) (0)
+#define amplifier_input_stream_standby(stream) (0)
+#define amplifier_set_parameters(parms) (0)
+#define amplifier_close() (0)
+#else
+
+int amplifier_open(void* adev);
+int amplifier_set_input_devices(uint32_t devices);
+int amplifier_set_output_devices(uint32_t devices);
+int amplifier_enable_devices(uint32_t devices, bool enable);
+int amplifier_set_mode(audio_mode_t mode);
+int amplifier_output_stream_start(struct audio_stream_out *stream,
+ bool offload);
+int amplifier_input_stream_start(struct audio_stream_in *stream);
+int amplifier_output_stream_standby(struct audio_stream_out *stream);
+int amplifier_input_stream_standby(struct audio_stream_in *stream);
+int amplifier_set_parameters(struct str_parms *parms);
+int amplifier_close(void);
+#endif
+
+#endif
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index f893b3f..96f7d08 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -44,7 +44,7 @@
#include <dlfcn.h>
#include <fcntl.h>
#include <cutils/properties.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <unistd.h>
#include <sched.h>
#include "audio_hw.h"
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 14d2325..1187642 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -138,12 +138,12 @@
:config->offload_info.bit_width)
#else
#define AUDIO_OUTPUT_BIT_WIDTH (CODEC_BACKEND_DEFAULT_BIT_WIDTH)
-#define compress_set_next_track_param(compress, codec_options) (0)
#endif
-#ifndef AUDIO_HW_EXTN_API_ENABLED
+#ifndef ENABLE_EXTENDED_COMPRESS_FORMAT
#define compress_set_metadata(compress, metadata) (0)
#define compress_get_metadata(compress, metadata) (0)
+#define compress_set_next_track_param(compress, codec_options) (0)
#endif
#define MAX_LENGTH_MIXER_CONTROL_IN_INT (128)
diff --git a/hal/audio_extn/bt_hal.c b/hal/audio_extn/bt_hal.c
index 6441bef..2020cba 100644
--- a/hal/audio_extn/bt_hal.c
+++ b/hal/audio_extn/bt_hal.c
@@ -31,7 +31,7 @@
/*#define LOG_NDEBUG 0*/
#include <inttypes.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <audio_hw.h>
#include <audio_extn.h>
#include <platform_api.h>
diff --git a/hal/audio_extn/compress_capture.c b/hal/audio_extn/compress_capture.c
index 671796c..1f9b0fd 100644
--- a/hal/audio_extn/compress_capture.c
+++ b/hal/audio_extn/compress_capture.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/compress_in.c b/hal/audio_extn/compress_in.c
index 305ed5b..4556741 100644
--- a/hal/audio_extn/compress_in.c
+++ b/hal/audio_extn/compress_in.c
@@ -32,10 +32,9 @@
#define LOG_NDDEBUG 0
#ifdef COMPRESS_INPUT_ENABLED
-#include <cutils/log.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/dev_arbi.c b/hal/audio_extn/dev_arbi.c
index 9c5382a..d83d6bd 100644
--- a/hal/audio_extn/dev_arbi.c
+++ b/hal/audio_extn/dev_arbi.c
@@ -32,7 +32,7 @@
#define LOG_NDDEBUG 0
#include <errno.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <fcntl.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index ffd256f..906c234 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -22,10 +22,10 @@
//#define LOG_NDDEBUG 0
#include <errno.h>
#include <cutils/properties.h>
+#include <cutils/str_parms.h>
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/dts_eagle.c b/hal/audio_extn/dts_eagle.c
index 7ae760b..3771a9d 100644
--- a/hal/audio_extn/dts_eagle.c
+++ b/hal/audio_extn/dts_eagle.c
@@ -21,7 +21,7 @@
#include <math.h>
#include <stdlib.h>
#include <fcntl.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
#include <sys/ioctl.h>
diff --git a/hal/audio_extn/ext_hw_plugin.c b/hal/audio_extn/ext_hw_plugin.c
index 3c9458a..b1691f4 100644
--- a/hal/audio_extn/ext_hw_plugin.c
+++ b/hal/audio_extn/ext_hw_plugin.c
@@ -32,7 +32,7 @@
#include <errno.h>
#include <pthread.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <audio_hw.h>
#include "audio_extn.h"
#include "platform_api.h"
diff --git a/hal/audio_extn/ffv.c b/hal/audio_extn/ffv.c
index f0309c2..e04dc4a 100644
--- a/hal/audio_extn/ffv.c
+++ b/hal/audio_extn/ffv.c
@@ -39,10 +39,10 @@
#include <errno.h>
#include <cutils/properties.h>
+#include <cutils/str_parms.h>
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <pthread.h>
#include <sys/resource.h>
#include <unistd.h>
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index ade6a7e..8d7c90e 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -23,7 +23,7 @@
#include <errno.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <unistd.h>
#include "audio_hw.h"
diff --git a/hal/audio_extn/gef.c b/hal/audio_extn/gef.c
index 39660c6..d56b07e 100644
--- a/hal/audio_extn/gef.c
+++ b/hal/audio_extn/gef.c
@@ -33,7 +33,7 @@
#include <errno.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <fcntl.h>
#include <dirent.h>
#include "audio_hw.h"
@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <math.h>
+#include <pthread.h>
#include <cutils/properties.h>
#include "audio_extn.h"
#include "audio_hw.h"
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 0c105d0..a046bf0 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -31,7 +31,7 @@
#include <errno.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/hw_loopback.c b/hal/audio_extn/hw_loopback.c
index 78e4215..347bfdb 100644
--- a/hal/audio_extn/hw_loopback.c
+++ b/hal/audio_extn/hw_loopback.c
@@ -51,16 +51,16 @@
#include <dlfcn.h>
#include <sys/resource.h>
#include <sys/prctl.h>
+#include <cutils/atomic.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
-#include <cutils/atomic.h>
+#include <cutils/sched_policy.h>
+#include <log/log.h>
#include "audio_utils/primitives.h"
#include "audio_hw.h"
#include "platform_api.h"
#include <platform.h>
#include <system/thread_defs.h>
-#include <cutils/sched_policy.h>
#include "audio_extn.h"
#include <sound/compress_params.h>
#include <sound/compress_offload.h>
diff --git a/hal/audio_extn/ip_hdlr_intf.c b/hal/audio_extn/ip_hdlr_intf.c
index ece7af3..395e829 100755
--- a/hal/audio_extn/ip_hdlr_intf.c
+++ b/hal/audio_extn/ip_hdlr_intf.c
@@ -46,7 +46,7 @@
#include <errno.h>
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <sound/asound.h>
#include <cutils/properties.h>
diff --git a/hal/audio_extn/keep_alive.c b/hal/audio_extn/keep_alive.c
index 90875d9..a28e0c9 100644
--- a/hal/audio_extn/keep_alive.c
+++ b/hal/audio_extn/keep_alive.c
@@ -32,7 +32,7 @@
#include <cutils/properties.h>
#include <stdlib.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "audio_extn.h"
#include "platform_api.h"
diff --git a/hal/audio_extn/listen.c b/hal/audio_extn/listen.c
index b98a429..5c3bbce 100644
--- a/hal/audio_extn/listen.c
+++ b/hal/audio_extn/listen.c
@@ -32,7 +32,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#ifdef AUDIO_LISTEN_ENABLED
#include <listen_types.h>
#endif
diff --git a/hal/audio_extn/passthru.c b/hal/audio_extn/passthru.c
index 9180391..78bcde1 100644
--- a/hal/audio_extn/passthru.c
+++ b/hal/audio_extn/passthru.c
@@ -31,14 +31,15 @@
/*#define LOG_NDEBUG 0*/
#include <stdlib.h>
#include <cutils/atomic.h>
+#include <cutils/properties.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <unistd.h>
+#include <pthread.h>
#include "audio_hw.h"
#include "audio_extn.h"
#include "platform_api.h"
#include <platform.h>
-#include <cutils/properties.h>
#include "sound/compress_params.h"
diff --git a/hal/audio_extn/pm.c b/hal/audio_extn/pm.c
index c6ef242..5b3aa4d 100644
--- a/hal/audio_extn/pm.c
+++ b/hal/audio_extn/pm.c
@@ -31,7 +31,7 @@
/*#define LOG_NDEBUG 0*/
#include "pm.h"
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#ifdef DYNAMIC_LOG_ENABLED
diff --git a/hal/audio_extn/pm.h b/hal/audio_extn/pm.h
index daa376e..f78c3aa 100644
--- a/hal/audio_extn/pm.h
+++ b/hal/audio_extn/pm.h
@@ -39,7 +39,7 @@
#include "audio_hw.h"
#include <platform.h>
#include <cutils/properties.h>
-#include <cutils/log.h>
+#include <log/log.h>
/* Client name to be registered with PM */
diff --git a/hal/audio_extn/qaf.c b/hal/audio_extn/qaf.c
index ced137f..dffb4ab 100755
--- a/hal/audio_extn/qaf.c
+++ b/hal/audio_extn/qaf.c
@@ -104,7 +104,7 @@
#include <sys/prctl.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/atomic.h>
#include "audio_utils/primitives.h"
#include "audio_hw.h"
diff --git a/hal/audio_extn/qap.c b/hal/audio_extn/qap.c
index 0625737..263853c 100644
--- a/hal/audio_extn/qap.c
+++ b/hal/audio_extn/qap.c
@@ -105,7 +105,7 @@
#include <sys/prctl.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/atomic.h>
#include "audio_utils/primitives.h"
#include "audio_hw.h"
diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c
index 88d9db7..3f3d005 100644
--- a/hal/audio_extn/sndmonitor.c
+++ b/hal/audio_extn/sndmonitor.c
@@ -49,9 +49,10 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/poll.h>
+#include <pthread.h>
#include <cutils/list.h>
#include <cutils/hashmap.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include <ctype.h>
@@ -432,12 +433,13 @@
return -1;
char val[32] = {0};
+ char *key = NULL;
// cpe actual card num is (card - MAGIC_NUM). so subtract accordingly
snprintf(val, sizeof(val), "%d,%s", s->card - (is_cpe ? CPE_MAGIC_NUM : 0),
status == CARD_STATUS_ONLINE ? "ONLINE" : "OFFLINE");
- if (str_parms_add_str(params, is_cpe ? "CPE_STATUS" : "SND_CARD_STATUS",
- val) < 0)
+ key = (is_cpe ? "CPE_STATUS" : "SND_CARD_STATUS");
+ if (str_parms_add_str(params, key, val) < 0)
return -1;
int ret = notify(params);
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index 38e7ae7..099834c 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -34,7 +34,8 @@
#include <stdbool.h>
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <pthread.h>
+#include <log/log.h>
#include <unistd.h>
#include "audio_hw.h"
#include "audio_extn.h"
diff --git a/hal/audio_extn/source_track.c b/hal/audio_extn/source_track.c
index 2a9ba57..0be68e0 100644
--- a/hal/audio_extn/source_track.c
+++ b/hal/audio_extn/source_track.c
@@ -32,7 +32,7 @@
#include <errno.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 4ae72a6..072e3f9 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -33,7 +33,7 @@
#include <errno.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <fcntl.h>
#include <dirent.h>
#include "audio_hw.h"
@@ -44,6 +44,7 @@
#include <dlfcn.h>
#include <math.h>
#include <unistd.h>
+#include <pthread.h>
#include <cutils/properties.h>
#include "audio_extn.h"
#include <linux/msm_audio_calibration.h>
diff --git a/hal/audio_extn/ssr.c b/hal/audio_extn/ssr.c
index 15eaaef..7e7df69 100644
--- a/hal/audio_extn/ssr.c
+++ b/hal/audio_extn/ssr.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <pthread.h>
#include <cutils/sched_policy.h>
#include <sys/resource.h>
diff --git a/hal/audio_extn/ultrasound.c b/hal/audio_extn/ultrasound.c
new file mode 100644
index 0000000..a020cdb
--- /dev/null
+++ b/hal/audio_extn/ultrasound.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2017-2018 The LineageOS Project
+ * Copyright (c) 2017 Balázs Triszka <balika011@protonmail.ch>
+ *
+ * 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 "ultrasound"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <log/log.h>
+#include "audio_hw.h"
+#include "platform_api.h"
+#include <platform.h>
+#include "ultrasound.h"
+
+#define ULTRASOUND_CALIBRATION_FILE "/persist/audio/us_cal"
+#define ULTRASOUND_CALIBRATION_MIXER "Ultrasound Calibration Data"
+
+enum {
+ ULTRASOUND_STATUS_DEFAULT,
+ ULTRASOUND_STATUS_STARTED,
+ ULTRASOUND_STATUS_STOPPED,
+};
+
+struct pcm_config pcm_config_us = {
+ .channels = 1,
+ .rate = 96000,
+ .period_size = 1024,
+ .period_count = 2,
+ .format = PCM_FORMAT_S16_LE,
+};
+
+struct ultrasound_device {
+ struct pcm *rx_pcm, *tx_pcm;
+ int state;
+ struct audio_device *adev;
+};
+
+static struct ultrasound_device *us = NULL;
+
+void us_cal_load(void)
+{
+ FILE *f;
+ char buff[5] = {0}, us_cal[64];
+ struct mixer_ctl * ctl;
+ int rc;
+
+ f = fopen(ULTRASOUND_CALIBRATION_FILE, "r");
+ if (!f) {
+ ALOGE("%s: Cannot open calibration file: %s",
+ __func__, ULTRASOUND_CALIBRATION_FILE);
+ return;
+ }
+
+ for (size_t i = 0; i < sizeof(us_cal); i++) {
+ fread(buff, 1, sizeof(buff), f);
+ us_cal[i] = strtol(buff, 0, 16);
+ }
+ fclose(f);
+
+ ctl = mixer_get_ctl_by_name(us->adev->mixer, ULTRASOUND_CALIBRATION_MIXER);
+ if (!ctl) {
+ ALOGE("%s: Could not get ctl for mixer cmd - %s",
+ __func__, ULTRASOUND_CALIBRATION_MIXER);
+ return;
+ }
+
+ rc = mixer_ctl_set_array(ctl, us_cal, sizeof(us_cal));
+ if (rc < 0)
+ ALOGE("%s: Could not set ctl, error:%d ", __func__, rc);
+}
+
+int us_init(struct audio_device *adev)
+{
+ ALOGD("%s: enter", __func__);
+
+ if (us) {
+ ALOGI("%s: ultrasound has been initialized!", __func__);
+ return 0;
+ }
+
+ us = calloc(1, sizeof(struct ultrasound_device));
+ if (!us) {
+ ALOGE("%s: Out of memory!", __func__);
+ return -ENOMEM;
+ }
+
+ us->adev = adev;
+
+ us_cal_load();
+
+ ALOGD("%s: exit, status(0)", __func__);
+
+ return 0;
+}
+
+void us_deinit(void)
+{
+ ALOGD("%s: enter", __func__);
+
+ if (us) {
+ free(us);
+ us = NULL;
+ }
+
+ ALOGD("%s: exit", __func__);
+}
+
+int stop_us(void)
+{
+ struct audio_usecase *rx_usecase, *tx_usecase;
+ int rc = 0;
+
+ ALOGD("%s: enter usecase: ultrasound", __func__);
+
+ us->state = ULTRASOUND_STATUS_STOPPED;
+ if (us->rx_pcm) {
+ pcm_close(us->rx_pcm);
+ us->rx_pcm = NULL;
+ }
+
+ if (us->tx_pcm) {
+ pcm_close(us->tx_pcm);
+ us->tx_pcm = NULL;
+ }
+
+ rx_usecase = get_usecase_from_list(us->adev, USECASE_AUDIO_ULTRASOUND_RX);
+ if (!rx_usecase) {
+ ALOGE("%s: Could not find the usecase (%d) in the list",
+ __func__, USECASE_AUDIO_ULTRASOUND_RX);
+ rc = -EINVAL;
+ } else {
+ disable_audio_route(us->adev, rx_usecase);
+ disable_snd_device(us->adev, rx_usecase->out_snd_device);
+ list_remove(&rx_usecase->list);
+ free(rx_usecase);
+ }
+
+ tx_usecase = get_usecase_from_list(us->adev, USECASE_AUDIO_ULTRASOUND_TX);
+ if (!rx_usecase) {
+ ALOGE("%s: Could not find the usecase (%d) in the list",
+ __func__, USECASE_AUDIO_ULTRASOUND_TX);
+ rc = -EINVAL;
+ } else {
+ disable_audio_route(us->adev, tx_usecase);
+ disable_snd_device(us->adev, tx_usecase->in_snd_device);
+ list_remove(&tx_usecase->list);
+ free(tx_usecase);
+ }
+
+ ALOGD("%s: exit: status(%d)", __func__, rc);
+
+ return rc;
+}
+
+int us_start(void)
+{
+ int rx_device_id, tx_device_id;
+ struct audio_usecase *rx_usecase, *tx_usecase;
+
+ ALOGD("%s: enter", __func__);
+
+ if (!us || us->state == ULTRASOUND_STATUS_STARTED)
+ return -EPERM;
+
+ ALOGD("%s: enter usecase: ultrasound", __func__);
+ rx_device_id = platform_get_pcm_device_id(USECASE_AUDIO_ULTRASOUND_RX, PCM_PLAYBACK);
+ tx_device_id = platform_get_pcm_device_id(USECASE_AUDIO_ULTRASOUND_TX, PCM_CAPTURE);
+ if (rx_device_id < 0 || tx_device_id < 0) {
+ ALOGE("%s: Invalid PCM devices (rx: %d tx: %d) for the usecase(ultrasound)",
+ __func__, rx_device_id, tx_device_id);
+ stop_us();
+ ALOGE("%s: exit: status(%d)", __func__, -EIO);
+ return -EIO;
+ }
+
+ rx_usecase = calloc(1, sizeof(struct audio_usecase));
+ if (!rx_usecase) {
+ ALOGE("%s: Out of memory!", __func__);
+ return -ENOMEM;
+ }
+
+ rx_usecase->type = PCM_PLAYBACK;
+ rx_usecase->out_snd_device = SND_DEVICE_OUT_ULTRASOUND_HANDSET;
+ rx_usecase->id = USECASE_AUDIO_ULTRASOUND_RX;
+ list_add_tail(&us->adev->usecase_list, &rx_usecase->list);
+
+ enable_snd_device(us->adev, SND_DEVICE_OUT_ULTRASOUND_HANDSET);
+ enable_audio_route(us->adev, rx_usecase);
+ ALOGV("%s: Opening PCM playback device card_id(%d) device_id(%d)",
+ __func__, us->adev->snd_card, rx_device_id);
+ us->rx_pcm = pcm_open(us->adev->snd_card, rx_device_id, PCM_OUT, &pcm_config_us);
+ if (us->rx_pcm && !pcm_is_ready(us->rx_pcm)) {
+ ALOGE("%s: %s", __func__, pcm_get_error(us->rx_pcm));
+ stop_us();
+ ALOGE("%s: exit: status(%d)", __func__, -EIO);
+ return -EIO;
+ }
+
+ tx_usecase = calloc(1, sizeof(struct audio_usecase));
+ if (!tx_usecase) {
+ ALOGE("%s: Out of memory!", __func__);
+ return -ENOMEM;
+ }
+
+ tx_usecase->type = PCM_CAPTURE;
+ tx_usecase->in_snd_device = SND_DEVICE_IN_ULTRASOUND_MIC;
+ tx_usecase->id = USECASE_AUDIO_ULTRASOUND_TX;
+ list_add_tail(&us->adev->usecase_list, &tx_usecase->list);
+
+ enable_snd_device(us->adev, SND_DEVICE_IN_ULTRASOUND_MIC);
+ enable_audio_route(us->adev, tx_usecase);
+ ALOGV("%s: Opening PCM capture device card_id(%d) device_id(%d)",
+ __func__, us->adev->snd_card, tx_device_id);
+ us->tx_pcm = pcm_open(us->adev->snd_card, tx_device_id, PCM_IN, &pcm_config_us);
+ if (us->tx_pcm && !pcm_is_ready(us->tx_pcm)) {
+ ALOGD("%s: %s", __func__, pcm_get_error(us->tx_pcm));
+ stop_us();
+ ALOGE("%s: exit: status(%d)", __func__, -EIO);
+ return -EIO;
+ }
+
+ pcm_start(us->rx_pcm);
+ pcm_start(us->tx_pcm);
+ us->state = ULTRASOUND_STATUS_STARTED;
+
+ ALOGD("%s: exit, status(0)", __func__);
+
+ return 0;
+}
+
+int us_stop(void)
+{
+ ALOGD("%s: enter", __func__);
+
+ if (!us || us->state != ULTRASOUND_STATUS_STARTED)
+ return -EPERM;
+
+ stop_us();
+
+ return 0;
+}
diff --git a/hal/audio_extn/ultrasound.h b/hal/audio_extn/ultrasound.h
new file mode 100644
index 0000000..0bb24ca
--- /dev/null
+++ b/hal/audio_extn/ultrasound.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017-2018 The LineageOS Project
+ * Copyright (c) 2017 Balázs Triszka <balika011@protonmail.ch>
+ *
+ * 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.
+ */
+
+#ifndef ULTRASOUND_H
+#define ULTRASOUND_H
+
+#ifndef ELLIPTIC_ULTRASOUND_ENABLED
+#define us_init(adev) (0)
+#define us_deinit() (0)
+#define us_start() (0)
+#define us_stop() (0)
+#else
+int us_init(struct audio_device *adev);
+void us_deinit(void);
+int us_start(void);
+int us_stop(void);
+#endif
+
+#endif
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index 16b3e10..63ca865 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -24,7 +24,7 @@
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include <sys/ioctl.h>
#include <fcntl.h>
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 5ee9414..cd78854 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/misc.h>
#include <unistd.h>
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index dca98ad..54d01c0 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -55,7 +55,7 @@
#include <sys/resource.h>
#include <sys/prctl.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/trace.h>
#include <cutils/str_parms.h>
#include <cutils/properties.h>
@@ -75,6 +75,8 @@
#include "audio_extn.h"
#include "voice_extn.h"
#include "ip_hdlr_intf.h"
+#include "ultrasound.h"
+#include "audio_amplifier.h"
#include "sound/compress_params.h"
#include "sound/asound.h"
@@ -354,7 +356,11 @@
[USECASE_AUDIO_EC_REF_LOOPBACK] = "ec-ref-audio-capture",
- [USECASE_AUDIO_A2DP_ABR_FEEDBACK] = "a2dp-abr-feedback"
+ [USECASE_AUDIO_A2DP_ABR_FEEDBACK] = "a2dp-abr-feedback",
+
+ /* For Elliptic Ultrasound proximity sensor */
+ [USECASE_AUDIO_ULTRASOUND_RX] = "ultrasound-rx",
+ [USECASE_AUDIO_ULTRASOUND_TX] = "ultrasound-tx",
};
static const audio_usecase_t offload_usecases[] = {
@@ -1004,6 +1010,9 @@
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_app_type_cfg(adev, usecase);
+#ifdef ELLIPTIC_ULTRASOUND_ENABLED
+ if (usecase->id != USECASE_AUDIO_ULTRASOUND_TX)
+#endif
audio_extn_utils_send_audio_calibration(adev, usecase);
if ((usecase->type == PCM_PLAYBACK) && is_offload_usecase(usecase->id)) {
out = usecase->stream.out;
@@ -1122,6 +1131,10 @@
ST_EVENT_SND_DEVICE_BUSY);
audio_extn_listen_update_device_status(snd_device,
LISTEN_EVENT_SND_DEVICE_BUSY);
+#ifdef ELLIPTIC_ULTRASOUND_ENABLED
+ if (snd_device != SND_DEVICE_OUT_ULTRASOUND_HANDSET &&
+ snd_device != SND_DEVICE_IN_ULTRASOUND_MIC)
+#endif
if (platform_get_snd_device_acdb_id(snd_device) < 0) {
audio_extn_sound_trigger_update_device_status(snd_device,
ST_EVENT_SND_DEVICE_FREE);
@@ -1130,6 +1143,7 @@
goto err;
}
audio_extn_dev_arbi_acquire(snd_device);
+ amplifier_enable_devices(snd_device, true);
audio_route_apply_and_update_path(adev->audio_route, device_name);
if (SND_DEVICE_OUT_HEADPHONES == snd_device &&
@@ -1198,6 +1212,7 @@
}
} else {
audio_route_reset_and_update_path(adev->audio_route, device_name);
+ amplifier_enable_devices(snd_device, false);
}
if (SND_DEVICE_OUT_BT_A2DP == snd_device)
@@ -1425,6 +1440,12 @@
platform_get_snd_device_name(snd_device),
platform_get_snd_device_name(usecase->out_snd_device),
platform_check_backends_match(snd_device, usecase->out_snd_device));
+
+#ifdef ELLIPTIC_ULTRASOUND_ENABLED
+ if (usecase->id == USECASE_AUDIO_ULTRASOUND_RX)
+ continue;
+#endif
+
if ((usecase->type != PCM_CAPTURE) && (usecase != uc_info)) {
uc_derive_snd_device = derive_playback_snd_device(adev->platform,
usecase, uc_info, snd_device);
@@ -1567,6 +1588,12 @@
/*
* TODO: Enhance below condition to handle BT sco/USB multi recording
*/
+
+#ifdef ELLIPTIC_ULTRASOUND_ENABLED
+ if (usecase->id == USECASE_AUDIO_ULTRASOUND_TX)
+ continue;
+#endif
+
if (usecase->type != PCM_PLAYBACK &&
usecase != uc_info &&
(usecase->in_snd_device != snd_device || force_routing) &&
@@ -2372,6 +2399,10 @@
voice_set_sidetone(adev, out_snd_device, true);
}
+ /* Rely on amplifier_set_devices to distinguish between in/out devices */
+ amplifier_set_input_devices(in_snd_device);
+ amplifier_set_output_devices(out_snd_device);
+
/* Applicable only on the targets that has external modem.
* Enable device command should be sent to modem only after
* enabling voice call mixer controls
@@ -3667,6 +3698,9 @@
stop_compressed_output_l(out);
pthread_mutex_lock(&adev->lock);
+
+ amplifier_output_stream_standby((struct audio_stream_out *) stream);
+
out->standby = true;
if (out->usecase == USECASE_COMPRESS_VOIP_CALL) {
voice_extn_compress_voip_close_output_stream(stream);
@@ -4696,6 +4730,11 @@
ret = voice_extn_compress_voip_start_output_stream(out);
else
ret = start_output_stream(out);
+
+ if (ret == 0)
+ amplifier_output_stream_start(stream,
+ is_offload_usecase(out->usecase));
+
pthread_mutex_unlock(&adev->lock);
/* ToDo: If use case is compress offload should return 0 */
if (ret != 0) {
@@ -5486,6 +5525,9 @@
adev->adm_deregister_stream(adev->adm_data, in->capture_handle);
pthread_mutex_lock(&adev->lock);
+
+ amplifier_input_stream_standby((struct audio_stream_in *) stream);
+
in->standby = true;
if (in->usecase == USECASE_COMPRESS_VOIP_CALL) {
do_stop = false;
@@ -5723,6 +5765,11 @@
ret = voice_extn_compress_voip_start_input_stream(in);
else
ret = start_input_stream(in);
+
+ if (ret == 0)
+ amplifier_input_stream_start(stream);
+
+
pthread_mutex_unlock(&adev->lock);
if (ret != 0) {
goto exit;
@@ -7008,6 +7055,16 @@
}
}
+ ret = str_parms_get_int(parms, "ultrasound_enable", &val);
+ if (ret >= 0) {
+ if (val == 1) {
+ us_start();
+ } else {
+ us_stop();
+ }
+ }
+
+ amplifier_set_parameters(parms);
audio_extn_set_parameters(adev, parms);
done:
str_parms_destroy(parms);
@@ -7131,6 +7188,8 @@
pthread_mutex_lock(&adev->lock);
if (adev->mode != mode) {
ALOGD("%s: mode %d\n", __func__, mode);
+ if (amplifier_set_mode(mode) != 0)
+ ALOGE("Failed setting amplifier mode");
adev->mode = mode;
if (voice_is_in_call(adev) &&
(mode == AUDIO_MODE_NORMAL ||
@@ -7686,14 +7745,16 @@
static int adev_close(hw_device_t *device)
{
- struct audio_device *adev = (struct audio_device *)device;
+ struct audio_device *adev_temp = (struct audio_device *)device;
- if (!adev)
+ if (!adev_temp)
return 0;
pthread_mutex_lock(&adev_init_lock);
if ((--audio_device_ref_count) == 0) {
+ if (amplifier_close() != 0)
+ ALOGE("Amplifier close failed");
audio_extn_snd_mon_unregister_listener(adev);
audio_extn_sound_trigger_deinit(adev);
audio_extn_listen_deinit(adev);
@@ -7724,6 +7785,9 @@
free(device);
adev = NULL;
}
+
+ us_deinit();
+
pthread_mutex_unlock(&adev_init_lock);
enable_gcov();
return 0;
@@ -8078,6 +8142,12 @@
adev->vr_audio_mode_enabled = false;
audio_extn_ds2_enable(adev);
+
+ us_init(adev);
+
+ if (amplifier_open(adev) != 0)
+ ALOGE("Amplifier initialization failed");
+
*device = &adev->device.common;
adev->dsp_bit_width_enforce_mode =
adev_init_dsp_bit_width_enforce_mode(adev->mixer);
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index f791b6a..fe2e30e 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <cutils/list.h>
+#include <hardware/audio_amplifier.h>
#include <hardware/audio.h>
#include <tinyalsa/asoundlib.h>
#include <tinycompress/tinycompress.h>
@@ -204,6 +205,9 @@
USECASE_AUDIO_A2DP_ABR_FEEDBACK,
+ USECASE_AUDIO_ULTRASOUND_RX,
+ USECASE_AUDIO_ULTRASOUND_TX,
+
AUDIO_USECASE_MAX
};
@@ -543,6 +547,7 @@
bool dp_allowed_for_voice;
void *ext_hw_plugin;
bool use_old_pspd_mix_ctrl;
+ amplifier_device_t *amp;
};
int select_devices(struct audio_device *adev,
diff --git a/hal/audio_hw_extn_api.c b/hal/audio_hw_extn_api.c
index 4e49a83..e16e3d0 100644
--- a/hal/audio_hw_extn_api.c
+++ b/hal/audio_hw_extn_api.c
@@ -33,7 +33,8 @@
#include <inttypes.h>
#include <errno.h>
-#include <cutils/log.h>
+#include <log/log.h>
+#include <pthread.h>
#include <hardware/audio.h>
#include "sound/compress_params.h"
diff --git a/hal/edid.c b/hal/edid.c
index 175842f..ffb0d64 100644
--- a/hal/edid.c
+++ b/hal/edid.c
@@ -23,10 +23,10 @@
#include <errno.h>
#include <cutils/properties.h>
+#include <cutils/str_parms.h>
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/str_parms.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/msm8916/hw_info.c b/hal/msm8916/hw_info.c
index 40e39a2..eb9a483 100644
--- a/hal/msm8916/hw_info.c
+++ b/hal/msm8916/hw_info.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index a08aafa..5305250 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -25,7 +25,7 @@
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
#include <audio_hw.h>
@@ -413,7 +413,7 @@
};
/* Array to store sound devices */
-static const char * const device_table[SND_DEVICE_MAX] = {
+static const char * device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_NONE] = "none",
/* Playback sound devices */
[SND_DEVICE_OUT_HANDSET] = "handset",
@@ -7865,6 +7865,21 @@
return snd_device;
}
+int platform_set_snd_device_name(snd_device_t device, const char *name)
+{
+ int ret = 0;
+
+ if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) {
+ ALOGE("%s:: Invalid snd_device = %d", __func__, device);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ device_table[device] = strdup(name);
+done:
+ return ret;
+}
+
int platform_set_sidetone(struct audio_device *adev,
snd_device_t out_snd_device,
bool enable,
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 809772f..c76b9ed 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/properties.h>
#include <audio_hw.h>
#include <platform_api.h>
@@ -1252,6 +1252,12 @@
ALOGE("%s: Not implemented", __func__);
}
+int platform_set_snd_device_name(snd_device_t snd_device __unused,
+ const char * name __unused)
+{
+ return -ENOSYS;
+}
+
bool platform_can_enable_spkr_prot_on_device(snd_device_t snd_device __unused)
{
/* speaker protection not implemented for this platform*/
diff --git a/hal/msm8974/hw_info.c b/hal/msm8974/hw_info.c
index 0cc261e..3ead268 100644
--- a/hal/msm8974/hw_info.c
+++ b/hal/msm8974/hw_info.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include <dlfcn.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include "audio_hw.h"
#include "platform.h"
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index daf6455..fe40a16 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -31,7 +31,7 @@
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/properties.h>
#include <cutils/str_parms.h>
#include <audio_hw.h>
@@ -400,10 +400,13 @@
[USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM8] =
{PLAYBACK_INTERACTIVE_STRM_DEVICE8, PLAYBACK_INTERACTIVE_STRM_DEVICE8},
[USECASE_AUDIO_EC_REF_LOOPBACK] = {-1, -1}, /* pcm id updated from platform info file */
+ [USECASE_AUDIO_ULTRASOUND_RX] = {ULTRASOUND_PCM_DEVICE, -1},
+ [USECASE_AUDIO_ULTRASOUND_TX] = {-1, ULTRASOUND_PCM_DEVICE},
+
};
/* Array to store sound devices */
-static const char * const device_table[SND_DEVICE_MAX] = {
+static const char * device_table[SND_DEVICE_MAX] = {
[SND_DEVICE_NONE] = "none",
/* Playback sound devices */
[SND_DEVICE_OUT_HANDSET] = "handset",
@@ -473,6 +476,7 @@
[SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS] = "speaker-protected-vbat",
[SND_DEVICE_OUT_SPEAKER_AND_BT_SCO] = "speaker-and-bt-sco",
[SND_DEVICE_OUT_SPEAKER_AND_BT_SCO_WB] = "speaker-and-bt-sco-wb",
+ [SND_DEVICE_OUT_ULTRASOUND_HANDSET] = "ultrasound-handset",
/* Capture sound devices */
[SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@@ -569,6 +573,7 @@
[SND_DEVICE_IN_INCALL_REC_TX] = "incall-rec-tx",
[SND_DEVICE_IN_INCALL_REC_RX_TX] = "incall-rec-rx-tx",
[SND_DEVICE_IN_EC_REF_LOOPBACK_QUAD] = "ec-ref-loopback-quad",
+ [SND_DEVICE_IN_ULTRASOUND_MIC] = "ultrasound-mic",
};
// Platform specific backend bit width table
@@ -976,6 +981,8 @@
{TO_NAME_INDEX(USECASE_AUDIO_A2DP_ABR_FEEDBACK)},
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_VOIP)},
{TO_NAME_INDEX(USECASE_AUDIO_RECORD_VOIP)},
+ {TO_NAME_INDEX(USECASE_AUDIO_ULTRASOUND_RX)},
+ {TO_NAME_INDEX(USECASE_AUDIO_ULTRASOUND_TX)},
};
#define NO_COLS 2
@@ -1198,7 +1205,11 @@
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, list);
- if (usecase != NULL && usecase->type == PCM_PLAYBACK) {
+ if (usecase != NULL && usecase->type == PCM_PLAYBACK
+#ifdef ELLIPTIC_ULTRASOUND_ENABLED
+ && usecase->id != USECASE_AUDIO_ULTRASOUND_RX
+#endif
+ ) {
int new_snd_device[2] = {0};
int i, num_devices = 1;
@@ -7955,6 +7966,21 @@
return snd_device;
}
+int platform_set_snd_device_name(snd_device_t device, const char *name)
+{
+ int ret = 0;
+
+ if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) {
+ ALOGE("%s:: Invalid snd_device = %d", __func__, device);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ device_table[device] = strdup(name);
+done:
+ return ret;
+}
+
int platform_set_sidetone(struct audio_device *adev,
snd_device_t out_snd_device,
bool enable,
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index d15f6eb..4f8655b 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -150,6 +150,7 @@
SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_HEADPHONES,
SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_ANC_HEADSET,
SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_ANC_FB_HEADSET,
+ SND_DEVICE_OUT_ULTRASOUND_HANDSET,
SND_DEVICE_OUT_END,
/*
@@ -251,6 +252,7 @@
SND_DEVICE_IN_INCALL_REC_TX,
SND_DEVICE_IN_INCALL_REC_RX_TX,
SND_DEVICE_IN_EC_REF_LOOPBACK_QUAD,
+ SND_DEVICE_IN_ULTRASOUND_MIC,
SND_DEVICE_IN_END,
SND_DEVICE_MAX = SND_DEVICE_IN_END,
@@ -497,6 +499,8 @@
#define AFE_PROXY_PLAYBACK_PCM_DEVICE 7
#define AFE_PROXY_RECORD_PCM_DEVICE 8
+#define ULTRASOUND_PCM_DEVICE 11
+
#ifdef PLATFORM_MSM8x26
#define HFP_SCO_RX 28
#define HFP_ASM_RX_TX 29
diff --git a/hal/platform_api.h b/hal/platform_api.h
index e54c496..7eb0a63 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -198,6 +198,7 @@
const char * hw_interface);
int platform_get_snd_device_backend_index(snd_device_t device);
const char * platform_get_snd_device_backend_interface(snd_device_t device);
+int platform_set_snd_device_name(snd_device_t snd_device, const char * name);
/* From platform_info.c */
int platform_info_init(const char *filename, void *, caller_t);
diff --git a/hal/platform_info.c b/hal/platform_info.c
index 70c2b70..b3dc273 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -33,7 +33,7 @@
#include <errno.h>
#include <stdio.h>
#include <expat.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include <audio_hw.h>
#include "acdb.h"
@@ -70,6 +70,7 @@
MIC_INFO,
CUSTOM_MTMX_PARAMS,
CUSTOM_MTMX_PARAM_COEFFS,
+ DEVICE_NAME,
} section_t;
typedef void (* section_process_fn)(const XML_Char **attr);
@@ -91,6 +92,7 @@
static void process_mic_info(const XML_Char **attr);
static void process_custom_mtmx_params(const XML_Char **attr);
static void process_custom_mtmx_param_coeffs(const XML_Char **attr);
+static void process_device_name(const XML_Char **attr);
static section_process_fn section_table[] = {
[ROOT] = process_root,
@@ -109,6 +111,7 @@
[MIC_INFO] = process_mic_info,
[CUSTOM_MTMX_PARAMS] = process_custom_mtmx_params,
[CUSTOM_MTMX_PARAM_COEFFS] = process_custom_mtmx_param_coeffs,
+ [DEVICE_NAME] = process_device_name,
};
static section_t section;
@@ -248,6 +251,11 @@
* ...
* ...
* </config_params>
+ * <device_names>
+ * <device name="???" alias="???"/>
+ * ...
+ * ...
+ * </device_names>
* </audio_platform_info>
*/
@@ -955,7 +963,38 @@
}
mtmx_params_info.snd_device = platform_get_snd_device_index((char *)attr[attr_idx++]);
platform_add_custom_mtmx_params((void *)my_data.platform, &mtmx_params_info);
+}
+static void process_device_name(const XML_Char **attr)
+{
+ int index;
+
+ if (strcmp(attr[0], "name") != 0) {
+ ALOGE("%s: 'name' not found, no alias 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 alias set!",
+ __func__, attr[1]);
+ goto done;
+ }
+
+ if (strcmp(attr[2], "alias") != 0) {
+ ALOGE("%s: Device %s in platform info xml has no alias, no alias set!",
+ __func__, attr[1]);
+ goto done;
+ }
+
+ if (platform_set_snd_device_name(index, attr[3]) < 0) {
+ ALOGE("%s: Device %s, alias %s was not set!",
+ __func__, attr[1], attr[3]);
+ goto done;
+ }
+
+done:
+ return;
}
static void start_tag(void *userdata __unused, const XML_Char *tag_name,
@@ -996,11 +1035,13 @@
section = MICROPHONE_CHARACTERISTIC;
} else if (strcmp(tag_name, "snd_devices") == 0) {
section = SND_DEVICES;
+ } else if (strcmp(tag_name, "device_names") == 0) {
+ section = DEVICE_NAME;
} else if (strcmp(tag_name, "device") == 0) {
if ((section != ACDB) && (section != AEC) && (section != NS) &&
(section != BACKEND_NAME) && (section != BITWIDTH) &&
- (section != INTERFACE_NAME)) {
- ALOGE("device tag only supported for acdb/backend names/bitwitdh/interface names");
+ (section != INTERFACE_NAME) && (section != DEVICE_NAME)) {
+ ALOGE("device tag only supported for acdb/backend names/bitwidth/interface/device names");
return;
}
@@ -1142,6 +1183,8 @@
section = ROOT;
} else if (strcmp(tag_name, "custom_mtmx_param_coeffs") == 0) {
section = CUSTOM_MTMX_PARAMS;
+ } else if (strcmp(tag_name, "device_names") == 0) {
+ section = ROOT;
}
}
diff --git a/hal/voice.c b/hal/voice.c
index 91eb3ff..514db81 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -24,7 +24,7 @@
#include <errno.h>
#include <stdlib.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include "audio_hw.h"
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index 890f508..b1fa285 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -27,7 +27,7 @@
#include <sys/time.h>
#include <stdlib.h>
#include <math.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include <cutils/properties.h>
diff --git a/post_proc/Android.mk b/post_proc/Android.mk
index 497fe17..b24b2e8 100644
--- a/post_proc/Android.mk
+++ b/post_proc/Android.mk
@@ -175,13 +175,13 @@
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_C_INCLUDES := \
- hardware/qcom/audio/hal \
+ $(call project-path-for,qcom-audio)/hal \
$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include \
external/tinyalsa/include \
$(call include-path-for, audio-effects) \
$(call include-path-for, audio-route) \
- hardware/qcom/audio/hal/audio_extn \
+ $(call project-path-for,qcom-audio)/hal/audio_extn \
external/tinycompress/include
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
diff --git a/post_proc/asphere.c b/post_proc/asphere.c
index 82bb496..e0d76a6 100644
--- a/post_proc/asphere.c
+++ b/post_proc/asphere.c
@@ -35,7 +35,7 @@
#include <unistd.h>
#include <stdbool.h>
#include <sys/stat.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/list.h>
#include <cutils/str_parms.h>
#include <cutils/properties.h>
diff --git a/post_proc/bass_boost.c b/post_proc/bass_boost.c
index 8e91764..f591bf1 100644
--- a/post_proc/bass_boost.c
+++ b/post_proc/bass_boost.c
@@ -21,7 +21,7 @@
//#define LOG_NDEBUG 0
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/properties.h>
#include <tinyalsa/asoundlib.h>
#include <sound/audio_effects.h>
diff --git a/post_proc/bundle.c b/post_proc/bundle.c
index ce0d0ec..99d8349 100644
--- a/post_proc/bundle.c
+++ b/post_proc/bundle.c
@@ -40,7 +40,7 @@
#include <stdlib.h>
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <system/thread_defs.h>
#include <tinyalsa/asoundlib.h>
#include <hardware/audio_effect.h>
diff --git a/post_proc/effect_api.c b/post_proc/effect_api.c
index 3098850..79b77de 100644
--- a/post_proc/effect_api.c
+++ b/post_proc/effect_api.c
@@ -56,7 +56,7 @@
#include <stdbool.h>
#include <errno.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <tinyalsa/asoundlib.h>
#include <sound/audio_effects.h>
#include <sound/devdep_params.h>
diff --git a/post_proc/equalizer.c b/post_proc/equalizer.c
index eddaca1..17d3112 100644
--- a/post_proc/equalizer.c
+++ b/post_proc/equalizer.c
@@ -21,7 +21,7 @@
//#define LOG_NDEBUG 0
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <tinyalsa/asoundlib.h>
#include <sound/audio_effects.h>
#include <audio_effects/effect_equalizer.h>
diff --git a/post_proc/hw_accelerator.c b/post_proc/hw_accelerator.c
index fae5807..583f001 100644
--- a/post_proc/hw_accelerator.c
+++ b/post_proc/hw_accelerator.c
@@ -32,7 +32,7 @@
/*#define LOG_NDEBUG 0*/
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <fcntl.h>
#include <tinyalsa/asoundlib.h>
#include <sound/audio_effects.h>
diff --git a/post_proc/reverb.c b/post_proc/reverb.c
index eafa07e..8eb4e0f 100644
--- a/post_proc/reverb.c
+++ b/post_proc/reverb.c
@@ -21,7 +21,7 @@
//#define LOG_NDEBUG 0
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <tinyalsa/asoundlib.h>
#include <sound/audio_effects.h>
#include <audio_effects/effect_environmentalreverb.h>
diff --git a/post_proc/virtualizer.c b/post_proc/virtualizer.c
index f47630b..3b372cb 100644
--- a/post_proc/virtualizer.c
+++ b/post_proc/virtualizer.c
@@ -21,7 +21,7 @@
//#define LOG_NDEBUG 0
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <tinyalsa/asoundlib.h>
#include <sound/audio_effects.h>
#include <audio_effects/effect_virtualizer.h>
diff --git a/post_proc/volume_listener.c b/post_proc/volume_listener.c
index 9fc8377..b29d1af 100644
--- a/post_proc/volume_listener.c
+++ b/post_proc/volume_listener.c
@@ -35,7 +35,7 @@
#include <pthread.h>
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <hardware/audio_effect.h>
#include <cutils/properties.h>
#include <platform_api.h>
diff --git a/qahw_api/test/qap_wrapper_extn.c b/qahw_api/test/qap_wrapper_extn.c
index f86908f..982e4f1 100644
--- a/qahw_api/test/qap_wrapper_extn.c
+++ b/qahw_api/test/qap_wrapper_extn.c
@@ -27,8 +27,8 @@
#include <time.h>
#include <cutils/properties.h>
#include <cutils/list.h>
-#include <cutils/log.h>
#include <cutils/str_parms.h>
+#include <log/log.h>
#include <system/audio.h>
#include <qap_api.h>
#include <qti_audio.h>
diff --git a/visualizer/offload_visualizer.c b/visualizer/offload_visualizer.c
index 9ad8fea..678b73a 100644
--- a/visualizer/offload_visualizer.c
+++ b/visualizer/offload_visualizer.c
@@ -27,7 +27,7 @@
#include <unistd.h>
#include <cutils/list.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <system/thread_defs.h>
#include <tinyalsa/asoundlib.h>
#include <audio_effects/effect_visualizer.h>
diff --git a/voice_processing/voice_processing.c b/voice_processing/voice_processing.c
index 32b76a5..366adf7 100644
--- a/voice_processing/voice_processing.c
+++ b/voice_processing/voice_processing.c
@@ -19,7 +19,7 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <stdlib.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/list.h>
#include <unistd.h>
#include <hardware/audio_effect.h>