Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP : Crop #444

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 33 additions & 1 deletion firmware/ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "tofe_eeprom.h"
#include "uptime.h"
#include "version.h"

#include "crop.h"
#include "ci.h"

int status_enabled;
Expand Down Expand Up @@ -97,18 +97,37 @@ static void help_heartbeat(void)
wputs(" heartbeat <on/off> - Turn on/off heartbeat feature");
}

static void help_crop(void)
{
wputs("change crop status (alias: 'cr')");
wputs(" crop <on/off> - Turn on/off crop feature");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra new line here needs to be removed

static void heartbeat_enable(void)
{
hb_status(true);
wprintf("Heartbeat enabled\n");
}

static void crop_enable(void)
{
crop_status(true);
wprintf("crop enable\n");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra new line

static void heartbeat_disable(void)
{
hb_status(false);
wprintf("Heartbeat disabled\n");
}

static void crop_disable(void)
{

crop_status(false);
wprintf("crop disabled\n");
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra new line

#ifdef CSR_HDMI_OUT0_BASE
static void help_output0(void)
{
Expand Down Expand Up @@ -191,6 +210,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("");
Expand All @@ -202,6 +222,9 @@ static void ci_help(void)
wputs("");
help_hdp_toggle();
wputs("");
help_crop();
wputs("");

#ifdef CSR_HDMI_OUT0_BASE
help_output0();
wputs("");
Expand Down Expand Up @@ -1134,6 +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();
}
#ifdef CSR_HDMI_OUT0_BASE
else if((strcmp(token, "output0") == 0) || (strcmp(token, "o0") == 0)) {
token = get_token(&str);
Expand Down
68 changes: 68 additions & 0 deletions firmware/crop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

#include <generated/csr.h>
#include <generated/mem.h>
#include <hw/flags.h>
#include <system.h>
#include <time.h>

#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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra new line

void crop_status(bool val)
{
crop_stat = val;
}

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);
}
}

void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top)
{
int addr1,addr2,addr3,addr4, i, j,k;
unsigned int color;
unsigned int *framebuffer = fb_ptrdiff_to_main_ram(fb_offset);

addr1 = 0 + (processor_h_active/2)*(processor_v_active-top);
addr2 = 0;
addr3 = 0 + (processor_h_active/2)*top + (processor_h_active/2) - top;
addr4 = 0 + (processor_h_active/2)*top;

for (i=0; i<processor_h_active/2; i++)
{
for (j=0; j<processor_v_active - top; j++)
{
framebuffer[addr1+i+(processor_h_active/2)*j] = YCBCR422_BLACK;
}
for (k=0; k<top; k++)
{
framebuffer[addr2+i+(processor_h_active/2)*k] = YCBCR422_BLACK;
}
} /*Bottom clipping & top clipping*/

for (i=0; i<top; i++)
{
for (j=0; j<processor_v_active - top; j++)
{
framebuffer[addr3+i+(processor_h_active/2)*j] = YCBCR422_BLACK;
}
for (k=0; k<processor_v_active-top; k++)
{
framebuffer[addr4+i+(processor_h_active/2)*k] = YCBCR422_BLACK;
}

} /*right clipping & left clipping*/
}
10 changes: 10 additions & 0 deletions firmware/crop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __CROP_H
#define __CROP_H

#include <stdbool.h>
#include "framebuffer.h"

void crop_status(bool val);
void crop_service(fb_ptrdiff_t fb_offset,int top) ;
void crop_fill(bool color_v, fb_ptrdiff_t fb_offset,int top);

10 changes: 9 additions & 1 deletion firmware/processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "mmcm.h"
#include "processor.h"
#include "heartbeat.h"

#include "crop.h"
/*
----------------->>> Time ----------->>>

Expand Down Expand Up @@ -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);
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);
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());
Expand Down Expand Up @@ -744,6 +750,8 @@ void processor_update(void)
encoder_reader_base_write(pattern_framebuffer_base());
#endif

crop_service(pattern_framebuffer_base(),40);

#ifdef CSR_HDMI_IN0_BASE
hb_service(hdmi_in0_framebuffer_base(hdmi_in0_fb_index));
#endif
Expand Down