blob: d35490f9fa278a884cd12a1d4ad600bbb830ed9e [file] [log] [blame]
Naseer Ahmed72cf9762012-07-21 12:17:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Arun Kumar K.R25187572013-02-28 18:47:36 -08003 * Copyright (C) 2012-2013, 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
21#ifndef HWC_EXTERNAL_DISPLAY_H
22#define HWC_EXTERNAL_DISPLAY_H
23
Saurabh Shah56f610d2012-08-07 15:27:06 -070024#include <utils/threads.h>
25#include <linux/fb.h>
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070026
Naseer Ahmed72cf9762012-07-21 12:17:13 -070027struct hwc_context_t;
Arun Kumar K.R25187572013-02-28 18:47:36 -080028struct msm_hdmi_mode_timing_info;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070029
30namespace qhwc {
31
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -080032//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};
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080039
Naseer Ahmed72cf9762012-07-21 12:17:13 -070040class ExternalDisplay
41{
Saurabh Shah56f610d2012-08-07 15:27:06 -070042public:
Naseer Ahmed72cf9762012-07-21 12:17:13 -070043 ExternalDisplay(hwc_context_t* ctx);
44 ~ExternalDisplay();
Saurabh Shah56f610d2012-08-07 15:27:06 -070045 int getModeCount() const;
46 void getEDIDModes(int *out) const;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -080047 bool isCEUnderscanSupported() { return mUnderscanSupported; }
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080048 void setExternalDisplay(bool connected, int extFbNum = 0);
49 bool isExternalConnected() { return mConnected;};
Amara Venkata Mastan Manoj Kumar11a380d2013-01-17 09:30:56 -080050 void setExtDpyNum(int extDpyNum) { mExtDpyNum = extDpyNum;};
Amara Venkata Mastan Manoj Kumarb156a2f2013-02-07 16:42:50 -080051 int getExternalType() {return mConnectedFbNum;};
52 bool isWFDActive() {return (mConnectedFbNum == mWfdFbNum);};
Saurabh Shah56f610d2012-08-07 15:27:06 -070053 void setHPD(uint32_t startEnd);
54 void setEDIDMode(int resMode);
55 void setActionSafeDimension(int w, int h);
Amara Venkata Mastan Manoj Kumarb156a2f2013-02-07 16:42:50 -080056 int ignoreRequest(const char *str);
57 int configureHDMIDisplay();
58 int configureWFDDisplay();
59 int teardownHDMIDisplay();
60 int teardownWFDDisplay();
Naseer Ahmed72cf9762012-07-21 12:17:13 -070061
Saurabh Shah56f610d2012-08-07 15:27:06 -070062private:
Arun Kumar K.R26808f32013-02-11 19:17:05 -080063 void setSPDInfo(const char* node, const char* property);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -080064 void readCEUnderscanInfo();
Naseer Ahmed72cf9762012-07-21 12:17:13 -070065 bool readResolution();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080066 int parseResolution(char* edidStr, int* edidModes);
Naseer Ahmed72cf9762012-07-21 12:17:13 -070067 void setResolution(int ID);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080068 bool openFrameBuffer(int fbNum);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070069 bool closeFrameBuffer();
Naseer Ahmed72cf9762012-07-21 12:17:13 -070070 bool writeHPDOption(int userOption) const;
71 bool isValidMode(int ID);
72 void handleUEvent(char* str, int len);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080073 int getModeOrder(int mode);
Arun Kumar K.R37552c52012-12-10 12:47:18 -080074 int getUserMode();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080075 int getBestMode();
Arun Kumar K.R37552c52012-12-10 12:47:18 -080076 bool isInterlacedMode(int mode);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070077 void resetInfo();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080078 void setDpyHdmiAttr();
79 void setDpyWfdAttr();
Saurabh Shah3e858eb2012-09-17 16:53:21 -070080 void getAttrForMode(int& width, int& height, int& fps);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080081 void updateExtDispDevFbIndex();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080082 int getExtFbNum(int &fbNum);
Naseer Ahmed72cf9762012-07-21 12:17:13 -070083
Saurabh Shah56f610d2012-08-07 15:27:06 -070084 mutable android::Mutex mExtDispLock;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070085 int mFd;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070086 int mCurrentMode;
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080087 int mConnected;
88 int mConnectedFbNum;
Saurabh Shah56f610d2012-08-07 15:27:06 -070089 int mResolutionMode;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070090 char mEDIDs[128];
91 int mEDIDModes[64];
92 int mModeCount;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -080093 bool mUnderscanSupported;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070094 hwc_context_t *mHwcContext;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070095 fb_var_screeninfo mVInfo;
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080096 int mHdmiFbNum;
97 int mWfdFbNum;
Amara Venkata Mastan Manoj Kumar11a380d2013-01-17 09:30:56 -080098 int mExtDpyNum;
Arun Kumar K.R25187572013-02-28 18:47:36 -080099 // Holds all the HDMI modes and timing info supported by driver
100 msm_hdmi_mode_timing_info* supported_video_mode_lut;
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700101};
102
103}; //qhwc
104// ---------------------------------------------------------------------------
105#endif //HWC_EXTERNAL_DISPLAY_H