summaryrefslogtreecommitdiff
path: root/camera
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2017-07-11 14:00:51 -0700
committerWei Wang <wvw@google.com>2017-08-09 00:53:27 +0000
commit23b7412d82babb6069d731af369303b60f128256 (patch)
tree6d0b0d053b5e71410e88bc70d901ab9feba1b1fe /camera
parentcc80027581782aceea0218862fabc0b206c7644a (diff)
camera: Fix powerHAL usage
We no longer have legacy powerhal module but IPower instance. Bug: 63039461 Test: Got powerhint from powerhal service Change-Id: I5bc76646662efd3bcffc1ce3e374cbec68b90287
Diffstat (limited to 'camera')
-rw-r--r--camera/QCamera2/Android.mk2
-rw-r--r--camera/QCamera2/HAL/QCamera2HWI.cpp10
-rw-r--r--camera/QCamera2/HAL3/QCamera3HWI.cpp4
-rw-r--r--camera/QCamera2/util/QCameraPerf.cpp23
-rw-r--r--camera/QCamera2/util/QCameraPerf.h18
5 files changed, 31 insertions, 26 deletions
diff --git a/camera/QCamera2/Android.mk b/camera/QCamera2/Android.mk
index cddf88d4..672b60be 100644
--- a/camera/QCamera2/Android.mk
+++ b/camera/QCamera2/Android.mk
@@ -56,6 +56,7 @@ ifeq ($(TARGET_USES_MEDIA_EXTENSIONS), true)
LOCAL_CFLAGS += -DUSE_MEDIA_EXTENSIONS
endif
+LOCAL_CFLAGS += -std=c++14 -std=gnu++1z
#HAL 1.0 Flags
LOCAL_CFLAGS += -DDEFAULT_DENOISE_MODE_ON -DHAL3 -DQCAMERA_REDEFINE_LOG
@@ -105,6 +106,7 @@ LOCAL_SHARED_LIBRARIES += libmmcamera_interface libmmjpeg_interface libui libcam
LOCAL_SHARED_LIBRARIES += libqdMetaData libqservice libbinder
LOCAL_SHARED_LIBRARIES += libcutils libdl
LOCAL_HEADER_LIBRARIES := OmxCore_headers gralloc_headers
+LOCAL_SHARED_LIBRARIES += libhidlbase libhwbinder libutils android.hardware.power@1.1
ifeq ($(TARGET_TS_MAKEUP),true)
LOCAL_SHARED_LIBRARIES += libts_face_beautify_hal libts_detected_face_hal
endif
diff --git a/camera/QCamera2/HAL/QCamera2HWI.cpp b/camera/QCamera2/HAL/QCamera2HWI.cpp
index 55260af7..1dead66a 100644
--- a/camera/QCamera2/HAL/QCamera2HWI.cpp
+++ b/camera/QCamera2/HAL/QCamera2HWI.cpp
@@ -412,7 +412,7 @@ void QCamera2HardwareInterface::stop_preview(struct camera_device *device)
hw->getCameraId());
// Disable power Hint for preview
- hw->m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, false);
+ hw->m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, false);
hw->m_perfLock.lock_acq();
hw->lockAPI();
@@ -3506,7 +3506,7 @@ int QCamera2HardwareInterface::startPreview()
if (rc == NO_ERROR) {
if (!mParameters.isSeeMoreEnabled()) {
// Set power Hint for preview
- m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, true);
+ m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, true);
}
}
@@ -3540,7 +3540,7 @@ int QCamera2HardwareInterface::stopPreview()
mActiveAF = false;
// Disable power Hint for preview
- m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, false);
+ m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, false);
m_perfLock.lock_acq();
@@ -3710,7 +3710,7 @@ int QCamera2HardwareInterface::startRecording()
if (rc == NO_ERROR) {
if (!mParameters.isSeeMoreEnabled()) {
// Set power Hint for video encoding
- m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, true);
+ m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, true);
}
}
@@ -3741,7 +3741,7 @@ int QCamera2HardwareInterface::stopRecording()
m_cbNotifier.flushVideoNotifications();
// Disable power hint for video encoding
- m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, false);
+ m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, false);
mVideoMem = NULL;
LOGI("X rc = %d", rc);
return rc;
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.cpp b/camera/QCamera2/HAL3/QCamera3HWI.cpp
index 5040bac2..03fa56c1 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/camera/QCamera2/HAL3/QCamera3HWI.cpp
@@ -1251,7 +1251,7 @@ int32_t QCamera3HardwareInterface::getSensorOutputSize(cam_dimension_t &sensor_d
void QCamera3HardwareInterface::enablePowerHint()
{
if (!mPowerHintEnabled) {
- m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, true);
+ m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, true);
mPowerHintEnabled = true;
}
}
@@ -1269,7 +1269,7 @@ void QCamera3HardwareInterface::enablePowerHint()
void QCamera3HardwareInterface::disablePowerHint()
{
if (mPowerHintEnabled) {
- m_perfLock.powerHint(POWER_HINT_VIDEO_ENCODE, false);
+ m_perfLock.powerHint(PowerHint::VIDEO_ENCODE, false);
mPowerHintEnabled = false;
}
}
diff --git a/camera/QCamera2/util/QCameraPerf.cpp b/camera/QCamera2/util/QCameraPerf.cpp
index 83ba4cc3..8356a356 100644
--- a/camera/QCamera2/util/QCameraPerf.cpp
+++ b/camera/QCamera2/util/QCameraPerf.cpp
@@ -108,14 +108,15 @@ void QCameraPerfLock::lock_init()
// Clear the list of active power hints
mActivePowerHints.clear();
- mCurrentPowerHint = static_cast<power_hint_t>(0);
+ mCurrentPowerHint = static_cast<PowerHint>(0);
mCurrentPowerHintEnable = false;
property_get("persist.camera.perflock.enable", value, "1");
mPerfLockEnable = atoi(value);
#ifdef HAS_MULTIMEDIA_HINTS
- if (hw_get_module(POWER_HARDWARE_MODULE_ID, (const hw_module_t **)&m_pPowerModule)) {
- LOGE("%s module not found", POWER_HARDWARE_MODULE_ID);
+ mPowerHal = IPower::getService();
+ if (mPowerHal == nullptr) {
+ ALOGE("Couldn't load PowerHAL module");
}
#endif
@@ -466,15 +467,11 @@ int32_t QCameraPerfLock::lock_rel()
* RETURN : void
*
*==========================================================================*/
-void QCameraPerfLock::powerHintInternal(power_hint_t hint, bool enable)
+void QCameraPerfLock::powerHintInternal(PowerHint hint, bool enable)
{
#ifdef HAS_MULTIMEDIA_HINTS
- if (m_pPowerModule != NULL) {
- if (enable == true) {
- m_pPowerModule->powerHint(m_pPowerModule, hint, (void *)"state=1");
- } else {
- m_pPowerModule->powerHint(m_pPowerModule, hint, (void *)"state=0");
- }
+ if (mPowerHal != nullptr && !mPowerHal->powerHintAsync(hint, enable).isOk()) {
+ LOGE("Send powerhint to PowerHal failed");
}
#endif
}
@@ -491,7 +488,7 @@ void QCameraPerfLock::powerHintInternal(power_hint_t hint, bool enable)
* RETURN : void
*
*==========================================================================*/
-void QCameraPerfLock::powerHint(power_hint_t hint, bool enable)
+void QCameraPerfLock::powerHint(PowerHint hint, bool enable)
{
#ifdef HAS_MULTIMEDIA_HINTS
if (enable == true) {
@@ -510,7 +507,7 @@ void QCameraPerfLock::powerHint(power_hint_t hint, bool enable)
}
} else {
// Remove the power hint from the list
- for (List<power_hint_t>::iterator it = mActivePowerHints.begin();
+ for (List<PowerHint>::iterator it = mActivePowerHints.begin();
it != mActivePowerHints.end(); ++it) {
if (*it == hint) {
if (it != mActivePowerHints.begin()) {
@@ -534,7 +531,7 @@ void QCameraPerfLock::powerHint(power_hint_t hint, bool enable)
mCurrentPowerHintEnable = true;
powerHintInternal(mCurrentPowerHint, true);
} else {
- mCurrentPowerHint = static_cast<power_hint_t>(0);
+ mCurrentPowerHint = static_cast<PowerHint>(0);
mCurrentPowerHintEnable = false;
}
}
diff --git a/camera/QCamera2/util/QCameraPerf.h b/camera/QCamera2/util/QCameraPerf.h
index a5978da8..06d7e041 100644
--- a/camera/QCamera2/util/QCameraPerf.h
+++ b/camera/QCamera2/util/QCameraPerf.h
@@ -35,7 +35,13 @@
#include <utils/Mutex.h>
// Camera dependencies
-#include "power.h"
+#include <android/hardware/power/1.1/IPower.h>
+
+using namespace android;
+using android::hardware::power::V1_1::IPower;
+using android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
typedef enum {
ALL_CORES_ONLINE = 0x7FE,
@@ -65,8 +71,8 @@ public:
int32_t lock_acq_timed(int32_t timer_val);
int32_t lock_rel_timed();
bool isTimerReset();
- void powerHintInternal(power_hint_t hint, bool enable);
- void powerHint(power_hint_t hint, bool enable);
+ void powerHintInternal(PowerHint hint, bool enable);
+ void powerHint(PowerHint hint, bool enable);
private:
int32_t (*perf_lock_acq)(int, int, int[], int);
@@ -78,13 +84,13 @@ private:
Mutex mLock;
int32_t mPerfLockHandle; // Performance lock library handle
int32_t mPerfLockHandleTimed; // Performance lock library handle
- power_module_t *m_pPowerModule; // power module Handle
- power_hint_t mCurrentPowerHint;
+ sp<IPower> mPowerHal;
+ PowerHint mCurrentPowerHint;
bool mCurrentPowerHintEnable;
uint32_t mTimerSet;
uint32_t mPerfLockTimeout;
nsecs_t mStartTimeofLock;
- List<power_hint_t> mActivePowerHints; // Active/enabled power hints list
+ List<PowerHint> mActivePowerHints; // Active/enabled power hints list
};
}; // namespace qcamera