power-libperfmgr: remove Google-specific camera and audio hints

Change-Id: I65285ca8c7248bd1e55d3800862e96c00f00effd
tirimbino
Jesse Chan 4 years ago
parent 9e9ba0a5b8
commit f834ac2741
  1. 30
      hidl/power-libperfmgr/AudioStreaming.h
  2. 30
      hidl/power-libperfmgr/CameraMode.h
  3. 81
      hidl/power-libperfmgr/Power.cpp
  4. 3
      hidl/power-libperfmgr/Power.h
  5. 10
      hidl/power-libperfmgr/android.hardware.power@1.3-service.samsung-libperfmgr.rc

@ -1,30 +0,0 @@
/*
* Copyright (C) 2019 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_AUDIOSTREAMING_H_
#define POWER_LIBPERFMGR_AUDIOSTREAMING_H_
enum AUDIO_STREAMING_HINT {
AUDIO_STREAMING_OFF = 0,
AUDIO_STREAMING_ON = 1,
TPU_BOOST_OFF = 1000,
TPU_BOOST_SHORT = 1001,
TPU_BOOST_LONG = 1002
};
enum TPU_HINT_DURATION_MS { SHORT = 200, LONG = 2000 };
#endif // POWER_LIBPERFMGR_AUDIOSTREAMING_H_

@ -1,30 +0,0 @@
/*
* 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_60FPS,
CAMERA_STREAMING_4K,
CAMERA_STREAMING_SECURE,
CAMERA_STREAMING_MAX
};
#endif // POWER_LIBPERFMGR_CAMERAMODE_H_

@ -28,7 +28,6 @@
#include <utils/Log.h> #include <utils/Log.h>
#include <utils/Trace.h> #include <utils/Trace.h>
#include "AudioStreaming.h"
#include "Power.h" #include "Power.h"
namespace android { namespace android {
@ -49,20 +48,12 @@ constexpr char kPowerHalInitProp[] = "vendor.powerhal.init";
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering"; constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
constexpr char kPowerHalConfigPath[] = "/vendor/etc/powerhint.json"; constexpr char kPowerHalConfigPath[] = "/vendor/etc/powerhint.json";
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_60FPS, "CAMERA_STREAMING_60FPS"},
{CAMERA_STREAMING_4K, "CAMERA_STREAMING_4K"},
{CAMERA_STREAMING_SECURE, "CAMERA_STREAMING_SECURE"}};
Power::Power() Power::Power()
: mHintManager(nullptr), : mHintManager(nullptr),
mInteractionHandler(nullptr), mInteractionHandler(nullptr),
mVRModeOn(false), mVRModeOn(false),
mSustainedPerfModeOn(false), mSustainedPerfModeOn(false),
mCameraStreamingMode(CAMERA_STREAMING_OFF), mCameraStreamingMode(false),
mReady(false) { mReady(false) {
mInitThread = std::thread([this]() { mInitThread = std::thread([this]() {
android::base::WaitForProperty(kPowerHalInitProp, "1"); android::base::WaitForProperty(kPowerHalInitProp, "1");
@ -76,23 +67,7 @@ Power::Power()
if (state == "CAMERA_STREAMING") { if (state == "CAMERA_STREAMING") {
ALOGI("Initialize with CAMERA_STREAMING on"); ALOGI("Initialize with CAMERA_STREAMING on");
mHintManager->DoHint("CAMERA_STREAMING"); mHintManager->DoHint("CAMERA_STREAMING");
mCameraStreamingMode = CAMERA_STREAMING; mCameraStreamingMode = true;
} 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_60FPS") {
ALOGI("Initialize CAMERA_STREAMING_60FPS on");
mHintManager->DoHint("CAMERA_STREAMING_60FPS");
mCameraStreamingMode = CAMERA_STREAMING_60FPS;
} 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 == "CAMERA_STREAMING_SECURE") {
ALOGI("Initialize with CAMERA_STREAMING_SECURE on");
mHintManager->DoHint("CAMERA_STREAMING_SECURE");
mCameraStreamingMode = CAMERA_STREAMING_SECURE;
} else if (state == "SUSTAINED_PERFORMANCE") { } else if (state == "SUSTAINED_PERFORMANCE") {
ALOGI("Initialize with SUSTAINED_PERFORMANCE on"); ALOGI("Initialize with SUSTAINED_PERFORMANCE on");
mHintManager->DoHint("SUSTAINED_PERFORMANCE"); mHintManager->DoHint("SUSTAINED_PERFORMANCE");
@ -250,21 +225,10 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
if (mVRModeOn || mSustainedPerfModeOn) { if (mVRModeOn || mSustainedPerfModeOn) {
ALOGV("%s: ignoring due to other active perf hints", __func__); ALOGV("%s: ignoring due to other active perf hints", __func__);
} else { } else {
if (data == static_cast<int32_t>(AUDIO_STREAMING_HINT::AUDIO_STREAMING_ON)) { if (data) {
mHintManager->DoHint("AUDIO_STREAMING"); mHintManager->DoHint("AUDIO_STREAMING");
} else if (data ==
static_cast<int32_t>(AUDIO_STREAMING_HINT::AUDIO_STREAMING_OFF)) {
mHintManager->EndHint("AUDIO_STREAMING");
} else if (data == static_cast<int32_t>(AUDIO_STREAMING_HINT::TPU_BOOST_SHORT)) {
mHintManager->DoHint("TPU_BOOST",
std::chrono::milliseconds(TPU_HINT_DURATION_MS::SHORT));
} else if (data == static_cast<int32_t>(AUDIO_STREAMING_HINT::TPU_BOOST_LONG)) {
mHintManager->DoHint("TPU_BOOST",
std::chrono::milliseconds(TPU_HINT_DURATION_MS::LONG));
} else if (data == static_cast<int32_t>(AUDIO_STREAMING_HINT::TPU_BOOST_OFF)) {
mHintManager->EndHint("TPU_BOOST");
} else { } else {
ALOGE("AUDIO STREAMING INVALID DATA: %d", data); mHintManager->EndHint("AUDIO_STREAMING");
} }
} }
break; break;
@ -278,34 +242,17 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
} }
break; break;
case PowerHint_1_2::CAMERA_STREAMING: { case PowerHint_1_2::CAMERA_STREAMING: {
const enum CameraStreamingMode mode = static_cast<enum CameraStreamingMode>(data); if (data > 0) {
if (mode < CAMERA_STREAMING_OFF || mode >= CAMERA_STREAMING_MAX) { mHintManager->DoHint("CAMERA_STREAMING");
ALOGE("CAMERA STREAMING INVALID Mode: %d", mode); mCameraStreamingMode = true;
break; } else {
} mHintManager->EndHint("CAMERA_STREAMING");
mCameraStreamingMode = false;
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);
if ((mCameraStreamingMode != CAMERA_STREAMING_SECURE)) {
// Boost 1s for tear down if not secure streaming use case
mHintManager->DoHint("CAMERA_LAUNCH", std::chrono::seconds(1));
}
}
if (mode != CAMERA_STREAMING_OFF) {
const auto hintValue = kCamStreamingHint.at(mode);
mHintManager->DoHint(hintValue);
} }
mCameraStreamingMode = mode; const auto prop = mCameraStreamingMode
const auto prop = (mCameraStreamingMode == CAMERA_STREAMING_OFF) ? "CAMERA_STREAMING"
? "" : "";
: kCamStreamingHint.at(mode).c_str();
if (!android::base::SetProperty(kPowerHalStateProp, prop)) { if (!android::base::SetProperty(kPowerHalStateProp, prop)) {
ALOGE("%s: could set powerHAL state %s property", __func__, prop); ALOGE("%s: could set powerHAL state %s property", __func__, prop);
} }
@ -363,7 +310,7 @@ Return<void> Power::debug(const hidl_handle &handle, const hidl_vec<hidl_string>
"CameraStreamingMode: %s\n" "CameraStreamingMode: %s\n"
"SustainedPerformanceMode: %s\n", "SustainedPerformanceMode: %s\n",
boolToString(mHintManager->IsRunning()), boolToString(mVRModeOn), boolToString(mHintManager->IsRunning()), boolToString(mVRModeOn),
kCamStreamingHint.at(mCameraStreamingMode).c_str(), boolToString(mCameraStreamingMode),
boolToString(mSustainedPerfModeOn))); boolToString(mSustainedPerfModeOn)));
// Dump nodes through libperfmgr // Dump nodes through libperfmgr
mHintManager->DumpToFd(fd); mHintManager->DumpToFd(fd);

@ -26,7 +26,6 @@
#include <hidl/Status.h> #include <hidl/Status.h>
#include <perfmgr/HintManager.h> #include <perfmgr/HintManager.h>
#include "CameraMode.h"
#include "InteractionHandler.h" #include "InteractionHandler.h"
namespace android { namespace android {
@ -74,7 +73,7 @@ class Power : public IPower {
std::unique_ptr<InteractionHandler> mInteractionHandler; std::unique_ptr<InteractionHandler> mInteractionHandler;
std::atomic<bool> mVRModeOn; std::atomic<bool> mVRModeOn;
std::atomic<bool> mSustainedPerfModeOn; std::atomic<bool> mSustainedPerfModeOn;
std::atomic<enum CameraStreamingMode> mCameraStreamingMode; std::atomic<bool> mCameraStreamingMode;
std::atomic<bool> mReady; std::atomic<bool> mReady;
std::thread mInitThread; std::thread mInitThread;
}; };

@ -14,13 +14,3 @@ on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
setprop vendor.powerhal.audio "" setprop vendor.powerhal.audio ""
setprop vendor.powerhal.rendering "" setprop vendor.powerhal.rendering ""
restart vendor.power-hal-1-3 restart vendor.power-hal-1-3
# restart powerHAL when cameraHAL died
on property:init.svc.vendor.camera-provider-2-4=restarting && property:vendor.powerhal.state=CAMERA_STREAMING
setprop vendor.powerhal.state ""
restart vendor.power-hal-1-3
# restart powerHAL when audioHAL died
on property:init.svc.vendor.audio-hal-2-0=restarting && property:vendor.powerhal.audio=AUDIO_LOW_LATENCY
setprop vendor.powerhal.audio ""
restart vendor.power-hal-1-3

Loading…
Cancel
Save