blob: e7cb8904cc8142cafab661771d5804bc4a9674f0 [file] [log] [blame]
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
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_EXT_OBSERVER_H
22#define HWC_EXT_OBSERVER_H
23
24#include <utils/threads.h>
25
26struct hwc_context_t;
27
28namespace qhwc {
29
30class ExtDisplayObserver : public android::Thread
31{
32 //Type of external display - OFF, HDMI, WFD
33 enum external_display_type {
34 EXT_TYPE_NONE,
35 EXT_TYPE_HDMI,
36 EXT_TYPE_WIFI
37 };
38
39 // Mirroring state
40 enum external_mirroring_state {
41 EXT_MIRRORING_OFF,
42 EXT_MIRRORING_ON,
43 };
44 public:
45 /*Overrides*/
46 virtual bool threadLoop();
47 virtual int readyToRun();
48 virtual void onFirstRef();
49
50 virtual ~ExtDisplayObserver();
51 static ExtDisplayObserver *getInstance();
52 int getExternalDisplay() const;
53 void setHwcContext(hwc_context_t* hwcCtx);
54
55 private:
56 ExtDisplayObserver();
57 void setExternalDisplayStatus(int connected);
58 bool readResolution();
59 int parseResolution(char* edidStr, int* edidModes, int len);
60 void setResolution(int ID);
61 bool openFramebuffer();
62 bool writeHPDOption(int userOption) const;
63 bool isValidMode(int ID);
64 void handleUEvent(char* str);
65 int getModeOrder(int mode);
66 int getBestMode();
67
68 int fd;
69 int mExternalDisplay;
70 int mCurrentID;
71 char mEDIDs[128];
72 int mEDIDModes[64];
73 int mModeCount;
74 hwc_context_t *mHwcContext;
75 static android::sp<ExtDisplayObserver> sExtDisplayObserverInstance;
76};
77
78}; //qhwc
79// ---------------------------------------------------------------------------
80#endif //HWC_EXT_OBSERVER_H