1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-27 18:59:43 +02:00

ubb-vga.c: moved line length and timing to variables

- ubb-vga.c (line_pairs, line, frame, tricolor, grid, session): line
  length is now kept in a variable, instead of hard-coding its value
  and the values derived from it
- ubb-vga.c (line_cycles, line, hdelay): the total line duration is now
  kept in a variable, instead of hard-coding it all over the place
This commit is contained in:
Werner Almesberger 2011-04-24 20:01:12 -03:00
parent dae21696b3
commit dab839ab66

View File

@ -203,7 +203,7 @@ static void cleanup(void)
/* ----- Prefetch and delay logic ------------------------------------------ */
#define BURST 32
#define BURST 32 /* bytes */
static inline void prefetch(const uint8_t *prefetch, int words)
@ -229,6 +229,10 @@ static void until(uint16_t cycles)
/* ----- Frame buffer output ----------------------------------------------- */
static int line_pairs = 160; /* set/unset pairs */
static int line_cycles = US(36); /* nominally 31.77 us, but we're too slow */
void setup(void)
{
mlockall(MCL_CURRENT | MCL_FUTURE);
@ -244,21 +248,20 @@ static void line(const uint8_t *line, const uint8_t *fetch)
/* HSYNC */
*tcnt = 0;
*pddatc = HSYNC;
prefetch(fetch, 160);
prefetch(fetch, line_pairs);
until(US(3.77));
*pddats = HSYNC;
/* Front porch */
until(US(3.77+1.79));
while (p != line+320) {
while (p != line+2*line_pairs) {
*pddats = *p++ << 8;
*pddatc = *p++ << 8;
}
/* Back porch */
until(US(31.77));
until(US(36));
until(line_cycles);
}
@ -269,8 +272,7 @@ static void hdelay(int cycles)
*pddatc = HSYNC;
until(US(3.77));
*pddats = HSYNC;
until(US(31.77));
until(US(36));
until(line_cycles);
}
}
@ -290,14 +292,13 @@ static void frame(const uint8_t *f)
until(US(3.77));
*pddats = HSYNC;
prefetch(f, 160);
until(US(31.77));
until(US(36));
prefetch(f, line_pairs);
until(line_cycles);
hdelay(31);
for (p = f; p != f+240*320; p += 320) {
line(p, p+160);
line(p, p+320);
for (p = f; p != f+240*2*line_pairs; p += 2*line_pairs) {
line(p, p+line_pairs);
line(p, p+2*line_pairs);
}
/* Back porch */
@ -322,18 +323,19 @@ static uint32_t pattern(int set, int r, int g, int b)
static void tricolor(uint32_t *f)
{
int pairs = 2*line_pairs*240;
int i;
for (i = 0; i != 320*240/3; i++) {
for (i = 0; i != pairs/3; i++) {
f[i & ~1] = R;
f[i | 1] = G | B;
}
for (; i != 320*240*2/3; i++) {
for (; i != pairs*2/3; i++) {
f[i & ~1] = G;
f[i | 1] = R | B;
}
for (; i != 320*240; i++) {
for (; i != pairs; i++) {
f[i & ~1] = B;
f[i | 1] = R | G;
}
@ -355,9 +357,10 @@ static void grid(uint8_t *f)
int i, x, y;
for (i = 0; i != 8; i++) {
x = i*40+20;
x = i*line_pairs/4+line_pairs/8;
for (y = 0; y != 240; y++) {
f[y*320+x] = f[y*320+x+1] = col[i] >> 8;
uint8_t *p = f+y*2*line_pairs+x;
p[0] = p[1] = col[i] >> 8;
}
}
}
@ -385,7 +388,7 @@ static void grab(uint8_t *f)
static void session(int frames)
{
uint8_t f[320*(240+1)];
uint8_t f[2*line_pairs*(240+1)];
int i;
memset(f, 0, sizeof(f));