/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * MPC823 and PXA LCD Controller
 *
 * Modeled after video interface by Paolo Scaffardi
 *
 *
 * (C) Copyright 2001
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 */

#ifndef _LCD_H_
#define _LCD_H_
#include <lcd_console.h>
#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
#include <bmp_layout.h>
#include <asm/byteorder.h>
#endif

int bmp_display(ulong addr, int x, int y);
struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
			     void **alloc_addr);

#ifndef CONFIG_DM_VIDEO

extern char lcd_is_enabled;
extern int lcd_line_length;
extern struct vidinfo panel_info;

void lcd_ctrl_init(void *lcdbase);
void lcd_enable(void);
void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
ulong lcd_setmem(ulong addr);

/**
 * Set whether we need to flush the dcache when changing the LCD image. This
 * defaults to off.
 *
 * @param flush		non-zero to flush cache after update, 0 to skip
 */
void lcd_set_flush_dcache(int flush);

#if defined(CONFIG_ATMEL_LCD) || defined(CONFIG_ATMEL_HLCD)
#include <atmel_lcd.h>
#elif defined(CONFIG_EXYNOS_FB)
#include <exynos_lcd.h>
#else
typedef struct vidinfo {
	ushort	vl_col;		/* Number of columns (i.e. 160) */
	ushort	vl_row;		/* Number of rows (i.e. 100) */
	ushort	vl_rot;		/* Rotation of Display (0, 1, 2, 3) */
	u_char	vl_bpix;	/* Bits per pixel, 0 = 1 */
	ushort	*cmap;		/* Pointer to the colormap */
	void	*priv;		/* Pointer to driver-specific data */
} vidinfo_t;

static __maybe_unused ushort *configuration_get_cmap(void)
{
	return panel_info.cmap;
}
#endif

ushort *configuration_get_cmap(void);

extern vidinfo_t panel_info;

void lcd_putc(const char c);
void lcd_puts(const char *s);
void lcd_printf(const char *fmt, ...);
void lcd_clear(void);
int lcd_display_bitmap(ulong bmp_image, int x, int y);

/**
 * Get the width of the LCD in pixels
 *
 * Return: width of LCD in pixels
 */
int lcd_get_pixel_width(void);

/**
 * Get the height of the LCD in pixels
 *
 * Return: height of LCD in pixels
 */
int lcd_get_pixel_height(void);

/**
 * Get the number of text lines/rows on the LCD
 *
 * Return: number of rows
 */
int lcd_get_screen_rows(void);

/**
 * Get the number of text columns on the LCD
 *
 * Return: number of columns
 */
int lcd_get_screen_columns(void);

/**
 * Get the background color of the LCD
 *
 * Return: background color value
 */
int lcd_getbgcolor(void);

/**
 * Get the foreground color of the LCD
 *
 * Return: foreground color value
 */
int lcd_getfgcolor(void);

/**
 * Set the position of the text cursor
 *
 * @param col	Column to place cursor (0 = left side)
 * @param row	Row to place cursor (0 = top line)
 */
void lcd_position_cursor(unsigned col, unsigned row);

/* Allow boards to customize the information displayed */
void lcd_show_board_info(void);

/* Return the size of the LCD frame buffer, and the line length */
int lcd_get_size(int *line_length);

/* Update the LCD / flush the cache */
void lcd_sync(void);

/*
 *  Information about displays we are using. This is for configuring
 *  the LCD controller and memory allocation. Someone has to know what
 *  is connected, as we can't autodetect anything.
 */
#define CONFIG_SYS_HIGH	0	/* Pins are active high			*/
#define CONFIG_SYS_LOW	1	/* Pins are active low			*/

#define LCD_MONOCHROME	0
#define LCD_COLOR2	1
#define LCD_COLOR4	2
#define LCD_COLOR8	3
#define LCD_COLOR16	4
#define LCD_COLOR32	5

/* Default to 8bpp if bit depth not specified */
#ifndef LCD_BPP
#define LCD_BPP			LCD_COLOR8
#endif

#ifndef LCD_DF
#define LCD_DF			1
#endif

/* Calculate nr. of bits per pixel  and nr. of colors */
#define NBITS(bit_code)		(1 << (bit_code))
#define NCOLORS(bit_code)	(1 << NBITS(bit_code))

#if LCD_BPP == LCD_COLOR8
# define CONSOLE_COLOR_BLACK	0
# define CONSOLE_COLOR_RED	1
# define CONSOLE_COLOR_GREEN	2
# define CONSOLE_COLOR_YELLOW	3
# define CONSOLE_COLOR_BLUE	4
# define CONSOLE_COLOR_MAGENTA	5
# define CONSOLE_COLOR_CYAN	6
# define CONSOLE_COLOR_GREY	14
# define CONSOLE_COLOR_WHITE	15		/* Must remain last / highest */
#elif LCD_BPP == LCD_COLOR32
#define CONSOLE_COLOR_RED	0x00ff0000
#define CONSOLE_COLOR_GREEN	0x0000ff00
#define CONSOLE_COLOR_YELLOW	0x00ffff00
#define CONSOLE_COLOR_BLUE	0x000000ff
#define CONSOLE_COLOR_MAGENTA	0x00ff00ff
#define CONSOLE_COLOR_CYAN	0x0000ffff
#define CONSOLE_COLOR_GREY	0x00aaaaaa
#define CONSOLE_COLOR_BLACK	0x00000000
#define CONSOLE_COLOR_WHITE	0x00ffffff	/* Must remain last / highest */
#define NBYTES(bit_code)	(NBITS(bit_code) >> 3)
#else /* 16bpp color definitions */
# define CONSOLE_COLOR_BLACK	0x0000
# define CONSOLE_COLOR_RED	0xF800
# define CONSOLE_COLOR_GREEN	0x07E0
# define CONSOLE_COLOR_YELLOW	0xFFE0
# define CONSOLE_COLOR_BLUE	0x001F
# define CONSOLE_COLOR_MAGENTA	0xF81F
# define CONSOLE_COLOR_CYAN	0x07FF
# define CONSOLE_COLOR_GREY	0xC618
# define CONSOLE_COLOR_WHITE	0xffff		/* Must remain last / highest */
#endif /* color definitions */

#if LCD_BPP == LCD_COLOR16
#define fbptr_t ushort
#elif LCD_BPP == LCD_COLOR32
#define fbptr_t u32
#else
#define fbptr_t uchar
#endif

#ifndef PAGE_SIZE
#define PAGE_SIZE	4096
#endif

#endif /* !CONFIG_DM_VIDEO */

#endif	/* _LCD_H_ */
