From 5a049642ea99e354626b8b011dc7f1d22bf890ab Mon Sep 17 00:00:00 2001 From: joevt Date: Tue, 27 Feb 2024 05:22:56 -0800 Subject: [PATCH] atirage: Add VBL callback. --- devices/video/atirage.cpp | 29 +++++++++++++++++++++++++++++ devices/video/atirage.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/devices/video/atirage.cpp b/devices/video/atirage.cpp index fdf1e60..52afd6c 100644 --- a/devices/video/atirage.cpp +++ b/devices/video/atirage.cpp @@ -801,6 +801,35 @@ void ATIRage::get_cursor_position(int& x, int& y) { y = extract_bits(this->regs[ATI_CUR_HORZ_VERT_POSN], ATI_CUR_VERT_POSN, ATI_CUR_VERT_POSN_size); } +int ATIRage::device_postinit() +{ + this->vbl_cb = [this](uint8_t irq_line_state) { + insert_bits(this->regs[ATI_CRTC_INT_CNTL], irq_line_state, ATI_CRTC_VBLANK, 1); + if (irq_line_state) { + set_bit(this->regs[ATI_CRTC_INT_CNTL], ATI_CRTC_VBLANK_INT); + set_bit(this->regs[ATI_CRTC_INT_CNTL], ATI_CRTC_VLINE_INT); +#if 1 +#else + set_bit(this->regs[ATI_CRTC_GEN_CNTL], ATI_CRTC_VSYNC_INT); +#endif + } + + bool do_interrupt = + bit_set(this->regs[ATI_CRTC_INT_CNTL], ATI_CRTC_VBLANK_INT_EN) || + bit_set(this->regs[ATI_CRTC_INT_CNTL], ATI_CRTC_VLINE_INT_EN) || +#if 1 +#else + bit_set(this->regs[ATI_CRTC_GEN_CNTL], ATI_CRTC_VSYNC_INT_EN) || +#endif + 0; + + if (do_interrupt) { + this->pci_interrupt(irq_line_state); + } + }; + return 0; +} + static const PropMap AtiRage_Properties = { {"gfxmem_size", new IntProperty( 2, vector({2, 4, 6}))}, diff --git a/devices/video/atirage.h b/devices/video/atirage.h index 7362877..1af2155 100644 --- a/devices/video/atirage.h +++ b/devices/video/atirage.h @@ -55,6 +55,9 @@ public: return std::unique_ptr(new ATIRage(ATI_RAGE_PRO_DEV_ID)); } + // HWComponent methods + int device_postinit(); + // MMIODevice methods uint32_t read(uint32_t rgn_start, uint32_t offset, int size); void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size);