blob: 32c48ff4699ccadc189e6ff2bebbd61313c14b27 [file] [log] [blame]
Naseer Ahmed72cf9762012-07-21 12:17:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Tatenda Chipeperekwa16301192014-11-14 17:39:27 -08003 * Copyright (C) 2012-2015, The Linux Foundation. All rights reserved.
Naseer Ahmed72cf9762012-07-21 12:17:13 -07004 *
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 Chipeperekwaaf2c0042014-09-17 12:55:01 -070021#ifndef HWC_HDMI_DISPLAY_H
22#define HWC_HDMI_DISPLAY_H
Naseer Ahmed72cf9762012-07-21 12:17:13 -070023
Saurabh Shah56f610d2012-08-07 15:27:06 -070024#include <linux/fb.h>
Tatenda Chipeperekwa16301192014-11-14 17:39:27 -080025#include <video/msm_hdmi_modes.h>
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070026
Arun Kumar K.R25187572013-02-28 18:47:36 -080027struct msm_hdmi_mode_timing_info;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070028
29namespace qhwc {
30
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -080031//Type of scanning of EDID(Video Capability Data Block)
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -070032enum 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.Rfeb2d8a2013-02-01 02:53:13 -080037};
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080038
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -070039class HDMIDisplay
Naseer Ahmed72cf9762012-07-21 12:17:13 -070040{
Saurabh Shah56f610d2012-08-07 15:27:06 -070041public:
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -070042 HDMIDisplay();
43 ~HDMIDisplay();
Saurabh Shah56f610d2012-08-07 15:27:06 -070044 void setHPD(uint32_t startEnd);
Saurabh Shah56f610d2012-08-07 15:27:06 -070045 void setActionSafeDimension(int w, int h);
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070046 bool isCEUnderscanSupported() { return mUnderscanSupported; }
47 int configure();
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070048 void getAttributes(uint32_t& width, uint32_t& height);
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070049 int teardown();
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070050 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 Chipeperekwa319eec12014-09-18 15:08:09 -070062 int getActiveConfig() const { return mActiveConfig; };
63 int setActiveConfig(int newConfig);
64 int getAttrForConfig(int config, uint32_t& xres,
Tatenda Chipeperekwa16301192014-11-14 17:39:27 -080065 uint32_t& yres, uint32_t& refresh, uint32_t& fps) const;
Tatenda Chipeperekwa319eec12014-09-18 15:08:09 -070066 int getDisplayConfigs(uint32_t* configs, size_t* numConfigs) const;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070067
Saurabh Shah56f610d2012-08-07 15:27:06 -070068private:
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070069 int getModeCount() const;
Arun Kumar K.R26808f32013-02-11 19:17:05 -080070 void setSPDInfo(const char* node, const char* property);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -080071 void readCEUnderscanInfo();
Naseer Ahmed72cf9762012-07-21 12:17:13 -070072 bool readResolution();
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070073 int parseResolution(char* edidMode);
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070074 bool openFrameBuffer();
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070075 bool closeFrameBuffer();
Naseer Ahmed72cf9762012-07-21 12:17:13 -070076 bool writeHPDOption(int userOption) const;
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070077 bool isValidMode(int mode);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080078 int getModeOrder(int mode);
Tatenda Chipeperekwa319eec12014-09-18 15:08:09 -070079 int getUserConfig();
80 int getBestConfig();
Arun Kumar K.R37552c52012-12-10 12:47:18 -080081 bool isInterlacedMode(int mode);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070082 void resetInfo();
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070083 void setAttributes();
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070084 int openDeviceNode(const char* node, int fileMode) const;
Tatenda Chipeperekwa319eec12014-09-18 15:08:09 -070085 int getModeIndex(int mode);
86 bool isValidConfigChange(int newConfig);
Tatenda Chipeperekwa16301192014-11-14 17:39:27 -080087 void requestNewPage(int pageNumber);
88 void readConfigs();
89 bool readResFile(char* configBuffer);
Naseer Ahmed72cf9762012-07-21 12:17:13 -070090
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070091 int mFd;
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070092 int mFbNum;
Tatenda Chipeperekwa319eec12014-09-18 15:08:09 -070093 // mCurrentMode is the HDMI video format that corresponds to the mEDIDMode
94 // entry referenced by mActiveConfig
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070095 int mCurrentMode;
Tatenda Chipeperekwa319eec12014-09-18 15:08:09 -070096 // mActiveConfig is the index correponding to the currently active mode for
97 // the HDMI display. It basically indexes the mEDIDMode array
98 int mActiveConfig;
99 // mEDIDModes contains a list of HDMI video formats (modes) supported by the
100 // HDMI display
Tatenda Chipeperekwa16301192014-11-14 17:39:27 -0800101 int mEDIDModes[HDMI_VFRMT_MAX];
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700102 int mModeCount;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700103 fb_var_screeninfo mVInfo;
Arun Kumar K.R25187572013-02-28 18:47:36 -0800104 // Holds all the HDMI modes and timing info supported by driver
Tatenda Chipeperekwa16301192014-11-14 17:39:27 -0800105 msm_hdmi_mode_timing_info *mDisplayConfigs;
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700106 uint32_t mXres, mYres, mVsyncPeriod, mPrimaryWidth, mPrimaryHeight;
107 bool mMDPScalingMode;
108 bool mUnderscanSupported;
109 // Downscale feature switch, set via system property
110 // sys.hwc.mdp_downscale_enabled
111 bool mMDPDownscaleEnabled;
Tatenda Chipeperekwa319eec12014-09-18 15:08:09 -0700112 bool mEnableResolutionChange;
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700113 int mDisplayId;
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700114};
115
116}; //qhwc
117// ---------------------------------------------------------------------------
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700118#endif //HWC_HDMI_DISPLAY_H