Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Tatenda Chipeperekwa | 1630119 | 2014-11-14 17:39:27 -0800 | [diff] [blame] | 3 | * Copyright (C) 2012-2015, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 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 | |
Tatenda Chipeperekwa | af2c004 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 21 | #ifndef HWC_HDMI_DISPLAY_H |
| 22 | #define HWC_HDMI_DISPLAY_H |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 23 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 24 | #include <linux/fb.h> |
Tatenda Chipeperekwa | 1630119 | 2014-11-14 17:39:27 -0800 | [diff] [blame] | 25 | #include <video/msm_hdmi_modes.h> |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 26 | |
Arun Kumar K.R | 2518757 | 2013-02-28 18:47:36 -0800 | [diff] [blame] | 27 | struct msm_hdmi_mode_timing_info; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 28 | |
| 29 | namespace qhwc { |
| 30 | |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 31 | //Type of scanning of EDID(Video Capability Data Block) |
Tatenda Chipeperekwa | af2c004 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 32 | enum hdmi_scansupport_type { |
| 33 | HDMI_SCAN_NOT_SUPPORTED = 0, |
| 34 | HDMI_SCAN_ALWAYS_OVERSCANED = 1, |
| 35 | HDMI_SCAN_ALWAYS_UNDERSCANED = 2, |
| 36 | HDMI_SCAN_BOTH_SUPPORTED = 3 |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 37 | }; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 38 | |
Tatenda Chipeperekwa | af2c004 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 39 | class HDMIDisplay |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 40 | { |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 41 | public: |
Tatenda Chipeperekwa | af2c004 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 42 | HDMIDisplay(); |
| 43 | ~HDMIDisplay(); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 44 | void setHPD(uint32_t startEnd); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 45 | void setActionSafeDimension(int w, int h); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 46 | bool isCEUnderscanSupported() { return mUnderscanSupported; } |
| 47 | int configure(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 48 | void getAttributes(uint32_t& width, uint32_t& height); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 49 | int teardown(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 50 | uint32_t getWidth() const { return mXres; }; |
| 51 | uint32_t getHeight() const { return mYres; }; |
| 52 | uint32_t getVsyncPeriod() const { return mVsyncPeriod; }; |
| 53 | int getFd() const { return mFd; }; |
| 54 | bool getMDPScalingMode() const { return mMDPScalingMode; } |
| 55 | void activateDisplay(); |
| 56 | /* Returns true if HDMI is the PRIMARY display device*/ |
| 57 | bool isHDMIPrimaryDisplay(); |
| 58 | int getConnectedState(); |
| 59 | /* when HDMI is an EXTERNAL display, PRIMARY display attributes are needed |
| 60 | for scaling mode */ |
| 61 | void setPrimaryAttributes(uint32_t primaryWidth, uint32_t primaryHeight); |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 62 | int getActiveConfig() const { return mActiveConfig; }; |
| 63 | int setActiveConfig(int newConfig); |
| 64 | int getAttrForConfig(int config, uint32_t& xres, |
Tatenda Chipeperekwa | 1630119 | 2014-11-14 17:39:27 -0800 | [diff] [blame] | 65 | uint32_t& yres, uint32_t& refresh, uint32_t& fps) const; |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 66 | int getDisplayConfigs(uint32_t* configs, size_t* numConfigs) const; |
Naseer Ahmed | 6bbd0a1 | 2015-01-23 11:57:10 -0500 | [diff] [blame] | 67 | bool configure3D(int s3dMode); |
| 68 | bool isS3DModeSupported(int s3dMode); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 69 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 70 | private: |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 71 | int getModeCount() const; |
Arun Kumar K.R | 26808f3 | 2013-02-11 19:17:05 -0800 | [diff] [blame] | 72 | void setSPDInfo(const char* node, const char* property); |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 73 | void readCEUnderscanInfo(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 74 | bool readResolution(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 75 | int parseResolution(char* edidMode); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 76 | bool openFrameBuffer(); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 77 | bool closeFrameBuffer(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 78 | bool writeHPDOption(int userOption) const; |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 79 | bool isValidMode(int mode); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 80 | int getModeOrder(int mode); |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 81 | int getUserConfig(); |
| 82 | int getBestConfig(); |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 83 | bool isInterlacedMode(int mode); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 84 | void resetInfo(); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 85 | void setAttributes(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 86 | int openDeviceNode(const char* node, int fileMode) const; |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 87 | int getModeIndex(int mode); |
| 88 | bool isValidConfigChange(int newConfig); |
Tatenda Chipeperekwa | 1630119 | 2014-11-14 17:39:27 -0800 | [diff] [blame] | 89 | void requestNewPage(int pageNumber); |
| 90 | void readConfigs(); |
| 91 | bool readResFile(char* configBuffer); |
Naseer Ahmed | 6bbd0a1 | 2015-01-23 11:57:10 -0500 | [diff] [blame] | 92 | bool writeS3DMode(int s3dMode); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 93 | |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 94 | int mFd; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 95 | int mFbNum; |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 96 | // mCurrentMode is the HDMI video format that corresponds to the mEDIDMode |
| 97 | // entry referenced by mActiveConfig |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 98 | int mCurrentMode; |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 99 | // mActiveConfig is the index correponding to the currently active mode for |
| 100 | // the HDMI display. It basically indexes the mEDIDMode array |
| 101 | int mActiveConfig; |
| 102 | // mEDIDModes contains a list of HDMI video formats (modes) supported by the |
| 103 | // HDMI display |
Tatenda Chipeperekwa | 1630119 | 2014-11-14 17:39:27 -0800 | [diff] [blame] | 104 | int mEDIDModes[HDMI_VFRMT_MAX]; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 105 | int mModeCount; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 106 | fb_var_screeninfo mVInfo; |
Arun Kumar K.R | 2518757 | 2013-02-28 18:47:36 -0800 | [diff] [blame] | 107 | // Holds all the HDMI modes and timing info supported by driver |
Tatenda Chipeperekwa | 1630119 | 2014-11-14 17:39:27 -0800 | [diff] [blame] | 108 | msm_hdmi_mode_timing_info *mDisplayConfigs; |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 109 | uint32_t mXres, mYres, mVsyncPeriod, mPrimaryWidth, mPrimaryHeight; |
| 110 | bool mMDPScalingMode; |
| 111 | bool mUnderscanSupported; |
| 112 | // Downscale feature switch, set via system property |
| 113 | // sys.hwc.mdp_downscale_enabled |
| 114 | bool mMDPDownscaleEnabled; |
Tatenda Chipeperekwa | 319eec1 | 2014-09-18 15:08:09 -0700 | [diff] [blame] | 115 | bool mEnableResolutionChange; |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame] | 116 | int mDisplayId; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | }; //qhwc |
| 120 | // --------------------------------------------------------------------------- |
Tatenda Chipeperekwa | af2c004 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 121 | #endif //HWC_HDMI_DISPLAY_H |