Loading services/surfaceflinger/DisplayDevice.h +3 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ namespace android { class DisplayInfo; class DisplaySurface; class IGraphicBufferProducer; class Layer; class SurfaceFlinger; class HWComposer; Loading @@ -56,8 +57,8 @@ public: DISPLAY_ID_INVALID = -1, DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY, DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL, NUM_DISPLAY_TYPES = HWC_NUM_DISPLAY_TYPES, DISPLAY_VIRTUAL = HWC_NUM_DISPLAY_TYPES DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL, NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES, }; enum { Loading services/surfaceflinger/DisplayHardware/HWComposer.cpp +6 −13 Original line number Diff line number Diff line Loading @@ -48,15 +48,8 @@ namespace android { #ifndef HWC_DEVICE_API_VERSION_1_3 #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) #endif #define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION #define NUM_PHYSICAL_DISPLAYS HWC_NUM_DISPLAY_TYPES #define VIRTUAL_DISPLAY_ID_BASE HWC_NUM_DISPLAY_TYPES static uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) { uint32_t hwcVersion = hwc->common.version; return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK; Loading Loading @@ -96,7 +89,7 @@ HWComposer::HWComposer( mEventHandler(handler), mVSyncCount(0), mDebugForceFakeVSync(false) { for (size_t i =0 ; i<MAX_DISPLAYS ; i++) { for (size_t i =0 ; i<MAX_HWC_DISPLAYS ; i++) { mLists[i] = 0; } Loading Loading @@ -127,7 +120,7 @@ HWComposer::HWComposer( } // these display IDs are always reserved for (size_t i=0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) { for (size_t i=0 ; i<NUM_BUILTIN_DISPLAYS ; i++) { mAllocatedDisplayIDs.markBit(i); } Loading Loading @@ -156,10 +149,10 @@ HWComposer::HWComposer( // hw composer version if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) { // 1.3 adds support for virtual displays mNumDisplays = MAX_DISPLAYS; mNumDisplays = MAX_HWC_DISPLAYS; } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) { // 1.1 adds support for multiple displays mNumDisplays = NUM_PHYSICAL_DISPLAYS; mNumDisplays = NUM_BUILTIN_DISPLAYS; } else { mNumDisplays = 1; } Loading Loading @@ -187,7 +180,7 @@ HWComposer::HWComposer( } } else if (mHwc) { // here we're guaranteed to have at least HWC 1.1 for (size_t i =0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) { for (size_t i =0 ; i<NUM_BUILTIN_DISPLAYS ; i++) { queryDisplayProperties(i); } } Loading Loading @@ -400,7 +393,7 @@ int32_t HWComposer::allocateDisplayId() { } status_t HWComposer::freeDisplayId(int32_t id) { if (id < NUM_PHYSICAL_DISPLAYS) { if (id < NUM_BUILTIN_DISPLAYS) { // cannot free the reserved IDs return BAD_VALUE; } Loading services/surfaceflinger/DisplayHardware/HWComposer.h +13 −10 Original line number Diff line number Diff line Loading @@ -64,7 +64,9 @@ public: }; enum { MAX_DISPLAYS = HWC_NUM_DISPLAY_TYPES + 1 NUM_BUILTIN_DISPLAYS = HWC_NUM_PHYSICAL_DISPLAY_TYPES, MAX_HWC_DISPLAYS = HWC_NUM_DISPLAY_TYPES, VIRTUAL_DISPLAY_ID_BASE = HWC_DISPLAY_VIRTUAL, }; HWComposer( Loading @@ -75,15 +77,16 @@ public: status_t initCheck() const; // returns a display ID starting at MAX_DISPLAYS, this ID // is to be used with createWorkList (and all other // methods requiring an ID below). // IDs below MAX_DISPLAY are pre-defined and therefore are always valid. // returns a negative error code if an ID cannot be allocated // Returns a display ID starting at VIRTUAL_DISPLAY_ID_BASE, this ID is to // be used with createWorkList (and all other methods requiring an ID // below). // IDs below NUM_BUILTIN_DISPLAYS are pre-defined and therefore are // always valid. // Returns -1 if an ID cannot be allocated int32_t allocateDisplayId(); // recycles the given ID and frees the associated worklist. // IDs below MAX_DISPLAYS are not recycled // Recycles the given virtual display ID and frees the associated worklist. // IDs below NUM_BUILTIN_DISPLAYS are not recycled. status_t freeDisplayId(int32_t id); Loading Loading @@ -333,8 +336,8 @@ private: struct hwc_composer_device_1* mHwc; // invariant: mLists[0] != NULL iff mHwc != NULL // mLists[i>0] can be NULL. that display is to be ignored struct hwc_display_contents_1* mLists[MAX_DISPLAYS]; DisplayData mDisplayData[MAX_DISPLAYS]; struct hwc_display_contents_1* mLists[MAX_HWC_DISPLAYS]; DisplayData mDisplayData[MAX_HWC_DISPLAYS]; size_t mNumDisplays; cb_context* mCBContext; Loading services/surfaceflinger/EventThread.cpp +12 −10 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ EventThread::EventThread(const sp<SurfaceFlinger>& flinger) mUseSoftwareVSync(false), mDebugVsyncEnabled(false) { for (int32_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) { for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { mVSyncEvent[i].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[i].header.id = 0; mVSyncEvent[i].header.timestamp = 0; Loading Loading @@ -112,11 +112,11 @@ void EventThread::onScreenAcquired() { void EventThread::onVSyncReceived(int type, nsecs_t timestamp) { ALOGE_IF(type >= HWC_NUM_DISPLAY_TYPES, ALOGE_IF(type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES, "received vsync event for an invalid display (id=%d)", type); Mutex::Autolock _l(mLock); if (type < HWC_NUM_DISPLAY_TYPES) { if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { mVSyncEvent[type].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[type].header.id = type; mVSyncEvent[type].header.timestamp = timestamp; Loading @@ -126,11 +126,11 @@ void EventThread::onVSyncReceived(int type, nsecs_t timestamp) { } void EventThread::onHotplugReceived(int type, bool connected) { ALOGE_IF(type >= HWC_NUM_DISPLAY_TYPES, ALOGE_IF(type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES, "received hotplug event for an invalid display (id=%d)", type); Mutex::Autolock _l(mLock); if (type < HWC_NUM_DISPLAY_TYPES) { if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { DisplayEventReceiver::Event event; event.header.type = DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG; event.header.id = type; Loading Loading @@ -184,7 +184,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( size_t vsyncCount = 0; nsecs_t timestamp = 0; for (int32_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) { for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { timestamp = mVSyncEvent[i].header.timestamp; if (timestamp) { // we have a vsync event to dispatch Loading Loading @@ -285,7 +285,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( // FIXME: how do we decide which display id the fake // vsync came from ? mVSyncEvent[0].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[0].header.id = HWC_DISPLAY_PRIMARY; mVSyncEvent[0].header.id = DisplayDevice::DISPLAY_PRIMARY; mVSyncEvent[0].header.timestamp = systemTime(SYSTEM_TIME_MONOTONIC); mVSyncEvent[0].vsync.count++; } Loading @@ -308,14 +308,16 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( void EventThread::enableVSyncLocked() { if (!mUseSoftwareVSync) { // never enable h/w VSYNC when screen is off mFlinger->eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); mFlinger->eventControl(DisplayDevice::DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); mPowerHAL.vsyncHint(true); } mDebugVsyncEnabled = true; } void EventThread::disableVSyncLocked() { mFlinger->eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false); mFlinger->eventControl(DisplayDevice::DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false); mPowerHAL.vsyncHint(false); mDebugVsyncEnabled = false; } Loading @@ -328,7 +330,7 @@ void EventThread::dump(String8& result) const { mUseSoftwareVSync?"enabled":"disabled"); result.appendFormat(" numListeners=%u,\n events-delivered: %u\n", mDisplayEventConnections.size(), mVSyncEvent[HWC_DISPLAY_PRIMARY].vsync.count); mVSyncEvent[DisplayDevice::DISPLAY_PRIMARY].vsync.count); for (size_t i=0 ; i<mDisplayEventConnections.size() ; i++) { sp<Connection> connection = mDisplayEventConnections.itemAt(i).promote(); Loading services/surfaceflinger/EventThread.h +2 −3 Original line number Diff line number Diff line Loading @@ -23,12 +23,11 @@ #include <gui/DisplayEventReceiver.h> #include <gui/IDisplayEventConnection.h> #include <hardware/hwcomposer_defs.h> #include <utils/Errors.h> #include <utils/threads.h> #include <utils/SortedVector.h> #include "DisplayDevice.h" #include "DisplayHardware/PowerHAL.h" // --------------------------------------------------------------------------- Loading Loading @@ -104,7 +103,7 @@ private: // protected by mLock SortedVector< wp<Connection> > mDisplayEventConnections; Vector< DisplayEventReceiver::Event > mPendingEvents; DisplayEventReceiver::Event mVSyncEvent[HWC_NUM_DISPLAY_TYPES]; DisplayEventReceiver::Event mVSyncEvent[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES]; bool mUseSoftwareVSync; // for debugging Loading Loading
services/surfaceflinger/DisplayDevice.h +3 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ namespace android { class DisplayInfo; class DisplaySurface; class IGraphicBufferProducer; class Layer; class SurfaceFlinger; class HWComposer; Loading @@ -56,8 +57,8 @@ public: DISPLAY_ID_INVALID = -1, DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY, DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL, NUM_DISPLAY_TYPES = HWC_NUM_DISPLAY_TYPES, DISPLAY_VIRTUAL = HWC_NUM_DISPLAY_TYPES DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL, NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES, }; enum { Loading
services/surfaceflinger/DisplayHardware/HWComposer.cpp +6 −13 Original line number Diff line number Diff line Loading @@ -48,15 +48,8 @@ namespace android { #ifndef HWC_DEVICE_API_VERSION_1_3 #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) #endif #define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION #define NUM_PHYSICAL_DISPLAYS HWC_NUM_DISPLAY_TYPES #define VIRTUAL_DISPLAY_ID_BASE HWC_NUM_DISPLAY_TYPES static uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) { uint32_t hwcVersion = hwc->common.version; return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK; Loading Loading @@ -96,7 +89,7 @@ HWComposer::HWComposer( mEventHandler(handler), mVSyncCount(0), mDebugForceFakeVSync(false) { for (size_t i =0 ; i<MAX_DISPLAYS ; i++) { for (size_t i =0 ; i<MAX_HWC_DISPLAYS ; i++) { mLists[i] = 0; } Loading Loading @@ -127,7 +120,7 @@ HWComposer::HWComposer( } // these display IDs are always reserved for (size_t i=0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) { for (size_t i=0 ; i<NUM_BUILTIN_DISPLAYS ; i++) { mAllocatedDisplayIDs.markBit(i); } Loading Loading @@ -156,10 +149,10 @@ HWComposer::HWComposer( // hw composer version if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) { // 1.3 adds support for virtual displays mNumDisplays = MAX_DISPLAYS; mNumDisplays = MAX_HWC_DISPLAYS; } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) { // 1.1 adds support for multiple displays mNumDisplays = NUM_PHYSICAL_DISPLAYS; mNumDisplays = NUM_BUILTIN_DISPLAYS; } else { mNumDisplays = 1; } Loading Loading @@ -187,7 +180,7 @@ HWComposer::HWComposer( } } else if (mHwc) { // here we're guaranteed to have at least HWC 1.1 for (size_t i =0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) { for (size_t i =0 ; i<NUM_BUILTIN_DISPLAYS ; i++) { queryDisplayProperties(i); } } Loading Loading @@ -400,7 +393,7 @@ int32_t HWComposer::allocateDisplayId() { } status_t HWComposer::freeDisplayId(int32_t id) { if (id < NUM_PHYSICAL_DISPLAYS) { if (id < NUM_BUILTIN_DISPLAYS) { // cannot free the reserved IDs return BAD_VALUE; } Loading
services/surfaceflinger/DisplayHardware/HWComposer.h +13 −10 Original line number Diff line number Diff line Loading @@ -64,7 +64,9 @@ public: }; enum { MAX_DISPLAYS = HWC_NUM_DISPLAY_TYPES + 1 NUM_BUILTIN_DISPLAYS = HWC_NUM_PHYSICAL_DISPLAY_TYPES, MAX_HWC_DISPLAYS = HWC_NUM_DISPLAY_TYPES, VIRTUAL_DISPLAY_ID_BASE = HWC_DISPLAY_VIRTUAL, }; HWComposer( Loading @@ -75,15 +77,16 @@ public: status_t initCheck() const; // returns a display ID starting at MAX_DISPLAYS, this ID // is to be used with createWorkList (and all other // methods requiring an ID below). // IDs below MAX_DISPLAY are pre-defined and therefore are always valid. // returns a negative error code if an ID cannot be allocated // Returns a display ID starting at VIRTUAL_DISPLAY_ID_BASE, this ID is to // be used with createWorkList (and all other methods requiring an ID // below). // IDs below NUM_BUILTIN_DISPLAYS are pre-defined and therefore are // always valid. // Returns -1 if an ID cannot be allocated int32_t allocateDisplayId(); // recycles the given ID and frees the associated worklist. // IDs below MAX_DISPLAYS are not recycled // Recycles the given virtual display ID and frees the associated worklist. // IDs below NUM_BUILTIN_DISPLAYS are not recycled. status_t freeDisplayId(int32_t id); Loading Loading @@ -333,8 +336,8 @@ private: struct hwc_composer_device_1* mHwc; // invariant: mLists[0] != NULL iff mHwc != NULL // mLists[i>0] can be NULL. that display is to be ignored struct hwc_display_contents_1* mLists[MAX_DISPLAYS]; DisplayData mDisplayData[MAX_DISPLAYS]; struct hwc_display_contents_1* mLists[MAX_HWC_DISPLAYS]; DisplayData mDisplayData[MAX_HWC_DISPLAYS]; size_t mNumDisplays; cb_context* mCBContext; Loading
services/surfaceflinger/EventThread.cpp +12 −10 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ EventThread::EventThread(const sp<SurfaceFlinger>& flinger) mUseSoftwareVSync(false), mDebugVsyncEnabled(false) { for (int32_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) { for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { mVSyncEvent[i].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[i].header.id = 0; mVSyncEvent[i].header.timestamp = 0; Loading Loading @@ -112,11 +112,11 @@ void EventThread::onScreenAcquired() { void EventThread::onVSyncReceived(int type, nsecs_t timestamp) { ALOGE_IF(type >= HWC_NUM_DISPLAY_TYPES, ALOGE_IF(type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES, "received vsync event for an invalid display (id=%d)", type); Mutex::Autolock _l(mLock); if (type < HWC_NUM_DISPLAY_TYPES) { if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { mVSyncEvent[type].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[type].header.id = type; mVSyncEvent[type].header.timestamp = timestamp; Loading @@ -126,11 +126,11 @@ void EventThread::onVSyncReceived(int type, nsecs_t timestamp) { } void EventThread::onHotplugReceived(int type, bool connected) { ALOGE_IF(type >= HWC_NUM_DISPLAY_TYPES, ALOGE_IF(type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES, "received hotplug event for an invalid display (id=%d)", type); Mutex::Autolock _l(mLock); if (type < HWC_NUM_DISPLAY_TYPES) { if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { DisplayEventReceiver::Event event; event.header.type = DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG; event.header.id = type; Loading Loading @@ -184,7 +184,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( size_t vsyncCount = 0; nsecs_t timestamp = 0; for (int32_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) { for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { timestamp = mVSyncEvent[i].header.timestamp; if (timestamp) { // we have a vsync event to dispatch Loading Loading @@ -285,7 +285,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( // FIXME: how do we decide which display id the fake // vsync came from ? mVSyncEvent[0].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[0].header.id = HWC_DISPLAY_PRIMARY; mVSyncEvent[0].header.id = DisplayDevice::DISPLAY_PRIMARY; mVSyncEvent[0].header.timestamp = systemTime(SYSTEM_TIME_MONOTONIC); mVSyncEvent[0].vsync.count++; } Loading @@ -308,14 +308,16 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( void EventThread::enableVSyncLocked() { if (!mUseSoftwareVSync) { // never enable h/w VSYNC when screen is off mFlinger->eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); mFlinger->eventControl(DisplayDevice::DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); mPowerHAL.vsyncHint(true); } mDebugVsyncEnabled = true; } void EventThread::disableVSyncLocked() { mFlinger->eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false); mFlinger->eventControl(DisplayDevice::DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false); mPowerHAL.vsyncHint(false); mDebugVsyncEnabled = false; } Loading @@ -328,7 +330,7 @@ void EventThread::dump(String8& result) const { mUseSoftwareVSync?"enabled":"disabled"); result.appendFormat(" numListeners=%u,\n events-delivered: %u\n", mDisplayEventConnections.size(), mVSyncEvent[HWC_DISPLAY_PRIMARY].vsync.count); mVSyncEvent[DisplayDevice::DISPLAY_PRIMARY].vsync.count); for (size_t i=0 ; i<mDisplayEventConnections.size() ; i++) { sp<Connection> connection = mDisplayEventConnections.itemAt(i).promote(); Loading
services/surfaceflinger/EventThread.h +2 −3 Original line number Diff line number Diff line Loading @@ -23,12 +23,11 @@ #include <gui/DisplayEventReceiver.h> #include <gui/IDisplayEventConnection.h> #include <hardware/hwcomposer_defs.h> #include <utils/Errors.h> #include <utils/threads.h> #include <utils/SortedVector.h> #include "DisplayDevice.h" #include "DisplayHardware/PowerHAL.h" // --------------------------------------------------------------------------- Loading Loading @@ -104,7 +103,7 @@ private: // protected by mLock SortedVector< wp<Connection> > mDisplayEventConnections; Vector< DisplayEventReceiver::Event > mPendingEvents; DisplayEventReceiver::Event mVSyncEvent[HWC_NUM_DISPLAY_TYPES]; DisplayEventReceiver::Event mVSyncEvent[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES]; bool mUseSoftwareVSync; // for debugging Loading