blob: fbba6a27f9f8b81239d5ede95f341bea118dc809 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
wdenk9ca7bbc2004-10-09 23:25:58 +00002 * MPC823 and PXA LCD Controller
wdenkfe8c2802002-11-03 00:38:21 +00003 *
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 Denkbd8ec7e2013-10-07 13:07:26 +020010 * SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +000011 */
12
13#ifndef _LCD_H_
14#define _LCD_H_
Nikita Kiryanovf6ebf6a2014-12-08 17:14:45 +020015#include <lcd_console.h>
wdenkfe8c2802002-11-03 00:38:21 +000016
wdenk4e112c12003-06-03 23:54:09 +000017extern char lcd_is_enabled;
18
wdenk9ca7bbc2004-10-09 23:25:58 +000019extern int lcd_line_length;
wdenk9ca7bbc2004-10-09 23:25:58 +000020
Alessandro Rubini465c45a2009-07-19 17:52:27 +020021extern struct vidinfo panel_info;
22
Jeroen Hofstee729b09e2013-01-12 12:07:56 +000023void lcd_ctrl_init(void *lcdbase);
24void lcd_enable(void);
Alessandro Rubini465c45a2009-07-19 17:52:27 +020025
26/* setcolreg used in 8bpp/16bpp; initcolregs used in monochrome */
Jeroen Hofstee729b09e2013-01-12 12:07:56 +000027void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
28void lcd_initcolregs(void);
Alessandro Rubini465c45a2009-07-19 17:52:27 +020029
30/* gunzip_bmp used if CONFIG_VIDEO_BMP_GZIP */
Piotr Wilczeke59e0ff2013-06-05 08:14:30 +020031struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
32 void **alloc_addr);
Jeroen Hofstee729b09e2013-01-12 12:07:56 +000033int bmp_display(ulong addr, int x, int y);
wdenk9ca7bbc2004-10-09 23:25:58 +000034
Simon Glassef45ffd2012-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
wdenk9ca7bbc2004-10-09 23:25:58 +000043#if defined CONFIG_MPC823
Nikita Kiryanovb2604922015-02-03 13:32:20 +020044#include <mpc823_lcd.h>
Marek Vasut85cc88a2011-11-26 07:20:07 +010045#elif defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
46 defined CONFIG_CPU_MONAHANS
Nikita Kiryanovb2604922015-02-03 13:32:20 +020047#include <pxa_lcd.h>
Bo Shen8dd55282012-05-25 00:59:58 +000048#elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
Nikita Kiryanovb2604922015-02-03 13:32:20 +020049#include <atmel_lcd.h>
Donghwa Lee0e6f77d2012-04-05 19:36:15 +000050#elif defined(CONFIG_EXYNOS_FB)
Nikita Kiryanovb2604922015-02-03 13:32:20 +020051#include <exynos_lcd.h>
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010052#else
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010053typedef struct vidinfo {
54 ushort vl_col; /* Number of columns (i.e. 160) */
55 ushort vl_row; /* Number of rows (i.e. 100) */
56
57 u_char vl_bpix; /* Bits per pixel, 0 = 1 */
58
59 ushort *cmap; /* Pointer to the colormap */
60
61 void *priv; /* Pointer to driver-specific data */
62} vidinfo_t;
Nikita Kiryanovb2604922015-02-03 13:32:20 +020063#endif
wdenk9ca7bbc2004-10-09 23:25:58 +000064
Alessandro Rubini249ce8a2009-07-21 14:09:45 +020065extern vidinfo_t panel_info;
66
wdenkfe8c2802002-11-03 00:38:21 +000067/* Video functions */
68
Jeroen Hofstee729b09e2013-01-12 12:07:56 +000069void lcd_putc(const char c);
70void lcd_puts(const char *s);
71void lcd_printf(const char *fmt, ...);
Che-Liang Chiou2444b172011-10-20 23:07:03 +000072void lcd_clear(void);
73int lcd_display_bitmap(ulong bmp_image, int x, int y);
wdenkfe8c2802002-11-03 00:38:21 +000074
Vadim Bendeburya7eaa2f2012-09-28 15:11:13 +000075/**
76 * Get the width of the LCD in pixels
77 *
78 * @return width of LCD in pixels
79 */
80int lcd_get_pixel_width(void);
81
82/**
83 * Get the height of the LCD in pixels
84 *
85 * @return height of LCD in pixels
86 */
87int lcd_get_pixel_height(void);
88
89/**
90 * Get the number of text lines/rows on the LCD
91 *
92 * @return number of rows
93 */
94int lcd_get_screen_rows(void);
95
96/**
97 * Get the number of text columns on the LCD
98 *
99 * @return number of columns
100 */
101int lcd_get_screen_columns(void);
102
103/**
Nikita Kiryanov631d2e12014-12-08 17:14:43 +0200104 * Get the background color of the LCD
105 *
106 * @return background color value
107 */
108int lcd_getbgcolor(void);
109
110/**
111 * Get the foreground color of the LCD
112 *
113 * @return foreground color value
114 */
115int lcd_getfgcolor(void);
116
117/**
Vadim Bendeburya7eaa2f2012-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 Skinnemoenddbcf952008-09-01 16:21:22 +0200125/* Allow boards to customize the information displayed */
126void lcd_show_board_info(void);
wdenk9ca7bbc2004-10-09 23:25:58 +0000127
Simon Glass599a4df2012-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
Stephen Warrenefe64282013-05-27 18:31:17 +0000131int lcd_dt_simplefb_add_node(void *blob);
132int lcd_dt_simplefb_enable_existing_node(void *blob);
133
Simon Glassb9ddbf42014-02-27 13:26:19 -0700134/* Update the LCD / flush the cache */
135void lcd_sync(void);
136
wdenk9ca7bbc2004-10-09 23:25:58 +0000137/************************************************************************/
138/* ** BITMAP DISPLAY SUPPORT */
139/************************************************************************/
Jon Loeliger2517d972007-07-09 17:15:49 -0500140#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
wdenk9ca7bbc2004-10-09 23:25:58 +0000141# include <bmp_layout.h>
142# include <asm/byteorder.h>
Jon Loeliger2517d972007-07-09 17:15:49 -0500143#endif
wdenk9ca7bbc2004-10-09 23:25:58 +0000144
wdenk9ca7bbc2004-10-09 23:25:58 +0000145/*
146 * Information about displays we are using. This is for configuring
147 * the LCD controller and memory allocation. Someone has to know what
148 * is connected, as we can't autodetect anything.
149 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200150#define CONFIG_SYS_HIGH 0 /* Pins are active high */
Jeroen Hofstee729b09e2013-01-12 12:07:56 +0000151#define CONFIG_SYS_LOW 1 /* Pins are active low */
wdenk9ca7bbc2004-10-09 23:25:58 +0000152
153#define LCD_MONOCHROME 0
154#define LCD_COLOR2 1
155#define LCD_COLOR4 2
156#define LCD_COLOR8 3
157#define LCD_COLOR16 4
Hannes Petermaier95f87df2014-03-07 18:55:40 +0100158#define LCD_COLOR32 5
wdenk9ca7bbc2004-10-09 23:25:58 +0000159/*----------------------------------------------------------------------*/
wdenk2b9d1862005-07-04 00:03:16 +0000160#if defined(CONFIG_LCD_INFO_BELOW_LOGO)
wdenk9ca7bbc2004-10-09 23:25:58 +0000161# define LCD_INFO_X 0
162# define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
163#elif defined(CONFIG_LCD_LOGO)
164# define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
Jeroen Hofstee729b09e2013-01-12 12:07:56 +0000165# define LCD_INFO_Y VIDEO_FONT_HEIGHT
wdenk9ca7bbc2004-10-09 23:25:58 +0000166#else
Jeroen Hofstee729b09e2013-01-12 12:07:56 +0000167# define LCD_INFO_X VIDEO_FONT_WIDTH
168# define LCD_INFO_Y VIDEO_FONT_HEIGHT
wdenk9ca7bbc2004-10-09 23:25:58 +0000169#endif
170
171/* Default to 8bpp if bit depth not specified */
172#ifndef LCD_BPP
173# define LCD_BPP LCD_COLOR8
174#endif
175#ifndef LCD_DF
176# define LCD_DF 1
177#endif
178
179/* Calculate nr. of bits per pixel and nr. of colors */
180#define NBITS(bit_code) (1 << (bit_code))
181#define NCOLORS(bit_code) (1 << NBITS(bit_code))
182
183/************************************************************************/
184/* ** CONSOLE CONSTANTS */
185/************************************************************************/
Nikita Kiryanov5aec5812014-12-08 17:14:38 +0200186#if LCD_BPP == LCD_COLOR8
wdenk9ca7bbc2004-10-09 23:25:58 +0000187
188/*
189 * 8bpp color definitions
190 */
191# define CONSOLE_COLOR_BLACK 0
192# define CONSOLE_COLOR_RED 1
193# define CONSOLE_COLOR_GREEN 2
194# define CONSOLE_COLOR_YELLOW 3
195# define CONSOLE_COLOR_BLUE 4
196# define CONSOLE_COLOR_MAGENTA 5
197# define CONSOLE_COLOR_CYAN 6
198# define CONSOLE_COLOR_GREY 14
199# define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
200
Hannes Petermaier95f87df2014-03-07 18:55:40 +0100201#elif LCD_BPP == LCD_COLOR32
202/*
203 * 32bpp color definitions
204 */
205# define CONSOLE_COLOR_RED 0x00ff0000
206# define CONSOLE_COLOR_GREEN 0x0000ff00
207# define CONSOLE_COLOR_YELLOW 0x00ffff00
208# define CONSOLE_COLOR_BLUE 0x000000ff
209# define CONSOLE_COLOR_MAGENTA 0x00ff00ff
210# define CONSOLE_COLOR_CYAN 0x0000ffff
211# define CONSOLE_COLOR_GREY 0x00aaaaaa
212# define CONSOLE_COLOR_BLACK 0x00000000
213# define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest*/
214# define NBYTES(bit_code) (NBITS(bit_code) >> 3)
215
wdenk9ca7bbc2004-10-09 23:25:58 +0000216#else
217
218/*
219 * 16bpp color definitions
220 */
221# define CONSOLE_COLOR_BLACK 0x0000
222# define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
223
224#endif /* color definitions */
225
wdenk9ca7bbc2004-10-09 23:25:58 +0000226/************************************************************************/
227#ifndef PAGE_SIZE
228# define PAGE_SIZE 4096
229#endif
230
231/************************************************************************/
wdenk9ca7bbc2004-10-09 23:25:58 +0000232
233#endif /* _LCD_H_ */