Skip to content
Permalink
Browse files

firmware: initialize video pattern

  • Loading branch information...
enjoy-digital committed Sep 1, 2015
1 parent 4a158df commit e88854d801ef3ce005de1f603d0d8fe67d2d2f4a
@@ -2,7 +2,7 @@
MSCDIR=../../build/misoc
include $(MSCDIR)/software/common.mak

OBJECTS=isr.o processor.o hdmi_in0.o hdmi_in1.o edid.o pll.o ci.o config.o encoder.o i2c.o main.o
OBJECTS=isr.o processor.o hdmi_in0.o hdmi_in1.o pattern.o edid.o pll.o ci.o config.o encoder.o i2c.o main.o

all: firmware.bin

@@ -153,18 +153,18 @@ static void status_service(void)

printf("hdmi_out0: ");
if(hdmi_out0_fi_enable_read())
printf("%dx%d from hdmi_in%d", processor_h_active,
processor_v_active,
processor_hdmi_out0_source);
printf("%dx%d from %s", processor_h_active,
processor_v_active,
processor_get_source_name(processor_hdmi_out0_source));
else
printf("off");
printf("\n");

printf("hdmi_out1: ");
if(hdmi_out1_fi_enable_read())
printf("%dx%d from hdmi_in%d", processor_h_active,
processor_v_active,
processor_hdmi_out1_source);
printf("%dx%d from %s", processor_h_active,
processor_v_active,
processor_get_source_name(processor_hdmi_out1_source));
else
printf("off");
printf("\n");
@@ -197,6 +197,8 @@ static void video_matrix_list(void)
printf(" %s\n", HDMI_OUT0_DESCRIPTION);
printf("hdmi_in1: %s\n", HDMI_IN1_MNEMONIC);
printf(" %s\n", HDMI_OUT1_DESCRIPTION);
printf("pattern:\n");
printf(" Video pattern\n");
puts(" ");
printf("Video sinks:\n");
printf("hdmi_out0: %s\n", HDMI_OUT0_MNEMONIC);
@@ -212,10 +214,10 @@ static void video_matrix_list(void)

