diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-04-04 15:16:50 +0100 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-04-06 00:34:54 +0100 |
commit | c962bf8b8fa4d9a6400811296fb270f47db68cf4 (patch) | |
tree | f5e651935cbbf54e6d1488bbe19a6e2a4599a070 /libhwcomposer/hwc_vsync.cpp | |
parent | 7a8a513ac8a2b9a76b36cf1341d45b00d88ed45c (diff) | |
parent | 6445344dbaf08ec4d8fbf6aeeffdf29faed64e78 (diff) | |
download | hardware_qcom_display-cm-10.1.tar.gz hardware_qcom_display-cm-10.1.tar.bz2 hardware_qcom_display-cm-10.1.zip |
Merge remote-tracking branch 'aosp/jb-mr1.1-release' into cm-10.1cm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1.2cm-10.1.1cm-10.1.0-RC5cm-10.1.0-RC4cm-10.1.0-RC3cm-10.1.0-RC2cm-10.1.0-RC1cm-10.1.0cm-10.1-M3cm-10.1
Change-Id: I44a10eaa285d0521669781a4fafb7641df209186
Diffstat (limited to 'libhwcomposer/hwc_vsync.cpp')
-rw-r--r-- | libhwcomposer/hwc_vsync.cpp | 91 |
1 files changed, 54 insertions, 37 deletions
diff --git a/libhwcomposer/hwc_vsync.cpp b/libhwcomposer/hwc_vsync.cpp index a3becfa59..ee6af2856 100644 --- a/libhwcomposer/hwc_vsync.cpp +++ b/libhwcomposer/hwc_vsync.cpp @@ -21,6 +21,7 @@ // WARNING : Excessive logging, if VSYNC_DEBUG enabled #define VSYNC_DEBUG 0 +#include <cutils/properties.h> #include <utils/Log.h> #include <fcntl.h> #include <sys/ioctl.h> @@ -59,16 +60,23 @@ static void *vsync_loop(void *param) int ret = 0; bool fb1_vsync = false; bool enabled = false; + bool fakevsync = false; + + char property[PROPERTY_VALUE_MAX]; + if(property_get("debug.hwc.fakevsync", property, NULL) > 0) { + if(atoi(property) == 1) + fakevsync = true; + } /* Currently read vsync timestamp from drivers e.g. VSYNC=41800875994 - */ + */ fd_timestamp = open(vsync_timestamp_fb0, O_RDONLY); if (fd_timestamp < 0) { ALOGE ("FATAL:%s:not able to open file:%s, %s", __FUNCTION__, (fb1_vsync) ? vsync_timestamp_fb1 : vsync_timestamp_fb0, strerror(errno)); - return NULL; + fakevsync = true; } do { @@ -76,7 +84,8 @@ static void *vsync_loop(void *param) while (ctx->vstate.enable == false) { if(enabled) { int e = 0; - if(ioctl(ctx->dpyAttr[dpy].fd, MSMFB_OVERLAY_VSYNC_CTRL, + if(!fakevsync && + ioctl(ctx->dpyAttr[dpy].fd, MSMFB_OVERLAY_VSYNC_CTRL, &e) < 0) { ALOGE("%s: vsync control failed. Dpy=%d, enabled=%d : %s", __FUNCTION__, dpy, enabled, strerror(errno)); @@ -90,8 +99,9 @@ static void *vsync_loop(void *param) if (!enabled) { int e = 1; - if(ioctl(ctx->dpyAttr[dpy].fd, MSMFB_OVERLAY_VSYNC_CTRL, - &e) < 0) { + if(!fakevsync && + ioctl(ctx->dpyAttr[dpy].fd, MSMFB_OVERLAY_VSYNC_CTRL, + &e) < 0) { ALOGE("%s: vsync control failed. Dpy=%d, enabled=%d : %s", __FUNCTION__, dpy, enabled, strerror(errno)); ret = -errno; @@ -99,37 +109,44 @@ static void *vsync_loop(void *param) enabled = true; } - for(int i = 0; i < MAX_RETRY_COUNT; i++) { - len = pread(fd_timestamp, vdata, MAX_DATA, 0); - if(len < 0 && (errno == EAGAIN || errno == EINTR)) { - ALOGW("%s: vsync read: EAGAIN, retry (%d/%d).", - __FUNCTION__, i, MAX_RETRY_COUNT); - continue; - } else { - break; - } - } - - if (len < 0) { - ALOGE ("FATAL:%s:not able to read file:%s, %s", __FUNCTION__, - vsync_timestamp_fb0, strerror(errno)); - //XXX: Need to continue here since SF needs vsync signal to compose - continue; - } - - // extract timestamp - const char *str = vdata; - if (!strncmp(str, "VSYNC=", strlen("VSYNC="))) { - cur_timestamp = strtoull(str + strlen("VSYNC="), NULL, 0); - } else { - ALOGE ("FATAL: %s: vsync timestamp not in correct format: [%s]", - __FUNCTION__, - str); - } - // send timestamp to HAL - ALOGD_IF (VSYNC_DEBUG, "%s: timestamp %llu sent to HWC for %s", - __FUNCTION__, cur_timestamp, "fb0"); - ctx->proc->vsync(ctx->proc, dpy, cur_timestamp); + if(!fakevsync) { + for(int i = 0; i < MAX_RETRY_COUNT; i++) { + len = pread(fd_timestamp, vdata, MAX_DATA, 0); + if(len < 0 && (errno == EAGAIN || errno == EINTR)) { + ALOGW("%s: vsync read: EAGAIN, retry (%d/%d).", + __FUNCTION__, i, MAX_RETRY_COUNT); + continue; + } else { + break; + } + } + + if (len < 0) { + ALOGE ("FATAL:%s:not able to read file:%s, %s", __FUNCTION__, + vsync_timestamp_fb0, strerror(errno)); + close (fd_timestamp); + fakevsync = true; + } + + // extract timestamp + const char *str = vdata; + if (!strncmp(str, "VSYNC=", strlen("VSYNC="))) { + cur_timestamp = strtoull(str + strlen("VSYNC="), NULL, 0); + } else { + ALOGE ("FATAL: %s: vsync timestamp not in correct format: [%s]", + __FUNCTION__, + str); + fakevsync = true; + } + + } else { + usleep(16000); + cur_timestamp = systemTime(); + } + // send timestamp to HAL + ALOGD_IF (VSYNC_DEBUG, "%s: timestamp %llu sent to HWC for %s", + __FUNCTION__, cur_timestamp, "fb0"); + ctx->proc->vsync(ctx->proc, dpy, cur_timestamp); } while (true); if(fd_timestamp >= 0) @@ -146,7 +163,7 @@ void init_vsync_thread(hwc_context_t* ctx) ret = pthread_create(&vsync_thread, NULL, vsync_loop, (void*) ctx); if (ret) { ALOGE("%s: failed to create %s: %s", __FUNCTION__, - HWC_VSYNC_THREAD_NAME, strerror(ret)); + HWC_VSYNC_THREAD_NAME, strerror(ret)); } } |