Commit c8d2febcc7e328d1c4bb11131ecd0b9cbab2f4fb

Authored by Nikita Kiryanov
Committed by Anatolij Gustschin
1 parent 8ddfe2fad8

lcd: various cleanups

This cleanup mostly focuses on removing unnecessary whitespace and comments
which are superfluous and/or do not conform to the coding style.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Bo Shen <voice.shen@atmel.com>
Tested-by: Josh Wu <josh.wu@atmel.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Anatolij Gustschin <agust@denx.de>

Showing 2 changed files with 49 additions and 143 deletions Side-by-side Diff

1 1 /*
2   - * Common LCD routines for supported CPUs
  2 + * Common LCD routines
3 3 *
4 4 * (C) Copyright 2001-2002
5 5 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
6 6  
... ... @@ -7,12 +7,7 @@
7 7 * SPDX-License-Identifier: GPL-2.0+
8 8 */
9 9  
10   -/************************************************************************/
11   -/* ** HEADER FILES */
12   -/************************************************************************/
13   -
14 10 /* #define DEBUG */
15   -
16 11 #include <config.h>
17 12 #include <common.h>
18 13 #include <command.h>
19 14  
20 15  
21 16  
... ... @@ -26,26 +21,19 @@
26 21 #include <asm/io.h>
27 22 #include <asm/unaligned.h>
28 23 #include <fdt_support.h>
  24 +#include <video_font.h>
29 25  
30 26 #if defined(CONFIG_LCD_DT_SIMPLEFB)
31 27 #include <libfdt.h>
32 28 #endif
33 29  
34   -/************************************************************************/
35   -/* ** FONT DATA */
36   -/************************************************************************/
37   -#include <video_font.h> /* Get font data, width and height */
38   -
39   -/************************************************************************/
40   -/* ** LOGO DATA */
41   -/************************************************************************/
42 30 #ifdef CONFIG_LCD_LOGO
43   -# include <bmp_logo.h> /* Get logo data, width and height */
44   -# include <bmp_logo_data.h>
45   -# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
46   -# error Default Color Map overlaps with Logo Color Map
47   -# endif
  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
48 35 #endif
  36 +#endif
49 37  
50 38 #ifdef CONFIG_SANDBOX
51 39 #include <asm/sdl.h>
52 40  
53 41  
54 42  
55 43  
56 44  
57 45  
... ... @@ -57,30 +45,23 @@
57 45  
58 46 #if (LCD_BPP != LCD_COLOR8) && (LCD_BPP != LCD_COLOR16) && \
59 47 (LCD_BPP != LCD_COLOR32)
60   -# error Unsupported LCD BPP.
  48 +#error Unsupported LCD BPP.
61 49 #endif
62 50  
63 51 DECLARE_GLOBAL_DATA_PTR;
64 52  
65 53 static int lcd_init(void *lcdbase);
66   -
67 54 static void *lcd_logo(void);
68   -
69 55 static void lcd_setfgcolor(int color);
70 56 static void lcd_setbgcolor(int color);
71 57  
72 58 static int lcd_color_fg;
73 59 static int lcd_color_bg;
74 60 int lcd_line_length;
75   -
76 61 char lcd_is_enabled = 0;
77   -
78 62 static void *lcd_base; /* Start of framebuffer memory */
79   -
80 63 static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */
81 64  
82   -/************************************************************************/
83   -
84 65 /* Flush LCD activity to the caches */
85 66 void lcd_sync(void)
86 67 {
... ... @@ -110,8 +91,6 @@
110 91 lcd_flush_dcache = (flush != 0);
111 92 }
112 93  
113   -/*----------------------------------------------------------------------*/
114   -
115 94 static void lcd_stub_putc(struct stdio_dev *dev, const char c)
116 95 {
117 96 lcd_putc(c);
... ... @@ -122,9 +101,7 @@
122 101 lcd_puts(s);
123 102 }
124 103  
125   -/************************************************************************/
126   -/** Small utility to check that you got the colours right */
127   -/************************************************************************/
  104 +/* Small utility to check that you got the colours right */
