1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef POWER_LIBPERFMGR_POWER_H_ 18 #define POWER_LIBPERFMGR_POWER_H_ 19 20 #include <atomic> 21 #include <memory> 22 #include <thread> 23 24 #include <android/hardware/power/1.3/IPower.h> 25 #include <hidl/MQDescriptor.h> 26 #include <hidl/Status.h> 27 #include <perfmgr/HintManager.h> 28 29 #include "CameraMode.h" 30 #include "disp-power/DisplayLowPower.h" 31 #include "disp-power/InteractionHandler.h" 32 33 namespace android { 34 namespace hardware { 35 namespace power { 36 namespace V1_3 { 37 namespace implementation { 38 39 using ::InteractionHandler; 40 using ::android::hardware::Return; 41 using ::android::hardware::Void; 42 using ::android::hardware::power::V1_0::Feature; 43 using ::android::hardware::power::V1_3::IPower; 44 using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint; 45 using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; 46 using PowerHint_1_3 = ::android::hardware::power::V1_3::PowerHint; 47 using ::android::perfmgr::HintManager; 48 49 class Power : public IPower { 50 public: 51 // Methods from ::android::hardware::power::V1_0::IPower follow. 52 53 Power(); 54 55 Return<void> setInteractive(bool /* interactive */) override; 56 Return<void> powerHint(PowerHint_1_0 hint, int32_t data) override; 57 Return<void> setFeature(Feature feature, bool activate) override; 58 Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; 59 60 // Methods from ::android::hardware::power::V1_1::IPower follow. 61 Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; 62 Return<void> powerHintAsync(PowerHint_1_0 hint, int32_t data) override; 63 64 // Methods from ::android::hardware::power::V1_2::IPower follow. 65 Return<void> powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override; 66 67 // Methods from ::android::hardware::power::V1_3::IPower follow. 68 Return<void> powerHintAsync_1_3(PowerHint_1_3 hint, int32_t data) override; 69 70 // Methods from ::android::hidl::base::V1_0::IBase follow. 71 Return<void> debug(const hidl_handle &fd, const hidl_vec<hidl_string> &args) override; 72 73 private: 74 std::shared_ptr<HintManager> mHintManager; 75 std::unique_ptr<InteractionHandler> mInteractionHandler; 76 std::unique_ptr<DisplayLowPower> mDisplayLowPower; 77 std::atomic<bool> mVRModeOn; 78 std::atomic<bool> mSustainedPerfModeOn; 79 std::atomic<enum CameraStreamingMode> mCameraStreamingMode; 80 std::atomic<bool> mReady; 81 std::thread mInitThread; 82 }; 83 84 } // namespace implementation 85 } // namespace V1_3 86 } // namespace power 87 } // namespace hardware 88 } // namespace android 89 90 #endif // POWER_LIBPERFMGR_POWER_H_ 91