1 /* 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 */ 16 #ifndef PHYSICAL_DEVICE_H 17 #define PHYSICAL_DEVICE_H 18 19 #include <DisplayPlane.h> 20 #include <IVsyncControl.h> 21 #include <IBlankControl.h> 22 #include <IPrepareListener.h> 23 #include <VsyncEventObserver.h> 24 #include <HwcLayerList.h> 25 #include <Drm.h> 26 #include <IDisplayDevice.h> 27 28 namespace android { 29 namespace intel { 30 31 class IHdcpControl; 32 33 class DeviceControlFactory { 34 public: ~DeviceControlFactory()35 virtual ~DeviceControlFactory(){} 36 public: 37 virtual IVsyncControl* createVsyncControl() = 0; 38 virtual IBlankControl* createBlankControl() = 0; 39 virtual IHdcpControl* createHdcpControl() = 0; 40 }; 41 42 class Hwcomposer; 43 44 // Base class for primary and external devices 45 class PhysicalDevice : public IDisplayDevice { 46 public: 47 PhysicalDevice(uint32_t type, Hwcomposer& hwc, DeviceControlFactory* controlFactory); 48 virtual ~PhysicalDevice(); 49 public: 50 virtual bool prePrepare(hwc_display_contents_1_t *display); 51 virtual bool prepare(hwc_display_contents_1_t *display); 52 virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context); 53 54 virtual bool vsyncControl(bool enabled); 55 virtual bool blank(bool blank); 56 virtual bool getDisplaySize(int *width, int *height); 57 virtual bool getDisplayConfigs(uint32_t *configs, 58 size_t *numConfigs); 59 virtual bool getDisplayAttributes(uint32_t config, 60 const uint32_t *attributes, 61 int32_t *values); 62 virtual bool compositionComplete(); 63 64 virtual bool setPowerMode(int mode); 65 virtual int getActiveConfig(); 66 virtual bool setActiveConfig(int index); 67 68 // display config operations 69 virtual void removeDisplayConfigs(); 70 virtual bool detectDisplayConfigs(); 71 72 // device related operations initCheck()73 virtual bool initCheck() const { return mInitialized; } 74 virtual bool initialize(); 75 virtual void deinitialize(); 76 virtual bool isConnected() const; 77 virtual const char* getName() const; 78 virtual int getType() const; 79 80 //events 81 virtual void onVsync(int64_t timestamp); 82 83 virtual void dump(Dump& d); 84 85 protected: 86 void onGeometryChanged(hwc_display_contents_1_t *list); 87 bool updateDisplayConfigs(); createVsyncControl()88 IVsyncControl* createVsyncControl() {return mControlFactory->createVsyncControl();} 89 friend class VsyncEventObserver; 90 91 protected: 92 uint32_t mType; 93 const char *mName; 94 95 Hwcomposer& mHwc; 96 97 // display configs 98 Vector<DisplayConfig*> mDisplayConfigs; 99 int mActiveDisplayConfig; 100 101 102 IBlankControl *mBlankControl; 103 VsyncEventObserver *mVsyncObserver; 104 105 DeviceControlFactory *mControlFactory; 106 107 // layer list 108 HwcLayerList *mLayerList; 109 bool mConnected; 110 bool mBlank; 111 112 // lock 113 Mutex mLock; 114 115 // DPMS on (1) or off (0) 116 int mDisplayState; 117 bool mInitialized; 118 }; 119 120 121 122 } 123 } 124 125 #endif /* PHYSICAL_DEVICE_H */ 126