From: Eleni Maria Stea Date: Sun, 24 Feb 2013 19:08:26 +0000 (+0200) Subject: ioctl doesn't work for my intel X-Git-Url: https://eleni.mutantstargoat.com/git/?p=winnie;a=commitdiff_plain;h=c4ab1fa2768863098306862047bdb1116bd62a24 ioctl doesn't work for my intel #@%&)@*&)*$%^)#&@%_ todo: find an intel and test --- diff --git a/src/fbdev/gfx.cc b/src/fbdev/gfx.cc index 2b1c32a..db579ff 100644 --- a/src/fbdev/gfx.cc +++ b/src/fbdev/gfx.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/src/gfx.h b/src/gfx.h index c866d78..2cf16b7 100644 --- 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_ diff --git a/src/main.cc b/src/main.cc index f87b011..ab82aa2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -11,7 +11,10 @@ static void cleanup(); int main() { - winnie_init(); + if(!winnie_init()) { + exit(1); + } + atexit(cleanup); Window *win1 = new Window; diff --git a/src/sdl/gfx.cc b/src/sdl/gfx.cc index b757688..5be33e6 100644 --- a/src/sdl/gfx.cc +++ b/src/sdl/gfx.cc @@ -167,4 +167,8 @@ void gfx_update() SDL_UpdateRect(fbsurf, 0, 0, 0, 0); } +void wait_vsync() +{ +} + #endif // WINNIE_SDL diff --git a/src/wm.cc b/src/wm.cc index a6e29b0..4547e1d 100644 --- 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);