diff options
author | Martin Liu <liumartin@google.com> | 2019-04-02 12:01:29 +0800 |
---|---|---|
committer | Martin Liu <liumartin@google.com> | 2019-04-03 10:01:34 +0800 |
commit | 2273ac5b214245547cbec480706ba0dc24bc5931 (patch) | |
tree | 186e7ca3dd0a0ad8ea51129dc65b98281d295e59 /power-libperfmgr | |
parent | 161280fd42fa96fc7576ff061059a390020c682a (diff) | |
download | pixel-2273ac5b214245547cbec480706ba0dc24bc5931.tar.gz |
PowerHAL: support more camera streaming modes
This patch extend camera streaming to normal
preview, 1080p and 4K recording cases.
Bug: 116854288
Bug: 129495482
Test: boot and function test
Change-Id: Ieea9976a1a48fb4580008a7bbd624b1e5167bad1
Diffstat (limited to 'power-libperfmgr')
-rw-r--r-- | power-libperfmgr/Android.bp | 6 | ||||
-rw-r--r-- | power-libperfmgr/CameraMode.h | 28 | ||||
-rw-r--r-- | power-libperfmgr/Power.cpp | 68 | ||||
-rw-r--r-- | power-libperfmgr/Power.h | 3 |
4 files changed, 87 insertions, 18 deletions
diff --git a/power-libperfmgr/Android.bp b/power-libperfmgr/Android.bp index 728acffd..ce3ba80c 100644 --- a/power-libperfmgr/Android.bp +++ b/power-libperfmgr/Android.bp @@ -12,6 +12,12 @@ // 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. + +cc_library_headers { + name: "pixel_power_headers", + export_include_dirs: ["."], +} + cc_binary { name: "android.hardware.power@1.3-service.pixel-libperfmgr", relative_install_path: "hw", diff --git a/power-libperfmgr/CameraMode.h b/power-libperfmgr/CameraMode.h new file mode 100644 index 00000000..6558ce8c --- /dev/null +++ b/power-libperfmgr/CameraMode.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef POWER_LIBPERFMGR_CAMERAMODE_H_ +#define POWER_LIBPERFMGR_CAMERAMODE_H_ + +enum CameraStreamingMode { + CAMERA_STREAMING_OFF = 0, + CAMERA_STREAMING, + CAMERA_STREAMING_1080P, + CAMERA_STREAMING_4K, + CAMERA_STREAMING_MAX +}; + +#endif // POWER_LIBPERFMGR_CAMERAMODE_H_ diff --git a/power-libperfmgr/Power.cpp b/power-libperfmgr/Power.cpp index 84a0648a..b2897fa6 100644 --- a/power-libperfmgr/Power.cpp +++ b/power-libperfmgr/Power.cpp @@ -44,12 +44,18 @@ using ::android::hardware::Void; using ::android::hardware::power::V1_0::Feature; using ::android::hardware::power::V1_0::Status; +static const std::map<enum CameraStreamingMode, std::string> kCamStreamingHint = { + {CAMERA_STREAMING_OFF, "CAMERA_STREAMING_OFF"}, + {CAMERA_STREAMING, "CAMERA_STREAMING"}, + {CAMERA_STREAMING_1080P, "CAMERA_STREAMING_1080P"}, + {CAMERA_STREAMING_4K, "CAMERA_STREAMING_4K"}}; + Power::Power() : mHintManager(nullptr), mInteractionHandler(nullptr), mVRModeOn(false), mSustainedPerfModeOn(false), - mCameraStreamingModeOn(false), + mCameraStreamingMode(CAMERA_STREAMING_OFF), mReady(false) { mInitThread = std::thread([this]() { android::base::WaitForProperty(kPowerHalInitProp, "1"); @@ -63,7 +69,15 @@ Power::Power() if (state == "CAMERA_STREAMING") { ALOGI("Initialize with CAMERA_STREAMING on"); mHintManager->DoHint("CAMERA_STREAMING"); - mCameraStreamingModeOn = true; + mCameraStreamingMode = CAMERA_STREAMING; + } else if (state == "CAMERA_STREAMING_1080P") { + ALOGI("Initialize CAMERA_STREAMING_1080P on"); + mHintManager->DoHint("CAMERA_STREAMING_1080P"); + mCameraStreamingMode = CAMERA_STREAMING_1080P; + } else if (state == "CAMERA_STREAMING_4K") { + ALOGI("Initialize with CAMERA_STREAMING_4K on"); + mHintManager->DoHint("CAMERA_STREAMING_4K"); + mCameraStreamingMode = CAMERA_STREAMING_4K; } else if (state == "SUSTAINED_PERFORMANCE") { ALOGI("Initialize with SUSTAINED_PERFORMANCE on"); mHintManager->DoHint("SUSTAINED_PERFORMANCE"); @@ -271,19 +285,38 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { ALOGE("CAMERA LAUNCH INVALID DATA: %d", data); } break; - case PowerHint_1_2::CAMERA_STREAMING: - if (data > 0) { - mHintManager->DoHint("CAMERA_STREAMING"); - mCameraStreamingModeOn = true; - } else if (data == 0) { - mHintManager->EndHint("CAMERA_STREAMING"); + case PowerHint_1_2::CAMERA_STREAMING: { + const enum CameraStreamingMode mode = static_cast<enum CameraStreamingMode>(data); + if (mode < CAMERA_STREAMING_OFF || mode >= CAMERA_STREAMING_MAX) { + ALOGE("CAMERA STREAMING INVALID Mode: %d", mode); + break; + } + + if (mCameraStreamingMode == mode) + break; + + // turn it off first if any previous hint. + if ((mCameraStreamingMode != CAMERA_STREAMING_OFF)) { + const auto modeValue = kCamStreamingHint.at(mCameraStreamingMode); + mHintManager->EndHint(modeValue); // Boost 1s for tear down mHintManager->DoHint("CAMERA_LAUNCH", std::chrono::seconds(1)); - mCameraStreamingModeOn = false; - } else { - ALOGE("CAMERA STREAMING INVALID DATA: %d", data); + } + + if (mode != CAMERA_STREAMING_OFF) { + const auto hintValue = kCamStreamingHint.at(mode); + mHintManager->DoHint(hintValue); + } + + mCameraStreamingMode = mode; + const auto prop = (mCameraStreamingMode == CAMERA_STREAMING_OFF) + ? "" + : kCamStreamingHint.at(mode).c_str(); + if (!android::base::SetProperty(kPowerHalStateProp, prop)) { + ALOGE("%s: could set powerHAL state %s property", __func__, prop); } break; + } case PowerHint_1_2::CAMERA_SHOT: if (data > 0) { mHintManager->DoHint("CAMERA_SHOT", std::chrono::milliseconds(data)); @@ -331,12 +364,13 @@ Return<void> Power::debug(const hidl_handle &handle, const hidl_vec<hidl_string> int fd = handle->data[0]; std::string buf(android::base::StringPrintf( - "HintManager Running: %s\n" - "VRMode: %s\n" - "CameraStreamingMode: %s\n" - "SustainedPerformanceMode: %s\n", - boolToString(mHintManager->IsRunning()), boolToString(mVRModeOn), - boolToString(mCameraStreamingModeOn), boolToString(mSustainedPerfModeOn))); + "HintManager Running: %s\n" + "VRMode: %s\n" + "CameraStreamingMode: %s\n" + "SustainedPerformanceMode: %s\n", + boolToString(mHintManager->IsRunning()), boolToString(mVRModeOn), + kCamStreamingHint.at(mCameraStreamingMode).c_str(), + boolToString(mSustainedPerfModeOn))); // Dump nodes through libperfmgr mHintManager->DumpToFd(fd); if (!android::base::WriteStringToFd(buf, fd)) { diff --git a/power-libperfmgr/Power.h b/power-libperfmgr/Power.h index 12e200d5..4b055bc2 100644 --- a/power-libperfmgr/Power.h +++ b/power-libperfmgr/Power.h @@ -26,6 +26,7 @@ #include <hidl/Status.h> #include <perfmgr/HintManager.h> +#include "CameraMode.h" #include "InteractionHandler.h" namespace android { @@ -80,7 +81,7 @@ struct Power : public IPower { std::unique_ptr<InteractionHandler> mInteractionHandler; std::atomic<bool> mVRModeOn; std::atomic<bool> mSustainedPerfModeOn; - std::atomic<bool> mCameraStreamingModeOn; + std::atomic<enum CameraStreamingMode> mCameraStreamingMode; std::atomic<bool> mReady; std::thread mInitThread; }; |