sun3fb.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*
  2. * linux/drivers/video/sun3fb.c -- Frame buffer driver for Sun3
  3. *
  4. * (C) 1998 Thomas Bogendoerfer
  5. *
  6. * This driver is bases on sbusfb.c, which is
  7. *
  8. * Copyright (C) 1998 Jakub Jelinek
  9. *
  10. * This driver is partly based on the Open Firmware console driver
  11. *
  12. * Copyright (C) 1997 Geert Uytterhoeven
  13. *
  14. * and SPARC console subsystem
  15. *
  16. * Copyright (C) 1995 Peter Zaitcev (zaitcev@yahoo.com)
  17. * Copyright (C) 1995-1997 David S. Miller (davem@caip.rutgers.edu)
  18. * Copyright (C) 1995-1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  19. * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk)
  20. * Copyright (C) 1996-1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  21. * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
  22. *
  23. * This file is subject to the terms and conditions of the GNU General Public
  24. * License. See the file COPYING in the main directory of this archive for
  25. * more details.
  26. */
  27. #include <linux/config.h>
  28. #include <linux/module.h>
  29. #include <linux/kernel.h>
  30. #include <linux/errno.h>
  31. #include <linux/string.h>
  32. #include <linux/mm.h>
  33. #include <linux/tty.h>
  34. #include <linux/slab.h>
  35. #include <linux/vmalloc.h>
  36. #include <linux/delay.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/fb.h>
  39. #include <linux/selection.h>
  40. #include <linux/init.h>
  41. #include <linux/console.h>
  42. #include <linux/kd.h>
  43. #include <linux/vt_kern.h>
  44. #include <asm/uaccess.h>
  45. #include <asm/pgtable.h> /* io_remap_page_range() */
  46. #ifdef CONFIG_SUN3
  47. #include <asm/oplib.h>
  48. #include <asm/machines.h>
  49. #include <asm/idprom.h>
  50. #define CGFOUR_OBMEM_ADDR 0x1f300000
  51. #define BWTWO_OBMEM_ADDR 0x1f000000
  52. #define BWTWO_OBMEM50_ADDR 0x00100000
  53. #endif
  54. #ifdef CONFIG_SUN3X
  55. #include <asm/sun3x.h>
  56. #endif
  57. #include <video/sbusfb.h>
  58. #define DEFAULT_CURSOR_BLINK_RATE (2*HZ/5)
  59. #define CURSOR_SHAPE 1
  60. #define CURSOR_BLINK 2
  61. #define mymemset(x,y) memset(x,0,y)
  62. /*
  63. * Interface used by the world
  64. */
  65. int sun3fb_init(void);
  66. void sun3fb_setup(char *options);
  67. static char fontname[40] __initdata = { 0 };
  68. static int curblink __initdata = 1;
  69. static int sun3fb_get_fix(struct fb_fix_screeninfo *fix, int con,
  70. struct fb_info *info);
  71. static int sun3fb_get_var(struct fb_var_screeninfo *var, int con,
  72. struct fb_info *info);
  73. static int sun3fb_set_var(struct fb_var_screeninfo *var, int con,
  74. struct fb_info *info);
  75. static int sun3fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
  76. struct fb_info *info);
  77. static int sun3fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
  78. struct fb_info *info);
  79. static int sun3fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
  80. u_int transp, struct fb_info *info);
  81. static int sun3fb_blank(int blank, struct fb_info *info);
  82. static void sun3fb_cursor(struct display *p, int mode, int x, int y);
  83. static void sun3fb_clear_margin(struct display *p, int s);
  84. /*
  85. * Interface to the low level console driver
  86. */
  87. static int sun3fbcon_switch(int con, struct fb_info *info);
  88. static int sun3fbcon_updatevar(int con, struct fb_info *info);
  89. /*
  90. * Internal routines
  91. */
  92. static int sun3fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
  93. u_int *transp, struct fb_info *info);
  94. static struct fb_ops sun3fb_ops = {
  95. .owner = THIS_MODULE,
  96. .fb_get_fix = sun3fb_get_fix,
  97. .fb_get_var = sun3fb_get_var,
  98. .fb_set_var = sun3fb_set_var,
  99. .fb_get_cmap = sun3fb_get_cmap,
  100. .fb_set_cmap = sun3fb_set_cmap,
  101. .fb_setcolreg = sun3fb_setcolreg,
  102. .fb_blank = sun3fb_blank,
  103. };
  104. static void sun3fb_clear_margin(struct display *p, int s)
  105. {
  106. struct fb_info_sbusfb *fb = sbusfbinfod(p);
  107. return;
  108. if (fb->switch_from_graph)
  109. (*fb->switch_from_graph)(fb);
  110. if (fb->fill) {
  111. unsigned short rects [16];
  112. rects [0] = 0;
  113. rects [1] = 0;
  114. rects [2] = fb->var.xres_virtual;
  115. rects [3] = fb->y_margin;
  116. rects [4] = 0;
  117. rects [5] = fb->y_margin;
  118. rects [6] = fb->x_margin;
  119. rects [7] = fb->var.yres_virtual;
  120. rects [8] = fb->var.xres_virtual - fb->x_margin;
  121. rects [9] = fb->y_margin;
  122. rects [10] = fb->var.xres_virtual;
  123. rects [11] = fb->var.yres_virtual;
  124. rects [12] = fb->x_margin;
  125. rects [13] = fb->var.yres_virtual - fb->y_margin;
  126. rects [14] = fb->var.xres_virtual - fb->x_margin;
  127. rects [15] = fb->var.yres_virtual;
  128. (*fb->fill)(fb, p, s, 4, rects);
  129. } else {
  130. unsigned char *fb_base = fb->info.screen_base, *q;
  131. int skip_bytes = fb->y_margin * fb->var.xres_virtual;
  132. int scr_size = fb->var.xres_virtual * fb->var.yres_virtual;
  133. int h, he, incr, size;
  134. he = fb->var.yres;
  135. if (fb->var.bits_per_pixel == 1) {
  136. fb_base -= (skip_bytes + fb->x_margin) / 8;
  137. skip_bytes /= 8;
  138. scr_size /= 8;
  139. mymemset (fb_base, skip_bytes - fb->x_margin / 8);
  140. mymemset (fb_base + scr_size - skip_bytes + fb->x_margin / 8, skip_bytes - fb->x_margin / 8);
  141. incr = fb->var.xres_virtual / 8;
  142. size = fb->x_margin / 8 * 2;
  143. for (q = fb_base + skip_bytes - fb->x_margin / 8, h = 0;
  144. h <= he; q += incr, h++)
  145. mymemset (q, size);
  146. } else {
  147. fb_base -= (skip_bytes + fb->x_margin);
  148. memset (fb_base, attr_bgcol(p,s), skip_bytes - fb->x_margin);
  149. memset (fb_base + scr_size - skip_bytes + fb->x_margin, attr_bgcol(p,s), skip_bytes - fb->x_margin);
  150. incr = fb->var.xres_virtual;
  151. size = fb->x_margin * 2;
  152. for (q = fb_base + skip_bytes - fb->x_margin, h = 0;
  153. h <= he; q += incr, h++)
  154. memset (q, attr_bgcol(p,s), size);
  155. }
  156. }
  157. }
  158. static void sun3fb_disp_setup(struct display *p)
  159. {
  160. struct fb_info_sbusfb *fb = sbusfbinfod(p);
  161. if (fb->setup)
  162. fb->setup(p);
  163. sun3fb_clear_margin(p, 0);
  164. }
  165. /*
  166. * Get the Fixed Part of the Display
  167. */
  168. static int sun3fb_get_fix(struct fb_fix_screeninfo *fix, int con,
  169. struct fb_info *info)
  170. {
  171. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  172. memcpy(fix, &fb->fix, sizeof(struct fb_fix_screeninfo));
  173. return 0;
  174. }
  175. /*
  176. * Get the User Defined Part of the Display
  177. */
  178. static int sun3fb_get_var(struct fb_var_screeninfo *var, int con,
  179. struct fb_info *info)
  180. {
  181. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  182. memcpy(var, &fb->var, sizeof(struct fb_var_screeninfo));
  183. return 0;
  184. }
  185. /*
  186. * Set the User Defined Part of the Display
  187. */
  188. static int sun3fb_set_var(struct fb_var_screeninfo *var, int con,
  189. struct fb_info *info)
  190. {
  191. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  192. if (var->xres > fb->var.xres || var->yres > fb->var.yres ||
  193. var->xres_virtual > fb->var.xres_virtual ||
  194. var->yres_virtual > fb->var.yres_virtual ||
  195. var->bits_per_pixel != fb->var.bits_per_pixel ||
  196. var->nonstd ||
  197. (var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED)
  198. return -EINVAL;
  199. memcpy(var, &fb->var, sizeof(struct fb_var_screeninfo));
  200. return 0;
  201. }
  202. /*
  203. * Hardware cursor
  204. */
  205. static unsigned char hw_cursor_cmap[2] = { 0, 0xff };
  206. static void
  207. sun3fb_cursor_timer_handler(unsigned long dev_addr)
  208. {
  209. struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)dev_addr;
  210. if (!fb->setcursor) return;
  211. if (fb->cursor.mode & CURSOR_BLINK) {
  212. fb->cursor.enable ^= 1;
  213. fb->setcursor(fb);
  214. }
  215. fb->cursor.timer.expires = jiffies + fb->cursor.blink_rate;
  216. add_timer(&fb->cursor.timer);
  217. }
  218. static void sun3fb_cursor(struct display *p, int mode, int x, int y)
  219. {
  220. struct fb_info_sbusfb *fb = sbusfbinfod(p);
  221. switch (mode) {
  222. case CM_ERASE:
  223. fb->cursor.mode &= ~CURSOR_BLINK;
  224. fb->cursor.enable = 0;
  225. (*fb->setcursor)(fb);
  226. break;
  227. case CM_MOVE:
  228. case CM_DRAW:
  229. if (fb->cursor.mode & CURSOR_SHAPE) {
  230. fb->cursor.size.fbx = fontwidth(p);
  231. fb->cursor.size.fby = fontheight(p);
  232. fb->cursor.chot.fbx = 0;
  233. fb->cursor.chot.fby = 0;
  234. fb->cursor.enable = 1;
  235. memset (fb->cursor.bits, 0, sizeof (fb->cursor.bits));
  236. fb->cursor.bits[0][fontheight(p) - 2] = (0xffffffff << (32 - fontwidth(p)));
  237. fb->cursor.bits[1][fontheight(p) - 2] = (0xffffffff << (32 - fontwidth(p)));
  238. fb->cursor.bits[0][fontheight(p) - 1] = (0xffffffff << (32 - fontwidth(p)));
  239. fb->cursor.bits[1][fontheight(p) - 1] = (0xffffffff << (32 - fontwidth(p)));
  240. (*fb->setcursormap) (fb, hw_cursor_cmap, hw_cursor_cmap, hw_cursor_cmap);
  241. (*fb->setcurshape) (fb);
  242. }
  243. fb->cursor.mode = CURSOR_BLINK;
  244. if (fontwidthlog(p))
  245. fb->cursor.cpos.fbx = (x << fontwidthlog(p)) + fb->x_margin;
  246. else
  247. fb->cursor.cpos.fbx = (x * fontwidth(p)) + fb->x_margin;
  248. if (fontheightlog(p))
  249. fb->cursor.cpos.fby = (y << fontheightlog(p)) + fb->y_margin;
  250. else
  251. fb->cursor.cpos.fby = (y * fontheight(p)) + fb->y_margin;
  252. (*fb->setcursor)(fb);
  253. break;
  254. }
  255. }
  256. /*
  257. * Get the Colormap
  258. */
  259. static int sun3fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
  260. struct fb_info *info)
  261. {
  262. if (con == info->currcon) /* current console? */
  263. return fb_get_cmap(cmap, kspc, sun3fb_getcolreg, info);
  264. else if (fb_display[con].cmap.len) /* non default colormap? */
  265. fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
  266. else
  267. fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), cmap, kspc ? 0 : 2);
  268. return 0;
  269. }
  270. /*
  271. * Set the Colormap
  272. */
  273. static int sun3fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
  274. struct fb_info *info)
  275. {
  276. int err;
  277. if (!fb_display[con].cmap.len) { /* no colormap allocated? */
  278. if ((err = fb_alloc_cmap(&fb_display[con].cmap, 1<<fb_display[con].var.bits_per_pixel, 0)))
  279. return err;
  280. }
  281. if (con == info->currcon) { /* current console? */
  282. err = fb_set_cmap(cmap, kspc, info);
  283. if (!err) {
  284. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  285. if (fb->loadcmap)
  286. (*fb->loadcmap)(fb, &fb_display[con], cmap->start, cmap->len);
  287. }
  288. return err;
  289. } else
  290. fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
  291. return 0;
  292. }
  293. /*
  294. * Setup: parse used options
  295. */
  296. void __init sun3fb_setup(char *options)
  297. {
  298. char *p;
  299. for (p = options;;) {
  300. if (!strncmp(p, "font=", 5)) {
  301. int i;
  302. for (i = 0; i < sizeof(fontname) - 1; i++)
  303. if (p[i+5] == ' ' || !p[i+5])
  304. break;
  305. memcpy(fontname, p+5, i);
  306. fontname[i] = 0;
  307. } else if (!strncmp(p, "noblink", 7))
  308. curblink = 0;
  309. while (*p && *p != ' ' && *p != ',') p++;
  310. if (*p != ',') break;
  311. p++;
  312. }
  313. return;
  314. }
  315. static int sun3fbcon_switch(int con, struct fb_info *info)
  316. {
  317. int x_margin, y_margin;
  318. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  319. int lastconsole;
  320. /* Do we have to save the colormap? */
  321. if (fb_display[info->currcon].cmap.len)
  322. fb_get_cmap(&fb_display[info->currcon].cmap, 1, sun3fb_getcolreg, info);
  323. if (info->display_fg) {
  324. lastconsole = info->display_fg->vc_num;
  325. if (lastconsole != con &&
  326. (fontwidth(&fb_display[lastconsole]) != fontwidth(&fb_display[con]) ||
  327. fontheight(&fb_display[lastconsole]) != fontheight(&fb_display[con])))
  328. fb->cursor.mode |= CURSOR_SHAPE;
  329. }
  330. x_margin = (fb_display[con].var.xres_virtual - fb_display[con].var.xres) / 2;
  331. y_margin = (fb_display[con].var.yres_virtual - fb_display[con].var.yres) / 2;
  332. if (fb->margins)
  333. fb->margins(fb, &fb_display[con], x_margin, y_margin);
  334. if (fb->graphmode || fb->x_margin != x_margin || fb->y_margin != y_margin) {
  335. fb->x_margin = x_margin; fb->y_margin = y_margin;
  336. sun3fb_clear_margin(&fb_display[con], 0);
  337. }
  338. info->currcon = con;
  339. /* Install new colormap */
  340. do_install_cmap(con, info);
  341. return 0;
  342. }
  343. /*
  344. * Update the `var' structure (called by fbcon.c)
  345. */
  346. static int sun3fbcon_updatevar(int con, struct fb_info *info)
  347. {
  348. /* Nothing */
  349. return 0;
  350. }
  351. /*
  352. * Blank the display.
  353. */
  354. static int sun3fb_blank(int blank, struct fb_info *info)
  355. {
  356. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  357. if (blank && fb->blank)
  358. return fb->blank(fb);
  359. else if (!blank && fb->unblank)
  360. return fb->unblank(fb);
  361. return 0;
  362. }
  363. /*
  364. * Read a single color register and split it into
  365. * colors/transparent. Return != 0 for invalid regno.
  366. */
  367. static int sun3fb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
  368. u_int *transp, struct fb_info *info)
  369. {
  370. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  371. if (!fb->color_map || regno > 255)
  372. return 1;
  373. *red = (fb->color_map CM(regno, 0)<<8) | fb->color_map CM(regno, 0);
  374. *green = (fb->color_map CM(regno, 1)<<8) | fb->color_map CM(regno, 1);
  375. *blue = (fb->color_map CM(regno, 2)<<8) | fb->color_map CM(regno, 2);
  376. *transp = 0;
  377. return 0;
  378. }
  379. /*
  380. * Set a single color register. The values supplied are already
  381. * rounded down to the hardware's capabilities (according to the
  382. * entries in the var structure). Return != 0 for invalid regno.
  383. */
  384. static int sun3fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
  385. u_int transp, struct fb_info *info)
  386. {
  387. struct fb_info_sbusfb *fb = sbusfbinfo(info);
  388. if (!fb->color_map || regno > 255)
  389. return 1;
  390. red >>= 8;
  391. green >>= 8;
  392. blue >>= 8;
  393. fb->color_map CM(regno, 0) = red;
  394. fb->color_map CM(regno, 1) = green;
  395. fb->color_map CM(regno, 2) = blue;
  396. return 0;
  397. }
  398. static int sun3fb_set_font(struct display *p, int width, int height)
  399. {
  400. int w = p->var.xres_virtual, h = p->var.yres_virtual;
  401. int depth = p->var.bits_per_pixel;
  402. struct fb_info_sbusfb *fb = sbusfbinfod(p);
  403. int x_margin, y_margin;
  404. if (depth > 8) depth = 8;
  405. x_margin = (w % width) / 2;
  406. y_margin = (h % height) / 2;
  407. p->var.xres = w - 2*x_margin;
  408. p->var.yres = h - 2*y_margin;
  409. fb->cursor.mode |= CURSOR_SHAPE;
  410. if (fb->margins)
  411. fb->margins(fb, p, x_margin, y_margin);
  412. if (fb->x_margin != x_margin || fb->y_margin != y_margin) {
  413. fb->x_margin = x_margin; fb->y_margin = y_margin;
  414. sun3fb_clear_margin(p, 0);
  415. }
  416. return 1;
  417. }
  418. void sun3fb_palette(int enter)
  419. {
  420. int i;
  421. struct display *p;
  422. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  423. p = &fb_display[i];
  424. if (p->dispsw && p->dispsw->setup == sun3fb_disp_setup &&
  425. p->fb_info->display_fg &&
  426. p->fb_info->display_fg->vc_num == i) {
  427. struct fb_info_sbusfb *fb = sbusfbinfod(p);
  428. if (fb->restore_palette) {
  429. if (enter)
  430. fb->restore_palette(fb);
  431. else if (vc_cons[i].d->vc_mode != KD_GRAPHICS)
  432. vc_cons[i].d->vc_sw->con_set_palette(vc_cons[i].d, color_table);
  433. }
  434. }
  435. }
  436. }
  437. /*
  438. * Initialisation
  439. */
  440. static int __init sun3fb_init_fb(int fbtype, unsigned long addr)
  441. {
  442. static struct sbus_dev sdb;
  443. struct fb_fix_screeninfo *fix;
  444. struct fb_var_screeninfo *var;
  445. struct display *disp;
  446. struct fb_info_sbusfb *fb;
  447. struct fbtype *type;
  448. int linebytes, w, h, depth;
  449. char *p = NULL;
  450. fb = kmalloc(sizeof(struct fb_info_sbusfb), GFP_ATOMIC);
  451. if (!fb)
  452. return -ENOMEM;
  453. memset(fb, 0, sizeof(struct fb_info_sbusfb));
  454. fix = &fb->fix;
  455. var = &fb->var;
  456. disp = &fb->disp;
  457. type = &fb->type;
  458. sdb.reg_addrs[0].phys_addr = addr;
  459. fb->sbdp = &sdb;
  460. type->fb_type = fbtype;
  461. type->fb_height = h = 900;
  462. type->fb_width = w = 1152;
  463. sizechange:
  464. type->fb_depth = depth = (fbtype == FBTYPE_SUN2BW) ? 1 : 8;
  465. linebytes = w * depth / 8;
  466. type->fb_size = PAGE_ALIGN((linebytes) * h);
  467. /*
  468. fb->x_margin = (w & 7) / 2;
  469. fb->y_margin = (h & 15) / 2;
  470. */
  471. fb->x_margin = fb->y_margin = 0;
  472. var->xres_virtual = w;
  473. var->yres_virtual = h;
  474. var->xres = w - 2*fb->x_margin;
  475. var->yres = h - 2*fb->y_margin;
  476. var->bits_per_pixel = depth;
  477. var->height = var->width = -1;
  478. var->pixclock = 10000;
  479. var->vmode = FB_VMODE_NONINTERLACED;
  480. var->red.length = var->green.length = var->blue.length = 8;
  481. fix->line_length = linebytes;
  482. fix->smem_len = type->fb_size;
  483. fix->type = FB_TYPE_PACKED_PIXELS;
  484. fix->visual = FB_VISUAL_PSEUDOCOLOR;
  485. fb->info.fbops = &sun3fb_ops;
  486. fb->info.disp = disp;
  487. fb->info.currcon = -1;
  488. strcpy(fb->info.fontname, fontname);
  489. fb->info.changevar = NULL;
  490. fb->info.switch_con = &sun3fbcon_switch;
  491. fb->info.updatevar = &sun3fbcon_updatevar;
  492. fb->info.flags = FBINFO_FLAG_DEFAULT;
  493. fb->cursor.hwsize.fbx = 32;
  494. fb->cursor.hwsize.fby = 32;
  495. if (depth > 1 && !fb->color_map) {
  496. if((fb->color_map = kmalloc(256 * 3, GFP_ATOMIC))==NULL)
  497. return -ENOMEM;
  498. }
  499. switch(fbtype) {
  500. #ifdef CONFIG_FB_CGSIX
  501. case FBTYPE_SUNFAST_COLOR:
  502. p = cgsixfb_init(fb); break;
  503. #endif
  504. #ifdef CONFIG_FB_BWTWO
  505. case FBTYPE_SUN2BW:
  506. p = bwtwofb_init(fb); break;
  507. #endif
  508. #ifdef CONFIG_FB_CGTHREE
  509. case FBTYPE_SUN4COLOR:
  510. case FBTYPE_SUN3COLOR:
  511. type->fb_size = 0x100000;
  512. p = cgthreefb_init(fb); break;
  513. #endif
  514. }
  515. fix->smem_start = (unsigned long)fb->info.screen_base; // FIXME
  516. if (!p) {
  517. kfree(fb);
  518. return -ENODEV;
  519. }
  520. if (p == SBUSFBINIT_SIZECHANGE)
  521. goto sizechange;
  522. disp->dispsw = &fb->dispsw;
  523. if (fb->setcursor) {
  524. fb->dispsw.cursor = sun3fb_cursor;
  525. if (curblink) {
  526. fb->cursor.blink_rate = DEFAULT_CURSOR_BLINK_RATE;
  527. init_timer(&fb->cursor.timer);
  528. fb->cursor.timer.expires = jiffies + fb->cursor.blink_rate;
  529. fb->cursor.timer.data = (unsigned long)fb;
  530. fb->cursor.timer.function = sun3fb_cursor_timer_handler;
  531. add_timer(&fb->cursor.timer);
  532. }
  533. }
  534. fb->cursor.mode = CURSOR_SHAPE;
  535. fb->dispsw.set_font = sun3fb_set_font;
  536. fb->setup = fb->dispsw.setup;
  537. fb->dispsw.setup = sun3fb_disp_setup;
  538. fb->dispsw.clear_margins = NULL;
  539. disp->var = *var;
  540. disp->visual = fix->visual;
  541. disp->type = fix->type;
  542. disp->type_aux = fix->type_aux;
  543. disp->line_length = fix->line_length;
  544. if (fb->blank)
  545. disp->can_soft_blank = 1;
  546. sun3fb_set_var(var, -1, &fb->info);
  547. if (register_framebuffer(&fb->info) < 0) {
  548. kfree(fb);
  549. return -EINVAL;
  550. }
  551. printk("fb%d: %s\n", fb->info.node, p);
  552. return 0;
  553. }
  554. int __init sun3fb_init(void)
  555. {
  556. extern int con_is_present(void);
  557. unsigned long addr;
  558. char p4id;
  559. if (!con_is_present()) return -ENODEV;
  560. #ifdef CONFIG_SUN3
  561. switch(*(romvec->pv_fbtype))
  562. {
  563. case FBTYPE_SUN2BW:
  564. addr = 0xfe20000;
  565. return sun3fb_init_fb(FBTYPE_SUN2BW, addr);
  566. case FBTYPE_SUN3COLOR:
  567. case FBTYPE_SUN4COLOR:
  568. if(idprom->id_machtype != (SM_SUN3|SM_3_60)) {
  569. printk("sun3fb: cgthree/four only supported on 3/60\n");
  570. return -ENODEV;
  571. }
  572. addr = CGFOUR_OBMEM_ADDR;
  573. return sun3fb_init_fb(*(romvec->pv_fbtype), addr);
  574. default:
  575. printk("sun3fb: unsupported framebuffer\n");
  576. return -ENODEV;
  577. }
  578. #else
  579. addr = SUN3X_VIDEO_BASE;
  580. p4id = *(char *)SUN3X_VIDEO_P4ID;
  581. p4id = (p4id == 0x45) ? p4id : (p4id & 0xf0);
  582. switch (p4id) {
  583. case 0x00:
  584. return sun3fb_init_fb(FBTYPE_SUN2BW, addr);
  585. #if 0 /* not yet */
  586. case 0x40:
  587. return sun3fb_init_fb(FBTYPE_SUN4COLOR, addr);
  588. break;
  589. case 0x45:
  590. return sun3fb_init_fb(FBTYPE_SUN8COLOR, addr);
  591. break;
  592. #endif
  593. case 0x60:
  594. return sun3fb_init_fb(FBTYPE_SUNFAST_COLOR, addr);
  595. }
  596. #endif
  597. return -ENODEV;
  598. }
  599. MODULE_LICENSE("GPL");