blob: d85ce4425536c79428a0108a840bdd5ff375c4fb [file] [log] [blame]
Naseer Ahmed72cf9762012-07-21 12:17:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Saurabh Shah56f610d2012-08-07 15:27:06 -07003 * Copyright (C) 2012, 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;
28
29namespace qhwc {
30
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080031
Naseer Ahmed72cf9762012-07-21 12:17:13 -070032class ExternalDisplay
33{
Saurabh Shah56f610d2012-08-07 15:27:06 -070034public:
Naseer Ahmed72cf9762012-07-21 12:17:13 -070035 ExternalDisplay(hwc_context_t* ctx);
36 ~ExternalDisplay();
Saurabh Shah56f610d2012-08-07 15:27:06 -070037 int getModeCount() const;
38 void getEDIDModes(int *out) const;
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080039 void setExternalDisplay(bool connected, int extFbNum = 0);
40 bool isExternalConnected() { return mConnected;};
Saurabh Shah3e858eb2012-09-17 16:53:21 -070041 bool post();
Saurabh Shah56f610d2012-08-07 15:27:06 -070042 void setHPD(uint32_t startEnd);
43 void setEDIDMode(int resMode);
44 void setActionSafeDimension(int w, int h);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080045 void processUEventOnline(const char *str);
46 void processUEventOffline(const char *str);
Naseer Ahmed72cf9762012-07-21 12:17:13 -070047
Saurabh Shah56f610d2012-08-07 15:27:06 -070048private:
Naseer Ahmed72cf9762012-07-21 12:17:13 -070049 bool readResolution();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080050 int parseResolution(char* edidStr, int* edidModes);
Naseer Ahmed72cf9762012-07-21 12:17:13 -070051 void setResolution(int ID);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080052 bool openFrameBuffer(int fbNum);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070053 bool closeFrameBuffer();
Naseer Ahmed72cf9762012-07-21 12:17:13 -070054 bool writeHPDOption(int userOption) const;
55 bool isValidMode(int ID);
56 void handleUEvent(char* str, int len);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080057 int getModeOrder(int mode);
Arun Kumar K.R37552c52012-12-10 12:47:18 -080058 int getUserMode();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080059 int getBestMode();
Arun Kumar K.R37552c52012-12-10 12:47:18 -080060 bool isInterlacedMode(int mode);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070061 void resetInfo();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080062 void setDpyHdmiAttr();
63 void setDpyWfdAttr();
Saurabh Shah3e858eb2012-09-17 16:53:21 -070064 void getAttrForMode(int& width, int& height, int& fps);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080065 void updateExtDispDevFbIndex();
66 int configureHDMIDisplay();
67 int configureWFDDisplay();
68 int teardownHDMIDisplay();
69 int teardownWFDDisplay();
70 int getExtFbNum(int &fbNum);
Naseer Ahmed72cf9762012-07-21 12:17:13 -070071
Saurabh Shah56f610d2012-08-07 15:27:06 -070072 mutable android::Mutex mExtDispLock;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070073 int mFd;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070074 int mCurrentMode;
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080075 int mConnected;
76 int mConnectedFbNum;
Saurabh Shah56f610d2012-08-07 15:27:06 -070077 int mResolutionMode;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070078 char mEDIDs[128];
79 int mEDIDModes[64];
80 int mModeCount;
81 hwc_context_t *mHwcContext;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -070082 fb_var_screeninfo mVInfo;
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080083 int mHdmiFbNum;
84 int mWfdFbNum;
Naseer Ahmed72cf9762012-07-21 12:17:13 -070085};
86
87}; //qhwc
88// ---------------------------------------------------------------------------
89#endif //HWC_EXTERNAL_DISPLAY_H