ioctl doesn't work for my intel
authorEleni Maria Stea <elene.mst@gmail.com>
Sun, 24 Feb 2013 19:08:26 +0000 (21:08 +0200)
committerEleni Maria Stea <elene.mst@gmail.com>
Sun, 24 Feb 2013 19:08:26 +0000 (21:08 +0200)
#@%&)@*&)*$%^)#&@%_
todo: find an intel and test

src/fbdev/gfx.cc
src/gfx.h
src/main.cc
src/sdl/gfx.cc
src/wm.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
index c866d78..2cf16b7 100644 (file)
--- a/src/gfx.h
+++ b/src/gfx.h
@@ -23,4 +23,6 @@ void blit_key(unsigned char *src_img, const Rect &src_rect, unsigned char* dest_
 
 void gfx_update();
 
+void wait_vsync(); // vertical synchronization
+
 #endif //GFX_H_
index f87b011..ab82aa2 100644 (file)
@@ -11,7 +11,10 @@ static void cleanup();
 
 int main()
 {
-       winnie_init();
+       if(!winnie_init()) {
+               exit(1);
+       }
+
        atexit(cleanup);
 
        Window *win1 = new Window;
index b757688..5be33e6 100644 (file)
@@ -167,4 +167,8 @@ void gfx_update()
        SDL_UpdateRect(fbsurf, 0, 0, 0, 0);
 }
 
+void wait_vsync()
+{
+}
+
 #endif // WINNIE_SDL
index a6e29b0..4547e1d 100644 (file)
--- a/src/wm.cc
+++ b/src/wm.cc
@@ -117,6 +117,8 @@ void WindowManager::process_windows()
        }
        dirty_rects.clear();
 
+       wait_vsync();
+
        fill_rect(uni, bg_color[0], bg_color[1], bg_color[2]);
 
        root_win->draw_children(uni);