1 /* 2 // Copyright(c)2014 IntelCorporation 3 // 4 // LicensedundertheApacheLicense,Version2.0(the"License"); 5 // youmaynotusethisfileexceptincompliancewiththeLicense. 6 // YoumayobtainacopyoftheLicenseat 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software 11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS, 12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. 13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand 14 // limitationsundertheLicense. 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: 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 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 virtual uint32_t getFpsDivider(); 80 81 //events 82 virtual void onVsync(int64_t timestamp); 83 84 virtual void dump(Dump& d); 85 86 protected: 87 void onGeometryChanged(hwc_display_contents_1_t *list); 88 bool updateDisplayConfigs(); 89 IVsyncControl* createVsyncControl() {return mControlFactory->createVsyncControl();} 90 friend class VsyncEventObserver; 91 92 protected: 93 uint32_t mType; 94 const char *mName; 95 96 Hwcomposer& mHwc; 97 98 // display configs 99 Vector<DisplayConfig*> mDisplayConfigs; 100 int mActiveDisplayConfig; 101 102 103 IBlankControl *mBlankControl; 104 VsyncEventObserver *mVsyncObserver; 105 106 DeviceControlFactory *mControlFactory; 107 108 // layer list 109 HwcLayerList *mLayerList; 110 bool mConnected; 111 bool mBlank; 112 113 // lock 114 Mutex mLock; 115 116 // DPMS on (1) or off (0) 117 int mDisplayState; 118 bool mInitialized; 119 uint32_t mFpsDivider; 120 }; 121 122 123 124 } 125 } 126 127 #endif /* PHYSICAL_DEVICE_H */ 128