Skip to content

Commit

Permalink
firmware: add color bar pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Sep 1, 2015
1 parent e025fa0 commit 4a8c4a2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
31 changes: 28 additions & 3 deletions firmware/lm32/pattern.c
Expand Up @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion firmware/lm32/pattern.h
Expand Up @@ -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 */
30 changes: 30 additions & 0 deletions firmware/lm32/pattern.py
@@ -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)
2 changes: 1 addition & 1 deletion firmware/lm32/processor.c
Expand Up @@ -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);
Expand Down

0 comments on commit 4a8c4a2

Please sign in to comment.