| 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 | */ |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 28 | #ifndef PHYSICAL_DEVICE_H |
| 29 | #define PHYSICAL_DEVICE_H |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 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 | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 34 | #include <IPrepareListener.h> |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 35 | #include <VsyncEventObserver.h> |
| 36 | #include <HotplugEventObserver.h> |
| 37 | #include <HwcLayerList.h> |
| Andy Qiu | 30c19ac | 2013-06-04 15:45:09 -0700 | [diff] [blame] | 38 | #include <Drm.h> |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 39 | #include <IDisplayDevice.h> |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 40 | |
| 41 | namespace android { |
| 42 | namespace intel { |
| 43 | |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 44 | class Hwcomposer; |
| 45 | |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 46 | // Base class for primary and external devices |
| 47 | class PhysicalDevice : public IDisplayDevice { |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 48 | public: |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 49 | PhysicalDevice(uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm); |
| 50 | virtual ~PhysicalDevice(); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 51 | public: |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 52 | virtual bool prePrepare(hwc_display_contents_1_t *display); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 53 | virtual bool prepare(hwc_display_contents_1_t *display); |
| Andy Qiu | 4b834ce | 2013-04-09 18:23:20 -0700 | [diff] [blame] | 54 | virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 55 | |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 56 | virtual bool vsyncControl(bool enabled); |
| 57 | virtual bool blank(bool blank); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 58 | virtual bool getDisplayConfigs(uint32_t *configs, |
| 59 | size_t *numConfigs); |
| 60 | virtual bool getDisplayAttributes(uint32_t config, |
| 61 | const uint32_t *attributes, |
| 62 | int32_t *values); |
| 63 | virtual bool compositionComplete(); |
| 64 | |
| 65 | // display config operations |
| 66 | virtual void removeDisplayConfigs(); |
| 67 | virtual bool detectDisplayConfigs(); |
| 68 | |
| 69 | // device related operations |
| 70 | virtual bool initCheck() const { return mInitialized; } |
| 71 | virtual bool initialize(); |
| fu jin | e2ad4c0 | 2013-05-28 13:47:51 -0700 | [diff] [blame] | 72 | virtual void deinitialize(); |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 73 | virtual bool isConnected() const; |
| 74 | virtual const char* getName() const; |
| 75 | virtual int getType() const; |
| 76 | |
| 77 | //events |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 78 | virtual void onVsync(int64_t timestamp); |
| 79 | |
| 80 | virtual void dump(Dump& d); |
| Andy Qiu | 65efc25 | 2013-04-25 17:59:54 -0700 | [diff] [blame] | 81 | |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 82 | protected: |
| 83 | void onGeometryChanged(hwc_display_contents_1_t *list); |
| Jackie Li | cf69645 | 2013-04-10 16:30:59 +0800 | [diff] [blame] | 84 | |
| Jackie Li | e6ecdad | 2013-03-25 09:03:16 -0700 | [diff] [blame] | 85 | virtual IVsyncControl* createVsyncControl() = 0; |
| 86 | virtual IBlankControl* createBlankControl() = 0; |
| Andy Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 87 | virtual IPrepareListener* createPrepareListener() = 0; |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 88 | friend class VsyncEventObserver; |
| 89 | |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 90 | protected: |
| 91 | uint32_t mType; |
| 92 | const char *mName; |
| 93 | |
| 94 | Hwcomposer& mHwc; |
| 95 | DisplayPlaneManager& mDisplayPlaneManager; |
| 96 | |
| 97 | // display configs |
| 98 | Vector<DisplayConfig*> mDisplayConfigs; |
| 99 | int mActiveDisplayConfig; |
| 100 | |
| Andy Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 101 | |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 102 | IBlankControl *mBlankControl; |
| Andy Qiu | 25caf44 | 2013-04-23 16:19:38 -0700 | [diff] [blame] | 103 | IPrepareListener *mPrepareListener; |
| Andy Qiu | eb726af | 2013-05-31 11:51:49 +0800 | [diff] [blame] | 104 | VsyncEventObserver *mVsyncObserver; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 105 | |
| 106 | // layer list |
| 107 | HwcLayerList *mLayerList; |
| Andy Qiu | 30c19ac | 2013-06-04 15:45:09 -0700 | [diff] [blame] | 108 | bool mConnected; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 109 | |
| 110 | // lock |
| 111 | Mutex mLock; |
| 112 | |
| Andy Qiu | 65efc25 | 2013-04-25 17:59:54 -0700 | [diff] [blame] | 113 | // DPMS on (1) or off (0) |
| 114 | int mDisplayState; |
| Andy Qiu | 6a6081a | 2013-03-22 16:25:43 -0700 | [diff] [blame] | 115 | bool mInitialized; |
| 116 | }; |
| 117 | |
| 118 | } |
| 119 | } |
| 120 | |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 121 | #endif /* PHYSICAL_DEVICE_H */ |