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 #include <HwcTrace.h> 17 #include <Drm.h> 18 #include <Hwcomposer.h> 19 #include <DrmConfig.h> 20 #include <PrimaryDevice.h> 21 22 namespace android { 23 namespace intel { 24 25 PrimaryDevice::PrimaryDevice(Hwcomposer& hwc, DeviceControlFactory* controlFactory) 26 : PhysicalDevice(DEVICE_PRIMARY, hwc, controlFactory) 27 { 28 CTRACE(); 29 } 30 31 PrimaryDevice::~PrimaryDevice() 32 { 33 CTRACE(); 34 } 35 36 bool PrimaryDevice::initialize() 37 { 38 if (!PhysicalDevice::initialize()) { 39 DEINIT_AND_RETURN_FALSE("failed to initialize physical device"); 40 } 41 42 UeventObserver *observer = Hwcomposer::getInstance().getUeventObserver(); 43 if (observer) { 44 observer->registerListener( 45 DrmConfig::getRepeatedFrameString(), 46 repeatedFrameEventListener, 47 this); 48 } else { 49 ETRACE("Uevent observer is NULL"); 50 } 51 52 return true; 53 } 54 55 void PrimaryDevice::deinitialize() 56 { 57 PhysicalDevice::deinitialize(); 58 } 59 60 61 void PrimaryDevice::repeatedFrameEventListener(void *data) 62 { 63 PrimaryDevice *pThis = (PrimaryDevice*)data; 64 if (pThis) { 65 pThis->repeatedFrameListener(); 66 } 67 } 68 69 void PrimaryDevice::repeatedFrameListener() 70 { 71 Hwcomposer::getInstance().getDisplayAnalyzer()->postIdleEntryEvent(); 72 Hwcomposer::getInstance().invalidate(); 73 } 74 75 bool PrimaryDevice::blank(bool blank) 76 { 77 if (!mConnected) 78 return true; 79 80 return PhysicalDevice::blank(blank); 81 } 82 83 } // namespace intel 84 } // namespace android 85