Merge "Merge VrHAL logic into PowerHAL"

This commit is contained in:
TreeHugger Robot
2018-11-21 00:22:22 +00:00
committed by Android (Google) Code Review
17 changed files with 102 additions and 293 deletions

View File

@@ -452,10 +452,6 @@ PRODUCT_PACKAGES += \
android.hardware.gnss@1.0-impl-qti \
android.hardware.gnss@1.0-service-qti
# VR HAL
PRODUCT_PACKAGES += \
android.hardware.vr@1.0-service.wahoo \
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/sec_config:$(TARGET_COPY_OUT_VENDOR)/etc/sec_config

View File

@@ -506,7 +506,7 @@ on property:init.svc.zygote=running
on property:init.svc.zygote=stopped
stop vendor.folio_daemon
service vendor.thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf}
service vendor.thermal-engine /vendor/bin/thermal-engine -c ${vendor.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf}
class hal
user root
group root system diag

View File

@@ -321,15 +321,6 @@
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.vr</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IVr</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.weaver</name>
<transport>hwbinder</transport>

View File

@@ -61,7 +61,10 @@ Power::Power() :
mInitThread =
std::thread([this](){
android::base::WaitForProperty(kPowerHalInitProp, "1");
mHintManager = HintManager::GetFromJSON("/vendor/etc/powerhint.json");
mHintManager = HintManager::GetFromJSON(kPowerHalConfigPath);
if (!mHintManager) {
LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath;
}
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
mInteractionHandler->Init();
@@ -88,7 +91,7 @@ Power::Power() :
}
state = android::base::GetProperty(kPowerHalAudioProp, "");
if (state == "LOW_LATENCY") {
if (state == "AUDIO_LOW_LATENCY") {
ALOGI("Initialize with AUDIO_LOW_LATENCY on");
mHintManager->DoHint("AUDIO_LOW_LATENCY");
}
@@ -131,17 +134,11 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
ATRACE_INT("video_encode_lock", 1);
mHintManager->DoHint("VIDEO_ENCODE");
ALOGD("VIDEO_ENCODE ON");
if (!android::base::SetProperty(kPowerHalStateProp, "VIDEO_ENCODE")) {
ALOGE("%s: could not set powerHAL state property to VIDEO_ENCODE", __func__);
}
mEncoderModeOn = true;
} else {
ATRACE_INT("video_encode_lock", 0);
mHintManager->EndHint("VIDEO_ENCODE");
ALOGD("VIDEO_ENCODE OFF");
if (!android::base::SetProperty(kPowerHalStateProp, "")) {
ALOGE("%s: could not clear powerHAL state property", __func__);
}
mEncoderModeOn = false;
}
}
@@ -152,15 +149,9 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
ALOGD("SUSTAINED_PERFORMANCE ON");
if (!mVRModeOn) { // Sustained mode only.
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
if (!android::base::SetProperty(kPowerHalStateProp, "SUSTAINED_PERFORMANCE")) {
ALOGE("%s: could not set powerHAL state property to SUSTAINED_PERFORMANCE", __func__);
}
} else { // Sustained + VR mode.
mHintManager->EndHint("VR_MODE");
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
if (!android::base::SetProperty(kPowerHalStateProp, "VR_SUSTAINED_PERFORMANCE")) {
ALOGE("%s: could not set powerHAL state property to VR_SUSTAINED_PERFORMANCE", __func__);
}
}
mSustainedPerfModeOn = true;
} else if (!data && mSustainedPerfModeOn) {
@@ -169,13 +160,6 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
mHintManager->EndHint("SUSTAINED_PERFORMANCE");
if (mVRModeOn) { // Switch back to VR Mode.
mHintManager->DoHint("VR_MODE");
if (!android::base::SetProperty(kPowerHalStateProp, "VR_MODE")) {
ALOGE("%s: could not set powerHAL state property to VR_MODE", __func__);
}
} else {
if (!android::base::SetProperty(kPowerHalStateProp, "")) {
ALOGE("%s: could not clear powerHAL state property", __func__);
}
}
mSustainedPerfModeOn = false;
}
@@ -185,15 +169,9 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
ALOGD("VR_MODE ON");
if (!mSustainedPerfModeOn) { // VR mode only.
mHintManager->DoHint("VR_MODE");
if (!android::base::SetProperty(kPowerHalStateProp, "VR_MODE")) {
ALOGE("%s: could not set powerHAL state property to VR_MODE", __func__);
}
} else { // Sustained + VR mode.
mHintManager->EndHint("SUSTAINED_PERFORMANCE");
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
if (!android::base::SetProperty(kPowerHalStateProp, "VR_SUSTAINED_PERFORMANCE")) {
ALOGE("%s: could not set powerHAL state property to VR_SUSTAINED_PERFORMANCE", __func__);
}
}
mVRModeOn = true;
} else if (!data && mVRModeOn) {
@@ -202,13 +180,6 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
mHintManager->EndHint("VR_MODE");
if (mSustainedPerfModeOn) { // Switch back to sustained Mode.
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
if (!android::base::SetProperty(kPowerHalStateProp, "SUSTAINED_PERFORMANCE")) {
ALOGE("%s: could not set powerHAL state property to SUSTAINED_PERFORMANCE", __func__);
}
} else {
if (!android::base::SetProperty(kPowerHalStateProp, "")) {
ALOGE("%s: could not clear powerHAL state property", __func__);
}
}
mVRModeOn = false;
}
@@ -440,16 +411,10 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
ATRACE_INT("audio_low_latency_lock", 1);
mHintManager->DoHint("AUDIO_LOW_LATENCY");
ALOGD("AUDIO LOW LATENCY ON");
if (!android::base::SetProperty(kPowerHalAudioProp, "LOW_LATENCY")) {
ALOGE("%s: could not set powerHAL audio state property to LOW_LATENCY", __func__);
}
} else {
ATRACE_INT("audio_low_latency_lock", 0);
mHintManager->EndHint("AUDIO_LOW_LATENCY");
ALOGD("AUDIO LOW LATENCY OFF");
if (!android::base::SetProperty(kPowerHalAudioProp, "")) {
ALOGE("%s: could not clear powerHAL audio state property", __func__);
}
}
ATRACE_END();
break;

