@samitouri / QOSamiQemu / commits / 3ab35ff519

ati-vga: Latch src and dst pitch and offset on master_cntl default

Hardware testing on the Rage 128 confirms that (SRC/DST)_OFFSET, and (SRC/DST)_PITCH are latched when (SRC/DST)_PITCH_OFFSET_CNTL bits in DP_GUI_MASTER_CNTL are set to "default". The earlier approach looked at the state of the (SRC/DST)_PITCH_OFFSET_CNTL bits when offset and pitch registers were used. This meant that when (SRC/DST)_PITCH_OFFSET_CNTL was reset to "leave alone" the old values stored in the registers would return. This is not how the real hardware works. Signed-off-by: Chad Jablonski <chad@jablonski.xyz> Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu> Message-ID: <20260303024730.1489136-5-chad@jablonski.xyz> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Chad Jablonski committed Mar 2, 2026 at 21:47 UTC 3ab35ff519b95cb37e1f87281229ea68229daf58
2 files changed +13 -9
hw/display/ati.c
+9
@@ -868,6 +868,15 @@ static void ati_mm_write(void *opaque, hwaddr addr,
868 s->regs.dp_datatype = (data & 0x0f00) >> 8 | (data & 0x30f0) << 4 |
869 (data & 0x4000) << 16;
870 s->regs.dp_mix = (data & GMC_ROP3_MASK) | (data & 0x7000000) >> 16;
871 +
872 + if (!(data & GMC_SRC_PITCH_OFFSET_CNTL)) {
873 + s->regs.src_offset = s->regs.default_offset;
874 + s->regs.src_pitch = s->regs.default_pitch;
875 + }
876 + if (!(data & GMC_DST_PITCH_OFFSET_CNTL)) {
877 + s->regs.dst_offset = s->regs.default_offset;
878 + s->regs.dst_pitch = s->regs.default_pitch;
879 + }
880 break;
881 case DST_WIDTH_X:
882 s->regs.dst_x = data & 0x3fff;
hw/display/ati_2d.c
+4 -9
@@ -43,8 +43,6 @@ static int ati_bpp_from_datatype(ATIVGAState *s)
43 }
44 }
45
46 -#define DEFAULT_CNTL (s->regs.dp_gui_master_cntl & GMC_DST_PITCH_OFFSET_CNTL)
47 -
46 void ati_2d_blt(ATIVGAState *s)
47 {
48 /* FIXME it is probably more complex than this and may need to be */
@@ -63,13 +61,12 @@ void ati_2d_blt(ATIVGAState *s)
61 qemu_log_mask(LOG_GUEST_ERROR, "Invalid bpp\n");
62 return;
63 }
66 - int dst_stride = DEFAULT_CNTL ? s->regs.dst_pitch : s->regs.default_pitch;
64 + int dst_stride = s->regs.dst_pitch;
65 if (!dst_stride) {
66 qemu_log_mask(LOG_GUEST_ERROR, "Zero dest pitch\n");
67 return;
68 }
71 - uint8_t *dst_bits = s->vga.vram_ptr + (DEFAULT_CNTL ?
72 - s->regs.dst_offset : s->regs.default_offset);
69 + uint8_t *dst_bits = s->vga.vram_ptr + s->regs.dst_offset;
70
71 if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) {
72 dst_bits += s->regs.crtc_offset & 0x07ffffff;
@@ -97,14 +94,12 @@ void ati_2d_blt(ATIVGAState *s)
94 s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_width);
95 unsigned src_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
96 s->regs.src_y : s->regs.src_y + 1 - s->regs.dst_height);
100 - int src_stride = DEFAULT_CNTL ?
101 - s->regs.src_pitch : s->regs.default_pitch;
97 + int src_stride = s->regs.src_pitch;
98 if (!src_stride) {
99 qemu_log_mask(LOG_GUEST_ERROR, "Zero source pitch\n");
100 return;
101 }
106 - uint8_t *src_bits = s->vga.vram_ptr + (DEFAULT_CNTL ?
107 - s->regs.src_offset : s->regs.default_offset);
102 + uint8_t *src_bits = s->vga.vram_ptr + s->regs.src_offset;
103
104 if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) {
105 src_bits += s->regs.crtc_offset & 0x07ffffff;