]> git.ipfire.org Git - thirdparty/u-boot.git/blob - include/lcd.h
lcd: split configuration_get_cmap
[thirdparty/u-boot.git] / include / lcd.h
1 /*
2 * MPC823 and PXA LCD Controller
3 *
4 * Modeled after video interface by Paolo Scaffardi
5 *
6 *
7 * (C) Copyright 2001
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 *
10 * SPDX-License-Identifier: GPL-2.0+
11 */
12
13 #ifndef _LCD_H_
14 #define _LCD_H_
15 #include <lcd_console.h>
16
17 extern char lcd_is_enabled;
18
19 extern int lcd_line_length;
20
21 extern struct vidinfo panel_info;
22
23 void lcd_ctrl_init(void *lcdbase);
24 void lcd_enable(void);
25
26 /* setcolreg used in 8bpp/16bpp; initcolregs used in monochrome */
27 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
28 void lcd_initcolregs(void);
29
30 /* gunzip_bmp used if CONFIG_VIDEO_BMP_GZIP */
31 struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
32 void **alloc_addr);
33 int bmp_display(ulong addr, int x, int y);
34
35 /**
36 * Set whether we need to flush the dcache when changing the LCD image. This
37 * defaults to off.
38 *
39 * @param flush non-zero to flush cache after update, 0 to skip
40 */
41 void lcd_set_flush_dcache(int flush);
42
43 #if defined CONFIG_MPC823
44 #include <mpc823_lcd.h>
45 #elif defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
46 defined CONFIG_CPU_MONAHANS
47 #include <pxa_lcd.h>
48 #elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
49 #include <atmel_lcd.h>
50 #elif defined(CONFIG_EXYNOS_FB)
51 #include <exynos_lcd.h>
52 #else
53 typedef struct vidinfo {
54 ushort vl_col; /* Number of columns (i.e. 160) */
55 ushort vl_row; /* Number of rows (i.e. 100) */
56
57 u_char vl_bpix; /* Bits per pixel, 0 = 1 */
58
59 ushort *cmap; /* Pointer to the colormap */
60
61 void *priv; /* Pointer to driver-specific data */
62 } vidinfo_t;
63
64 static __maybe_unused ushort *configuration_get_cmap(void)
65 {
66 return panel_info.cmap;
67 }
68 #endif
69
70 ushort *configuration_get_cmap(void);
71
72 extern vidinfo_t panel_info;
73
74 /* Video functions */
75
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 /**
83 * Get the width of the LCD in pixels
84 *
85 * @return width of LCD in pixels
86 */
87 int lcd_get_pixel_width(void);
88
89 /**
90 * Get the height of the LCD in pixels
91 *
92 * @return height of LCD in pixels
93 */
94 int lcd_get_pixel_height(void);
95
96 /**
97 * Get the number of text lines/rows on the LCD
98 *
99 * @return number of rows
100 */
101 int lcd_get_screen_rows(void);
102
103 /**
104 * Get the number of text columns on the LCD
105 *
106 * @return number of columns
107 */
108 int lcd_get_screen_columns(void);
109
110 /**
111 * Get the background color of the LCD
112 *
113 * @return background color value
114 */
115 int lcd_getbgcolor(void);
116
117 /**
118 * Get the foreground color of the LCD
119 *
120 * @return foreground color value
121 */
122 int lcd_getfgcolor(void);
123
124 /**
125 * Set the position of the text cursor
126 *
127 * @param col Column to place cursor (0 = left side)
128 * @param row Row to place cursor (0 = top line)
129 */
130 void lcd_position_cursor(unsigned col, unsigned row);
131
132 /* Allow boards to customize the information displayed */
133 void lcd_show_board_info(void);
134
135 /* Return the size of the LCD frame buffer, and the line length */
136 int lcd_get_size(int *line_length);
137
138 int lcd_dt_simplefb_add_node(void *blob);
139 int lcd_dt_simplefb_enable_existing_node(void *blob);
140
141 /* Update the LCD / flush the cache */
142 void lcd_sync(void);
143
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 /*
153 * Information about displays we are using. This is for configuring
154 * the LCD controller and memory allocation. Someone has to know what
155 * is connected, as we can't autodetect anything.
156 */
157 #define CONFIG_SYS_HIGH 0 /* Pins are active high */
158 #define CONFIG_SYS_LOW 1 /* Pins are active low */
159
160 #define LCD_MONOCHROME 0
161 #define LCD_COLOR2 1
162 #define LCD_COLOR4 2
163 #define LCD_COLOR8 3
164 #define LCD_COLOR16 4
165 #define LCD_COLOR32 5
166 /*----------------------------------------------------------------------*/
167 #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
168 # define LCD_INFO_X 0
169 # define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
170 #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
173 #else
174 # define LCD_INFO_X VIDEO_FONT_WIDTH
175 # define LCD_INFO_Y VIDEO_FONT_HEIGHT
176 #endif
177
178 /* Default to 8bpp if bit depth not specified */
179 #ifndef LCD_BPP
180 # define LCD_BPP LCD_COLOR8
181 #endif
182 #ifndef LCD_DF
183 # define LCD_DF 1
184 #endif
185
186 /* Calculate nr. of bits per pixel and nr. of colors */
187 #define NBITS(bit_code) (1 << (bit_code))
188 #define NCOLORS(bit_code) (1 << NBITS(bit_code))
189
190 /************************************************************************/
191 /* ** CONSOLE CONSTANTS */
192 /************************************************************************/
193 #if LCD_BPP == LCD_COLOR8
194
195 /*
196 * 8bpp color definitions
197 */
198 # define CONSOLE_COLOR_BLACK 0
199 # define CONSOLE_COLOR_RED 1
200 # define CONSOLE_COLOR_GREEN 2
201 # define CONSOLE_COLOR_YELLOW 3
202 # define CONSOLE_COLOR_BLUE 4
203 # define CONSOLE_COLOR_MAGENTA 5
204 # define CONSOLE_COLOR_CYAN 6
205 # define CONSOLE_COLOR_GREY 14
206 # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
207
208 #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
231 #endif /* color definitions */
232
233 /************************************************************************/
234 #ifndef PAGE_SIZE
235 # define PAGE_SIZE 4096
236 #endif
237
238 /************************************************************************/
239
240 #endif /* _LCD_H_ */