Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 2 | /* |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 3 | * MPC823 and PXA LCD Controller |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 4 | * |
| 5 | * Modeled after video interface by Paolo Scaffardi |
| 6 | * |
| 7 | * |
| 8 | * (C) Copyright 2001 |
| 9 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef _LCD_H_ |
| 13 | #define _LCD_H_ |
Nikita Kiryanov | 904672e | 2014-12-08 17:14:45 +0200 | [diff] [blame] | 14 | #include <lcd_console.h> |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 15 | #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
| 16 | #include <bmp_layout.h> |
| 17 | #include <asm/byteorder.h> |
| 18 | #endif |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 19 | |
Simon Glass | 6cbf5de | 2016-01-18 19:52:16 -0700 | [diff] [blame] | 20 | int bmp_display(ulong addr, int x, int y); |
| 21 | struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, |
| 22 | void **alloc_addr); |
| 23 | |
| 24 | #ifndef CONFIG_DM_VIDEO |
| 25 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 26 | extern char lcd_is_enabled; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 27 | extern int lcd_line_length; |
Alessandro Rubini | 6111722 | 2009-07-19 17:52:27 +0200 | [diff] [blame] | 28 | extern struct vidinfo panel_info; |
| 29 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 30 | void lcd_ctrl_init(void *lcdbase); |
| 31 | void lcd_enable(void); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 32 | void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue); |
Simon Glass | 3c1ecde | 2019-08-01 09:46:38 -0600 | [diff] [blame] | 33 | ulong lcd_setmem(ulong addr); |
Alessandro Rubini | 6111722 | 2009-07-19 17:52:27 +0200 | [diff] [blame] | 34 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 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 | |
Tom Rini | a457ebd | 2022-06-25 11:02:42 -0400 | [diff] [blame] | 43 | #if defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD) |
Nikita Kiryanov | baaa7dd | 2015-02-03 13:32:20 +0200 | [diff] [blame] | 44 | #include <atmel_lcd.h> |
Donghwa Lee | 559a05c | 2012-04-05 19:36:15 +0000 | [diff] [blame] | 45 | #elif defined(CONFIG_EXYNOS_FB) |
Nikita Kiryanov | baaa7dd | 2015-02-03 13:32:20 +0200 | [diff] [blame] | 46 | #include <exynos_lcd.h> |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 47 | #else |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 48 | typedef struct vidinfo { |
| 49 | ushort vl_col; /* Number of columns (i.e. 160) */ |
| 50 | ushort vl_row; /* Number of rows (i.e. 100) */ |
Hannes Petermaier | 604c7d4 | 2015-03-27 08:01:38 +0100 | [diff] [blame] | 51 | ushort vl_rot; /* Rotation of Display (0, 1, 2, 3) */ |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 52 | u_char vl_bpix; /* Bits per pixel, 0 = 1 */ |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 53 | ushort *cmap; /* Pointer to the colormap */ |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 54 | void *priv; /* Pointer to driver-specific data */ |
| 55 | } vidinfo_t; |
Nikita Kiryanov | 38b5508 | 2015-02-03 13:32:21 +0200 | [diff] [blame] | 56 | |
| 57 | static __maybe_unused ushort *configuration_get_cmap(void) |
| 58 | { |
| 59 | return panel_info.cmap; |
| 60 | } |
Nikita Kiryanov | baaa7dd | 2015-02-03 13:32:20 +0200 | [diff] [blame] | 61 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 62 | |
Nikita Kiryanov | 38b5508 | 2015-02-03 13:32:21 +0200 | [diff] [blame] | 63 | ushort *configuration_get_cmap(void); |
| 64 | |
Alessandro Rubini | 60e9741 | 2009-07-21 14:09:45 +0200 | [diff] [blame] | 65 | extern vidinfo_t panel_info; |
| 66 | |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 67 | void lcd_putc(const char c); |
| 68 | void lcd_puts(const char *s); |
| 69 | void lcd_printf(const char *fmt, ...); |
| 70 | void lcd_clear(void); |
| 71 | int lcd_display_bitmap(ulong bmp_image, int x, int y); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 72 | |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 73 | /** |
| 74 | * Get the width of the LCD in pixels |
| 75 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 76 | * Return: width of LCD in pixels |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 77 | */ |
| 78 | int lcd_get_pixel_width(void); |
| 79 | |
| 80 | /** |
| 81 | * Get the height of the LCD in pixels |
| 82 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 83 | * Return: height of LCD in pixels |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 84 | */ |
| 85 | int lcd_get_pixel_height(void); |
| 86 | |
| 87 | /** |
| 88 | * Get the number of text lines/rows on the LCD |
| 89 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 90 | * Return: number of rows |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 91 | */ |
| 92 | int lcd_get_screen_rows(void); |
| 93 | |
| 94 | /** |
| 95 | * Get the number of text columns on the LCD |
| 96 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 97 | * Return: number of columns |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 98 | */ |
| 99 | int lcd_get_screen_columns(void); |
| 100 | |
| 101 | /** |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 102 | * Get the background color of the LCD |
| 103 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 104 | * Return: background color value |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 105 | */ |
| 106 | int lcd_getbgcolor(void); |
| 107 | |
| 108 | /** |
| 109 | * Get the foreground color of the LCD |
| 110 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 111 | * Return: foreground color value |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 112 | */ |
| 113 | int lcd_getfgcolor(void); |
| 114 | |
| 115 | /** |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 116 | * Set the position of the text cursor |
| 117 | * |
| 118 | * @param col Column to place cursor (0 = left side) |
| 119 | * @param row Row to place cursor (0 = top line) |
| 120 | */ |
| 121 | void lcd_position_cursor(unsigned col, unsigned row); |
| 122 | |
Haavard Skinnemoen | 6b59e03 | 2008-09-01 16:21:22 +0200 | [diff] [blame] | 123 | /* Allow boards to customize the information displayed */ |
| 124 | void lcd_show_board_info(void); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 125 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 126 | /* Return the size of the LCD frame buffer, and the line length */ |
| 127 | int lcd_get_size(int *line_length); |
| 128 | |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 129 | /* Update the LCD / flush the cache */ |
| 130 | void lcd_sync(void); |
| 131 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 132 | /* |
| 133 | * Information about displays we are using. This is for configuring |
| 134 | * the LCD controller and memory allocation. Someone has to know what |
| 135 | * is connected, as we can't autodetect anything. |
| 136 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 137 | #define CONFIG_SYS_HIGH 0 /* Pins are active high */ |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 138 | #define CONFIG_SYS_LOW 1 /* Pins are active low */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 139 | |
| 140 | #define LCD_MONOCHROME 0 |
| 141 | #define LCD_COLOR2 1 |
| 142 | #define LCD_COLOR4 2 |
| 143 | #define LCD_COLOR8 3 |
| 144 | #define LCD_COLOR16 4 |
Hannes Petermaier | 57d76a8 | 2014-03-07 18:55:40 +0100 | [diff] [blame] | 145 | #define LCD_COLOR32 5 |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 146 | |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 147 | #if defined(CONFIG_LCD_INFO_BELOW_LOGO) |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 148 | #define LCD_INFO_X 0 |
| 149 | #define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 150 | #elif defined(CONFIG_LCD_LOGO) |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 151 | #define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH) |
| 152 | #define LCD_INFO_Y VIDEO_FONT_HEIGHT |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 153 | #else |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 154 | #define LCD_INFO_X VIDEO_FONT_WIDTH |
| 155 | #define LCD_INFO_Y VIDEO_FONT_HEIGHT |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 156 | #endif |
| 157 | |
| 158 | /* Default to 8bpp if bit depth not specified */ |
| 159 | #ifndef LCD_BPP |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 160 | #define LCD_BPP LCD_COLOR8 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 161 | #endif |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 162 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 163 | #ifndef LCD_DF |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 164 | #define LCD_DF 1 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 165 | #endif |
| 166 | |
| 167 | /* Calculate nr. of bits per pixel and nr. of colors */ |
| 168 | #define NBITS(bit_code) (1 << (bit_code)) |
| 169 | #define NCOLORS(bit_code) (1 << NBITS(bit_code)) |
| 170 | |
Nikita Kiryanov | f4469f5 | 2014-12-08 17:14:38 +0200 | [diff] [blame] | 171 | #if LCD_BPP == LCD_COLOR8 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 172 | # define CONSOLE_COLOR_BLACK 0 |
| 173 | # define CONSOLE_COLOR_RED 1 |
| 174 | # define CONSOLE_COLOR_GREEN 2 |
| 175 | # define CONSOLE_COLOR_YELLOW 3 |
| 176 | # define CONSOLE_COLOR_BLUE 4 |
| 177 | # define CONSOLE_COLOR_MAGENTA 5 |
| 178 | # define CONSOLE_COLOR_CYAN 6 |
| 179 | # define CONSOLE_COLOR_GREY 14 |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 180 | # define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */ |
Hannes Petermaier | 57d76a8 | 2014-03-07 18:55:40 +0100 | [diff] [blame] | 181 | #elif LCD_BPP == LCD_COLOR32 |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 182 | #define CONSOLE_COLOR_RED 0x00ff0000 |
| 183 | #define CONSOLE_COLOR_GREEN 0x0000ff00 |
| 184 | #define CONSOLE_COLOR_YELLOW 0x00ffff00 |
| 185 | #define CONSOLE_COLOR_BLUE 0x000000ff |
| 186 | #define CONSOLE_COLOR_MAGENTA 0x00ff00ff |
| 187 | #define CONSOLE_COLOR_CYAN 0x0000ffff |
| 188 | #define CONSOLE_COLOR_GREY 0x00aaaaaa |
| 189 | #define CONSOLE_COLOR_BLACK 0x00000000 |
| 190 | #define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest */ |
| 191 | #define NBYTES(bit_code) (NBITS(bit_code) >> 3) |
| 192 | #else /* 16bpp color definitions */ |
Andreas Neubacher | e32951b | 2016-01-21 13:06:32 +0100 | [diff] [blame] | 193 | # define CONSOLE_COLOR_BLACK 0x0000 |
| 194 | # define CONSOLE_COLOR_RED 0xF800 |
| 195 | # define CONSOLE_COLOR_GREEN 0x07E0 |
| 196 | # define CONSOLE_COLOR_YELLOW 0xFFE0 |
| 197 | # define CONSOLE_COLOR_BLUE 0x001F |
| 198 | # define CONSOLE_COLOR_MAGENTA 0xF81F |
| 199 | # define CONSOLE_COLOR_CYAN 0x07FF |
| 200 | # define CONSOLE_COLOR_GREY 0xC618 |
| 201 | # define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 202 | #endif /* color definitions */ |
| 203 | |
Hannes Petermaier | 604c7d4 | 2015-03-27 08:01:38 +0100 | [diff] [blame] | 204 | #if LCD_BPP == LCD_COLOR16 |
| 205 | #define fbptr_t ushort |
| 206 | #elif LCD_BPP == LCD_COLOR32 |
| 207 | #define fbptr_t u32 |
| 208 | #else |
| 209 | #define fbptr_t uchar |
| 210 | #endif |
| 211 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 212 | #ifndef PAGE_SIZE |
Nikita Kiryanov | c8d2feb | 2015-02-03 13:32:29 +0200 | [diff] [blame] | 213 | #define PAGE_SIZE 4096 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 214 | #endif |
| 215 | |
Simon Glass | 6cbf5de | 2016-01-18 19:52:16 -0700 | [diff] [blame] | 216 | #endif /* !CONFIG_DM_VIDEO */ |
| 217 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 218 | #endif /* _LCD_H_ */ |