Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 3 | * Copyright (C) 2012, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 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 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 24 | #include <utils/threads.h> |
| 25 | #include <linux/fb.h> |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 26 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 27 | struct hwc_context_t; |
| 28 | |
| 29 | namespace qhwc { |
| 30 | |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 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 | }; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 38 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 39 | class ExternalDisplay |
| 40 | { |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 41 | public: |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 42 | ExternalDisplay(hwc_context_t* ctx); |
| 43 | ~ExternalDisplay(); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 44 | int getModeCount() const; |
| 45 | void getEDIDModes(int *out) const; |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 46 | bool isCEUnderscanSupported() { return mUnderscanSupported; } |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 47 | void setExternalDisplay(bool connected, int extFbNum = 0); |
| 48 | bool isExternalConnected() { return mConnected;}; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 49 | void setExtDpyNum(int extDpyNum) { mExtDpyNum = extDpyNum;}; |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame^] | 50 | int getExternalType() {return mConnectedFbNum;}; |
| 51 | bool isWFDActive() {return (mConnectedFbNum == mWfdFbNum);}; |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 52 | void setHPD(uint32_t startEnd); |
| 53 | void setEDIDMode(int resMode); |
| 54 | void setActionSafeDimension(int w, int h); |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame^] | 55 | int ignoreRequest(const char *str); |
| 56 | int configureHDMIDisplay(); |
| 57 | int configureWFDDisplay(); |
| 58 | int teardownHDMIDisplay(); |
| 59 | int teardownWFDDisplay(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 60 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 61 | private: |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 62 | void readCEUnderscanInfo(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 63 | bool readResolution(); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 64 | int parseResolution(char* edidStr, int* edidModes); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 65 | void setResolution(int ID); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 66 | bool openFrameBuffer(int fbNum); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 67 | bool closeFrameBuffer(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 68 | bool writeHPDOption(int userOption) const; |
| 69 | bool isValidMode(int ID); |
| 70 | void handleUEvent(char* str, int len); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 71 | int getModeOrder(int mode); |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 72 | int getUserMode(); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 73 | int getBestMode(); |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 74 | bool isInterlacedMode(int mode); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 75 | void resetInfo(); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 76 | void setDpyHdmiAttr(); |
| 77 | void setDpyWfdAttr(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 78 | void getAttrForMode(int& width, int& height, int& fps); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 79 | void updateExtDispDevFbIndex(); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 80 | int getExtFbNum(int &fbNum); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 81 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 82 | mutable android::Mutex mExtDispLock; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 83 | int mFd; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 84 | int mCurrentMode; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 85 | int mConnected; |
| 86 | int mConnectedFbNum; |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 87 | int mResolutionMode; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 88 | char mEDIDs[128]; |
| 89 | int mEDIDModes[64]; |
| 90 | int mModeCount; |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 91 | bool mUnderscanSupported; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 92 | hwc_context_t *mHwcContext; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 93 | fb_var_screeninfo mVInfo; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 94 | int mHdmiFbNum; |
| 95 | int mWfdFbNum; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 96 | int mExtDpyNum; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | }; //qhwc |
| 100 | // --------------------------------------------------------------------------- |
| 101 | #endif //HWC_EXTERNAL_DISPLAY_H |