qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH] ati-vga: Implement dummy VBlank IRQ


From: BALATON Zoltan
Subject: Re: [Qemu-devel] [RFC PATCH] ati-vga: Implement dummy VBlank IRQ
Date: Thu, 15 Aug 2019 11:19:46 +0200 (CEST)
User-agent: Alpine 2.21.9999 (BSF 287 2018-06-16)

On Thu, 15 Aug 2019, Gerd Hoffmann wrote:
On Thu, Aug 15, 2019 at 02:25:07AM +0200, BALATON Zoltan wrote:
The MacOS driver exits if the card does not have an interrupt. If we
set PCI_INTERRUPT_PIN to 1 then it enables VBlank interrupts and it
boots but the mouse poniter can not be moved. This patch implements a
dummy VBlank interrupt by a timer triggered at 60 Hz to test if it
helps. Unfortunately it doesn't: MacOS with this patch hangs during
boot just polling interrupts and acknowledging them so maybe it needs
something else or there may be some other problem with this
implementation.

This is posted for comments and to let others experiment with it but
probably should not be committed upstream yet.

Signed-off-by: BALATON Zoltan <address@hidden>
---
 hw/display/ati.c      | 41 +++++++++++++++++++++++++++++++++++++++++
 hw/display/ati_dbg.c  |  1 +
 hw/display/ati_int.h  |  4 ++++
 hw/display/ati_regs.h |  1 +
 4 files changed, 47 insertions(+)

diff --git a/hw/display/ati.c b/hw/display/ati.c
index a365e2455d..e06cbf3e91 100644
--- a/hw/display/ati.c
+++ b/hw/display/ati.c
@@ -243,6 +243,21 @@ static uint64_t ati_i2c(bitbang_i2c_interface *i2c, 
uint64_t data, int base)
     return data;
 }

+static void ati_vga_update_irq(ATIVGAState *s)
+{
+    pci_set_irq(&s->dev, s->regs.gen_int_status & 1);

This should be "s->regs.gen_int_status & s->regs.gen_int_cntl" I guess?

Probably, but we only try to emulate VBlank yet so to avoid any problems due to raising irq for unknown bits I restricted it for that now.

+static void ati_vga_vblank_irq(void *opaque)
+{
+    ATIVGAState *s = opaque;
+
+    timer_mod(&s->vblank_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
+              NANOSECONDS_PER_SECOND / 60);
+    s->regs.gen_int_status |= 1;

#defines for the irq status bits would be nice.

Yes, I thought about that but this was only for quick testing. I'll add constant for this in next version.

+    case GEN_INT_CNTL:
+        s->regs.gen_int_cntl = data;
+        if (data & 1) {
+            ati_vga_vblank_irq(s);
+        } else {
+            timer_del(&s->vblank_timer);
+        }

ati_vga_update_irq() needed here.

+        break;
+    case GEN_INT_STATUS:
+        data &= (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF ?
+                 0x000f040fUL : 0xfc080effUL);

Add IRQ_MASK #define ?

I'd leave these as constants because there are many of them (basically reserved bit mask for regs where we care or in this case writable bits) and one has to check docs to verify them and also in some cases we combine rage128p and rv100 so hiding them behind a constant would just make code less readable in my opinion. (This would become 3 lines for example with defines you'd have to look up in a different header so it's easier to see this way.)

+        s->regs.gen_int_status &= ~data;

ati_vga_update_irq() needed here too.

Thanks. Indeed I forgot this. With that it works a bit better, mouse now can be moved but only vertically... No idea why, I'll have to check,

Regards,
BALATON Zoltan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]