Skip to content

Commit 0b606fd

Browse files
committed
minor scanvideo fix when recovering from overruns
1 parent 5200ce5 commit 0b606fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/rp2_common/pico_scanvideo_dpi/scanvideo.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,9 @@ void __video_most_time_critical_func(prepare_for_active_scanline_irqs_enabled)()
735735
#if PICO_SCANVIDEO_ENABLE_VIDEO_RECOVERY
736736
if (!pio_sm_is_tx_fifo_empty(video_pio, PICO_SCANVIDEO_SCANLINE_SM)) {
737737
pio_sm_clear_fifos(video_pio, PICO_SCANVIDEO_SCANLINE_SM);
738+
// if there wsa something in the FIFO, then there's a good chance there's a possibility that there was something
739+
// in the OSR still, too
740+
pio_sm_exec(video_pio, PICO_SCANVIDEO_SCANLINE_SM, pio_encode_out(pio_null, 32));
738741
}
739742
if (video_pio->sm[PICO_SCANVIDEO_SCANLINE_SM].instr != PIO_WAIT_IRQ4) {
740743
// hmm the problem here is we don't know if we should wait or not, because that is purely based on timing..
@@ -744,7 +747,12 @@ void __video_most_time_critical_func(prepare_for_active_scanline_irqs_enabled)()
744747
// - id irq already posted, and we don't wait: GOOD
745748
pio_sm_exec(video_pio, PICO_SCANVIDEO_SCANLINE_SM, pio_encode_wait_irq(1, false, 4));
746749
if (pio_sm_is_exec_stalled(video_pio, PICO_SCANVIDEO_SCANLINE_SM)) {
747-
pio_sm_exec(video_pio, PICO_SCANVIDEO_SCANLINE_SM, pio_encode_jmp(shared_state.scanline_program_wait_index));
750+
// special case check that we are have actually presumably seen the IRQ, but are blocked on the OUT after it, in
751+
// which case we don't want to block again
752+
if (video_pio->sm[PICO_SCANVIDEO_SCANLINE_SM].addr != shared_state.scanline_program_wait_index + 1) {
753+
pio_sm_exec(video_pio, PICO_SCANVIDEO_SCANLINE_SM,
754+
pio_encode_jmp(shared_state.scanline_program_wait_index));
755+
}
748756
} else {
749757
pio_sm_exec(video_pio, PICO_SCANVIDEO_SCANLINE_SM,
750758
pio_encode_jmp(shared_state.scanline_program_wait_index + 1));

0 commit comments

Comments
 (0)