blob: 9a4c0da5baca71dc2a9b8513886e80611759c05b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenkfe8c2802002-11-03 00:38:21 +00002/*
wdenk9ca7bbc2004-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 Kiryanovf6ebf6a2014-12-08 17:14:45 +020014#include <lcd_console.h>
Nikita Kiryanovf54c0262015-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 Glass68f5bf32016-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
wdenk4e112c12003-06-03 23:54:09 +000026extern char lcd_is_enabled;
wdenk9ca7bbc2004-10-09 23:25:58 +000027extern int lcd_line_length;
Alessandro Rubini465c45a2009-07-19 17:52:27 +020028extern struct vidinfo panel_info;
29
Jeroen Hofstee729b09e2013-01-12 12:07:56 +000030void lcd_ctrl_init(void *lcdbase);
31void lcd_enable(void);
Jeroen Hofstee729b09e2013-01-12 12:07:56 +000032void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
Simon Glass42cf22f2019-08-01 09:46:38 -060033ulong lcd_setmem(ulong addr);
Alessandro Rubini465c45a2009-07-19 17:52:27 +020034
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
Heiko Schocher65d94db2017-06-07 17:33:09 +020043#if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
Marek Vasut85cc88a2011-11-26 07:20:07 +010044 defined CONFIG_CPU_MONAHANS
Nikita Kiryanovb2604922015-02-03 13:32:20 +020045#include <pxa_lcd.h>
Bo Shen8dd55282012-05-25 00:59:58 +000046#elif defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
Nikita Kiryanovb2604922015-02-03 13:32:20 +020047#include <atmel_lcd.h>
Donghwa Lee0e6f77d2012-04-05 19:36:15 +000048#elif defined(CONFIG_EXYNOS_FB)
Nikita Kiryanovb2604922015-02-03 13:32:20 +020049#include <exynos_lcd.h>
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010050#else
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010051typedef struct vidinfo {
52 ushort vl_col; /* Number of columns (i.e. 160) */
53 ushort vl_row; /* Number of rows (i.e. 100) */
Hannes Petermaiera3c8e862015-03-27 08:01:38 +010054 ushort vl_rot; /* Rotation of Display (0, 1, 2, 3) */
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010055 u_char vl_bpix; /* Bits per pixel, 0 = 1 */
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010056 ushort *cmap; /* Pointer to the colormap */
Guennadi Liakhovetski332d0b52009-02-06 10:37:53 +010057 void *priv; /* Pointer to driver-specific data */
58} vidinfo_t;
Nikita Kiryanovec3685d2015-02-03 13:32:21 +020059
60static __maybe_unused ushort *configuration_get_cmap(void)
61{
62 return panel_info.cmap;
63}
Nikita Kiryanovb2604922015-02-03 13:32:20 +020064#endif
wdenk9ca7bbc2004-10-09 23:25:58 +000065
Nikita Kiryanovec3685d2015-02-03 13:32:21 +020066ushort *configuration_get_cmap(void);
67
Alessandro Rubini249ce8a2009-07-21 14:09:45 +020068extern vidinfo_t panel_info;
69
Nikita Kiryanovf54c0262015-02-03 13:32:29 +020070void lcd_putc(const char c);
71void lcd_puts(const char *s);
72void lcd_printf(const char *fmt, ...);
73void lcd_clear(void);
74int lcd_display_bitmap(ulong bmp_image, int x, int y);
wdenkfe8c2802002-11-03 00:38:21 +000075
Vadim Bendeburya7eaa2f2012-09-28 15:11:13 +000076/**
77 * Get the width of the LCD in pixels
78 *
79 * @return width of LCD in pixels
80 */
81int lcd_get_pixel_width(void);
82
83/**
84 * Get the height of the LCD in pixels
85 *
86 * @return height of LCD in pixels
87 */
88int lcd_get_pixel_height(void);
89
90/**
91 * Get the number of text lines/rows on the LCD
92 *
93 * @return number of rows
94 */
95int lcd_get_screen_rows(void);
96
97/**
98 * Get the number of text columns on the LCD
99 *
100 * @return number of columns
101 */
102int lcd_get_screen_columns(void);
103
104/**
Nikita Kiryanov631d2e12014-12-08 17:14:43 +0200105 * Get the background color of the LCD
106 *
107 * @return background color value
108 */
109int lcd_getbgcolor(void);
110
111/**
112 * Get the foreground color of the LCD
113 *
114 * @return foreground color value
115 */
116int lcd_getfgcolor(void);
117
118/**
Vadim Bendeburya7eaa2f2012-09-28 15:11:13 +0000119 * Set the position of the text cursor
120 *
121 * @param col Column to place cursor (0 = left side)
122 * @param row Row to place cursor (0 = top line)
123 */
124void lcd_position_cursor(unsigned col, unsigned row);
125
Haavard Skinnemoenddbcf952008-09-01 16:21:22 +0200126/* Allow boards to customize the information displayed */
127void lcd_show_board_info(void);
wdenk9ca7bbc2004-10-09 23:25:58 +0000128
Simon Glass599a4df2012-10-17 13:24:54 +0000129/* Return the size of the LCD frame buffer, and the line length */
130int lcd_get_size(int *line_length);
131
Simon Glassb9ddbf42014-02-27 13:26:19 -0700132/* Update the LCD / flush the cache */
133void lcd_sync(void);
134
wdenk9ca7bbc2004-10-09 23:25:58 +0000135/*
136 * Information about displays we are using. This is for configuring
137 * the LCD controller and memory allocation. Someone has to know what
138 * is connected, as we can't autodetect anything.
139 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200140#define CONFIG_SYS_HIGH 0 /* Pins are active high */
Jeroen Hofstee729b09e2013-01-12 12:07:56 +0000141#define CONFIG_SYS_LOW 1 /* Pins are active low */
wdenk9ca7bbc2004-10-09 23:25:58 +0000142
143#define LCD_MONOCHROME 0
144#define LCD_COLOR2 1
145#define LCD_COLOR4 2
146#define LCD_COLOR8 3
147#define LCD_COLOR16 4
Hannes Petermaier95f87df2014-03-07 18:55:40 +0100148#define LCD_COLOR32 5
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200149
wdenk2b9d1862005-07-04 00:03:16 +0000150#if defined(CONFIG_LCD_INFO_BELOW_LOGO)
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200151#define LCD_INFO_X 0
152#define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
wdenk9ca7bbc2004-10-09 23:25:58 +0000153#elif defined(CONFIG_LCD_LOGO)
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200154#define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
155#define LCD_INFO_Y VIDEO_FONT_HEIGHT
wdenk9ca7bbc2004-10-09 23:25:58 +0000156#else
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200157#define LCD_INFO_X VIDEO_FONT_WIDTH
158#define LCD_INFO_Y VIDEO_FONT_HEIGHT
wdenk9ca7bbc2004-10-09 23:25:58 +0000159#endif
160
161/* Default to 8bpp if bit depth not specified */
162#ifndef LCD_BPP
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200163#define LCD_BPP LCD_COLOR8
wdenk9ca7bbc2004-10-09 23:25:58 +0000164#endif
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200165
wdenk9ca7bbc2004-10-09 23:25:58 +0000166#ifndef LCD_DF
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200167#define LCD_DF 1
wdenk9ca7bbc2004-10-09 23:25:58 +0000168#endif
169
170/* Calculate nr. of bits per pixel and nr. of colors */
171#define NBITS(bit_code) (1 << (bit_code))
172#define NCOLORS(bit_code) (1 << NBITS(bit_code))
173
Nikita Kiryanov5aec5812014-12-08 17:14:38 +0200174#if LCD_BPP == LCD_COLOR8
wdenk9ca7bbc2004-10-09 23:25:58 +0000175# define CONSOLE_COLOR_BLACK 0
176# define CONSOLE_COLOR_RED 1
177# define CONSOLE_COLOR_GREEN 2
178# define CONSOLE_COLOR_YELLOW 3
179# define CONSOLE_COLOR_BLUE 4
180# define CONSOLE_COLOR_MAGENTA 5
181# define CONSOLE_COLOR_CYAN 6
182# define CONSOLE_COLOR_GREY 14
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200183# define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */
Hannes Petermaier95f87df2014-03-07 18:55:40 +0100184#elif LCD_BPP == LCD_COLOR32
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200185#define CONSOLE_COLOR_RED 0x00ff0000
186#define CONSOLE_COLOR_GREEN 0x0000ff00
187#define CONSOLE_COLOR_YELLOW 0x00ffff00
188#define CONSOLE_COLOR_BLUE 0x000000ff
189#define CONSOLE_COLOR_MAGENTA 0x00ff00ff
190#define CONSOLE_COLOR_CYAN 0x0000ffff
191#define CONSOLE_COLOR_GREY 0x00aaaaaa
192#define CONSOLE_COLOR_BLACK 0x00000000
193#define CONSOLE_COLOR_WHITE 0x00ffffff /* Must remain last / highest */
194#define NBYTES(bit_code) (NBITS(bit_code) >> 3)
195#else /* 16bpp color definitions */
Andreas Neubacher9f9b56a2016-01-21 13:06:32 +0100196# define CONSOLE_COLOR_BLACK 0x0000
197# define CONSOLE_COLOR_RED 0xF800
198# define CONSOLE_COLOR_GREEN 0x07E0
199# define CONSOLE_COLOR_YELLOW 0xFFE0
200# define CONSOLE_COLOR_BLUE 0x001F
201# define CONSOLE_COLOR_MAGENTA 0xF81F
202# define CONSOLE_COLOR_CYAN 0x07FF
203# define CONSOLE_COLOR_GREY 0xC618
204# define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */
wdenk9ca7bbc2004-10-09 23:25:58 +0000205#endif /* color definitions */
206
Hannes Petermaiera3c8e862015-03-27 08:01:38 +0100207#if LCD_BPP == LCD_COLOR16
208#define fbptr_t ushort
209#elif LCD_BPP == LCD_COLOR32
210#define fbptr_t u32
211#else
212#define fbptr_t uchar
213#endif
214
wdenk9ca7bbc2004-10-09 23:25:58 +0000215#ifndef PAGE_SIZE
Nikita Kiryanovf54c0262015-02-03 13:32:29 +0200216#define PAGE_SIZE 4096
wdenk9ca7bbc2004-10-09 23:25:58 +0000217#endif
218
Simon Glass68f5bf32016-01-18 19:52:16 -0700219#endif /* !CONFIG_DM_VIDEO */
220
wdenk9ca7bbc2004-10-09 23:25:58 +0000221#endif /* _LCD_H_ */