1 /* 2 * Copyright (C) 2022 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 EXYNOS_DISPLAY_MODULE_ZUMA_H 18 #define EXYNOS_DISPLAY_MODULE_ZUMA_H 19 20 #include "../../gs201/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h" 21 22 namespace zuma { 23 24 using namespace displaycolor; 25 26 class ExynosPrimaryDisplayModule : public gs201::ExynosPrimaryDisplayModule { 27 public: 28 ExynosPrimaryDisplayModule(uint32_t index, ExynosDevice* device, 29 const std::string& displayName); 30 ~ExynosPrimaryDisplayModule(); 31 virtual int32_t validateWinConfigData(); 32 void checkPreblendingRequirement() override; 33 34 protected: 35 class OperationRateManager 36 : public gs201::ExynosPrimaryDisplayModule::OperationRateManager { 37 public: 38 OperationRateManager(ExynosPrimaryDisplay* display, int32_t hsHz, int32_t nsHz); 39 virtual ~OperationRateManager(); 40 41 int32_t onLowPowerMode(bool enabled) override; 42 int32_t onPeakRefreshRate(uint32_t rate) override; 43 int32_t onConfig(hwc2_config_t cfg) override; 44 int32_t onBrightness(uint32_t dbv) override; 45 int32_t onPowerMode(int32_t mode) override; 46 int32_t getTargetOperationRate() const override; 47 48 private: 49 enum class DispOpCondition : uint32_t { 50 PANEL_SET_POWER = 0, 51 SET_CONFIG, 52 SET_DBV, 53 MAX, 54 }; 55 56 int32_t updateOperationRateLocked(const DispOpCondition cond); 57 int32_t setTargetOperationRate(const int32_t rate); 58 59 ExynosPrimaryDisplay* mDisplay; 60 int32_t mDisplayHsOperationRate; 61 int32_t mDisplayNsOperationRate; 62 int32_t mDisplayTargetOperationRate; 63 int32_t mDisplayNsMinDbv; 64 int32_t mDisplayPeakRefreshRate; 65 int32_t mDisplayRefreshRate; 66 int32_t mDisplayLastDbv; 67 int32_t mDisplayDbv; 68 std::optional<hwc2_power_mode_t> mDisplayPowerMode; 69 bool mDisplayLowBatteryModeEnabled; 70 Mutex mLock; 71 72 static constexpr uint32_t BRIGHTNESS_DELTA_THRESHOLD = 10; 73 static constexpr uint32_t LP_OP_RATE = 30; 74 }; 75 }; 76 77 } // namespace zuma 78 79 #endif // EXYNOS_DISPLAY_MODULE_ZUMA_H 80