external.h revision 90eaa60b7db56c6c494bf7cb10115a97e4bac3bc
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 <utils/threads.h>
25#include <linux/fb.h>
26
27struct hwc_context_t;
28struct msm_hdmi_mode_timing_info;
29
30namespace qhwc {
31
32//Type of scanning of EDID(Video Capability Data Block)
33enum external_scansupport_type {
34    EXT_SCAN_NOT_SUPPORTED      = 0,
35    EXT_SCAN_ALWAYS_OVERSCANED  = 1,
36    EXT_SCAN_ALWAYS_UNDERSCANED = 2,
37    EXT_SCAN_BOTH_SUPPORTED     = 3
38};
39
40class ExternalDisplay
41{
42public:
43    ExternalDisplay(hwc_context_t* ctx);
44    ~ExternalDisplay();
45    int getModeCount() const;
46    void getEDIDModes(int *out) const;
47    bool isCEUnderscanSupported() { return mUnderscanSupported; }
48    void setExternalDisplay(bool connected, int extFbNum = 0);
49    bool isExternalConnected() { return mConnected;};
50    void  setExtDpyNum(int extDpyNum) { mExtDpyNum = extDpyNum;};
51    void setHPD(uint32_t startEnd);
52    void setEDIDMode(int resMode);
53    void setActionSafeDimension(int w, int h);
54    void processUEventOnline(const char *str);
55    void processUEventOffline(const char *str);
56
57private:
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(int fbNum);
64    bool closeFrameBuffer();
65    bool writeHPDOption(int userOption) const;
66    bool isValidMode(int ID);
67    void handleUEvent(char* str, int len);
68    int  getModeOrder(int mode);
69    int  getUserMode();
70    int  getBestMode();
71    bool isInterlacedMode(int mode);
72    void resetInfo();
73    void setDpyHdmiAttr();
74    void setDpyWfdAttr();
75    void getAttrForMode(int& width, int& height, int& fps);
76    void updateExtDispDevFbIndex();
77    int  configureHDMIDisplay();
78    int  configureWFDDisplay();
79    int  teardownHDMIDisplay();
80    int  teardownWFDDisplay();
81    int  getExtFbNum(int &fbNum);
82
83    mutable android::Mutex mExtDispLock;
84    int mFd;
85    int mCurrentMode;
86    int mConnected;
87    int mConnectedFbNum;
88    int mResolutionMode;
89    char mEDIDs[128];
90    int mEDIDModes[64];
91    int mModeCount;
92    bool mUnderscanSupported;
93    hwc_context_t *mHwcContext;
94    fb_var_screeninfo mVInfo;
95    int mHdmiFbNum;
96    int mWfdFbNum;
97    int mExtDpyNum;
98    // Holds all the HDMI modes and timing info supported by driver
99    msm_hdmi_mode_timing_info* supported_video_mode_lut;
100};
101
102}; //qhwc
103// ---------------------------------------------------------------------------
104#endif //HWC_EXTERNAL_DISPLAY_H
105