Skip to content

Commit dee133c

Browse files
committed
Fix memory region in framebuffer and cache synchronization
1 parent 980bd4c commit dee133c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

backend/fbdev.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#define FBDEV_NAME "FRAMEBUFFER"
2222
#define FBDEV_DEFAULT "/dev/fb0"
23+
#define FBIO_CACHE_SYNC 0x4630
2324
#define SCREEN(x) ((twin_context_t *) x)->screen
2425
#define PRIV(x) ((twin_fbdev_t *) ((twin_context_t *) x)->priv)
2526

@@ -56,12 +57,23 @@ static void _twin_fbdev_put_span(twin_coord_t left,
5657
return;
5758

5859
twin_coord_t width = right - left;
59-
off_t off = top * screen->width + left;
60-
uint32_t *dest =
61-
(uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(uint32_t)));
60+
off_t off = tx->fb_fix.line_length * top + 4 * left;
61+
unsigned char *dest = (unsigned char *) tx->fb_base + off;
6262
memcpy(dest, pixels, width * sizeof(uint32_t));
6363
}
6464

65+
static void twin_fbdev_cache_sync(void *closure)
66+
{
67+
twin_fbdev_t *tx = PRIV(closure);
68+
unsigned int args[2];
69+
args[0] = tx->fb_base;
70+
args[1] = tx->fb_base + tx->fb_var.yres_virtual * tx->fb_fix.line_length;
71+
ioctl(tx->fb_fd, FBIO_CACHE_SYNC, args);
72+
73+
struct fb_var_screeninfo var = tx->fb_var;
74+
ioctl(tx->fb_fd, FBIOPAN_DISPLAY, &var);
75+
}
76+
6577
static void twin_fbdev_get_screen_size(twin_fbdev_t *tx,
6678
int *width,
6779
int *height)
@@ -85,6 +97,7 @@ static bool twin_fbdev_work(void *closure)
8597

8698
if (twin_screen_damaged(screen))
8799
twin_screen_update(screen);
100+
twin_fbdev_cache_sync(closure);
88101
return true;
89102
}
90103

0 commit comments

Comments
 (0)