Skip to content

Commit 964d343

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 980bd4c commit 964d343

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

backend/fbdev.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ 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(uint32_t)));
59+
off_t off = sizeof(uint32_t) * left + top * tx->fb_fix.line_length;
60+
uint32_t *dest = (uint32_t *) ((uintptr_t) tx->fb_base + off);
6261
memcpy(dest, pixels, width * sizeof(uint32_t));
6362
}
6463

@@ -105,6 +104,11 @@ static bool twin_fbdev_apply_config(twin_fbdev_t *tx)
105104
return false;
106105
}
107106

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

0 commit comments

Comments
 (0)