V4L/DVB (6715): ivtv: Remove unnecessary register update
[linux-2.6/verdex.git] / drivers / video / console / newport_con.c
blobd31b203bf6549bdb94b337e9f28f7265d8b544e4
1 /*
2 * newport_con.c: Abscon for newport hardware
3 *
4 * (C) 1998 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
5 * (C) 1999 Ulf Carlsson (ulfc@thepuffingruop.com)
6 *
7 * This driver is based on sgicons.c and cons_newport.
8 *
9 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
10 * Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx)
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/errno.h>
15 #include <linux/kd.h>
16 #include <linux/selection.h>
17 #include <linux/console.h>
18 #include <linux/vt_kern.h>
19 #include <linux/mm.h>
20 #include <linux/module.h>
21 #include <linux/slab.h>
23 #include <asm/io.h>
24 #include <asm/uaccess.h>
25 #include <asm/system.h>
26 #include <asm/page.h>
27 #include <asm/pgtable.h>
28 #include <video/newport.h>
30 #include <linux/linux_logo.h>
31 #include <linux/font.h>
34 extern unsigned long sgi_gfxaddr;
36 #define FONT_DATA ((unsigned char *)font_vga_8x16.data)
38 /* borrowed from fbcon.c */
39 #define REFCOUNT(fd) (((int *)(fd))[-1])
40 #define FNTSIZE(fd) (((int *)(fd))[-2])
41 #define FNTCHARCNT(fd) (((int *)(fd))[-3])
42 #define FONT_EXTRA_WORDS 3
44 static unsigned char *font_data[MAX_NR_CONSOLES];
46 static struct newport_regs *npregs;
48 static int logo_active;
49 static int topscan;
50 static int xcurs_correction = 29;
51 static int newport_xsize;
52 static int newport_ysize;
53 static int newport_has_init;
55 static int newport_set_def_font(int unit, struct console_font *op);
57 #define BMASK(c) (c << 24)
59 #define RENDER(regs, cp) do { \
60 (regs)->go.zpattern = BMASK((cp)[0x0]); (regs)->go.zpattern = BMASK((cp)[0x1]); \
61 (regs)->go.zpattern = BMASK((cp)[0x2]); (regs)->go.zpattern = BMASK((cp)[0x3]); \
62 (regs)->go.zpattern = BMASK((cp)[0x4]); (regs)->go.zpattern = BMASK((cp)[0x5]); \
63 (regs)->go.zpattern = BMASK((cp)[0x6]); (regs)->go.zpattern = BMASK((cp)[0x7]); \
64 (regs)->go.zpattern = BMASK((cp)[0x8]); (regs)->go.zpattern = BMASK((cp)[0x9]); \
65 (regs)->go.zpattern = BMASK((cp)[0xa]); (regs)->go.zpattern = BMASK((cp)[0xb]); \
66 (regs)->go.zpattern = BMASK((cp)[0xc]); (regs)->go.zpattern = BMASK((cp)[0xd]); \
67 (regs)->go.zpattern = BMASK((cp)[0xe]); (regs)->go.zpattern = BMASK((cp)[0xf]); \
68 } while(0)
70 #define TESTVAL 0xdeadbeef
71 #define XSTI_TO_FXSTART(val) (((val) & 0xffff) << 11)
73 static inline void newport_render_background(int xstart, int ystart,
74 int xend, int yend, int ci)
76 newport_wait(npregs);
77 npregs->set.wrmask = 0xffffffff;
78 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
79 NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
80 | NPORT_DMODE0_STOPY);
81 npregs->set.colori = ci;
82 npregs->set.xystarti =
83 (xstart << 16) | ((ystart + topscan) & 0x3ff);
84 npregs->go.xyendi =
85 ((xend + 7) << 16) | ((yend + topscan + 15) & 0x3ff);
88 static inline void newport_init_cmap(void)
90 unsigned short i;
92 for (i = 0; i < 16; i++) {
93 newport_bfwait(npregs);
94 newport_cmap_setaddr(npregs, color_table[i]);
95 newport_cmap_setrgb(npregs,
96 default_red[i],
97 default_grn[i], default_blu[i]);
101 static const struct linux_logo *newport_show_logo(void)
103 #ifdef CONFIG_LOGO_SGI_CLUT224
104 const struct linux_logo *logo = fb_find_logo(8);
105 const unsigned char *clut;
106 const unsigned char *data;
107 unsigned long i;
109 if (!logo)
110 return NULL;
111 clut = logo->clut;
112 data = logo->data;
114 for (i = 0; i < logo->clutsize; i++) {
115 newport_bfwait(npregs);
116 newport_cmap_setaddr(npregs, i + 0x20);
117 newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]);
118 clut += 3;
121 newport_wait(npregs);
122 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
123 NPORT_DMODE0_CHOST);
125 npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0);
126 npregs->set.xyendi = ((newport_xsize - 1) << 16);
127 newport_wait(npregs);
129 for (i = 0; i < logo->width*logo->height; i++)
130 npregs->go.hostrw0 = *data++ << 24;
132 return logo;
133 #endif /* CONFIG_LOGO_SGI_CLUT224 */
136 static inline void newport_clear_screen(int xstart, int ystart, int xend,
137 int yend, int ci)
139 if (logo_active)
140 return;
142 newport_wait(npregs);
143 npregs->set.wrmask = 0xffffffff;
144 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
145 NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
146 | NPORT_DMODE0_STOPY);
147 npregs->set.colori = ci;
148 npregs->set.xystarti = (xstart << 16) | ystart;
149 npregs->go.xyendi = (xend << 16) | yend;
152 static inline void newport_clear_lines(int ystart, int yend, int ci)
154 ystart = ((ystart << 4) + topscan) & 0x3ff;
155 yend = ((yend << 4) + topscan + 15) & 0x3ff;
156 newport_clear_screen(0, ystart, 1280 + 63, yend, ci);
159 static void newport_reset(void)
161 unsigned short treg;
162 int i;
164 newport_wait(npregs);
165 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
166 newport_vc2_set(npregs, VC2_IREG_CONTROL,
167 (treg | VC2_CTRL_EVIDEO));
169 treg = newport_vc2_get(npregs, VC2_IREG_CENTRY);
170 newport_vc2_set(npregs, VC2_IREG_RADDR, treg);
171 npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
172 NPORT_DMODE_W2 | VC2_PROTOCOL);
173 for (i = 0; i < 128; i++) {
174 newport_bfwait(npregs);
175 if (i == 92 || i == 94)
176 npregs->set.dcbdata0.byshort.s1 = 0xff00;
177 else
178 npregs->set.dcbdata0.byshort.s1 = 0x0000;
181 newport_init_cmap();
183 /* turn off popup plane */
184 npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
185 XM9_CRS_CONFIG | NPORT_DMODE_W1);
186 npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
187 npregs->set.dcbmode = (DCB_XMAP1 | R_DCB_XMAP9_PROTOCOL |
188 XM9_CRS_CONFIG | NPORT_DMODE_W1);
189 npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
191 topscan = 0;
192 npregs->cset.topscan = 0x3ff;
193 npregs->cset.xywin = (4096 << 16) | 4096;
195 /* Clear the screen. */
196 newport_clear_screen(0, 0, 1280 + 63, 1024, 0);
200 * calculate the actual screen size by reading
201 * the video timing out of the VC2
203 static void newport_get_screensize(void)
205 int i, cols;
206 unsigned short ventry, treg;
207 unsigned short linetable[128]; /* should be enough */
209 ventry = newport_vc2_get(npregs, VC2_IREG_VENTRY);
210 newport_vc2_set(npregs, VC2_IREG_RADDR, ventry);
211 npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
212 NPORT_DMODE_W2 | VC2_PROTOCOL);
213 for (i = 0; i < 128; i++) {
214 newport_bfwait(npregs);
215 linetable[i] = npregs->set.dcbdata0.byshort.s1;
218 newport_xsize = newport_ysize = 0;
219 for (i = 0; linetable[i + 1] && (i < sizeof(linetable)); i += 2) {
220 cols = 0;
221 newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
222 npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
223 NPORT_DMODE_W2 | VC2_PROTOCOL);
224 do {
225 newport_bfwait(npregs);
226 treg = npregs->set.dcbdata0.byshort.s1;
227 if ((treg & 1) == 0)
228 cols += (treg >> 7) & 0xfe;
229 if ((treg & 0x80) == 0) {
230 newport_bfwait(npregs);
231 treg = npregs->set.dcbdata0.byshort.s1;
233 } while ((treg & 0x8000) == 0);
234 if (cols) {
235 if (cols > newport_xsize)
236 newport_xsize = cols;
237 newport_ysize += linetable[i + 1];
240 printk("NG1: Screensize %dx%d\n", newport_xsize, newport_ysize);
243 static void newport_get_revisions(void)
245 unsigned int tmp;
246 unsigned int board_rev;
247 unsigned int rex3_rev;
248 unsigned int vc2_rev;
249 unsigned int cmap_rev;
250 unsigned int xmap9_rev;
251 unsigned int bt445_rev;
252 unsigned int bitplanes;
254 rex3_rev = npregs->cset.status & NPORT_STAT_VERS;
256 npregs->set.dcbmode = (DCB_CMAP0 | NCMAP_PROTOCOL |
257 NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
258 tmp = npregs->set.dcbdata0.bybytes.b3;
259 cmap_rev = tmp & 7;
260 board_rev = (tmp >> 4) & 7;
261 bitplanes = ((board_rev > 1) && (tmp & 0x80)) ? 8 : 24;
263 npregs->set.dcbmode = (DCB_CMAP1 | NCMAP_PROTOCOL |
264 NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
265 tmp = npregs->set.dcbdata0.bybytes.b3;
266 if ((tmp & 7) < cmap_rev)
267 cmap_rev = (tmp & 7);
269 vc2_rev = (newport_vc2_get(npregs, VC2_IREG_CONFIG) >> 5) & 7;
271 npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
272 XM9_CRS_REVISION | NPORT_DMODE_W1);
273 xmap9_rev = npregs->set.dcbdata0.bybytes.b3 & 7;
275 npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
276 BT445_CSR_ADDR_REG | NPORT_DMODE_W1);
277 npregs->set.dcbdata0.bybytes.b3 = BT445_REVISION_REG;
278 npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
279 BT445_CSR_REVISION | NPORT_DMODE_W1);
280 bt445_rev = (npregs->set.dcbdata0.bybytes.b3 >> 4) - 0x0a;
282 #define L(a) (char)('A'+(a))
283 printk
284 ("NG1: Revision %d, %d bitplanes, REX3 revision %c, VC2 revision %c, xmap9 revision %c, cmap revision %c, bt445 revision %c\n",
285 board_rev, bitplanes, L(rex3_rev), L(vc2_rev), L(xmap9_rev),
286 L(cmap_rev ? (cmap_rev + 1) : 0), L(bt445_rev));
287 #undef L
289 if (board_rev == 3) /* I don't know all affected revisions */
290 xcurs_correction = 21;
293 static void newport_exit(void)
295 int i;
297 /* free memory used by user font */
298 for (i = 0; i < MAX_NR_CONSOLES; i++)
299 newport_set_def_font(i, NULL);
302 /* Can't be __init, take_over_console may call it later */
303 static const char *newport_startup(void)
305 int i;
307 if (!sgi_gfxaddr)
308 return NULL;
310 if (!npregs)
311 npregs = (struct newport_regs *)/* ioremap cannot fail */
312 ioremap(sgi_gfxaddr, sizeof(struct newport_regs));
313 npregs->cset.config = NPORT_CFG_GD0;
315 if (newport_wait(npregs))
316 goto out_unmap;
318 npregs->set.xstarti = TESTVAL;
319 if (npregs->set._xstart.word != XSTI_TO_FXSTART(TESTVAL))
320 goto out_unmap;
322 for (i = 0; i < MAX_NR_CONSOLES; i++)
323 font_data[i] = FONT_DATA;
325 newport_reset();
326 newport_get_revisions();
327 newport_get_screensize();
328 newport_has_init = 1;
330 return "SGI Newport";
332 out_unmap:
333 return NULL;
336 static void newport_init(struct vc_data *vc, int init)
338 vc->vc_cols = newport_xsize / 8;
339 vc->vc_rows = newport_ysize / 16;
340 vc->vc_can_do_color = 1;
343 static void newport_deinit(struct vc_data *c)
345 if (!con_is_bound(&newport_con) && newport_has_init) {
346 newport_exit();
347 newport_has_init = 0;
351 static void newport_clear(struct vc_data *vc, int sy, int sx, int height,
352 int width)
354 int xend = ((sx + width) << 3) - 1;
355 int ystart = ((sy << 4) + topscan) & 0x3ff;
356 int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
358 if (logo_active)
359 return;
361 if (ystart < yend) {
362 newport_clear_screen(sx << 3, ystart, xend, yend,
363 (vc->vc_color & 0xf0) >> 4);
364 } else {
365 newport_clear_screen(sx << 3, ystart, xend, 1023,
366 (vc->vc_color & 0xf0) >> 4);
367 newport_clear_screen(sx << 3, 0, xend, yend,
368 (vc->vc_color & 0xf0) >> 4);
372 static void newport_putc(struct vc_data *vc, int charattr, int ypos,
373 int xpos)
375 unsigned char *p;
377 p = &font_data[vc->vc_num][(charattr & 0xff) << 4];
378 charattr = (charattr >> 8) & 0xff;
379 xpos <<= 3;
380 ypos <<= 4;
382 newport_render_background(xpos, ypos, xpos, ypos,
383 (charattr & 0xf0) >> 4);
385 /* Set the color and drawing mode. */
386 newport_wait(npregs);
387 npregs->set.colori = charattr & 0xf;
388 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
389 NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
390 NPORT_DMODE0_L32);
392 /* Set coordinates for bitmap operation. */
393 npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff);
394 npregs->set.xyendi = ((xpos + 7) << 16);
395 newport_wait(npregs);
397 /* Go, baby, go... */
398 RENDER(npregs, p);
401 static void newport_putcs(struct vc_data *vc, const unsigned short *s,
402 int count, int ypos, int xpos)
404 int i;
405 int charattr;
406 unsigned char *p;
408 charattr = (scr_readw(s) >> 8) & 0xff;
410 xpos <<= 3;
411 ypos <<= 4;
413 if (!logo_active)
414 /* Clear the area behing the string */
415 newport_render_background(xpos, ypos,
416 xpos + ((count - 1) << 3), ypos,
417 (charattr & 0xf0) >> 4);
419 newport_wait(npregs);
421 /* Set the color and drawing mode. */
422 npregs->set.colori = charattr & 0xf;
423 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
424 NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
425 NPORT_DMODE0_L32);
427 for (i = 0; i < count; i++, xpos += 8) {
428 p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4];
430 newport_wait(npregs);
432 /* Set coordinates for bitmap operation. */
433 npregs->set.xystarti =
434 (xpos << 16) | ((ypos + topscan) & 0x3ff);
435 npregs->set.xyendi = ((xpos + 7) << 16);
437 /* Go, baby, go... */
438 RENDER(npregs, p);
442 static void newport_cursor(struct vc_data *vc, int mode)
444 unsigned short treg;
445 int xcurs, ycurs;
447 switch (mode) {
448 case CM_ERASE:
449 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
450 newport_vc2_set(npregs, VC2_IREG_CONTROL,
451 (treg & ~(VC2_CTRL_ECDISP)));
452 break;
454 case CM_MOVE:
455 case CM_DRAW:
456 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
457 newport_vc2_set(npregs, VC2_IREG_CONTROL,
458 (treg | VC2_CTRL_ECDISP));
459 xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2;
460 ycurs = ((xcurs / vc->vc_cols) << 4) + 31;
461 xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction;
462 newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs);
463 newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs);
467 static int newport_switch(struct vc_data *vc)
469 static int logo_drawn = 0;
471 topscan = 0;
472 npregs->cset.topscan = 0x3ff;
474 if (!logo_drawn) {
475 if (newport_show_logo()) {
476 logo_drawn = 1;
477 logo_active = 1;
481 return 1;
484 static int newport_blank(struct vc_data *c, int blank, int mode_switch)
486 unsigned short treg;
488 if (blank == 0) {
489 /* unblank console */
490 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
491 newport_vc2_set(npregs, VC2_IREG_CONTROL,
492 (treg | VC2_CTRL_EDISP));
493 } else {
494 /* blank console */
495 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
496 newport_vc2_set(npregs, VC2_IREG_CONTROL,
497 (treg & ~(VC2_CTRL_EDISP)));
499 return 1;
502 static int newport_set_font(int unit, struct console_font *op)
504 int w = op->width;
505 int h = op->height;
506 int size = h * op->charcount;
507 int i;
508 unsigned char *new_data, *data = op->data, *p;
510 /* ladis: when I grow up, there will be a day... and more sizes will
511 * be supported ;-) */
512 if ((w != 8) || (h != 16)
513 || (op->charcount != 256 && op->charcount != 512))
514 return -EINVAL;
516 if (!(new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size,
517 GFP_USER))) return -ENOMEM;
519 new_data += FONT_EXTRA_WORDS * sizeof(int);
520 FNTSIZE(new_data) = size;
521 FNTCHARCNT(new_data) = op->charcount;
522 REFCOUNT(new_data) = 0; /* usage counter */
524 p = new_data;
525 for (i = 0; i < op->charcount; i++) {
526 memcpy(p, data, h);
527 data += 32;
528 p += h;
531 /* check if font is already used by other console */
532 for (i = 0; i < MAX_NR_CONSOLES; i++) {
533 if (font_data[i] != FONT_DATA
534 && FNTSIZE(font_data[i]) == size
535 && !memcmp(font_data[i], new_data, size)) {
536 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
537 /* current font is the same as the new one */
538 if (i == unit)
539 return 0;
540 new_data = font_data[i];
541 break;
544 /* old font is user font */
545 if (font_data[unit] != FONT_DATA) {
546 if (--REFCOUNT(font_data[unit]) == 0)
547 kfree(font_data[unit] -
548 FONT_EXTRA_WORDS * sizeof(int));
550 REFCOUNT(new_data)++;
551 font_data[unit] = new_data;
553 return 0;
556 static int newport_set_def_font(int unit, struct console_font *op)
558 if (font_data[unit] != FONT_DATA) {
559 if (--REFCOUNT(font_data[unit]) == 0)
560 kfree(font_data[unit] -
561 FONT_EXTRA_WORDS * sizeof(int));
562 font_data[unit] = FONT_DATA;
565 return 0;
568 static int newport_font_default(struct vc_data *vc, struct console_font *op, char *name)
570 return newport_set_def_font(vc->vc_num, op);
573 static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags)
575 return newport_set_font(vc->vc_num, font);
578 static int newport_set_palette(struct vc_data *vc, unsigned char *table)
580 return -EINVAL;
583 static int newport_scrolldelta(struct vc_data *vc, int lines)
585 /* there is (nearly) no off-screen memory, so we can't scroll back */
586 return 0;
589 static int newport_scroll(struct vc_data *vc, int t, int b, int dir,
590 int lines)
592 int count, x, y;
593 unsigned short *s, *d;
594 unsigned short chattr;
596 logo_active = 0; /* it's time to disable the logo now.. */
598 if (t == 0 && b == vc->vc_rows) {
599 if (dir == SM_UP) {
600 topscan = (topscan + (lines << 4)) & 0x3ff;
601 newport_clear_lines(vc->vc_rows - lines,
602 vc->vc_rows - 1,
603 (vc->vc_color & 0xf0) >> 4);
604 } else {
605 topscan = (topscan + (-lines << 4)) & 0x3ff;
606 newport_clear_lines(0, lines - 1,
607 (vc->vc_color & 0xf0) >> 4);
609 npregs->cset.topscan = (topscan - 1) & 0x3ff;
610 return 0;
613 count = (b - t - lines) * vc->vc_cols;
614 if (dir == SM_UP) {
615 x = 0;
616 y = t;
617 s = (unsigned short *) (vc->vc_origin +
618 vc->vc_size_row * (t + lines));
619 d = (unsigned short *) (vc->vc_origin +
620 vc->vc_size_row * t);
621 while (count--) {
622 chattr = scr_readw(s++);
623 if (chattr != scr_readw(d)) {
624 newport_putc(vc, chattr, y, x);
625 scr_writew(chattr, d);
627 d++;
628 if (++x == vc->vc_cols) {
629 x = 0;
630 y++;
633 d = (unsigned short *) (vc->vc_origin +
634 vc->vc_size_row * (b - lines));
635 x = 0;
636 y = b - lines;
637 for (count = 0; count < (lines * vc->vc_cols); count++) {
638 if (scr_readw(d) != vc->vc_video_erase_char) {
639 newport_putc(vc, vc->vc_video_erase_char,
640 y, x);
641 scr_writew(vc->vc_video_erase_char, d);
643 d++;
644 if (++x == vc->vc_cols) {
645 x = 0;
646 y++;
649 } else {
650 x = vc->vc_cols - 1;
651 y = b - 1;
652 s = (unsigned short *) (vc->vc_origin +
653 vc->vc_size_row * (b - lines) - 2);
654 d = (unsigned short *) (vc->vc_origin +
655 vc->vc_size_row * b - 2);
656 while (count--) {
657 chattr = scr_readw(s--);
658 if (chattr != scr_readw(d)) {
659 newport_putc(vc, chattr, y, x);
660 scr_writew(chattr, d);
662 d--;
663 if (x-- == 0) {
664 x = vc->vc_cols - 1;
665 y--;
668 d = (unsigned short *) (vc->vc_origin +
669 vc->vc_size_row * t);
670 x = 0;
671 y = t;
672 for (count = 0; count < (lines * vc->vc_cols); count++) {
673 if (scr_readw(d) != vc->vc_video_erase_char) {
674 newport_putc(vc, vc->vc_video_erase_char,
675 y, x);
676 scr_writew(vc->vc_video_erase_char, d);
678 d++;
679 if (++x == vc->vc_cols) {
680 x = 0;
681 y++;
685 return 1;
688 static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy,
689 int dx, int h, int w)
691 short xs, ys, xe, ye, xoffs, yoffs, tmp;
693 xs = sx << 3;
694 xe = ((sx + w) << 3) - 1;
696 * as bmove is only used to move stuff around in the same line
697 * (h == 1), we don't care about wrap arounds caused by topscan != 0
699 ys = ((sy << 4) + topscan) & 0x3ff;
700 ye = (((sy + h) << 4) - 1 + topscan) & 0x3ff;
701 xoffs = (dx - sx) << 3;
702 yoffs = (dy - sy) << 4;
703 if (xoffs > 0) {
704 /* move to the right, exchange starting points */
705 tmp = xe;
706 xe = xs;
707 xs = tmp;
709 newport_wait(npregs);
710 npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK |
711 NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
712 | NPORT_DMODE0_STOPY);
713 npregs->set.xystarti = (xs << 16) | ys;
714 npregs->set.xyendi = (xe << 16) | ye;
715 npregs->go.xymove = (xoffs << 16) | yoffs;
718 static int newport_dummy(struct vc_data *c)
720 return 0;
723 #define DUMMY (void *) newport_dummy
725 const struct consw newport_con = {
726 .owner = THIS_MODULE,
727 .con_startup = newport_startup,
728 .con_init = newport_init,
729 .con_deinit = newport_deinit,
730 .con_clear = newport_clear,
731 .con_putc = newport_putc,
732 .con_putcs = newport_putcs,
733 .con_cursor = newport_cursor,
734 .con_scroll = newport_scroll,
735 .con_bmove = newport_bmove,
736 .con_switch = newport_switch,
737 .con_blank = newport_blank,
738 .con_font_set = newport_font_set,
739 .con_font_default = newport_font_default,
740 .con_set_palette = newport_set_palette,
741 .con_scrolldelta = newport_scrolldelta,
742 .con_set_origin = DUMMY,
743 .con_save_screen = DUMMY
746 #ifdef MODULE
747 static int __init newport_console_init(void)
749 if (!sgi_gfxaddr)
750 return 0;
752 if (!npregs)
753 npregs = (struct newport_regs *)/* ioremap cannot fail */
754 ioremap(sgi_gfxaddr, sizeof(struct newport_regs));
756 return take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
758 module_init(newport_console_init);
760 static void __exit newport_console_exit(void)
762 give_up_console(&newport_con);
763 iounmap((void *)npregs);
765 module_exit(newport_console_exit);
766 #endif
768 MODULE_LICENSE("GPL");