From: Sebastien Bourdeauducq Date: Mon, 11 Nov 2013 22:20:21 +0000 (+0100) Subject: videomixer: support resolution change at runtime X-Git-Tag: 24jan2021_ls180~2810 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=69568adb8e50cd25a0f9888259541795dc71c48e;p=litex.git videomixer: support resolution change at runtime --- diff --git a/software/videomixer/Makefile b/software/videomixer/Makefile index 9afe6341..58e3aec7 100644 --- a/software/videomixer/Makefile +++ b/software/videomixer/Makefile @@ -1,7 +1,7 @@ MSCDIR=../.. include $(MSCDIR)/software/common.mak -OBJECTS=isr.o processor.o dvisampler0.o dvisampler1.o edid.o main.o +OBJECTS=isr.o processor.o dvisampler0.o dvisampler1.o edid.o ci.o main.o all: videomixer.bin videomixer.fbi diff --git a/software/videomixer/ci.c b/software/videomixer/ci.c new file mode 100644 index 00000000..57ea2fac --- /dev/null +++ b/software/videomixer/ci.c @@ -0,0 +1,76 @@ +#include + +#include +#include + +#include "dvisampler0.h" +#include "dvisampler1.h" +#include "processor.h" +#include "ci.h" + +static void print_mem_bandwidth(void) +{ + unsigned long long int nr, nw; + unsigned long long int f; + unsigned int rdb, wrb; + + lasmicon_bandwidth_update_write(1); + nr = lasmicon_bandwidth_nreads_read(); + nw = lasmicon_bandwidth_nwrites_read(); + f = identifier_frequency_read(); + rdb = (nr*f >> (24 - 7))/1000000ULL; + wrb = (nw*f >> (24 - 7))/1000000ULL; + printf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); +} + +static void list_video_modes(void) +{ + char mode_descriptors[PROCESSOR_MODE_COUNT*PROCESSOR_MODE_DESCLEN]; + int i; + + processor_list_modes(mode_descriptors); + printf("==== Available video modes ====\n"); + for(i=0;i= '0') && (c <= '9')) { + int m; + + m = c - '0'; + if(m < PROCESSOR_MODE_COUNT) + processor_start(m); + } + switch(c) { + case 'l': + list_video_modes(); + break; + case 'D': + dvisampler0_debug = dvisampler1_debug = 1; + printf("DVI sampler debug is ON\n"); + break; + case 'd': + dvisampler0_debug = dvisampler1_debug = 0; + printf("DVI sampler debug is OFF\n"); + break; + case 'F': + fb_enable_write(1); + printf("framebuffer is ON\n"); + break; + case 'f': + fb_enable_write(0); + printf("framebuffer is OFF\n"); + break; + case 'm': + print_mem_bandwidth(); + break; + } + } +} diff --git a/software/videomixer/ci.h b/software/videomixer/ci.h new file mode 100644 index 00000000..63400feb --- /dev/null +++ b/software/videomixer/ci.h @@ -0,0 +1,6 @@ +#ifndef __CI_H +#define __CI_H + +void ci_service(void); + +#endif \ No newline at end of file diff --git a/software/videomixer/dvisamplerX.c b/software/videomixer/dvisamplerX.c index 636798fc..bdb486ac 100644 --- a/software/videomixer/dvisamplerX.c +++ b/software/videomixer/dvisamplerX.c @@ -9,6 +9,8 @@ #include "dvisamplerX.h" +int dvisamplerX_debug; + #define FRAMEBUFFER_COUNT 4 #define FRAMEBUFFER_MASK (FRAMEBUFFER_COUNT - 1) @@ -39,11 +41,15 @@ void dvisamplerX_isr(void) fb_dmaX_base_write((unsigned int)dvisamplerX_framebuffers[fb_index]); } +static int dvisamplerX_connected; +static int dvisamplerX_locked; + void dvisamplerX_init_video(int hres, int vres) { unsigned int mask; dvisamplerX_clocking_pll_reset_write(1); + dvisamplerX_connected = dvisamplerX_locked = 0; dvisamplerX_dma_ev_pending_write(dvisamplerX_dma_ev_pending_read()); dvisamplerX_dma_ev_enable_write(0x3); @@ -96,7 +102,7 @@ static int wait_idelays(void) || dvisamplerX_data1_cap_dly_busy_read() || dvisamplerX_data2_cap_dly_busy_read()) { if(elapsed(&ev, identifier_frequency_read() >> 6) == 0) { - printf("IDELAY busy timeout\n"); + printf("dvisamplerX: IDELAY busy timeout\n"); return 0; } } @@ -201,10 +207,12 @@ int dvisamplerX_phase_startup(void) while(1) { attempts++; dvisamplerX_calibrate_delays(); - printf("dvisamplerX: delays calibrated\n"); + if(dvisamplerX_debug) + printf("dvisamplerX: delays calibrated\n"); ret = dvisamplerX_init_phase(); if(ret) { - printf("dvisamplerX: phase init OK\n"); + if(dvisamplerX_debug) + printf("dvisamplerX: phase init OK\n"); return 1; } else { printf("dvisamplerX: phase init failed\n"); @@ -225,15 +233,14 @@ static void dvisamplerX_check_overflow(void) } } -static int dvisamplerX_connected; -static int dvisamplerX_locked; static int dvisamplerX_last_event; void dvisamplerX_service(void) { if(dvisamplerX_connected) { if(!dvisamplerX_edid_hpd_notif_read()) { - printf("dvisamplerX: disconnected\n"); + if(dvisamplerX_debug) + printf("dvisamplerX: disconnected\n"); dvisamplerX_connected = 0; dvisamplerX_locked = 0; dvisamplerX_clocking_pll_reset_write(1); @@ -242,24 +249,29 @@ void dvisamplerX_service(void) if(dvisamplerX_clocking_locked_read()) { if(elapsed(&dvisamplerX_last_event, identifier_frequency_read()/2)) { dvisamplerX_adjust_phase(); - dvisamplerX_print_status(); + if(dvisamplerX_debug) + dvisamplerX_print_status(); } } else { - printf("dvisamplerX: lost PLL lock\n"); + if(dvisamplerX_debug) + printf("dvisamplerX: lost PLL lock\n"); dvisamplerX_locked = 0; } } else { if(dvisamplerX_clocking_locked_read()) { - printf("dvisamplerX: PLL locked\n"); + if(dvisamplerX_debug) + printf("dvisamplerX: PLL locked\n"); dvisamplerX_phase_startup(); - dvisamplerX_print_status(); + if(dvisamplerX_debug) + dvisamplerX_print_status(); dvisamplerX_locked = 1; } } } } else { if(dvisamplerX_edid_hpd_notif_read()) { - printf("dvisamplerX: connected\n"); + if(dvisamplerX_debug) + printf("dvisamplerX: connected\n"); dvisamplerX_connected = 1; dvisamplerX_clocking_pll_reset_write(0); } diff --git a/software/videomixer/dvisamplerX.h b/software/videomixer/dvisamplerX.h index 300722a6..258305bd 100644 --- a/software/videomixer/dvisamplerX.h +++ b/software/videomixer/dvisamplerX.h @@ -1,6 +1,8 @@ #ifndef __DVISAMPLERX_H #define __DVISAMPLERX_H +extern int dvisamplerX_debug; + void dvisamplerX_isr(void); void dvisamplerX_init_video(int hres, int vres); void dvisamplerX_print_status(void); diff --git a/software/videomixer/main.c b/software/videomixer/main.c index a4359edd..3909d76a 100644 --- a/software/videomixer/main.c +++ b/software/videomixer/main.c @@ -8,6 +8,7 @@ #include #include +#include "ci.h" #include "processor.h" #ifdef POTS_BASE @@ -83,50 +84,6 @@ static void ui_service(void) #endif -static void fb_service(void) -{ - int c; - - if(readchar_nonblock()) { - c = readchar(); - if(c == '1') { - fb_enable_write(1); - printf("Framebuffer is ON\n"); - } else if(c == '0') { - fb_enable_write(0); - printf("Framebuffer is OFF\n"); - } - } -} - -static void membw_service(void) -{ - static int last_event; - unsigned long long int nr, nw; - unsigned long long int f; - unsigned int rdb, wrb; - - if(elapsed(&last_event, identifier_frequency_read())) { - lasmicon_bandwidth_update_write(1); - nr = lasmicon_bandwidth_nreads_read(); - nw = lasmicon_bandwidth_nwrites_read(); - f = identifier_frequency_read(); - rdb = (nr*f >> (24 - 7))/1000000ULL; - wrb = (nw*f >> (24 - 7))/1000000ULL; - printf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); - } -} - -static void list_video_modes(void) -{ - char mode_descriptors[PROCESSOR_MODE_COUNT*PROCESSOR_MODE_DESCLEN]; - int i; - - processor_list_modes(mode_descriptors); - for(i=0;ih_active, mode->v_active); + fb_get_clock_md(mode->pixel_clock, &clock_m, &clock_d); fb_fi_hres_write(mode->h_active); @@ -147,8 +149,6 @@ static void fb_set_mode(const struct video_timing *mode) printf("waiting for LOCKED..."); while(!(fb_driver_clocking_status_read() & CLKGEN_STATUS_LOCKED)); printf("ok\n"); - - printf("Video mode set to %dx%d\n", mode->h_active, mode->v_active); } static void edid_set_mode(const struct video_timing *mode)