Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 3 | * Copyright (C) 2012-2014, 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 <linux/fb.h> |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 25 | |
Arun Kumar K.R | 2518757 | 2013-02-28 18:47:36 -0800 | [diff] [blame] | 26 | struct msm_hdmi_mode_timing_info; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 27 | |
| 28 | namespace qhwc { |
| 29 | |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 30 | //Type of scanning of EDID(Video Capability Data Block) |
| 31 | enum external_scansupport_type { |
| 32 | EXT_SCAN_NOT_SUPPORTED = 0, |
| 33 | EXT_SCAN_ALWAYS_OVERSCANED = 1, |
| 34 | EXT_SCAN_ALWAYS_UNDERSCANED = 2, |
| 35 | EXT_SCAN_BOTH_SUPPORTED = 3 |
| 36 | }; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 37 | |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 38 | // Structure to store EDID related data |
| 39 | struct EDIDData { |
| 40 | int mMode, mWidth, mHeight, mFps; |
| 41 | // Predetermined ordering for each mode |
| 42 | int mModeOrder; |
| 43 | EDIDData(int mode, int width, int height, int fps, int order) |
| 44 | : mMode(mode), mWidth(width), mHeight(height), mFps(fps), mModeOrder(order) |
| 45 | { } |
| 46 | }; |
| 47 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 48 | class ExternalDisplay |
| 49 | { |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 50 | public: |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 51 | ExternalDisplay(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 52 | ~ExternalDisplay(); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 53 | void setHPD(uint32_t startEnd); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 54 | void setActionSafeDimension(int w, int h); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 55 | bool isCEUnderscanSupported() { return mUnderscanSupported; } |
| 56 | int configure(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 57 | void getAttributes(uint32_t& width, uint32_t& height); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 58 | int teardown(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 59 | uint32_t getWidth() const { return mXres; }; |
| 60 | uint32_t getHeight() const { return mYres; }; |
| 61 | uint32_t getVsyncPeriod() const { return mVsyncPeriod; }; |
| 62 | int getFd() const { return mFd; }; |
| 63 | bool getMDPScalingMode() const { return mMDPScalingMode; } |
| 64 | void activateDisplay(); |
| 65 | /* Returns true if HDMI is the PRIMARY display device*/ |
| 66 | bool isHDMIPrimaryDisplay(); |
| 67 | int getConnectedState(); |
| 68 | /* when HDMI is an EXTERNAL display, PRIMARY display attributes are needed |
| 69 | for scaling mode */ |
| 70 | void setPrimaryAttributes(uint32_t primaryWidth, uint32_t primaryHeight); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 71 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 72 | private: |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 73 | int getModeCount() const; |
Arun Kumar K.R | 26808f3 | 2013-02-11 19:17:05 -0800 | [diff] [blame] | 74 | void setSPDInfo(const char* node, const char* property); |
Arun Kumar K.R | feb2d8a | 2013-02-01 02:53:13 -0800 | [diff] [blame] | 75 | void readCEUnderscanInfo(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 76 | bool readResolution(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 77 | int parseResolution(char* edidMode); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 78 | bool openFrameBuffer(); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 79 | bool closeFrameBuffer(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 80 | bool writeHPDOption(int userOption) const; |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 81 | bool isValidMode(int mode); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 82 | int getModeOrder(int mode); |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 83 | int getUserMode(); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 84 | int getBestMode(); |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 85 | bool isInterlacedMode(int mode); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 86 | void resetInfo(); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 87 | void setAttributes(); |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 88 | void getAttrForMode(uint32_t& width, uint32_t& height, uint32_t& fps); |
| 89 | int openDeviceNode(const char* node, int fileMode) const; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 90 | |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 91 | int mFd; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 92 | int mFbNum; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 93 | int mCurrentMode; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 94 | int mEDIDModes[64]; |
| 95 | int mModeCount; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 96 | fb_var_screeninfo mVInfo; |
Arun Kumar K.R | 2518757 | 2013-02-28 18:47:36 -0800 | [diff] [blame] | 97 | // Holds all the HDMI modes and timing info supported by driver |
| 98 | msm_hdmi_mode_timing_info* supported_video_mode_lut; |
Tatenda Chipeperekwa | 03d5df2 | 2014-09-16 18:09:18 -0700 | [diff] [blame^] | 99 | uint32_t mXres, mYres, mVsyncPeriod, mPrimaryWidth, mPrimaryHeight; |
| 100 | bool mMDPScalingMode; |
| 101 | bool mUnderscanSupported; |
| 102 | // Downscale feature switch, set via system property |
| 103 | // sys.hwc.mdp_downscale_enabled |
| 104 | bool mMDPDownscaleEnabled; |
| 105 | int mDisplayId; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | }; //qhwc |
| 109 | // --------------------------------------------------------------------------- |
| 110 | #endif //HWC_EXTERNAL_DISPLAY_H |