1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  * Copyright (C) 2012-2013, 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_EXTERNAL_DISPLAY_H
22 #define HWC_EXTERNAL_DISPLAY_H
23 
24 #include <linux/fb.h>
25 
26 struct hwc_context_t;
27 struct msm_hdmi_mode_timing_info;
28 
29 namespace qhwc {
30 
31 //Type of scanning of EDID(Video Capability Data Block)
32 enum external_scansupport_type {
33     EXT_SCAN_NOT_SUPPORTED      = 0,
34     EXT_SCAN_ALWAYS_OVERSCANED  = 1,
35     EXT_SCAN_ALWAYS_UNDERSCANED = 2,
36     EXT_SCAN_BOTH_SUPPORTED     = 3
37 };
38 
39 class ExternalDisplay
40 {
41 public:
42     ExternalDisplay(hwc_context_t* ctx);
43     ~ExternalDisplay();
44     void setHPD(uint32_t startEnd);
45     void setActionSafeDimension(int w, int h);
isCEUnderscanSupported()46     bool isCEUnderscanSupported() { return mUnderscanSupported; }
47     int configure();
48     void getAttributes(int& width, int& height);
49     int teardown();
isConnected()50     bool isConnected() {
51         return  mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].connected;
52     }
53 
54 private:
55     int getModeCount() const;
56     void getEDIDModes(int *out) const;
57     void setEDIDMode(int resMode);
58     void setSPDInfo(const char* node, const char* property);
59     void readCEUnderscanInfo();
60     bool readResolution();
61     int  parseResolution(char* edidStr, int* edidModes);
62     void setResolution(int ID);
63     bool openFrameBuffer();
64     bool closeFrameBuffer();
65     bool writeHPDOption(int userOption) const;
66     bool isValidMode(int ID);
67     int  getModeOrder(int mode);
68     int  getUserMode();
69     int  getBestMode();
70     bool isInterlacedMode(int mode);
71     void resetInfo();
72     void setAttributes();
73     void getAttrForMode(int& width, int& height, int& fps);
74 
75     int mFd;
76     int mFbNum;
77     int mCurrentMode;
78     int mEDIDModes[64];
79     int mModeCount;
80     bool mUnderscanSupported;
81     hwc_context_t *mHwcContext;
82     fb_var_screeninfo mVInfo;
83     // Holds all the HDMI modes and timing info supported by driver
84     msm_hdmi_mode_timing_info* supported_video_mode_lut;
85 };
86 
87 }; //qhwc
88 // ---------------------------------------------------------------------------
89 #endif //HWC_EXTERNAL_DISPLAY_H
90