summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-08-21 17:45:46 -0700
committerMathias Agopian <mathias@google.com>2013-08-21 17:45:46 -0700
commitbef42c50ebda2d63400f92611e1dd857c03bb38c (patch)
tree83ec293a0274c463ce885b2b939da1c6e123cb6c
parent0f288fcc9c1b2d23b1cff2f5c59689aef76b77ae (diff)
downloadframeworks_native-bef42c50ebda2d63400f92611e1dd857c03bb38c.zip
frameworks_native-bef42c50ebda2d63400f92611e1dd857c03bb38c.tar.gz
frameworks_native-bef42c50ebda2d63400f92611e1dd857c03bb38c.tar.bz2
handle several vsync signal correctly
Change-Id: I34935d2197ce8e914fef2f110896e47b44225ad2
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.cpp22
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.h4
2 files changed, 18 insertions, 8 deletions
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index e7d0d23..32c55fd 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -87,12 +87,17 @@ HWComposer::HWComposer(
mFbDev(0), mHwc(0), mNumDisplays(1),
mCBContext(new cb_context),
mEventHandler(handler),
- mVSyncCount(0), mDebugForceFakeVSync(false)
+ mDebugForceFakeVSync(false)
{
for (size_t i =0 ; i<MAX_HWC_DISPLAYS ; i++) {
mLists[i] = 0;
}
+ for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) {
+ mLastHwVSync[i] = 0;
+ mVSyncCounts[i] = 0;
+ }
+
char value[PROPERTY_VALUE_MAX];
property_get("debug.sf.no_hw_vsync", value, "0");
mDebugForceFakeVSync = atoi(value);
@@ -278,10 +283,15 @@ void HWComposer::invalidate() {
}
void HWComposer::vsync(int disp, int64_t timestamp) {
- ATRACE_INT("VSYNC", ++mVSyncCount&1);
- mEventHandler.onVSyncReceived(disp, timestamp);
- Mutex::Autolock _l(mLock);
- mLastHwVSync = timestamp;
+ if (uint32_t(disp) < HWC_NUM_PHYSICAL_DISPLAY_TYPES) {
+ char tag[16];
+ snprintf(tag, sizeof(tag), "VSYNC_%1u", disp);
+ ATRACE_INT(tag, ++mVSyncCounts[disp] & 1);
+
+ mEventHandler.onVSyncReceived(disp, timestamp);
+ Mutex::Autolock _l(mLock);
+ mLastHwVSync[disp] = timestamp;
+ }
}
void HWComposer::hotplug(int disp, int connected) {
@@ -415,7 +425,7 @@ nsecs_t HWComposer::getRefreshTimestamp(int disp) const {
// the refresh period and whatever closest timestamp we have.
Mutex::Autolock _l(mLock);
nsecs_t now = systemTime(CLOCK_MONOTONIC);
- return now - ((now - mLastHwVSync) % mDisplayData[disp].refresh);
+ return now - ((now - mLastHwVSync[disp]) % mDisplayData[disp].refresh);
}
sp<Fence> HWComposer::getDisplayFence(int disp) const {
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index d901c62..9f96113 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -342,14 +342,14 @@ private:
cb_context* mCBContext;
EventHandler& mEventHandler;
- size_t mVSyncCount;
+ size_t mVSyncCounts[HWC_NUM_PHYSICAL_DISPLAY_TYPES];
sp<VSyncThread> mVSyncThread;
bool mDebugForceFakeVSync;
BitSet32 mAllocatedDisplayIDs;
// protected by mLock
mutable Mutex mLock;
- mutable nsecs_t mLastHwVSync;
+ mutable nsecs_t mLastHwVSync[HWC_NUM_PHYSICAL_DISPLAY_TYPES];
// thread-safe
mutable Mutex mEventControlLock;