| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 1 | /* |
| Prodyut Hazarika | cd727f5 | 2014-07-23 19:34:42 -0700 | [diff] [blame] | 2 | // 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 Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 16 | #ifndef PHYSICAL_DEVICE_H |
| 17 | #define PHYSICAL_DEVICE_H |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 18 | |
| 19 | #include <DisplayPlane.h> |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame] | 20 | #include <IVsyncControl.h> |
| 21 | #include <IBlankControl.h> |
| Andy Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 22 | #include <IPrepareListener.h> |
| Thierry Strudel | 0594c42 | 2014-07-14 14:54:55 -0700 | [diff] [blame] | 23 | #include <common/observers/VsyncEventObserver.h> |
| 24 | #include <common/base/HwcLayerList.h> |
| 25 | #include <common/base/Drm.h> |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 26 | #include <IDisplayDevice.h> |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace intel { |
| 30 | |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 31 | class Hwcomposer; |
| 32 | |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 33 | // Base class for primary and external devices |
| 34 | class PhysicalDevice : public IDisplayDevice { |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 35 | public: |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 36 | PhysicalDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm); |
| 37 | virtual ~PhysicalDevice(); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 38 | public: |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 39 | virtual bool prePrepare(hwc_display_contents_1_t *display); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 40 | virtual bool prepare(hwc_display_contents_1_t *display); |
| Andy Qiu | 4b834ce | 2013-04-09 18:23:20 -0700 | [diff] [blame] | 41 | virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 42 | |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 43 | virtual bool vsyncControl(bool enabled); |
| 44 | virtual bool blank(bool blank); |
| Andy Qiu | 0131f12 | 2013-07-19 14:51:20 -0700 | [diff] [blame] | 45 | virtual bool getDisplaySize(int *width, int *height); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 46 | 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 jin | e2ad4c0 | 2013-05-28 13:47:51 -0700 | [diff] [blame] | 60 | virtual void deinitialize(); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 61 | virtual bool isConnected() const; |
| 62 | virtual const char* getName() const; |
| 63 | virtual int getType() const; |
| 64 | |
| 65 | //events |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 66 | virtual void onVsync(int64_t timestamp); |
| 67 | |
| 68 | virtual void dump(Dump& d); |
| Andy Qiu | 65efc25 | 2013-04-25 17:59:54 -0700 | [diff] [blame] | 69 | |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 70 | protected: |
| 71 | void onGeometryChanged(hwc_display_contents_1_t *list); |
| Lin Xie | 3f19740 | 2013-06-26 16:50:54 +0800 | [diff] [blame] | 72 | bool updateDisplayConfigs(); |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame] | 73 | virtual IVsyncControl* createVsyncControl() = 0; |
| 74 | virtual IBlankControl* createBlankControl() = 0; |
| Andy Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 75 | virtual IPrepareListener* createPrepareListener() = 0; |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 76 | friend class VsyncEventObserver; |
| 77 | |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 78 | protected: |
| 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 Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 89 | |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 90 | IBlankControl *mBlankControl; |
| Andy Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 91 | IPrepareListener *mPrepareListener; |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 92 | VsyncEventObserver *mVsyncObserver; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 93 | |
| 94 | // layer list |
| 95 | HwcLayerList *mLayerList; |
| Andy Qiu | 30c19ac | 2013-06-04 15:45:09 -0700 | [diff] [blame] | 96 | bool mConnected; |
| fu jin | 2413102 | 2013-10-15 17:48:28 -0700 | [diff] [blame] | 97 | bool mBlank; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 98 | |
| 99 | // lock |
| 100 | Mutex mLock; |
| 101 | |
| Andy Qiu | 65efc25 | 2013-04-25 17:59:54 -0700 | [diff] [blame] | 102 | // DPMS on (1) or off (0) |
| 103 | int mDisplayState; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 104 | bool mInitialized; |
| 105 | }; |
| 106 | |
| 107 | } |
| 108 | } |
| 109 | |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 110 | #endif /* PHYSICAL_DEVICE_H */ |