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