static void video_matrix_connect(int source, int sink)
{
if(source >= 0 && source <= VIDEO_IN_HDMI_IN1)
if(source >= 0 && source <= VIDEO_IN_PATTERN)
{
if(sink >= 0 && sink <= VIDEO_OUT_HDMI_OUT1) {
printf("Connecting hdmi_in%d to hdmi_out%d\n", source, sink);
printf("Connecting %s to hdmi_out%d\n", processor_get_source_name(source), sink);
if(sink == VIDEO_OUT_HDMI_OUT0)
processor_set_hdmi_out0_source(source);
else if(sink == VIDEO_OUT_HDMI_OUT1)
@@ -224,7 +226,7 @@ static void video_matrix_connect(int source, int sink)
}
#ifdef ENCODER_BASE
else if(sink == VIDEO_OUT_ENCODER) {
printf("Connecting hdmi_in%d to encoder\n", source);
printf("Connecting %s to encoder\n", processor_get_source_name(source));
processor_set_encoder_source(source);
processor_update();
}
@@ -453,6 +455,8 @@ void ci_service(void)
source = VIDEO_IN_HDMI_IN0;
else if(strcmp(token, "hdmi_in1") == 0)
source = VIDEO_IN_HDMI_IN1;
else if(strcmp(token, "pattern") == 0)
source = VIDEO_IN_PATTERN;
/* get video sink */
token = get_token(&str);
sink = -1;
@@ -7,6 +7,7 @@
#include <time.h>
#include <system.h>
#include <generated/csr.h>
#include <generated/mem.h>
#include <hw/flags.h>

#include "hdmi_in0.h"
@@ -18,7 +19,7 @@ int hdmi_in0_fb_index;
#define FRAMEBUFFER_MASK (FRAMEBUFFER_COUNT - 1)

#define HDMI_IN0_FRAMEBUFFERS_BASE 0x00000000
#define HDMI_IN0_FRAMEBUFFERS_SIZE 1280*720*4
#define HDMI_IN0_FRAMEBUFFERS_SIZE 1280*720*2

unsigned int hdmi_in0_framebuffer_base(char n) {
return HDMI_IN0_FRAMEBUFFERS_BASE + n*HDMI_IN0_FRAMEBUFFERS_SIZE;
@@ -133,7 +134,12 @@ void hdmi_in0_disable(void)

void hdmi_in0_clear_framebuffers(void)
{
int i;
flush_l2_cache();
volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + HDMI_IN0_FRAMEBUFFERS_BASE);
for(i=0; i<HDMI_IN0_FRAMEBUFFERS_SIZE/4; i++) {
framebuffer[i] = 0x80108010; /* black in YCbCr 4:2:2*/
}
}

static int hdmi_in0_d0, hdmi_in0_d1, hdmi_in0_d2;
@@ -7,6 +7,7 @@
#include <time.h>
#include <system.h>
#include <generated/csr.h>
#include <generated/mem.h>
#include <hw/flags.h>

#include "hdmi_in1.h"
@@ -18,7 +19,7 @@ int hdmi_in1_fb_index;
#define FRAMEBUFFER_MASK (FRAMEBUFFER_COUNT - 1)

#define HDMI_IN1_FRAMEBUFFERS_BASE 0x01000000
#define HDMI_IN1_FRAMEBUFFERS_SIZE 1280*720*4
#define HDMI_IN1_FRAMEBUFFERS_SIZE 1280*720*2

unsigned int hdmi_in1_framebuffer_base(char n) {
return HDMI_IN1_FRAMEBUFFERS_BASE + n*HDMI_IN1_FRAMEBUFFERS_SIZE;
@@ -134,7 +135,12 @@ void hdmi_in1_disable(void)

void hdmi_in1_clear_framebuffers(void)
{
int i;
flush_l2_cache();
volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + HDMI_IN1_FRAMEBUFFERS_BASE);
for(i=0; i<HDMI_IN1_FRAMEBUFFERS_SIZE/4; i++) {
framebuffer[i] = 0x80108010; /* black in YCbCr 4:2:2*/
}
}

static int hdmi_in1_d0, hdmi_in1_d1, hdmi_in1_d2;
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>

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

#include "pattern.h"

#define PATTERN_FRAMEBUFFER_BASE 0x02000000
#define PATTERN_FRAMEBUFFER_SIZE 1280*720*2

unsigned int pattern_framebuffer_base(void) {
return PATTERN_FRAMEBUFFER_BASE;
}

void pattern_fill_framebuffer(void)
{
int i;
flush_l2_cache();
volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + PATTERN_FRAMEBUFFER_BASE);
for(i=0; i<PATTERN_FRAMEBUFFER_SIZE/4; i++) {
framebuffer[i] = 0xf0296e29; /* blue in YCbCr 4:2:2 */
}
flush_l2_cache();
}
@@ -0,0 +1,8 @@
#ifndef __PATTERN_H
#define __PATTERN_H

unsigned int pattern_framebuffer_base(void);

void pattern_fill_framebuffer(void);

#endif /* __PATTERN_H */
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <generated/csr.h>
#include <generated/mem.h>
@@ -8,6 +9,7 @@

#include "hdmi_in0.h"
#include "hdmi_in1.h"
#include "pattern.h"
#include "edid.h"
#include "pll.h"
#include "processor.h"
@@ -285,6 +287,7 @@ void processor_start(int mode)
hdmi_in1_disable();
hdmi_in0_clear_framebuffers();
hdmi_in1_clear_framebuffers();
pattern_fill_framebuffer();

pll_config_for_clock(m->pixel_clock);
fb_set_mode(m);
@@ -311,23 +314,32 @@ void processor_set_encoder_source(int source) {
processor_encoder_source = source;
}

char * processor_get_source_name(int source) {
memset(processor_buffer, 0, 16);
if(source == VIDEO_IN_PATTERN)
sprintf(processor_buffer, "pattern");
else
sprintf(processor_buffer, "hdmi_in%d", source);
return processor_buffer;
}

void processor_update(void)
{
/* hdmi_out0 */
if(processor_hdmi_out0_source == VIDEO_IN_HDMI_IN0) {
if(processor_hdmi_out0_source == VIDEO_IN_HDMI_IN0)
hdmi_out0_fi_base0_write(hdmi_in0_framebuffer_base(hdmi_in0_fb_index));
}
else if(processor_hdmi_out0_source == VIDEO_IN_HDMI_IN1) {
else if(processor_hdmi_out0_source == VIDEO_IN_HDMI_IN1)
hdmi_out0_fi_base0_write(hdmi_in1_framebuffer_base(hdmi_in1_fb_index));
}
else if(processor_hdmi_out0_source == VIDEO_IN_PATTERN)
hdmi_out0_fi_base0_write(pattern_framebuffer_base());

/* hdmi_out1 */
if(processor_hdmi_out1_source == VIDEO_IN_HDMI_IN0) {
if(processor_hdmi_out1_source == VIDEO_IN_HDMI_IN0)
hdmi_out1_fi_base0_write(hdmi_in0_framebuffer_base(hdmi_in0_fb_index));
}
else if(processor_hdmi_out1_source == VIDEO_IN_HDMI_IN1) {
else if(processor_hdmi_out1_source == VIDEO_IN_HDMI_IN1)
hdmi_out1_fi_base0_write(hdmi_in1_framebuffer_base(hdmi_in1_fb_index));
}
else if(processor_hdmi_out1_source == VIDEO_IN_PATTERN)
hdmi_out1_fi_base0_write(pattern_framebuffer_base());

#ifdef ENCODER_BASE
/* encoder */
@@ -337,6 +349,8 @@ void processor_update(void)
else if(processor_encoder_source == VIDEO_IN_HDMI_IN1) {
encoder_reader_dma_base_write((hdmi_in1_framebuffer_base(hdmi_in1_fb_index)));
}
else if(processor_encoder_source == VIDEO_IN_PATTERN)
encoder_reader_dma_base_write(pattern_framebuffer_base());
#endif
}

@@ -6,7 +6,8 @@

enum {
VIDEO_IN_HDMI_IN0=0,
VIDEO_IN_HDMI_IN1
VIDEO_IN_HDMI_IN1,
VIDEO_IN_PATTERN
};

enum {
@@ -21,13 +22,15 @@ int processor_v_active;
int processor_hdmi_out0_source;
int processor_hdmi_out1_source;
int processor_encoder_source;
char processor_buffer[16];

void processor_list_modes(char *mode_descriptors);
void processor_start(int mode);
void processor_set_hdmi_out0_source(int source);
void processor_set_hdmi_out1_source(int source);
void processor_set_encoder_source(int source);
char * processor_get_source_name(int source);
void processor_update(void);
void processor_service(void);

#endif /* __VIDEOMODE_H */
#endif /* __PROCESSOR_H */

0 comments on commit e88854d

Please sign in to comment.
You can’t perform that action at this time.