128 105 #ifdef LCD_TEST_PATTERN
129 106  
130 107 #define N_BLK_VERT 2
... ... @@ -158,10 +135,6 @@
158 135 }
159 136 #endif /* LCD_TEST_PATTERN */
160 137  
161   -
162   -/************************************************************************/
163   -/* ** GENERIC Initialization Routines */
164   -/************************************************************************/
165 138 /*
166 139 * With most lcd drivers the line length is set up
167 140 * by calculating it from panel_info parameters. Some
... ... @@ -181,7 +154,7 @@
181 154  
182 155 lcd_base = map_sysmem(gd->fb_base, 0);
183 156  
184   - lcd_init(lcd_base); /* LCD initialization */
  157 + lcd_init(lcd_base);
185 158  
186 159 /* Device initialization */
187 160 memset(&lcddev, 0, sizeof(lcddev));
... ... @@ -197,7 +170,6 @@
197 170 return (rc == 0) ? 1 : rc;
198 171 }
199 172  
200   -/*----------------------------------------------------------------------*/
201 173 void lcd_clear(void)
202 174 {
203 175 short console_rows, console_cols;
204 176  
205 177  
206 178  
... ... @@ -261,20 +233,11 @@
261 233 lcd_clear();
262 234 return 0;
263 235 }
  236 +U_BOOT_CMD(cls, 1, 1, do_lcd_clear, "clear screen", "");
