hwc: fix reading vsync timestamps from sysfs
authorGreg Hackmann <ghackmann@google.com>
Thu, 26 Jul 2012 21:21:16 +0000 (14:21 -0700)
committerGreg Hackmann <ghackmann@google.com>
Thu, 26 Jul 2012 22:01:02 +0000 (15:01 -0700)
Per the recipe in kernel commit
4508a7a734b111b8b7e39986237d84acb1168dd0.  Prevents a vsync timestamp
being delivered to SurfaceFlinger before it requests them.

Change-Id: I2185594c1d15ee13ff3f78779140e7655153b540
Signed-off-by: Greg Hackmann <ghackmann@google.com>
libhwc/hwc.cpp

index f1fcfb080754d0bf2b660d49f1ce017abe314eff..5fb5bbcb3d3649dff25985b6826855355ab07727 100644 (file)
@@ -713,8 +713,14 @@ static void handle_vsync_event(struct exynos5_hwc_composer_device_1_t *pdev)
     if (!pdev->procs || !pdev->procs->vsync)
         return;
 
+    int err = lseek(pdev->vsync_fd, 0, SEEK_SET);
+    if (err < 0) {
+        ALOGE("error seeking to vsync timestamp: %s", strerror(errno));
+        return;
+    }
+
     char buf[4096];
-    int err = read(pdev->vsync_fd, buf, sizeof(buf));
+    err = read(pdev->vsync_fd, buf, sizeof(buf));
     if (err < 0) {
         ALOGE("error reading vsync timestamp: %s", strerror(errno));
         return;
@@ -738,6 +744,13 @@ static void *hwc_vsync_thread(void *data)
 
     uevent_init();
 
+    char temp[4096];
+    int err = read(pdev->vsync_fd, temp, sizeof(temp));
+    if (err < 0) {
+        ALOGE("error reading vsync timestamp: %s", strerror(errno));
+        return NULL;
+    }
+
     struct pollfd fds[2];
     fds[0].fd = pdev->vsync_fd;
     fds[0].events = POLLPRI;