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 ANDROID_HARDWARE_POWER_V1_2_POWER_H 18 #define ANDROID_HARDWARE_POWER_V1_2_POWER_H 19 20 #include <atomic> 21 22 #include <android/hardware/power/1.2/IPower.h> 23 #include <hidl/MQDescriptor.h> 24 #include <hidl/Status.h> 25 #include <perfmgr/HintManager.h> 26 27 #include "InteractionHandler.h" 28 29 namespace android { 30 namespace hardware { 31 namespace power { 32 namespace V1_2 { 33 namespace implementation { 34 35 using ::android::hardware::power::V1_0::Feature; 36 using ::android::hardware::power::V1_2::IPower; 37 using ::android::hardware::Return; 38 using ::android::hardware::Void; 39 using ::InteractionHandler; 40 using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint; 41 using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; 42 using ::android::perfmgr::HintManager; 43 44 constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; 45 constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; 46 47 struct Power : public IPower { 48 // Methods from ::android::hardware::power::V1_0::IPower follow. 49 50 Power(); 51 52 Return<void> setInteractive(bool /* interactive */) override; 53 Return<void> powerHint(PowerHint_1_0 hint, int32_t data) override; 54 Return<void> setFeature(Feature feature, bool activate) override; 55 Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; 56 57 // Methods from ::android::hardware::power::V1_1::IPower follow. 58 Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; 59 Return<void> powerHintAsync(PowerHint_1_0 hint, int32_t data) override; 60 61 // Methods from ::android::hardware::power::V1_2::IPower follow. 62 Return<void> powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override; 63 64 // Methods from ::android::hidl::base::V1_0::IBase follow. 65 Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override; 66 67 private: 68 static bool isSupportedGovernor(); 69 70 std::shared_ptr<HintManager> mHintManager; 71 InteractionHandler mInteractionHandler; 72 std::atomic<bool> mVRModeOn; 73 std::atomic<bool> mSustainedPerfModeOn; 74 std::atomic<bool> mEncoderModeOn; 75 }; 76 77 } // namespace implementation 78 } // namespace V1_2 79 } // namespace power 80 } // namespace hardware 81 } // namespace android 82 83 #endif // ANDROID_HARDWARE_POWER_V1_2_POWER_H 84