ite_rt.c revision 1.16 1 1.16 veego /* $NetBSD: ite_rt.c,v 1.16 1996/04/23 22:53:12 veego 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.16 veego #ifdef RETINA_SPEED_HACK
61 1.16 veego static void screen_up __P((struct ite_softc *, int, int, int));
62 1.16 veego static void screen_down __P((struct ite_softc *, int, int, int));
63 1.16 veego #endif
64 1.16 veego
65 1.7 chopps /*
66 1.9 chopps * this function is called from grf_rt to init the grf_softc->g_conpri
67 1.9 chopps * field each time a retina is attached.
68 1.7 chopps */
69 1.7 chopps int
70 1.9 chopps grfrt_cnprobe()
71 1.7 chopps {
72 1.9 chopps static int done;
73 1.9 chopps int rv;
74 1.9 chopps
75 1.9 chopps if (retina_console && done == 0)
76 1.9 chopps rv = CN_INTERNAL;
77 1.9 chopps else
78 1.9 chopps rv = CN_NORMAL;
79 1.9 chopps done = 1;
80 1.9 chopps return(rv);
81 1.7 chopps }
82 1.1 mw
83 1.9 chopps /*
84 1.9 chopps * init the required fields in the grf_softc struct for a
85 1.9 chopps * grf to function as an ite.
86 1.9 chopps */
87 1.9 chopps void
88 1.9 chopps grfrt_iteinit(gp)
89 1.9 chopps struct grf_softc *gp;
90 1.1 mw {
91 1.9 chopps gp->g_iteinit = retina_init;
92 1.9 chopps gp->g_itedeinit = retina_deinit;
93 1.9 chopps gp->g_iteclear = retina_clear;
94 1.9 chopps gp->g_iteputc = retina_putc;
95 1.9 chopps gp->g_itescroll = retina_scroll;
96 1.9 chopps gp->g_itecursor = retina_cursor;
97 1.9 chopps }
98 1.1 mw
99 1.16 veego
100 1.9 chopps void
101 1.9 chopps retina_init(ip)
102 1.9 chopps struct ite_softc *ip;
103 1.9 chopps {
104 1.9 chopps struct MonDef *md;
105 1.1 mw
106 1.9 chopps ip->priv = ip->grf->g_data;
107 1.9 chopps md = (struct MonDef *) ip->priv;
108 1.16 veego
109 1.9 chopps ip->cols = md->TX;
110 1.9 chopps ip->rows = md->TY;
111 1.1 mw }
112 1.1 mw
113 1.1 mw
114 1.16 veego void
115 1.16 veego retina_cursor(ip, flag)
116 1.16 veego struct ite_softc *ip;
117 1.16 veego int flag;
118 1.1 mw {
119 1.15 veego volatile caddr_t ba = ip->grf->g_regkva;
120 1.1 mw
121 1.1 mw if (flag == ERASE_CURSOR)
122 1.1 mw {
123 1.1 mw /* disable cursor */
124 1.1 mw WCrt (ba, CRT_ID_CURSOR_START, RCrt (ba, CRT_ID_CURSOR_START) | 0x20);
125 1.1 mw }
126 1.1 mw else
127 1.1 mw {
128 1.1 mw int pos = ip->curx + ip->cury * ip->cols;
129 1.1 mw
130 1.1 mw /* make sure to enable cursor */
131 1.1 mw WCrt (ba, CRT_ID_CURSOR_START, RCrt (ba, CRT_ID_CURSOR_START) & ~0x20);
132 1.1 mw
133 1.1 mw /* and position it */
134 1.1 mw WCrt (ba, CRT_ID_CURSOR_LOC_HIGH, (u_char) (pos >> 8));
135 1.1 mw WCrt (ba, CRT_ID_CURSOR_LOC_LOW, (u_char) pos);
136 1.1 mw
137 1.1 mw ip->cursorx = ip->curx;
138 1.1 mw ip->cursory = ip->cury;
139 1.1 mw }
140 1.1 mw }
141 1.1 mw
142 1.1 mw
143 1.1 mw
144 1.16 veego #ifdef RETINA_SPEED_HACK
145 1.16 veego static void
146 1.16 veego screen_up(ip, top, bottom, lines)
147 1.16 veego struct ite_softc *ip;
148 1.16 veego int top;
149 1.16 veego int bottom;
150 1.16 veego int lines;
151 1.1 mw {
152 1.15 veego volatile caddr_t ba = ip->grf->g_regkva;
153 1.15 veego volatile caddr_t fb = ip->grf->g_fbkva;
154 1.1 mw const struct MonDef * md = (struct MonDef *) ip->priv;
155 1.3 mw #ifdef BANKEDDEVPAGER
156 1.3 mw int bank;
157 1.3 mw #endif
158 1.1 mw
159 1.1 mw /* do some bounds-checking here.. */
160 1.1 mw if (top >= bottom)
161 1.1 mw return;
162 1.1 mw
163 1.1 mw if (top + lines >= bottom)
164 1.1 mw {
165 1.1 mw retina_clear (ip, top, 0, bottom - top, ip->cols);
166 1.1 mw return;
167 1.1 mw }
168 1.1 mw
169 1.1 mw
170 1.3 mw #ifdef BANKEDDEVPAGER
171 1.3 mw /* make sure to save/restore active bank (and if it's only
172 1.3 mw for tests of the feature in text-mode..) */
173 1.3 mw bank = (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO)
174 1.3 mw | (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8));
175 1.3 mw #endif
176 1.3 mw
177 1.1 mw /* the trick here is to use a feature of the NCR chip. It can
178 1.1 mw optimize data access in various read/write modes. One of
179 1.1 mw the modes is able to read/write from/to different zones.
180 1.1 mw
181 1.1 mw Thus, by setting the read-offset to lineN, and the write-offset
182 1.1 mw to line0, we just cause read/write cycles for all characters
183 1.1 mw up to the last line, and have the chip transfer the data. The
184 1.1 mw `addqb' are the cheapest way to cause read/write cycles (DONT
185 1.1 mw use `tas' on the Amiga!), their results are completely ignored
186 1.1 mw by the NCR chip, it just replicates what it just read. */
187 1.1 mw
188 1.1 mw /* write to primary, read from secondary */
189 1.16 veego WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
190 1.16 veego (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0 );
191 1.1 mw /* clear extended chain4 mode */
192 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
193 1.1 mw
194 1.1 mw /* set write mode 1, "[...] data in the read latches is written
195 1.1 mw to memory during CPU memory write cycles. [...]" */
196 1.16 veego WGfx (ba, GCT_ID_GRAPHICS_MODE,
197 1.16 veego (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
198 1.1 mw
199 1.1 mw {
200 1.1 mw /* write to line TOP */
201 1.1 mw long toploc = top * (md->TX / 16);
202 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, ((unsigned char)toploc));
203 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, ((unsigned char)(toploc >> 8)));
204 1.1 mw }
205 1.1 mw {
206 1.1 mw /* read from line TOP + LINES */
207 1.1 mw long fromloc = (top+lines) * (md->TX / 16);
208 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, ((unsigned char)fromloc)) ;
209 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, ((unsigned char)(fromloc >> 8))) ;
210 1.1 mw }
211 1.1 mw {
212 1.15 veego caddr_t p = (caddr_t)fb;
213 1.1 mw /* transfer all characters but LINES lines, unroll by 16 */
214 1.1 mw short x = (1 + bottom - (top + lines)) * (md->TX / 16) - 1;
215 1.1 mw do {
216 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
217 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
218 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
219 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
220 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
221 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
222 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
223 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
224 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
225 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
226 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
227 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
228 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
229 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
230 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
231 1.1 mw asm volatile("addqb #1,%0@+" : "=a" (p) : "0" (p));
232 1.1 mw } while (x--);
233 1.1 mw }
234 1.1 mw
235 1.1 mw /* reset to default values */
236 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, 0);
237 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, 0);
238 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, 0);
239 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, 0);
240 1.1 mw /* write mode 0 */
241 1.16 veego WGfx (ba, GCT_ID_GRAPHICS_MODE,
242 1.16 veego (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
243 1.1 mw /* extended chain4 enable */
244 1.16 veego WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR,
245 1.16 veego RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
246 1.1 mw /* read/write to primary on A0, secondary on B0 */
247 1.16 veego WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
248 1.16 veego (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0x40);
249 1.16 veego
250 1.16 veego
251 1.1 mw /* fill the free lines with spaces */
252 1.16 veego
253 1.1 mw { /* feed latches with value */
254 1.1 mw unsigned short * f = (unsigned short *) fb;
255 1.16 veego
256 1.1 mw f += (1 + bottom - lines) * md->TX * 2;
257 1.1 mw *f = 0x2010;
258 1.1 mw }
259 1.16 veego
260 1.1 mw /* clear extended chain4 mode */
261 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
262 1.1 mw /* set write mode 1, "[...] data in the read latches is written
263 1.1 mw to memory during CPU memory write cycles. [...]" */
264 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
265 1.16 veego
266 1.1 mw {
267 1.1 mw unsigned long * p = (unsigned long *) fb;
268 1.1 mw short x = (lines * (md->TX/16)) - 1;
269 1.1 mw const unsigned long dummyval = 0;
270 1.16 veego
271 1.1 mw p += (1 + bottom - lines) * (md->TX/4);
272 1.16 veego
273 1.1 mw do {
274 1.1 mw *p++ = dummyval;
275 1.1 mw *p++ = dummyval;
276 1.1 mw *p++ = dummyval;
277 1.1 mw *p++ = dummyval;
278 1.1 mw } while (x--);
279 1.1 mw }
280 1.16 veego
281 1.1 mw /* write mode 0 */
282 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
283 1.1 mw /* extended chain4 enable */
284 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
285 1.3 mw
286 1.3 mw #ifdef BANKEDDEVPAGER
287 1.3 mw /* restore former bank */
288 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
289 1.3 mw bank >>= 8;
290 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
291 1.3 mw #endif
292 1.1 mw };
293 1.1 mw
294 1.16 veego
295 1.16 veego static void
296 1.16 veego screen_down(ip, top, bottom, lines)
297 1.16 veego struct ite_softc *ip;
298 1.16 veego int top;
299 1.16 veego int bottom;
300 1.16 veego int lines;
301 1.16 veego {
302 1.15 veego volatile caddr_t ba = ip->grf->g_regkva;
303 1.15 veego volatile caddr_t fb = ip->grf->g_fbkva;
304 1.1 mw const struct MonDef * md = (struct MonDef *) ip->priv;
305 1.3 mw #ifdef BANKEDDEVPAGER
306 1.3 mw int bank;
307 1.3 mw #endif
308 1.1 mw
309 1.1 mw /* do some bounds-checking here.. */
310 1.1 mw if (top >= bottom)
311 1.1 mw return;
312 1.16 veego
313 1.1 mw if (top + lines >= bottom)
314 1.1 mw {
315 1.1 mw retina_clear (ip, top, 0, bottom - top, ip->cols);
316 1.1 mw return;
317 1.1 mw }
318 1.1 mw
319 1.3 mw #ifdef BANKEDDEVPAGER
320 1.3 mw /* make sure to save/restore active bank (and if it's only
321 1.3 mw for tests of the feature in text-mode..) */
322 1.3 mw bank = (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO)
323 1.3 mw | (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8));
324 1.3 mw #endif
325 1.1 mw /* see screen_up() for explanation of chip-tricks */
326 1.1 mw
327 1.1 mw /* write to primary, read from secondary */
328 1.16 veego WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
329 1.16 veego (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0 );
330 1.1 mw /* clear extended chain4 mode */
331 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
332 1.16 veego
333 1.1 mw /* set write mode 1, "[...] data in the read latches is written
334 1.1 mw to memory during CPU memory write cycles. [...]" */
335 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
336 1.16 veego
337 1.1 mw {
338 1.1 mw /* write to line TOP + LINES */
339 1.1 mw long toloc = (top + lines) * (md->TX / 16);
340 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, ((unsigned char)toloc));
341 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, ((unsigned char)(toloc >> 8)));
342 1.1 mw }
343 1.1 mw {
344 1.1 mw /* read from line TOP */
345 1.1 mw long fromloc = top * (md->TX / 16);
346 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, ((unsigned char)fromloc));
347 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, ((unsigned char)(fromloc >> 8))) ;
348 1.1 mw }
349 1.16 veego
350 1.1 mw {
351 1.15 veego caddr_t p = (caddr_t)fb;
352 1.1 mw short x = (1 + bottom - (top + lines)) * (md->TX / 16) - 1;
353 1.1 mw p += (1 + bottom - (top + lines)) * md->TX;
354 1.1 mw do {
355 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
356 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
357 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
358 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
359 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
360 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
361 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
362 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
363 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
364 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
365 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
366 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
367 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
368 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
369 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
370 1.1 mw asm volatile("addqb #1,%0@-" : "=a" (p) : "0" (p));
371 1.1 mw } while (x--);
372 1.1 mw }
373 1.16 veego
374 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, 0);
375 1.1 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, 0);
376 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_HI, 0);
377 1.1 mw WSeq (ba, SEQ_ID_SEC_HOST_OFF_LO, 0);
378 1.16 veego
379 1.1 mw /* write mode 0 */
380 1.16 veego WGfx (ba, GCT_ID_GRAPHICS_MODE,
381 1.16 veego (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
382 1.1 mw /* extended chain4 enable */
383 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
384 1.1 mw /* read/write to primary on A0, secondary on B0 */
385 1.16 veego WSeq (ba, SEQ_ID_EXTENDED_MEM_ENA,
386 1.16 veego (RSeq(ba, SEQ_ID_EXTENDED_MEM_ENA) & 0x1f) | 0x40 );
387 1.16 veego
388 1.1 mw /* fill the free lines with spaces */
389 1.16 veego
390 1.1 mw { /* feed latches with value */
391 1.1 mw unsigned short * f = (unsigned short *) fb;
392 1.16 veego
393 1.1 mw f += top * md->TX * 2;
394 1.1 mw *f = 0x2010;
395 1.1 mw }
396 1.16 veego
397 1.1 mw /* clear extended chain4 mode */
398 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR, RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) & ~0x02);
399 1.1 mw /* set write mode 1, "[...] data in the read latches is written
400 1.1 mw to memory during CPU memory write cycles. [...]" */
401 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 1);
402 1.16 veego
403 1.1 mw {
404 1.1 mw unsigned long * p = (unsigned long *) fb;
405 1.1 mw short x = (lines * (md->TX/16)) - 1;
406 1.1 mw const unsigned long dummyval = 0;
407 1.16 veego
408 1.1 mw p += top * (md->TX/4);
409 1.16 veego
410 1.1 mw do {
411 1.1 mw *p++ = dummyval;
412 1.1 mw *p++ = dummyval;
413 1.1 mw *p++ = dummyval;
414 1.1 mw *p++ = dummyval;
415 1.1 mw } while (x--);
416 1.1 mw }
417 1.16 veego
418 1.1 mw /* write mode 0 */
419 1.1 mw WGfx (ba, GCT_ID_GRAPHICS_MODE, (RGfx(ba, GCT_ID_GRAPHICS_MODE) & 0xfc) | 0);
420 1.1 mw /* extended chain4 enable */
421 1.1 mw WSeq (ba, SEQ_ID_EXT_VIDEO_ADDR , RSeq(ba, SEQ_ID_EXT_VIDEO_ADDR) | 0x02);
422 1.16 veego
423 1.3 mw #ifdef BANKEDDEVPAGER
424 1.3 mw /* restore former bank */
425 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
426 1.3 mw bank >>= 8;
427 1.3 mw WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
428 1.3 mw #endif
429 1.1 mw };
430 1.16 veego #endif /* RETINA_SPEED_HACK */
431 1.16 veego
432 1.1 mw
433 1.16 veego void
434 1.16 veego retina_deinit(ip)
435 1.16 veego struct ite_softc *ip;
436 1.1 mw {
437 1.16 veego ip->flags &= ~ITE_INITED;
438 1.1 mw }
439 1.1 mw
440 1.1 mw
441 1.16 veego void
442 1.16 veego retina_putc(ip, c, dy, dx, mode)
443 1.16 veego struct ite_softc *ip;
444 1.16 veego int c;
445 1.16 veego int dy;
446 1.16 veego int dx;
447 1.16 veego int mode;
448 1.1 mw {
449 1.15 veego volatile caddr_t fb = ip->grf->g_fbkva;
450 1.1 mw register u_char attr;
451 1.16 veego
452 1.1 mw attr = (mode & ATTR_INV) ? 0x21 : 0x10;
453 1.1 mw if (mode & ATTR_UL) attr = 0x01; /* ???????? */
454 1.1 mw if (mode & ATTR_BOLD) attr |= 0x08;
455 1.1 mw if (mode & ATTR_BLINK) attr |= 0x80;
456 1.16 veego
457 1.1 mw fb += 4 * (dy * ip->cols + dx);
458 1.1 mw *fb++ = c; *fb = attr;
459 1.1 mw }
460 1.1 mw
461 1.16 veego
462 1.16 veego void
463 1.16 veego retina_clear(ip, sy, sx, h, w)
464 1.16 veego struct ite_softc *ip;
465 1.16 veego int sy;
466 1.16 veego int sx;
467 1.16 veego int h;
468 1.16 veego int w;
469 1.1 mw {
470 1.1 mw u_short * fb = (u_short *) ip->grf->g_fbkva;
471 1.1 mw short x;
472 1.1 mw const u_short fillval = 0x2010;
473 1.16 veego
474 1.1 mw /* could probably be optimized just like the scrolling functions !! */
475 1.1 mw fb += 2 * (sy * ip->cols + sx);
476 1.1 mw while (h--)
477 1.1 mw {
478 1.1 mw for (x = 2 * (w - 1); x >= 0; x -= 2)
479 1.1 mw fb[x] = fillval;
480 1.1 mw fb += 2 * ip->cols;
481 1.1 mw }
482 1.1 mw }
483 1.1 mw
484 1.16 veego
485 1.13 chopps /*
486 1.13 chopps * RETINA_SPEED_HACK code seems to work on some boards and on others
487 1.13 chopps * it causes text to smear horizontally
488 1.13 chopps */
489 1.13 chopps void
490 1.16 veego retina_scroll(ip, sy, sx, count, dir)
491 1.16 veego struct ite_softc *ip;
492 1.16 veego int sy;
493 1.16 veego int sx;
494 1.16 veego int count;
495 1.16 veego int dir;
496 1.1 mw {
497 1.15 veego volatile caddr_t ba;
498 1.13 chopps u_long *fb;
499 1.13 chopps
500 1.13 chopps ba = ip->grf->g_regkva;
501 1.13 chopps fb = (u_long *)ip->grf->g_fbkva;
502 1.16 veego
503 1.13 chopps retina_cursor(ip, ERASE_CURSOR);
504 1.13 chopps
505 1.13 chopps if (dir == SCROLL_UP) {
506 1.13 chopps #ifdef RETINA_SPEED_HACK
507 1.13 chopps screen_up(ip, sy - count, ip->bottom_margin, count);
508 1.13 chopps #else
509 1.13 chopps bcopy(fb + sy * ip->cols, fb + (sy - count) * ip->cols,
510 1.13 chopps 4 * (ip->bottom_margin - sy + 1) * ip->cols);
511 1.13 chopps retina_clear(ip, ip->bottom_margin + 1 - count, 0, count,
512 1.13 chopps ip->cols);
513 1.13 chopps #endif
514 1.13 chopps } else if (dir == SCROLL_DOWN) {
515 1.13 chopps #ifdef RETINA_SPEED_HACK
516 1.13 chopps screen_down(ip, sy, ip->bottom_margin, count);
517 1.13 chopps #else
518 1.13 chopps bcopy(fb + sy * ip->cols, fb + (sy + count) * ip->cols,
519 1.13 chopps 4 * (ip->bottom_margin - sy - count + 1) * ip->cols);
520 1.13 chopps retina_clear(ip, sy, 0, count, ip->cols);
521 1.14 chopps #endif
522 1.13 chopps } else if (dir == SCROLL_RIGHT) {
523 1.13 chopps bcopy(fb + sx + sy * ip->cols, fb + sx + sy * ip->cols + count,
524 1.13 chopps 4 * (ip->cols - (sx + count)));
525 1.13 chopps retina_clear(ip, sy, sx, 1, count);
526 1.13 chopps } else {
527 1.13 chopps bcopy(fb + sx + sy * ip->cols, fb + sx - count + sy * ip->cols,
528 1.13 chopps 4 * (ip->cols - sx));
529 1.13 chopps retina_clear(ip, sy, ip->cols - count, 1, count);
530 1.13 chopps }
531 1.13 chopps #ifndef RETINA_SPEED_HACK
532 1.13 chopps retina_cursor(ip, !ERASE_CURSOR);
533 1.13 chopps #endif
534 1.1 mw }
535 1.10 chopps
536 1.10 chopps #endif /* NGRFRT */
537