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 HWCOMPOSER_H 17 #define HWCOMPOSER_H 18 19 #include <EGL/egl.h> 20 #include <hardware/hwcomposer.h> 21 #include <utils/Vector.h> 22 23 #include <IDisplayDevice.h> 24 #include <BufferManager.h> 25 #include <IDisplayContext.h> 26 #include <common/base/Drm.h> 27 #include <DisplayPlaneManager.h> 28 #include <common/base/DisplayAnalyzer.h> 29 #include <UeventObserver.h> 30 31 namespace android { 32 namespace intel { 33 34 class Hwcomposer : public hwc_composer_device_1_t { 35 public: 36 virtual ~Hwcomposer(); 37 public: 38 // callbacks implementation 39 virtual bool prepare(size_t numDisplays, 40 hwc_display_contents_1_t** displays); 41 virtual bool commit(size_t numDisplays, 42 hwc_display_contents_1_t** displays); 43 virtual bool vsyncControl(int disp, int enabled); 44 virtual bool release(); 45 virtual bool dump(char *buff, int buff_len, int *cur_len); 46 virtual void registerProcs(hwc_procs_t const *procs); 47 48 virtual bool blank(int disp, int blank); 49 virtual bool getDisplayConfigs(int disp, 50 uint32_t *configs, 51 size_t *numConfigs); 52 virtual bool getDisplayAttributes(int disp, 53 uint32_t config, 54 const uint32_t *attributes, 55 int32_t *values); 56 virtual bool compositionComplete(int disp); 57 58 virtual bool setPowerMode(int disp, int mode); 59 virtual int getActiveConfig(int disp); 60 virtual bool setActiveConfig(int disp, int index); 61 virtual bool setCursorPositionAsync(int disp, int x, int y); 62 63 // callbacks 64 virtual void vsync(int disp, int64_t timestamp); 65 virtual void hotplug(int disp, bool connected); 66 virtual void invalidate(); 67 68 virtual bool initCheck() const; 69 virtual bool initialize(); 70 virtual void deinitialize(); 71 72 public: 73 Drm* getDrm(); 74 DisplayPlaneManager* getPlaneManager(); 75 BufferManager* getBufferManager(); 76 IDisplayContext* getDisplayContext(); 77 DisplayAnalyzer* getDisplayAnalyzer(); 78 IDisplayDevice* getDisplayDevice(int disp); 79 UeventObserver* getUeventObserver(); 80 81 protected: 82 Hwcomposer(); 83 84 public: getInstance()85 static Hwcomposer& getInstance() { 86 Hwcomposer *instance = sInstance; 87 if (instance == 0) { 88 instance = createHwcomposer(); 89 sInstance = instance; 90 } 91 return *sInstance; 92 } releaseInstance()93 static void releaseInstance() { 94 delete sInstance; 95 sInstance = NULL; 96 } 97 // Need to be implemented 98 static Hwcomposer* createHwcomposer(); 99 protected: 100 virtual DisplayPlaneManager* createDisplayPlaneManager() = 0; 101 virtual BufferManager* createBufferManager() = 0; 102 virtual IDisplayDevice* createDisplayDevice(int disp, 103 DisplayPlaneManager& dpm) = 0; 104 virtual IDisplayContext* createDisplayContext() = 0; 105 106 protected: 107 hwc_procs_t const *mProcs; 108 Drm *mDrm; 109 DisplayPlaneManager *mPlaneManager; 110 BufferManager *mBufferManager; 111 DisplayAnalyzer *mDisplayAnalyzer; 112 Vector<IDisplayDevice*> mDisplayDevices; 113 IDisplayContext *mDisplayContext; 114 UeventObserver *mUeventObserver; 115 bool mInitialized; 116 private: 117 static Hwcomposer *sInstance; 118 }; 119 120 } // namespace intel 121 } 122 123 #endif /*HW_COMPOSER_H*/ 124