blob: 3cf5d63c071e3c23fcaeb277bc468768a0cd7ca7 [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 Qiu30c19ac2013-06-04 15:45:09 -070038#include <Drm.h>
Andy Qiu8a427142013-04-05 17:41:58 -070039#include <IDisplayDevice.h>
Andy Qiu6a6081a2013-03-22 16:25:43 -070040
41namespace android {
42namespace intel {
43
Andy Qiu6a6081a2013-03-22 16:25:43 -070044class Hwcomposer;
45
Andy Qiu8a427142013-04-05 17:41:58 -070046// Base class for primary and external devices
47class PhysicalDevice : public IDisplayDevice {
Andy Qiu6a6081a2013-03-22 16:25:43 -070048public:
Andy Qiu8a427142013-04-05 17:41:58 -070049 PhysicalDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
50 virtual ~PhysicalDevice();
Andy Qiu6a6081a2013-03-22 16:25:43 -070051public:
Andy Qiu8a427142013-04-05 17:41:58 -070052 virtual bool prePrepare(hwc_display_contents_1_t *display);
Andy Qiu6a6081a2013-03-22 16:25:43 -070053 virtual bool prepare(hwc_display_contents_1_t *display);
Andy Qiu4b834ce2013-04-09 18:23:20 -070054 virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context);
Andy Qiu6a6081a2013-03-22 16:25:43 -070055
Andy Qiueb726af2013-05-31 11:51:49 +080056 virtual bool vsyncControl(bool enabled);
57 virtual bool blank(bool blank);
Andy Qiu0131f122013-07-19 14:51:20 -070058 virtual bool getDisplaySize(int *width, int *height);
Andy Qiu6a6081a2013-03-22 16:25:43 -070059 virtual bool getDisplayConfigs(uint32_t *configs,
60 size_t *numConfigs);
61 virtual bool getDisplayAttributes(uint32_t config,
62 const uint32_t *attributes,
63 int32_t *values);
64 virtual bool compositionComplete();
65
66 // display config operations
67 virtual void removeDisplayConfigs();
68 virtual bool detectDisplayConfigs();
69
70 // device related operations
71 virtual bool initCheck() const { return mInitialized; }
72 virtual bool initialize();
fu jine2ad4c02013-05-28 13:47:51 -070073 virtual void deinitialize();
Andy Qiu6a6081a2013-03-22 16:25:43 -070074 virtual bool isConnected() const;
75 virtual const char* getName() const;
76 virtual int getType() const;
77
78 //events
Andy Qiu6a6081a2013-03-22 16:25:43 -070079 virtual void onVsync(int64_t timestamp);
80
81 virtual void dump(Dump& d);
Andy Qiu65efc252013-04-25 17:59:54 -070082
Andy Qiu6a6081a2013-03-22 16:25:43 -070083protected:
84 void onGeometryChanged(hwc_display_contents_1_t *list);
Lin Xie3f197402013-06-26 16:50:54 +080085 bool updateDisplayConfigs();
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 Qiueb726af2013-05-31 11:51:49 +080089 friend class VsyncEventObserver;
90
Andy Qiu6a6081a2013-03-22 16:25:43 -070091protected:
92 uint32_t mType;
93 const char *mName;
94
95 Hwcomposer& mHwc;
96 DisplayPlaneManager& mDisplayPlaneManager;
97
98 // display configs
99 Vector<DisplayConfig*> mDisplayConfigs;
100 int mActiveDisplayConfig;
101
Andy Qiu25caf442013-04-23 16:19:38 -0700102
Andy Qiueb726af2013-05-31 11:51:49 +0800103 IBlankControl *mBlankControl;
Andy Qiu25caf442013-04-23 16:19:38 -0700104 IPrepareListener *mPrepareListener;
Andy Qiueb726af2013-05-31 11:51:49 +0800105 VsyncEventObserver *mVsyncObserver;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700106
107 // layer list
108 HwcLayerList *mLayerList;
Andy Qiu30c19ac2013-06-04 15:45:09 -0700109 bool mConnected;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700110
111 // lock
112 Mutex mLock;
113
Andy Qiu65efc252013-04-25 17:59:54 -0700114 // DPMS on (1) or off (0)
115 int mDisplayState;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700116 bool mInitialized;
117};
118
119}
120}
121
Andy Qiu8a427142013-04-05 17:41:58 -0700122#endif /* PHYSICAL_DEVICE_H */