| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 28 | #ifndef DISPLAYDEVICE_H_ |
| 29 | #define DISPLAYDEVICE_H_ |
| 30 | |
| 31 | #include <DisplayPlane.h> |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 32 | #include <IVsyncControl.h> |
| 33 | #include <IBlankControl.h> |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 34 | #include <VsyncEventObserver.h> |
| 35 | #include <HotplugEventObserver.h> |
| 36 | #include <HwcLayerList.h> |
| 37 | |
| 38 | namespace android { |
| 39 | namespace intel { |
| 40 | |
| 41 | // display config |
| 42 | class DisplayConfig { |
| 43 | public: |
| 44 | DisplayConfig(int rr, int w, int h, int dpix, int dpiy) |
| 45 | : mRefreshRate(rr), |
| 46 | mWidth(w), |
| 47 | mHeight(h), |
| 48 | mDpiX(dpix), |
| 49 | mDpiY(dpiy) |
| 50 | {} |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 51 | public: |
| 52 | int getRefreshRate() const { return mRefreshRate; } |
| 53 | int getWidth() const { return mWidth; } |
| 54 | int getHeight() const { return mHeight; } |
| 55 | int getDpiX() const { return mDpiX; } |
| 56 | int getDpiY() const { return mDpiY; } |
| 57 | private: |
| 58 | int mRefreshRate; |
| 59 | int mWidth; |
| 60 | int mHeight; |
| 61 | int mDpiX; |
| 62 | int mDpiY; |
| 63 | }; |
| 64 | |
| 65 | class Hwcomposer; |
| 66 | |
| 67 | // generic display device |
| 68 | class DisplayDevice { |
| 69 | public: |
| 70 | // display device type |
| 71 | enum { |
| 72 | DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY, |
| 73 | DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL, |
| 74 | DEVICE_VIRTUAL = HWC_NUM_DISPLAY_TYPES, |
| 75 | DEVICE_COUNT, |
| 76 | }; |
| 77 | enum { |
| 78 | DEVICE_DISCONNECTED = 0, |
| 79 | DEVICE_CONNECTED, |
| 80 | }; |
| 81 | public: |
| 82 | DisplayDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm); |
| 83 | virtual ~DisplayDevice(); |
| 84 | public: |
| 85 | virtual void prePrepare(hwc_display_contents_1_t *display); |
| 86 | virtual bool prepare(hwc_display_contents_1_t *display); |
| 87 | virtual bool commit(hwc_display_contents_1_t *display, |
| 88 | void* context, |
| 89 | int& count) = 0; |
| 90 | |
| 91 | virtual bool vsyncControl(int enabled); |
| 92 | virtual bool blank(int blank); |
| 93 | virtual bool getDisplayConfigs(uint32_t *configs, |
| 94 | size_t *numConfigs); |
| 95 | virtual bool getDisplayAttributes(uint32_t config, |
| 96 | const uint32_t *attributes, |
| 97 | int32_t *values); |
| 98 | virtual bool compositionComplete(); |
| 99 | |
| 100 | // display config operations |
| 101 | virtual void removeDisplayConfigs(); |
| 102 | virtual bool detectDisplayConfigs(); |
| 103 | |
| 104 | // device related operations |
| 105 | virtual bool initCheck() const { return mInitialized; } |
| 106 | virtual bool initialize(); |
| 107 | virtual bool isConnected() const; |
| 108 | virtual const char* getName() const; |
| 109 | virtual int getType() const; |
| 110 | |
| 111 | //events |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 112 | virtual void onHotplug(); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 113 | virtual void onVsync(int64_t timestamp); |
| 114 | |
| 115 | virtual void dump(Dump& d); |
| 116 | protected: |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 117 | virtual void deinitialize(); |
| 118 | protected: |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 119 | void onGeometryChanged(hwc_display_contents_1_t *list); |
| 120 | bool updateDisplayConfigs(struct Output *output); |
| 121 | protected: |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 122 | virtual IVsyncControl* createVsyncControl() = 0; |
| 123 | virtual IBlankControl* createBlankControl() = 0; |
| 124 | virtual IHotplugControl* createHotplugControl() = 0; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 125 | protected: |
| 126 | uint32_t mType; |
| 127 | const char *mName; |
| 128 | |
| 129 | Hwcomposer& mHwc; |
| 130 | DisplayPlaneManager& mDisplayPlaneManager; |
| 131 | |
| 132 | // display configs |
| 133 | Vector<DisplayConfig*> mDisplayConfigs; |
| 134 | int mActiveDisplayConfig; |
| 135 | |
| 136 | // vsync control |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 137 | IVsyncControl *mVsyncControl; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 138 | // blank control |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 139 | IBlankControl *mBlankControl; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 140 | // hotplug control |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame^] | 141 | IHotplugControl *mHotplugControl; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 142 | |
| 143 | // hotplug event observer |
| 144 | sp<HotplugEventObserver> mHotplugObserver; |
| 145 | // vsync event observer |
| 146 | sp<VsyncEventObserver> mVsyncObserver; |
| 147 | |
| 148 | // layer list |
| 149 | HwcLayerList *mLayerList; |
| 150 | DisplayPlane *mPrimaryPlane; |
| 151 | bool mConnection; |
| 152 | |
| 153 | // lock |
| 154 | Mutex mLock; |
| 155 | |
| 156 | bool mInitialized; |
| 157 | }; |
| 158 | |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | #endif /* DISPLAYDEVICE_H_ */ |