blob: 7570e7ac609c27d99a400c1ef141198a4aa6f0ab [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenkfe8c2802002-11-03 00:38:21 +00002/*
wdenk8655b6f2004-10-09 23:25:58 +00003 * MPC823 and PXA LCD Controller
wdenkfe8c2802002-11-03 00:38:21 +00004 *
5 * Modeled after video interface by Paolo Scaffardi
6 *
7 *
8 * (C) Copyright 2001
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenkfe8c2802002-11-03 00:38:21 +000010 */
11
12#ifndef _LCD_H_
13#define _LCD_H_
Nikita Kiryanov904672e2014-12-08 17:14:45 +020014#include <lcd_console.h>
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +020015#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
16#include <bmp_layout.h>
17#include <asm/byteorder.h>
18#endif
wdenkfe8c2802002-11-03 00:38:21 +000019
Simon Glass6cbf5de2016-01-18 19:52:16 -070020int bmp_display(ulong addr, int x, int y);
21struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
22 void **alloc_addr);
23
24#ifndef CONFIG_DM_VIDEO
25
wdenk682011f2003-06-03 23:54:09 +000026extern char lcd_is_enabled;
wdenk8655b6f2004-10-09 23:25:58 +000027extern int lcd_line_length;
Alessandro Rubini61117222009-07-19 17:52:27 +020028extern struct vidinfo panel_info;
29
Jeroen Hofstee6b035142013-01-12 12:07:56 +000030void lcd_ctrl_init(void *lcdbase);
31void lcd_enable(void);
Jeroen Hofstee6b035142013-01-12 12:07:56 +000032void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
Simon Glass3c1ecde2019-08-01 09:46:38 -060033ulong lcd_setmem(ulong addr);
Alessandro Rubini61117222009-07-19 17:52:27 +020034
Simon Glass9a8efc42012-10-30 13:40:18 +000035/**
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 */
41void lcd_set_flush_dcache(int flush);
42
Tom Rini3135ba62022-05-25 16:13:48 -040043#if defined(CONFIG_CPU_PXA27X) || defined CONFIG_CPU_MONAHANS
Nikita Kiryanovbaaa7dd2015-02-03 13:32:20 +020044#include <pxa_lcd.h>
Bo Shenf6b690e2012-05-25 00:59:58 +000045#elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
Nikita Kiryanovbaaa7dd2015-02-03 13:32:20 +020046#include <atmel_lcd.h>
Donghwa Lee559a05c2012-04-05 19:36:15 +000047#elif defined(CONFIG_EXYNOS_FB)
Nikita Kiryanovbaaa7dd2015-02-03 13:32:20 +020048#include <exynos_lcd.h>
Guennadi Liakhovetskib245e652009-02-06 10:37:53 +010049#else
Guennadi Liakhovetskib245e652009-02-06 10:37:53 +010050typedef struct vidinfo {
51 ushort vl_col; /* Number of columns (i.e. 160) */
52 ushort vl_row; /* Number of rows (i.e. 100) */
Hannes Petermaier604c7d42015-03-27 08:01:38 +010053 ushort vl_rot; /* Rotation of Display (0, 1, 2, 3) */
Guennadi Liakhovetskib245e652009-02-06 10:37:53 +010054 u_char vl_bpix; /* Bits per pixel, 0 = 1 */
Guennadi Liakhovetskib245e652009-02-06 10:37:53 +010055 ushort *cmap; /* Pointer to the colormap */
Guennadi Liakhovetskib245e652009-02-06 10:37:53 +010056 void *priv; /* Pointer to driver-specific data */
57} vidinfo_t;
Nikita Kiryanov38b55082015-02-03 13:32:21 +020058
59static __maybe_unused ushort *configuration_get_cmap(void)
60{
61 return panel_info.cmap;
62}
Nikita Kiryanovbaaa7dd2015-02-03 13:32:20 +020063#endif
wdenk8655b6f2004-10-09 23:25:58 +000064
Nikita Kiryanov38b55082015-02-03 13:32:21 +020065ushort *configuration_get_cmap(void);
66
Alessandro Rubini60e97412009-07-21 14:09:45 +020067extern vidinfo_t panel_info;
68
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +020069void lcd_putc(const char c);
70void lcd_puts(const char *s);
71void lcd_printf(const char *fmt, ...);
72void lcd_clear(void);
73int lcd_display_bitmap(ulong bmp_image, int x, int y);
wdenkfe8c2802002-11-03 00:38:21 +000074
Vadim Bendebury395166c2012-09-28 15:11:13 +000075/**
76 * Get the width of the LCD in pixels
77 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010078 * Return: width of LCD in pixels
Vadim Bendebury395166c2012-09-28 15:11:13 +000079 */
80int lcd_get_pixel_width(void);
81
82/**
83 * Get the height of the LCD in pixels
84 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010085 * Return: height of LCD in pixels
Vadim Bendebury395166c2012-09-28 15:11:13 +000086 */
87int lcd_get_pixel_height(void);
88
89/**
90 * Get the number of text lines/rows on the LCD
91 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010092 * Return: number of rows
Vadim Bendebury395166c2012-09-28 15:11:13 +000093 */
94int lcd_get_screen_rows(void);
95
96/**
97 * Get the number of text columns on the LCD
98 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010099 * Return: number of columns
Vadim Bendebury395166c2012-09-28 15:11:13 +0000100 */
101int lcd_get_screen_columns(void);
102
103/**
Nikita Kiryanov4d036342014-12-08 17:14:43 +0200104 * Get the background color of the LCD
105 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +0100106 * Return: background color value
Nikita Kiryanov4d036342014-12-08 17:14:43 +0200107 */
108int lcd_getbgcolor(void);
109
110/**
111 * Get the foreground color of the LCD
112 *
Heinrich Schuchardt185f8122022-01-19 18:05:50 +0100113 * Return: foreground color value
Nikita Kiryanov4d036342014-12-08 17:14:43 +0200114 */
115int lcd_getfgcolor(void);
116
117/**
Vadim Bendebury395166c2012-09-28 15:11:13 +0000118 * Set the position of the text cursor
119 *
120 * @param col Column to place cursor (0 = left side)
121 * @param row Row to place cursor (0 = top line)
122 */
123void lcd_position_cursor(unsigned col, unsigned row);
124
Haavard Skinnemoen6b59e032008-09-01 16:21:22 +0200125/* Allow boards to customize the information displayed */
126void lcd_show_board_info(void);
wdenk8655b6f2004-10-09 23:25:58 +0000127
Simon Glass676d3192012-10-17 13:24:54 +0000128/* Return the size of the LCD frame buffer, and the line length */
129int lcd_get_size(int *line_length);
130
Simon Glass7d95f2a2014-02-27 13:26:19 -0700131/* Update the LCD / flush the cache */
132void lcd_sync(void);
133
wdenk8655b6f2004-10-09 23:25:58 +0000134/*
135 * Information about displays we are using. This is for configuring
136 * the LCD controller and memory allocation. Someone has to know what
137 * is connected, as we can't autodetect anything.
138 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200139#define CONFIG_SYS_HIGH 0 /* Pins are active high */
Jeroen Hofstee6b035142013-01-12 12:07:56 +0000140#define CONFIG_SYS_LOW 1 /* Pins are active low */
wdenk8655b6f2004-10-09 23:25:58 +0000141
142#define LCD_MONOCHROME 0
143#define LCD_COLOR2 1
144#define LCD_COLOR4 2
145#define LCD_COLOR8 3
146#define LCD_COLOR16 4
Hannes Petermaier57d76a82014-03-07 18:55:40 +0100147#define LCD_COLOR32 5
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200148
wdenk88804d12005-07-04 00:03:16 +0000149#if defined(CONFIG_LCD_INFO_BELOW_LOGO)
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200150#define LCD_INFO_X 0
151#define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
wdenk8655b6f2004-10-09 23:25:58 +0000152#elif defined(CONFIG_LCD_LOGO)
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200153#define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
154#define LCD_INFO_Y VIDEO_FONT_HEIGHT
wdenk8655b6f2004-10-09 23:25:58 +0000155#else
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200156#define LCD_INFO_X VIDEO_FONT_WIDTH
157#define LCD_INFO_Y VIDEO_FONT_HEIGHT
wdenk8655b6f2004-10-09 23:25:58 +0000158#endif
159
160/* Default to 8bpp if bit depth not specified */
161#ifndef LCD_BPP
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200162#define LCD_BPP LCD_COLOR8
wdenk8655b6f2004-10-09 23:25:58 +0000163#endif
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200164
wdenk8655b6f2004-10-09 23:25:58 +0000165#ifndef LCD_DF
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200166#define LCD_DF 1
wdenk8655b6f2004-10-09 23:25:58 +0000167#endif
168
169/* Calculate nr. of bits per pixel and nr. of colors */
170#define NBITS(bit_code) (1 << (bit_code))
171#define NCOLORS(bit_code) (1 << NBITS(bit_code))
172
Nikita Kiryanovf4469f52014-12-08 17:14:38 +0200173#if LCD_BPP == LCD_COLOR8
wdenk8655b6f2004-10-09 23:25:58 +0000174# define CONSOLE_COLOR_BLACK 0
175# define CONSOLE_COLOR_RED 1
176# define CONSOLE_COLOR_GREEN 2
177# define CONSOLE_COLOR_YELLOW 3
178# define CONSOLE_COLOR_BLUE 4
179# define CONSOLE_COLOR_MAGENTA 5
180# define CONSOLE_COLOR_CYAN 6
181# define CONSOLE_COLOR_GREY 14
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200182# define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
Hannes Petermaier57d76a82014-03-07 18:55:40 +0100183#elif LCD_BPP == LCD_COLOR32
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200184#define CONSOLE_COLOR_RED 0x00ff0000
185#define CONSOLE_COLOR_GREEN 0x0000ff00
186#define CONSOLE_COLOR_YELLOW 0x00ffff00
187#define CONSOLE_COLOR_BLUE 0x000000ff
188#define CONSOLE_COLOR_MAGENTA 0x00ff00ff
189#define CONSOLE_COLOR_CYAN 0x0000ffff
190#define CONSOLE_COLOR_GREY 0x00aaaaaa
191#define CONSOLE_COLOR_BLACK 0x00000000
192#define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest */
193#define NBYTES(bit_code) (NBITS(bit_code) >> 3)
194#else /* 16bpp color definitions */
Andreas Neubachere32951b2016-01-21 13:06:32 +0100195# define CONSOLE_COLOR_BLACK 0x0000
196# define CONSOLE_COLOR_RED 0xF800
197# define CONSOLE_COLOR_GREEN 0x07E0
198# define CONSOLE_COLOR_YELLOW 0xFFE0
199# define CONSOLE_COLOR_BLUE 0x001F
200# define CONSOLE_COLOR_MAGENTA 0xF81F
201# define CONSOLE_COLOR_CYAN 0x07FF
202# define CONSOLE_COLOR_GREY 0xC618
203# define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
wdenk8655b6f2004-10-09 23:25:58 +0000204#endif /* color definitions */
205
Hannes Petermaier604c7d42015-03-27 08:01:38 +0100206#if LCD_BPP == LCD_COLOR16
207#define fbptr_t ushort
208#elif LCD_BPP == LCD_COLOR32
209#define fbptr_t u32
210#else
211#define fbptr_t uchar
212#endif
213
wdenk8655b6f2004-10-09 23:25:58 +0000214#ifndef PAGE_SIZE
Nikita Kiryanovc8d2feb2015-02-03 13:32:29 +0200215#define PAGE_SIZE 4096
wdenk8655b6f2004-10-09 23:25:58 +0000216#endif
217
Simon Glass6cbf5de2016-01-18 19:52:16 -0700218#endif /* !CONFIG_DM_VIDEO */
219
wdenk8655b6f2004-10-09 23:25:58 +0000220#endif /* _LCD_H_ */