View File

@@ -45,6 +45,7 @@ using ::android::perfmgr::HintManager;
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
constexpr char kPowerHalInitProp[] = "vendor.powerhal.init";
constexpr char kPowerHalConfigPath[] = "/vendor/etc/powerhint.json";
struct Power : public IPower {
// Methods from ::android::hardware::power::V1_0::IPower follow.

View File

@@ -12,10 +12,23 @@ on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
# restart powerHAL when cameraHAL died
on property:init.svc.vendor.camera-provider-2-4=restarting && property:vendor.powerhal.state=VIDEO_ENCODE
setprop vendor.powerhal.state ""
setprop vendor.powerhal.audio ""
restart vendor.power-hal-1-2
# restart powerHAL when audioHAL died
on property:init.svc.vendor.audio-hal-2-0=restarting && property:vendor.powerhal.audio=LOW_LATENCY
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-2
# reset touch and thermal-engine config when framework died and thermal-engine is in VR mode
on property:init.svc.zygote=restarting && property:vendor.qcom.thermalcfg=/vendor/etc/thermal-engine-vr.conf
write /sys/devices/virtual/input/ftm4_touch/vrmode 0
setprop vendor.qcom.thermalcfg "/vendor/etc/thermal-engine.conf"
on property:vendor.qcom.thermalcfg=*
restart vendor.thermal-engine
on property:ro.hardware=taimen && property:vendor.qcom.thermalcfg=/vendor/etc/thermal-engine-vr.conf
write /sys/devices/virtual/input/ftm4_touch/vrmode 1
on property:ro.hardware=taimen && property:vendor.qcom.thermalcfg=/vendor/etc/thermal-engine.conf
write /sys/devices/virtual/input/ftm4_touch/vrmode 0

View File

@@ -134,15 +134,57 @@
"100"
],
"HoldFd": true
},
{
"Name": "PowerHALMainState",
"Path": "vendor.powerhal.state",
"Values": [
"VIDEO_ENCODE",
"VR_SUSTAINED_PERFORMANCE",
"SUSTAINED_PERFORMANCE",
"VR_MODE",
""
],
"Type": "Property"
},
{
"Name": "PowerHALAudioState",
"Path": "vendor.powerhal.audio",
"Values": [
"AUDIO_LOW_LATENCY",
""
],
"Type": "Property"
},
{
"Name": "ThermalConfig",
"Path": "vendor.qcom.thermalcfg",
"Values": [
"/vendor/etc/thermal-engine-vr.conf",
"/vendor/etc/thermal-engine.conf"
],
"Type": "Property"
}
],
"Actions": [
{
"PowerHint": "VIDEO_ENCODE",
"Node": "PowerHALMainState",
"Duration": 0,
"Value": "VIDEO_ENCODE"
},
{
"PowerHint": "VIDEO_ENCODE",
"Node": "CPUBigClusterMaxFreq",
"Duration": 0,
"Value": "1958400"
},
{
"PowerHint": "SUSTAINED_PERFORMANCE",
"Node": "PowerHALMainState",
"Duration": 0,
"Value": "SUSTAINED_PERFORMANCE"
},
{
"PowerHint": "SUSTAINED_PERFORMANCE",
"Node": "CPUBigClusterMaxFreq",
@@ -161,6 +203,18 @@
"Duration": 0,
"Value": "342000000"
},
{
"PowerHint": "VR_MODE",
"Node": "PowerHALMainState",
"Duration": 0,
"Value": "VR_MODE"
},
{
"PowerHint": "VR_MODE",
"Node": "ThermalConfig",
"Duration": 0,
"Value": "/vendor/etc/thermal-engine-vr.conf"
},
{
"PowerHint": "VR_MODE",
"Node": "CPUBigClusterMaxFreq",
@@ -203,6 +257,18 @@
"Duration": 0,
"Value": "11863"
},
{
"PowerHint": "VR_SUSTAINED_PERFORMANCE",
"Node": "PowerHALMainState",
"Duration": 0,
"Value": "VR_MODE"
},
{
"PowerHint": "VR_SUSTAINED_PERFORMANCE",
"Node": "ThermalConfig",
"Duration": 0,
"Value": "/vendor/etc/thermal-engine-vr.conf"
},
{
"PowerHint": "VR_SUSTAINED_PERFORMANCE",
"Node": "CPUBigClusterMaxFreq",
@@ -443,6 +509,12 @@
"Duration": 2000,
"Value": "44"
},
{
"PowerHint": "AUDIO_LOW_LATENCY",
"Node": "PowerHALAudioState",
"Duration": 0,
"Value": "AUDIO_LOW_LATENCY"
},
{
"PowerHint": "AUDIO_LOW_LATENCY",
"Node": "PMQoSCpuDmaLatency",
@@ -450,4 +522,4 @@
"Value": "44"
}
]
}
}

