@samitouri / QOSamiQemu / commits / 4f635bddf5

hw/display/exynos4210_fimd: Factor out finding screen width/height

Currently we hard-code the expressions for getting the global screen width and height out of the VIDTCON2 register where we need them. Use functions instead. Make the global_width variable in exynos4210_fimd_update() uint32_t for consistency. (The values are clamped to well below INT_MAX, so there is no overflow risk here.) 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-2-peter.maydell@linaro.org

Peter Maydell committed Jul 6, 2026 at 18:33 UTC 4f635bddf50c8c7783dbab7a584ebce4a07feee2
1 file changed +16 -6
hw/display/exynos4210_fimd.c
+16 -6
@@ -1195,15 +1195,25 @@ static void exynos4210_fimd_update_irq(Exynos4210fimdState *s)
1195 }
1196 }
1197
1198 +static uint32_t exynos4210_fimd_global_width(Exynos4210fimdState *s)
1199 +{
1200 + return ((s->vidtcon[2] >> FIMD_VIDTCON2_HOR_SHIFT) &
1201 + FIMD_VIDTCON2_SIZE_MASK) + 1;
1202 +}
1203 +
1204 +static uint32_t exynos4210_fimd_global_height(Exynos4210fimdState *s)
1205 +{
1206 + return ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) &
1207 + FIMD_VIDTCON2_SIZE_MASK) + 1;
1208 +}
1209 +
1210 static void exynos4210_update_resolution(Exynos4210fimdState *s)
1211 {
1212 DisplaySurface *surface = qemu_console_surface(s->console);
1213
1214 /* LCD resolution is stored in VIDEO TIME CONTROL REGISTER 2 */
1203 - uint32_t width = ((s->vidtcon[2] >> FIMD_VIDTCON2_HOR_SHIFT) &
1204 - FIMD_VIDTCON2_SIZE_MASK) + 1;
1205 - uint32_t height = ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) &
1206 - FIMD_VIDTCON2_SIZE_MASK) + 1;
1215 + uint32_t width = exynos4210_fimd_global_width(s);
1216 + uint32_t height = exynos4210_fimd_global_height(s);
1217
1218 if (s->ifb == NULL || surface_width(surface) != width ||
1219 surface_height(surface) != height) {
@@ -1229,14 +1239,14 @@ static bool exynos4210_fimd_update(void *opaque)
1239 bool blend = false;
1240 uint8_t *host_fb_addr;
1241 bool is_dirty = false;
1232 - int global_width;
1242 + uint32_t global_width;
1243
1244 if (!s || !s->console || !s->enabled ||
1245 surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) {
1246 return true;
1247 }
1248
1239 - global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1;
1249 + global_width = exynos4210_fimd_global_width(s);
1250 exynos4210_update_resolution(s);
1251 surface = qemu_console_surface(s->console);
1252