altos: Add vblank signal to vga driver
authorKeith Packard <keithp@keithp.com>
Thu, 2 Nov 2017 16:10:54 +0000 (09:10 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 2 Nov 2017 16:10:54 +0000 (09:10 -0700)
Allow applications to sync with vblank.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_vga.c
src/drivers/ao_vga.h

index 909e31098004a25879949d69992da20b7b7525ea..59658caf9c56b9249620de05522be6d1e8704f94 100644 (file)
@@ -91,6 +91,8 @@ static uint32_t       *scanline;
                         (en << STM_DMA_CCR_EN))
 
 
+uint8_t        ao_vga_vblank;
+
 void stm_tim2_isr(void)
 {
        int16_t line = stm_tim3.cnt;
@@ -111,6 +113,10 @@ void stm_tim2_isr(void)
                if (((line - VBLANK_END) & 1))
                        scanline += AO_VGA_STRIDE;
        } else {
+               if (line == VBLANK_START) {
+                       ao_vga_vblank = 1;
+                       ao_wakeup(&ao_vga_vblank);
+               }
                scanline = ao_vga_fb;
        }
        stm_tim2.sr = 0;
index 7d9d6b39110954f84b368d8bfb323cfed1fc1e11..92cdb76c96a652002bc35c69b0bf079041275344 100644 (file)
@@ -36,4 +36,6 @@ extern uint32_t       ao_vga_fb[AO_VGA_STRIDE * AO_VGA_HEIGHT];
 
 extern const struct ao_bitmap ao_vga_bitmap;
 
+extern uint8_t ao_vga_vblank;
+
 #endif /* _AO_VGA_H_ */