lcd: Remove LCD_TEST_PATTERN code
[platform/kernel/u-boot.git] / common / lcd.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Common LCD routines
4  *
5  * (C) Copyright 2001-2002
6  * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
7  */
8
9 /* #define DEBUG */
10 #include <config.h>
11 #include <common.h>
12 #include <command.h>
13 #include <cpu_func.h>
14 #include <env_callback.h>
15 #include <log.h>
16 #include <asm/cache.h>
17 #include <init.h>
18 #include <asm/global_data.h>
19 #include <linux/types.h>
20 #include <stdio_dev.h>
21 #include <lcd.h>
22 #include <mapmem.h>
23 #include <watchdog.h>
24 #include <asm/unaligned.h>
25 #include <splash.h>
26 #include <asm/io.h>
27 #include <asm/unaligned.h>
28 #include <video_font.h>
29
30 #ifdef CONFIG_LCD_LOGO
31 #include <bmp_logo.h>
32 #include <bmp_logo_data.h>
33 #if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
34 #error Default Color Map overlaps with Logo Color Map
35 #endif
36 #endif
37
38 #ifndef CONFIG_LCD_ALIGNMENT
39 #define CONFIG_LCD_ALIGNMENT PAGE_SIZE
40 #endif
41
42 #if (LCD_BPP != LCD_COLOR8) && (LCD_BPP != LCD_COLOR16) && \
43         (LCD_BPP != LCD_COLOR32)
44 #error Unsupported LCD BPP.
45 #endif
46
47 DECLARE_GLOBAL_DATA_PTR;
48
49 static int lcd_init(void *lcdbase);
50 static void lcd_logo(void);
51 static void lcd_setfgcolor(int color);
52 static void lcd_setbgcolor(int color);
53
54 static int lcd_color_fg;
55 static int lcd_color_bg;
56 int lcd_line_length;
57 char lcd_is_enabled = 0;
58 static void *lcd_base;                  /* Start of framebuffer memory  */
59 static char lcd_flush_dcache;   /* 1 to flush dcache after each lcd update */
60
61 /* Flush LCD activity to the caches */
62 void lcd_sync(void)
63 {
64         /*
65          * flush_dcache_range() is declared in common.h but it seems that some
66          * architectures do not actually implement it. Is there a way to find
67          * out whether it exists? For now, ARM is safe.
68          */
69 #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
70         int line_length;
71
72         if (lcd_flush_dcache)
73                 flush_dcache_range((ulong)lcd_base,
74                         (ulong)(lcd_base + lcd_get_size(&line_length)));
75 #endif
76 }
77
78 void lcd_set_flush_dcache(int flush)
79 {
80         lcd_flush_dcache = (flush != 0);
81 }
82
83 static void lcd_stub_putc(struct stdio_dev *dev, const char c)
84 {
85         lcd_putc(c);
86 }
87
88 static void lcd_stub_puts(struct stdio_dev *dev, const char *s)
89 {
90         lcd_puts(s);
91 }
92
93 /*
94  * With most lcd drivers the line length is set up
95  * by calculating it from panel_info parameters. Some
96  * drivers need to calculate the line length differently,
97  * so make the function weak to allow overriding it.
98  */
99 __weak int lcd_get_size(int *line_length)
100 {
101         *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
102         return *line_length * panel_info.vl_row;
103 }
104
105 int drv_lcd_init(void)
106 {
107         struct stdio_dev lcddev;
108         int rc;
109
110         lcd_base = map_sysmem(gd->fb_base, 0);
111
112         lcd_init(lcd_base);
113
114         /* Device initialization */
115         memset(&lcddev, 0, sizeof(lcddev));
116
117         strcpy(lcddev.name, "lcd");
118         lcddev.ext   = 0;                       /* No extensions */
119         lcddev.flags = DEV_FLAGS_OUTPUT;        /* Output only */
120         lcddev.putc  = lcd_stub_putc;           /* 'putc' function */
121         lcddev.puts  = lcd_stub_puts;           /* 'puts' function */
122
123         rc = stdio_register(&lcddev);
124
125         return (rc == 0) ? 1 : rc;
126 }
127
128 void lcd_clear(void)
129 {
130         int bg_color;
131         __maybe_unused ulong addr;
132         static int do_splash = 1;
133 #if LCD_BPP == LCD_COLOR8
134         /* Setting the palette */
135         lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0);
136         lcd_setcolreg(CONSOLE_COLOR_RED, 0xFF, 0, 0);
137         lcd_setcolreg(CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
138         lcd_setcolreg(CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
139         lcd_setcolreg(CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
140         lcd_setcolreg(CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
141         lcd_setcolreg(CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
142         lcd_setcolreg(CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
143         lcd_setcolreg(CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
144 #endif
145
146 #ifndef CONFIG_SYS_WHITE_ON_BLACK
147         lcd_setfgcolor(CONSOLE_COLOR_BLACK);
148         lcd_setbgcolor(CONSOLE_COLOR_WHITE);
149         bg_color = CONSOLE_COLOR_WHITE;
150 #else
151         lcd_setfgcolor(CONSOLE_COLOR_WHITE);
152         lcd_setbgcolor(CONSOLE_COLOR_BLACK);
153         bg_color = CONSOLE_COLOR_BLACK;
154 #endif  /* CONFIG_SYS_WHITE_ON_BLACK */
155
156         /* set framebuffer to background color */
157 #if (LCD_BPP != LCD_COLOR32)
158         memset((char *)lcd_base, bg_color, lcd_line_length * panel_info.vl_row);
159 #else
160         u32 *ppix = lcd_base;
161         u32 i;
162         for (i = 0;
163            i < (lcd_line_length * panel_info.vl_row)/NBYTES(panel_info.vl_bpix);
164            i++) {
165                 *ppix++ = bg_color;
166         }
167 #endif
168         /* setup text-console */
169         debug("[LCD] setting up console...\n");
170         lcd_init_console(lcd_base,
171                          panel_info.vl_col,
172                          panel_info.vl_row,
173                          panel_info.vl_rot);
174         /* Paint the logo and retrieve LCD base address */
175         debug("[LCD] Drawing the logo...\n");
176         if (do_splash) {
177                 if (splash_display() == 0) {
178                         do_splash = 0;
179                         lcd_sync();
180                         return;
181                 }
182         }
183
184         lcd_logo();
185 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
186         addr = (ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length;
187         lcd_init_console((void *)addr, panel_info.vl_col,
188                          panel_info.vl_row, panel_info.vl_rot);
189 #endif
190         lcd_sync();
191 }
192
193 static int lcd_init(void *lcdbase)
194 {
195         debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
196         lcd_ctrl_init(lcdbase);
197
198         /*
199          * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi) ignores
200          * the 'lcdbase' argument and uses custom lcd base address
201          * by setting up gd->fb_base. Check for this condition and fixup
202          * 'lcd_base' address.
203          */
204         if (map_to_sysmem(lcdbase) != gd->fb_base)
205                 lcd_base = map_sysmem(gd->fb_base, 0);
206
207         debug("[LCD] Using LCD frambuffer at %p\n", lcd_base);
208
209         lcd_get_size(&lcd_line_length);
210         lcd_is_enabled = 1;
211         lcd_clear();
212         lcd_enable();
213
214         /* Initialize the console */
215         lcd_set_col(0);
216 #ifdef CONFIG_LCD_INFO_BELOW_LOGO
217         lcd_set_row(7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT);
218 #else
219         lcd_set_row(1); /* leave 1 blank line below logo */
220 #endif
221
222         return 0;
223 }
224
225 /*
226  * This is called early in the system initialization to grab memory
227  * for the LCD controller.
228  * Returns new address for monitor, after reserving LCD buffer memory
229  *
230  * Note that this is running from ROM, so no write access to global data.
231  */
232 ulong lcd_setmem(ulong addr)
233 {
234         ulong size;
235         int line_length;
236
237         debug("LCD panel info: %d x %d, %d bit/pix\n", panel_info.vl_col,
238                 panel_info.vl_row, NBITS(panel_info.vl_bpix));
239
240         size = lcd_get_size(&line_length);
241
242         /* Round up to nearest full page, or MMU section if defined */
243         size = ALIGN(size, CONFIG_LCD_ALIGNMENT);
244         addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT);
245
246         /* Allocate pages for the frame buffer. */
247         addr -= size;
248
249         debug("Reserving %ldk for LCD Framebuffer at: %08lx\n",
250               size >> 10, addr);
251
252         return addr;
253 }
254
255 static void lcd_setfgcolor(int color)
256 {
257         lcd_color_fg = color;
258 }
259
260 int lcd_getfgcolor(void)
261 {
262         return lcd_color_fg;
263 }
264
265 static void lcd_setbgcolor(int color)
266 {
267         lcd_color_bg = color;
268 }
269
270 int lcd_getbgcolor(void)
271 {
272         return lcd_color_bg;
273 }
274
275 #ifdef CONFIG_LCD_LOGO
276 __weak void lcd_logo_set_cmap(void)
277 {
278         int i;
279         ushort *cmap = configuration_get_cmap();
280
281         for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i)
282                 *cmap++ = bmp_logo_palette[i];
283 }
284
285 void lcd_logo_plot(int x, int y)
286 {
287         ushort i, j;
288         uchar *bmap = &bmp_logo_bitmap[0];
289         unsigned bpix = NBITS(panel_info.vl_bpix);
290         uchar *fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8);
291         ushort *fb16;
292
293         debug("Logo: width %d  height %d  colors %d\n",
294               BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS);
295
296         if (bpix < 12) {
297                 WATCHDOG_RESET();
298                 lcd_logo_set_cmap();
299                 WATCHDOG_RESET();
300
301                 for (i = 0; i < BMP_LOGO_HEIGHT; ++i) {
302                         memcpy(fb, bmap, BMP_LOGO_WIDTH);
303                         bmap += BMP_LOGO_WIDTH;
304                         fb += panel_info.vl_col;
305                 }
306         }
307         else { /* true color mode */
308                 u16 col16;
309                 fb16 = (ushort *)fb;
310                 for (i = 0; i < BMP_LOGO_HEIGHT; ++i) {
311                         for (j = 0; j < BMP_LOGO_WIDTH; j++) {
312                                 col16 = bmp_logo_palette[(bmap[j]-16)];
313                                 fb16[j] =
314                                         ((col16 & 0x000F) << 1) |
315                                         ((col16 & 0x00F0) << 3) |
316                                         ((col16 & 0x0F00) << 4);
317                                 }
318                         bmap += BMP_LOGO_WIDTH;
319                         fb16 += panel_info.vl_col;
320                 }
321         }
322
323         WATCHDOG_RESET();
324         lcd_sync();
325 }
326 #else
327 static inline void lcd_logo_plot(int x, int y) {}
328 #endif /* CONFIG_LCD_LOGO */
329
330 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
331 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
332
333 static void splash_align_axis(int *axis, unsigned long panel_size,
334                                         unsigned long picture_size)
335 {
336         unsigned long panel_picture_delta = panel_size - picture_size;
337         unsigned long axis_alignment;
338
339         if (*axis == BMP_ALIGN_CENTER)
340                 axis_alignment = panel_picture_delta / 2;
341         else if (*axis < 0)
342                 axis_alignment = panel_picture_delta + *axis + 1;
343         else
344                 return;
345
346         *axis = max(0, (int)axis_alignment);
347 }
348 #endif
349
350 #ifdef CONFIG_LCD_BMP_RLE8
351 #define BMP_RLE8_ESCAPE         0
352 #define BMP_RLE8_EOL            0
353 #define BMP_RLE8_EOBMP          1
354 #define BMP_RLE8_DELTA          2
355
356 static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap,
357                                   int cnt)
358 {
359         while (cnt > 0) {
360                 *(*fbp)++ = cmap[*bmap++];
361                 cnt--;
362         }
363 }
364
365 static void draw_encoded_bitmap(ushort **fbp, ushort c, int cnt)
366 {
367         ushort *fb = *fbp;
368         int cnt_8copy = cnt >> 3;
369
370         cnt -= cnt_8copy << 3;
371         while (cnt_8copy > 0) {
372                 *fb++ = c;
373                 *fb++ = c;
374                 *fb++ = c;
375                 *fb++ = c;
376                 *fb++ = c;
377                 *fb++ = c;
378                 *fb++ = c;
379                 *fb++ = c;
380                 cnt_8copy--;
381         }
382         while (cnt > 0) {
383                 *fb++ = c;
384                 cnt--;
385         }
386         *fbp = fb;
387 }
388
389 /*
390  * Do not call this function directly, must be called from lcd_display_bitmap.
391  */
392 static void lcd_display_rle8_bitmap(struct bmp_image *bmp, ushort *cmap,
393                                     uchar *fb, int x_off, int y_off)
394 {
395         uchar *bmap;
396         ulong width, height;
397         ulong cnt, runlen;
398         int x, y;
399         int decode = 1;
400
401         width = get_unaligned_le32(&bmp->header.width);
402         height = get_unaligned_le32(&bmp->header.height);
403         bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
404
405         x = 0;
406         y = height - 1;
407
408         while (decode) {
409                 if (bmap[0] == BMP_RLE8_ESCAPE) {
410                         switch (bmap[1]) {
411                         case BMP_RLE8_EOL:
412                                 /* end of line */
413                                 bmap += 2;
414                                 x = 0;
415                                 y--;
416                                 /* 16bpix, 2-byte per pixel, width should *2 */
417                                 fb -= (width * 2 + lcd_line_length);
418                                 break;
419                         case BMP_RLE8_EOBMP:
420                                 /* end of bitmap */
421                                 decode = 0;
422                                 break;
423                         case BMP_RLE8_DELTA:
424                                 /* delta run */
425                                 x += bmap[2];
426                                 y -= bmap[3];
427                                 /* 16bpix, 2-byte per pixel, x should *2 */
428                                 fb = (uchar *) (lcd_base + (y + y_off - 1)
429                                         * lcd_line_length + (x + x_off) * 2);
430                                 bmap += 4;
431                                 break;
432                         default:
433                                 /* unencoded run */
434                                 runlen = bmap[1];
435                                 bmap += 2;
436                                 if (y < height) {
437                                         if (x < width) {
438                                                 if (x + runlen > width)
439                                                         cnt = width - x;
440                                                 else
441                                                         cnt = runlen;
442                                                 draw_unencoded_bitmap(
443                                                         (ushort **)&fb,
444                                                         bmap, cmap, cnt);
445                                         }
446                                         x += runlen;
447                                 }
448                                 bmap += runlen;
449                                 if (runlen & 1)
450                                         bmap++;
451                         }
452                 } else {
453                         /* encoded run */
454                         if (y < height) {
455                                 runlen = bmap[0];
456                                 if (x < width) {
457                                         /* aggregate the same code */
458                                         while (bmap[0] == 0xff &&
459                                                bmap[2] != BMP_RLE8_ESCAPE &&
460                                                bmap[1] == bmap[3]) {
461                                                 runlen += bmap[2];
462                                                 bmap += 2;
463                                         }
464                                         if (x + runlen > width)
465                                                 cnt = width - x;
466                                         else
467                                                 cnt = runlen;
468                                         draw_encoded_bitmap((ushort **)&fb,
469                                                 cmap[bmap[1]], cnt);
470                                 }
471                                 x += runlen;
472                         }
473                         bmap += 2;
474                 }
475         }
476 }
477 #endif
478
479 __weak void fb_put_byte(uchar **fb, uchar **from)
480 {
481         *(*fb)++ = *(*from)++;
482 }
483
484 #if defined(CONFIG_BMP_16BPP)
485 __weak void fb_put_word(uchar **fb, uchar **from)
486 {
487         *(*fb)++ = *(*from)++;
488         *(*fb)++ = *(*from)++;
489 }
490 #endif /* CONFIG_BMP_16BPP */
491
492 __weak void lcd_set_cmap(struct bmp_image *bmp, unsigned colors)
493 {
494         int i;
495         struct bmp_color_table_entry cte;
496         ushort *cmap = configuration_get_cmap();
497
498         for (i = 0; i < colors; ++i) {
499                 cte = bmp->color_table[i];
500                 *cmap = (((cte.red)   << 8) & 0xf800) |
501                         (((cte.green) << 3) & 0x07e0) |
502                         (((cte.blue)  >> 3) & 0x001f);
503                 cmap++;
504         }
505 }
506
507 int lcd_display_bitmap(ulong bmp_image, int x, int y)
508 {
509         ushort *cmap_base = NULL;
510         ushort i, j;
511         uchar *fb;
512         struct bmp_image *bmp = (struct bmp_image *)map_sysmem(bmp_image, 0);
513         uchar *bmap;
514         ushort padded_width;
515         unsigned long width, height, byte_width;
516         unsigned long pwidth = panel_info.vl_col;
517         unsigned colors, bpix, bmp_bpix;
518         int hdr_size;
519         struct bmp_color_table_entry *palette;
520
521         if (!bmp || !(bmp->header.signature[0] == 'B' &&
522                 bmp->header.signature[1] == 'M')) {
523                 printf("Error: no valid bmp image at %lx\n", bmp_image);
524
525                 return 1;
526         }
527
528         palette = bmp->color_table;
529         width = get_unaligned_le32(&bmp->header.width);
530         height = get_unaligned_le32(&bmp->header.height);
531         bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
532         hdr_size = get_unaligned_le16(&bmp->header.size);
533         debug("hdr_size=%d, bmp_bpix=%d\n", hdr_size, bmp_bpix);
534
535         colors = 1 << bmp_bpix;
536
537         bpix = NBITS(panel_info.vl_bpix);
538
539         if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) {
540                 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
541                         bpix, bmp_bpix);
542
543                 return 1;
544         }
545
546         /*
547          * We support displaying 8bpp BMPs on 16bpp LCDs
548          * and displaying 24bpp BMPs on 32bpp LCDs
549          * */
550         if (bpix != bmp_bpix &&
551             !(bmp_bpix == 8 && bpix == 16) &&
552             !(bmp_bpix == 24 && bpix == 32)) {
553                 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
554                         bpix, get_unaligned_le16(&bmp->header.bit_count));
555                 return 1;
556         }
557
558         debug("Display-bmp: %d x %d  with %d colors, display %d\n",
559               (int)width, (int)height, (int)colors, 1 << bpix);
560
561         if (bmp_bpix == 8)
562                 lcd_set_cmap(bmp, colors);
563
564         padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width);
565
566 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
567         splash_align_axis(&x, pwidth, width);
568         splash_align_axis(&y, panel_info.vl_row, height);
569 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
570
571         if ((x + width) > pwidth)
572                 width = pwidth - x;
573         if ((y + height) > panel_info.vl_row)
574                 height = panel_info.vl_row - y;
575
576         bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
577         fb   = (uchar *)(lcd_base +
578                 (y + height - 1) * lcd_line_length + x * bpix / 8);
579
580         switch (bmp_bpix) {
581         case 1:
582         case 8: {
583                 cmap_base = configuration_get_cmap();
584 #ifdef CONFIG_LCD_BMP_RLE8
585                 u32 compression = get_unaligned_le32(&bmp->header.compression);
586                 debug("compressed %d %d\n", compression, BMP_BI_RLE8);
587                 if (compression == BMP_BI_RLE8) {
588                         if (bpix != 16) {
589                                 /* TODO implement render code for bpix != 16 */
590                                 printf("Error: only support 16 bpix");
591                                 return 1;
592                         }
593                         lcd_display_rle8_bitmap(bmp, cmap_base, fb, x, y);
594                         break;
595                 }
596 #endif
597
598                 if (bpix != 16)
599                         byte_width = width;
600                 else
601                         byte_width = width * 2;
602
603                 for (i = 0; i < height; ++i) {
604                         WATCHDOG_RESET();
605                         for (j = 0; j < width; j++) {
606                                 if (bpix != 16) {
607                                         fb_put_byte(&fb, &bmap);
608                                 } else {
609                                         struct bmp_color_table_entry *entry;
610                                         uint val;
611
612                                         if (cmap_base) {
613                                                 val = cmap_base[*bmap];
614                                         } else {
615                                                 entry = &palette[*bmap];
616                                                 val = entry->blue >> 3 |
617                                                         entry->green >> 2 << 5 |
618                                                         entry->red >> 3 << 11;
619                                         }
620                                         *(uint16_t *)fb = val;
621                                         bmap++;
622                                         fb += sizeof(uint16_t) / sizeof(*fb);
623                                 }
624                         }
625                         bmap += (padded_width - width);
626                         fb -= byte_width + lcd_line_length;
627                 }
628                 break;
629         }
630 #if defined(CONFIG_BMP_16BPP)
631         case 16:
632                 for (i = 0; i < height; ++i) {
633                         WATCHDOG_RESET();
634                         for (j = 0; j < width; j++)
635                                 fb_put_word(&fb, &bmap);
636
637                         bmap += (padded_width - width) * 2;
638                         fb -= width * 2 + lcd_line_length;
639                 }
640                 break;
641 #endif /* CONFIG_BMP_16BPP */
642 #if defined(CONFIG_BMP_24BPP)
643         case 24:
644                 for (i = 0; i < height; ++i) {
645                         for (j = 0; j < width; j++) {
646                                 *(fb++) = *(bmap++);
647                                 *(fb++) = *(bmap++);
648                                 *(fb++) = *(bmap++);
649                                 *(fb++) = 0;
650                         }
651                         fb -= lcd_line_length + width * (bpix / 8);
652                 }
653                 break;
654 #endif /* CONFIG_BMP_24BPP */
655 #if defined(CONFIG_BMP_32BPP)
656         case 32:
657                 for (i = 0; i < height; ++i) {
658                         for (j = 0; j < width; j++) {
659                                 *(fb++) = *(bmap++);
660                                 *(fb++) = *(bmap++);
661                                 *(fb++) = *(bmap++);
662                                 *(fb++) = *(bmap++);
663                         }
664                         fb -= lcd_line_length + width * (bpix / 8);
665                 }
666                 break;
667 #endif /* CONFIG_BMP_32BPP */
668         default:
669                 break;
670         };
671
672         lcd_sync();
673         return 0;
674 }
675 #endif
676
677 static void lcd_logo(void)
678 {
679         lcd_logo_plot(0, 0);
680
681 #ifdef CONFIG_LCD_INFO
682         lcd_set_col(LCD_INFO_X / VIDEO_FONT_WIDTH);
683         lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT);
684         lcd_show_board_info();
685 #endif /* CONFIG_LCD_INFO */
686 }
687
688 #ifdef CONFIG_SPLASHIMAGE_GUARD
689 static int on_splashimage(const char *name, const char *value, enum env_op op,
690         int flags)
691 {
692         ulong addr;
693         int aligned;
694
695         if (op == env_op_delete)
696                 return 0;
697
698         addr = hextoul(value, NULL);
699         /* See README.displaying-bmps */
700         aligned = (addr % 4 == 2);
701         if (!aligned) {
702                 printf("Invalid splashimage value. Value must be 16 bit aligned, but not 32 bit aligned\n");
703                 return -1;
704         }
705
706         return 0;
707 }
708
709 U_BOOT_ENV_CALLBACK(splashimage, on_splashimage);
710 #endif
711
712 int lcd_get_pixel_width(void)
713 {
714         return panel_info.vl_col;
715 }
716
717 int lcd_get_pixel_height(void)
718 {
719         return panel_info.vl_row;
720 }