blob: ea1742516fe35425ab98c4a9a93efb86e07657cb [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 Qiu6a6081a2013-03-22 16:25:43 -070034#include <VsyncEventObserver.h>
35#include <HotplugEventObserver.h>
36#include <HwcLayerList.h>
Andy Qiu8a427142013-04-05 17:41:58 -070037#include <IDisplayDevice.h>
Andy Qiu6a6081a2013-03-22 16:25:43 -070038
39namespace android {
40namespace intel {
41
Andy Qiu6a6081a2013-03-22 16:25:43 -070042class Hwcomposer;
43
Andy Qiu8a427142013-04-05 17:41:58 -070044// Base class for primary and external devices
45class PhysicalDevice : public IDisplayDevice {
Andy Qiu6a6081a2013-03-22 16:25:43 -070046public:
Andy Qiu8a427142013-04-05 17:41:58 -070047 PhysicalDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
48 virtual ~PhysicalDevice();
Andy Qiu6a6081a2013-03-22 16:25:43 -070049public:
Andy Qiu8a427142013-04-05 17:41:58 -070050 virtual bool prePrepare(hwc_display_contents_1_t *display);
Andy Qiu6a6081a2013-03-22 16:25:43 -070051 virtual bool prepare(hwc_display_contents_1_t *display);
Andy Qiu4b834ce2013-04-09 18:23:20 -070052 virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context);
Andy Qiu6a6081a2013-03-22 16:25:43 -070053
54 virtual bool vsyncControl(int enabled);
55 virtual bool blank(int blank);
56 virtual bool getDisplayConfigs(uint32_t *configs,
57 size_t *numConfigs);
58 virtual bool getDisplayAttributes(uint32_t config,
59 const uint32_t *attributes,
60 int32_t *values);
61 virtual bool compositionComplete();
62
63 // display config operations
64 virtual void removeDisplayConfigs();
65 virtual bool detectDisplayConfigs();
66
67 // device related operations
68 virtual bool initCheck() const { return mInitialized; }
69 virtual bool initialize();
70 virtual bool isConnected() const;
71 virtual const char* getName() const;
72 virtual int getType() const;
73
74 //events
Andy Qiu6a6081a2013-03-22 16:25:43 -070075 virtual void onVsync(int64_t timestamp);
76
77 virtual void dump(Dump& d);
78protected:
Jackie Lie6ecdad2013-03-25 09:03:16 -070079 virtual void deinitialize();
Jackie Licf696452013-04-10 16:30:59 +080080
Andy Qiu6a6081a2013-03-22 16:25:43 -070081 void onGeometryChanged(hwc_display_contents_1_t *list);
82 bool updateDisplayConfigs(struct Output *output);
Jackie Licf696452013-04-10 16:30:59 +080083
Jackie Lie6ecdad2013-03-25 09:03:16 -070084 virtual IVsyncControl* createVsyncControl() = 0;
85 virtual IBlankControl* createBlankControl() = 0;
Andy Qiu6a6081a2013-03-22 16:25:43 -070086protected:
87 uint32_t mType;
88 const char *mName;
89
90 Hwcomposer& mHwc;
91 DisplayPlaneManager& mDisplayPlaneManager;
92
93 // display configs
94 Vector<DisplayConfig*> mDisplayConfigs;
95 int mActiveDisplayConfig;
96
97 // vsync control
Jackie Lie6ecdad2013-03-25 09:03:16 -070098 IVsyncControl *mVsyncControl;
Andy Qiu6a6081a2013-03-22 16:25:43 -070099 // blank control
Jackie Lie6ecdad2013-03-25 09:03:16 -0700100 IBlankControl *mBlankControl;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700101 // vsync event observer
102 sp<VsyncEventObserver> mVsyncObserver;
103
104 // layer list
105 HwcLayerList *mLayerList;
106 DisplayPlane *mPrimaryPlane;
107 bool mConnection;
108
109 // lock
110 Mutex mLock;
111
112 bool mInitialized;
113};
114
115}
116}
117
Andy Qiu8a427142013-04-05 17:41:58 -0700118#endif /* PHYSICAL_DEVICE_H */