hal: Performance mode during recording usecase
Put system in performance mode during start of recording
usecase to meet KPI values of cold start input latency.
Change-Id: I30c202c39b4b15b37e7245fc2f1a427377178baa
diff --git a/hal/Android.mk b/hal/Android.mk
index fef47de..ea7d799 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -62,6 +62,10 @@
LOCAL_CFLAGS += -DAFE_PROXY_ENABLED
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE)),true)
+ LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
+endif
+
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM)),true)
LOCAL_CFLAGS += -DFM_ENABLED
LOCAL_SRC_FILES += audio_extn/fm.c
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 846a816..cae961d 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <errno.h>
+#include <dlfcn.h>
#include <cutils/properties.h>
#include <cutils/log.h>
@@ -507,3 +508,68 @@
return 0;
}
#endif /* AUXPCM_BT_ENABLED */
+
+#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[512] = {0};
+int perf_lock_opts[1] = {0x20E};
+
+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 \n", __func__);
+ ret = -EINVAL;
+ goto err;
+ }
+ if ((qcopt_handle = dlopen(opt_lib_path, RTLD_NOW)) == NULL) {
+ ALOGE("%s: Failed to open perf handle \n", __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 \n", __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 \n", __func__);
+ ret = -EINVAL;
+ goto err;
+ }
+ ALOGE("%s: Perf lock handles Success \n", __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, 1);
+ else
+ ALOGE("%s: Perf lock acquire error \n", __func__);
+}
+
+void audio_extn_perf_lock_release(void)
+{
+ if (perf_lock_rel && perf_lock_handle)
+ perf_lock_rel(perf_lock_handle);
+ else
+ ALOGE("%s: Perf lock release error \n", __func__);
+}
+#endif /* KPI_OPTIMIZE_ENABLED */
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 8224a44..6baa37f 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -377,4 +377,14 @@
#ifndef AUDIO_FORMAT_E_AC3_JOC
#define AUDIO_FORMAT_E_AC3_JOC 0x19000000UL
#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 27eb73b..af097c1 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -991,6 +991,7 @@
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",
@@ -1022,12 +1023,14 @@
}
break;
}
+ 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;
@@ -3223,6 +3226,7 @@
/* This stream could be for sound trigger lab,
get sound trigger pcm if present */
audio_extn_sound_trigger_check_and_get_session(in);
+ audio_extn_perf_lock_init();
*stream_in = &in->stream;
ALOGV("%s: exit", __func__);