Import 2.3.18pre1
[davej-history.git] / drivers / video / leofb.c
blob9daa664214fc541de3e006fa42f30ebc427b5feb
1 /* $Id: leofb.c,v 1.7 1999/08/09 11:06:52 jj Exp $
2 * leofb.c: Leo (ZX) 24/8bit frame buffer driver
4 * Copyright (C) 1996-1999 Jakub Jelinek (jj@ultra.linux.cz)
5 * Copyright (C) 1997 Michal Rehacek (Michal.Rehacek@st.mff.cuni.cz)
6 */
8 #include <linux/module.h>
9 #include <linux/sched.h>
10 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/string.h>
13 #include <linux/mm.h>
14 #include <linux/tty.h>
15 #include <linux/malloc.h>
16 #include <linux/vmalloc.h>
17 #include <linux/delay.h>
18 #include <linux/interrupt.h>
19 #include <linux/fb.h>
20 #include <linux/init.h>
21 #include <linux/selection.h>
23 #include <video/sbusfb.h>
24 #include <asm/io.h>
26 #define LEO_OFF_LC_SS0_KRN 0x00200000
27 #define LEO_OFF_LC_SS0_USR 0x00201000
28 #define LEO_OFF_LC_SS1_KRN 0x01200000
29 #define LEO_OFF_LC_SS1_USR 0x01201000
30 #define LEO_OFF_LD_SS0 0x00400000
31 #define LEO_OFF_LD_SS1 0x01400000
32 #define LEO_OFF_LD_GBL 0x00401000
33 #define LEO_OFF_LX_KRN 0x00600000
34 #define LEO_OFF_LX_CURSOR 0x00601000
35 #define LEO_OFF_SS0 0x00800000
36 #define LEO_OFF_SS1 0x01800000
37 #define LEO_OFF_UNK 0x00602000
38 #define LEO_OFF_UNK2 0x00000000
40 #define LEO_CUR_ENABLE 0x00000080
41 #define LEO_CUR_UPDATE 0x00000030
42 #define LEO_CUR_PROGRESS 0x00000006
43 #define LEO_CUR_UPDATECMAP 0x00000003
45 #define LEO_CUR_TYPE_MASK 0x00000000
46 #define LEO_CUR_TYPE_IMAGE 0x00000020
47 #define LEO_CUR_TYPE_CMAP 0x00000050
49 struct leo_cursor {
50 u8 xxx0[16];
51 volatile u32 cur_type;
52 volatile u32 cur_misc;
53 volatile u32 cur_cursxy;
54 volatile u32 cur_data;
57 #define LEO_KRN_TYPE_CLUT0 0x00001000
58 #define LEO_KRN_TYPE_CLUT1 0x00001001
59 #define LEO_KRN_TYPE_CLUT2 0x00001002
60 #define LEO_KRN_TYPE_WID 0x00001003
61 #define LEO_KRN_TYPE_UNK 0x00001006
62 #define LEO_KRN_TYPE_VIDEO 0x00002003
63 #define LEO_KRN_TYPE_CLUTDATA 0x00004000
64 #define LEO_KRN_CSR_ENABLE 0x00000008
65 #define LEO_KRN_CSR_PROGRESS 0x00000004
66 #define LEO_KRN_CSR_UNK 0x00000002
67 #define LEO_KRN_CSR_UNK2 0x00000001
69 struct leo_lx_krn {
70 volatile u32 krn_type;
71 volatile u32 krn_csr;
72 volatile u32 krn_value;
75 struct leo_lc_ss0_krn {
76 volatile u32 misc;
77 u8 xxx0[0x800-4];
78 volatile u32 rev;
81 struct leo_lc_ss0_usr {
82 volatile u32 csr;
83 volatile u32 addrspace;
84 volatile u32 fontmsk;
85 volatile u32 fontt;
86 volatile u32 extent;
87 volatile u32 src;
88 u32 dst;
89 volatile u32 copy;
90 volatile u32 fill;
93 struct leo_lc_ss1_krn {
94 u8 unknown;
97 struct leo_lc_ss1_usr {
98 u8 unknown;
101 struct leo_ld {
102 u8 xxx0[0xe00];
103 volatile u32 csr;
104 volatile u32 wid;
105 volatile u32 wmask;
106 volatile u32 widclip;
107 volatile u32 vclipmin;
108 volatile u32 vclipmax;
109 volatile u32 pickmin; /* SS1 only */
110 volatile u32 pickmax; /* SS1 only */
111 volatile u32 fg;
112 volatile u32 bg;
113 volatile u32 src; /* Copy/Scroll (SS0 only) */
114 volatile u32 dst; /* Copy/Scroll/Fill (SS0 only) */
115 volatile u32 extent; /* Copy/Scroll/Fill size (SS0 only) */
116 u32 xxx1[3];
117 volatile u32 setsem; /* SS1 only */
118 volatile u32 clrsem; /* SS1 only */
119 volatile u32 clrpick; /* SS1 only */
120 volatile u32 clrdat; /* SS1 only */
121 volatile u32 alpha; /* SS1 only */
122 u8 xxx2[0x2c];
123 volatile u32 winbg;
124 volatile u32 planemask;
125 volatile u32 rop;
126 volatile u32 z;
127 volatile u32 dczf; /* SS1 only */
128 volatile u32 dczb; /* SS1 only */
129 volatile u32 dcs; /* SS1 only */
130 volatile u32 dczs; /* SS1 only */
131 volatile u32 pickfb; /* SS1 only */
132 volatile u32 pickbb; /* SS1 only */
133 volatile u32 dcfc; /* SS1 only */
134 volatile u32 forcecol; /* SS1 only */
135 volatile u32 door[8]; /* SS1 only */
136 volatile u32 pick[5]; /* SS1 only */
139 #define LEO_SS1_MISC_ENABLE 0x00000001
140 #define LEO_SS1_MISC_STEREO 0x00000002
141 struct leo_ld_ss1 {
142 u8 xxx0[0xef4];
143 volatile u32 ss1_misc;
146 struct leo_ld_gbl {
147 u8 unknown;
150 static struct sbus_mmap_map leo_mmap_map[] = {
151 { LEO_SS0_MAP, LEO_OFF_SS0, 0x800000 },
152 { LEO_LC_SS0_USR_MAP, LEO_OFF_LC_SS0_USR, 0x1000 },
153 { LEO_LD_SS0_MAP, LEO_OFF_LD_SS0, 0x1000 },
154 { LEO_LX_CURSOR_MAP, LEO_OFF_LX_CURSOR, 0x1000 },
155 { LEO_SS1_MAP, LEO_OFF_SS1, 0x800000 },
156 { LEO_LC_SS1_USR_MAP, LEO_OFF_LC_SS1_USR, 0x1000 },
157 { LEO_LD_SS1_MAP, LEO_OFF_LD_SS1, 0x1000 },
158 { LEO_UNK_MAP, LEO_OFF_UNK, 0x1000 },
159 { LEO_LX_KRN_MAP, LEO_OFF_LX_KRN, 0x1000 },
160 { LEO_LC_SS0_KRN_MAP, LEO_OFF_LC_SS0_KRN, 0x1000 },
161 { LEO_LC_SS1_KRN_MAP, LEO_OFF_LC_SS1_KRN, 0x1000 },
162 { LEO_LD_GBL_MAP, LEO_OFF_LD_GBL, 0x1000 },
163 { LEO_UNK2_MAP, LEO_OFF_UNK2, 0x100000 },
164 { 0, 0, 0 }
167 static void leo_setup(struct display *p)
169 p->next_line = 8192;
170 p->next_plane = 0;
173 static void leo_clear(struct vc_data *conp, struct display *p, int sy, int sx,
174 int height, int width)
176 struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)p->fb_info;
177 register struct leo_lc_ss0_usr *us = fb->s.leo.lc_ss0_usr;
178 register struct leo_ld *ss = fb->s.leo.ld_ss0;
179 int x, y, w, h;
180 int i;
182 do {
183 i = us->csr;
184 } while (i & 0x20000000);
185 ss->fg = (attr_bgcol_ec(p,conp)<<24);
186 if (fontheightlog(p)) {
187 y = sy << fontheightlog(p); h = height << fontheightlog(p);
188 } else {
189 y = sy * fontheight(p); h = height * fontheight(p);
191 if (fontwidthlog(p)) {
192 x = sx << fontwidthlog(p); w = width << fontwidthlog(p);
193 } else {
194 x = sx * fontwidth(p); w = width * fontwidth(p);
196 us->extent = (w - 1) | ((h - 1) << 11);
197 us->fill = (x + fb->x_margin) | ((y + fb->y_margin) << 11) |
198 0x80000000;
201 static void leo_fill(struct fb_info_sbusfb *fb, struct display *p, int s,
202 int count, unsigned short *boxes)
204 int i;
205 register struct leo_lc_ss0_usr *us = fb->s.leo.lc_ss0_usr;
206 register struct leo_ld *ss = fb->s.leo.ld_ss0;
208 ss->fg = (attr_bgcol(p,s)<<24);
209 while (count-- > 0) {
210 do {
211 i = us->csr;
212 } while (i & 0x20000000);
213 us->extent = (boxes[2] - boxes[0] - 1) |
214 ((boxes[3] - boxes[1] - 1) << 11);
215 us->fill = boxes[0] | (boxes[1] << 11) | 0x80000000;
216 boxes += 4;
220 static void leo_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx)
222 struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)p->fb_info;
223 register struct leo_lc_ss0_usr *us = fb->s.leo.lc_ss0_usr;
224 register struct leo_ld *ss = fb->s.leo.ld_ss0;
225 int i, x, y;
226 u8 *fd;
227 u32 *u;
229 if (fontheightlog(p)) {
230 y = yy << (fontheightlog(p) + 11);
231 i = (c & p->charmask) << fontheightlog(p);
232 } else {
233 y = (yy * fontheight(p)) << 11;
234 i = (c & p->charmask) * fontheight(p);
236 if (fontwidth(p) <= 8)
237 fd = p->fontdata + i;
238 else
239 fd = p->fontdata + (i << 1);
240 if (fontwidthlog(p))
241 x = xx << fontwidthlog(p);
242 else
243 x = xx * fontwidth(p);
244 do {
245 i = us->csr;
246 } while (i & 0x20000000);
247 ss->fg = attr_fgcol(p,c) << 24;
248 ss->bg = attr_bgcol(p,c) << 24;
249 us->fontmsk = 0xFFFFFFFF<<(32-fontwidth(p));
250 u = ((u32 *)p->screen_base) + y + x;
251 if (fontwidth(p) <= 8) {
252 for (i = 0; i < fontheight(p); i++, u += 2048)
253 *u = *fd++ << 24;
254 } else {
255 for (i = 0; i < fontheight(p); i++, u += 2048) {
256 *u = *(u16 *)fd << 16;
257 fd += 2;
262 static void leo_putcs(struct vc_data *conp, struct display *p, const unsigned short *s,
263 int count, int yy, int xx)
265 struct fb_info_sbusfb *fb = (struct fb_info_sbusfb *)p->fb_info;
266 register struct leo_lc_ss0_usr *us = fb->s.leo.lc_ss0_usr;
267 register struct leo_ld *ss = fb->s.leo.ld_ss0;
268 int i, x, y;
269 u8 *fd1, *fd2, *fd3, *fd4;
270 u32 *u;
272 do {
273 i = us->csr;
274 } while (i & 0x20000000);
275 ss->fg = attr_fgcol(p,scr_readw(s)) << 24;
276 ss->bg = attr_bgcol(p,scr_readw(s)) << 24;
277 us->fontmsk = 0xFFFFFFFF<<(32-fontwidth(p));
278 if (fontwidthlog(p))
279 x = (xx << fontwidthlog(p));
280 else
281 x = xx * fontwidth(p);
282 if (fontheightlog(p))
283 y = yy << (fontheightlog(p) + 11);
284 else
285 y = (yy * fontheight(p)) << 11;
286 u = ((u32 *)p->screen_base) + y + x;
287 if (fontwidth(p) <= 8) {
288 us->fontmsk = 0xFFFFFFFF<<(32-4*fontwidth(p));
289 x = 4*fontwidth(p) - fontheight(p)*2048;
290 while (count >= 4) {
291 count -= 4;
292 if (fontheightlog(p)) {
293 fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
294 fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
295 fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
296 fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) << fontheightlog(p));
297 } else {
298 fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
299 fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
300 fd3 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
301 fd4 = p->fontdata + ((scr_readw(s++) & p->charmask) * fontheight(p));
303 if (fontwidth(p) == 8) {
304 for (i = 0; i < fontheight(p); i++, u += 2048)
305 *u = ((u32)*fd4++) | ((((u32)*fd3++) | ((((u32)*fd2++) | (((u32)*fd1++)
306 << 8)) << 8)) << 8);
307 u += x;
308 } else {
309 for (i = 0; i < fontheight(p); i++, u += 2048)
310 *u = (((u32)*fd4++) | ((((u32)*fd3++) | ((((u32)*fd2++) | (((u32)*fd1++)
311 << fontwidth(p))) << fontwidth(p))) << fontwidth(p))) << (24 - 3 * fontwidth(p));
312 u += x;
315 } else {
316 us->fontmsk = 0xFFFFFFFF<<(32-2*fontwidth(p));
317 x = 2*fontwidth(p) - fontheight(p)*2048;
318 while (count >= 2) {
319 count -= 2;
320 if (fontheightlog(p)) {
321 fd1 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
322 fd2 = p->fontdata + ((scr_readw(s++) & p->charmask) << (fontheightlog(p) + 1));
323 } else {
324 fd1 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
325 fd2 = p->fontdata + (((scr_readw(s++) & p->charmask) * fontheight(p)) << 1);
327 for (i = 0; i < fontheight(p); i++, u += 2048) {
328 *u = ((((u32)*(u16 *)fd1) << fontwidth(p)) | ((u32)*(u16 *)fd2)) << (16 - fontwidth(p));
329 fd1 += 2; fd2 += 2;
331 u += x;
334 us->fontmsk = 0xFFFFFFFF<<(32-fontwidth(p));
335 x = fontwidth(p) - fontheight(p)*2048;
336 while (count) {
337 count--;
338 if (fontheightlog(p))
339 i = ((scr_readw(s++) & p->charmask) << fontheightlog(p));
340 else
341 i = ((scr_readw(s++) & p->charmask) * fontheight(p));
342 if (fontwidth(p) <= 8) {
343 fd1 = p->fontdata + i;
344 for (i = 0; i < fontheight(p); i++, u += 2048)
345 *u = *fd1++ << 24;
346 } else {
347 fd1 = p->fontdata + (i << 1);
348 for (i = 0; i < fontheight(p); i++, u += 2048) {
349 *u = *(u16 *)fd1 << 16;
350 fd1 += 2;
353 u += x;
357 static void leo_revc(struct display *p, int xx, int yy)
359 /* Not used if hw cursor */
362 static int leo_wait (struct leo_lx_krn *lx_krn)
364 int i;
366 for (i = 0; (lx_krn->krn_csr & LEO_KRN_CSR_PROGRESS) && i < 300000; i++)
367 udelay (1); /* Busy wait at most 0.3 sec */
368 if (i == 300000) return -EFAULT; /* Timed out - should we print some message? */
369 return 0;
372 static void leo_loadcmap (struct fb_info_sbusfb *fb, struct display *p, int index, int count)
374 struct leo_lx_krn *lx_krn = fb->s.leo.lx_krn;
375 int i;
377 lx_krn->krn_type = LEO_KRN_TYPE_CLUT0;
378 i = leo_wait (lx_krn);
379 if (i) return;
380 lx_krn->krn_type = LEO_KRN_TYPE_CLUTDATA;
381 for (i = 0; i < 256; i++)
382 lx_krn->krn_value = fb->color_map CM(i,0) |
383 (fb->color_map CM(i,1) << 8) |
384 (fb->color_map CM(i,2) << 16); /* Throw colors there :)) */
385 lx_krn->krn_type = LEO_KRN_TYPE_CLUT0;
386 lx_krn->krn_csr |= (LEO_KRN_CSR_UNK|LEO_KRN_CSR_UNK2);
389 static void leo_restore_palette (struct fb_info_sbusfb *fb)
391 fb->s.leo.ld_ss1->ss1_misc &= ~(LEO_SS1_MISC_ENABLE);
394 static struct display_switch leo_dispsw __initdata = {
395 leo_setup, fbcon_redraw_bmove, leo_clear, leo_putc, leo_putcs, leo_revc,
396 NULL, NULL, NULL, FONTWIDTHRANGE(1,16) /* Allow fontwidths up to 16 */
399 static void leo_setcursormap (struct fb_info_sbusfb *fb, u8 *red, u8 *green, u8 *blue)
401 struct leo_cursor *l = fb->s.leo.cursor;
402 int i;
404 for (i = 0; (l->cur_misc & LEO_CUR_PROGRESS) && i < 300000; i++)
405 udelay (1); /* Busy wait at most 0.3 sec */
406 if (i == 300000) return; /* Timed out - should we print some message? */
407 l->cur_type = LEO_CUR_TYPE_CMAP;
408 l->cur_data = (red[0] | (green[0]<<8) | (blue[0]<<16));
409 l->cur_data = (red[1] | (green[1]<<8) | (blue[1]<<16));
410 l->cur_misc = LEO_CUR_UPDATECMAP;
413 /* Set cursor shape */
414 static void leo_setcurshape (struct fb_info_sbusfb *fb)
416 int i, j, k;
417 u32 m, n, mask;
418 struct leo_cursor *l = fb->s.leo.cursor;
420 l->cur_misc &= ~LEO_CUR_ENABLE;
421 for (k = 0; k < 2; k ++) {
422 l->cur_type = (k * LEO_CUR_TYPE_IMAGE); /* LEO_CUR_TYPE_MASK is 0 */
423 for (i = 0; i < 32; i++) {
424 mask = 0;
425 m = fb->cursor.bits[k][i];
426 /* mask = m with reversed bit order */
427 for (j = 0, n = 1; j < 32; j++, n <<= 1)
428 if (m & n)
429 mask |= (0x80000000 >> j);
430 l->cur_data = mask;
433 l->cur_misc |= LEO_CUR_ENABLE;
436 /* Load cursor information */
437 static void leo_setcursor (struct fb_info_sbusfb *fb)
439 struct cg_cursor *c = &fb->cursor;
440 struct leo_cursor *l = fb->s.leo.cursor;
442 l->cur_misc &= ~LEO_CUR_ENABLE;
443 l->cur_cursxy = ((c->cpos.fbx - c->chot.fbx) & 0x7ff)
444 |(((c->cpos.fby - c->chot.fby) & 0x7ff) << 11);
445 l->cur_misc |= LEO_CUR_UPDATE;
446 if (c->enable)
447 l->cur_misc |= LEO_CUR_ENABLE;
450 static void leo_blank (struct fb_info_sbusfb *fb)
452 fb->s.leo.lx_krn->krn_type = LEO_KRN_TYPE_VIDEO;
453 fb->s.leo.lx_krn->krn_csr &= ~LEO_KRN_CSR_ENABLE;
456 static void leo_unblank (struct fb_info_sbusfb *fb)
458 fb->s.leo.lx_krn->krn_type = LEO_KRN_TYPE_VIDEO;
459 if (!(fb->s.leo.lx_krn->krn_csr & LEO_KRN_CSR_ENABLE))
460 fb->s.leo.lx_krn->krn_csr |= LEO_KRN_CSR_ENABLE;
463 static int __init
464 leo_wid_put (struct fb_info_sbusfb *fb, struct fb_wid_list *wl)
466 struct leo_lx_krn *lx_krn = fb->s.leo.lx_krn;
467 struct fb_wid_item *wi;
468 int i, j;
470 lx_krn->krn_type = LEO_KRN_TYPE_WID;
471 i = leo_wait (lx_krn);
472 if (i) return i;
473 for (i = 0, wi = wl->wl_list; i < wl->wl_count; i++, wi++) {
474 switch (wi->wi_type) {
475 case FB_WID_DBL_8: j = (wi->wi_index & 0xf) + 0x40; break;
476 case FB_WID_DBL_24: j = wi->wi_index & 0x3f; break;
477 default: return -EINVAL;
479 lx_krn->krn_type = 0x5800 + j;
480 lx_krn->krn_value = wi->wi_values[0];
482 lx_krn->krn_type = LEO_KRN_TYPE_WID;
483 lx_krn->krn_csr = 3;
484 return 0;
487 static void leo_margins (struct fb_info_sbusfb *fb, struct display *p, int x_margin, int y_margin)
489 p->screen_base += 8192 * (y_margin - fb->y_margin) + 4 * (x_margin - fb->x_margin);
492 static void leo_switch_from_graph (struct fb_info_sbusfb *fb)
494 register struct leo_lc_ss0_usr *us = fb->s.leo.lc_ss0_usr;
495 register struct leo_ld *ss = fb->s.leo.ld_ss0;
497 ss->wid = 0xffffffff;
498 ss->wmask = 0xffff;
499 ss->vclipmin = 0;
500 ss->vclipmax = fb->s.leo.extent;
501 ss->planemask = 0xff000000;
502 ss->rop = 0x310850;
503 ss->widclip = 0;
504 us->addrspace = 4;
505 us->fontt = 0;
508 static int __init leo_rasterimg (struct fb_info *info, int start)
510 struct fb_info_sbusfb *fb = sbusfbinfo(info);
511 register struct leo_lc_ss0_usr *us = fb->s.leo.lc_ss0_usr;
512 register struct leo_ld *ss = fb->s.leo.ld_ss0;
514 if (start) {
515 ss->wid = 1;
516 ss->planemask = 0xffffff;
517 ss->rop = 0x310b90;
518 us->addrspace = 0;
519 } else {
520 ss->wid = 0xffffffff;
521 ss->planemask = 0xff000000;
522 ss->rop = 0x310850;
523 us->addrspace = 4;
525 return 0;
528 static char idstring[40] __initdata = { 0 };
530 char * __init leofb_init(struct fb_info_sbusfb *fb)
532 struct fb_fix_screeninfo *fix = &fb->fix;
533 struct fb_var_screeninfo *var = &fb->var;
534 struct display *disp = &fb->disp;
535 struct fbtype *type = &fb->type;
536 unsigned long phys = fb->sbdp->reg_addrs[0].phys_addr;
537 struct fb_wid_item wi;
538 struct fb_wid_list wl;
539 int i;
540 register struct leo_lc_ss0_usr *us;
541 register struct leo_ld *ss;
542 struct fb_ops *fbops;
544 strcpy(fb->info.modename, "Leo");
546 strcpy(fix->id, "Leo");
547 fix->visual = FB_VISUAL_TRUECOLOR;
548 fix->line_length = 8192;
549 fix->accel = FB_ACCEL_SUN_LEO;
551 var->bits_per_pixel = 32;
552 var->green.offset = 8;
553 var->blue.offset = 16;
554 var->accel_flags = FB_ACCELF_TEXT;
556 fbops = kmalloc(sizeof(*fbops), GFP_KERNEL);
557 if (!fbops) return NULL;
559 *fbops = *fb->info.fbops;
560 fbops->fb_rasterimg = leo_rasterimg;
561 fb->info.fbops = fbops;
563 disp->scrollmode = SCROLL_YREDRAW;
564 if (!disp->screen_base)
565 disp->screen_base = (char *)sparc_alloc_io(phys + LEO_OFF_SS0, 0,
566 0x800000, "leo_ram", fb->iospace, 0);
567 disp->screen_base += 8192 * fb->y_margin + 4 * fb->x_margin;
568 us = fb->s.leo.lc_ss0_usr = (struct leo_lc_ss0_usr *)
569 sparc_alloc_io(phys + LEO_OFF_LC_SS0_USR, 0,
570 0x1000, "leo_lc_ss0_usr", fb->iospace, 0);
571 ss = fb->s.leo.ld_ss0 = (struct leo_ld *)
572 sparc_alloc_io(phys + LEO_OFF_LD_SS0, 0,
573 0x1000, "leo_ld_ss0", fb->iospace, 0);
574 fb->s.leo.ld_ss1 = (struct leo_ld_ss1 *)
575 sparc_alloc_io(phys + LEO_OFF_LD_SS1, 0,
576 0x1000, "leo_ld_ss1", fb->iospace, 0);
577 fb->s.leo.lx_krn = (struct leo_lx_krn *)
578 sparc_alloc_io(phys + LEO_OFF_LX_KRN, 0,
579 0x1000, "leo_lx_krn", fb->iospace, 0);
580 fb->s.leo.cursor = (struct leo_cursor *)
581 sparc_alloc_io(phys + LEO_OFF_LX_CURSOR, 0,
582 sizeof(struct leo_cursor), "leo_lx_cursor", fb->iospace, 0);
583 fb->dispsw = leo_dispsw;
585 fb->s.leo.extent = (type->fb_width-1) | ((type->fb_height-1) << 16);
587 wl.wl_count = 1;
588 wl.wl_list = &wi;
589 wi.wi_type = FB_WID_DBL_8;
590 wi.wi_index = 0;
591 wi.wi_values [0] = 0x2c0;
592 leo_wid_put (fb, &wl);
593 wi.wi_index = 1;
594 wi.wi_values [0] = 0x30;
595 leo_wid_put (fb, &wl);
596 wi.wi_index = 2;
597 wi.wi_values [0] = 0x20;
598 leo_wid_put (fb, &wl);
599 wi.wi_type = FB_WID_DBL_24;
600 wi.wi_index = 1;
601 wi.wi_values [0] = 0x30;
602 leo_wid_put (fb, &wl);
604 fb->s.leo.ld_ss1->ss1_misc |= LEO_SS1_MISC_ENABLE;
606 ss->wid = 0xffffffff;
607 ss->wmask = 0xffff;
608 ss->vclipmin = 0;
609 ss->vclipmax = fb->s.leo.extent;
610 ss->fg = 0;
611 ss->planemask = 0xff000000;
612 ss->rop = 0x310850;
613 ss->widclip = 0;
614 us->extent = (type->fb_width-1) | ((type->fb_height-1) << 11);
615 us->addrspace = 4;
616 us->fill = 0x80000000;
617 us->fontt = 0;
618 do {
619 i = us->csr;
620 } while (i & 0x20000000);
622 fb->margins = leo_margins;
623 fb->loadcmap = leo_loadcmap;
624 fb->setcursor = leo_setcursor;
625 fb->setcursormap = leo_setcursormap;
626 fb->setcurshape = leo_setcurshape;
627 fb->restore_palette = leo_restore_palette;
628 fb->switch_from_graph = leo_switch_from_graph;
629 fb->fill = leo_fill;
630 fb->blank = leo_blank;
631 fb->unblank = leo_unblank;
633 fb->physbase = phys;
634 fb->mmap_map = leo_mmap_map;
636 #ifdef __sparc_v9__
637 sprintf(idstring, "leo at %016lx", phys);
638 #else
639 sprintf(idstring, "leo at %x.%08lx", fb->iospace, phys);
640 #endif
642 return idstring;