3 * Stäubli Faverges - <www.staubli.com>
4 * Pierre AUBERT p.aubert@staubli.com
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /* Video support for Epson SED13806 chipset */
31 #define readByte(ptrReg) \
32 *(volatile unsigned char *)(sed13806.isaBase + ptrReg)
34 #define writeByte(ptrReg,value) \
35 *(volatile unsigned char *)(sed13806.isaBase + ptrReg) = value
37 #ifdef CONFIG_TOTAL5200
38 #define writeWord(ptrReg,value) \
39 (*(volatile unsigned short *)(sed13806.isaBase + ptrReg) = value)
41 #define writeWord(ptrReg,value) \
42 (*(volatile unsigned short *)(sed13806.isaBase + ptrReg) = ((value >> 8 ) & 0xff) | ((value << 8) & 0xff00))
45 GraphicDevice sed13806;
47 /*-----------------------------------------------------------------------------
49 *-----------------------------------------------------------------------------
51 static void EpsonSetRegs (void)
53 /* the content of the chipset register depends on the board (clocks, ...)*/
54 const S1D_REGS *preg = board_get_regs ();
55 while (preg -> Index) {
56 writeByte (preg -> Index, preg -> Value);
61 /*-----------------------------------------------------------------------------
63 *-----------------------------------------------------------------------------
65 void *video_hw_init (void)
69 memset (&sed13806, 0, sizeof (GraphicDevice));
71 /* Initialization of the access to the graphic chipset
72 Retreive base address of the chipset
73 (see board/RPXClassic/eccx.c) */
74 if ((sed13806.isaBase = board_video_init ()) == 0) {
78 sed13806.frameAdrs = sed13806.isaBase + FRAME_BUFFER_OFFSET;
79 sed13806.winSizeX = board_get_width ();
80 sed13806.winSizeY = board_get_height ();
82 #if defined(CONFIG_VIDEO_SED13806_8BPP)
83 sed13806.gdfIndex = GDF__8BIT_INDEX;
84 sed13806.gdfBytesPP = 1;
86 #elif defined(CONFIG_VIDEO_SED13806_16BPP)
87 sed13806.gdfIndex = GDF_16BIT_565RGB;
88 sed13806.gdfBytesPP = 2;
91 #error Unsupported SED13806 BPP
94 sed13806.memSize = sed13806.winSizeX * sed13806.winSizeY * sed13806.gdfBytesPP;
96 /* Load SED registers */
99 /* (see board/RPXClassic/RPXClassic.c) */
100 board_validate_screen (sed13806.isaBase);
102 /* Clear video memory */
103 i = sed13806.memSize/4;
104 vm = (unsigned int *)sed13806.frameAdrs;
111 /*-----------------------------------------------------------------------------
112 * Epson_wait_idle -- Wait for hardware to become idle
113 *-----------------------------------------------------------------------------
115 static void Epson_wait_idle (void)
117 while (readByte (BLT_CTRL0) & 0x80);
119 /* Read a word in the BitBLT memory area to shutdown the BitBLT engine */
120 *(volatile unsigned short *)(sed13806.isaBase + BLT_REG);
123 /*-----------------------------------------------------------------------------
125 *-----------------------------------------------------------------------------
127 void video_hw_bitblt (
128 unsigned int bpp, /* bytes per pixel */
129 unsigned int src_x, /* source pos x */
130 unsigned int src_y, /* source pos y */
131 unsigned int dst_x, /* dest pos x */
132 unsigned int dst_y, /* dest pos y */
133 unsigned int dim_x, /* frame width */
134 unsigned int dim_y /* frame height */
137 register GraphicDevice *pGD = (GraphicDevice *)&sed13806;
138 unsigned long srcAddr, dstAddr;
139 unsigned int stride = bpp * pGD -> winSizeX;
141 srcAddr = (src_y * stride) + (src_x * bpp);
142 dstAddr = (dst_y * stride) + (dst_x * bpp);
146 writeByte(BLT_ROP,0x0C); /* source */
147 writeByte(BLT_OP,0x02);/* move blit in positive direction with ROP */
148 writeWord(BLT_MEM_OFF0, stride / 2);
149 if (pGD -> gdfIndex == GDF__8BIT_INDEX) {
150 writeByte(BLT_CTRL1,0x00);
153 writeByte(BLT_CTRL1,0x01);
156 writeWord(BLT_WIDTH0,(dim_x - 1));
157 writeWord(BLT_HEIGHT0,(dim_y - 1));
159 /* set up blit registers */
160 writeByte(BLT_SRC_ADDR0,srcAddr);
161 writeByte(BLT_SRC_ADDR1,srcAddr>>8);
162 writeByte(BLT_SRC_ADDR2,srcAddr>>16);
164 writeByte(BLT_DST_ADDR0,dstAddr);
165 writeByte(BLT_DST_ADDR1,dstAddr>>8);
166 writeByte(BLT_DST_ADDR2,dstAddr>>16);
168 /* Engage the blt engine */
169 /* rectangular region for src and dst */
170 writeByte(BLT_CTRL0,0x80);
172 /* wait untill current blits finished */
175 /*-----------------------------------------------------------------------------
176 * video_hw_rectfill --
177 *-----------------------------------------------------------------------------
179 void video_hw_rectfill (
180 unsigned int bpp, /* bytes per pixel */
181 unsigned int dst_x, /* dest pos x */
182 unsigned int dst_y, /* dest pos y */
183 unsigned int dim_x, /* frame width */
184 unsigned int dim_y, /* frame height */
185 unsigned int color /* fill color */
188 register GraphicDevice *pGD = (GraphicDevice *)&sed13806;
189 unsigned long dstAddr;
190 unsigned int stride = bpp * pGD -> winSizeX;
192 dstAddr = (dst_y * stride) + (dst_x * bpp);
196 /* set up blit registers */
197 writeByte(BLT_DST_ADDR0,dstAddr);
198 writeByte(BLT_DST_ADDR1,dstAddr>>8);
199 writeByte(BLT_DST_ADDR2,dstAddr>>16);
201 writeWord(BLT_WIDTH0,(dim_x - 1));
202 writeWord(BLT_HEIGHT0,(dim_y - 1));
203 writeWord(BLT_FGCOLOR0,color);
205 writeByte(BLT_OP,0x0C); /* solid fill */
206 writeWord(BLT_MEM_OFF0,stride / 2);
208 if (pGD -> gdfIndex == GDF__8BIT_INDEX) {
209 writeByte(BLT_CTRL1,0x00);
212 writeByte(BLT_CTRL1,0x01);
215 /* Engage the blt engine */
216 /* rectangular region for src and dst */
217 writeByte(BLT_CTRL0,0x80);
219 /* wait untill current blits finished */
223 /*-----------------------------------------------------------------------------
225 *-----------------------------------------------------------------------------
228 unsigned int index, /* color number */
229 unsigned char r, /* red */
230 unsigned char g, /* green */
231 unsigned char b /* blue */
234 writeByte(REG_LUT_ADDR, index );
235 writeByte(REG_LUT_DATA, r);
236 writeByte(REG_LUT_DATA, g);
237 writeByte(REG_LUT_DATA, b);
239 #ifdef CONFIG_VIDEO_HW_CURSOR
240 /*-----------------------------------------------------------------------------
241 * video_set_hw_cursor --
242 *-----------------------------------------------------------------------------
244 void video_set_hw_cursor (int x, int y)
246 writeByte (LCD_CURSOR_XL, (x & 0xff));
247 writeByte (LCD_CURSOR_XM, (x >> 8));
248 writeByte (LCD_CURSOR_YL, (y & 0xff));
249 writeByte (LCD_CURSOR_YM, (y >> 8));
252 /*-----------------------------------------------------------------------------
253 * video_init_hw_cursor --
254 *-----------------------------------------------------------------------------
256 void video_init_hw_cursor (int font_width, int font_height)
258 volatile unsigned char *ptr;
259 unsigned char pattern;
263 /* Init cursor content
264 Cursor size is 64x64 pixels
265 Start of the cursor memory depends on panel type (dual panel ...) */
266 if ((i = readByte (LCD_CURSOR_START)) == 0) {
267 ptr = (unsigned char *)(sed13806.frameAdrs + DEFAULT_VIDEO_MEMORY_SIZE - HWCURSORSIZE);
270 ptr = (unsigned char *)(sed13806.frameAdrs + DEFAULT_VIDEO_MEMORY_SIZE - (i * 8192));
273 /* Fill the first line and the first empty line after cursor */
274 for (i = 0, pattern = 0; i < 64; i++) {
275 if (i < font_width) {
276 /* Invert background */
286 *(ptr + font_height * 16) = 0xaa;
293 /* Duplicate this line */
294 for (i = 1; i < font_height; i++) {
295 memcpy ((void *)ptr, (void *)(ptr - 16), 16);
299 for (; i < 64; i++) {
300 memcpy ((void *)(ptr + 16), (void *)ptr, 16);
304 /* Select cursor mode */
305 writeByte (LCD_CURSOR_CNTL, 1);