blob: 09cde3bcd790ba7c464eeb3b9741d9039fc77d88 [file] [log] [blame]
Naseer Ahmed1589dee2012-07-21 12:17:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Saurabh Shahbbee5b12012-08-07 15:27:06 -07003 * Copyright (C) 2012, The Linux Foundation. All rights reserved.
Naseer Ahmed1589dee2012-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 Shahbbee5b12012-08-07 15:27:06 -070024#include <utils/threads.h>
25#include <linux/fb.h>
Naseer Ahmed080cfca2012-07-31 18:56:23 -070026
Naseer Ahmed1589dee2012-07-21 12:17:13 -070027struct hwc_context_t;
28
29namespace qhwc {
30
31class ExternalDisplay
32{
33 //Type of external display - OFF, HDMI, WFD
34 enum external_display_type {
35 EXT_TYPE_NONE,
36 EXT_TYPE_HDMI,
37 EXT_TYPE_WIFI
38 };
39
40 // Mirroring state
41 enum external_mirroring_state {
42 EXT_MIRRORING_OFF,
43 EXT_MIRRORING_ON,
44 };
Saurabh Shahbbee5b12012-08-07 15:27:06 -070045public:
Naseer Ahmed1589dee2012-07-21 12:17:13 -070046 ExternalDisplay(hwc_context_t* ctx);
47 ~ExternalDisplay();
Saurabh Shahbbee5b12012-08-07 15:27:06 -070048 int getModeCount() const;
49 void getEDIDModes(int *out) const;
Naseer Ahmed1589dee2012-07-21 12:17:13 -070050 int getExternalDisplay() const;
Naseer Ahmed080cfca2012-07-31 18:56:23 -070051 void setExternalDisplay(int connected);
52 bool commit();
53 int enableHDMIVsync(int enable);
Saurabh Shahbbee5b12012-08-07 15:27:06 -070054 void setHPD(uint32_t startEnd);
55 void setEDIDMode(int resMode);
56 void setActionSafeDimension(int w, int h);
Naseer Ahmed1589dee2012-07-21 12:17:13 -070057
Saurabh Shahbbee5b12012-08-07 15:27:06 -070058private:
Naseer Ahmed1589dee2012-07-21 12:17:13 -070059 bool readResolution();
Naseer Ahmed080cfca2012-07-31 18:56:23 -070060 int parseResolution(char* edidStr, int* edidModes);
Naseer Ahmed1589dee2012-07-21 12:17:13 -070061 void setResolution(int ID);
62 bool openFramebuffer();
Naseer Ahmed080cfca2012-07-31 18:56:23 -070063 bool closeFrameBuffer();
Naseer Ahmed1589dee2012-07-21 12:17:13 -070064 bool writeHPDOption(int userOption) const;
65 bool isValidMode(int ID);
66 void handleUEvent(char* str, int len);
67 int getModeOrder(int mode);
68 int getBestMode();
Naseer Ahmed080cfca2012-07-31 18:56:23 -070069 void resetInfo();
Naseer Ahmed1589dee2012-07-21 12:17:13 -070070
Saurabh Shahbbee5b12012-08-07 15:27:06 -070071 mutable android::Mutex mExtDispLock;
Naseer Ahmed080cfca2012-07-31 18:56:23 -070072 int mFd;
Naseer Ahmed080cfca2012-07-31 18:56:23 -070073 int mCurrentMode;
Saurabh Shahbbee5b12012-08-07 15:27:06 -070074 int mExternalDisplay;
75 int mResolutionMode;
Naseer Ahmed1589dee2012-07-21 12:17:13 -070076 char mEDIDs[128];
77 int mEDIDModes[64];
78 int mModeCount;
79 hwc_context_t *mHwcContext;
Naseer Ahmed080cfca2012-07-31 18:56:23 -070080 fb_var_screeninfo mVInfo;
Naseer Ahmed1589dee2012-07-21 12:17:13 -070081};
82
83}; //qhwc
84// ---------------------------------------------------------------------------
85#endif //HWC_EXTERNAL_DISPLAY_H