]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/lcd.h
lcd: various cleanups
[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 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
19 #include <bmp_layout.h>
20 #include <asm/byteorder.h>
21 #endif
22
23 extern char lcd_is_enabled;
24 extern int lcd_line_length;
25 extern struct vidinfo panel_info;
26
27 void lcd_ctrl_init(void *lcdbase);
28 void lcd_enable(void);
29 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
30
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         u_char  vl_bpix;        /* Bits per pixel, 0 = 1 */
57         ushort  *cmap;          /* Pointer to the colormap */
58         void    *priv;          /* Pointer to driver-specific data */
59 } vidinfo_t;
60
61 static __maybe_unused ushort *configuration_get_cmap(void)
62 {
63         return panel_info.cmap;
64 }
65 #endif
66
67 ushort *configuration_get_cmap(void);
68
69 extern vidinfo_t panel_info;
70
71 void lcd_putc(const char c);
72 void lcd_puts(const char *s);
73 void lcd_printf(const char *fmt, ...);
74 void lcd_clear(void);
75 int lcd_display_bitmap(ulong bmp_image, int x, int y);
76
77 /**
78  * Get the width of the LCD in pixels
79  *
80  * @return width of LCD in pixels
81  */
82 int lcd_get_pixel_width(void);
83
84 /**
85  * Get the height of the LCD in pixels
86  *
87  * @return height of LCD in pixels
88  */
89 int lcd_get_pixel_height(void);
90
91 /**
92  * Get the number of text lines/rows on the LCD
93  *
94  * @return number of rows
95  */
96 int lcd_get_screen_rows(void);
97
98 /**
99  * Get the number of text columns on the LCD
100  *
101  * @return number of columns
102  */
103 int lcd_get_screen_columns(void);
104
105 /**
106  * Get the background color of the LCD
107  *
108  * @return background color value
109  */
110 int lcd_getbgcolor(void);
111
112 /**
113  * Get the foreground color of the LCD
114  *
115  * @return foreground color value
116  */
117 int lcd_getfgcolor(void);
118
119 /**
120  * Set the position of the text cursor
121  *
122  * @param col   Column to place cursor (0 = left side)
123  * @param row   Row to place cursor (0 = top line)
124  */
125 void lcd_position_cursor(unsigned col, unsigned row);
126
127 /* Allow boards to customize the information displayed */
128 void lcd_show_board_info(void);
129
130 /* Return the size of the LCD frame buffer, and the line length */
131 int lcd_get_size(int *line_length);
132
133 int lcd_dt_simplefb_add_node(void *blob);
134 int lcd_dt_simplefb_enable_existing_node(void *blob);
135
136 /* Update the LCD / flush the cache */
137 void lcd_sync(void);
138
139 /*
140  *  Information about displays we are using. This is for configuring
141  *  the LCD controller and memory allocation. Someone has to know what
142  *  is connected, as we can't autodetect anything.
143  */
144 #define CONFIG_SYS_HIGH 0       /* Pins are active high                 */
145 #define CONFIG_SYS_LOW  1       /* Pins are active low                  */
146
147 #define LCD_MONOCHROME  0
148 #define LCD_COLOR2      1
149 #define LCD_COLOR4      2
150 #define LCD_COLOR8      3
151 #define LCD_COLOR16     4
152 #define LCD_COLOR32     5
153
154 #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
155 #define LCD_INFO_X              0
156 #define LCD_INFO_Y              (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
157 #elif defined(CONFIG_LCD_LOGO)
158 #define LCD_INFO_X              (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
159 #define LCD_INFO_Y              VIDEO_FONT_HEIGHT
160 #else
161 #define LCD_INFO_X              VIDEO_FONT_WIDTH
162 #define LCD_INFO_Y              VIDEO_FONT_HEIGHT
163 #endif
164
165 /* Default to 8bpp if bit depth not specified */
166 #ifndef LCD_BPP
167 #define LCD_BPP                 LCD_COLOR8
168 #endif
169
170 #ifndef LCD_DF
171 #define LCD_DF                  1
172 #endif
173
174 /* Calculate nr. of bits per pixel  and nr. of colors */
175 #define NBITS(bit_code)         (1 << (bit_code))
176 #define NCOLORS(bit_code)       (1 << NBITS(bit_code))
177
178 #if LCD_BPP == LCD_COLOR8
179 # define CONSOLE_COLOR_BLACK    0
180 # define CONSOLE_COLOR_RED      1
181 # define CONSOLE_COLOR_GREEN    2
182 # define CONSOLE_COLOR_YELLOW   3
183 # define CONSOLE_COLOR_BLUE     4
184 # define CONSOLE_COLOR_MAGENTA  5
185 # define CONSOLE_COLOR_CYAN     6
186 # define CONSOLE_COLOR_GREY     14
187 # define CONSOLE_COLOR_WHITE    15              /* Must remain last / highest */
188 #elif LCD_BPP == LCD_COLOR32
189 #define CONSOLE_COLOR_RED       0x00ff0000
190 #define CONSOLE_COLOR_GREEN     0x0000ff00
191 #define CONSOLE_COLOR_YELLOW    0x00ffff00
192 #define CONSOLE_COLOR_BLUE      0x000000ff
193 #define CONSOLE_COLOR_MAGENTA   0x00ff00ff
194 #define CONSOLE_COLOR_CYAN      0x0000ffff
195 #define CONSOLE_COLOR_GREY      0x00aaaaaa
196 #define CONSOLE_COLOR_BLACK     0x00000000
197 #define CONSOLE_COLOR_WHITE     0x00ffffff      /* Must remain last / highest */
198 #define NBYTES(bit_code)        (NBITS(bit_code) >> 3)
199 #else /* 16bpp color definitions */
200 #define CONSOLE_COLOR_BLACK     0x0000
201 #define CONSOLE_COLOR_WHITE     0xffff          /* Must remain last / highest */
202 #endif /* color definitions */
203
204 #ifndef PAGE_SIZE
205 #define PAGE_SIZE       4096
206 #endif
207
208 #endif  /* _LCD_H_ */