264 237  
265   -U_BOOT_CMD(
266   - cls, 1, 1, do_lcd_clear,
267   - "clear screen",
268   - ""
269   -);
270   -
271   -/*----------------------------------------------------------------------*/
272   -
273 238 static int lcd_init(void *lcdbase)
274 239 {
275   - /* Initialize the lcd controller */
276 240 debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
277   -
278 241 lcd_ctrl_init(lcdbase);
279 242  
280 243 /*
... ... @@ -304,10 +267,6 @@
304 267 return 0;
305 268 }
306 269  
307   -
308   -/************************************************************************/
309   -/* ** ROM capable initialization part - needed to reserve FB memory */
310   -/************************************************************************/
311 270 /*
312 271 * This is called early in the system initialization to grab memory
313 272 * for the LCD controller.
... ... @@ -338,8 +297,6 @@
338 297 return addr;
339 298 }
340 299  
341   -/*----------------------------------------------------------------------*/
342   -
343 300 static void lcd_setfgcolor(int color)
344 301 {
345 302 lcd_color_fg = color;
... ... @@ -350,8 +307,6 @@
350 307 return lcd_color_fg;
351 308 }
352 309  
353   -/*----------------------------------------------------------------------*/
354   -
355 310 static void lcd_setbgcolor(int color)
356 311 {
357 312 lcd_color_bg = color;
... ... @@ -362,10 +317,6 @@
362 317 return lcd_color_bg;
363 318 }
364 319  
365   -/************************************************************************/
366   -/* ** Chipset depending Bitmap / Logo stuff... */
367   -/************************************************************************/
368   -
369 320 #ifdef CONFIG_LCD_LOGO
370 321 __weak void lcd_logo_set_cmap(void)
371 322 {
372 323  
373 324  
... ... @@ -379,17 +330,14 @@
379 330 void bitmap_plot(int x, int y)
380 331 {
381 332 ushort i, j;
382   - uchar *bmap;
383   - uchar *fb;
384   - ushort *fb16;
  333 + uchar *bmap = &bmp_logo_bitmap[0];
385 334 unsigned bpix = NBITS(panel_info.vl_bpix);
  335 + uchar *fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8);
  336 + ushort *fb16;
386 337  
387 338 debug("Logo: width %d height %d colors %d\n",
388 339 BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS);
389 340  
390   - bmap = &bmp_logo_bitmap[0];
391   - fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8);
392   -
393 341 if (bpix < 12) {
394 342 WATCHDOG_RESET();
395 343 lcd_logo_set_cmap();
396 344  
... ... @@ -424,13 +372,7 @@
424 372 static inline void bitmap_plot(int x, int y) {}
425 373 #endif /* CONFIG_LCD_LOGO */
426 374  
427   -/*----------------------------------------------------------------------*/
428 375 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
429   -/*
430   - * Display the BMP file located at address bmp_image.
431   - * Only uncompressed.
432   - */
433   -
434 376 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
435 377 #define BMP_ALIGN_CENTER 0x7FFF
436 378  
437 379  
... ... @@ -451,9 +393,7 @@
451 393 }
452 394 #endif
453 395  
454   -
455 396 #ifdef CONFIG_LCD_BMP_RLE8
456   -
457 397 #define BMP_RLE8_ESCAPE 0
458 398 #define BMP_RLE8_EOL 0
459 399 #define BMP_RLE8_EOBMP 1
... ... @@ -683,7 +623,7 @@
683 623 (y + height - 1) * lcd_line_length + x * bpix / 8);
684 624  
685 625 switch (bmp_bpix) {
686   - case 1: /* pass through */
  626 + case 1:
687 627 case 8: {
688 628 cmap_base = configuration_get_cmap();
689 629 #ifdef CONFIG_LCD_BMP_RLE8
... ... @@ -13,21 +13,19 @@
13 13 #ifndef _LCD_H_
14 14 #define _LCD_H_
15 15 #include <lcd_console.h>
  16 +#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
  17 +#include <bmp_layout.h>
  18 +#include <asm/byteorder.h>
  19 +#endif
16 20  
17 21 extern char lcd_is_enabled;
18   -
19 22 extern int lcd_line_length;
20   -
21 23 extern struct vidinfo panel_info;
22 24  
23 25 void lcd_ctrl_init(void *lcdbase);
24 26 void lcd_enable(void);
25   -
26   -/* setcolreg used in 8bpp/16bpp; initcolregs used in monochrome */
27 27 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
28   -void lcd_initcolregs(void);
29 28  
30   -/* gunzip_bmp used if CONFIG_VIDEO_BMP_GZIP */
31 29 struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
32 30 void **alloc_addr);
33 31 int bmp_display(ulong addr, int x, int y);
34 32  
35 33  
... ... @@ -53,11 +51,8 @@
53 51 typedef struct vidinfo {
54 52 ushort vl_col; /* Number of columns (i.e. 160) */
55 53 ushort vl_row; /* Number of rows (i.e. 100) */
56   -
57 54 u_char vl_bpix; /* Bits per pixel, 0 = 1 */
58   -
59 55 ushort *cmap; /* Pointer to the colormap */
60   -
61 56 void *priv; /* Pointer to driver-specific data */
62 57 } vidinfo_t;
63 58  
64 59  
... ... @@ -71,14 +66,12 @@
71 66  
72 67 extern vidinfo_t panel_info;
73 68  
74   -/* Video functions */
  69 +void lcd_putc(const char c);
  70 +void lcd_puts(const char *s);
  71 +void lcd_printf(const char *fmt, ...);
  72 +void lcd_clear(void);
  73 +int lcd_display_bitmap(ulong bmp_image, int x, int y);
75 74  
76   -void lcd_putc(const char c);
77   -void lcd_puts(const char *s);
78   -void lcd_printf(const char *fmt, ...);
79   -void lcd_clear(void);
80   -int lcd_display_bitmap(ulong bmp_image, int x, int y);
81   -
82 75 /**
83 76 * Get the width of the LCD in pixels
84 77 *
... ... @@ -141,14 +134,6 @@
141 134 /* Update the LCD / flush the cache */
142 135 void lcd_sync(void);
143 136  
144   -/************************************************************************/
145   -/* ** BITMAP DISPLAY SUPPORT */
146   -/************************************************************************/
147   -#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
148   -# include <bmp_layout.h>
149   -# include <asm/byteorder.h>
150   -#endif
151   -
152 137 /*
153 138 * Information about displays we are using. This is for configuring
154 139 * the LCD controller and memory allocation. Someone has to know what
155 140  
156 141  
157 142  
158 143  
159 144  
160 145  
161 146  
162 147  
... ... @@ -163,38 +148,32 @@
163 148 #define LCD_COLOR8 3
164 149 #define LCD_COLOR16 4
165 150 #define LCD_COLOR32 5
166   -/*----------------------------------------------------------------------*/
  151 +
167 152 #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
168   -# define LCD_INFO_X 0
169   -# define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
  153 +#define LCD_INFO_X 0
  154 +#define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
170 155 #elif defined(CONFIG_LCD_LOGO)
171   -# define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
172   -# define LCD_INFO_Y VIDEO_FONT_HEIGHT
  156 +#define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
  157 +#define LCD_INFO_Y VIDEO_FONT_HEIGHT
173 158 #else
174   -# define LCD_INFO_X VIDEO_FONT_WIDTH
175   -# define LCD_INFO_Y VIDEO_FONT_HEIGHT
  159 +#define LCD_INFO_X VIDEO_FONT_WIDTH
  160 +#define LCD_INFO_Y VIDEO_FONT_HEIGHT
176 161 #endif
177 162  
178 163 /* Default to 8bpp if bit depth not specified */
179 164 #ifndef LCD_BPP
180   -# define LCD_BPP LCD_COLOR8
  165 +#define LCD_BPP LCD_COLOR8
181 166 #endif
  167 +
182 168 #ifndef LCD_DF
183   -# define LCD_DF 1
  169 +#define LCD_DF 1
184 170 #endif
185 171  
186 172 /* Calculate nr. of bits per pixel and nr. of colors */
187 173 #define NBITS(bit_code) (1 << (bit_code))
188 174 #define NCOLORS(bit_code) (1 << NBITS(bit_code))
189 175  
190   -/************************************************************************/
191   -/* ** CONSOLE CONSTANTS */
192   -/************************************************************************/
193 176 #if LCD_BPP == LCD_COLOR8
194   -
195   -/*
196   - * 8bpp color definitions
197   - */
198 177 # define CONSOLE_COLOR_BLACK 0
199 178 # define CONSOLE_COLOR_RED 1
200 179 # define CONSOLE_COLOR_GREEN 2
201 180  
202 181  
203 182  
204 183  
... ... @@ -203,39 +182,26 @@
203 182 # define CONSOLE_COLOR_MAGENTA 5
204 183 # define CONSOLE_COLOR_CYAN 6
205 184 # define CONSOLE_COLOR_GREY 14
206   -# define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
207   -
  185 +# define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
208 186 #elif LCD_BPP == LCD_COLOR32
209   -/*
210   - * 32bpp color definitions
211   - */
212   -# define CONSOLE_COLOR_RED 0x00ff0000
213   -# define CONSOLE_COLOR_GREEN 0x0000ff00
214   -# define CONSOLE_COLOR_YELLOW 0x00ffff00
215   -# define CONSOLE_COLOR_BLUE 0x000000ff
216   -# define CONSOLE_COLOR_MAGENTA 0x00ff00ff
217   -# define CONSOLE_COLOR_CYAN 0x0000ffff
218   -# define CONSOLE_COLOR_GREY 0x00aaaaaa
219   -# define CONSOLE_COLOR_BLACK 0x00000000
220   -# define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest*/
221   -# define NBYTES(bit_code) (NBITS(bit_code) >> 3)
222   -
223   -#else
224   -
225   -/*
226   - * 16bpp color definitions
227   - */
228   -# define CONSOLE_COLOR_BLACK 0x0000
229   -# define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
230   -
  187 +#define CONSOLE_COLOR_RED 0x00ff0000
  188 +#define CONSOLE_COLOR_GREEN 0x0000ff00
  189 +#define CONSOLE_COLOR_YELLOW 0x00ffff00
  190 +#define CONSOLE_COLOR_BLUE 0x000000ff
  191 +#define CONSOLE_COLOR_MAGENTA 0x00ff00ff
  192 +#define CONSOLE_COLOR_CYAN 0x0000ffff
  193 +#define CONSOLE_COLOR_GREY 0x00aaaaaa
  194 +#define CONSOLE_COLOR_BLACK 0x00000000
  195 +#define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest */
  196 +#define NBYTES(bit_code) (NBITS(bit_code) >> 3)
  197 +#else /* 16bpp color definitions */
  198 +#define CONSOLE_COLOR_BLACK 0x0000
  199 +#define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
231 200 #endif /* color definitions */
232 201  
233   -/************************************************************************/
234 202 #ifndef PAGE_SIZE
235   -# define PAGE_SIZE 4096
  203 +#define PAGE_SIZE 4096
236 204 #endif
237   -
238   -/************************************************************************/
239 205  
240 206 #endif /* _LCD_H_ */