1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved. 4 * 5 * Not a Contribution, Apache license notifications and license are 6 * retained for attribution purposes only. 7 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 #ifndef HWC_HDMI_DISPLAY_H 22 #define HWC_HDMI_DISPLAY_H 23 24 #include <linux/fb.h> 25 26 struct msm_hdmi_mode_timing_info; 27 28 namespace qhwc { 29 30 //Type of scanning of EDID(Video Capability Data Block) 31 enum hdmi_scansupport_type { 32 HDMI_SCAN_NOT_SUPPORTED = 0, 33 HDMI_SCAN_ALWAYS_OVERSCANED = 1, 34 HDMI_SCAN_ALWAYS_UNDERSCANED = 2, 35 HDMI_SCAN_BOTH_SUPPORTED = 3 36 }; 37 38 // Structure to store EDID related data 39 struct EDIDData { 40 int mMode, mWidth, mHeight, mFps; 41 // Predetermined ordering for each mode 42 int mModeOrder; EDIDDataEDIDData43 EDIDData(int mode, int width, int height, int fps, int order) 44 : mMode(mode), mWidth(width), mHeight(height), mFps(fps), mModeOrder(order) 45 { } 46 }; 47 48 class HDMIDisplay 49 { 50 public: 51 HDMIDisplay(); 52 ~HDMIDisplay(); 53 void setHPD(uint32_t startEnd); 54 void setActionSafeDimension(int w, int h); isCEUnderscanSupported()55 bool isCEUnderscanSupported() { return mUnderscanSupported; } 56 int configure(); 57 void getAttributes(uint32_t& width, uint32_t& height); 58 int teardown(); getWidth()59 uint32_t getWidth() const { return mXres; }; getHeight()60 uint32_t getHeight() const { return mYres; }; getVsyncPeriod()61 uint32_t getVsyncPeriod() const { return mVsyncPeriod; }; getFd()62 int getFd() const { return mFd; }; getMDPScalingMode()63 bool getMDPScalingMode() const { return mMDPScalingMode; } 64 void activateDisplay(); 65 /* Returns true if HDMI is the PRIMARY display device*/ 66 bool isHDMIPrimaryDisplay(); 67 int getConnectedState(); 68 /* when HDMI is an EXTERNAL display, PRIMARY display attributes are needed 69 for scaling mode */ 70 void setPrimaryAttributes(uint32_t primaryWidth, uint32_t primaryHeight); getActiveConfig()71 int getActiveConfig() const { return mActiveConfig; }; 72 int setActiveConfig(int newConfig); 73 int getAttrForConfig(int config, uint32_t& xres, 74 uint32_t& yres, uint32_t& refresh) const; 75 int getDisplayConfigs(uint32_t* configs, size_t* numConfigs) const; 76 77 private: 78 int getModeCount() const; 79 void setSPDInfo(const char* node, const char* property); 80 void readCEUnderscanInfo(); 81 bool readResolution(); 82 int parseResolution(char* edidMode); 83 bool openFrameBuffer(); 84 bool closeFrameBuffer(); 85 bool writeHPDOption(int userOption) const; 86 bool isValidMode(int mode); 87 int getModeOrder(int mode); 88 int getUserConfig(); 89 int getBestConfig(); 90 bool isInterlacedMode(int mode); 91 void resetInfo(); 92 void setAttributes(); 93 void getAttrForMode(uint32_t& width, uint32_t& height, uint32_t& fps); 94 int openDeviceNode(const char* node, int fileMode) const; 95 int getModeIndex(int mode); 96 bool isValidConfigChange(int newConfig); 97 98 int mFd; 99 int mFbNum; 100 // mCurrentMode is the HDMI video format that corresponds to the mEDIDMode 101 // entry referenced by mActiveConfig 102 int mCurrentMode; 103 // mActiveConfig is the index correponding to the currently active mode for 104 // the HDMI display. It basically indexes the mEDIDMode array 105 int mActiveConfig; 106 // mEDIDModes contains a list of HDMI video formats (modes) supported by the 107 // HDMI display 108 int mEDIDModes[64]; 109 int mModeCount; 110 fb_var_screeninfo mVInfo; 111 // Holds all the HDMI modes and timing info supported by driver 112 msm_hdmi_mode_timing_info* supported_video_mode_lut; 113 uint32_t mXres, mYres, mVsyncPeriod, mPrimaryWidth, mPrimaryHeight; 114 bool mMDPScalingMode; 115 bool mUnderscanSupported; 116 // Downscale feature switch, set via system property 117 // sys.hwc.mdp_downscale_enabled 118 bool mMDPDownscaleEnabled; 119 bool mEnableResolutionChange; 120 int mDisplayId; 121 }; 122 123 }; //qhwc 124 // --------------------------------------------------------------------------- 125 #endif //HWC_HDMI_DISPLAY_H 126