1 /* $NetBSD: grfabs_fal.c,v 1.21 2009/03/14 21:04:06 dsl Exp $ */ 2 3 /* 4 * Copyright (c) 1995 Thomas Gerner. 5 * Copyright (c) 1995 Leo Weppelman. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Leo Weppelman. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <sys/cdefs.h> 35 __KERNEL_RCSID(0, "$NetBSD: grfabs_fal.c,v 1.21 2009/03/14 21:04:06 dsl Exp $"); 36 37 #ifdef FALCON_VIDEO 38 /* 39 * atari abstract graphics driver: Falcon-interface 40 */ 41 #include <sys/param.h> 42 #include <sys/queue.h> 43 #include <sys/malloc.h> 44 #include <sys/device.h> 45 #include <sys/systm.h> 46 47 #include <uvm/uvm_extern.h> 48 49 #include <machine/iomap.h> 50 #include <machine/video.h> 51 #include <machine/mfp.h> 52 #include <atari/atari/device.h> 53 #include <atari/atari/stalloc.h> 54 #include <atari/dev/grfabs_reg.h> 55 #include <atari/dev/grfabs_fal.h> 56 57 /* 58 * Function decls 59 */ 60 static void init_view(view_t *, bmap_t *, dmode_t *, box_t *); 61 static bmap_t *alloc_bitmap(u_long, u_long, u_char); 62 static colormap_t *alloc_colormap(dmode_t *); 63 static void free_bitmap(bmap_t *); 64 static void falcon_display_view(view_t *); 65 static view_t *falcon_alloc_view(dmode_t *, dimen_t *, u_char); 66 static void falcon_free_view(view_t *); 67 static void falcon_remove_view(view_t *); 68 static void falcon_save_view(view_t *); 69 static int falcon_use_colormap(view_t *, colormap_t *); 70 static void falcon_detect(dmode_t *); 71 static struct videl *falcon_getreg(u_short); 72 73 /* 74 * Our function switch table 75 */ 76 struct grfabs_sw fal_vid_sw = { 77 falcon_display_view, 78 falcon_alloc_view, 79 falcon_free_view, 80 falcon_remove_view, 81 falcon_save_view, 82 falcon_use_colormap 83 }; 84 85 struct falcon_hwregs { 86 u_short fal_mode; /* falcon mode */ 87 struct videl *fal_regs; /* videl register values */ 88 }; 89 #define vm_mode(dm) (((struct falcon_hwregs*)(dm->data))->fal_mode) 90 #define vm_regs(dm) (((struct falcon_hwregs*)(dm->data))->fal_regs) 91 92 /* 93 * Note that the order of this table *must* match the order of 94 * the table below! 95 */ 96 static struct falcon_hwregs fal_hwregs[] = { 97 { RES_FALAUTO }, 98 { RES_FAL_STHIGH }, 99 { RES_FAL_STMID }, 100 { RES_FAL_STLOW }, 101 { RES_FAL_TTLOW }, 102 { RES_VGA2 }, 103 { RES_VGA4 }, 104 { RES_VGA16 }, 105 { RES_VGA256 }, 106 { RES_DIRECT } 107 }; 108 109 110 static dmode_t vid_modes[] = { 111 { {NULL,NULL}, "falauto", { 0, 0 }, 0, NULL, &fal_vid_sw}, 112 { {NULL,NULL}, "sthigh", { 640,400 }, 1, NULL, &fal_vid_sw}, 113 { {NULL,NULL}, "stmid", { 640,200 }, 2, NULL, &fal_vid_sw}, 114 { {NULL,NULL}, "stlow", { 320,200 }, 4, NULL, &fal_vid_sw}, 115 { {NULL,NULL}, "ttlow", { 320,480 }, 8, NULL, &fal_vid_sw}, 116 { {NULL,NULL}, "vga2", { 640,480 }, 1, NULL, &fal_vid_sw}, 117 { {NULL,NULL}, "vga4", { 640,480 }, 2, NULL, &fal_vid_sw}, 118 { {NULL,NULL}, "vga16", { 640,480 }, 4, NULL, &fal_vid_sw}, 119 { {NULL,NULL}, "vga256", { 640,480 }, 8, NULL, &fal_vid_sw}, 120 { {NULL,NULL}, "highcol", { 320,200 }, 16, NULL, &fal_vid_sw}, 121 { {NULL,NULL}, NULL, } 122 }; 123 124 /* 125 * The following table contains timing values for the various video modes. 126 * I have only a multisync display, therefore I can not say if this values 127 * are useful at other displays. 128 * Use other video modes at YOUR OWN RISK. 129 * THERE IS NO WARRENTY ABOUT THIS VALUES TO WORK WITH A PARTICULAR 130 * DISPLAY. -- Thomas 131 */ 132 static struct videl videlinit[] = { 133 { RES_FALAUTO, /* autodedect */ 134 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 135 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, 136 137 { FAL_VGA | RES_FAL_STHIGH, /* sthigh, 640x400, 2 colors */ 138 0x2, 0x0, 0x28, 0x0, 0x400, 0xc6, 0x8d, 0x15, 0x273, 0x50, 0x96, 0x0, 139 0x0, 0x419, 0x3af, 0x8f, 0x8f, 0x3af, 0x415, 0x186, 0x8 }, 140 141 #if 0 /* not yet */ 142 { FAL_SM | RES_FAL_STHIGH, /* sthigh, 640x400, 2 colors */ 143 0x0, 0x0, 0x28, 0x2, 0x0, 0x1a, 0x0, 0x0, 0x20f, 0xc, 0x14, 0x0, 144 0x0, 0x3e9, 0x0, 0x0, 0x43, 0x363, 0x3e7, 0x80, 0x8 }, 145 #endif 146 147 { FAL_VGA | RES_FAL_STMID, /* stmid, 640x200, 4 colors */ 148 0x2, 0x0, 0x50, 0x1, 0x0, 0x17, 0x12, 0x1, 0x20e, 0xd, 0x11, 0x0, 149 0x0, 0x419, 0x3af, 0x8f, 0x8f, 0x3af, 0x415, 0x186, 0x9 }, 150 151 { FAL_VGA | RES_FAL_STLOW, /* stlow, 320x200, 16 colors */ 152 0x2, 0x0, 0x50, 0x0, 0x0, 0x17, 0x12, 0x1, 0x20e, 0xd, 0x11, 0x0, 153 0x0, 0x419, 0x3af, 0x8f, 0x8f, 0x3af, 0x415, 0x186, 0x5 }, 154 155 { FAL_VGA | RES_FAL_TTLOW, /* ttlow, 320x480, 256 colors */ 156 0x2, 0x0, 0xa0, 0x0, 0x10, 0xc6, 0x8d, 0x15, 0x29a, 0x7b, 0x96, 0x0, 157 0x0, 0x419, 0x3ff, 0x3f, 0x3f, 0x3ff, 0x415, 0x186, 0x4 }, 158 159 { FAL_VGA | RES_VGA2, /* vga, 640x480, 2 colors */ 160 0x2, 0x0, 0x28, 0x0, 0x400, 0xc6, 0x8d, 0x15, 0x273, 0x50, 0x96, 0x0, 161 0x0, 0x419, 0x3ff, 0x3f, 0x3f, 0x3ff, 0x415, 0x186, 0x8 }, 162 163 { FAL_VGA | RES_VGA4, /* vga, 640x480, 4 colors */ 164 0x2, 0x0, 0x50, 0x1, 0x0, 0x17, 0x12, 0x1, 0x20e, 0xd, 0x11, 0x0, 165 0x0, 0x419, 0x3ff, 0x3f, 0x3f, 0x3ff, 0x415, 0x186, 0x8 }, 166 167 { FAL_VGA | RES_VGA16, /* vga, 640x480, 16 colors */ 168 0x2, 0x0, 0xa0, 0x1, 0x0, 0xc6, 0x8d, 0x15, 0x2a3, 0x7c, 0x96, 0x0, 169 0x0, 0x419, 0x3ff, 0x3f, 0x3f, 0x3ff, 0x415, 0x186, 0x8 }, 170 171 { FAL_VGA | RES_VGA256, /* vga, 640x480, 256 colors */ 172 0x2, 0x0, 0x140, 0x1, 0x10, 0xc6, 0x8d, 0x15, 0x2ab, 0x84, 0x96, 0x0, 173 0x0, 0x419, 0x3ff, 0x3f, 0x3f, 0x3ff, 0x415, 0x186, 0x8 }, 174 175 { FAL_VGA | RES_DIRECT, /* direct video, 320x200, 65536 colors */ 176 0x2, 0x0, 0x140, 0x0, 0x100, 0xc6, 0x8d, 0x15, 0x2ac, 0x91, 0x96, 0x0, 177 0x0, 0x419, 0x3ff, 0x3f, 0x3f, 0x3ff, 0x415, 0x186, 0x4 }, 178 179 { 0xffff } /* end of list */ 180 }; 181 182 static u_short mon_type; 183 /* 184 * XXX: called from ite console init routine. 185 * Initialize list of possible video modes. 186 */ 187 void 188 falcon_probe_video(MODES *modelp) 189 { 190 dmode_t *dm; 191 struct videl *vregs; 192 int i; 193 194 mon_type = *(volatile unsigned char *)(AD_FAL_MON_TYPE); 195 mon_type = (mon_type & 0xc0) << 2; 196 197 /* 198 * get all possible modes 199 */ 200 201 for (i = 0; (dm = &vid_modes[i])->name != NULL; i++) { 202 dm->data = (void *)&fal_hwregs[i]; 203 if (vm_mode(dm) == RES_FALAUTO) { 204 vm_regs(dm) = falcon_getreg(RES_FALAUTO); 205 falcon_detect(dm); 206 LIST_INSERT_HEAD(modelp, dm, link); 207 } else { 208 vregs = falcon_getreg(vm_mode(dm) | mon_type); 209 if (vregs) { 210 vm_regs(dm) = vregs; 211 LIST_INSERT_HEAD(modelp, dm, link); 212 } 213 } 214 } 215 216 /* 217 * This seems to prevent bordered screens. 218 */ 219 for (i=0; i < 16; i++) 220 VIDEO->vd_fal_rgb[i] = CM_L2FAL(gra_def_color16[i]); 221 } 222 223 static struct videl * 224 falcon_getreg(u_short mode) 225 { 226 int i; 227 struct videl *vregs; 228 229 for (i = 0; (vregs = &videlinit[i])->video_mode != 0xffff; i++) 230 if ((vregs->video_mode) == mode) 231 return vregs; 232 233 return NULL; /* mode not found */ 234 } 235 236 static void 237 falcon_detect(dmode_t *dm) 238 { 239 u_short falshift, stshift; 240 struct videl *vregs = vm_regs(dm); 241 242 /* 243 * First get the videl register values 244 */ 245 246 vregs->vd_syncmode = VIDEO->vd_sync; 247 vregs->vd_line_wide = VIDEO->vd_line_wide; 248 vregs->vd_vert_wrap = VIDEO->vd_vert_wrap; 249 vregs->vd_st_res = VIDEO->vd_st_res; 250 vregs->vd_fal_res = VIDEO->vd_fal_res; 251 vregs->vd_h_hold_tim = VIDEO->vd_h_hold_tim; 252 vregs->vd_h_bord_beg = VIDEO->vd_h_bord_beg; 253 vregs->vd_h_bord_end = VIDEO->vd_h_bord_end; 254 vregs->vd_h_dis_beg = VIDEO->vd_h_dis_beg; 255 vregs->vd_h_dis_end = VIDEO->vd_h_dis_end; 256 vregs->vd_h_ss = VIDEO->vd_h_ss; 257 vregs->vd_h_fs = VIDEO->vd_h_fs; 258 vregs->vd_h_hh = VIDEO->vd_h_hh; 259 vregs->vd_v_freq_tim = VIDEO->vd_v_freq_tim; 260 vregs->vd_v_bord_beg = VIDEO->vd_v_bord_beg; 261 vregs->vd_v_bord_end = VIDEO->vd_v_bord_end; 262 vregs->vd_v_dis_beg = VIDEO->vd_v_dis_beg; 263 vregs->vd_v_dis_end = VIDEO->vd_v_dis_end; 264 vregs->vd_v_ss = VIDEO->vd_v_ss; 265 vregs->vd_fal_ctrl = VIDEO->vd_fal_ctrl; 266 vregs->vd_fal_mode = VIDEO->vd_fal_mode; 267 268 269 /* 270 * Calculate the depth of the screen 271 */ 272 273 falshift = vregs->vd_fal_res; 274 stshift = vregs->vd_st_res; 275 276 if (falshift & 0x400) /* 2 color */ 277 dm->depth = 1; 278 else if (falshift & 0x100) /* high color, direct */ 279 dm->depth = 16; 280 else if (falshift & 0x10) /* 256 color */ 281 dm->depth = 8; 282 else if (stshift == 0) /* 16 color */ 283 dm->depth = 4; 284 else if (stshift == 1) /* 4 color */ 285 dm->depth = 2; 286 else dm->depth = 1; /* 2 color */ 287 288 /* 289 * Now calculate the screen hight 290 */ 291 292 dm->size.height = vregs->vd_v_dis_end - vregs->vd_v_dis_beg; 293 if (!((vregs->vd_fal_mode & 0x2) >> 1)) /* if not interlaced */ 294 dm->size.height >>=1; 295 if (vregs->vd_fal_mode & 0x1) /* if doublescan */ 296 dm->size.height >>=1; 297 298 /* 299 * And the width 300 */ 301 302 dm->size.width = vregs->vd_vert_wrap * 16 / dm->depth; 303 304 } 305 306 u_long falcon_needs_vbl; 307 void falcon_display_switch(void); 308 309 static void 310 falcon_display_view(view_t *v) 311 { 312 dmode_t *dm = v->mode; 313 bmap_t *bm; 314 struct videl *vregs; 315 static u_short last_mode = 0xffff; 316 317 if (dm->current_view) { 318 /* 319 * Mark current view for this mode as no longer displayed 320 */ 321 dm->current_view->flags &= ~VF_DISPLAY; 322 } 323 dm->current_view = v; 324 v->flags |= VF_DISPLAY; 325 vregs = vm_regs(v->mode); 326 327 falcon_use_colormap(v, v->colormap); 328 329 bm = v->bitmap; 330 VIDEO->vd_ramh = ((u_long)bm->hw_address >> 16) & 0xff; 331 VIDEO->vd_ramm = ((u_long)bm->hw_address >> 8) & 0xff; 332 VIDEO->vd_raml = (u_long)bm->hw_address & 0xff; 333 334 if (last_mode != vregs->video_mode) { 335 last_mode = vregs->video_mode; 336 337 if (dm->depth == 1) { 338 /* 339 * Set the resolution registers to a mode, which guarantee 340 * no shifting when the register are written during vbl. 341 */ 342 VIDEO->vd_fal_res = 0; 343 VIDEO->vd_st_res = 0; 344 } 345 346 /* 347 * Arrange for them to be activated 348 * at the second vbl interrupt. 349 */ 350 falcon_needs_vbl = (u_long)v; 351 } 352 } 353 354 void 355 falcon_display_switch() 356 { 357 view_t *v; 358 struct videl *vregs; 359 static int vbl_count = 1; 360 361 if(vbl_count--) return; 362 363 v = (view_t*)falcon_needs_vbl; 364 365 vbl_count = 1; 366 falcon_needs_vbl = 0; 367 368 /* 369 * Write to videl registers only on VGA displays 370 * This is only a hack. Must be fixed soon. XXX -- Thomas 371 */ 372 if(mon_type != FAL_VGA) return; 373 374 vregs = vm_regs(v->mode); 375 376 VIDEO->vd_v_freq_tim = vregs->vd_v_freq_tim; 377 VIDEO->vd_v_ss = vregs->vd_v_ss; 378 VIDEO->vd_v_bord_beg = vregs->vd_v_bord_beg; 379 VIDEO->vd_v_bord_end = vregs->vd_v_bord_end; 380 VIDEO->vd_v_dis_beg = vregs->vd_v_dis_beg; 381 VIDEO->vd_v_dis_end = vregs->vd_v_dis_end; 382 VIDEO->vd_h_hold_tim = vregs->vd_h_hold_tim; 383 VIDEO->vd_h_ss = vregs->vd_h_ss; 384 VIDEO->vd_h_bord_beg = vregs->vd_h_bord_beg; 385 VIDEO->vd_h_bord_end = vregs->vd_h_bord_end; 386 VIDEO->vd_h_dis_beg = vregs->vd_h_dis_beg; 387 VIDEO->vd_h_dis_end = vregs->vd_h_dis_end; 388 #if 0 /* This seems not to be necessary -- Thomas */ 389 VIDEO->vd_h_fs = vregs->vd_h_fs; 390 VIDEO->vd_h_hh = vregs->vd_h_hh; 391 #endif 392 VIDEO->vd_sync = vregs->vd_syncmode; 393 VIDEO->vd_fal_res = 0; 394 if (v->mode->depth == 2) 395 VIDEO->vd_st_res = vregs->vd_st_res; 396 else { 397 VIDEO->vd_st_res = 0; 398 VIDEO->vd_fal_res = vregs->vd_fal_res; 399 } 400 VIDEO->vd_vert_wrap = vregs->vd_vert_wrap; 401 VIDEO->vd_line_wide = vregs->vd_line_wide; 402 VIDEO->vd_fal_ctrl = vregs->vd_fal_ctrl; 403 VIDEO->vd_fal_mode = vregs->vd_fal_mode; 404 } 405 406 static void 407 falcon_remove_view(view_t *v) 408 { 409 dmode_t *mode = v->mode; 410 411 if (mode->current_view == v) { 412 #if 0 413 if (v->flags & VF_DISPLAY) 414 panic("Cannot shutdown display"); /* XXX */ 415 #endif 416 mode->current_view = NULL; 417 } 418 v->flags &= ~VF_DISPLAY; 419 } 420 421 void 422 falcon_save_view(view_t *v) 423 { 424 } 425 426 static void 427 falcon_free_view(view_t *v) 428 { 429 if (v) { 430 falcon_remove_view(v); 431 if (v->colormap != &gra_con_cmap) 432 free(v->colormap, M_DEVBUF); 433 free_bitmap(v->bitmap); 434 if (v != &gra_con_view) 435 free(v, M_DEVBUF); 436 } 437 } 438 439 static int 440 falcon_use_colormap(view_t *v, colormap_t *cm) 441 { 442 dmode_t *dm; 443 volatile u_short *creg; 444 volatile u_long *fcreg; 445 u_long *src; 446 colormap_t *vcm; 447 u_long *vcreg; 448 u_short ncreg; 449 int last_streg; 450 int i; 451 452 dm = v->mode; 453 vcm = v->colormap; 454 455 /* 456 * I guess it seems reasonable to require the maps to be 457 * of the same type... 458 */ 459 if (cm->type != vcm->type) 460 return (EINVAL); 461 462 /* 463 * First get the colormap addresses an calculate 464 * howmany colors are in it. 465 */ 466 if (dm->depth == 16) /* direct color, no colormap; 467 but also not (yet) supported */ 468 return(0); 469 fcreg = &VIDEO->vd_fal_rgb[0]; 470 creg = &VIDEO->vd_st_rgb[0]; 471 ncreg = 1 << dm->depth; 472 473 /* If first entry specified beyond capabilities -> error */ 474 if (cm->first >= ncreg) 475 return (EINVAL); 476 477 /* 478 * A little tricky, the actual colormap pointer will be NULL 479 * when view is not displaying, valid otherwise. 480 */ 481 if (v->flags & VF_DISPLAY) { 482 creg = &creg[cm->first]; 483 fcreg = &fcreg[cm->first]; 484 } else { 485 creg = NULL; 486 fcreg = NULL; 487 } 488 489 vcreg = &vcm->entry[cm->first]; 490 ncreg -= cm->first; 491 last_streg = 16 - cm->first; 492 if (cm->size > ncreg) 493 return (EINVAL); 494 ncreg = cm->size; 495 496 for (i = 0, src = cm->entry; i < ncreg; i++, vcreg++) { 497 *vcreg = *src++; 498 499 /* 500 * If displaying, also update actual color register. 501 */ 502 if (fcreg != NULL) { 503 *fcreg++ = CM_L2FAL(*vcreg); 504 if (i < last_streg) 505 *creg++ = CM_L2ST(*vcreg); 506 } 507 } 508 return (0); 509 } 510 511 static view_t * 512 falcon_alloc_view(dmode_t *mode, dimen_t *dim, u_char depth) 513 { 514 view_t *v; 515 bmap_t *bm; 516 517 if (!atari_realconfig) 518 v = &gra_con_view; 519 else v = malloc(sizeof(*v), M_DEVBUF, M_NOWAIT); 520 if (v == NULL) 521 return(NULL); 522 523 bm = alloc_bitmap(mode->size.width, mode->size.height, mode->depth); 524 if (bm) { 525 box_t box; 526 527 v->colormap = alloc_colormap(mode); 528 if (v->colormap) { 529 INIT_BOX(&box,0,0,mode->size.width,mode->size.height); 530 init_view(v, bm, mode, &box); 531 return(v); 532 } 533 free_bitmap(bm); 534 } 535 if (v != &gra_con_view) 536 free(v, M_DEVBUF); 537 return (NULL); 538 } 539 540 static void 541 init_view(view_t *v, bmap_t *bm, dmode_t *mode, box_t *dbox) 542 { 543 v->bitmap = bm; 544 v->mode = mode; 545 v->flags = 0; 546 bcopy(dbox, &v->display, sizeof(box_t)); 547 } 548 549 /* bitmap functions */ 550 551 static bmap_t * 552 alloc_bitmap(u_long width, u_long height, u_char depth) 553 { 554 u_long total_size, bm_size; 555 void *hw_address; 556 bmap_t *bm; 557 558 /* 559 * Sigh, it seems for mapping to work we need the bitplane data to 560 * 1: be aligned on a page boundry. 561 * 2: be n pages large. 562 * 563 * why? because the user gets a page aligned address, if this is before 564 * your allocation, too bad. Also it seems that the mapping routines 565 * do not watch to closely to the allowable length. so if you go over 566 * n pages by less than another page, the user gets to write all over 567 * the entire page. Since you did not allocate up to a page boundry 568 * (or more) the user writes into someone elses memory. -ch 569 */ 570 bm_size = m68k_round_page((width * height * depth) / NBBY); 571 total_size = bm_size + sizeof(bmap_t) + PAGE_SIZE; 572 573 if ((bm = (bmap_t*)alloc_stmem(total_size, &hw_address)) == NULL) 574 return(NULL); 575 576 bm->plane = (u_char*)bm + sizeof(bmap_t); 577 bm->plane = (u_char*)m68k_round_page(bm->plane); 578 bm->hw_address = (u_char*)hw_address + sizeof(bmap_t); 579 bm->hw_address = (u_char*)m68k_round_page(bm->hw_address); 580 bm->bytes_per_row = (width * depth) / NBBY; 581 bm->rows = height; 582 bm->depth = depth; 583 bm->phys_mappable = (depth * width * height) / NBBY; 584 bm->regs = NULL; 585 bm->hw_regs = NULL; 586 bm->reg_size = 0; 587 bm->vga_address = NULL; 588 bm->vga_mappable = 0; 589 bm->lin_base = 0; 590 bm->vga_base = 0; 591 592 bzero(bm->plane, bm_size); 593 return (bm); 594 } 595 596 static void 597 free_bitmap(bmap_t *bm) 598 { 599 if (bm) 600 free_stmem(bm); 601 } 602 603 static colormap_t * 604 alloc_colormap(dmode_t *dm) 605 { 606 int nentries, i; 607 colormap_t *cm; 608 u_char type = CM_COLOR; 609 610 if (dm->depth == 16) /* direct color, no colormap; 611 not (yet) supported */ 612 nentries = 0; 613 else 614 nentries = 1 << dm->depth; 615 616 if (!atari_realconfig) { 617 cm = &gra_con_cmap; 618 cm->entry = gra_con_colors; 619 } 620 else { 621 int size; 622 623 size = sizeof(*cm) + (nentries * sizeof(cm->entry[0])); 624 cm = malloc(size, M_DEVBUF, M_NOWAIT); 625 if (cm == NULL) 626 return(NULL); 627 cm->entry = (long *)&cm[1]; 628 629 } 630 631 if ((cm->type = type) == CM_COLOR) 632 cm->red_mask = cm->green_mask = cm->blue_mask = 0x3f; 633 634 cm->first = 0; 635 cm->size = nentries; 636 637 for (i = 0; i < nentries; i++) 638 cm->entry[i] = gra_def_color16[i % 16]; 639 return (cm); 640 } 641 #endif /* FALCON_VIDEO */ 642