NanoPayload

Annotated stage2/jzlcd.h

224:d41c05accd39
2017-07-09 Paul Boddie Parameterised LCD controller initialisation, allowing addresses to be passed in rather than being calculated within the function. Changed various descriptor structure member names.
paul@33 1
/*
paul@38 2
 * U-Boot and JzRISC LCD controller definitions
paul@33 3
 *
paul@38 4
 * Copyright (C) 2001 Wolfgang Denk, DENX Software Engineering, wd@denx.de.
paul@33 5
 * Copyright (C) 2005-2007, Ingenic Semiconductor Inc.
paul@38 6
 * Copyright (C) Xiangfu Liu <xiangfu@sharism.cc>
paul@217 7
 * Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
paul@33 8
 *
paul@33 9
 * This program is free software; you can redistribute it and/or
paul@33 10
 * modify it under the terms of the GNU General Public License as
paul@33 11
 * published by the Free Software Foundation; either version 2 of
paul@33 12
 * the License, or (at your option) any later version.
paul@33 13
 *
paul@33 14
 * This program is distributed in the hope that it will be useful,
paul@33 15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@33 16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
paul@33 17
 * GNU General Public License for more details.
paul@33 18
 *
paul@33 19
 * You should have received a copy of the GNU General Public License
paul@33 20
 * along with this program; if not, write to the Free Software
paul@42 21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@42 22
 * Boston, MA  02110-1301, USA
paul@33 23
 */
