[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 092/126] hw/display/sm501: Add fallbacks to pixman routines
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 092/126] hw/display/sm501: Add fallbacks to pixman routines |
Date: |
Mon, 27 Feb 2023 15:01:39 +0100 |
From: BALATON Zoltan <balaton@eik.bme.hu>
Pixman may return false if it does not have a suitable implementation.
Add fallbacks to handle such cases.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reported-by: Rene Engel <ReneEngel80@emailn.de>
Tested-by: Rene Engel <ReneEngel80@emailn.de>
Message-Id:
<20ed9442a0146238254ccc340c0d1efa226c6356.1677445307.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/display/sm501.c | 75 ++++++++++++++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 23 deletions(-)
diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index c4c567d977..17835159fc 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -692,7 +692,7 @@ static void sm501_2d_operation(SM501State *s)
unsigned int dst_pitch = (s->twoD_pitch >> 16) & 0x1FFF;
int crt = (s->dc_crt_control & SM501_DC_CRT_CONTROL_SEL) ? 1 : 0;
int fb_len = get_width(s, crt) * get_height(s, crt) * get_bpp(s, crt);
- bool overlap = false;
+ bool overlap = false, fallback = false;
if ((s->twoD_stretch >> 16) & 0xF) {
qemu_log_mask(LOG_UNIMP, "sm501: only XY addressing is supported.\n");
@@ -835,25 +835,48 @@ static void sm501_2d_operation(SM501State *s)
if (tmp_stride * sizeof(uint32_t) * height > sizeof(tmp_buf)) {
tmp = g_malloc(tmp_stride * sizeof(uint32_t) * height);
}
- pixman_blt((uint32_t *)&s->local_mem[src_base], tmp,
- src_pitch * bypp / sizeof(uint32_t),
- tmp_stride, 8 * bypp, 8 * bypp,
- src_x, src_y, 0, 0, width, height);
- pixman_blt(tmp, (uint32_t *)&s->local_mem[dst_base],
- tmp_stride,
- dst_pitch * bypp / sizeof(uint32_t),
- 8 * bypp, 8 * bypp,
- 0, 0, dst_x, dst_y, width, height);
+ fallback = !pixman_blt((uint32_t *)&s->local_mem[src_base],
+ tmp,
+ src_pitch * bypp / sizeof(uint32_t),
+ tmp_stride,
+ 8 * bypp, 8 * bypp,
+ src_x, src_y, 0, 0, width, height);
+ if (!fallback) {
+ fallback = !pixman_blt(tmp,
+ (uint32_t *)&s->local_mem[dst_base],
+ tmp_stride,
+ dst_pitch * bypp / sizeof(uint32_t),
+ 8 * bypp, 8 * bypp,
+ 0, 0, dst_x, dst_y, width, height);
+ }
if (tmp != tmp_buf) {
g_free(tmp);
}
} else {
- pixman_blt((uint32_t *)&s->local_mem[src_base],
- (uint32_t *)&s->local_mem[dst_base],
- src_pitch * bypp / sizeof(uint32_t),
- dst_pitch * bypp / sizeof(uint32_t),
- 8 * bypp, 8 * bypp,
- src_x, src_y, dst_x, dst_y, width, height);
+ fallback = !pixman_blt((uint32_t *)&s->local_mem[src_base],
+ (uint32_t *)&s->local_mem[dst_base],
+ src_pitch * bypp / sizeof(uint32_t),
+ dst_pitch * bypp / sizeof(uint32_t),
+ 8 * bypp, 8 * bypp, src_x, src_y,
+ dst_x, dst_y, width, height);
+ }
+ if (fallback) {
+ uint8_t *sp = s->local_mem + src_base;
+ uint8_t *d = s->local_mem + dst_base;
+ unsigned int y, i, j;
+ for (y = 0; y < height; y++) {
+ if (overlap) { /* overlap also means rtl */
+ i = (dst_y + height - 1 - y) * dst_pitch;
+ i = (dst_x + i) * bypp;
+ j = (src_y + height - 1 - y) * src_pitch;
+ j = (src_x + j) * bypp;
+ memmove(&d[i], &sp[j], width * bypp);
+ } else {
+ i = (dst_x + (dst_y + y) * dst_pitch) * bypp;
+ j = (src_x + (src_y + y) * src_pitch) * bypp;
+ memcpy(&d[i], &sp[j], width * bypp);
+ }
+ }
}
}
break;
@@ -868,13 +891,19 @@ static void sm501_2d_operation(SM501State *s)
color = cpu_to_le16(color);
}
- if (width == 1 && height == 1) {
- unsigned int i = (dst_x + dst_y * dst_pitch) * bypp;
- stn_he_p(&s->local_mem[dst_base + i], bypp, color);
- } else {
- pixman_fill((uint32_t *)&s->local_mem[dst_base],
- dst_pitch * bypp / sizeof(uint32_t),
- 8 * bypp, dst_x, dst_y, width, height, color);
+ if ((width == 1 && height == 1) ||
+ !pixman_fill((uint32_t *)&s->local_mem[dst_base],
+ dst_pitch * bypp / sizeof(uint32_t), 8 * bypp,
+ dst_x, dst_y, width, height, color)) {
+ /* fallback when pixman failed or we don't want to call it */
+ uint8_t *d = s->local_mem + dst_base;
+ unsigned int x, y, i;
+ for (y = 0; y < height; y++, i += dst_pitch * bypp) {
+ i = (dst_x + (dst_y + y) * dst_pitch) * bypp;
+ for (x = 0; x < width; x++, i += bypp) {
+ stn_he_p(&d[i], bypp, color);
+ }
+ }
}
break;
}
--
2.38.1
- [PULL 079/126] hw/usb/ohci: Code style fix comments, (continued)
- [PULL 079/126] hw/usb/ohci: Code style fix comments, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 083/126] hw/usb/ohci: Add trace points for register access, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 084/126] hw/usb/ohci: Fix typo, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 087/126] hw/usb/xhci-nec: Declare QOM macros for NEC_XHCI, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 089/126] hw/display/sm501: Embed OHCI QOM child in chipset, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 086/126] hw/usb/uhci: Replace container_of() by UHCI_GET_CLASS() QOM macro, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 088/126] hw/usb/xhci-nec: Replace container_of() by NEC_XHCI() QOM cast macro, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 090/126] hw/display/sm501: Alias 'dma-offset' QOM property in chipset object, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 085/126] hw/usb/uhci: Declare QOM macros using OBJECT_DECLARE_TYPE(), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 091/126] hw/display/sm501: Implement more 2D raster operations, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 092/126] hw/display/sm501: Add fallbacks to pixman routines,
Philippe Mathieu-Daudé <=
- [PULL 093/126] hw/ppc/sam460ex: Correctly set MAL properties, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 094/126] block/vvfat: Remove pointless check of NDEBUG, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 095/126] scripts/checkpatch.pl: Do not allow assert(0), Philippe Mathieu-Daudé, 2023/02/27
- [PULL 096/126] MAINTAINERS: Mark IDE and Floppy as "Odd Fixes", Philippe Mathieu-Daudé, 2023/02/27
- [PULL 099/126] hw/ide/mmio: Use CamelCase for MMIO_IDE state name, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 101/126] hw/ide/isa: Extract TYPE_ISA_IDE declarations to 'hw/ide/isa.h', Philippe Mathieu-Daudé, 2023/02/27
- [PULL 103/126] hw/ide/atapi: Restrict 'scsi/constants.h' inclusion, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 098/126] hw/ide/ahci: Trace ncq write command as write instead of read, Philippe Mathieu-Daudé, 2023/02/27
- [PULL 100/126] hw/ide/mmio: Extract TYPE_MMIO_IDE declarations to 'hw/ide/mmio.h', Philippe Mathieu-Daudé, 2023/02/27
- [PULL 102/126] hw/ide/isa: Remove intermediate ISAIDEState::irq variable, Philippe Mathieu-Daudé, 2023/02/27