View File

@@ -20,3 +20,6 @@ allow hal_power_default cgroup:file rw_file_perms;
# To get/set powerhal state property
set_prop(hal_power_default, power_prop)
# interact with thermal_config
set_prop(hal_power_default, thermal_prop)

View File

@@ -1,6 +0,0 @@
# interact with thermal_config
set_prop(hal_vr, thermal_prop)
# Access to touch vrmode node
allow hal_vr sysfs_touch:dir r_dir_perms;
allow hal_vr sysfs_touch:file rw_file_perms;

View File

@@ -16,8 +16,7 @@ vendor.debug.ssrdump u:object_r:vendor_ssr_prop:s0
persist.sys.cnss. u:object_r:cnss_diag_prop:s0
sys.listeners.registered u:object_r:tee_listener_prop:s0
wc_transport. u:object_r:wc_prop:s0
sys.qcom.thermalcfg u:object_r:thermal_prop:s0
ctl.vendor.thermal-engine u:object_r:thermal_prop:s0
vendor.qcom.thermalcfg u:object_r:thermal_prop:s0
persist.sys.modem.diag. u:object_r:modem_diag_prop:s0
sys.modem.diag. u:object_r:modem_diag_prop:s0
sys.time.set u:object_r:sys_time_prop:s0

View File

@@ -33,3 +33,6 @@ dontaudit vendor_init unlabeled:file getattr;
allow vendor_init debugfs_tracing_instances:dir create_dir_perms;
allow vendor_init debugfs_tracing_instances:file w_file_perms;
# Write to touch vrmode node
allow vendor_init sysfs_touch:file w_file_perms;

View File

@@ -1,30 +0,0 @@
//
// Copyright (C) 2017 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.
cc_binary {
name: "android.hardware.vr@1.0-service.wahoo",
relative_install_path: "hw",
init_rc: ["android.hardware.vr@1.0-service.wahoo.rc"],
srcs: ["service.cpp", "VrDevice.cpp"],
cflags: ["-Werror", "-Wall"],
shared_libs: [
"libbase",
"libhidlbase",
"libhidltransport",
"liblog",
"libutils",
"android.hardware.vr@1.0",
],
proprietary: true,
}

