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