Skip to content

Commit acf5c4d

Browse files
committed
Fix memory region in framebuffer and pan display
The width of a screen may be different to the virtual resolution. If the virtual screen size is set, `xoffset` and `yoffset` should be set as well. `FBIOPAN_DISPLAY` is used to update these setting. The same setting may not be applied on different hardware.
1 parent a846095 commit acf5c4d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

backend/fbdev.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ static void _twin_fbdev_put_span(twin_coord_t left,
5656
return;
5757

5858
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(*dest)));
59+
uint32_t *dest;
60+
off_t off = sizeof(*dest) * left + top * tx->fb_fix.line_length;
61+
dest = (uint32_t *) ((uintptr_t) tx->fb_base + off);
6262
memcpy(dest, pixels, width * sizeof(*dest));
6363
}
6464

@@ -105,6 +105,11 @@ static bool twin_fbdev_apply_config(twin_fbdev_t *tx)
105105
return false;
106106
}
107107

108+
/* Set if the xoffset and yoffset are changed */
109+
tx->fb_var.xoffset = 0;
110+
tx->fb_var.yoffset = 0;
111+
ioctl(tx->fb_fd, FBIOPAN_DISPLAY, &tx->fb_var);
112+
108113
/* Read changable information of the framebuffer again */
109114
if (ioctl(tx->fb_fd, FBIOGET_VSCREENINFO, &tx->fb_var) < 0) {
110115
log_error("Failed to get framebuffer information");

0 commit comments

Comments
 (0)