Jan Altensen | e0dd329 | 2020-02-01 06:21:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The LineageOS 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_0_POWER_H |
| 18 | #define ANDROID_HARDWARE_POWER_V1_0_POWER_H |
| 19 | |
| 20 | #include <android/hardware/power/1.0/IPower.h> |
| 21 | #include <hidl/MQDescriptor.h> |
| 22 | #include <hidl/Status.h> |
| 23 | #include <vendor/lineage/power/1.0/ILineagePower.h> |
| 24 | |
| 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace power { |
| 28 | namespace V1_0 { |
| 29 | namespace implementation { |
| 30 | |
| 31 | using ::android::sp; |
| 32 | using ::android::hardware::hidl_array; |
| 33 | using ::android::hardware::hidl_memory; |
| 34 | using ::android::hardware::hidl_string; |
| 35 | using ::android::hardware::hidl_vec; |
| 36 | using ::android::hardware::Return; |
| 37 | using ::android::hardware::Void; |
| 38 | |
| 39 | using ::vendor::lineage::power::V1_0::ILineagePower; |
| 40 | using ::vendor::lineage::power::V1_0::LineageFeature; |
| 41 | using ::vendor::lineage::power::V1_0::LineagePowerHint; |
| 42 | |
| 43 | // clang-format off |
| 44 | enum PowerProfile { |
| 45 | POWER_SAVE = 0, |
| 46 | BALANCED, |
| 47 | HIGH_PERFORMANCE, |
| 48 | MAX |
| 49 | }; |
| 50 | // clang-format on |
| 51 | |
| 52 | struct Power : public IPower, public ILineagePower { |
| 53 | Return<void> setInteractive(bool interactive) override; |
| 54 | Return<void> powerHint(PowerHint hint, int32_t data) override; |
| 55 | Return<void> setFeature(Feature feature, bool activate) override; |
| 56 | Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; |
| 57 | |
| 58 | Return<int32_t> getFeature(LineageFeature feature) override; |
| 59 | |
| 60 | private: |
| 61 | void initialize(); |
| 62 | void findInputNodes(); |
| 63 | void setProfile(PowerProfile profile); |
| 64 | void sendBoostpulse(); |
| 65 | void sendBoost(int duration_us); |
| 66 | |
| 67 | bool initialized; |
| 68 | bool touchkeys_blocked; |
| 69 | std::string sec_touchkey; |
| 70 | std::string sec_touchscreen; |
| 71 | PowerProfile current_profile; |
| 72 | std::vector<std::string> hispeed_freqs; |
| 73 | std::vector<std::string> max_freqs; |
| 74 | }; |
| 75 | |
| 76 | } // namespace implementation |
| 77 | } // namespace V1_0 |
| 78 | } // namespace power |
| 79 | } // namespace hardware |
| 80 | } // namespace android |
| 81 | |
| 82 | #endif // ANDROID_HARDWARE_POWER_V1_0_POWER_H |