1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-27 17:05:20 +02:00

ubb-vga: new option -2 to keep on refreshing the LCD display (experimental)

"Experimental" means that it doesn't seem to work at the moment.

- regs4740.h (_LCD, LCDCTRL): added the LCD control register
- ubb-vga.c (old_lcdctrl, tame_lcd, restore_lcd): make the LCD controller
  use short bursts, to reduce the bus access latency for other users
- ubb-vga.c (keep_lcd, setup_noirq, cleanup_noirq, usage, main): new
  option -2 to keep on refreshing the LCD display
This commit is contained in:
Werner Almesberger 2011-05-06 20:19:13 -03:00
parent f7e8fbbaea
commit ba1d297643
2 changed files with 33 additions and 4 deletions

View File

@ -30,6 +30,7 @@
#define _GPIO(n) REG(0x0010000+(n)) #define _GPIO(n) REG(0x0010000+(n))
#define _MSC(n) REG(0x0021000+(n)) #define _MSC(n) REG(0x0021000+(n))
#define _DMAC(n) REG(0x3020000+(n)) #define _DMAC(n) REG(0x3020000+(n))
#define _LCD(n) REG(0x3050000+(n))
#define CLKGR _CGU(0x0020) /* Clock Gate */ #define CLKGR _CGU(0x0020) /* Clock Gate */
#define MSCCDR _CGU(0x0068) /* MSC device clock divider */ #define MSCCDR _CGU(0x0068) /* MSC device clock divider */
@ -80,4 +81,6 @@
#define DMAC _DMAC(0x300) /* DMA control */ #define DMAC _DMAC(0x300) /* DMA control */
#define DDR _DMAC(0x308) /* DMA doorbell */ #define DDR _DMAC(0x308) /* DMA doorbell */
#define LCDCTRL _LCD(0x30) /* LCD control */
#endif /* !REGS4740_H */ #endif /* !REGS4740_H */

View File

@ -43,6 +43,7 @@
static volatile void *base; static volatile void *base;
static int bad; static int bad;
static int keep_lcd = 0;
#define US(us) ((uint16_t) ((us)*112)) #define US(us) ((uint16_t) ((us)*112))
@ -141,6 +142,7 @@ static uint32_t clkrt = 0;
static uint32_t old_icmr; static uint32_t old_icmr;
static uint32_t old_clkgr; static uint32_t old_clkgr;
static uint32_t old_lcdctrl;
static void disable_interrupts(void) static void disable_interrupts(void)
@ -181,6 +183,20 @@ static void enable_lcd(void)
} }
static void tame_lcd(void)
{
old_lcdctrl = LCDCTRL;
/* LCDCTRL.BST = 0, for 4 word burst, the shortest available */
LCDCTRL = old_lcdctrl & 0xfffffff;
}
static void restore_lcd(void)
{
LCDCTRL = old_lcdctrl;
}
static void get_timer(void) static void get_timer(void)
{ {
TSCR = 1 << TIMER; /* enable clock */ TSCR = 1 << TIMER; /* enable clock */
@ -269,7 +285,10 @@ static void setup(void)
static void setup_noirq(void) static void setup_noirq(void)
{ {
disable_lcd(); if (keep_lcd)
tame_lcd();
else
disable_lcd();
get_timer(); get_timer();
DMAC = 1; DMAC = 1;
@ -290,7 +309,10 @@ static void cleanup_noirq(void)
DCS(DMA) = 0; DCS(DMA) = 0;
release_timer(); release_timer();
enable_lcd(); if (keep_lcd)
restore_lcd();
else
enable_lcd();
} }
@ -448,10 +470,11 @@ static void list_modes(void)
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-t] [-r resolution] [frames [file]]\n" "usage: %s [-2] [-t] [-r resolution] [frames [file]]\n"
" %s -l\n\n" " %s -l\n\n"
" frames number of frames to display\n" " frames number of frames to display\n"
" file PPM file\n\n" " file PPM file\n\n"
" -2 keep on refreshing the LCD display (experimental)\n"
" -l list available modes\n" " -l list available modes\n"
" -m mode select the display mode, default \"%s\"\n" " -m mode select the display mode, default \"%s\"\n"
" -t generate a test image\n" " -t generate a test image\n"
@ -466,8 +489,11 @@ int main(int argc, char *const *argv)
int frames = 0; int frames = 0;
int c; int c;
while ((c = getopt(argc, argv, "lm:t")) != EOF) while ((c = getopt(argc, argv, "2lm:t")) != EOF)
switch (c) { switch (c) {
case '2':
keep_lcd = 1;
break;
case 'l': case 'l':
list_modes(); list_modes();
exit(0); exit(0);