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

Added heartbeat functionality #266

Merged
merged 13 commits into from Jul 11, 2016
View
@@ -20,6 +20,7 @@ OBJECTS=isr.o \
hdmi_in1.o \
hdmi_out0.o \
hdmi_out1.o \
heartbeat.o \
pattern.o \
edid.o \
pll.o \
View
@@ -13,6 +13,7 @@
#include "hdmi_in0.h"
#include "hdmi_in1.h"
#include "processor.h"
#include "heartbeat.h"
#include "pll.h"
#include "ci.h"
#include "encoder.h"
@@ -54,6 +55,12 @@ static void help_status(void)
puts(" status <on/off> - repeatedly print status message");
}
static void help_heartbeat(void)
{
puts("change heartbeat status (alias: 'h')");
puts(" heartbeat <on/off> - Turn on/off heartbeat feature");
}
#ifdef CSR_HDMI_OUT0_BASE
static void help_output0(void)
{
@@ -113,6 +120,8 @@ static void help(void)
puts("");
help_video_mode();
puts("");
help_heartbeat();
puts("");
help_hdp_toggle();
puts("");
#ifdef CSR_HDMI_OUT0_BASE
@@ -230,6 +239,20 @@ static void status_service(void)
}
}
static void heartbeat_enable(void)
{
hb_status(true);
printf("Heartbeat enabled\r\n");
}
static void heartbeat_disable(void)
{
hb_status(false);
printf("Heartbeat disabled\r\n");
}
static void video_matrix_list(void)
{
printf("Video sources:\r\n");
@@ -536,6 +559,10 @@ void ci_service(void)
#endif
else if(strcmp(token, "debug") == 0)
help_debug();
else if(strcmp(token, "heartbeat") == 0)
help_heartbeat();
else
help();
puts("");
@@ -596,6 +623,15 @@ void ci_service(void)
else
video_mode_set(atoi(token));
}
else if((strcmp(token, "heartbeat") == 0) || (strcmp(token, "h") == 0)) {
token = get_token(&str);
if((strcmp(token, "on") == 0) )
heartbeat_enable();
else if((strcmp(token, "off") == 0) )
heartbeat_disable();
else
help_heartbeat();
}
else if(strcmp(token, "hdp_toggle") == 0) {
token = get_token(&str);
hdp_toggle(atoi(token));
@@ -751,7 +787,8 @@ void ci_service(void)
printf("%s port has no EDID capabilities\r\n", token);
} else
help_debug();
} else {
}
else {
if(status_enabled)
status_disable();
}
View
@@ -0,0 +1,82 @@
#include <generated/csr.h>
#include <generated/mem.h>
#include <hw/flags.h>
#include <system.h>
#include <time.h>
#include "heartbeat.h"
#include "processor.h"
#include "hdmi_in0.h"
#include "hdmi_in1.h"
#include "pattern.h"
static bool heartbeat_status = false;
#define HEARTBEAT_FREQUENCY 1 // In Hertz
#define FILL_RATE 120 // In Hertz, double the standard frame rate
void hb_status(bool val)
{
heartbeat_status = val;
}
void hb_service(int sink)
{
static int last_event;
static int counter;
static bool color_v;
if (heartbeat_status==1) {
if(elapsed(&last_event, identifier_frequency_read()/FILL_RATE)) {
counter = counter+1;
hb_fill(color_v, sink);
if(counter > FILL_RATE/(HEARTBEAT_FREQUENCY*2)) {
color_v = !color_v;
counter = 0;
}
}
}
}
void hb_fill(bool color_v, int sink)
{
int addr, i, j;
unsigned int color;
volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base());

This comment has been minimized.

@mithro

mithro Jul 4, 2016

Member

@shenki What does the volatile here do? Is it saying the pointer can change out under the compiler - or that the thing that the pointer is pointing too can change out under the compiler?

@mithro

mithro Jul 4, 2016

Member

@shenki What does the volatile here do? Is it saying the pointer can change out under the compiler - or that the thing that the pointer is pointing too can change out under the compiler?

This comment has been minimized.

@ssk1328

ssk1328 Jul 4, 2016

Contributor

volatile not explicitly required here, but will be continued to use for consistency. volatile is used when we want our memory accesses for that variable to be ordered.

@ssk1328

ssk1328 Jul 4, 2016

Contributor

volatile not explicitly required here, but will be continued to use for consistency. volatile is used when we want our memory accesses for that variable to be ordered.

#ifdef CSR_HDMI_OUT0_BASE
if (sink == VIDEO_OUT_HDMI_OUT0) {
framebuffer = (unsigned int *)(MAIN_RAM_BASE + hdmi_out0_fi_base0_read());
}
#endif
#ifdef CSR_HDMI_OUT1_BASE
if (sink == VIDEO_OUT_HDMI_OUT1) {
framebuffer = (unsigned int *)(MAIN_RAM_BASE + hdmi_out1_fi_base0_read());
}
#endif
#ifdef ENCODER_BASE
if (sink == VIDEO_OUT_ENCODER) {
framebuffer = (unsigned int *)(MAIN_RAM_BASE + encoder_reader_base_read());
}
#endif
/*
8x8 pixel square at right bottom corner
8 pixel = 4 memory locations in horizoantal
8 pixel = 8 memory locations in vertical
Toggles between BLUE and RED
*/
if (color_v == 0)
color = YCBCR422_BLUE;
else
color = YCBCR422_RED;
addr = 0 + (processor_h_active/2)*(processor_v_active-8) + (processor_h_active/2) - 4;
for (i=0; i<4; i++){
for (j=0; j<8; j++){
framebuffer[addr+i+(processor_h_active/2)*j] = color;
}
}
}
View
@@ -0,0 +1,10 @@
#ifndef __HEARTBEAT_H
#define __HEARTBEAT_H
#include <stdbool.h>
void hb_status(bool val);
void hb_service(int sink) ;
void hb_fill(bool color_v, int sink);
#endif /* __HEARTBEAT_H */
View
@@ -14,6 +14,7 @@
#include "edid.h"
#include "pll.h"
#include "processor.h"
#include "heartbeat.h"
/*
----------------->>> Time ----------->>>
@@ -300,6 +301,7 @@ static const struct video_timing video_modes[PROCESSOR_MODE_COUNT] = {
};
void processor_list_modes(char *mode_descriptors)
{
int i;
@@ -517,6 +519,8 @@ void processor_update(void)
#endif
if(processor_hdmi_out0_source == VIDEO_IN_PATTERN)
hdmi_out0_fi_base0_write(pattern_framebuffer_base());
hb_service(VIDEO_OUT_HDMI_OUT0);
#endif
#ifdef CSR_HDMI_OUT1_BASE
@@ -531,6 +535,8 @@ void processor_update(void)
#endif
if(processor_hdmi_out1_source == VIDEO_IN_PATTERN)
hdmi_out1_fi_base0_write(pattern_framebuffer_base());
hb_service(VIDEO_OUT_HDMI_OUT1);
#endif
#ifdef ENCODER_BASE
@@ -547,6 +553,8 @@ void processor_update(void)
#endif
if(processor_encoder_source == VIDEO_IN_PATTERN)
encoder_reader_base_write(pattern_framebuffer_base());
hb_service(VIDEO_OUT_ENCODER);
#endif
}
@@ -558,8 +566,10 @@ void processor_service(void)
#ifdef CSR_HDMI_IN1_BASE
hdmi_in1_service();
#endif
processor_update();
#ifdef ENCODER_BASE
encoder_service();
#endif
}
ProTip! Use n and p to navigate between commits in a pull request.