Skip to content

Commit

Permalink
Fix memory region in framebuffer and pan display
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a1091150 committed Nov 4, 2024
1 parent a846095 commit acf5c4d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions backend/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ 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(*dest)));
uint32_t *dest;
off_t off = sizeof(*dest) * left + top * tx->fb_fix.line_length;
dest = (uint32_t *) ((uintptr_t) tx->fb_base + off);
memcpy(dest, pixels, width * sizeof(*dest));
}

Expand Down Expand Up @@ -105,6 +105,11 @@ static bool twin_fbdev_apply_config(twin_fbdev_t *tx)
return false;
}

/* Set if the xoffset and yoffset are changed */
tx->fb_var.xoffset = 0;
tx->fb_var.yoffset = 0;
ioctl(tx->fb_fd, FBIOPAN_DISPLAY, &tx->fb_var);

/* Read changable information of the framebuffer again */
if (ioctl(tx->fb_fd, FBIOGET_VSCREENINFO, &tx->fb_var) < 0) {
log_error("Failed to get framebuffer information");
Expand Down

0 comments on commit acf5c4d

Please sign in to comment.