diff --git a/backend/fbdev.c b/backend/fbdev.c index eb50cd1..582b614 100644 --- a/backend/fbdev.c +++ b/backend/fbdev.c @@ -20,6 +20,7 @@ #define FBDEV_NAME "FRAMEBUFFER" #define FBDEV_DEFAULT "/dev/fb0" +#define FBIO_CACHE_SYNC 0x4630 #define SCREEN(x) ((twin_context_t *) x)->screen #define PRIV(x) ((twin_fbdev_t *) ((twin_context_t *) x)->priv) @@ -56,12 +57,23 @@ static void _twin_fbdev_put_span(twin_coord_t left, return; twin_coord_t width = right - left; - off_t off = top * screen->width + left; - uint32_t *dest = - (uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(uint32_t))); + off_t off = tx->fb_fix.line_length * top + 4 * left; + unsigned char *dest = (unsigned char *) tx->fb_base + off; memcpy(dest, pixels, width * sizeof(uint32_t)); } +static void twin_fbdev_cache_sync(void *closure) +{ + twin_fbdev_t *tx = PRIV(closure); + unsigned int args[2]; + args[0] = tx->fb_base; + args[1] = tx->fb_base + tx->fb_var.yres_virtual * tx->fb_fix.line_length; + ioctl(tx->fb_fd, FBIO_CACHE_SYNC, args); + + struct fb_var_screeninfo var = tx->fb_var; + ioctl(tx->fb_fd, FBIOPAN_DISPLAY, &var); +} + static void twin_fbdev_get_screen_size(twin_fbdev_t *tx, int *width, int *height) @@ -85,6 +97,7 @@ static bool twin_fbdev_work(void *closure) if (twin_screen_damaged(screen)) twin_screen_update(screen); + twin_fbdev_cache_sync(closure); return true; }