ite_rt.c revision 1.13 1 1.13 chopps /* $NetBSD: ite_rt.c,v 1.13 1995/04/06 19:19:48 chopps Exp $ */
2 1.5 chopps
3 1.12 chopps /*
4 1.12 chopps * Copyright (c) 1993 Markus Wild
5 1.12 chopps * Copyright (c) 1993 Lutz Vieweg
6 1.12 chopps * All rights reserved.
7 1.12 chopps *
8 1.12 chopps * Redistribution and use in source and binary forms, with or without
9 1.12 chopps * modification, are permitted provided that the following conditions
10 1.12 chopps * are met:
11 1.12 chopps * 1. Redistributions of source code must retain the above copyright
12 1.12 chopps * notice, this list of conditions and the following disclaimer.
13 1.12 chopps * 2. Redistributions in binary form must reproduce the above copyright
14 1.12 chopps * notice, this list of conditions and the following disclaimer in the
15 1.12 chopps * documentation and/or other materials provided with the distribution.
16 1.12 chopps * 3. All advertising materials mentioning features or use of this software
17 1.12 chopps * must display the following acknowledgement:
18 1.12 chopps * This product includes software developed by Lutz Vieweg.
19 1.12 chopps * 4. The name of the author may not be used to endorse or promote products
20 1.12 chopps * derived from this software without specific prior written permission
21 1.12 chopps *
22 1.12 chopps * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.12 chopps * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.12 chopps * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.12 chopps * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.12 chopps * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.12 chopps * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.12 chopps * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.12 chopps * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.12 chopps * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.12 chopps * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.12 chopps */
33 1.10 chopps #include "grfrt.h"
34 1.10 chopps #if NGRFRT > 0
35 1.10 chopps
36 1.6 chopps #include <sys/param.h>
37 1.6 chopps #include <sys/conf.h>
38 1.6 chopps #include <sys/proc.h>
39 1.9 chopps #include <sys/device.h>
40 1.6 chopps #include <sys/ioctl.h>
41 1.6 chopps #include <sys/tty.h>
42 1.6 chopps #include <sys/systm.h>
43 1.7 chopps #include <dev/cons.h>
44 1.9 chopps #include <machine/cpu.h>
45 1.9 chopps #include <amiga/amiga/device.h>
46 1.6 chopps #include <amiga/dev/itevar.h>
47 1.6 chopps #include <amiga/dev/grfioctl.h>
48 1.6 chopps #include <amiga/dev/grfvar.h>
49 1.6 chopps #include <amiga/dev/grf_rtreg.h>
50 1.7 chopps
51 1.8 chopps int retina_console = 1;
52 1.7 chopps
53 1.9 chopps void retina_cursor __P((struct ite_softc *,int));
54 1.9 chopps void retina_scroll __P((struct ite_softc *,int,int,int,int));
55 1.9 chopps void retina_deinit __P((struct ite_softc *));
56 1.9 chopps void retina_clear __P((struct ite_softc *,int,int,int,int));
57 1.9 chopps void retina_putc __P((struct ite_softc *,int,int,int,int));
58 1.9 chopps void retina_init __P((struct ite_softc *));
59 1.9 chopps
60 1.7 chopps /*
61 1.9 chopps * this function is called from grf_rt to init the grf_softc->g_conpri
62 1.9 chopps * field each time a retina is attached.
63 1.7 chopps */
64 1.7 chopps int
65 1.9 chopps grfrt_cnprobe()
66 1.7 chopps {
67 1.9 chopps static int done;
68 1.9 chopps int rv;
69 1.9 chopps
70 1.9 chopps if (retina_console && done == 0)
71 1.9 chopps rv = CN_INTERNAL;
72 1.9 chopps else
73 1.9 chopps rv = CN_NORMAL;
74 1.9 chopps done = 1;
75 1.9 chopps return(rv);
76 1.7 chopps }
77 1.1 mw
78 1.9 chopps /*
79 1.9 chopps * init the required fields in the grf_softc struct for a
80 1.9 chopps * grf to function as an ite.
81 1.9 chopps */
82 1.9 chopps void
83 1.9 chopps grfrt_iteinit(gp)
84 1.9 chopps struct grf_softc *gp;
85 1.1 mw {
86 1.9 chopps gp->g_iteinit = retina_init;
87 1.9 chopps gp->g_itedeinit = retina_deinit;
88 1.9 chopps gp->g_iteclear = retina_clear;
89 1.9 chopps gp->g_iteputc = retina_putc;
90 1.9 chopps gp->g_itescroll = retina_scroll;
91 1.9 chopps gp->g_itecursor = retina_cursor;
92 1.9 chopps }
93 1.1 mw
94 1.9 chopps void
95 1.9 chopps retina_init(ip)
96 1.9 chopps struct ite_softc *ip;
97 1.9 chopps {
98 1.9 chopps struct MonDef *md;
99 1.1 mw
100 1.9 chopps ip->priv = ip->grf->g_data;
101 1.9 chopps md = (struct MonDef *) ip->priv;
102 1.1 mw
103 1.9 chopps ip->cols = md->TX;
104 1.9 chopps ip->rows = md->TY;
105 1.1 mw }
106 1.1 mw
107 1.1 mw
108 1.1 mw void retina_cursor(struct ite_softc *ip, int flag)
109 1.1 mw {
110 1.1 mw volatile u_char *ba = ip->grf->g_regkva;
111 1.1 mw
112 1.1 mw if (flag == ERASE_CURSOR)
113 1.1 mw {
114 1.1 mw /* disable cursor */
115 1.1 mw WCrt (ba, CRT_ID_CURSOR_START, RCrt (ba, CRT_ID_CURSOR_START) | 0x20);
116 1.1 mw }
117 1.1 mw else
118 1.1 mw {
119 1.1 mw int pos = ip->curx + ip->cury * ip->cols;
120 1.1 mw
121 1.1 mw /* make sure to enable cursor */
122 1.1 mw WCrt (ba, CRT_ID_CURSOR_START, RCrt (ba, CRT_ID_CURSOR_START) & ~0x20);
123 1.1 mw
124 1.1 mw /* and position it */
125 1.1 mw WCrt (ba, CRT_ID_CURSOR_LOC_HIGH, (u_char) (pos >> 8));
126 1.1 mw WCrt (ba, CRT_ID_CURSOR_LOC_LOW, (u_char) pos);
127 1.1 mw
128 1.1 mw ip->cursorx = ip->curx;
129 1.1 mw ip->cursory = ip->cury;
130 1.1 mw }
131 1.1 mw }
132 1.1 mw
133 1.1 mw
134 1.1 mw
135 1.1 mw static void screen_up (struct ite_softc *ip, int top, int bottom, int lines)
136 1.1 mw {
137 1.1 mw volatile u_char * ba = ip->grf->g_regkva;
138 1.1 mw volatile u_char * fb = ip->grf->g_fbkva;
139 1.1 mw const struct MonDef * md = (struct MonDef *) ip->priv;
140 1.3 mw #ifdef BANKEDDEVPAGER
141 1.3 mw int bank;
142 1.3 mw #endif
143 1.1 mw
144 1.1 mw /* do some bounds-checking here.. */
145 1.1 mw if (top >= bottom)
146 1.1 mw return;
147 1.1 mw
148 1.1 mw if (top + lines >= bottom)
149 1.1 mw {
150 1.1 mw retina_clear (ip, top, 0, bottom - top, ip->cols);
151 1.1 mw return;
152 1.1 mw }
153 1.1 mw
154 1.1 mw
155 1.3 mw #ifdef BANKEDDEVPAGER
156 1.3 mw /* make sure to save/restore active bank (and if it's only
157 1.3 mw for tests of the feature in text-mode..) */
158 1.3 mw bank = (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO)
159 1.3 mw | (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8));
160 1.3 mw #endif
161 1.3 mw
162 1.1 mw /* the trick here is to use a feature of the NCR chip. It can
163 1.1 mw optimize data access in various read/write modes. One of
164 1.1 mw the modes is able to read/write from/to different zones.
165 1.1 mw
166 1.1 mw Thus, by setting the read-offset to lineN, and the write-offset
167 1.1 mw to line0, we just cause read/write cycles for all characters
168 1.1 mw up to the last line, and have the chip transfer the data. The
169 1.1 mw `addqb' are the cheapest way to cause read/write cycles (DONT
170 1.1 mw use `tas' on the Amiga!), their results are completely ignored
171 1.1 mw by the NCR chip, it just replicates what it just read. */
172 1.1 mw
173 1.1 mw /* write to primary, read from secondary */
174 1.1 mw WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA, (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0 );
175 1.1 mw /* clear extended chain4 mode */
176 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
177 1.1 mw
178 1.1 mw /* set write mode 1, "[...] data in the read latches is written
179 1.1 mw to memory during CPU memory write cycles. [...]" */
180 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
181 1.1 mw
182 1.1 mw {
183 1.1 mw /* write to line TOP */
184 1.1 mw long toploc = top * (md->TX / 16);
185 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, ((unsigned char)toploc));
186 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, ((unsigned char)(toploc >> 8)));
187 1.1 mw }
188 1.1 mw {
189 1.1 mw /* read from line TOP + LINES */
190 1.1 mw long fromloc = (top+lines) * (md->TX / 16);
191 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, ((unsigned char)fromloc)) ;
192 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, ((unsigned char)(fromloc >> 8))) ;
193 1.1 mw }
194 1.1 mw {
195 1.1 mw unsigned char * p = (unsigned char *) fb;
196 1.1 mw /* transfer all characters but LINES lines, unroll by 16 */
197 1.1 mw short x = (1 + bottom - (top + lines)) * (md->TX / 16) - 1;
198 1.1 mw do {
199 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
200 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
201 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
202 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
203 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
204 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
205 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
206 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
207 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
208 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
209 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
210 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
211 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
212 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
213 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
214 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
215 1.1 mw } while (x--);
216 1.1 mw }
217 1.1 mw
218 1.1 mw /* reset to default values */
219 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, 0);
220 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, 0);
221 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, 0);
222 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, 0);
223 1.1 mw /* write mode 0 */
224 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
225 1.1 mw /* extended chain4 enable */
226 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
227 1.1 mw /* read/write to primary on A0, secondary on B0 */
228 1.1 mw WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA, (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0x40 );
229 1.1 mw
230 1.1 mw
231 1.1 mw /* fill the free lines with spaces */
232 1.1 mw
233 1.1 mw { /* feed latches with value */
234 1.1 mw unsigned short * f = (unsigned short *) fb;
235 1.1 mw
236 1.1 mw f += (1 + bottom - lines) * md->TX * 2;
237 1.1 mw *f = 0x2010;
238 1.1 mw {
239 1.1 mw volatile unsigned short dummy = *((volatile unsigned short *)f);
240 1.1 mw }
241 1.1 mw }
242 1.1 mw
243 1.1 mw /* clear extended chain4 mode */
244 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
245 1.1 mw /* set write mode 1, "[...] data in the read latches is written
246 1.1 mw to memory during CPU memory write cycles. [...]" */
247 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
248 1.1 mw
249 1.1 mw {
250 1.1 mw unsigned long * p = (unsigned long *) fb;
251 1.1 mw short x = (lines * (md->TX/16)) - 1;
252 1.1 mw const unsigned long dummyval = 0;
253 1.1 mw
254 1.1 mw p += (1 + bottom - lines) * (md->TX/4);
255 1.1 mw
256 1.1 mw do {
257 1.1 mw *p++ = dummyval;
258 1.1 mw *p++ = dummyval;
259 1.1 mw *p++ = dummyval;
260 1.1 mw *p++ = dummyval;
261 1.1 mw } while (x--);
262 1.1 mw }
263 1.1 mw
264 1.1 mw /* write mode 0 */
265 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
266 1.1 mw /* extended chain4 enable */
267 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
268 1.3 mw
269 1.3 mw #ifdef BANKEDDEVPAGER
270 1.3 mw /* restore former bank */
271 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
272 1.3 mw bank >>= 8;
273 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
274 1.3 mw #endif
275 1.1 mw };
276 1.1 mw
277 1.1 mw static void screen_down (struct ite_softc *ip, int top, int bottom, int lines)
278 1.1 mw {
279 1.1 mw volatile u_char * ba = ip->grf->g_regkva;
280 1.1 mw volatile u_char * fb = ip->grf->g_fbkva;
281 1.1 mw const struct MonDef * md = (struct MonDef *) ip->priv;
282 1.3 mw #ifdef BANKEDDEVPAGER
283 1.3 mw int bank;
284 1.3 mw #endif
285 1.1 mw
286 1.1 mw /* do some bounds-checking here.. */
287 1.1 mw if (top >= bottom)
288 1.1 mw return;
289 1.1 mw
290 1.1 mw if (top + lines >= bottom)
291 1.1 mw {
292 1.1 mw retina_clear (ip, top, 0, bottom - top, ip->cols);
293 1.1 mw return;
294 1.1 mw }
295 1.1 mw
296 1.3 mw #ifdef BANKEDDEVPAGER
297 1.3 mw /* make sure to save/restore active bank (and if it's only
298 1.3 mw for tests of the feature in text-mode..) */
299 1.3 mw bank = (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO)
300 1.3 mw | (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8));
301 1.3 mw #endif
302 1.1 mw /* see screen_up() for explanation of chip-tricks */
303 1.1 mw
304 1.1 mw /* write to primary, read from secondary */
305 1.1 mw WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA, (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0 );
306 1.1 mw /* clear extended chain4 mode */
307 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
308 1.1 mw
309 1.1 mw /* set write mode 1, "[...] data in the read latches is written
310 1.1 mw to memory during CPU memory write cycles. [...]" */
311 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
312 1.1 mw
313 1.1 mw {
314 1.1 mw /* write to line TOP + LINES */
315 1.1 mw long toloc = (top + lines) * (md->TX / 16);
316 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, ((unsigned char)toloc));
317 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, ((unsigned char)(toloc >> 8)));
318 1.1 mw }
319 1.1 mw {
320 1.1 mw /* read from line TOP */
321 1.1 mw long fromloc = top * (md->TX / 16);
322 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, ((unsigned char)fromloc));
323 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, ((unsigned char)(fromloc >> 8))) ;
324 1.1 mw }
325 1.1 mw
326 1.1 mw {
327 1.1 mw unsigned char * p = (unsigned char *) fb;
328 1.1 mw short x = (1 + bottom - (top + lines)) * (md->TX / 16) - 1;
329 1.1 mw p += (1 + bottom - (top + lines)) * md->TX;
330 1.1 mw do {
331 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
332 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
333 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
334 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
335 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
336 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
337 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
338 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
339 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
340 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
341 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
342 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
343 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
344 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
345 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
346 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
347 1.1 mw } while (x--);
348 1.1 mw }
349 1.1 mw
350 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, 0);
351 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, 0);
352 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, 0);
353 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, 0);
354 1.1 mw
355 1.1 mw /* write mode 0 */
356 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
357 1.1 mw /* extended chain4 enable */
358 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
359 1.1 mw /* read/write to primary on A0, secondary on B0 */
360 1.1 mw WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA, (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0x40 );
361 1.1 mw
362 1.1 mw /* fill the free lines with spaces */
363 1.1 mw
364 1.1 mw { /* feed latches with value */
365 1.1 mw unsigned short * f = (unsigned short *) fb;
366 1.1 mw
367 1.1 mw f += top * md->TX * 2;
368 1.1 mw *f = 0x2010;
369 1.1 mw {
370 1.1 mw volatile unsigned short dummy = *((volatile unsigned short *)f);
371 1.1 mw }
372 1.1 mw }
373 1.1 mw
374 1.1 mw /* clear extended chain4 mode */
375 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
376 1.1 mw /* set write mode 1, "[...] data in the read latches is written
377 1.1 mw to memory during CPU memory write cycles. [...]" */
378 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
379 1.1 mw
380 1.1 mw {
381 1.1 mw unsigned long * p = (unsigned long *) fb;
382 1.1 mw short x = (lines * (md->TX/16)) - 1;
383 1.1 mw const unsigned long dummyval = 0;
384 1.1 mw
385 1.1 mw p += top * (md->TX/4);
386 1.1 mw
387 1.1 mw do {
388 1.1 mw *p++ = dummyval;
389 1.1 mw *p++ = dummyval;
390 1.1 mw *p++ = dummyval;
391 1.1 mw *p++ = dummyval;
392 1.1 mw } while (x--);
393 1.1 mw }
394 1.1 mw
395 1.1 mw /* write mode 0 */
396 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
397 1.1 mw /* extended chain4 enable */
398 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
399 1.1 mw
400 1.3 mw #ifdef BANKEDDEVPAGER
401 1.3 mw /* restore former bank */
402 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
403 1.3 mw bank >>= 8;
404 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
405 1.3 mw #endif
406 1.1 mw };
407 1.1 mw
408 1.1 mw void retina_deinit(struct ite_softc *ip)
409 1.1 mw {
410 1.1 mw ip->flags &= ~ITE_INITED;
411 1.1 mw }
412 1.1 mw
413 1.1 mw
414 1.1 mw void retina_putc(struct ite_softc *ip, int c, int dy, int dx, int mode)
415 1.1 mw {
416 1.1 mw volatile u_char * ba = ip->grf->g_regkva;
417 1.1 mw volatile u_char * fb = ip->grf->g_fbkva;
418 1.1 mw register u_char attr;
419 1.1 mw
420 1.1 mw attr = (mode & ATTR_INV) ? 0x21 : 0x10;
421 1.1 mw if (mode & ATTR_UL) attr = 0x01; /* ???????? */
422 1.1 mw if (mode & ATTR_BOLD) attr |= 0x08;
423 1.1 mw if (mode & ATTR_BLINK) attr |= 0x80;
424 1.1 mw
425 1.1 mw fb += 4 * (dy * ip->cols + dx);
426 1.1 mw *fb++ = c; *fb = attr;
427 1.1 mw }
428 1.1 mw
429 1.1 mw void retina_clear(struct ite_softc *ip, int sy, int sx, int h, int w)
430 1.1 mw {
431 1.1 mw volatile u_char * ba = ip->grf->g_regkva;
432 1.1 mw u_short * fb = (u_short *) ip->grf->g_fbkva;
433 1.1 mw short x;
434 1.1 mw const u_short fillval = 0x2010;
435 1.1 mw /* could probably be optimized just like the scrolling functions !! */
436 1.1 mw fb += 2 * (sy * ip->cols + sx);
437 1.1 mw while (h--)
438 1.1 mw {
439 1.1 mw for (x = 2 * (w - 1); x >= 0; x -= 2)
440 1.1 mw fb[x] = fillval;
441 1.1 mw fb += 2 * ip->cols;
442 1.1 mw }
443 1.1 mw }
444 1.1 mw
445 1.13 chopps /*
446 1.13 chopps * RETINA_SPEED_HACK code seems to work on some boards and on others
447 1.13 chopps * it causes text to smear horizontally
448 1.13 chopps */
449 1.13 chopps void
450 1.13 chopps retina_scroll(struct ite_softc *ip, int sy, int sx, int count, int dir)
451 1.1 mw {
452 1.13 chopps register int height, dy, i;
453 1.13 chopps volatile u_char *ba;
454 1.13 chopps u_long *fb;
455 1.13 chopps
456 1.13 chopps ba = ip->grf->g_regkva;
457 1.13 chopps fb = (u_long *)ip->grf->g_fbkva;
458 1.13 chopps
459 1.13 chopps retina_cursor(ip, ERASE_CURSOR);
460 1.13 chopps
461 1.13 chopps if (dir == SCROLL_UP) {
462 1.13 chopps #ifdef RETINA_SPEED_HACK
463 1.13 chopps screen_up(ip, sy - count, ip->bottom_margin, count);
464 1.13 chopps #else
465 1.13 chopps bcopy(fb + sy * ip->cols, fb + (sy - count) * ip->cols,
466 1.13 chopps 4 * (ip->bottom_margin - sy + 1) * ip->cols);
467 1.13 chopps retina_clear(ip, ip->bottom_margin + 1 - count, 0, count,
468 1.13 chopps ip->cols);
469 1.13 chopps #endif
470 1.13 chopps } else if (dir == SCROLL_DOWN) {
471 1.13 chopps #ifdef RETINA_SPEED_HACK
472 1.13 chopps screen_down(ip, sy, ip->bottom_margin, count);
473 1.13 chopps #else
474 1.13 chopps bcopy(fb + sy * ip->cols, fb + (sy + count) * ip->cols,
475 1.13 chopps 4 * (ip->bottom_margin - sy - count + 1) * ip->cols);
476 1.13 chopps retina_clear(ip, sy, 0, count, ip->cols);
477 1.13 chopps #else
478 1.13 chopps } else if (dir == SCROLL_RIGHT) {
479 1.13 chopps bcopy(fb + sx + sy * ip->cols, fb + sx + sy * ip->cols + count,
480 1.13 chopps 4 * (ip->cols - (sx + count)));
481 1.13 chopps retina_clear(ip, sy, sx, 1, count);
482 1.13 chopps } else {
483 1.13 chopps bcopy(fb + sx + sy * ip->cols, fb + sx - count + sy * ip->cols,
484 1.13 chopps 4 * (ip->cols - sx));
485 1.13 chopps retina_clear(ip, sy, ip->cols - count, 1, count);
486 1.13 chopps }
487 1.13 chopps #ifndef RETINA_SPEED_HACK
488 1.13 chopps retina_cursor(ip, !ERASE_CURSOR);
489 1.13 chopps #endif
490 1.1 mw }
491 1.10 chopps
492 1.10 chopps #endif /* NGRFRT */
493