-
-static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
-{
- uchar *dest;
- ushort off, row;
-
- dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
- off = x * (1 << LCD_BPP) % 8;
-
- for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
- uchar *s = str;
- uchar *d = dest;
- int i;
-
-#if LCD_BPP == LCD_MONOCHROME
- uchar rest = *d & -(1 << (8-off));
- uchar sym;
-#endif
- for (i=0; i<count; ++i) {
- uchar c, bits;
-
- c = *s++;
- bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
-
-#if LCD_BPP == LCD_MONOCHROME
- sym = (COLOR_MASK(lcd_color_fg) & bits) |
- (COLOR_MASK(lcd_color_bg) & ~bits);
-
- *d++ = rest | (sym >> off);
- rest = sym << (8-off);
-#elif LCD_BPP == LCD_COLOR8
- for (c=0; c<8; ++c) {
- *d++ = (bits & 0x80) ?
- lcd_color_fg : lcd_color_bg;
- bits <<= 1;
- }
-#endif
- }
-
-#if LCD_BPP == LCD_MONOCHROME
- *d = rest | (*d & ((1 << (8-off)) - 1));
-#endif
- }
-}
-
-/*----------------------------------------------------------------------*/
-
-static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
-{
-#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
- lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s));
-#else
- lcd_drawchars (x, y, s, strlen (s));
-#endif
-}
-
-/*----------------------------------------------------------------------*/
-
-static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
-{
-#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
- lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
-#else
- lcd_drawchars (x, y, &c, 1);
-#endif
-}
-
-/************************************************************************/
-/** Small utility to check that you got the colours right */
-/************************************************************************/
-#ifdef LCD_TEST_PATTERN
-
-#define N_BLK_VERT 2
-#define N_BLK_HOR 3
-
-static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
- CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW,
- CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN,
-};
-
-static void test_pattern (void)
-{
- ushort v_max = panel_info.vl_row;
- ushort h_max = panel_info.vl_col;
- ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
- ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
- ushort v, h;
- uchar *pix = (uchar *)lcd_base;
-
- printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
- h_max, v_max, h_step, v_step);
-
- /* WARNING: Code silently assumes 8bit/pixel */
- for (v=0; v<v_max; ++v) {
- uchar iy = v / v_step;
- for (h=0; h<h_max; ++h) {
- uchar ix = N_BLK_HOR * iy + (h/h_step);
- *pix++ = test_colors[ix];
- }
- }
-}
-#endif /* LCD_TEST_PATTERN */
-
-
-/************************************************************************/
-/* ** GENERIC Initialization Routines */
-/************************************************************************/
-
-int drv_lcd_init (void)
-{
- DECLARE_GLOBAL_DATA_PTR;
-
- device_t lcddev;
- int rc;
-
- lcd_base = (void *)(gd->fb_base);
-
- lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
-
- lcd_init (lcd_base); /* LCD initialization */
-
- /* Device initialization */
- memset (&lcddev, 0, sizeof (lcddev));
-
- strcpy (lcddev.name, "lcd");
- lcddev.ext = 0; /* No extensions */
- lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
- lcddev.putc = lcd_putc; /* 'putc' function */
- lcddev.puts = lcd_puts; /* 'puts' function */
-
- rc = device_register (&lcddev);
-
- return (rc == 0) ? 1 : rc;
-}
-
-/*----------------------------------------------------------------------*/
-
-static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
-{
-#if LCD_BPP == LCD_MONOCHROME
- /* Setting the palette */
- lcd_initcolregs();
-
-#elif LCD_BPP == LCD_COLOR8
- /* Setting the palette */
- lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0);
- lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0);
- lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
- lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
- lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
- lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
- lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
- lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
- lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
-#endif
-
-#ifndef CFG_WHITE_ON_BLACK
- lcd_setfgcolor (CONSOLE_COLOR_BLACK);
- lcd_setbgcolor (CONSOLE_COLOR_WHITE);
-#else
- lcd_setfgcolor (CONSOLE_COLOR_WHITE);
- lcd_setbgcolor (CONSOLE_COLOR_BLACK);
-#endif /* CFG_WHITE_ON_BLACK */
-
-#ifdef LCD_TEST_PATTERN
- test_pattern();
-#else
- /* set framebuffer to background color */
- memset ((char *)lcd_base,
- COLOR_MASK(lcd_getbgcolor()),
- lcd_line_length*panel_info.vl_row);
-#endif
- /* Paint the logo and retrieve LCD base address */
- debug ("[LCD] Drawing the logo...\n");
- lcd_console_address = lcd_logo ();
-
- console_col = 0;
- console_row = 0;
-
- return (0);
-}
-
-U_BOOT_CMD(
- cls, 1, 1, lcd_clear,
- "cls - clear screen\n",
- NULL
-);
-
-/*----------------------------------------------------------------------*/
-
-static int lcd_init (void *lcdbase)
-{
- /* Initialize the lcd controller */
- debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
-
- lcd_ctrl_init (lcdbase);
- lcd_clear (NULL, 1, 1, NULL); /* dummy args */
- lcd_enable ();
-
- /* Initialize the console */
- console_col = 0;
-#ifdef LCD_INFO_BELOW_LOGO
- console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
-#else
- console_row = 1; /* leave 1 blank line below logo */
-#endif
- lcd_is_enabled = 1;
-
- return 0;
-}
-
-
-/************************************************************************/
-/* ** ROM capable initialization part - needed to reserve FB memory */