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 Oct 31, 2024
1 parent 980bd4c commit 964d343
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ 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 = sizeof(uint32_t) * left + top * tx->fb_fix.line_length;
uint32_t *dest = (uint32_t *) ((uintptr_t) tx->fb_base + off);
memcpy(dest, pixels, width * sizeof(uint32_t));
}

Expand Down Expand Up @@ -105,6 +104,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 964d343

Please sign in to comment.