blob: cbba3fc2eb8fbe618e48d9fe8d63228292ce8d00 [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 */
Andy Qiu8a427142013-04-05 17:41:58 -070028#ifndef PHYSICAL_DEVICE_H
29#define PHYSICAL_DEVICE_H
Andy Qiu6a6081a2013-03-22 16:25:43 -070030
31#include <DisplayPlane.h>
Jackie Lie6ecdad2013-03-25 09:03:16 -070032#include <IVsyncControl.h>
33#include <IBlankControl.h>
Andy Qiu25caf442013-04-23 16:19:38 -070034#include <IPrepareListener.h>
Andy Qiu6a6081a2013-03-22 16:25:43 -070035#include <VsyncEventObserver.h>
36#include <HotplugEventObserver.h>
37#include <HwcLayerList.h>
Andy Qiu8a427142013-04-05 17:41:58 -070038#include <IDisplayDevice.h>
Andy Qiu6a6081a2013-03-22 16:25:43 -070039
40namespace android {
41namespace intel {
42
Andy Qiu6a6081a2013-03-22 16:25:43 -070043class Hwcomposer;
44
Andy Qiu8a427142013-04-05 17:41:58 -070045// Base class for primary and external devices
46class PhysicalDevice : public IDisplayDevice {
Andy Qiu6a6081a2013-03-22 16:25:43 -070047public:
Andy Qiu8a427142013-04-05 17:41:58 -070048 PhysicalDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
49 virtual ~PhysicalDevice();
Andy Qiu6a6081a2013-03-22 16:25:43 -070050public:
Andy Qiu8a427142013-04-05 17:41:58 -070051 virtual bool prePrepare(hwc_display_contents_1_t *display);
Andy Qiu6a6081a2013-03-22 16:25:43 -070052 virtual bool prepare(hwc_display_contents_1_t *display);
Andy Qiu4b834ce2013-04-09 18:23:20 -070053 virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context);
Andy Qiu6a6081a2013-03-22 16:25:43 -070054
55 virtual bool vsyncControl(int enabled);
56 virtual bool blank(int blank);
57 virtual bool getDisplayConfigs(uint32_t *configs,
58 size_t *numConfigs);
59 virtual bool getDisplayAttributes(uint32_t config,
60 const uint32_t *attributes,
61 int32_t *values);
62 virtual bool compositionComplete();
63
64 // display config operations
65 virtual void removeDisplayConfigs();
66 virtual bool detectDisplayConfigs();
67
68 // device related operations
69 virtual bool initCheck() const { return mInitialized; }
70 virtual bool initialize();
71 virtual bool isConnected() const;
72 virtual const char* getName() const;
73 virtual int getType() const;
74
75 //events
Andy Qiu6a6081a2013-03-22 16:25:43 -070076 virtual void onVsync(int64_t timestamp);
77
78 virtual void dump(Dump& d);
Andy Qiu65efc252013-04-25 17:59:54 -070079
Andy Qiu6a6081a2013-03-22 16:25:43 -070080protected:
Jackie Lie6ecdad2013-03-25 09:03:16 -070081 virtual void deinitialize();
Jackie Licf696452013-04-10 16:30:59 +080082
Andy Qiu6a6081a2013-03-22 16:25:43 -070083 void onGeometryChanged(hwc_display_contents_1_t *list);
84 bool updateDisplayConfigs(struct Output *output);
Jackie Licf696452013-04-10 16:30:59 +080085
Jackie Lie6ecdad2013-03-25 09:03:16 -070086 virtual IVsyncControl* createVsyncControl() = 0;
87 virtual IBlankControl* createBlankControl() = 0;
Andy Qiu25caf442013-04-23 16:19:38 -070088 virtual IPrepareListener* createPrepareListener() = 0;
Andy Qiu6a6081a2013-03-22 16:25:43 -070089protected:
90 uint32_t mType;
91 const char *mName;
92
93 Hwcomposer& mHwc;
94 DisplayPlaneManager& mDisplayPlaneManager;
95
96 // display configs
97 Vector<DisplayConfig*> mDisplayConfigs;
98 int mActiveDisplayConfig;
99
100 // vsync control
Jackie Lie6ecdad2013-03-25 09:03:16 -0700101 IVsyncControl *mVsyncControl;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700102 // blank control
Jackie Lie6ecdad2013-03-25 09:03:16 -0700103 IBlankControl *mBlankControl;
Andy Qiu25caf442013-04-23 16:19:38 -0700104
105 IPrepareListener *mPrepareListener;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700106 // vsync event observer
107 sp<VsyncEventObserver> mVsyncObserver;
108
109 // layer list
110 HwcLayerList *mLayerList;
111 DisplayPlane *mPrimaryPlane;
112 bool mConnection;
113
114 // lock
115 Mutex mLock;
116
Andy Qiu65efc252013-04-25 17:59:54 -0700117 // DPMS on (1) or off (0)
118 int mDisplayState;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700119 bool mInitialized;
120};
121
122}
123}
124
Andy Qiu8a427142013-04-05 17:41:58 -0700125#endif /* PHYSICAL_DEVICE_H */