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