software/videomixer: send to framebuffer
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 6 May 2013 07:56:49 +0000 (09:56 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 6 May 2013 07:56:49 +0000 (09:56 +0200)
software/videomixer/main.c

index 7ae7e4f67a86850b27a8b350e80cdc6462a14ca3..118e1291dbbd006b53dc74b2d7ca92d41c74a458 100644 (file)
@@ -3,10 +3,12 @@
 
 #include <irq.h>
 #include <uart.h>
+#include <console.h>
 #include <hw/csr.h>
 #include <hw/flags.h>
 
 static int d0, d1, d2;
+static unsigned int framebuffer[640*480] __attribute__((aligned(16)));
 
 static void print_status(void)
 {
@@ -22,6 +24,17 @@ static void print_status(void)
                dvisampler0_resdetection_vres_read());
 }
 
+static void capture_fb(void)
+{
+       dvisampler0_dma_base_write((unsigned int)framebuffer);
+       dvisampler0_dma_length_write(sizeof(framebuffer));
+       dvisampler0_dma_shoot_write(1);
+
+       printf("waiting for DMA...");
+       while(dvisampler0_dma_busy_read());
+       printf("done\n");
+}
+
 static void calibrate_delays(void)
 {
        dvisampler0_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_CAL);
@@ -119,6 +132,8 @@ static void vmix(void)
                                adjust_phase();
                                counter = 0;
                        }
+                       if(readchar_nonblock() && (readchar() == 'c'))
+                               capture_fb();
                }
                printf("PLL unlocked\n");
        }
@@ -132,6 +147,8 @@ int main(void)
        
        puts("Minimal video mixer software built "__DATE__" "__TIME__"\n");
        
+       fb_base_write((unsigned int)framebuffer);
+       fb_enable_write(1);
        vmix();
        
        return 0;