hw/display/exynos4210_fimd: Pass width to draw_line functions
The draw_line functions currently assume the width of the line they need to draw is w->rightbot_x - w->lefttop_x + 1, i.e. the full width of the guest-programmed window. We want to be able to clamp this to the overall screen size, which we can calculate in the calling function. Refactor to do this calculation in the caller and pass the width as an argument to the draw_line functions. Stable CC because this is a prerequisite for an upcoming bugfix commit. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20260706173324.804340-3-peter.maydell@linaro.org
Peter Maydell committed
Jul 6, 2026 at 18:33 UTC
7dd1e2218835f2c0bd754c092588110883a380a5
1 file changed
+10
-8
hw/display/exynos4210_fimd.c
+10
-8
@@ -282,7 +282,7 @@ struct Exynos4210fimdWindow {
282
283
pixel_to_rgb_func *pixel_to_rgb;
284
void (*draw_line)(Exynos4210fimdWindow *w, uint8_t *src, uint8_t *dst,
285
- bool blend);
285
+ uint32_t width, bool blend);
286
uint32_t (*get_alpha)(Exynos4210fimdWindow *w, uint32_t pix_a);
287
uint16_t lefttop_x, lefttop_y; /* VIDOSD0 register */
288
uint16_t rightbot_x, rightbot_y; /* VIDOSD1 register */
@@ -784,9 +784,9 @@ exynos4210_fimd_blend_pixel(Exynos4210fimdWindow *w, rgba p_bg, rgba *ret)
784
/* Draw line with index in palette table in RAM frame buffer data */
785
#define DEF_DRAW_LINE_PALETTE(N) \
786
static void glue(draw_line_palette_, N)(Exynos4210fimdWindow *w, uint8_t *src, \
787
- uint8_t *dst, bool blend) \
787
+ uint8_t *dst, uint32_t width, \
788
+ bool blend) \
789
{ \
789
- int width = w->rightbot_x - w->lefttop_x + 1; \
790
uint8_t *ifb = dst; \
791
uint8_t swap = (w->wincon & FIMD_WINCON_SWAP) >> FIMD_WINCON_SWAP_SHIFT; \
792
uint64_t data; \
@@ -813,9 +813,8 @@ static void glue(draw_line_palette_, N)(Exynos4210fimdWindow *w, uint8_t *src, \
813
/* Draw line with direct color value in RAM frame buffer data */
814
#define DEF_DRAW_LINE_NOPALETTE(N) \
815
static void glue(draw_line_, N)(Exynos4210fimdWindow *w, uint8_t *src, \
816
- uint8_t *dst, bool blend) \
816
+ uint8_t *dst, uint32_t width, bool blend) \
817
{ \
818
- int width = w->rightbot_x - w->lefttop_x + 1; \
818
uint8_t *ifb = dst; \
819
uint8_t swap = (w->wincon & FIMD_WINCON_SWAP) >> FIMD_WINCON_SWAP_SHIFT; \
820
uint64_t data; \
@@ -848,11 +847,10 @@ DEF_DRAW_LINE_NOPALETTE(32)
847
848
/* Special draw line routine for window color map case */
849
static void draw_line_mapcolor(Exynos4210fimdWindow *w, uint8_t *src,
851
- uint8_t *dst, bool blend)
850
+ uint8_t *dst, uint32_t width, bool blend)
851
{
852
rgba p, p_old;
853
uint8_t *ifb = dst;
855
- int width = w->rightbot_x - w->lefttop_x + 1;
854
uint32_t map_color = w->winmap & FIMD_WINMAP_COLOR_MASK;
855
856
do {
@@ -1240,6 +1238,7 @@ static bool exynos4210_fimd_update(void *opaque)
1238
uint8_t *host_fb_addr;
1239
bool is_dirty = false;
1240
uint32_t global_width;
1241
+ uint32_t window_width;
1242
1243
if (!s || !s->console || !s->enabled ||
1244
surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) {
@@ -1255,6 +1254,8 @@ static bool exynos4210_fimd_update(void *opaque)
1254
if ((w->wincon & FIMD_WINCON_ENWIN) && w->host_fb_addr) {
1255
scrn_height = w->rightbot_y - w->lefttop_y + 1;
1256
scrn_width = w->virtpage_width;
1257
+ /* Number of bytes to actually draw */
1258
+ window_width = w->rightbot_x - w->lefttop_x + 1;
1259
/* Total width of virtual screen page in bytes */
1260
inc_size = scrn_width + w->virtpage_offsize;
1261
host_fb_addr = w->host_fb_addr;
@@ -1273,7 +1274,8 @@ static bool exynos4210_fimd_update(void *opaque)
1274
last_line = line;
1275
w->draw_line(w, host_fb_addr, s->ifb +
1276
w->lefttop_x * RGBA_SIZE + (w->lefttop_y + line) *
1276
- global_width * RGBA_SIZE, blend);
1277
+ global_width * RGBA_SIZE,
1278
+ window_width, blend);
1279
}
1280
host_fb_addr += inc_size;
1281
fb_line_addr += inc_size;