Skip to content
Permalink
Browse files

firmware: add color bar pattern

  • Loading branch information...
enjoy-digital committed Sep 1, 2015
1 parent e025fa0 commit 4a8c4a2176bda7c2366a0b1abc637cc83657f89b
Showing with 60 additions and 5 deletions.
  1. +28 −3 firmware/lm32/pattern.c
  2. +1 −1 firmware/lm32/pattern.h
  3. +30 −0 firmware/lm32/pattern.py
  4. +1 −1 firmware/lm32/processor.c
@@ -16,12 +16,37 @@ unsigned int pattern_framebuffer_base(void) {
return PATTERN_FRAMEBUFFER_BASE;
}

void pattern_fill_framebuffer(void)
void pattern_fill_framebuffer(int h_active, int m_active)
{
int i;
int change_color;
int color;
flush_l2_cache();
color = -1;
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 */
for(i=0; i<h_active*m_active*2/4; i++) {
change_color = i%(h_active/16) == 0;
if(change_color)
color++;
color = color%8;
switch(color) {
case 0:
framebuffer[i] = 0x80ff80ff; break;
case 1:
framebuffer[i] = 0x00e194e1; break;
case 2:
framebuffer[i] = 0xabb200b2; break;
case 3:
framebuffer[i] = 0x2b951595; break;
case 4:
framebuffer[i] = 0xd469e969; break;
case 5:
framebuffer[i] = 0x544cff4c; break;
case 6:
framebuffer[i] = 0xff1d6f1d; break;
case 7:
framebuffer[i] = 0x80108010;
break;
}
}
}
@@ -3,6 +3,6 @@

unsigned int pattern_framebuffer_base(void);

void pattern_fill_framebuffer(void);
void pattern_fill_framebuffer(int h_active, int m_active);

#endif /* __PATTERN_H */
@@ -0,0 +1,30 @@
def rgb2ycbcr(r, g, b):
y = int(0.299*r + 0.587*g + 0.114*b)
cb = int(-0.1687*r - 0.3313*g + 0.5*b + 128)
cr = int(0.5*r - 0.4187*g - 0.0813*b + 128)
return y, cb, cr

color_bars_rgb = [
[255, 255, 255],
[255, 255, 0],
[0, 255, 255],
[0, 255, 0],
[255, 0, 255],
[255, 0, 0],
[0, 0, 255],
[0, 0, 0],
]

color_bars_ycbcr = []
for color_bar_rgb in color_bars_rgb:
r, g, b = color_bar_rgb
y, cb, cr = rgb2ycbcr(r, g, b)
color_bars_ycbcr.append([y, cb, cr])

for color_bar_ycbcr in color_bars_ycbcr:
y, cb, cr = color_bar_ycbcr
value = y
value |= cr << 8
value |= y << 16
value |= cb << 24
print("%08x" %value)
@@ -287,7 +287,7 @@ void processor_start(int mode)
hdmi_in1_disable();
hdmi_in0_clear_framebuffers();
hdmi_in1_clear_framebuffers();
pattern_fill_framebuffer();
pattern_fill_framebuffer(m->h_active, m->v_active);

pll_config_for_clock(m->pixel_clock);
fb_set_mode(m);

0 comments on commit 4a8c4a2

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