1 /* 2 * Copyright (C) 2012 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 #ifndef EXYNOS_PRIMARY_DISPLAY_H 17 #define EXYNOS_PRIMARY_DISPLAY_H 18 19 #include <map> 20 21 #include "../libdevice/ExynosDisplay.h" 22 23 class ExynosPrimaryDisplay : public ExynosDisplay { 24 public: 25 /* Methods */ 26 ExynosPrimaryDisplay(uint32_t index, ExynosDevice *device); 27 ~ExynosPrimaryDisplay(); 28 virtual void setDDIScalerEnable(int width, int height); 29 virtual int getDDIScalerMode(int width, int height); 30 virtual int32_t SetCurrentPanelGammaSource(const displaycolor::DisplayType type, 31 const PanelGammaSource& source) override; GetCurrentPanelGammaSource()32 virtual PanelGammaSource GetCurrentPanelGammaSource() const override { 33 return currentPanelGammaSource; 34 } 35 isLhbmSupported()36 virtual bool isLhbmSupported() { return mLhbmFd ? true : false; } 37 virtual int32_t setLhbmState(bool enabled); 38 virtual int32_t setDisplayBrightness(float brightness) override; 39 40 virtual bool getLhbmState(); 41 virtual void notifyLhbmState(bool enabled); 42 virtual void setWakeupDisplay(); 43 44 virtual void initDisplayInterface(uint32_t interfaceType); 45 virtual int32_t doDisplayConfigInternal(hwc2_config_t config) override; 46 47 virtual int setMinIdleRefreshRate(const int fps) override; 48 virtual int setRefreshRateThrottleNanos(const int64_t delayNs) override; 49 virtual void dump(String8& result) override; 50 virtual void updateAppliedActiveConfig(const hwc2_config_t newConfig, 51 const int64_t ts) override; 52 53 protected: 54 /* setPowerMode(int32_t mode) 55 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE 56 * Parameters: 57 * mode - hwc2_power_mode_t and ext_hwc2_power_mode_t 58 * 59 * Returns HWC2_ERROR_NONE or the following error: 60 * HWC2_ERROR_UNSUPPORTED when DOZE mode not support 61 */ 62 virtual int32_t setPowerMode(int32_t mode) override; 63 virtual bool getHDRException(ExynosLayer* __unused layer); 64 virtual int32_t setActiveConfigInternal(hwc2_config_t config, bool force) override; 65 virtual int32_t getActiveConfigInternal(hwc2_config_t* outConfig) override; 66 public: 67 // Prepare multi resolution 68 ResolutionInfo mResolutionInfo; 69 70 private: 71 static constexpr const char* kDisplayCalFilePath = "/mnt/vendor/persist/display/"; 72 static constexpr const char* kPanelGammaCalFilePrefix = "gamma_calib_data"; 73 enum PanelGammaSource currentPanelGammaSource = PanelGammaSource::GAMMA_DEFAULT; 74 75 bool checkLhbmMode(bool status, nsecs_t timoutNs); 76 77 hwc2_config_t mPendActiveConfig = UINT_MAX; 78 bool mFirstPowerOn = true; 79 80 int32_t applyPendingConfig(); 81 int32_t setPowerOn(); 82 int32_t setPowerOff(); 83 int32_t setPowerDoze(hwc2_power_mode_t mode); 84 void firstPowerOn(); 85 86 std::string getPanelSysfsPath(const displaycolor::DisplayType& type); 87 88 // LHBM 89 FILE* mLhbmFd; 90 bool mLhbmOn; 91 bool mLhbmChanged; 92 93 std::atomic<bool> mLastRequestedLhbm; 94 std::atomic<bool> mLhbmStatusPending; 95 96 static constexpr const char *kLocalHbmModeFileNode = 97 "/sys/class/backlight/panel0-backlight/local_hbm_mode"; 98 std::mutex lhbm_mutex_; 99 std::condition_variable lhbm_cond_; 100 101 FILE* mWakeupDispFd; 102 static constexpr const char* kWakeupDispFilePath = 103 "/sys/devices/platform/1c300000.drmdecon/early_wakeup"; 104 105 void calculateTimeline(hwc2_config_t config, 106 hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints, 107 hwc_vsync_period_change_timeline_t* outTimeline) override; 108 int mMinIdleRefreshRate; 109 int64_t mRefreshRateDelayNanos; 110 int64_t mLastRefreshRateAppliedNanos; 111 hwc2_config_t mAppliedActiveConfig; 112 }; 113 114 #endif 115