videoctrl: Add VBL callback.

Allows overriding the method used to post interrupts.
This commit is contained in:
joevt 2023-09-18 16:48:36 -07:00 committed by Maxim Poliakovski
parent cf9237f7d6
commit 5c460c9f3b
2 changed files with 7 additions and 5 deletions

View File

@ -84,8 +84,7 @@ void VideoCtrlBase::start_refresh_task() {
refresh_interval,
[this]() {
// assert VBL interrupt
if (this->int_ctrl)
this->int_ctrl->ack_int(this->irq_id, 1);
this->vbl_cb(1);
this->update_screen();
}
);
@ -97,8 +96,7 @@ void VideoCtrlBase::start_refresh_task() {
refresh_interval + vbl_duration,
[this]() {
// deassert VBL interrupt
if (this->int_ctrl)
this->int_ctrl->ack_int(this->irq_id, 0);
this->vbl_cb(0);
}
);
}

View File

@ -24,12 +24,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef VIDEO_CTRL_H
#define VIDEO_CTRL_H
#include <devices/common/hwinterrupt.h>
#include <devices/video/display.h>
#include <cinttypes>
#include <functional>
class InterruptCtrl;
class WindowEvent;
class VideoCtrlBase {
@ -96,6 +96,10 @@ protected:
// interrupt suff
InterruptCtrl* int_ctrl = nullptr;
uint32_t irq_id = 0;
std::function<void(uint8_t irq_line_state)> vbl_cb = [this](uint8_t irq_line_state) {
if (this->int_ctrl)
this->int_ctrl->ack_int(this->irq_id, irq_line_state);
};
std::function<void(uint8_t *dst_buf, int dst_pitch)> convert_fb_cb;