@@ -341,6 +341,9 @@ static bool video_timing_enabled = false;
341341static bool display_enabled = true;
342342
343343static scanvideo_scanline_repeat_count_fn _scanline_repeat_count_fn ;
344+ #if PICO_SCANVIDEO_SCANLINE_RELEASE_FUNCTION
345+ static scanvideo_scanline_release_fn _scanline_release_fn ;
346+ #endif
344347
345348inline static void list_prepend (full_scanline_buffer_t * * phead , full_scanline_buffer_t * fsb ) {
346349 scanline_assert (fsb );
@@ -466,6 +469,9 @@ inline static void free_local_free_list_irqs_enabled(full_scanline_buffer_t *loc
466469 spin_unlock (shared_state .free_list .lock , save );
467470 // note also this is useful for triggering scanvideo_wait_for_scanline_complete check
468471 __sev ();
472+ #if PICO_SCANVIDEO_SCANLINE_RELEASE_FUNCTION
473+ if (_scanline_release_fn ) _scanline_release_fn ();
474+ #endif
469475 }
470476}
471477
@@ -872,7 +878,6 @@ static void __video_time_critical_func(prepare_for_vblank_scanline_irqs_enabled)
872878
873879 // because IRQs are enabled, we may obviously be pre-empted before or between either of these
874880 release_scanline_irqs_enabled (buffers_to_free_count , & local_free_list );
875-
876881 free_local_free_list_irqs_enabled (local_free_list );
877882
878883 if (signal ) {
@@ -1041,7 +1046,6 @@ extern bool scanvideo_in_vblank() {
10411046 return * (volatile bool * ) & shared_state .scanline .in_vblank ;
10421047}
10431048
1044-
10451049static uint default_scanvideo_scanline_repeat_count_fn (uint32_t scanline_id ) {
10461050 return 1 ;
10471051}
@@ -1254,6 +1258,13 @@ void scanvideo_set_scanline_repeat_fn(scanvideo_scanline_repeat_count_fn fn) {
12541258 _scanline_repeat_count_fn = fn ? fn : default_scanvideo_scanline_repeat_count_fn ;
12551259}
12561260
1261+ #if PICO_SCANVIDEO_SCANLINE_RELEASE_FUNCTION
1262+ void scanvideo_set_scanline_release_fn (scanvideo_scanline_release_fn fn ) {
1263+ _scanline_release_fn = fn ;
1264+ }
1265+ #endif
1266+
1267+
12571268bool scanvideo_setup (const scanvideo_mode_t * mode ) {
12581269 return scanvideo_setup_with_timing (mode , mode -> default_timing );
12591270}
@@ -1377,7 +1388,7 @@ bool scanvideo_setup_with_timing(const scanvideo_mode_t *mode, const scanvideo_t
13771388#if PICO_SCANVIDEO_ENABLE_VIDEO_RECOVERY
13781389 int program_wait_index = -1 ;
13791390#endif
1380- #if PICO_SCANVIDEO_ENABLE_VIDEO_RECOVERY || PARAM_ASSERTIONS_ENABLED (SCANVIDEO_DBI )
1391+ #if PICO_SCANVIDEO_ENABLE_VIDEO_RECOVERY || PARAM_ASSERTIONS_ENABLED (SCANVIDEO_DPI )
13811392 for (int i = 0 ; i < mode -> pio_program -> program -> length ; i ++ ) {
13821393 if (instructions [i ] == PIO_WAIT_IRQ4 ) {
13831394#if PICO_SCANVIDEO_ENABLE_VIDEO_RECOVERY
0 commit comments