paul@33 24
paul@33 25
#ifndef __JZLCD_H__
paul@33 26
#define __JZLCD_H__
paul@33 27
paul@217 28
#include <stdint.h>
paul@106 29
paul@217 30
void lcd_set_bpp(uint8_t bpp);
paul@217 31
uint32_t lcd_ctrl_init();
paul@195 32
void lcd_enable();
paul@195 33
void lcd_disable();
paul@33 34
paul@223 35
/* Framebuffer characteristics. */
paul@223 36
paul@33 37
struct jzfb_info {
paul@217 38
	uint32_t cfg;	/* panel mode and pin usage etc. */
paul@223 39
	uint16_t w;	/* display width in pixels */
paul@223 40
	uint16_t h;	/* display height in pixels */
paul@223 41
	uint8_t bpp;	/* bits per pixel */
paul@223 42
	uint32_t fclk;	/* frame clock */
paul@223 43
	uint32_t hsw;	/* hsync width, in pixel clock */
paul@217 44
	uint32_t vsw;	/* vsync width, in line count */
paul@223 45
	uint32_t elw;	/* end of line, in pixel clock */
paul@223 46
	uint32_t blw;	/* begin of line, in pixel clock */
paul@217 47
	uint32_t efw;	/* end of frame, in line count */
paul@217 48
	uint32_t bfw;	/* begin of frame, in line count */
paul@33 49
};
paul@33 50
paul@223 51
/* LCD controller stucture for jz4740. */
paul@223 52
paul@38 53
struct jz_fb_dma_descriptor {
paul@223 54
	struct jz_fb_dma_descriptor *fdadr;	/* frame descriptor address register */
paul@223 55
	uint32_t fsadr;				/* frame source address register */
paul@223 56
	uint32_t fidr;				/* frame identifier register */
paul@223 57
	uint32_t ldcmd;				/* command register */
paul@38 58
};
paul@38 59
paul@223 60
/* Framebuffer and controller memory information. */
paul@223 61
paul@221 62
struct jz_mem_info {
paul@38 63
paul@223 64
	/* DMA descriptor references (updated for transfers). */
paul@223 65
paul@224 66
	struct jz_fb_dma_descriptor *fdadr0;	/* physical address of frame descriptor */
paul@224 67
	struct jz_fb_dma_descriptor *fdadr1;	/* physical address of frame/palette descriptor */
paul@38 68
paul@223 69
	/* DMA descriptor references (indicating allocated regions). */
paul@223 70
paul@224 71
	struct jz_fb_dma_descriptor *dmadesc_fb0;
paul@224 72
	struct jz_fb_dma_descriptor *dmadesc_fb1;
paul@38 73
	struct jz_fb_dma_descriptor *dmadesc_palette;
paul@93 74
paul@223 75
	uint32_t screen;			/* address of first frame buffer (base of memory used) */
paul@217 76
	uint32_t palette;			/* address of palette memory */
paul@223 77
	uint32_t total;				/* total memory used */
paul@38 78
};
paul@38 79
paul@223 80
/* Display characteristics and memory resources. */
paul@223 81
paul@38 82
typedef struct vidinfo {
paul@223 83
	struct jzfb_info *jz_fb;		/* framebuffer and panel properties */
paul@223 84
	struct jz_mem_info jz_mem;		/* framebuffer memory information */
paul@223 85
	void *lcd;				/* address of LCD controller registers */
paul@38 86
} vidinfo_t;
paul@38 87
paul@100 88
/* Alignment/rounding macros. */
paul@100 89
paul@100 90
#define ALIGN(x,a)              __ALIGN_MASK((x),(typeof(x))(a)-1)
paul@100 91
#define __ALIGN_MASK(x,mask)    (((x)+(mask))&~(mask))
paul@100 92
paul@38 93
/* Transfer and display types. */
paul@38 94
paul@33 95
#define MODE_MASK		0x0f
paul@33 96
#define MODE_TFT_GEN		0x00
paul@33 97
#define MODE_TFT_SHARP		0x01
paul@33 98
#define MODE_TFT_CASIO		0x02
paul@33 99
#define MODE_TFT_SAMSUNG	0x03
paul@33 100
#define MODE_CCIR656_NONINT	0x04
paul@33 101
#define MODE_CCIR656_INT	0x05
paul@33 102
#define MODE_STN_COLOR_SINGLE	0x08
paul@33 103
#define MODE_STN_MONO_SINGLE	0x09
paul@33 104
#define MODE_STN_COLOR_DUAL	0x0a
paul@33 105
#define MODE_STN_MONO_DUAL	0x0b
paul@33 106
#define MODE_8BIT_SERIAL_TFT    0x0c
paul@33 107
paul@33 108
#define MODE_TFT_18BIT          (1<<7)
paul@33 109
paul@33 110
#define STN_DAT_PIN1	(0x00 << 4)
paul@33 111
#define STN_DAT_PIN2	(0x01 << 4)
paul@33 112
#define STN_DAT_PIN4	(0x02 << 4)
paul@33 113
#define STN_DAT_PIN8	(0x03 << 4)
paul@33 114
#define STN_DAT_PINMASK	STN_DAT_PIN8
paul@33 115
paul@33 116
#define STFT_PSHI	(1 << 15)
paul@33 117
#define STFT_CLSHI	(1 << 14)
paul@33 118
#define STFT_SPLHI	(1 << 13)
paul@33 119
#define STFT_REVHI	(1 << 12)
paul@33 120
paul@33 121
#define SYNC_MASTER	(0 << 16)
paul@33 122
#define SYNC_SLAVE	(1 << 16)
paul@33 123
paul@33 124
#define DE_P		(0 << 9)
paul@33 125
#define DE_N		(1 << 9)
paul@33 126
paul@33 127
#define PCLK_P		(0 << 10)
paul@33 128
#define PCLK_N		(1 << 10)
paul@33 129
paul@33 130
#define HSYNC_P		(0 << 11)
paul@33 131
#define HSYNC_N		(1 << 11)
paul@33 132
paul@33 133
#define VSYNC_P		(0 << 8)
paul@33 134
#define VSYNC_N		(1 << 8)
paul@33 135
paul@33 136
#define DATA_NORMAL	(0 << 17)
paul@33 137
#define DATA_INVERSE	(1 << 17)
paul@33 138
paul@224 139
/* Palette buffer (LCD_CMDx.PAL). */
paul@224 140
paul@224 141
#define LCD_CMD_PAL		(1 << 28)
paul@224 142
paul@33 143
#endif /* __JZLCD_H__ */