View File

@@ -1,10 +0,0 @@
Copyright (C) 2017 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.
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.

View File

@@ -1,92 +0,0 @@
/*
* Copyright (C) 2017 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 "VrDevice"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include "VrDevice.h"
namespace android {
namespace hardware {
namespace vr {
namespace V1_0 {
namespace implementation {
constexpr char kTouchVRModeSysfs[] = "/sys/devices/virtual/input/ftm4_touch/vrmode";
VrDevice::VrDevice() : mVRmode(false) {
std::string hardware = android::base::GetProperty("ro.hardware", "");
if (hardware == "taimen") {
mFtm4Touch = true;
} else {
mFtm4Touch = false;
}
}
Return<void> VrDevice::init() {
// NOOP
return Void();
}
Return<void> VrDevice::setVrMode(bool enabled) {
mVRmode = enabled;
if (enabled) {
if (!android::base::SetProperty("sys.qcom.thermalcfg",
"/vendor/etc/thermal-engine-vr.conf")) {
LOG(ERROR) << "Couldn't set thermal_engine enable property";
return Void();
}
} else {
if (!android::base::SetProperty("sys.qcom.thermalcfg",
"/vendor/etc/thermal-engine.conf")) {
LOG(ERROR) << "Couldn't set thermal_engine disable property";
return Void();
}
}
if (!android::base::SetProperty("ctl.restart", "vendor.thermal-engine")) {
LOG(ERROR) << "Couldn't set thermal_engine restart property";
}
if (mFtm4Touch &&
!android::base::WriteStringToFile((enabled ? "1" : "0"), kTouchVRModeSysfs)) {
PLOG(ERROR) << "Failed to write to vrmode sysfs node with :" << enabled;
}
return Void();
}
Return<void> VrDevice::debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) {
if (handle != nullptr && handle->numFds >= 1) {
int fd = handle->data[0];
std::string buf(android::base::StringPrintf("VRMode: %s\n",
(mVRmode ? "true" : "false")));
if (!android::base::WriteStringToFd(buf, fd)) {
PLOG(ERROR) << "Failed to dump state to fd";
}
fsync(fd);
}
return Void();
}
} // namespace implementation
} // namespace V1_0
} // namespace vr
} // namespace hardware
} // namespace android

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) 2017 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 ANDROID_HARDWARE_VR_V1_0_VR_H
#define ANDROID_HARDWARE_VR_V1_0_VR_H
#include <android/hardware/vr/1.0/IVr.h>
namespace android {
namespace hardware {
namespace vr {
namespace V1_0 {
namespace implementation {
using ::android::hardware::vr::V1_0::IVr;
using ::android::hardware::Return;
struct VrDevice : public IVr {
VrDevice();
Return<void> init() override;
Return<void> setVrMode(bool enabled) override;
Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) override;
private:
// Taimen display touch sensitivity for VR Mode (b/37515573)
bool mFtm4Touch;
bool mVRmode;
};
} // namespace implementation
} // namespace V1_0
} // namespace vr
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_VR_V1_0_VR_H

View File

@@ -1,10 +0,0 @@
service vendor.vr-wahoo-1-0 /vendor/bin/hw/android.hardware.vr@1.0-service.wahoo
class hal
user system
group system
# reset touch and thermal-engine when framework died and thermal-engine is in VR mode
on property:init.svc.zygote=restarting && property:sys.qcom.thermalcfg=/vendor/etc/thermal-engine-vr.conf
write /sys/devices/virtual/input/ftm4_touch/vrmode 0
setprop sys.qcom.thermalcfg "/vendor/etc/thermal-engine.conf"
restart vendor.thermal-engine

View File

@@ -1,38 +0,0 @@
/*
* Copyright (C) 2017 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 "android.hardware.vr@1.0-service.wahoo"
#include <android-base/logging.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/StrongPointer.h>
#include "VrDevice.h"
using ::android::hardware::configureRpcThreadpool;
using ::android::hardware::joinRpcThreadpool;
using ::android::hardware::vr::V1_0::implementation::VrDevice;
using ::android::hardware::vr::V1_0::IVr;
using ::android::sp;
int main(int /* argc */, char* /* argv */ []) {
sp<IVr> vr = new VrDevice;
configureRpcThreadpool(1, true);
CHECK_EQ(vr->registerAsService(), android::NO_ERROR)
<< "Failed to register vr HAL";
joinRpcThreadpool();
return 0;
}