Skip to content

Commit

Permalink
Fix memory region in framebuffer and cache synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
a1091150 committed Oct 26, 2024
1 parent 980bd4c commit dee133c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions backend/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down

0 comments on commit dee133c

Please sign in to comment.