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 */
28 #ifdef CONFIG_VIDEO_SED13806
33 #define readByte(ptrReg) \
34 *(volatile unsigned char *)(sed13806.isaBase + ptrReg)
36 #define writeByte(ptrReg,value) \
37 *(volatile unsigned char *)(sed13806.isaBase + ptrReg) = value
39 #ifdef CONFIG_TOTAL5200
40 #define writeWord(ptrReg,value) \
41 (*(volatile unsigned short *)(sed13806.isaBase + ptrReg) = value)
43 #define writeWord(ptrReg,value) \
44 (*(volatile unsigned short *)(sed13806.isaBase + ptrReg) = ((value >> 8 ) & 0xff) | ((value << 8) & 0xff00))
47 GraphicDevice sed13806
;
49 /*-----------------------------------------------------------------------------
51 *-----------------------------------------------------------------------------
53 static void EpsonSetRegs (void)
55 /* the content of the chipset register depends on the board (clocks, ...)*/
56 const S1D_REGS
*preg
= board_get_regs ();
57 while (preg
-> Index
) {
58 writeByte (preg
-> Index
, preg
-> Value
);
63 /*-----------------------------------------------------------------------------
65 *-----------------------------------------------------------------------------
67 void *video_hw_init (void)
71 memset (&sed13806
, 0, sizeof (GraphicDevice
));
73 /* Initialization of the access to the graphic chipset
74 Retreive base address of the chipset
75 (see board/RPXClassic/eccx.c) */
76 if ((sed13806
.isaBase
= board_video_init ()) == 0) {
80 sed13806
.frameAdrs
= sed13806
.isaBase
+ FRAME_BUFFER_OFFSET
;
81 sed13806
.winSizeX
= board_get_width ();
82 sed13806
.winSizeY
= board_get_height ();
84 #if defined(CONFIG_VIDEO_SED13806_8BPP)
85 sed13806
.gdfIndex
= GDF__8BIT_INDEX
;
86 sed13806
.gdfBytesPP
= 1;
88 #elif defined(CONFIG_VIDEO_SED13806_16BPP)
89 sed13806
.gdfIndex
= GDF_16BIT_565RGB
;
90 sed13806
.gdfBytesPP
= 2;
93 #error Unsupported SED13806 BPP
96 sed13806
.memSize
= sed13806
.winSizeX
* sed13806
.winSizeY
* sed13806
.gdfBytesPP
;
98 /* Load SED registers */
101 /* (see board/RPXClassic/RPXClassic.c) */
102 board_validate_screen (sed13806
.isaBase
);
104 /* Clear video memory */
105 i
= sed13806
.memSize
/4;
106 vm
= (unsigned int *)sed13806
.frameAdrs
;
113 /*-----------------------------------------------------------------------------
114 * Epson_wait_idle -- Wait for hardware to become idle
115 *-----------------------------------------------------------------------------
117 static void Epson_wait_idle (void)
119 while (readByte (BLT_CTRL0
) & 0x80);
121 /* Read a word in the BitBLT memory area to shutdown the BitBLT engine */
122 *(volatile unsigned short *)(sed13806
.isaBase
+ BLT_REG
);
125 /*-----------------------------------------------------------------------------
127 *-----------------------------------------------------------------------------
129 void video_hw_bitblt (
130 unsigned int bpp
, /* bytes per pixel */
131 unsigned int src_x
, /* source pos x */
132 unsigned int src_y
, /* source pos y */
133 unsigned int dst_x
, /* dest pos x */
134 unsigned int dst_y
, /* dest pos y */
135 unsigned int dim_x
, /* frame width */
136 unsigned int dim_y
/* frame height */
139 register GraphicDevice
*pGD
= (GraphicDevice
*)&sed13806
;
140 unsigned long srcAddr
, dstAddr
;
141 unsigned int stride
= bpp
* pGD
-> winSizeX
;
143 srcAddr
= (src_y
* stride
) + (src_x
* bpp
);
144 dstAddr
= (dst_y
* stride
) + (dst_x
* bpp
);
148 writeByte(BLT_ROP
,0x0C); /* source */
149 writeByte(BLT_OP
,0x02);/* move blit in positive direction with ROP */
150 writeWord(BLT_MEM_OFF0
, stride
/ 2);
151 if (pGD
-> gdfIndex
== GDF__8BIT_INDEX
) {
152 writeByte(BLT_CTRL1
,0x00);
155 writeByte(BLT_CTRL1
,0x01);
158 writeWord(BLT_WIDTH0
,(dim_x
- 1));
159 writeWord(BLT_HEIGHT0
,(dim_y
- 1));
161 /* set up blit registers */
162 writeByte(BLT_SRC_ADDR0
,srcAddr
);
163 writeByte(BLT_SRC_ADDR1
,srcAddr
>>8);
164 writeByte(BLT_SRC_ADDR2
,srcAddr
>>16);
166 writeByte(BLT_DST_ADDR0
,dstAddr
);
167 writeByte(BLT_DST_ADDR1
,dstAddr
>>8);
168 writeByte(BLT_DST_ADDR2
,dstAddr
>>16);
170 /* Engage the blt engine */
171 /* rectangular region for src and dst */
172 writeByte(BLT_CTRL0
,0x80);
174 /* wait untill current blits finished */
177 /*-----------------------------------------------------------------------------
178 * video_hw_rectfill --
179 *-----------------------------------------------------------------------------
181 void video_hw_rectfill (
182 unsigned int bpp
, /* bytes per pixel */
183 unsigned int dst_x
, /* dest pos x */
184 unsigned int dst_y
, /* dest pos y */
185 unsigned int dim_x
, /* frame width */
186 unsigned int dim_y
, /* frame height */
187 unsigned int color
/* fill color */
190 register GraphicDevice
*pGD
= (GraphicDevice
*)&sed13806
;
191 unsigned long dstAddr
;
192 unsigned int stride
= bpp
* pGD
-> winSizeX
;
194 dstAddr
= (dst_y
* stride
) + (dst_x
* bpp
);
198 /* set up blit registers */
199 writeByte(BLT_DST_ADDR0
,dstAddr
);
200 writeByte(BLT_DST_ADDR1
,dstAddr
>>8);
201 writeByte(BLT_DST_ADDR2
,dstAddr
>>16);
203 writeWord(BLT_WIDTH0
,(dim_x
- 1));
204 writeWord(BLT_HEIGHT0
,(dim_y
- 1));
205 writeWord(BLT_FGCOLOR0
,color
);
207 writeByte(BLT_OP
,0x0C); /* solid fill */
208 writeWord(BLT_MEM_OFF0
,stride
/ 2);
210 if (pGD
-> gdfIndex
== GDF__8BIT_INDEX
) {
211 writeByte(BLT_CTRL1
,0x00);
214 writeByte(BLT_CTRL1
,0x01);
217 /* Engage the blt engine */
218 /* rectangular region for src and dst */
219 writeByte(BLT_CTRL0
,0x80);
221 /* wait untill current blits finished */
225 /*-----------------------------------------------------------------------------
227 *-----------------------------------------------------------------------------
230 unsigned int index
, /* color number */
231 unsigned char r
, /* red */
232 unsigned char g
, /* green */
233 unsigned char b
/* blue */
236 writeByte(REG_LUT_ADDR
, index
);
237 writeByte(REG_LUT_DATA
, r
);
238 writeByte(REG_LUT_DATA
, g
);
239 writeByte(REG_LUT_DATA
, b
);
241 #ifdef CONFIG_VIDEO_HW_CURSOR
242 /*-----------------------------------------------------------------------------
243 * video_set_hw_cursor --
244 *-----------------------------------------------------------------------------
246 void video_set_hw_cursor (int x
, int y
)
248 writeByte (LCD_CURSOR_XL
, (x
& 0xff));
249 writeByte (LCD_CURSOR_XM
, (x
>> 8));
250 writeByte (LCD_CURSOR_YL
, (y
& 0xff));
251 writeByte (LCD_CURSOR_YM
, (y
>> 8));
254 /*-----------------------------------------------------------------------------
255 * video_init_hw_cursor --
256 *-----------------------------------------------------------------------------
258 void video_init_hw_cursor (int font_width
, int font_height
)
260 volatile unsigned char *ptr
;
261 unsigned char pattern
;
265 /* Init cursor content
266 Cursor size is 64x64 pixels
267 Start of the cursor memory depends on panel type (dual panel ...) */
268 if ((i
= readByte (LCD_CURSOR_START
)) == 0) {
269 ptr
= (unsigned char *)(sed13806
.frameAdrs
+ DEFAULT_VIDEO_MEMORY_SIZE
- HWCURSORSIZE
);
272 ptr
= (unsigned char *)(sed13806
.frameAdrs
+ DEFAULT_VIDEO_MEMORY_SIZE
- (i
* 8192));
275 /* Fill the first line and the first empty line after cursor */
276 for (i
= 0, pattern
= 0; i
< 64; i
++) {
277 if (i
< font_width
) {
278 /* Invert background */
288 *(ptr
+ font_height
* 16) = 0xaa;
295 /* Duplicate this line */
296 for (i
= 1; i
< font_height
; i
++) {
297 memcpy ((void *)ptr
, (void *)(ptr
- 16), 16);
301 for (; i
< 64; i
++) {
302 memcpy ((void *)(ptr
+ 16), (void *)ptr
, 16);
306 /* Select cursor mode */
307 writeByte (LCD_CURSOR_CNTL
, 1);