blob: 16ffc86afdeb58fd363af76dfcead6caa5ee6f20 [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>
Jackie Lie6ecdad2013-03-25 09:03:16 -070032#include <IVsyncControl.h>
33#include <IBlankControl.h>
Andy Qiu6a6081a2013-03-22 16:25:43 -070034#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 {}
Andy Qiu6a6081a2013-03-22 16:25:43 -070051public:
52 int getRefreshRate() const { return mRefreshRate; }
53 int getWidth() const { return mWidth; }
54 int getHeight() const { return mHeight; }
55 int getDpiX() const { return mDpiX; }
56 int getDpiY() const { return mDpiY; }
57private:
58 int mRefreshRate;
59 int mWidth;
60 int mHeight;
61 int mDpiX;
62 int mDpiY;
63};
64
65class Hwcomposer;
66
67// generic display device
68class DisplayDevice {
69public:
70 // display device type
71 enum {
72 DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY,
73 DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL,
74 DEVICE_VIRTUAL = HWC_NUM_DISPLAY_TYPES,
75 DEVICE_COUNT,
76 };
77 enum {
78 DEVICE_DISCONNECTED = 0,
79 DEVICE_CONNECTED,
80 };
81public:
82 DisplayDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
83 virtual ~DisplayDevice();
84public:
85 virtual void prePrepare(hwc_display_contents_1_t *display);
86 virtual bool prepare(hwc_display_contents_1_t *display);
87 virtual bool commit(hwc_display_contents_1_t *display,
88 void* context,
89 int& count) = 0;
90
91 virtual bool vsyncControl(int enabled);
92 virtual bool blank(int blank);
93 virtual bool getDisplayConfigs(uint32_t *configs,
94 size_t *numConfigs);
95 virtual bool getDisplayAttributes(uint32_t config,
96 const uint32_t *attributes,
97 int32_t *values);
98 virtual bool compositionComplete();
99
100 // display config operations
101 virtual void removeDisplayConfigs();
102 virtual bool detectDisplayConfigs();
103
104 // device related operations
105 virtual bool initCheck() const { return mInitialized; }
106 virtual bool initialize();
107 virtual bool isConnected() const;
108 virtual const char* getName() const;
109 virtual int getType() const;
110
111 //events
Jackie Lie6ecdad2013-03-25 09:03:16 -0700112 virtual void onHotplug();
Andy Qiu6a6081a2013-03-22 16:25:43 -0700113 virtual void onVsync(int64_t timestamp);
114
115 virtual void dump(Dump& d);
116protected:
Jackie Lie6ecdad2013-03-25 09:03:16 -0700117 virtual void deinitialize();
118protected:
Andy Qiu6a6081a2013-03-22 16:25:43 -0700119 void onGeometryChanged(hwc_display_contents_1_t *list);
120 bool updateDisplayConfigs(struct Output *output);
121protected:
Jackie Lie6ecdad2013-03-25 09:03:16 -0700122 virtual IVsyncControl* createVsyncControl() = 0;
123 virtual IBlankControl* createBlankControl() = 0;
124 virtual IHotplugControl* createHotplugControl() = 0;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700125protected:
126 uint32_t mType;
127 const char *mName;
128
129 Hwcomposer& mHwc;
130 DisplayPlaneManager& mDisplayPlaneManager;
131
132 // display configs
133 Vector<DisplayConfig*> mDisplayConfigs;
134 int mActiveDisplayConfig;
135
136 // vsync control
Jackie Lie6ecdad2013-03-25 09:03:16 -0700137 IVsyncControl *mVsyncControl;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700138 // blank control
Jackie Lie6ecdad2013-03-25 09:03:16 -0700139 IBlankControl *mBlankControl;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700140 // hotplug control
Jackie Lie6ecdad2013-03-25 09:03:16 -0700141 IHotplugControl *mHotplugControl;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700142
143 // hotplug event observer
144 sp<HotplugEventObserver> mHotplugObserver;
145 // vsync event observer
146 sp<VsyncEventObserver> mVsyncObserver;
147
148 // layer list
149 HwcLayerList *mLayerList;
150 DisplayPlane *mPrimaryPlane;
151 bool mConnection;
152
153 // lock
154 Mutex mLock;
155
156 bool mInitialized;
157};
158
159}
160}
161
162#endif /* DISPLAYDEVICE_H_ */