blob: db7ff42feb3fb58df088be7cce210badafe2ec96 [file] [log] [blame]
Andy Qiu6a6081a2013-03-22 16:25:43 -07001/*
2 * Copyright © 2012 Intel Corporation
3 * All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 *
24 * Authors:
25 * Jackie Li <yaodong.li@intel.com>
26 *
27 */
28#ifndef DISPLAYDEVICE_H_
29#define DISPLAYDEVICE_H_
30
31#include <DisplayPlane.h>
32#include <VsyncControl.h>
33#include <BlankControl.h>
34#include <VsyncEventObserver.h>
35#include <HotplugEventObserver.h>
36#include <HwcLayerList.h>
37
38namespace android {
39namespace intel {
40
41// display config
42class DisplayConfig {
43public:
44 DisplayConfig(int rr, int w, int h, int dpix, int dpiy)
45 : mRefreshRate(rr),
46 mWidth(w),
47 mHeight(h),
48 mDpiX(dpix),
49 mDpiY(dpiy)
50 {}
51 ~DisplayConfig() {}
52public:
53 int getRefreshRate() const { return mRefreshRate; }
54 int getWidth() const { return mWidth; }
55 int getHeight() const { return mHeight; }
56 int getDpiX() const { return mDpiX; }
57 int getDpiY() const { return mDpiY; }
58private:
59 int mRefreshRate;
60 int mWidth;
61 int mHeight;
62 int mDpiX;
63 int mDpiY;
64};
65
66class Hwcomposer;
67
68// generic display device
69class DisplayDevice {
70public:
71 // display device type
72 enum {
73 DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY,
74 DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL,
75 DEVICE_VIRTUAL = HWC_NUM_DISPLAY_TYPES,
76 DEVICE_COUNT,
77 };
78 enum {
79 DEVICE_DISCONNECTED = 0,
80 DEVICE_CONNECTED,
81 };
82public:
83 DisplayDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
84 virtual ~DisplayDevice();
85public:
86 virtual void prePrepare(hwc_display_contents_1_t *display);
87 virtual bool prepare(hwc_display_contents_1_t *display);
88 virtual bool commit(hwc_display_contents_1_t *display,
89 void* context,
90 int& count) = 0;
91
92 virtual bool vsyncControl(int enabled);
93 virtual bool blank(int blank);
94 virtual bool getDisplayConfigs(uint32_t *configs,
95 size_t *numConfigs);
96 virtual bool getDisplayAttributes(uint32_t config,
97 const uint32_t *attributes,
98 int32_t *values);
99 virtual bool compositionComplete();
100
101 // display config operations
102 virtual void removeDisplayConfigs();
103 virtual bool detectDisplayConfigs();
104
105 // device related operations
106 virtual bool initCheck() const { return mInitialized; }
107 virtual bool initialize();
108 virtual bool isConnected() const;
109 virtual const char* getName() const;
110 virtual int getType() const;
111
112 //events
113 virtual void onHotplug(int connected);
114 virtual void onVsync(int64_t timestamp);
115
116 virtual void dump(Dump& d);
117protected:
118 void onGeometryChanged(hwc_display_contents_1_t *list);
119 bool updateDisplayConfigs(struct Output *output);
120protected:
121 virtual VsyncControl* createVsyncControl() = 0;
122 virtual BlankControl* createBlankControl() = 0;
123 virtual HotplugControl* createHotplugControl() = 0;
124protected:
125 uint32_t mType;
126 const char *mName;
127
128 Hwcomposer& mHwc;
129 DisplayPlaneManager& mDisplayPlaneManager;
130
131 // display configs
132 Vector<DisplayConfig*> mDisplayConfigs;
133 int mActiveDisplayConfig;
134
135 // vsync control
136 VsyncControl *mVsyncControl;
137 // blank control
138 BlankControl *mBlankControl;
139 // hotplug control
140 HotplugControl *mHotplugControl;
141
142 // hotplug event observer
143 sp<HotplugEventObserver> mHotplugObserver;
144 // vsync event observer
145 sp<VsyncEventObserver> mVsyncObserver;
146
147 // layer list
148 HwcLayerList *mLayerList;
149 DisplayPlane *mPrimaryPlane;
150 bool mConnection;
151
152 // lock
153 Mutex mLock;
154
155 bool mInitialized;
156};
157
158}
159}
160
161#endif /* DISPLAYDEVICE_H_ */