newport_con.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  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)
  11. */
  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>
  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>
  29. #include <linux/linux_logo.h>
  30. #include <linux/font.h>
  31. extern unsigned long sgi_gfxaddr;
  32. #define FONT_DATA ((unsigned char *)font_vga_8x16.data)
  33. /* borrowed from fbcon.c */
  34. #define REFCOUNT(fd) (((int *)(fd))[-1])
  35. #define FNTSIZE(fd) (((int *)(fd))[-2])
  36. #define FNTCHARCNT(fd) (((int *)(fd))[-3])
  37. #define FONT_EXTRA_WORDS 3
  38. static unsigned char *font_data[MAX_NR_CONSOLES];
  39. static struct newport_regs *npregs;
  40. static int logo_active;
  41. static int topscan;
  42. static int xcurs_correction = 29;
  43. static int newport_xsize;
  44. static int newport_ysize;
  45. static int newport_set_def_font(int unit, struct console_font *op);
  46. #define BMASK(c) (c << 24)
  47. #define RENDER(regs, cp) do { \
  48. (regs)->go.zpattern = BMASK((cp)[0x0]); (regs)->go.zpattern = BMASK((cp)[0x1]); \
  49. (regs)->go.zpattern = BMASK((cp)[0x2]); (regs)->go.zpattern = BMASK((cp)[0x3]); \
  50. (regs)->go.zpattern = BMASK((cp)[0x4]); (regs)->go.zpattern = BMASK((cp)[0x5]); \
  51. (regs)->go.zpattern = BMASK((cp)[0x6]); (regs)->go.zpattern = BMASK((cp)[0x7]); \
  52. (regs)->go.zpattern = BMASK((cp)[0x8]); (regs)->go.zpattern = BMASK((cp)[0x9]); \
  53. (regs)->go.zpattern = BMASK((cp)[0xa]); (regs)->go.zpattern = BMASK((cp)[0xb]); \
  54. (regs)->go.zpattern = BMASK((cp)[0xc]); (regs)->go.zpattern = BMASK((cp)[0xd]); \
  55. (regs)->go.zpattern = BMASK((cp)[0xe]); (regs)->go.zpattern = BMASK((cp)[0xf]); \
  56. } while(0)
  57. #define TESTVAL 0xdeadbeef
  58. #define XSTI_TO_FXSTART(val) (((val) & 0xffff) << 11)
  59. static inline void newport_render_background(int xstart, int ystart,
  60. int xend, int yend, int ci)
  61. {
  62. newport_wait(npregs);
  63. npregs->set.wrmask = 0xffffffff;
  64. npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
  65. NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
  66. | NPORT_DMODE0_STOPY);
  67. npregs->set.colori = ci;
  68. npregs->set.xystarti =
  69. (xstart << 16) | ((ystart + topscan) & 0x3ff);
  70. npregs->go.xyendi =
  71. ((xend + 7) << 16) | ((yend + topscan + 15) & 0x3ff);
  72. }
  73. static inline void newport_init_cmap(void)
  74. {
  75. unsigned short i;
  76. for (i = 0; i < 16; i++) {
  77. newport_bfwait(npregs);
  78. newport_cmap_setaddr(npregs, color_table[i]);
  79. newport_cmap_setrgb(npregs,
  80. default_red[i],
  81. default_grn[i], default_blu[i]);
  82. }
  83. }
  84. static void newport_show_logo(void)
  85. {
  86. #ifdef CONFIG_LOGO_SGI_CLUT224
  87. const struct linux_logo *logo = fb_find_logo(8);
  88. const unsigned char *clut = logo->clut;
  89. const unsigned char *data = logo->data;
  90. unsigned long i;
  91. for (i = 0; i < logo->clutsize; i++) {
  92. newport_bfwait(npregs);
  93. newport_cmap_setaddr(npregs, i + 0x20);
  94. newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]);
  95. clut += 3;
  96. }
  97. newport_wait(npregs);
  98. npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
  99. NPORT_DMODE0_CHOST);
  100. npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0);
  101. npregs->set.xyendi = ((newport_xsize - 1) << 16);
  102. newport_wait(npregs);
  103. for (i = 0; i < logo->width*logo->height; i++)
  104. npregs->go.hostrw0 = *data++ << 24;
  105. #endif /* CONFIG_LOGO_SGI_CLUT224 */
  106. }
  107. static inline void newport_clear_screen(int xstart, int ystart, int xend,
  108. int yend, int ci)
  109. {
  110. if (logo_active)
  111. return;
  112. newport_wait(npregs);
  113. npregs->set.wrmask = 0xffffffff;
  114. npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
  115. NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
  116. | NPORT_DMODE0_STOPY);
  117. npregs->set.colori = ci;
  118. npregs->set.xystarti = (xstart << 16) | ystart;
  119. npregs->go.xyendi = (xend << 16) | yend;
  120. }
  121. static inline void newport_clear_lines(int ystart, int yend, int ci)
  122. {
  123. ystart = ((ystart << 4) + topscan) & 0x3ff;
  124. yend = ((yend << 4) + topscan + 15) & 0x3ff;
  125. newport_clear_screen(0, ystart, 1280 + 63, yend, ci);
  126. }
  127. static void newport_reset(void)
  128. {
  129. unsigned short treg;
  130. int i;
  131. newport_wait(npregs);
  132. treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
  133. newport_vc2_set(npregs, VC2_IREG_CONTROL,
  134. (treg | VC2_CTRL_EVIDEO));
  135. treg = newport_vc2_get(npregs, VC2_IREG_CENTRY);
  136. newport_vc2_set(npregs, VC2_IREG_RADDR, treg);
  137. npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
  138. NPORT_DMODE_W2 | VC2_PROTOCOL);
  139. for (i = 0; i < 128; i++) {
  140. newport_bfwait(npregs);
  141. if (i == 92 || i == 94)
  142. npregs->set.dcbdata0.byshort.s1 = 0xff00;
  143. else
  144. npregs->set.dcbdata0.byshort.s1 = 0x0000;
  145. }
  146. newport_init_cmap();
  147. /* turn off popup plane */
  148. npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
  149. XM9_CRS_CONFIG | NPORT_DMODE_W1);
  150. npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
  151. npregs->set.dcbmode = (DCB_XMAP1 | R_DCB_XMAP9_PROTOCOL |
  152. XM9_CRS_CONFIG | NPORT_DMODE_W1);
  153. npregs->set.dcbdata0.bybytes.b3 &= ~XM9_PUPMODE;
  154. topscan = 0;
  155. npregs->cset.topscan = 0x3ff;
  156. npregs->cset.xywin = (4096 << 16) | 4096;
  157. /* Clear the screen. */
  158. newport_clear_screen(0, 0, 1280 + 63, 1024, 0);
  159. }
  160. /*
  161. * calculate the actual screen size by reading
  162. * the video timing out of the VC2
  163. */
  164. static void newport_get_screensize(void)
  165. {
  166. int i, cols;
  167. unsigned short ventry, treg;
  168. unsigned short linetable[128]; /* should be enough */
  169. ventry = newport_vc2_get(npregs, VC2_IREG_VENTRY);
  170. newport_vc2_set(npregs, VC2_IREG_RADDR, ventry);
  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. linetable[i] = npregs->set.dcbdata0.byshort.s1;
  176. }
  177. newport_xsize = newport_ysize = 0;
  178. for (i = 0; linetable[i + 1] && (i < sizeof(linetable)); i += 2) {
  179. cols = 0;
  180. newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
  181. npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
  182. NPORT_DMODE_W2 | VC2_PROTOCOL);
  183. do {
  184. newport_bfwait(npregs);
  185. treg = npregs->set.dcbdata0.byshort.s1;
  186. if ((treg & 1) == 0)
  187. cols += (treg >> 7) & 0xfe;
  188. if ((treg & 0x80) == 0) {
  189. newport_bfwait(npregs);
  190. treg = npregs->set.dcbdata0.byshort.s1;
  191. }
  192. } while ((treg & 0x8000) == 0);
  193. if (cols) {
  194. if (cols > newport_xsize)
  195. newport_xsize = cols;
  196. newport_ysize += linetable[i + 1];
  197. }
  198. }
  199. printk("NG1: Screensize %dx%d\n", newport_xsize, newport_ysize);
  200. }
  201. static void newport_get_revisions(void)
  202. {
  203. unsigned int tmp;
  204. unsigned int board_rev;
  205. unsigned int rex3_rev;
  206. unsigned int vc2_rev;
  207. unsigned int cmap_rev;
  208. unsigned int xmap9_rev;
  209. unsigned int bt445_rev;
  210. unsigned int bitplanes;
  211. rex3_rev = npregs->cset.status & NPORT_STAT_VERS;
  212. npregs->set.dcbmode = (DCB_CMAP0 | NCMAP_PROTOCOL |
  213. NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
  214. tmp = npregs->set.dcbdata0.bybytes.b3;
  215. cmap_rev = tmp & 7;
  216. board_rev = (tmp >> 4) & 7;
  217. bitplanes = ((board_rev > 1) && (tmp & 0x80)) ? 8 : 24;
  218. npregs->set.dcbmode = (DCB_CMAP1 | NCMAP_PROTOCOL |
  219. NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
  220. tmp = npregs->set.dcbdata0.bybytes.b3;
  221. if ((tmp & 7) < cmap_rev)
  222. cmap_rev = (tmp & 7);
  223. vc2_rev = (newport_vc2_get(npregs, VC2_IREG_CONFIG) >> 5) & 7;
  224. npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
  225. XM9_CRS_REVISION | NPORT_DMODE_W1);
  226. xmap9_rev = npregs->set.dcbdata0.bybytes.b3 & 7;
  227. npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
  228. BT445_CSR_ADDR_REG | NPORT_DMODE_W1);
  229. npregs->set.dcbdata0.bybytes.b3 = BT445_REVISION_REG;
  230. npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
  231. BT445_CSR_REVISION | NPORT_DMODE_W1);
  232. bt445_rev = (npregs->set.dcbdata0.bybytes.b3 >> 4) - 0x0a;
  233. #define L(a) (char)('A'+(a))
  234. printk
  235. ("NG1: Revision %d, %d bitplanes, REX3 revision %c, VC2 revision %c, xmap9 revision %c, cmap revision %c, bt445 revision %c\n",
  236. board_rev, bitplanes, L(rex3_rev), L(vc2_rev), L(xmap9_rev),
  237. L(cmap_rev ? (cmap_rev + 1) : 0), L(bt445_rev));
  238. #undef L
  239. if (board_rev == 3) /* I don't know all affected revisions */
  240. xcurs_correction = 21;
  241. }
  242. /* Can't be __init, take_over_console may call it later */
  243. static const char *newport_startup(void)
  244. {
  245. int i;
  246. if (!sgi_gfxaddr)
  247. return NULL;
  248. npregs = (struct newport_regs *) /* ioremap cannot fail */
  249. ioremap(sgi_gfxaddr, sizeof(struct newport_regs));
  250. npregs->cset.config = NPORT_CFG_GD0;
  251. if (newport_wait(npregs))
  252. goto out_unmap;
  253. npregs->set.xstarti = TESTVAL;
  254. if (npregs->set._xstart.word != XSTI_TO_FXSTART(TESTVAL))
  255. goto out_unmap;
  256. for (i = 0; i < MAX_NR_CONSOLES; i++)
  257. font_data[i] = FONT_DATA;
  258. newport_reset();
  259. newport_get_revisions();
  260. newport_get_screensize();
  261. return "SGI Newport";
  262. out_unmap:
  263. iounmap((void *)npregs);
  264. return NULL;
  265. }
  266. static void newport_init(struct vc_data *vc, int init)
  267. {
  268. vc->vc_cols = newport_xsize / 8;
  269. vc->vc_rows = newport_ysize / 16;
  270. vc->vc_can_do_color = 1;
  271. }
  272. static void newport_deinit(struct vc_data *c)
  273. {
  274. int i;
  275. /* free memory used by user font */
  276. for (i = 0; i < MAX_NR_CONSOLES; i++)
  277. newport_set_def_font(i, NULL);
  278. }
  279. static void newport_clear(struct vc_data *vc, int sy, int sx, int height,
  280. int width)
  281. {
  282. int xend = ((sx + width) << 3) - 1;
  283. int ystart = ((sy << 4) + topscan) & 0x3ff;
  284. int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
  285. if (logo_active)
  286. return;
  287. if (ystart < yend) {
  288. newport_clear_screen(sx << 3, ystart, xend, yend,
  289. (vc->vc_color & 0xf0) >> 4);
  290. } else {
  291. newport_clear_screen(sx << 3, ystart, xend, 1023,
  292. (vc->vc_color & 0xf0) >> 4);
  293. newport_clear_screen(sx << 3, 0, xend, yend,
  294. (vc->vc_color & 0xf0) >> 4);
  295. }
  296. }
  297. static void newport_putc(struct vc_data *vc, int charattr, int ypos,
  298. int xpos)
  299. {
  300. unsigned char *p;
  301. p = &font_data[vc->vc_num][(charattr & 0xff) << 4];
  302. charattr = (charattr >> 8) & 0xff;
  303. xpos <<= 3;
  304. ypos <<= 4;
  305. newport_render_background(xpos, ypos, xpos, ypos,
  306. (charattr & 0xf0) >> 4);
  307. /* Set the color and drawing mode. */
  308. newport_wait(npregs);
  309. npregs->set.colori = charattr & 0xf;
  310. npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
  311. NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
  312. NPORT_DMODE0_L32);
  313. /* Set coordinates for bitmap operation. */
  314. npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff);
  315. npregs->set.xyendi = ((xpos + 7) << 16);
  316. newport_wait(npregs);
  317. /* Go, baby, go... */
  318. RENDER(npregs, p);
  319. }
  320. static void newport_putcs(struct vc_data *vc, const unsigned short *s,
  321. int count, int ypos, int xpos)
  322. {
  323. int i;
  324. int charattr;
  325. unsigned char *p;
  326. charattr = (scr_readw(s) >> 8) & 0xff;
  327. xpos <<= 3;
  328. ypos <<= 4;
  329. if (!logo_active)
  330. /* Clear the area behing the string */
  331. newport_render_background(xpos, ypos,
  332. xpos + ((count - 1) << 3), ypos,
  333. (charattr & 0xf0) >> 4);
  334. newport_wait(npregs);
  335. /* Set the color and drawing mode. */
  336. npregs->set.colori = charattr & 0xf;
  337. npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
  338. NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
  339. NPORT_DMODE0_L32);
  340. for (i = 0; i < count; i++, xpos += 8) {
  341. p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4];
  342. newport_wait(npregs);
  343. /* Set coordinates for bitmap operation. */
  344. npregs->set.xystarti =
  345. (xpos << 16) | ((ypos + topscan) & 0x3ff);
  346. npregs->set.xyendi = ((xpos + 7) << 16);
  347. /* Go, baby, go... */
  348. RENDER(npregs, p);
  349. }
  350. }
  351. static void newport_cursor(struct vc_data *vc, int mode)
  352. {
  353. unsigned short treg;
  354. int xcurs, ycurs;
  355. switch (mode) {
  356. case CM_ERASE:
  357. treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
  358. newport_vc2_set(npregs, VC2_IREG_CONTROL,
  359. (treg & ~(VC2_CTRL_ECDISP)));
  360. break;
  361. case CM_MOVE:
  362. case CM_DRAW:
  363. treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
  364. newport_vc2_set(npregs, VC2_IREG_CONTROL,
  365. (treg | VC2_CTRL_ECDISP));
  366. xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2;
  367. ycurs = ((xcurs / vc->vc_cols) << 4) + 31;
  368. xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction;
  369. newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs);
  370. newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs);
  371. }
  372. }
  373. static int newport_switch(struct vc_data *vc)
  374. {
  375. static int logo_drawn = 0;
  376. topscan = 0;
  377. npregs->cset.topscan = 0x3ff;
  378. if (!logo_drawn) {
  379. newport_show_logo();
  380. logo_drawn = 1;
  381. logo_active = 1;
  382. }
  383. return 1;
  384. }
  385. static int newport_blank(struct vc_data *c, int blank, int mode_switch)
  386. {
  387. unsigned short treg;
  388. if (blank == 0) {
  389. /* unblank console */
  390. treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
  391. newport_vc2_set(npregs, VC2_IREG_CONTROL,
  392. (treg | VC2_CTRL_EDISP));
  393. } else {
  394. /* blank console */
  395. treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
  396. newport_vc2_set(npregs, VC2_IREG_CONTROL,
  397. (treg & ~(VC2_CTRL_EDISP)));
  398. }
  399. return 1;
  400. }
  401. static int newport_set_font(int unit, struct console_font *op)
  402. {
  403. int w = op->width;
  404. int h = op->height;
  405. int size = h * op->charcount;
  406. int i;
  407. unsigned char *new_data, *data = op->data, *p;
  408. /* ladis: when I grow up, there will be a day... and more sizes will
  409. * be supported ;-) */
  410. if ((w != 8) || (h != 16)
  411. || (op->charcount != 256 && op->charcount != 512))
  412. return -EINVAL;
  413. if (!(new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size,
  414. GFP_USER))) return -ENOMEM;
  415. new_data += FONT_EXTRA_WORDS * sizeof(int);
  416. FNTSIZE(new_data) = size;
  417. FNTCHARCNT(new_data) = op->charcount;
  418. REFCOUNT(new_data) = 0; /* usage counter */
  419. p = new_data;
  420. for (i = 0; i < op->charcount; i++) {
  421. memcpy(p, data, h);
  422. data += 32;
  423. p += h;
  424. }
  425. /* check if font is already used by other console */
  426. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  427. if (font_data[i] != FONT_DATA
  428. && FNTSIZE(font_data[i]) == size
  429. && !memcmp(font_data[i], new_data, size)) {
  430. kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
  431. /* current font is the same as the new one */
  432. if (i == unit)
  433. return 0;
  434. new_data = font_data[i];
  435. break;
  436. }
  437. }
  438. /* old font is user font */
  439. if (font_data[unit] != FONT_DATA) {
  440. if (--REFCOUNT(font_data[unit]) == 0)
  441. kfree(font_data[unit] -
  442. FONT_EXTRA_WORDS * sizeof(int));
  443. }
  444. REFCOUNT(new_data)++;
  445. font_data[unit] = new_data;
  446. return 0;
  447. }
  448. static int newport_set_def_font(int unit, struct console_font *op)
  449. {
  450. if (font_data[unit] != FONT_DATA) {
  451. if (--REFCOUNT(font_data[unit]) == 0)
  452. kfree(font_data[unit] -
  453. FONT_EXTRA_WORDS * sizeof(int));
  454. font_data[unit] = FONT_DATA;
  455. }
  456. return 0;
  457. }
  458. static int newport_font_default(struct vc_data *vc, struct console_font *op, char *name)
  459. {
  460. return newport_set_def_font(vc->vc_num, op);
  461. }
  462. static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags)
  463. {
  464. return newport_set_font(vc->vc_num, font);
  465. }
  466. static int newport_set_palette(struct vc_data *vc, unsigned char *table)
  467. {
  468. return -EINVAL;
  469. }
  470. static int newport_scrolldelta(struct vc_data *vc, int lines)
  471. {
  472. /* there is (nearly) no off-screen memory, so we can't scroll back */
  473. return 0;
  474. }
  475. static int newport_scroll(struct vc_data *vc, int t, int b, int dir,
  476. int lines)
  477. {
  478. int count, x, y;
  479. unsigned short *s, *d;
  480. unsigned short chattr;
  481. logo_active = 0; /* it's time to disable the logo now.. */
  482. if (t == 0 && b == vc->vc_rows) {
  483. if (dir == SM_UP) {
  484. topscan = (topscan + (lines << 4)) & 0x3ff;
  485. newport_clear_lines(vc->vc_rows - lines,
  486. vc->vc_rows - 1,
  487. (vc->vc_color & 0xf0) >> 4);
  488. } else {
  489. topscan = (topscan + (-lines << 4)) & 0x3ff;
  490. newport_clear_lines(0, lines - 1,
  491. (vc->vc_color & 0xf0) >> 4);
  492. }
  493. npregs->cset.topscan = (topscan - 1) & 0x3ff;
  494. return 0;
  495. }
  496. count = (b - t - lines) * vc->vc_cols;
  497. if (dir == SM_UP) {
  498. x = 0;
  499. y = t;
  500. s = (unsigned short *) (vc->vc_origin +
  501. vc->vc_size_row * (t + lines));
  502. d = (unsigned short *) (vc->vc_origin +
  503. vc->vc_size_row * t);
  504. while (count--) {
  505. chattr = scr_readw(s++);
  506. if (chattr != scr_readw(d)) {
  507. newport_putc(vc, chattr, y, x);
  508. scr_writew(chattr, d);
  509. }
  510. d++;
  511. if (++x == vc->vc_cols) {
  512. x = 0;
  513. y++;
  514. }
  515. }
  516. d = (unsigned short *) (vc->vc_origin +
  517. vc->vc_size_row * (b - lines));
  518. x = 0;
  519. y = b - lines;
  520. for (count = 0; count < (lines * vc->vc_cols); count++) {
  521. if (scr_readw(d) != vc->vc_video_erase_char) {
  522. newport_putc(vc, vc->vc_video_erase_char,
  523. y, x);
  524. scr_writew(vc->vc_video_erase_char, d);
  525. }
  526. d++;
  527. if (++x == vc->vc_cols) {
  528. x = 0;
  529. y++;
  530. }
  531. }
  532. } else {
  533. x = vc->vc_cols - 1;
  534. y = b - 1;
  535. s = (unsigned short *) (vc->vc_origin +
  536. vc->vc_size_row * (b - lines) - 2);
  537. d = (unsigned short *) (vc->vc_origin +
  538. vc->vc_size_row * b - 2);
  539. while (count--) {
  540. chattr = scr_readw(s--);
  541. if (chattr != scr_readw(d)) {
  542. newport_putc(vc, chattr, y, x);
  543. scr_writew(chattr, d);
  544. }
  545. d--;
  546. if (x-- == 0) {
  547. x = vc->vc_cols - 1;
  548. y--;
  549. }
  550. }
  551. d = (unsigned short *) (vc->vc_origin +
  552. vc->vc_size_row * t);
  553. x = 0;
  554. y = t;
  555. for (count = 0; count < (lines * vc->vc_cols); count++) {
  556. if (scr_readw(d) != vc->vc_video_erase_char) {
  557. newport_putc(vc, vc->vc_video_erase_char,
  558. y, x);
  559. scr_writew(vc->vc_video_erase_char, d);
  560. }
  561. d++;
  562. if (++x == vc->vc_cols) {
  563. x = 0;
  564. y++;
  565. }
  566. }
  567. }
  568. return 1;
  569. }
  570. static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy,
  571. int dx, int h, int w)
  572. {
  573. short xs, ys, xe, ye, xoffs, yoffs, tmp;
  574. xs = sx << 3;
  575. xe = ((sx + w) << 3) - 1;
  576. /*
  577. * as bmove is only used to move stuff around in the same line
  578. * (h == 1), we don't care about wrap arounds caused by topscan != 0
  579. */
  580. ys = ((sy << 4) + topscan) & 0x3ff;
  581. ye = (((sy + h) << 4) - 1 + topscan) & 0x3ff;
  582. xoffs = (dx - sx) << 3;
  583. yoffs = (dy - sy) << 4;
  584. if (xoffs > 0) {
  585. /* move to the right, exchange starting points */
  586. tmp = xe;
  587. xe = xs;
  588. xs = tmp;
  589. }
  590. newport_wait(npregs);
  591. npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK |
  592. NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX
  593. | NPORT_DMODE0_STOPY);
  594. npregs->set.xystarti = (xs << 16) | ys;
  595. npregs->set.xyendi = (xe << 16) | ye;
  596. npregs->go.xymove = (xoffs << 16) | yoffs;
  597. }
  598. static int newport_dummy(struct vc_data *c)
  599. {
  600. return 0;
  601. }
  602. #define DUMMY (void *) newport_dummy
  603. const struct consw newport_con = {
  604. .owner = THIS_MODULE,
  605. .con_startup = newport_startup,
  606. .con_init = newport_init,
  607. .con_deinit = newport_deinit,
  608. .con_clear = newport_clear,
  609. .con_putc = newport_putc,
  610. .con_putcs = newport_putcs,
  611. .con_cursor = newport_cursor,
  612. .con_scroll = newport_scroll,
  613. .con_bmove = newport_bmove,
  614. .con_switch = newport_switch,
  615. .con_blank = newport_blank,
  616. .con_font_set = newport_font_set,
  617. .con_font_default = newport_font_default,
  618. .con_set_palette = newport_set_palette,
  619. .con_scrolldelta = newport_scrolldelta,
  620. .con_set_origin = DUMMY,
  621. .con_save_screen = DUMMY
  622. };
  623. #ifdef MODULE
  624. static int __init newport_console_init(void)
  625. {
  626. return take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1);
  627. }
  628. static void __exit newport_console_exit(void)
  629. {
  630. give_up_console(&newport_con);
  631. iounmap((void *)npregs);
  632. }
  633. module_init(newport_console_init);
  634. module_exit(newport_console_exit);
  635. #endif
  636. MODULE_LICENSE("GPL");