software/videomixer: use new csr.h
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 14 Apr 2013 14:33:00 +0000 (16:33 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 14 Apr 2013 14:33:00 +0000 (16:33 +0200)
software/include/hw/flags.h
software/videomixer/isr.c
software/videomixer/main.c

index 759246a69907ea7466064e5e53082a927adbbc97..41c6db23c236b754aea1538a54d19a360fd13e80 100644 (file)
 #define CLKGEN_STATUS_PROGDONE 0x2
 #define CLKGEN_STATUS_LOCKED   0x4
 
+#define DVISAMPLER_TOO_LATE            0x1
+#define DVISAMPLER_TOO_EARLY   0x2
+
+#define DVISAMPLER_DELAY_CAL   0x1
+#define DVISAMPLER_DELAY_RST   0x2
+#define DVISAMPLER_DELAY_INC   0x4
+#define DVISAMPLER_DELAY_DEC   0x8
+
 #endif /* __HW_FLAGS_H */
index 74dbe34202f60dce75974adec4e02f49764c6e11..36c4c7e07268a7caeb3a588a47b4a3af77ee61d3 100644 (file)
@@ -1,5 +1,4 @@
-#include <hw/uart.h>
-#include <interrupt.h>
+#include <hw/csr.h>
 #include <irq.h>
 #include <uart.h>
 
index 397e756e7181d7d5bf95e281713b4ff349f04da7..8aa8e9c180618e941bc1ca99e840884b75956cae 100644 (file)
@@ -3,77 +3,80 @@
 
 #include <irq.h>
 #include <uart.h>
-#include <hw/dvisampler.h>
+#include <hw/csr.h>
+#include <hw/flags.h>
 
 static int d0, d1, d2;
 
 static void print_status(void)
 {
        printf("Ph: %4d %4d %4d // %d%d%d [%d %d %d] // %d // %dx%d // %d\n", d0, d1, d2,
-               CSR_DVISAMPLER0_D0_CHAR_SYNCED,
-               CSR_DVISAMPLER0_D1_CHAR_SYNCED,
-               CSR_DVISAMPLER0_D2_CHAR_SYNCED,
-               CSR_DVISAMPLER0_D0_CTL_POS,
-               CSR_DVISAMPLER0_D1_CTL_POS,
-               CSR_DVISAMPLER0_D2_CTL_POS,
-               CSR_DVISAMPLER0_CHAN_SYNCED,
-               (CSR_DVISAMPLER0_HRESH << 8) | CSR_DVISAMPLER0_HRESL,
-               (CSR_DVISAMPLER0_VRESH << 8) | CSR_DVISAMPLER0_VRESL,
-               (CSR_DVISAMPLER0_DECNT2 << 16) | (CSR_DVISAMPLER0_DECNT1 << 8) |  CSR_DVISAMPLER0_DECNT0);
+               dvisampler0_data0_charsync_char_synced_read(),
+               dvisampler0_data1_charsync_char_synced_read(),
+               dvisampler0_data2_charsync_char_synced_read(),
+               dvisampler0_data0_charsync_ctl_pos_read(),
+               dvisampler0_data1_charsync_ctl_pos_read(),
+               dvisampler0_data2_charsync_ctl_pos_read(),
+               dvisampler0_chansync_channels_synced_read(),
+               dvisampler0_resdetection_hres_read(),
+               dvisampler0_resdetection_vres_read(),
+               dvisampler0_resdetection_de_cycles_read());
 }
 
 static void calibrate_delays(void)
 {
-       CSR_DVISAMPLER0_D0_DELAY_CTL = DVISAMPLER_DELAY_CAL;
-       CSR_DVISAMPLER0_D1_DELAY_CTL = DVISAMPLER_DELAY_CAL;
-       CSR_DVISAMPLER0_D2_DELAY_CTL = DVISAMPLER_DELAY_CAL;
-       while(CSR_DVISAMPLER0_D0_DELAY_BUSY || CSR_DVISAMPLER0_D1_DELAY_BUSY || CSR_DVISAMPLER0_D2_DELAY_BUSY);
-       CSR_DVISAMPLER0_D0_DELAY_CTL = DVISAMPLER_DELAY_RST;
-       CSR_DVISAMPLER0_D1_DELAY_CTL = DVISAMPLER_DELAY_RST;
-       CSR_DVISAMPLER0_D2_DELAY_CTL = DVISAMPLER_DELAY_RST;
-       CSR_DVISAMPLER0_D0_PHASE_RESET = 1;
-       CSR_DVISAMPLER0_D1_PHASE_RESET = 1;
-       CSR_DVISAMPLER0_D2_PHASE_RESET = 1;
+       dvisampler0_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_CAL);
+       dvisampler0_data1_cap_dly_ctl_write(DVISAMPLER_DELAY_CAL);
+       dvisampler0_data2_cap_dly_ctl_write(DVISAMPLER_DELAY_CAL);
+       while(dvisampler0_data0_cap_dly_busy_read()
+               || dvisampler0_data1_cap_dly_busy_read()
+               || dvisampler0_data2_cap_dly_busy_read());
+       dvisampler0_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_RST);
+       dvisampler0_data1_cap_dly_ctl_write(DVISAMPLER_DELAY_RST);
+       dvisampler0_data2_cap_dly_ctl_write(DVISAMPLER_DELAY_RST);
+       dvisampler0_data0_cap_phase_reset_write(1);
+       dvisampler0_data1_cap_phase_reset_write(1);
+       dvisampler0_data2_cap_phase_reset_write(1);
        d0 = d1 = d2 = 0;
        printf("Delays calibrated\n");
 }
 
 static void adjust_phase(void)
 {
-       switch(CSR_DVISAMPLER0_D0_PHASE) {
+       switch(dvisampler0_data0_cap_phase_read()) {
                case DVISAMPLER_TOO_LATE:
-                       CSR_DVISAMPLER0_D0_DELAY_CTL = DVISAMPLER_DELAY_DEC;
+                       dvisampler0_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_DEC);
                        d0--;
-                       CSR_DVISAMPLER0_D0_PHASE_RESET = 1;
+                       dvisampler0_data0_cap_phase_reset_write(1);
                        break;
                case DVISAMPLER_TOO_EARLY:
-                       CSR_DVISAMPLER0_D0_DELAY_CTL = DVISAMPLER_DELAY_INC;
+                       dvisampler0_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_INC);
                        d0++;
-                       CSR_DVISAMPLER0_D0_PHASE_RESET = 1;
+                       dvisampler0_data0_cap_phase_reset_write(1);
                        break;
        }
