1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-07-01 02:37:18 +03: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 */
// while (*msc_stat & (1 << 15));
/* HSYNC */
*msc_txfifo = *p++;
// *msc_txfifo = *p++;
until(US(0.79));
/* HSYNC */
*pddatc = HSYNC;
*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 */
#if 1
// *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));
until(US(0.79+3.77-0.3));
/*
* Without the -0.2, the XEN-1510 only detects the signal in only about
* 20% of all cases.
* Adjustment value tests with the XEN-1510:
*
* 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 */
@ -303,32 +313,32 @@ static void line(const uint32_t *line, volatile const uint32_t *prefetch)
*pdfuns = CMD;
*pddats = HSYNC;
*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) {
uint8_t st;
do {
st = *msc_stat;
if (st & 3) {
// printf("st 0x%04x\n", st);
bad++;
goto fail;
// return;
bad++;
goto fail;
}
}
while (st & (1 << 7));
*msc_txfifo = *p;
//*msc_txfifo = 0xf0f0f0f0;
p++;
*msc_txfifo = *p++;
}
fail:
//(void) *(volatile uint32_t *) (line+line_words);
(void) *prefetch;
(void) *prefetch;
until(line_cycles);
}
@ -356,16 +366,17 @@ static void frame(const uint32_t *f)
/* Front porch */
#if 0
hdelay(32);
#else
hdelay(31);
*tcnt = 0;
*pddatc = HSYNC;
until(US(3.77));
*pddats = HSYNC;
until(line_cycles-US(0.79));
#endif
/*
* 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;
*pddatc = HSYNC;
until(US(3.77));
*pddats = HSYNC;
until(line_cycles-US(0.79));
for (p = f; p != f+240*line_words; p += line_words) {
line(p, p);