1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * MPC823 and PXA LCD Controller
5 * Modeled after video interface by Paolo Scaffardi
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <lcd_console.h>
15 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
16 #include <bmp_layout.h>
17 #include <asm/byteorder.h>
20 int bmp_display(ulong addr, int x, int y);
21 struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
24 #ifndef CONFIG_DM_VIDEO
26 extern char lcd_is_enabled;
27 extern int lcd_line_length;
28 extern struct vidinfo panel_info;
30 void lcd_ctrl_init(void *lcdbase);
31 void lcd_enable(void);
32 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
33 ulong lcd_setmem(ulong addr);
36 * Set whether we need to flush the dcache when changing the LCD image. This
39 * @param flush non-zero to flush cache after update, 0 to skip
41 void lcd_set_flush_dcache(int flush);
43 #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
44 defined CONFIG_CPU_MONAHANS
46 #elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
47 #include <atmel_lcd.h>
48 #elif defined(CONFIG_EXYNOS_FB)
49 #include <exynos_lcd.h>
51 typedef struct vidinfo {
52 ushort vl_col; /* Number of columns (i.e. 160) */
53 ushort vl_row; /* Number of rows (i.e. 100) */
54 ushort vl_rot; /* Rotation of Display (0, 1, 2, 3) */
55 u_char vl_bpix; /* Bits per pixel, 0 = 1 */
56 ushort *cmap; /* Pointer to the colormap */
57 void *priv; /* Pointer to driver-specific data */
60 static __maybe_unused ushort *configuration_get_cmap(void)
62 return panel_info.cmap;
66 ushort *configuration_get_cmap(void);
68 extern vidinfo_t panel_info;
70 void lcd_putc(const char c);
71 void lcd_puts(const char *s);
72 void lcd_printf(const char *fmt, ...);
74 int lcd_display_bitmap(ulong bmp_image, int x, int y);
77 * Get the width of the LCD in pixels
79 * Return: width of LCD in pixels
81 int lcd_get_pixel_width(void);
84 * Get the height of the LCD in pixels
86 * Return: height of LCD in pixels
88 int lcd_get_pixel_height(void);
91 * Get the number of text lines/rows on the LCD
93 * Return: number of rows
95 int lcd_get_screen_rows(void);
98 * Get the number of text columns on the LCD
100 * Return: number of columns
102 int lcd_get_screen_columns(void);
105 * Get the background color of the LCD
107 * Return: background color value
109 int lcd_getbgcolor(void);
112 * Get the foreground color of the LCD
114 * Return: foreground color value
116 int lcd_getfgcolor(void);
119 * Set the position of the text cursor
121 * @param col Column to place cursor (0 = left side)
122 * @param row Row to place cursor (0 = top line)
124 void lcd_position_cursor(unsigned col, unsigned row);
126 /* Allow boards to customize the information displayed */
127 void lcd_show_board_info(void);
129 /* Return the size of the LCD frame buffer, and the line length */
130 int lcd_get_size(int *line_length);
132 /* Update the LCD / flush the cache */
136 * Information about displays we are using. This is for configuring
137 * the LCD controller and memory allocation. Someone has to know what
138 * is connected, as we can't autodetect anything.
140 #define CONFIG_SYS_HIGH 0 /* Pins are active high */
141 #define CONFIG_SYS_LOW 1 /* Pins are active low */
143 #define LCD_MONOCHROME 0
147 #define LCD_COLOR16 4
148 #define LCD_COLOR32 5
150 #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
152 #define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
153 #elif defined(CONFIG_LCD_LOGO)
154 #define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
155 #define LCD_INFO_Y VIDEO_FONT_HEIGHT
157 #define LCD_INFO_X VIDEO_FONT_WIDTH
158 #define LCD_INFO_Y VIDEO_FONT_HEIGHT
161 /* Default to 8bpp if bit depth not specified */
163 #define LCD_BPP LCD_COLOR8
170 /* Calculate nr. of bits per pixel and nr. of colors */
171 #define NBITS(bit_code) (1 << (bit_code))
172 #define NCOLORS(bit_code) (1 << NBITS(bit_code))
174 #if LCD_BPP == LCD_COLOR8
175 # define CONSOLE_COLOR_BLACK 0
176 # define CONSOLE_COLOR_RED 1
177 # define CONSOLE_COLOR_GREEN 2
178 # define CONSOLE_COLOR_YELLOW 3
179 # define CONSOLE_COLOR_BLUE 4
180 # define CONSOLE_COLOR_MAGENTA 5
181 # define CONSOLE_COLOR_CYAN 6
182 # define CONSOLE_COLOR_GREY 14
183 # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
184 #elif LCD_BPP == LCD_COLOR32
185 #define CONSOLE_COLOR_RED 0x00ff0000
186 #define CONSOLE_COLOR_GREEN 0x0000ff00
187 #define CONSOLE_COLOR_YELLOW 0x00ffff00
188 #define CONSOLE_COLOR_BLUE 0x000000ff
189 #define CONSOLE_COLOR_MAGENTA 0x00ff00ff
190 #define CONSOLE_COLOR_CYAN 0x0000ffff
191 #define CONSOLE_COLOR_GREY 0x00aaaaaa
192 #define CONSOLE_COLOR_BLACK 0x00000000
193 #define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest */
194 #define NBYTES(bit_code) (NBITS(bit_code) >> 3)
195 #else /* 16bpp color definitions */
196 # define CONSOLE_COLOR_BLACK 0x0000
197 # define CONSOLE_COLOR_RED 0xF800
198 # define CONSOLE_COLOR_GREEN 0x07E0
199 # define CONSOLE_COLOR_YELLOW 0xFFE0
200 # define CONSOLE_COLOR_BLUE 0x001F
201 # define CONSOLE_COLOR_MAGENTA 0xF81F
202 # define CONSOLE_COLOR_CYAN 0x07FF
203 # define CONSOLE_COLOR_GREY 0xC618
204 # define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
205 #endif /* color definitions */
207 #if LCD_BPP == LCD_COLOR16
208 #define fbptr_t ushort
209 #elif LCD_BPP == LCD_COLOR32
212 #define fbptr_t uchar
216 #define PAGE_SIZE 4096
219 #endif /* !CONFIG_DM_VIDEO */