From 55923babab45ee03a9fd07bb3291cbb38b659eff Mon Sep 17 00:00:00 2001 From: Nancy Date: Thu, 31 May 2018 10:56:26 +0530 Subject: [PATCH 1/5] Update getting-started.md Addition in Test loading the gateware $make gateware-load $make firmware-load BIOS>serialboot $make firmware-connect --- getting-started.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/getting-started.md b/getting-started.md index a7a943ee..00a87bbf 100644 --- a/getting-started.md +++ b/getting-started.md @@ -312,6 +312,56 @@ to switch to serial mode and then back to the jtag mode like this; ``` hdmi2usb-mode-switch --mode=serial hdmi2usb-mode-switch --mode=jtag +``` +Load the firmware +``` +make firmware-load + +``` +If you see no output, press ‘Enter’ a few times. You can then kick off the firmware loading process again: +``` +BIOS> serialboot +Booting from serial... +Press Q or ESC to abort boot completely. +sL5DdSMmkekro +[FLTERM] Received firmware download request from the device. +[FLTERM] Uploading kernel (86484 bytes)... +[FLTERM] Upload complete (10.6KB/s). +[FLTERM] Booting the device. +[FLTERM] Done. +Executing booted program at 0x40000000 +HDMI2USB firmware booting... + +opsis_eeprom: Init...finished. + +hardware version info +=============================================== + DNA: 0137be87d98719f0 + MAC: d8:80:39:57:04:94 + +gateware version info +=============================================== + platform: opsis + target: video + revision: 5f07955beabcf9cebe0e896c4e51242075566cb6 + +firmware version info +=============================================== + platform: opsis + target: video + git commit: 5f07955beabcf9cebe0e896c4e51242075566cb6 + git branch: master + git describe: v0.0.4-203-g5f07955 + git status: + -- + ?? ../../../../HDMI2USB-mode-switch/ + -- + + built: May 31 2018 10:43:25 + uptime: 00:00:00 +----------------------------------------------- +MDIO mode: 1000Mbps / link: down + ``` ## 5) Testing From 455f7a8fd633b444019155f41e3b50f38df0d7e1 Mon Sep 17 00:00:00 2001 From: Nancy-Chauhan Date: Sun, 10 Jun 2018 22:27:49 +0530 Subject: [PATCH 2/5] crop --- firmware/Makefile | 1 + firmware/ci.c | 42 +++++++++++++++++++++++- firmware/crop.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ firmware/crop.h | 11 +++++++ firmware/processor.c | 12 ++++++- 5 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 firmware/crop.c create mode 100644 firmware/crop.h diff --git a/firmware/Makefile b/firmware/Makefile index 1076a6f8..9902e95e 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -45,6 +45,7 @@ OBJECTS=\ tofe_eeprom.o \ uptime.o \ version.o \ + crop.o \ $(FIRMBUILD_DIRECTORY)/version_data.o \ $(FIRMBUILD_DIRECTORY)/hdmi_in1.o \ boot-helper-$(CPU).o diff --git a/firmware/ci.c b/firmware/ci.c index fa6277c2..9ffd1c7a 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -49,7 +49,7 @@ #include "tofe_eeprom.h" #include "uptime.h" #include "version.h" - +#include "crop.h" #include "ci.h" int status_enabled; @@ -97,18 +97,41 @@ static void help_heartbeat(void) wputs(" heartbeat - Turn on/off heartbeat feature"); } +static void help_crop(void) +{ + wputs("change crop status (alias: 'cr')"); + wputs(" crop - Turn on/off crop feature"); +} + + static void heartbeat_enable(void) { hb_status(true); wprintf("Heartbeat enabled\n"); } +static void crop_enable(void) +{ + crop_status(true); + wprintf("crop enable\n"); +} + + static void heartbeat_disable(void) { hb_status(false); wprintf("Heartbeat disabled\n"); } + +static void crop_disable(void) +{ + + crop_status(false); + wprintf("crop disabled\n"); +} + + #ifdef CSR_HDMI_OUT0_BASE static void help_output0(void) { @@ -191,6 +214,7 @@ static void ci_help(void) wputs("mdio_status - show mdio status"); #endif wputs("pattern (p) - select next pattern"); + wputs("version - show firmware version"); wputs(""); help_status(); wputs(""); @@ -202,6 +226,9 @@ static void ci_help(void) wputs(""); help_hdp_toggle(); wputs(""); + help_crop(); + wputs(""); + #ifdef CSR_HDMI_OUT0_BASE help_output0(); wputs(""); @@ -1134,6 +1161,19 @@ void ci_service(void) token = get_token(&str); hdp_toggle(atoi(token)); } + + + else if((strcmp(token, "crop") == 0) || (strcmp(token, "cr") == 0)) { + token = get_token(&str); + if((strcmp(token, "on") == 0) ) + + crop_enable(); + else if((strcmp(token, "off") == 0) ) + crop_disable(); + else + help_crop(); + } + #ifdef CSR_HDMI_OUT0_BASE else if((strcmp(token, "output0") == 0) || (strcmp(token, "o0") == 0)) { token = get_token(&str); diff --git a/firmware/crop.c b/firmware/crop.c new file mode 100644 index 00000000..1c12f10e --- /dev/null +++ b/firmware/crop.c @@ -0,0 +1,76 @@ + +#include +#include +#include +#include +#include + +#include "hdmi_in0.h" +#include "hdmi_in1.h" +#include "crop.h" +#include "processor.h" +#include "pattern.h" +#include "stdio_wrap.h" + +static bool crop_stat = false; + + + +void crop_status(bool val) +{ + crop_stat = val; +} + +void crop_service(fb_ptrdiff_t fb_offset,int top,int bottom,int left,int right) +{ + static int last_event; + static int counter; + static bool color_v; + + if (crop_stat==1) { + crop_fill(color_v, fb_offset,top,bottom,left,right); + + } +} + +void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top,int bottom,int left,int right) +{ + int addr, i, j; + unsigned int color; + unsigned int *framebuffer = fb_ptrdiff_to_main_ram(fb_offset); + +//Bottom clipping + + addr = 0 + (processor_h_active/2)*(processor_v_active-bottom);// + (processor_h_active/2) - right; + for (i=0; i +#include "framebuffer.h" + +void crop_status(bool val); +void crop_service(fb_ptrdiff_t fb_offset,int top,int bottom,int left,int right) ; +void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top,int bottom,int left,int right); + +#endif /* __HEARTBEAT_H */ diff --git a/firmware/processor.c b/firmware/processor.c index 171fbbd7..f4465647 100644 --- a/firmware/processor.c +++ b/firmware/processor.c @@ -33,7 +33,7 @@ #include "mmcm.h" #include "processor.h" #include "heartbeat.h" - +#include "crop.h" /* ----------------->>> Time ----------->>> @@ -703,11 +703,17 @@ void processor_update(void) /* hdmi_out0 */ #ifdef CSR_HDMI_IN0_BASE if(processor_hdmi_out0_source == VIDEO_IN_HDMI_IN0) + { + crop_service(hdmi_in0_framebuffer_base(hdmi_in0_fb_index),40,40,40,40); hdmi_out0_core_initiator_base_write(hdmi_in0_framebuffer_base(hdmi_in0_fb_index)); + } #endif #ifdef CSR_HDMI_IN1_BASE if(processor_hdmi_out0_source == VIDEO_IN_HDMI_IN1) + { + crop_service(hdmi_in1_framebuffer_base(hdmi_in1_fb_index),40,40,40,40); hdmi_out0_core_initiator_base_write(hdmi_in1_framebuffer_base(hdmi_in1_fb_index)); + } #endif if(processor_hdmi_out0_source == VIDEO_IN_PATTERN) hdmi_out0_core_initiator_base_write(pattern_framebuffer_base()); @@ -744,6 +750,10 @@ void processor_update(void) encoder_reader_base_write(pattern_framebuffer_base()); #endif +// crop_service(hdmi_in0_framebuffer_base(hdmi_in0_fb_index),40,40,40,40); +// crop_service(hdmi_in1_framebuffer_base(hdmi_in1_fb_index),40,40,40,40); + crop_service(pattern_framebuffer_base(),40,40,40,40); + #ifdef CSR_HDMI_IN0_BASE hb_service(hdmi_in0_framebuffer_base(hdmi_in0_fb_index)); #endif From 5cc65e4e1bdd712062910e0aa10888bfc097a9f7 Mon Sep 17 00:00:00 2001 From: Nancy Date: Wed, 13 Jun 2018 10:36:47 +0530 Subject: [PATCH 3/5] Update getting-started.md --- getting-started.md | 50 ---------------------------------------------- 1 file changed, 50 deletions(-) diff --git a/getting-started.md b/getting-started.md index 00a87bbf..a7a943ee 100644 --- a/getting-started.md +++ b/getting-started.md @@ -312,56 +312,6 @@ to switch to serial mode and then back to the jtag mode like this; ``` hdmi2usb-mode-switch --mode=serial hdmi2usb-mode-switch --mode=jtag -``` -Load the firmware -``` -make firmware-load - -``` -If you see no output, press ‘Enter’ a few times. You can then kick off the firmware loading process again: -``` -BIOS> serialboot -Booting from serial... -Press Q or ESC to abort boot completely. -sL5DdSMmkekro -[FLTERM] Received firmware download request from the device. -[FLTERM] Uploading kernel (86484 bytes)... -[FLTERM] Upload complete (10.6KB/s). -[FLTERM] Booting the device. -[FLTERM] Done. -Executing booted program at 0x40000000 -HDMI2USB firmware booting... - -opsis_eeprom: Init...finished. - -hardware version info -=============================================== - DNA: 0137be87d98719f0 - MAC: d8:80:39:57:04:94 - -gateware version info -=============================================== - platform: opsis - target: video - revision: 5f07955beabcf9cebe0e896c4e51242075566cb6 - -firmware version info -=============================================== - platform: opsis - target: video - git commit: 5f07955beabcf9cebe0e896c4e51242075566cb6 - git branch: master - git describe: v0.0.4-203-g5f07955 - git status: - -- - ?? ../../../../HDMI2USB-mode-switch/ - -- - - built: May 31 2018 10:43:25 - uptime: 00:00:00 ------------------------------------------------ -MDIO mode: 1000Mbps / link: down - ``` ## 5) Testing From 8ed0cc2c648c1000110511e2e336c20231a139a7 Mon Sep 17 00:00:00 2001 From: Nancy-Chauhan Date: Tue, 19 Jun 2018 00:09:13 +0530 Subject: [PATCH 4/5] crop --- firmware/ci.c | 247 +++++++++++++++++++++---------------------- firmware/crop.c | 69 ++++++------ firmware/crop.h | 5 +- firmware/processor.c | 8 +- 4 files changed, 156 insertions(+), 173 deletions(-) diff --git a/firmware/ci.c b/firmware/ci.c index 9ffd1c7a..5a739a76 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -99,11 +99,10 @@ static void help_heartbeat(void) static void help_crop(void) { - wputs("change crop status (alias: 'cr')"); - wputs(" crop - Turn on/off crop feature"); + wputs("change crop status (alias: 'cr')"); + wputs(" crop - Turn on/off crop feature"); } - static void heartbeat_enable(void) { hb_status(true); @@ -116,22 +115,18 @@ static void crop_enable(void) wprintf("crop enable\n"); } - static void heartbeat_disable(void) { hb_status(false); wprintf("Heartbeat disabled\n"); } - static void crop_disable(void) { - - crop_status(false); - wprintf("crop disabled\n"); + crop_status(false); + wprintf("crop disabled\n"); } - #ifdef CSR_HDMI_OUT0_BASE static void help_output0(void) { @@ -226,8 +221,8 @@ static void ci_help(void) wputs(""); help_hdp_toggle(); wputs(""); - help_crop(); - wputs(""); + help_crop(); + wputs(""); #ifdef CSR_HDMI_OUT0_BASE help_output0(); @@ -381,23 +376,23 @@ static void status_short_print(void) unsigned int underflows; #ifdef CSR_HDMI_IN0_BASE wprintf( - "in0: %dx%d", - hdmi_in0_resdetection_hres_read(), - hdmi_in0_resdetection_vres_read()); + "in0: %dx%d", + hdmi_in0_resdetection_hres_read(), + hdmi_in0_resdetection_vres_read()); #ifdef CSR_HDMI_IN0_FREQ_BASE wprintf("@" REFRESH_RATE_PRINTF "MHz, ", - REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); #endif #endif #ifdef CSR_HDMI_IN1_BASE wprintf( - "in1: %dx%d", - hdmi_in1_resdetection_hres_read(), - hdmi_in1_resdetection_vres_read()); + "in1: %dx%d", + hdmi_in1_resdetection_hres_read(), + hdmi_in1_resdetection_vres_read()); #ifdef CSR_HDMI_IN1_FREQ_BASE wprintf("@" REFRESH_RATE_PRINTF "MHz, ", - REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); #endif #endif @@ -408,12 +403,12 @@ static void status_short_print(void) hdmi_out0_core_underflow_update_write(1); underflows = hdmi_out0_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d), ", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out0_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d), ", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out0_source), + underflows); hdmi_out0_core_underflow_enable_write(0); hdmi_out0_core_underflow_enable_write(1); } else @@ -427,12 +422,12 @@ static void status_short_print(void) hdmi_out1_core_underflow_update_write(1); underflows = hdmi_out1_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d) ", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out1_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d) ", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out1_source), + underflows); hdmi_out1_core_underflow_enable_write(0); hdmi_out1_core_underflow_enable_write(1); } else @@ -442,9 +437,9 @@ static void status_short_print(void) wprintf("\nstatus2: "); wprintf("EDID: "); wprintf("%dx%d@" REFRESH_RATE_PRINTF "Hz/", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh)); + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh)); if (processor_secondary_mode == EDID_SECONDARY_MODE_OFF) { wprintf("off, "); @@ -459,12 +454,12 @@ static void status_short_print(void) wprintf("enc: "); if(encoder_enabled) { wprintf( - "%dx%d@%dfps %s (q:%d), ", - processor_h_active, - processor_v_active, - encoder_fps, - processor_get_source_name(processor_encoder_source), - encoder_quality); + "%dx%d@%dfps %s (q:%d), ", + processor_h_active, + processor_v_active, + encoder_fps, + processor_get_source_name(processor_encoder_source), + encoder_quality); } else wprintf("off, "); #endif @@ -480,12 +475,12 @@ static void status_print(void) unsigned int underflows; #ifdef CSR_HDMI_IN0_BASE wprintf( - "input0: %dx%d", - hdmi_in0_resdetection_hres_read(), - hdmi_in0_resdetection_vres_read()); + "input0: %dx%d", + hdmi_in0_resdetection_hres_read(), + hdmi_in0_resdetection_vres_read()); #ifdef CSR_HDMI_IN0_FREQ_BASE wprintf(" (@" REFRESH_RATE_PRINTF " MHz)", - REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); if(hdmi_in0_status()) { wprintf(" (capturing)"); } else { @@ -497,12 +492,12 @@ static void status_print(void) #ifdef CSR_HDMI_IN1_BASE wprintf( - "input1: %dx%d", - hdmi_in1_resdetection_hres_read(), - hdmi_in1_resdetection_vres_read()); + "input1: %dx%d", + hdmi_in1_resdetection_hres_read(), + hdmi_in1_resdetection_vres_read()); #ifdef CSR_HDMI_IN1_FREQ_BASE wprintf(" (@" REFRESH_RATE_PRINTF " MHz)", - REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); #endif if(hdmi_in1_status()) { wprintf(" (capturing)"); @@ -519,12 +514,12 @@ static void status_print(void) hdmi_out0_core_underflow_update_write(1); underflows = hdmi_out0_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out0_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out0_source), + underflows); hdmi_out0_core_underflow_enable_write(0); hdmi_out0_core_underflow_enable_write(1); } else @@ -539,12 +534,12 @@ static void status_print(void) hdmi_out1_core_underflow_update_write(1); underflows = hdmi_out1_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out1_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out1_source), + underflows); hdmi_out1_core_underflow_enable_write(0); hdmi_out1_core_underflow_enable_write(1); } else @@ -554,9 +549,9 @@ static void status_print(void) wprintf("EDID primary mode: "); wprintf("%dx%d@" REFRESH_RATE_PRINTF "Hz", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh)); + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh)); wputchar('\n'); wprintf("EDID secondary mode: "); @@ -574,12 +569,12 @@ static void status_print(void) wprintf("encoder: "); if(encoder_enabled) { wprintf( - "%dx%d @ %dfps from %s (q: %d)", - processor_h_active, - processor_v_active, - encoder_fps, - processor_get_source_name(processor_encoder_source), - encoder_quality); + "%dx%d @ %dfps from %s (q: %d)", + processor_h_active, + processor_v_active, + encoder_fps, + processor_get_source_name(processor_encoder_source), + encoder_quality); } else wprintf("off"); wputchar('\n'); @@ -601,7 +596,7 @@ static void status_service(void) wputchar('\n'); } if(status_short_enabled) { - status_short_print(); + status_short_print(); } } } @@ -690,13 +685,13 @@ static void video_matrix_connect(int source, int sink) #ifdef CSR_HDMI_OUT0_BASE processor_set_hdmi_out0_source(source); #else - wprintf("hdmi_out0 is missing.\n"); + wprintf("hdmi_out0 is missing.\n"); #endif else if(sink == VIDEO_OUT_HDMI_OUT1) #ifdef CSR_HDMI_OUT1_BASE processor_set_hdmi_out1_source(source); #else - wprintf("hdmi_out1 is missing.\n"); + wprintf("hdmi_out1 is missing.\n"); #endif processor_update(); } @@ -823,38 +818,38 @@ static void video_mode_custom(char* str) } /* - -------------------> Time -------------> + -------------------> Time -------------> - +-------------------+ + +-------------------+ Video | Blanking | Video - | | - ----(a)--------->|<-------(b)------->| - | | - | +-------+ | - | | Sync | | - | | | | - |<-(c)->|<-(d)->| | - | | | | - ----(1)--------->| | | | - ----(2)----------------->| | | - ----(3)------------------------->| | - ----(4)----------------------------->| - | | | | - -----------------\ /-------- - | | - \-------\ /---/ - | | - \-------/ - - (a) - h_active - (b) - h_blanking - (c) - h_sync_offset - (d) - h_sync_width - (1) - HDisp / width - (2) - HSyncStart - (3) - HSyncEnd - (4) - HTotal - */ + | | + ----(a)--------->|<-------(b)------->| + | | + | +-------+ | + | | Sync | | + | | | | + |<-(c)->|<-(d)->| | + | | | | + ----(1)--------->| | | | + ----(2)----------------->| | | + ----(3)------------------------->| | + ----(4)----------------------------->| + | | | | + -----------------\ /-------- + | | + \-------\ /---/ + | | + \-------/ + + (a) - h_active + (b) - h_blanking + (c) - h_sync_offset + (d) - h_sync_width + (1) - HDisp / width + (2) - HSyncStart + (3) - HSyncEnd + (4) - HTotal + */ if (hTotal <= hSyncEnd || hSyncEnd <= hSyncStart || hSyncStart <= width || vTotal <= vSyncEnd || @@ -1013,20 +1008,20 @@ static unsigned int log2(unsigned int v) static void debug_ddr(void) { /* - unsigned long long int nr, nw; - unsigned long long int f; - unsigned int rdb, wrb; - unsigned int burstbits; - - sdram_controller_bandwidth_update_write(1); - nr = sdram_controller_bandwidth_nreads_read(); - nw = sdram_controller_bandwidth_nwrites_read(); - f = SYSTEM_CLOCK_FREQUENCY; - burstbits = (2*DFII_NPHASES) << DFII_PIX_DATA_SIZE; - rdb = (nr*f >> (24 - log2(burstbits)))/1000000ULL; - wrb = (nw*f >> (24 - log2(burstbits)))/1000000ULL; - wprintf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); - */ + unsigned long long int nr, nw; + unsigned long long int f; + unsigned int rdb, wrb; + unsigned int burstbits; + + sdram_controller_bandwidth_update_write(1); + nr = sdram_controller_bandwidth_nreads_read(); + nw = sdram_controller_bandwidth_nwrites_read(); + f = SYSTEM_CLOCK_FREQUENCY; + burstbits = (2*DFII_NPHASES) << DFII_PIX_DATA_SIZE; + rdb = (nr*f >> (24 - log2(burstbits)))/1000000ULL; + wrb = (nw*f >> (24 - log2(burstbits)))/1000000ULL; + wprintf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); + */ } #endif @@ -1162,17 +1157,15 @@ void ci_service(void) hdp_toggle(atoi(token)); } - - else if((strcmp(token, "crop") == 0) || (strcmp(token, "cr") == 0)) { - token = get_token(&str); - if((strcmp(token, "on") == 0) ) - - crop_enable(); - else if((strcmp(token, "off") == 0) ) - crop_disable(); - else - help_crop(); - } + else if((strcmp(token, "crop") == 0) || (strcmp(token, "cr") == 0)) { + token = get_token(&str); + if((strcmp(token, "on") == 0) ) + crop_enable(); + else if((strcmp(token, "off") == 0) ) + crop_disable(); + else + help_crop(); + } #ifdef CSR_HDMI_OUT0_BASE else if((strcmp(token, "output0") == 0) || (strcmp(token, "o0") == 0)) { diff --git a/firmware/crop.c b/firmware/crop.c index 1c12f10e..09113947 100644 --- a/firmware/crop.c +++ b/firmware/crop.c @@ -14,63 +14,56 @@ static bool crop_stat = false; - - void crop_status(bool val) { crop_stat = val; } -void crop_service(fb_ptrdiff_t fb_offset,int top,int bottom,int left,int right) +void crop_service(fb_ptrdiff_t fb_offset,int top) { static int last_event; static int counter; static bool color_v; if (crop_stat==1) { - crop_fill(color_v, fb_offset,top,bottom,left,right); - + crop_fill(color_v, fb_offset,top); } } -void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top,int bottom,int left,int right) +void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top) { - int addr, i, j; + int addr1,addr2,addr3,addr4, i, j,k; unsigned int color; unsigned int *framebuffer = fb_ptrdiff_to_main_ram(fb_offset); -//Bottom clipping - - addr = 0 + (processor_h_active/2)*(processor_v_active-bottom);// + (processor_h_active/2) - right; - for (i=0; i Date: Tue, 19 Jun 2018 00:30:26 +0530 Subject: [PATCH 5/5] crop --- firmware/ci.c | 243 ++++++++++++++++++++++++------------------------ firmware/crop.c | 1 - 2 files changed, 121 insertions(+), 123 deletions(-) diff --git a/firmware/ci.c b/firmware/ci.c index 5a739a76..d3a0ed6d 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -99,8 +99,8 @@ static void help_heartbeat(void) static void help_crop(void) { - wputs("change crop status (alias: 'cr')"); - wputs(" crop - Turn on/off crop feature"); + wputs("change crop status (alias: 'cr')"); + wputs(" crop - Turn on/off crop feature"); } static void heartbeat_enable(void) @@ -123,8 +123,9 @@ static void heartbeat_disable(void) static void crop_disable(void) { - crop_status(false); - wprintf("crop disabled\n"); + + crop_status(false); + wprintf("crop disabled\n"); } #ifdef CSR_HDMI_OUT0_BASE @@ -221,8 +222,8 @@ static void ci_help(void) wputs(""); help_hdp_toggle(); wputs(""); - help_crop(); - wputs(""); + help_crop(); + wputs(""); #ifdef CSR_HDMI_OUT0_BASE help_output0(); @@ -376,23 +377,23 @@ static void status_short_print(void) unsigned int underflows; #ifdef CSR_HDMI_IN0_BASE wprintf( - "in0: %dx%d", - hdmi_in0_resdetection_hres_read(), - hdmi_in0_resdetection_vres_read()); + "in0: %dx%d", + hdmi_in0_resdetection_hres_read(), + hdmi_in0_resdetection_vres_read()); #ifdef CSR_HDMI_IN0_FREQ_BASE wprintf("@" REFRESH_RATE_PRINTF "MHz, ", - REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); #endif #endif #ifdef CSR_HDMI_IN1_BASE wprintf( - "in1: %dx%d", - hdmi_in1_resdetection_hres_read(), - hdmi_in1_resdetection_vres_read()); + "in1: %dx%d", + hdmi_in1_resdetection_hres_read(), + hdmi_in1_resdetection_vres_read()); #ifdef CSR_HDMI_IN1_FREQ_BASE wprintf("@" REFRESH_RATE_PRINTF "MHz, ", - REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); #endif #endif @@ -403,12 +404,12 @@ static void status_short_print(void) hdmi_out0_core_underflow_update_write(1); underflows = hdmi_out0_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d), ", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out0_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d), ", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out0_source), + underflows); hdmi_out0_core_underflow_enable_write(0); hdmi_out0_core_underflow_enable_write(1); } else @@ -422,12 +423,12 @@ static void status_short_print(void) hdmi_out1_core_underflow_update_write(1); underflows = hdmi_out1_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d) ", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out1_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz %s (uf:%d) ", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out1_source), + underflows); hdmi_out1_core_underflow_enable_write(0); hdmi_out1_core_underflow_enable_write(1); } else @@ -437,9 +438,9 @@ static void status_short_print(void) wprintf("\nstatus2: "); wprintf("EDID: "); wprintf("%dx%d@" REFRESH_RATE_PRINTF "Hz/", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh)); + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh)); if (processor_secondary_mode == EDID_SECONDARY_MODE_OFF) { wprintf("off, "); @@ -454,12 +455,12 @@ static void status_short_print(void) wprintf("enc: "); if(encoder_enabled) { wprintf( - "%dx%d@%dfps %s (q:%d), ", - processor_h_active, - processor_v_active, - encoder_fps, - processor_get_source_name(processor_encoder_source), - encoder_quality); + "%dx%d@%dfps %s (q:%d), ", + processor_h_active, + processor_v_active, + encoder_fps, + processor_get_source_name(processor_encoder_source), + encoder_quality); } else wprintf("off, "); #endif @@ -475,12 +476,12 @@ static void status_print(void) unsigned int underflows; #ifdef CSR_HDMI_IN0_BASE wprintf( - "input0: %dx%d", - hdmi_in0_resdetection_hres_read(), - hdmi_in0_resdetection_vres_read()); + "input0: %dx%d", + hdmi_in0_resdetection_hres_read(), + hdmi_in0_resdetection_vres_read()); #ifdef CSR_HDMI_IN0_FREQ_BASE wprintf(" (@" REFRESH_RATE_PRINTF " MHz)", - REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in0_freq_value_read() / 10000)); if(hdmi_in0_status()) { wprintf(" (capturing)"); } else { @@ -492,12 +493,12 @@ static void status_print(void) #ifdef CSR_HDMI_IN1_BASE wprintf( - "input1: %dx%d", - hdmi_in1_resdetection_hres_read(), - hdmi_in1_resdetection_vres_read()); + "input1: %dx%d", + hdmi_in1_resdetection_hres_read(), + hdmi_in1_resdetection_vres_read()); #ifdef CSR_HDMI_IN1_FREQ_BASE wprintf(" (@" REFRESH_RATE_PRINTF " MHz)", - REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); + REFRESH_RATE_PRINTF_ARGS(hdmi_in1_freq_value_read() / 10000)); #endif if(hdmi_in1_status()) { wprintf(" (capturing)"); @@ -514,12 +515,12 @@ static void status_print(void) hdmi_out0_core_underflow_update_write(1); underflows = hdmi_out0_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out0_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out0_source), + underflows); hdmi_out0_core_underflow_enable_write(0); hdmi_out0_core_underflow_enable_write(1); } else @@ -534,12 +535,12 @@ static void status_print(void) hdmi_out1_core_underflow_update_write(1); underflows = hdmi_out1_core_underflow_counter_read(); wprintf( - "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh), - processor_get_source_name(processor_hdmi_out1_source), - underflows); + "%dx%d@" REFRESH_RATE_PRINTF "Hz from %s (underflows: %d)", + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh), + processor_get_source_name(processor_hdmi_out1_source), + underflows); hdmi_out1_core_underflow_enable_write(0); hdmi_out1_core_underflow_enable_write(1); } else @@ -549,9 +550,9 @@ static void status_print(void) wprintf("EDID primary mode: "); wprintf("%dx%d@" REFRESH_RATE_PRINTF "Hz", - processor_h_active, - processor_v_active, - REFRESH_RATE_PRINTF_ARGS(processor_refresh)); + processor_h_active, + processor_v_active, + REFRESH_RATE_PRINTF_ARGS(processor_refresh)); wputchar('\n'); wprintf("EDID secondary mode: "); @@ -569,12 +570,12 @@ static void status_print(void) wprintf("encoder: "); if(encoder_enabled) { wprintf( - "%dx%d @ %dfps from %s (q: %d)", - processor_h_active, - processor_v_active, - encoder_fps, - processor_get_source_name(processor_encoder_source), - encoder_quality); + "%dx%d @ %dfps from %s (q: %d)", + processor_h_active, + processor_v_active, + encoder_fps, + processor_get_source_name(processor_encoder_source), + encoder_quality); } else wprintf("off"); wputchar('\n'); @@ -596,7 +597,7 @@ static void status_service(void) wputchar('\n'); } if(status_short_enabled) { - status_short_print(); + status_short_print(); } } } @@ -685,13 +686,13 @@ static void video_matrix_connect(int source, int sink) #ifdef CSR_HDMI_OUT0_BASE processor_set_hdmi_out0_source(source); #else - wprintf("hdmi_out0 is missing.\n"); + wprintf("hdmi_out0 is missing.\n"); #endif else if(sink == VIDEO_OUT_HDMI_OUT1) #ifdef CSR_HDMI_OUT1_BASE processor_set_hdmi_out1_source(source); #else - wprintf("hdmi_out1 is missing.\n"); + wprintf("hdmi_out1 is missing.\n"); #endif processor_update(); } @@ -818,38 +819,38 @@ static void video_mode_custom(char* str) } /* - -------------------> Time -------------> + -------------------> Time -------------> - +-------------------+ + +-------------------+ Video | Blanking | Video - | | - ----(a)--------->|<-------(b)------->| - | | - | +-------+ | - | | Sync | | - | | | | - |<-(c)->|<-(d)->| | - | | | | - ----(1)--------->| | | | - ----(2)----------------->| | | - ----(3)------------------------->| | - ----(4)----------------------------->| - | | | | - -----------------\ /-------- - | | - \-------\ /---/ - | | - \-------/ - - (a) - h_active - (b) - h_blanking - (c) - h_sync_offset - (d) - h_sync_width - (1) - HDisp / width - (2) - HSyncStart - (3) - HSyncEnd - (4) - HTotal - */ + | | + ----(a)--------->|<-------(b)------->| + | | + | +-------+ | + | | Sync | | + | | | | + |<-(c)->|<-(d)->| | + | | | | + ----(1)--------->| | | | + ----(2)----------------->| | | + ----(3)------------------------->| | + ----(4)----------------------------->| + | | | | + -----------------\ /-------- + | | + \-------\ /---/ + | | + \-------/ + + (a) - h_active + (b) - h_blanking + (c) - h_sync_offset + (d) - h_sync_width + (1) - HDisp / width + (2) - HSyncStart + (3) - HSyncEnd + (4) - HTotal + */ if (hTotal <= hSyncEnd || hSyncEnd <= hSyncStart || hSyncStart <= width || vTotal <= vSyncEnd || @@ -1008,20 +1009,20 @@ static unsigned int log2(unsigned int v) static void debug_ddr(void) { /* - unsigned long long int nr, nw; - unsigned long long int f; - unsigned int rdb, wrb; - unsigned int burstbits; - - sdram_controller_bandwidth_update_write(1); - nr = sdram_controller_bandwidth_nreads_read(); - nw = sdram_controller_bandwidth_nwrites_read(); - f = SYSTEM_CLOCK_FREQUENCY; - burstbits = (2*DFII_NPHASES) << DFII_PIX_DATA_SIZE; - rdb = (nr*f >> (24 - log2(burstbits)))/1000000ULL; - wrb = (nw*f >> (24 - log2(burstbits)))/1000000ULL; - wprintf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); - */ + unsigned long long int nr, nw; + unsigned long long int f; + unsigned int rdb, wrb; + unsigned int burstbits; + + sdram_controller_bandwidth_update_write(1); + nr = sdram_controller_bandwidth_nreads_read(); + nw = sdram_controller_bandwidth_nwrites_read(); + f = SYSTEM_CLOCK_FREQUENCY; + burstbits = (2*DFII_NPHASES) << DFII_PIX_DATA_SIZE; + rdb = (nr*f >> (24 - log2(burstbits)))/1000000ULL; + wrb = (nw*f >> (24 - log2(burstbits)))/1000000ULL; + wprintf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); + */ } #endif @@ -1156,17 +1157,15 @@ void ci_service(void) token = get_token(&str); hdp_toggle(atoi(token)); } - - else if((strcmp(token, "crop") == 0) || (strcmp(token, "cr") == 0)) { - token = get_token(&str); - if((strcmp(token, "on") == 0) ) - crop_enable(); - else if((strcmp(token, "off") == 0) ) - crop_disable(); - else - help_crop(); - } - + else if((strcmp(token, "crop") == 0) || (strcmp(token, "cr") == 0)) { + token = get_token(&str); + if((strcmp(token, "on") == 0) ) + crop_enable(); + else if((strcmp(token, "off") == 0) ) + crop_disable(); + else + help_crop(); + } #ifdef CSR_HDMI_OUT0_BASE else if((strcmp(token, "output0") == 0) || (strcmp(token, "o0") == 0)) { token = get_token(&str); diff --git a/firmware/crop.c b/firmware/crop.c index 09113947..2d5f0967 100644 --- a/firmware/crop.c +++ b/firmware/crop.c @@ -41,7 +41,6 @@ void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top) addr3 = 0 + (processor_h_active/2)*top + (processor_h_active/2) - top; addr4 = 0 + (processor_h_active/2)*top; - for (i=0; i