summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;