hwc: Check for correct screen state before enabling vsync
Sometimes vsync would not be disabled before the display is
blanked.
This was due to the vsync disable ioctl being kicked off in a
thread different from the event control which surfaceflinger
called. So, while the calls from surfaceflinger are in order, the
order of execution wasn't always the same. Hence, making sure
ioctls are called in the same context to ensure order.
Also
- Make blanking/unblanking logs show the operation as a string.
- Add a debug property to dump vsync timestamps (needs framework
reboot)
- Remove a log which showed delay in reading vsync. This log was
unreliable when vsync is disabled and we're still reading from
the sysfs node.
Change-Id: Ibec04e9ffebd0ac6e1d32b7031e3668abd9390ff
CRs-fixed: 443113
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 785e66e..ae7bb95 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -209,22 +209,24 @@
}
static int hwc_eventControl(struct hwc_composer_device_1* dev, int dpy,
- int event, int enabled)
+ int event, int enable)
{
int ret = 0;
-
hwc_context_t* ctx = (hwc_context_t*)(dev);
private_module_t* m = reinterpret_cast<private_module_t*>(
ctx->mFbDev->common.module);
pthread_mutex_lock(&ctx->vstate.lock);
switch(event) {
case HWC_EVENT_VSYNC:
- if (ctx->vstate.enable == enabled)
+ if (ctx->vstate.enable == enable)
break;
- ctx->vstate.enable = !!enabled;
- pthread_cond_signal(&ctx->vstate.cond);
+ ret = hwc_vsync_control(ctx, dpy, enable);
+ if(ret == 0) {
+ ctx->vstate.enable = !!enable;
+ pthread_cond_signal(&ctx->vstate.cond);
+ }
ALOGD_IF (VSYNC_DEBUG, "VSYNC state changed to %s",
- (enabled)?"ENABLED":"DISABLED");
+ (enable)?"ENABLED":"DISABLED");
break;
default:
ret = -EINVAL;
@@ -241,7 +243,8 @@
ctx->mFbDev->common.module);
Locker::Autolock _l(ctx->mBlankLock);
int ret = 0;
- ALOGD("%s: Doing Dpy=%d, blank=%d", __FUNCTION__, dpy, blank);
+ ALOGD("%s: %s display: %d", __FUNCTION__,
+ blank==1 ? "Blanking":"Unblanking", dpy);
switch(dpy) {
case HWC_DISPLAY_PRIMARY:
if(blank) {
@@ -286,14 +289,16 @@
// Enable HPD here, as during bootup unblank is called
// when SF is completely initialized
ctx->mExtDisplay->setHPD(1);
-
- if(ret < 0) {
- ALOGE("%s: failed. Dpy=%d, blank=%d : %s",
- __FUNCTION__, dpy, blank, strerror(errno));
+ if(ret == 0){
+ ctx->dpyAttr[dpy].isActive = !blank;
+ } else {
+ ALOGE("%s: Failed in %s display: %d error:%s", __FUNCTION__,
+ blank==1 ? "blanking":"unblanking", dpy, strerror(errno));
return ret;
}
- ALOGD("%s: Done Dpy=%d, blank=%d", __FUNCTION__, dpy, blank);
- ctx->dpyAttr[dpy].isActive = !blank;
+
+ ALOGD("%s: Done %s display: %d", __FUNCTION__,
+ blank==1 ? "blanking":"unblanking", dpy);
return 0;
}