[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / video / console / newport_con.c
blobe793ffd39db53fff857dd88ce3c78a7833ca89c0
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/tty.h>
16 #include <linux/kd.h>
17 #include <linux/selection.h>
18 #include <linux/console.h>
19 #include <linux/vt_kern.h>
20 #include <linux/mm.h>
21 #include <linux/module.h>
22 #include <linux/slab.h>
24 #include <asm/io.h>
25 #include <asm/uaccess.h>
26 #include <asm/system.h>
27 #include <asm/page.h>
28 #include <asm/pgtable.h>
29 #include <video/newport.h>
31 #include <linux/linux_logo.h>
32 #include <linux/font.h>
35 extern struct font_desc font_vga_8x16;
36 extern unsigned long sgi_gfxaddr;
38 #define FONT_DATA ((unsigned char *)font_vga_8x16.data)
40 /* borrowed from fbcon.c */
41 #define REFCOUNT(fd) (((int *)(fd))[-1])
42 #define FNTSIZE(fd) (((int *)(fd))[-2])
43 #define FNTCHARCNT(fd) (((int *)(fd))[-3])
44 #define FONT_EXTRA_WORDS 3
46 static unsigned char *font_data[MAX_NR_CONSOLES];
48 static struct newport_regs *npregs;
50 static int logo_active;
51 static int topscan;
52 static int xcurs_correction = 29;
53 static int newport_xsize;
54 static int newport_ysize;
56 static int newport_set_def_font(int unit, struct console_font *op);
58 #define BMASK(c) (c << 24)
60 #define RENDER(regs, cp) do { \
61 (regs)->go.zpattern = BMASK((cp)[0x0]); (regs)->go.zpattern = BMASK((cp)[0x1]); \
62 (regs)->go.zpattern = BMASK((cp)[0x2]); (regs)->go.zpattern = BMASK((cp)[0x3]); \
63 (regs)->go.zpattern = BMASK((cp)[0x4]); (regs)->go.zpattern = BMASK((cp)[0x5]); \
64 (regs)->go.zpattern = BMASK((cp)[0x6]); (regs)->go.zpattern = BMASK((cp)[0x7]); \
65 (regs)->go.zpattern = BMASK((cp)[0x8]); (regs)->go.zpattern = BMASK((cp)[0x9]); \
66 (regs)->go.zpattern = BMASK((cp)[0xa]); (regs)->go.zpattern = BMASK((cp)[0xb]); \
67 (regs)->go.zpattern = BMASK((cp)[0xc]); (regs)->go.zpattern = BMASK((cp)[0xd]); \
68 (regs)->go.zpattern = BMASK((cp)[0xe]); (regs)->go.zpattern = BMASK((cp)[0xf]); \
69 } while(0)
71 #define TESTVAL 0xdeadbeef
72 #define XSTI_TO_FXSTART(val) (((val) & 0xffff) << 11)
74 static inline void newport_render_background(int xstart, int ystart,
75 int xend, int yend, int ci)
77 newport_wait(npregs);
78 npregs->set.wrmask = 0xffffffff;
79 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
80 NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
81 | NPORT_DMODE0_STOPY);
82 npregs->set.colori = ci;
83 npregs->set.xystarti =
84 (xstart << 16) | ((ystart + topscan) & 0x3ff);
85 npregs->go.xyendi =
86 ((xend + 7) << 16) | ((yend + topscan + 15) & 0x3ff);
89 static inline void newport_init_cmap(void)
91 unsigned short i;
93 for (i = 0; i < 16; i++) {
94 newport_bfwait(npregs);
95 newport_cmap_setaddr(npregs, color_table[i]);
96 newport_cmap_setrgb(npregs,
97 default_red[i],
98 default_grn[i], default_blu[i]);
102 static void newport_show_logo(void)
104 #ifdef CONFIG_LOGO_SGI_CLUT224
105 const struct linux_logo *logo = fb_find_logo(8);
106 const unsigned char *clut = logo->clut;
107 const unsigned char *data = logo->data;
108 unsigned long i;
110 for (i = 0; i < logo->clutsize; i++) {
111 newport_bfwait(npregs);
112 newport_cmap_setaddr(npregs, i + 0x20);
113 newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]);
114 clut += 3;
117 newport_wait(npregs);
118 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
119 NPORT_DMODE0_CHOST);
121 npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0);
122 npregs->set.xyendi = ((newport_xsize - 1) << 16);
123 newport_wait(npregs);
125 for (i = 0; i < logo->width*logo->height; i++)
126 npregs->go.hostrw0 = *data++ << 24;
127 #endif /* CONFIG_LOGO_SGI_CLUT224 */
130 static inline void newport_clear_screen(int xstart, int ystart, int xend,
131 int yend, int ci)
133 if (logo_active)
134 return;
136 newport_wait(npregs);
137 npregs->set.wrmask = 0xffffffff;
138 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
139 NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
140 | NPORT_DMODE0_STOPY);
141 npregs->set.colori = ci;
142 npregs->set.xystarti = (xstart << 16) | ystart;
143 npregs->go.xyendi = (xend << 16) | yend;
146 static inline void newport_clear_lines(int ystart, int yend, int ci)
148 ystart = ((ystart << 4) + topscan) & 0x3ff;
149 yend = ((yend << 4) + topscan + 15) & 0x3ff;
150 newport_clear_screen(0, ystart, 1280 + 63, yend, ci);
153 void newport_reset(void)
155 unsigned short treg;
156 int i;
158 newport_wait(npregs);
159 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
160 newport_vc2_set(npregs, VC2_IREG_CONTROL,
161 (treg | VC2_CTRL_EVIDEO));
163 treg = newport_vc2_get(npregs, VC2_IREG_CENTRY);
164 newport_vc2_set(npregs, VC2_IREG_RADDR, treg);
165 npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
166 NPORT_DMODE_W2 | VC2_PROTOCOL);
167 for (i = 0; i < 128; i++) {
168 newport_bfwait(npregs);
169 if (i == 92 || i == 94)
170 npregs->set.dcbdata0.byshort.s1 = 0xff00;
171 else
172 npregs->set.dcbdata0.byshort.s1 = 0x0000;
175 newport_init_cmap();
177 /* turn off popup plane */
178 npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
179 XM9_CRS_CONFIG | NPORT_DMODE_W1);
180 npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
181 npregs->set.dcbmode = (DCB_XMAP1 | R_DCB_XMAP9_PROTOCOL |
182 XM9_CRS_CONFIG | NPORT_DMODE_W1);
183 npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
185 topscan = 0;
186 npregs->cset.topscan = 0x3ff;
187 npregs->cset.xywin = (4096 << 16) | 4096;
189 /* Clear the screen. */
190 newport_clear_screen(0, 0, 1280 + 63, 1024, 0);
194 * calculate the actual screen size by reading
195 * the video timing out of the VC2
197 void newport_get_screensize(void)
199 int i, cols;
200 unsigned short ventry, treg;
201 unsigned short linetable[128]; /* should be enough */
203 ventry = newport_vc2_get(npregs, VC2_IREG_VENTRY);
204 newport_vc2_set(npregs, VC2_IREG_RADDR, ventry);
205 npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
206 NPORT_DMODE_W2 | VC2_PROTOCOL);
207 for (i = 0; i < 128; i++) {
208 newport_bfwait(npregs);
209 linetable[i] = npregs->set.dcbdata0.byshort.s1;
212 newport_xsize = newport_ysize = 0;
213 for (i = 0; linetable[i + 1] && (i < sizeof(linetable)); i += 2) {
214 cols = 0;
215 newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
216 npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
217 NPORT_DMODE_W2 | VC2_PROTOCOL);
218 do {
219 newport_bfwait(npregs);
220 treg = npregs->set.dcbdata0.byshort.s1;
221 if ((treg & 1) == 0)
222 cols += (treg >> 7) & 0xfe;
223 if ((treg & 0x80) == 0) {
224 newport_bfwait(npregs);
225 treg = npregs->set.dcbdata0.byshort.s1;
227 } while ((treg & 0x8000) == 0);
228 if (cols) {
229 if (cols > newport_xsize)
230 newport_xsize = cols;
231 newport_ysize += linetable[i + 1];
234 printk("NG1: Screensize %dx%d\n", newport_xsize, newport_ysize);
237 static void newport_get_revisions(void)
239 unsigned int tmp;
240 unsigned int board_rev;
241 unsigned int rex3_rev;
242 unsigned int vc2_rev;
243 unsigned int cmap_rev;
244 unsigned int xmap9_rev;
245 unsigned int bt445_rev;
246 unsigned int bitplanes;
248 rex3_rev = npregs->cset.status & NPORT_STAT_VERS;
250 npregs->set.dcbmode = (DCB_CMAP0 | NCMAP_PROTOCOL |
251 NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
252 tmp = npregs->set.dcbdata0.bybytes.b3;
253 cmap_rev = tmp & 7;
254 board_rev = (tmp >> 4) & 7;
255 bitplanes = ((board_rev > 1) && (tmp & 0x80)) ? 8 : 24;
257 npregs->set.dcbmode = (DCB_CMAP1 | NCMAP_PROTOCOL |
258 NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
259 tmp = npregs->set.dcbdata0.bybytes.b3;
260 if ((tmp & 7) < cmap_rev)
261 cmap_rev = (tmp & 7);
263 vc2_rev = (newport_vc2_get(npregs, VC2_IREG_CONFIG) >> 5) & 7;
265 npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
266 XM9_CRS_REVISION | NPORT_DMODE_W1);
267 xmap9_rev = npregs->set.dcbdata0.bybytes.b3 & 7;
269 npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
270 BT445_CSR_ADDR_REG | NPORT_DMODE_W1);
271 npregs->set.dcbdata0.bybytes.b3 = BT445_REVISION_REG;
272 npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
273 BT445_CSR_REVISION | NPORT_DMODE_W1);
274 bt445_rev = (npregs->set.dcbdata0.bybytes.b3 >> 4) - 0x0a;
276 #define L(a) (char)('A'+(a))
277 printk
278 ("NG1: Revision %d, %d bitplanes, REX3 revision %c, VC2 revision %c, xmap9 revision %c, cmap revision %c, bt445 revision %c\n",
279 board_rev, bitplanes, L(rex3_rev), L(vc2_rev), L(xmap9_rev),
280 L(cmap_rev ? (cmap_rev + 1) : 0), L(bt445_rev));
281 #undef L
283 if (board_rev == 3) /* I don't know all affected revisions */
284 xcurs_correction = 21;
287 /* Can't be __init, take_over_console may call it later */
288 static const char *newport_startup(void)
290 int i;
292 if (!sgi_gfxaddr)
293 return NULL;
294 npregs = (struct newport_regs *) /* ioremap cannot fail */
295 ioremap(sgi_gfxaddr, sizeof(struct newport_regs));
296 npregs->cset.config = NPORT_CFG_GD0;
298 if (newport_wait(npregs))
299 goto out_unmap;
301 npregs->set.xstarti = TESTVAL;
302 if (npregs->set._xstart.word != XSTI_TO_FXSTART(TESTVAL))
303 goto out_unmap;
305 for (i = 0; i < MAX_NR_CONSOLES; i++)
306 font_data[i] = FONT_DATA;
308 newport_reset();
309 newport_get_revisions();
310 newport_get_screensize();
312 return "SGI Newport";
314 out_unmap:
315 iounmap((void *)npregs);
316 return NULL;
319 static void newport_init(struct vc_data *vc, int init)
321 vc->vc_cols = newport_xsize / 8;
322 vc->vc_rows = newport_ysize / 16;
323 vc->vc_can_do_color = 1;
326 static void newport_deinit(struct vc_data *c)
328 int i;
330 /* free memory used by user font */
331 for (i = 0; i < MAX_NR_CONSOLES; i++)
332 newport_set_def_font(i, NULL);
335 static void newport_clear(struct vc_data *vc, int sy, int sx, int height,
336 int width)
338 int xend = ((sx + width) << 3) - 1;
339 int ystart = ((sy << 4) + topscan) & 0x3ff;
340 int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
342 if (logo_active)
343 return;
345 if (ystart < yend) {
346 newport_clear_screen(sx << 3, ystart, xend, yend,
347 (vc->vc_color & 0xf0) >> 4);
348 } else {
349 newport_clear_screen(sx << 3, ystart, xend, 1023,
350 (vc->vc_color & 0xf0) >> 4);
351 newport_clear_screen(sx << 3, 0, xend, yend,
352 (vc->vc_color & 0xf0) >> 4);
356 static void newport_putc(struct vc_data *vc, int charattr, int ypos,
357 int xpos)
359 unsigned char *p;
361 p = &font_data[vc->vc_num][(charattr & 0xff) << 4];
362 charattr = (charattr >> 8) & 0xff;
363 xpos <<= 3;
364 ypos <<= 4;
366 newport_render_background(xpos, ypos, xpos, ypos,
367 (charattr & 0xf0) >> 4);
369 /* Set the color and drawing mode. */
370 newport_wait(npregs);
371 npregs->set.colori = charattr & 0xf;
372 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
373 NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
374 NPORT_DMODE0_L32);
376 /* Set coordinates for bitmap operation. */
377 npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff);
378 npregs->set.xyendi = ((xpos + 7) << 16);
379 newport_wait(npregs);
381 /* Go, baby, go... */
382 RENDER(npregs, p);
385 static void newport_putcs(struct vc_data *vc, const unsigned short *s,
386 int count, int ypos, int xpos)
388 int i;
389 int charattr;
390 unsigned char *p;
392 charattr = (scr_readw(s) >> 8) & 0xff;
394 xpos <<= 3;
395 ypos <<= 4;
397 if (!logo_active)
398 /* Clear the area behing the string */
399 newport_render_background(xpos, ypos,
400 xpos + ((count - 1) << 3), ypos,
401 (charattr & 0xf0) >> 4);
403 newport_wait(npregs);
405 /* Set the color and drawing mode. */
406 npregs->set.colori = charattr & 0xf;
407 npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
408 NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
409 NPORT_DMODE0_L32);
411 for (i = 0; i < count; i++, xpos += 8) {
412 p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4];
414 newport_wait(npregs);
416 /* Set coordinates for bitmap operation. */
417 npregs->set.xystarti =
418 (xpos << 16) | ((ypos + topscan) & 0x3ff);
419 npregs->set.xyendi = ((xpos + 7) << 16);
421 /* Go, baby, go... */
422 RENDER(npregs, p);
426 static void newport_cursor(struct vc_data *vc, int mode)
428 unsigned short treg;
429 int xcurs, ycurs;
431 switch (mode) {
432 case CM_ERASE:
433 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
434 newport_vc2_set(npregs, VC2_IREG_CONTROL,
435 (treg & ~(VC2_CTRL_ECDISP)));
436 break;
438 case CM_MOVE:
439 case CM_DRAW:
440 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
441 newport_vc2_set(npregs, VC2_IREG_CONTROL,
442 (treg | VC2_CTRL_ECDISP));
443 xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2;
444 ycurs = ((xcurs / vc->vc_cols) << 4) + 31;
445 xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction;
446 newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs);
447 newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs);
451 static int newport_switch(struct vc_data *vc)
453 static int logo_drawn = 0;
455 topscan = 0;
456 npregs->cset.topscan = 0x3ff;
458 if (!logo_drawn) {
459 newport_show_logo();
460 logo_drawn = 1;
461 logo_active = 1;
464 return 1;
467 static int newport_blank(struct vc_data *c, int blank, int mode_switch)
469 unsigned short treg;
471 if (blank == 0) {
472 /* unblank console */
473 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
474 newport_vc2_set(npregs, VC2_IREG_CONTROL,
475 (treg | VC2_CTRL_EDISP));
476 } else {
477 /* blank console */
478 treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
479 newport_vc2_set(npregs, VC2_IREG_CONTROL,
480 (treg & ~(VC2_CTRL_EDISP)));
482 return 1;
485 static int newport_set_font(int unit, struct console_font *op)
487 int w = op->width;
488 int h = op->height;
489 int size = h * op->charcount;
490 int i;
491 unsigned char *new_data, *data = op->data, *p;
493 /* ladis: when I grow up, there will be a day... and more sizes will
494 * be supported ;-) */
495 if ((w != 8) || (h != 16)
496 || (op->charcount != 256 && op->charcount != 512))
497 return -EINVAL;
499 if (!(new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size,
500 GFP_USER))) return -ENOMEM;
502 new_data += FONT_EXTRA_WORDS * sizeof(int);
503 FNTSIZE(new_data) = size;
504 FNTCHARCNT(new_data) = op->charcount;
505 REFCOUNT(new_data) = 0; /* usage counter */
507 p = new_data;
508 for (i = 0; i < op->charcount; i++) {
509 memcpy(p, data, h);
510 data += 32;
511 p += h;
514 /* check if font is already used by other console */
515 for (i = 0; i < MAX_NR_CONSOLES; i++) {
516 if (font_data[i] != FONT_DATA
517 && FNTSIZE(font_data[i]) == size
518 && !memcmp(font_data[i], new_data, size)) {
519 kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
520 /* current font is the same as the new one */
521 if (i == unit)
522 return 0;
523 new_data = font_data[i];
524 break;
527 /* old font is user font */
528 if (font_data[unit] != FONT_DATA) {
529 if (--REFCOUNT(font_data[unit]) == 0)
530 kfree(font_data[unit] -
531 FONT_EXTRA_WORDS * sizeof(int));
533 REFCOUNT(new_data)++;
534 font_data[unit] = new_data;
536 return 0;
539 static int newport_set_def_font(int unit, struct console_font *op)
541 if (font_data[unit] != FONT_DATA) {
542 if (--REFCOUNT(font_data[unit]) == 0)
543 kfree(font_data[unit] -
544 FONT_EXTRA_WORDS * sizeof(int));
545 font_data[unit] = FONT_DATA;
548 return 0;
551 static int newport_font_default(struct vc_data *vc, struct console_font *op, char *name)
553 return newport_set_def_font(vc->vc_num, op);
556 static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags)
558 return newport_set_font(vc->vc_num, font);
561 static int newport_set_palette(struct vc_data *vc, unsigned char *table)
563 return -EINVAL;
566 static int newport_scrolldelta(struct vc_data *vc, int lines)
568 /* there is (nearly) no off-screen memory, so we can't scroll back */
569 return 0;
572 static int newport_scroll(struct vc_data *vc, int t, int b, int dir,
573 int lines)
575 int count, x, y;
576 unsigned short *s, *d;
577 unsigned short chattr;
579 logo_active = 0; /* it's time to disable the logo now.. */
581 if (t == 0 && b == vc->vc_rows) {
582 if (dir == SM_UP) {
583 topscan = (topscan + (lines << 4)) & 0x3ff;
584 newport_clear_lines(vc->vc_rows - lines,
585 vc->vc_rows - 1,
586 (vc->vc_color & 0xf0) >> 4);
587 } else {
588 topscan = (topscan + (-lines << 4)) & 0x3ff;
589 newport_clear_lines(0, lines - 1,
590 (vc->vc_color & 0xf0) >> 4);
592 npregs->cset.topscan = (topscan - 1) & 0x3ff;
593 return 0;
596 count = (b - t - lines) * vc->vc_cols;
597 if (dir == SM_UP) {
598 x = 0;
599 y = t;
600 s = (unsigned short *) (vc->vc_origin +
601 vc->vc_size_row * (t + lines));
602 d = (unsigned short *) (vc->vc_origin +
603 vc->vc_size_row * t);
604 while (count--) {
605 chattr = scr_readw(s++);
606 if (chattr != scr_readw(d)) {
607 newport_putc(vc, chattr, y, x);
608 scr_writew(chattr, d);
610 d++;
611 if (++x == vc->vc_cols) {
612 x = 0;
613 y++;
616 d = (unsigned short *) (vc->vc_origin +
617 vc->vc_size_row * (b - lines));
618 x = 0;
619 y = b - lines;
620 for (count = 0; count < (lines * vc->vc_cols); count++) {
621 if (scr_readw(d) != vc->vc_video_erase_char) {
622 newport_putc(vc, vc->vc_video_erase_char,
623 y, x);
624 scr_writew(vc->vc_video_erase_char, d);
626 d++;
627 if (++x == vc->vc_cols) {
628 x = 0;
629 y++;
632 } else {
633 x = vc->vc_cols - 1;
634 y = b - 1;
635 s = (unsigned short *) (vc->vc_origin +
636 vc->vc_size_row * (b - lines) - 2);
637 d = (unsigned short *) (vc->vc_origin +
638 vc->vc_size_row * b - 2);
639 while (count--) {
640 chattr = scr_readw(s--);
641 if (chattr != scr_readw(d)) {
642 newport_putc(vc, chattr, y, x);
643 scr_writew(chattr, d);
645 d--;
646 if (x-- == 0) {
647 x = vc->vc_cols - 1;
648 y--;
651 d = (unsigned short *) (vc->vc_origin +
652 vc->vc_size_row * t);
653 x = 0;
654 y = t;
655 for (count = 0; count < (lines * vc->vc_cols); count++) {
656 if (scr_readw(d) != vc->vc_video_erase_char) {
657 newport_putc(vc, vc->vc_video_erase_char,
658 y, x);
659 scr_writew(vc->vc_video_erase_char, d);
661 d++;
662 if (++x == vc->vc_cols) {
663 x = 0;
664 y++;
668 return 1;
671 static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy,
672 int dx, int h, int w)
674 short xs, ys, xe, ye, xoffs, yoffs, tmp;
676 xs = sx << 3;
677 xe = ((sx + w) << 3) - 1;
679 * as bmove is only used to move stuff around in the same line
680 * (h == 1), we don't care about wrap arounds caused by topscan != 0
682 ys = ((sy << 4) + topscan) & 0x3ff;
683 ye = (((sy + h) << 4) - 1 + topscan) & 0x3ff;
684 xoffs = (dx - sx) << 3;
685 yoffs = (dy - sy) << 4;
686 if (xoffs > 0) {
687 /* move to the right, exchange starting points */
688 tmp = xe;
689 xe = xs;
690 xs = tmp;
692 newport_wait(npregs);
693 npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK |
694 NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
695 | NPORT_DMODE0_STOPY);
696 npregs->set.xystarti = (xs << 16) | ys;
697 npregs->set.xyendi = (xe << 16) | ye;
698 npregs->go.xymove = (xoffs << 16) | yoffs;
701 static int newport_dummy(struct vc_data *c)
703 return 0;
706 #define DUMMY (void *) newport_dummy
708 const struct consw newport_con = {
709 .owner = THIS_MODULE,
710 .con_startup = newport_startup,
711 .con_init = newport_init,
712 .con_deinit = newport_deinit,
713 .con_clear = newport_clear,
714 .con_putc = newport_putc,
715 .con_putcs = newport_putcs,
716 .con_cursor = newport_cursor,
717 .con_scroll = newport_scroll,
718 .con_bmove = newport_bmove,
719 .con_switch = newport_switch,
720 .con_blank = newport_blank,
721 .con_font_set = newport_font_set,
722 .con_font_default = newport_font_default,
723 .con_set_palette = newport_set_palette,
724 .con_scrolldelta = newport_scrolldelta,
725 .con_set_origin = DUMMY,
726 .con_save_screen = DUMMY
729 #ifdef MODULE
730 static int __init newport_console_init(void)
732 return take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
735 static void __exit newport_console_exit(void)
737 give_up_console(&newport_con);
738 iounmap((void *)npregs);
741 module_init(newport_console_init);
742 module_exit(newport_console_exit);
743 #endif
745 MODULE_LICENSE("GPL");