sun3fb.c 18 KB

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