-       switch(CSR_DVISAMPLER0_D1_PHASE) {
+       switch(dvisampler0_data1_cap_phase_read()) {
                case DVISAMPLER_TOO_LATE:
-                       CSR_DVISAMPLER0_D1_DELAY_CTL = DVISAMPLER_DELAY_DEC;
+                       dvisampler0_data1_cap_dly_ctl_write(DVISAMPLER_DELAY_DEC);
                        d1--;
-                       CSR_DVISAMPLER0_D1_PHASE_RESET = 1;
+                       dvisampler0_data1_cap_phase_reset_write(1);
                        break;
                case DVISAMPLER_TOO_EARLY:
-                       CSR_DVISAMPLER0_D1_DELAY_CTL = DVISAMPLER_DELAY_INC;
+                       dvisampler0_data1_cap_dly_ctl_write(DVISAMPLER_DELAY_INC);
                        d1++;
-                       CSR_DVISAMPLER0_D1_PHASE_RESET = 1;
+                       dvisampler0_data1_cap_phase_reset_write(1);
                        break;
        }
-       switch(CSR_DVISAMPLER0_D2_PHASE) {
+       switch(dvisampler0_data2_cap_phase_read()) {
                case DVISAMPLER_TOO_LATE:
-                       CSR_DVISAMPLER0_D2_DELAY_CTL = DVISAMPLER_DELAY_DEC;
+                       dvisampler0_data2_cap_dly_ctl_write(DVISAMPLER_DELAY_DEC);
                        d2--;
-                       CSR_DVISAMPLER0_D2_PHASE_RESET = 1;
+                       dvisampler0_data2_cap_phase_reset_write(1);
                        break;
                case DVISAMPLER_TOO_EARLY:
-                       CSR_DVISAMPLER0_D2_DELAY_CTL = DVISAMPLER_DELAY_INC;
+                       dvisampler0_data2_cap_dly_ctl_write(DVISAMPLER_DELAY_INC);
                        d2++;
-                       CSR_DVISAMPLER0_D2_PHASE_RESET = 1;
+                       dvisampler0_data2_cap_phase_reset_write(1);
                        break;
        }
 }
@@ -101,7 +104,7 @@ static void vmix(void)
        unsigned int counter;
 
        while(1) {
-               while(!CSR_DVISAMPLER0_PLL_LOCKED);
+               while(!dvisampler0_clocking_locked_read());
                printf("PLL locked\n");
                calibrate_delays();
                if(init_phase())
@@ -111,7 +114,7 @@ static void vmix(void)
                print_status();
 
                counter = 0;
-               while(CSR_DVISAMPLER0_PLL_LOCKED) {
+               while(dvisampler0_clocking_locked_read()) {
                        counter++;
                        if(counter == 2000000) {
                                print_status();