ioctl doesn't work for my intel
[winnie] / src / fbdev / gfx.cc
index 2b1c32a..db579ff 100644 (file)
@@ -7,6 +7,7 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
+#include <sys/time.h>
 #include <unistd.h>
 
 #include <linux/fb.h>
@@ -54,6 +55,16 @@ bool init_gfx()
                return false;
        }
 
+       fb_vblank vblank;
+       if(ioctl(dev_fd, FBIOGET_VBLANK, &vblank) == -1) {
+               fprintf(stderr, "FBIOGET_VBLANK error: %s\n", strerror(errno));
+       }
+       else {
+               printf("flags: %x\n", vblank.flags);
+               printf("count: %d\n", vblank.count);
+               printf("beam position: %d, %d\n", vblank.hcount, vblank.vcount);
+       }
+
        return true;
 }
 
@@ -233,4 +244,19 @@ void gfx_update()
 {
 }
 
+void wait_vsync()
+{
+       unsigned long arg = 0;
+
+       timeval tvstart, tvend;
+       gettimeofday(&tvstart, 0);
+       
+       if(ioctl(dev_fd, FBIO_WAITFORVSYNC, &arg) == -1) {
+               printf("ioctl error %s\n", strerror(errno));
+       }
+
+       gettimeofday(&tvend, 0);
+       printf("%ld %ld\n", tvend.tv_sec - tvstart.tv_sec, tvend.tv_usec - tvstart.tv_usec);
+}
+
 #endif // WINNIE_FBDEV