summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavi Kumar Alamanda <ralama@codeaurora.org>2015-09-24 22:47:39 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-24 22:47:39 +0000
commitc5a1eee907a7ac0fd31679a4d2489b27db911888 (patch)
tree7ca2e1439010bf23dfe5a7a9df8ed602075e992f
parentda3d511f7d5313cfcbfc8f496e1801d9dcf3c2d2 (diff)
parent533bb72620933eddd232d41e171ab70ea0807e34 (diff)
downloadandroid_hardware_qcom_audio-c5a1eee907a7ac0fd31679a4d2489b27db911888.tar.gz
android_hardware_qcom_audio-c5a1eee907a7ac0fd31679a4d2489b27db911888.tar.bz2
android_hardware_qcom_audio-c5a1eee907a7ac0fd31679a4d2489b27db911888.zip
am 533bb726: hal: Add support for perf lock management
* commit '533bb72620933eddd232d41e171ab70ea0807e34': hal: Add support for perf lock management
-rw-r--r--hal/Android.mk3
-rw-r--r--hal/audio_extn/audio_extn.c102
-rw-r--r--hal/audio_extn/audio_extn.h9
-rw-r--r--hal/audio_hw.c13
4 files changed, 127 insertions, 0 deletions
diff --git a/hal/Android.mk b/hal/Android.mk
index a51fac70..c0fbc8d6 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -21,10 +21,12 @@ endif
ifneq ($(filter msm8992,$(TARGET_BOARD_PLATFORM)),)
LOCAL_CFLAGS := -DPLATFORM_MSM8994
LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4"
+ LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
endif
ifneq ($(filter msm8994,$(TARGET_BOARD_PLATFORM)),)
LOCAL_CFLAGS := -DPLATFORM_MSM8994
LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4"
+ LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
endif
endif
@@ -33,6 +35,7 @@ LOCAL_SRC_FILES := \
voice.c \
platform_info.c \
audio_extn/ext_speaker.c \
+ audio_extn/audio_extn.c \
$(AUDIO_PLATFORM)/platform.c
LOCAL_SHARED_LIBRARIES := \
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
new file mode 100644
index 00000000..dcc9baf6
--- /dev/null
+++ b/hal/audio_extn/audio_extn.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2015 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_extn"
+/*#define LOG_NDEBUG 0*/
+#define LOG_NDDEBUG 0
+
+#include <stdlib.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <cutils/properties.h>
+#include <cutils/log.h>
+
+#include "audio_hw.h"
+#include "audio_extn.h"
+#include "platform.h"
+#include "platform_api.h"
+
+
+
+#ifdef KPI_OPTIMIZE_ENABLED
+typedef int (*perf_lock_acquire_t)(int, int, int*, int);
+typedef int (*perf_lock_release_t)(int);
+
+static void *qcopt_handle;
+static perf_lock_acquire_t perf_lock_acq;
+static perf_lock_release_t perf_lock_rel;
+
+static int perf_lock_handle;
+char opt_lib_path[PROPERTY_VALUE_MAX] = {0};
+
+int perf_lock_opts[] = {0x101, 0x20E, 0x30E};
+
+int audio_extn_perf_lock_init(void)
+{
+ int ret = 0;
+ if (qcopt_handle == NULL) {
+ if (property_get("ro.vendor.extension_library",
+ opt_lib_path, NULL) <= 0) {
+ ALOGE("%s: Failed getting perf property", __func__);
+ ret = -EINVAL;
+ goto err;
+ }
+ if ((qcopt_handle = dlopen(opt_lib_path, RTLD_NOW)) == NULL) {
+ ALOGE("%s: Failed to open perf handle", __func__);
+ ret = -EINVAL;
+ goto err;
+ } else {
+ perf_lock_acq = (perf_lock_acquire_t)dlsym(qcopt_handle,
+ "perf_lock_acq");
+ if (perf_lock_acq == NULL) {
+ ALOGE("%s: Perf lock Acquire NULL", __func__);
+ ret = -EINVAL;
+ goto err;
+ }
+ perf_lock_rel = (perf_lock_release_t)dlsym(qcopt_handle,
+ "perf_lock_rel");
+ if (perf_lock_rel == NULL) {
+ ALOGE("%s: Perf lock Release NULL", __func__);
+ ret = -EINVAL;
+ goto err;
+ }
+ ALOGD("%s: Perf lock handles Success", __func__);
+ }
+ }
+err:
+ return ret;
+}
+
+void audio_extn_perf_lock_acquire(void)
+{
+ if (perf_lock_acq) {
+ perf_lock_handle = perf_lock_acq(perf_lock_handle, 0, perf_lock_opts, 3);
+ ALOGV("%s: Perf lock acquired", __func__);
+ } else {
+ ALOGE("%s: Perf lock acquire error", __func__);
+ }
+}
+
+void audio_extn_perf_lock_release(void)
+{
+ if (perf_lock_rel && perf_lock_handle) {
+ perf_lock_rel(perf_lock_handle);
+ ALOGV("%s: Perf lock released", __func__);
+ } else {
+ ALOGE("%s: Perf lock release error", __func__);
+ }
+}
+#endif /* KPI_OPTIMIZE_ENABLED */
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index b99378e8..c518faa7 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -101,4 +101,13 @@ void audio_extn_dsm_feedback_enable(struct audio_device *adev,
void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle);
#endif
+#ifndef KPI_OPTIMIZE_ENABLED
+#define audio_extn_perf_lock_init() (0)
+#define audio_extn_perf_lock_acquire() (0)
+#define audio_extn_perf_lock_release() (0)
+#else
+int audio_extn_perf_lock_init(void);
+void audio_extn_perf_lock_acquire(void);
+void audio_extn_perf_lock_release(void);
+#endif /* KPI_OPTIMIZE_ENABLED */
#endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index ca86d75b..3b8d6e08 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -801,6 +801,9 @@ int start_input_stream(struct stream_in *in)
uc_info->out_snd_device = SND_DEVICE_NONE;
list_add_tail(&adev->usecase_list, &uc_info->list);
+
+ audio_extn_perf_lock_acquire();
+
select_devices(adev, in->usecase);
ALOGV("%s: Opening PCM device card_id(%d) device_id(%d), channels %d",
@@ -835,12 +838,16 @@ int start_input_stream(struct stream_in *in)
ALOGV("%s: pcm_prepare start", __func__);
pcm_prepare(in->pcm);
+
+ audio_extn_perf_lock_release();
+
ALOGV("%s: exit", __func__);
return ret;
error_open:
stop_input_stream(in);
+ audio_extn_perf_lock_release();
error_config:
adev->active_input = NULL;
@@ -1153,6 +1160,8 @@ int start_output_stream(struct stream_out *out)
list_add_tail(&adev->usecase_list, &uc_info->list);
+ audio_extn_perf_lock_acquire();
+
select_devices(adev, out->usecase);
audio_extn_extspk_update(adev->extspk);
@@ -1209,9 +1218,11 @@ int start_output_stream(struct stream_out *out)
if (adev->offload_effects_start_output != NULL)
adev->offload_effects_start_output(out->handle, out->pcm_device_id);
}
+ audio_extn_perf_lock_release();
ALOGV("%s: exit", __func__);
return 0;
error_open:
+ audio_extn_perf_lock_release();
stop_output_stream(out);
error_config:
return ret;
@@ -2977,6 +2988,8 @@ static int adev_open(const hw_module_t *module, const char *name,
if (adev->adm_init)
adev->adm_data = adev->adm_init();
+ audio_extn_perf_lock_init();
+
ALOGV("%s: exit", __func__);
return 0;
}