1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-30 19:12:48 +02:00

ubb-vga2.c: code cleanup and some fine-tuning

This commit is contained in:
Werner Almesberger 2011-04-27 18:28:09 -03:00
parent a759723ed1
commit 9a455c55fc

View File

@ -267,12 +267,12 @@ static void line(const uint32_t *line, volatile const uint32_t *prefetch)
*msc_strpcl = 1 << 3; /* reset the MSC */ *msc_strpcl = 1 << 3; /* reset the MSC */
// while (*msc_stat & (1 << 15)); // while (*msc_stat & (1 << 15));
/* HSYNC */
*msc_txfifo = *p++; *msc_txfifo = *p++;
// *msc_txfifo = *p++;
until(US(0.79)); until(US(0.79));
/* HSYNC */
*pddatc = HSYNC; *pddatc = HSYNC;
*msc_strpcl = 2; /* start MMC clock output */ *msc_strpcl = 2; /* start MMC clock output */
@ -284,18 +284,28 @@ static void line(const uint32_t *line, volatile const uint32_t *prefetch)
*msc_strpcl = 4; /* START_OP */ *msc_strpcl = 4; /* START_OP */
#if 1 until(US(0.79+3.77-0.3));
// *msc_txfifo = *p++;
#else
for (p = line; p != line+1; p++)
for (p = line; p != line+1; p++)
*msc_txfifo = *p;//0xf0f0f0f0;//*p;
#endif
until(US(0.79+3.77-0.2));
/* /*
* Without the -0.2, the XEN-1510 only detects the signal in only about * Adjustment value tests with the XEN-1510:
* 20% of all cases. *
* Adjustment Tries Good Jam FIFO jitter
* Quick load
* -0.0 10 3 7 0 n
* -0.1 10 5 5 0 n
* -0.2 10 6 4 0 n
* -0.3 10 7 3 0 n
* 10 5 5 0 y
* -0.4 10 1 0 9 n
* 10 5 0 5 n repeat
* 10 5 0 5 y
* -0.5 10 3 0 7 n
* 10 7 0 3 y
* -1.0 5 0 5 0
*
* Good = image is stable
* Jam = does not detect the signal properly, loss of HSYNC, artefacts,
* or no image at all
* FIFO jitter = some lines get shifted by a "digital" amount
*/ */
/* Front porch */ /* Front porch */
@ -303,31 +313,31 @@ static void line(const uint32_t *line, volatile const uint32_t *prefetch)
*pdfuns = CMD; *pdfuns = CMD;
*pddats = HSYNC; *pddats = HSYNC;
*pdfunc = CMD; *pdfunc = CMD;
// *msc_txfifo = *p++;
// for (; p != line+4; p++)
// *msc_txfifo = *p;//0xf0f0f0f0;//*p;
// until(US(0.79+3.77+1.79-0.1));
// while (p != line+32) { //line_words) { /*
* We don't wait for the end of the front porch because the beginning
* of pixel data is determined by the MSC. Instead, we make good use
* of the delay to shovel bits into the MSC's FIFO.
*/
#if 0 /* quick load */
*msc_txfifo = *p++;
*msc_txfifo = *p++;
#endif
while (p != line+line_words) { while (p != line+line_words) {
uint8_t st; uint8_t st;
do { do {
st = *msc_stat; st = *msc_stat;
if (st & 3) { if (st & 3) {
// printf("st 0x%04x\n", st);
bad++; bad++;
goto fail; goto fail;
// return;
} }
} }
while (st & (1 << 7)); while (st & (1 << 7));
*msc_txfifo = *p; *msc_txfifo = *p++;
//*msc_txfifo = 0xf0f0f0f0;
p++;
} }
fail: fail:
//(void) *(volatile uint32_t *) (line+line_words);
(void) *prefetch; (void) *prefetch;
until(line_cycles); until(line_cycles);
} }
@ -356,16 +366,17 @@ static void frame(const uint32_t *f)
/* Front porch */ /* Front porch */
#if 0
hdelay(32);
#else
hdelay(31); hdelay(31);
/*
* The horizontal back porch of the previous line is handled inside
* "line", so we have to wait for less than a full line here.
*/
*tcnt = 0; *tcnt = 0;
*pddatc = HSYNC; *pddatc = HSYNC;
until(US(3.77)); until(US(3.77));
*pddats = HSYNC; *pddats = HSYNC;
until(line_cycles-US(0.79)); until(line_cycles-US(0.79));
#endif
for (p = f; p != f+240*line_words; p += line_words) { for (p = f; p != f+240*line_words; p += line_words) {
line(p, p); line(p, p);