1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc. 7 * 8 * %sccs.include.redist.c% 9 * 10 * from: $Hdr: fbdefs.h,v 4.300 91/06/09 06:33:54 root Rel41 $ SONY 11 * 12 * @(#)fbdefs.h 8.1 (Berkeley) 06/11/93 13 */ 14 15 #ifndef mips 16 #define volatile 17 #endif 18 19 #ifdef CPU_SINGLE 20 21 #if defined(news3400) || defined(news3700) 22 #define splbitmap spl3 23 #endif 24 #define FB_LOCK lock_bitmap() 25 #define FB_UNLOCK unlock_bitmap() 26 27 #else /* CPU_SINGLE */ 28 29 #undef PRE_EMPT 30 #define PRE_EMPT 31 #define FB_LOCK 32 #define FB_UNLOCK 33 #include <news3400/fb/fbsem.h> /* semaphore name */ 34 35 #endif /* CPU_SINGLE */ 36 37 #if defined(news3400) || defined(news3700) 38 #define WB_FLUSH MachEmptyWriteBuffer() 39 #else 40 #define WB_FLUSH 41 #endif 42 43 /* 44 * macro to compute modulo 45 * MOD(-1, 16) --> 15 46 * DIV(-1, 16) --> -1 47 */ 48 #define MOD(x, d, t) (((t)=(x)%(d))>=0?(t):(t)+(d)) 49 #define TRUNC(x, d, t) ((x)-MOD(x,d,t)) 50 #define DIV(x, d, t) (((x)-MOD(x,d,t))/(d)) 51 52 /* BitsPerWord should be 2^x */ 53 #define MODWORD(x) ((x)&((BitsPerWord)-1)) 54 #define TRUNCWORD(x) ((x)-MODWORD(x)) 55 #define DIVWORD(x) (((x)-MODWORD(x))/BitsPerWord) 56 57 58 #define AllOnes 0xffff 59 60 /* transparency */ 61 #define TRANS(t,f) ((t) ? ((f) & 0x3 | 0x4) : (f)) 62 63 /* 64 * color definitions 65 */ 66 #define MODE_1to1 0 67 #define MODE_1toN 1 68 #define MODE_Nto1 2 69 #define MODE_NtoN 3 70 71 #define PARALLEL 0 72 #define INTERNAL 1 73 74 #define NODRAW 0 75 #define DRAW 1 76 77 typedef struct _mergeRopBits { 78 unsigned long ca1, cx1, ca2, cx2; 79 } mergeRopRec; 80 81 extern mergeRopRec mergeRopBits[]; 82 83 #define DoRop(f, s, d, r) \ 84 { \ 85 switch(f) { \ 86 case BF_0: \ 87 (r) = 0; break; \ 88 case BF_SDA: \ 89 (r) = (s)&(d); break; \ 90 case BF_SDIA: \ 91 (r) = (s)&~(d); break; \ 92 case BF_S: \ 93 (r) = (s); break; \ 94 case BF_SIDA: \ 95 (r) = ~(s)&(d); break; \ 96 case BF_D: \ 97 (r) = (d); break; \ 98 case BF_SDX: \ 99 (r) = (s)^(d); break; \ 100 case BF_SDO: \ 101 (r) = (s)|(d); break; \ 102 case BF_SDOI: \ 103 (r) = ~((s)|(d)); break; \ 104 case BF_SDXI: \ 105 (r) = ~((s)^(d)); break; \ 106 case BF_DI: \ 107 (r) = ~(d); break; \ 108 case BF_SDIO: \ 109 (r) = (s)|~(d); break; \ 110 case BF_SI: \ 111 (r) = ~(s); break; \ 112 case BF_SIDO: \ 113 (r) = ~(s)|(d); break; \ 114 case BF_SDAI: \ 115 (r) = ~((s)&(d)); break; \ 116 case BF_1: \ 117 (r) = 0xffffffff; break; \ 118 } \ 119 } 120 121 #define DoMergeRop(src, dst) \ 122 ((dst) & ((src) & _ca1 ^ _cx1) ^ ((src) & _ca2 ^ _cx2)) 123 #define DoMergeRopMask(src, dst, mask) \ 124 ((dst) & (((src) & _ca1 ^ _cx1) | ~(mask)) ^ \ 125 (((src) & _ca2 ^ _cx2) & (mask))) 126 #define DoMergeFill(dst) (((dst) & (rop_and)) ^ (rop_xor)) 127 #define DoMergeFillMask(dst, mask) \ 128 (((dst) & ((rop_and) | ~(mask))) ^ ((rop_xor) & (mask))) 129 #define DoMultiRop(src, dst) \ 130 { \ 131 DoRop(funcs[0], src, dst, tmp0) \ 132 DoRop(funcs[1], src, dst, tmp1) \ 133 DoRop(funcs[2], src, dst, tmp2) \ 134 DoRop(funcs[3], src, dst, tmp3) \ 135 (dst) = tmp0 & masks[0] | tmp1 & masks[1] | \ 136 tmp2 & masks[2] | tmp3 & masks[3]; \ 137 } 138 #define DoMultiRopMask(src, dst, mask) \ 139 { \ 140 DoRop(funcs[0], src, dst, tmp0) \ 141 DoRop(funcs[1], src, dst, tmp1) \ 142 DoRop(funcs[2], src, dst, tmp2) \ 143 DoRop(funcs[3], src, dst, tmp3) \ 144 (dst) = dst & ~(mask) | \ 145 (tmp0 & masks[0] | tmp1 & masks[1] | \ 146 tmp2 & masks[2] | tmp3 & masks[3]) & mask; \ 147 } 148 149 #define TypeAt(m, p) ((m)->fm_vaddr + (p) - (m)->fm_offset) 150 151 #ifdef CPU_DOUBLE 152 # define _TypeAt(m, p) ((m)->fm_addr[(p)>>CLSHIFT] + (CLOFSET&(p))) 153 #else /* CPU_DOUBLE */ 154 # define _TypeAt(m, p) ((m)->fm_vaddr + (p) - (m)->fm_offset) 155 #endif /* CPU_DOUBLE */ 156 157 #define WordAt(m, p) (*(Word *)_TypeAt(m, p)) 158 159 /* 160 * Device Dependent Structure 161 */ 162 163 #define MAXPLANE 24 164 165 struct fbdev { 166 struct fbdev_ops *fbbm_op; 167 int type; 168 int unit; 169 lRectangle FrameRect; 170 lRectangle VisRect; 171 lRectangle CursorRect; 172 lRectangle MaskRect; 173 lRectangle SaveRect; 174 lBitmap Krom_BM0; 175 lBitmap Krom_BM1; 176 char * Krom_base; 177 lPoint Krom_font_extent0; 178 lPoint Krom_font_extent1; 179 char funcvec[MAXPLANE]; 180 int Mode; 181 int Pmask; 182 unsigned int pat; 183 char func; 184 int fore; 185 int aux; 186 int trans; 187 int cache_off; 188 int font_w; 189 int font_h; 190 int char_w; 191 int char_h; 192 int scr_w; 193 int scr_h; 194 int ch_pos; 195 int ul_pos; 196 int x_offset; 197 int y_offset; 198 int rit_m; 199 int btm_m; 200 lRectangle moveArea; 201 lPoint size; 202 lPoint hot; 203 char curfuncv[MAXPLANE]; 204 char maskfuncv[MAXPLANE]; 205 int cursorSet; 206 int cursorShow; 207 int cursorVis; 208 lPoint cursorP; 209 char *rcont_base; 210 char *rcont_reg; 211 int fbNplane; 212 int Colorwidth; 213 int planemask; 214 int Mono; 215 int Dimmer; 216 int DispVer; 217 unsigned short status_flag; 218 unsigned short run_flag; 219 char *private; 220 int hard_cursor; 221 }; 222 223 #ifdef CPU_SINGLE 224 struct mfbdev { 225 char *vram_start; 226 int vram_width; 227 }; 228 #endif /* CPU_SINGLE */ 229 230 struct fbdev_ops { 231 void (*fb_rop_init)(); 232 void (*fb_rop_copy)(); 233 void (*fb_rop_winit)(); 234 void (*fb_rop_write)(); 235 void (*fb_rop_read)(); 236 void (*fb_rop_cinit)(); 237 void (*fb_rop_clear)(); 238 void (*fb_rop_vect)(); 239 void (*fb_rop_dot)(); 240 void (*fb_rop_fillscan)(); 241 void (*fb_rop_wait)(); 242 void (*fb_rop_reset)(); 243 char *(*fb_Krom_addr)(); 244 void (*fb_init_palette)(); 245 int (*fb_set_palette)(); 246 int (*fb_get_palette)(); 247 int (*fb_get_pixel)(); 248 int (*fb_set_dimmer)(); 249 int (*fb_get_dimmer)(); 250 int (*fb_open)(); 251 int (*fb_close)(); 252 int (*fb_ioctl)(); 253 int (*fb_get_page)(); 254 void (*fb_cursor_set)(); 255 void (*fb_cursor_on)(); 256 void (*fb_cursor_off)(); 257 void (*fb_cursor_move)(); 258 }; 259 260 struct autodev { 261 int type; 262 char *base; 263 char *reg; 264 }; 265 266 struct fbdevsw { 267 int num; 268 int (*fb_probe)(); 269 void (*fb_setup)(); 270 }; 271 272 extern struct autodev autodev[]; 273 extern struct fbdev fbdev[]; 274 extern int nfbdev; 275 extern struct fbdev *consfb; 276 extern unsigned short fb_color_pallet_def[]; 277 extern unsigned short fb_gray_pallet_def[]; 278 279 /* fb_ioctl Command */ 280 281 #define FB_INTCHECK 1 282 #define FB_INTCLEAR 2 283 #define FB_INTENABLE 3 284 #define FB_STATUSCHECK 4 285 286 #define FB_SETVIDEOCTL 10 287 #define FB_GETVIDEOSTATUS 11 288 #define FB_SETPALETTEMODE 12 289 #define FB_GETPALETTEMODE 13 290 291 #define FB_INT_VSYNC 1 292 #define FB_INT_ROPDONE 2 293 294 #define FB_STATUS_ROPEXEC 4 295 #define FB_STATUS_ROPWAIT 8 296 #define FB_STATUS_ROPVSYNC 16 297 298 /* run_flag */ 299 300 #define FB_ACTIVE 1 301 #define FB_WAITING 2 302 #define FB_DONE 4 303 304 /* 305 * Pseudo Frame Buffer 306 * 307 * unit no 308 * 0 Console Device and old Interface (/dev/fb) 309 * 1 B/W Display and New Interface (/dev/mfb) 310 * 2 Color Display and New Interface (/dev/cfb) 311 * 312 */ 313 314 #define fbbm_rop_init(fb, func) \ 315 (*(fb)->fbbm_op->fb_rop_init)(fb, func) 316 317 #define fbbm_rop_copy(fb, s, d, rp, wp) \ 318 (*(fb)->fbbm_op->fb_rop_copy)(fb, s, d, rp, wp) 319 320 #define fbbm_rop_winit(fb) \ 321 (*(fb)->fbbm_op->fb_rop_winit)(fb) 322 323 #define fbbm_rop_write(fb, map, p, width, srp, drp, wplane) \ 324 (*(fb)->fbbm_op->fb_rop_write)(fb, map, p, width, srp, drp, wplane) 325 326 #define fbbm_rop_read(fb, map, p, width, srp, drp, rplane, wplane) \ 327 (*(fb)->fbbm_op->fb_rop_read)(fb, map, p, width, srp, drp, rplane, wplane) 328 329 #define fbbm_rop_cinit(fb, wplane, bw) \ 330 (*(fb)->fbbm_op->fb_rop_cinit)(fb, wplane, bw) 331 332 #define fbbm_rop_clear(fb, dr) \ 333 (*(fb)->fbbm_op->fb_rop_clear)(fb, dr) 334 335 #define fbbm_rop_vect(fb, dr, func, forc, auxc, transp, wplane, n, p, lptn, lpf, sw) \ 336 (*(fb)->fbbm_op->fb_rop_vect)(fb, dr, func, forc, auxc, transp, wplane, n, p, lptn, lpf, sw) 337 338 #define fbbm_rop_dot(fb, dr, func, forc, auxc, transp, wplane, n, p) \ 339 (*(fb)->fbbm_op->fb_rop_dot)(fb, dr, func, forc, auxc, transp, wplane, n, p) 340 341 #define fbbm_rop_fillscan(fb, ls, ns, clip, sw) \ 342 (*(fb)->fbbm_op->fb_rop_fillscan)(fb, ls, ns, clip, sw) 343 344 #define fbbm_Krom_addr(fb, c, sr) \ 345 (*(fb)->fbbm_op->fb_Krom_addr)(fb, c, sr) 346 347 #define fbbm_rop_wait(fb) \ 348 (*(fb)->fbbm_op->fb_rop_wait)(fb) 349 #define fbbm_rop_reset(fb) \ 350 (*(fb)->fbbm_op->fb_rop_reset)(fb) 351 352 #define fbbm_init_palette(fb) \ 353 (*(fb)->fbbm_op->fb_init_palette)(fb) 354 #define fbbm_set_palette(fb, palette) \ 355 (*(fb)->fbbm_op->fb_set_palette)(fb, palette) 356 #define fbbm_get_palette(fb, palette) \ 357 (*(fb)->fbbm_op->fb_get_palette)(fb, palette) 358 #define fbbm_get_pixel(fb, pixel) \ 359 (*(fb)->fbbm_op->fb_get_pixel)(fb, pixel) 360 361 #define fbbm_set_dimmer(fb, n) \ 362 (*(fb)->fbbm_op->fb_set_dimmer)(fb, n) 363 #define fbbm_get_dimmer(fb) \ 364 (*(fb)->fbbm_op->fb_get_dimmer)(fb) 365 366 #define fbbm_open(fb) \ 367 (*(fb)->fbbm_op->fb_open)(fb) 368 #define fbbm_close(fb) \ 369 (*(fb)->fbbm_op->fb_close)(fb) 370 #define fbbm_ioctl(fb, cmd, data) \ 371 (*(fb)->fbbm_op->fb_ioctl)(fb, cmd, data) 372 373 #define fbbm_get_page(fb, off) \ 374 (*(fb)->fbbm_op->fb_get_page)(fb, off) 375 376 #define fbbm_cursor_set(fb, fc, bc) \ 377 (*(fb)->fbbm_op->fb_cursor_set)(fb, fc, bc) 378 #define fbbm_cursor_on(fb) \ 379 (*(fb)->fbbm_op->fb_cursor_on)(fb) 380 #define fbbm_cursor_off(fb) \ 381 (*(fb)->fbbm_op->fb_cursor_off)(fb) 382 #define fbbm_cursor_move(fb) \ 383 (*(fb)->fbbm_op->fb_cursor_move)(fb) 384 385 extern unsigned short mfbstarttab16[16]; 386 extern unsigned short mfbendtab16[16]; 387 extern unsigned short mfbpartmasks16[16][16]; 388 extern unsigned int mfbstarttab32[32]; 389 extern unsigned int mfbendtab32[32]; 390 extern unsigned int mfbpartmasks32[32][32]; 391 extern void mfb_copy_area32(); 392 extern void mfb_copyinv_area32(); 393 extern void mfb_or_area32(); 394 extern void mfb_xor_area32(); 395 extern void mfb_general_area32(); 396 extern void mfb_clr_area32(); 397 extern void mfb_inv_area32(); 398 extern void mfb_set_area32(); 399 extern void mfb_copy_area16(); 400 extern void mfb_copyinv_area16(); 401 extern void mfb_or_area16(); 402 extern void mfb_xor_area16(); 403 extern void mfb_general_area16(); 404 extern void mfb_clr_area16(); 405 extern void mfb_inv_area16(); 406 extern void mfb_set_area16(); 407 extern void mfb_clrvvector32(); 408 extern void mfb_clrhvector32(); 409 extern void mfb_clrvector32(); 410 extern void mfb_invvvector32(); 411 extern void mfb_invhvector32(); 412 extern void mfb_invvector32(); 413 extern void mfb_setvvector32(); 414 extern void mfb_sethvector32(); 415 extern void mfb_setvector32(); 416 extern void mfb_point(); 417 extern void mfb_vector32(); 418