blob: c35f04f00b2efbd9abca92dbbea2b1c1be645983 [file] [log] [blame]
Andy Qiu6a6081a2013-03-22 16:25:43 -07001/*
Prodyut Hazarikacd727f52014-07-23 19:34:42 -07002// Copyright (c) 2014 Intel Corporation 
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
Andy Qiu8a427142013-04-05 17:41:58 -070016#ifndef PHYSICAL_DEVICE_H
17#define PHYSICAL_DEVICE_H
Andy Qiu6a6081a2013-03-22 16:25:43 -070018
19#include <DisplayPlane.h>
Jackie Lie6ecdad2013-03-25 09:03:16 -070020#include <IVsyncControl.h>
21#include <IBlankControl.h>
Andy Qiu25caf442013-04-23 16:19:38 -070022#include <IPrepareListener.h>
Thierry Strudel0594c422014-07-14 14:54:55 -070023#include <common/observers/VsyncEventObserver.h>
24#include <common/base/HwcLayerList.h>
25#include <common/base/Drm.h>
Andy Qiu8a427142013-04-05 17:41:58 -070026#include <IDisplayDevice.h>
Andy Qiu6a6081a2013-03-22 16:25:43 -070027
28namespace android {
29namespace intel {
30
Andy Qiu6a6081a2013-03-22 16:25:43 -070031class Hwcomposer;
32
Andy Qiu8a427142013-04-05 17:41:58 -070033// Base class for primary and external devices
34class PhysicalDevice : public IDisplayDevice {
Andy Qiu6a6081a2013-03-22 16:25:43 -070035public:
Andy Qiu8a427142013-04-05 17:41:58 -070036 PhysicalDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
37 virtual ~PhysicalDevice();
Andy Qiu6a6081a2013-03-22 16:25:43 -070038public:
Andy Qiu8a427142013-04-05 17:41:58 -070039 virtual bool prePrepare(hwc_display_contents_1_t *display);
Andy Qiu6a6081a2013-03-22 16:25:43 -070040 virtual bool prepare(hwc_display_contents_1_t *display);
Andy Qiu4b834ce2013-04-09 18:23:20 -070041 virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context);
Andy Qiu6a6081a2013-03-22 16:25:43 -070042
Andy Qiueb726af2013-05-31 11:51:49 +080043 virtual bool vsyncControl(bool enabled);
44 virtual bool blank(bool blank);
Andy Qiu0131f122013-07-19 14:51:20 -070045 virtual bool getDisplaySize(int *width, int *height);
Andy Qiu6a6081a2013-03-22 16:25:43 -070046 virtual bool getDisplayConfigs(uint32_t *configs,
47 size_t *numConfigs);
48 virtual bool getDisplayAttributes(uint32_t config,
49 const uint32_t *attributes,
50 int32_t *values);
51 virtual bool compositionComplete();
52
53 // display config operations
54 virtual void removeDisplayConfigs();
55 virtual bool detectDisplayConfigs();
56
57 // device related operations
58 virtual bool initCheck() const { return mInitialized; }
59 virtual bool initialize();
fu jine2ad4c02013-05-28 13:47:51 -070060 virtual void deinitialize();
Andy Qiu6a6081a2013-03-22 16:25:43 -070061 virtual bool isConnected() const;
62 virtual const char* getName() const;
63 virtual int getType() const;
64
65 //events
Andy Qiu6a6081a2013-03-22 16:25:43 -070066 virtual void onVsync(int64_t timestamp);
67
68 virtual void dump(Dump& d);
Andy Qiu65efc252013-04-25 17:59:54 -070069
Andy Qiu6a6081a2013-03-22 16:25:43 -070070protected:
71 void onGeometryChanged(hwc_display_contents_1_t *list);
Lin Xie3f197402013-06-26 16:50:54 +080072 bool updateDisplayConfigs();
Jackie Lie6ecdad2013-03-25 09:03:16 -070073 virtual IVsyncControl* createVsyncControl() = 0;
74 virtual IBlankControl* createBlankControl() = 0;
Andy Qiu25caf442013-04-23 16:19:38 -070075 virtual IPrepareListener* createPrepareListener() = 0;
Andy Qiueb726af2013-05-31 11:51:49 +080076 friend class VsyncEventObserver;
77
Andy Qiu6a6081a2013-03-22 16:25:43 -070078protected:
79 uint32_t mType;
80 const char *mName;
81
82 Hwcomposer& mHwc;
83 DisplayPlaneManager& mDisplayPlaneManager;
84
85 // display configs
86 Vector<DisplayConfig*> mDisplayConfigs;
87 int mActiveDisplayConfig;
88
Andy Qiu25caf442013-04-23 16:19:38 -070089
Andy Qiueb726af2013-05-31 11:51:49 +080090 IBlankControl *mBlankControl;
Andy Qiu25caf442013-04-23 16:19:38 -070091 IPrepareListener *mPrepareListener;
Andy Qiueb726af2013-05-31 11:51:49 +080092 VsyncEventObserver *mVsyncObserver;
Andy Qiu6a6081a2013-03-22 16:25:43 -070093
94 // layer list
95 HwcLayerList *mLayerList;
Andy Qiu30c19ac2013-06-04 15:45:09 -070096 bool mConnected;
fu jin24131022013-10-15 17:48:28 -070097 bool mBlank;
Andy Qiu6a6081a2013-03-22 16:25:43 -070098
99 // lock
100 Mutex mLock;
101
Andy Qiu65efc252013-04-25 17:59:54 -0700102 // DPMS on (1) or off (0)
103 int mDisplayState;
Andy Qiu6a6081a2013-03-22 16:25:43 -0700104 bool mInitialized;
105};
106
107}
108}
109
Andy Qiu8a427142013-04-05 17:41:58 -0700110#endif /* PHYSICAL_DEVICE_H */