rendition.c revision 66c2ea32
1/* 2 * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to 6 * deal in the Software without restriction, including without limitation the 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 * sell copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 * 21 * Except as contained in this notice, the name of the XFree86 Project shall 22 * not be used in advertising or otherwise to promote the sale, use or other 23 * dealings in this Software without prior written authorization from the 24 * XFree86 Project. 25 */ 26 27/* 28 * This is essentially a transfer of the 3.3 sources written by 29 * Marc Langenbach and Tim Rowley. 30 * 31 * The initial port of this driver to XFree86 4.0 was done by 32 * Marc Langenbach <mlangen@studcs.uni-sb.de> 33 * Additions, updates and bugfixes by Dejan Ilic <dejan.ilic@home.se> 34 */ 35 36#ifdef HAVE_CONFIG_H 37#include "config.h" 38#endif 39 40/* 41 * Activate acceleration code or not. 42 * 43 * WARNING BUGGY !!! 44 * Yes, you activate it on your own risk. 45 */ 46#define USE_ACCEL 0 47 48/* 49 * includes 50 */ 51 52#include "rendition.h" 53#include "rendition_options.h" 54 55#include "hwcursor.h" 56#include "xf86int10.h" 57 58#include "vtypes.h" 59#include "vboard.h" 60#include "vmodes.h" 61#include "accel.h" 62#include "vramdac.h" 63#include "rendition_shadow.h" 64#include "vbe.h" 65 66#ifdef XSERVER_LIBPCIACCESS 67# include <pciaccess.h> 68# define DEVICE_ID(p) (p)->device_id 69#else 70# define DEVICE_ID(p) (p)->chipType 71#endif 72 73 74/* 75 * defines 76 */ 77 78#undef DEBUG 79 80#define RENDITION_NAME "RENDITION" 81#define RENDITION_DRIVER_NAME "rendition" 82#define RENDITION_VERSION_NAME PACKAGE_VERSION 83#define RENDITION_VERSION_MAJOR PACKAGE_VERSION_MAJOR 84#define RENDITION_VERSION_MINOR PACKAGE_VERSION_MINOR 85#define RENDITION_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL 86#define RENDITION_VERSION_CURRENT ((RENDITION_VERSION_MAJOR << 24) | \ 87 (RENDITION_VERSION_MINOR << 16) | RENDITION_PATCHLEVEL) 88 89/* 90 * Constants for the (theoretical) maximum width and height that can 91 * be used to display data on the CRT. These were calculated from 92 * the HORZ and VERT macors, respectively, in vmodes.c. 93 */ 94static const int MAX_HDISPLAY = 2048; 95static const int MAX_VDISPLAY = 2048; 96 97/* 98 * Constants for the (theoretical) maximum line length of a scan line 99 * and scan lines per screen (including overdraw). These were 100 * calculated from the HORZ and VERT macors, respectively, in vmodes.c. 101 */ 102static const int MAX_HTOTAL = 2880; 103static const int MAX_VTOTAL = 2184; 104 105/* 106 * local function prototypes 107 */ 108 109static const OptionInfoRec * renditionAvailableOptions(int, int); 110static void renditionIdentify(int); 111#ifdef XSERVER_LIBPCIACCESS 112static Bool renditionPciProbe(DriverPtr drv, int entity_num, 113 struct pci_device *dev, intptr_t match_data); 114#else 115static Bool renditionProbe(DriverPtr, int); 116#endif 117static Bool renditionPreInit(ScrnInfoPtr, int); 118static Bool renditionScreenInit(int, ScreenPtr, int, char **); 119static Bool renditionSwitchMode(int, DisplayModePtr, int); 120static void renditionAdjustFrame(int, int, int, int); 121static Bool renditionEnterVT(int, int); 122static void renditionLeaveVT(int, int); 123static void renditionFreeScreen(int, int); 124 125static ModeStatus renditionValidMode(int, DisplayModePtr, Bool, int); 126static Bool renditionMapMem(ScrnInfoPtr pScreenInfo); 127static Bool renditionUnmapMem(ScrnInfoPtr pScreenInfo); 128#if 0 129static xf86MonPtr renditionDDC(ScrnInfoPtr pScreenInfo); 130static unsigned int renditionDDC1Read (ScrnInfoPtr pScreenInfo); 131#endif 132static xf86MonPtr renditionProbeDDC(ScrnInfoPtr pScrn, int index); 133 134static void renditionLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); 135static renditionPtr renditionGetRec(ScrnInfoPtr pScreenInfo); 136 137 138/* 139 * global data 140 */ 141 142OptionInfoRec const renditionOptions[]={ 143 { OPTION_FBWC, "FramebufferWC", OPTV_BOOLEAN, {0}, FALSE }, 144 { OPTION_SW_CURSOR, "SW_Cursor", OPTV_BOOLEAN, {0}, FALSE }, 145 { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, 146 { OPTION_OVERCLOCK_MEM,"Overclock_Mem", OPTV_BOOLEAN, {0}, FALSE }, 147 { OPTION_NO_DDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE }, 148 { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, 149 { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, 150 { -1, NULL, OPTV_NONE, {0}, FALSE } 151}; 152 153enum renditionTypes { 154 CHIP_RENDITION_V1000, 155 CHIP_RENDITION_V2x00 156}; 157 158/* supported chipsets */ 159static SymTabRec renditionChipsets[] = { 160 {CHIP_RENDITION_V1000, "V1000"}, 161 {CHIP_RENDITION_V2x00, "V2x00"}, 162 {-1, NULL} 163}; 164 165#ifdef XSERVER_LIBPCIACCESS 166#define RENDITION_DEVICE_MATCH(d, i) \ 167 { 0x1163, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) } 168 169static const struct pci_id_match rendition_device_match[] = { 170 RENDITION_DEVICE_MATCH(PCI_CHIP_V1000, CHIP_RENDITION_V1000), 171 RENDITION_DEVICE_MATCH(PCI_CHIP_V2x00, CHIP_RENDITION_V2x00), 172 173 { 0, 0, 0 } 174}; 175#else 176static PciChipsets renditionPCIchipsets[] = { 177 { CHIP_RENDITION_V1000, PCI_CHIP_V1000, RES_SHARED_VGA }, 178 { CHIP_RENDITION_V2x00, PCI_CHIP_V2x00, RES_SHARED_VGA }, 179 { -1, -1, RES_UNDEFINED } 180}; 181#endif 182 183_X_EXPORT DriverRec RENDITION={ 184 RENDITION_VERSION_CURRENT, 185 "rendition", 186 renditionIdentify, 187#ifdef XSERVER_LIBPCIACCESS 188 NULL, 189#else 190 renditionProbe, 191#endif 192 renditionAvailableOptions, 193 NULL, 194 0, 195 NULL, 196 197#ifdef XSERVER_LIBPCIACCESS 198 rendition_device_match, 199 renditionPciProbe 200#endif 201}; 202 203#ifdef XFree86LOADER 204 205/* Module loader interface */ 206 207static MODULESETUPPROTO(renditionSetup); 208 209static XF86ModuleVersionInfo renditionVersionRec = { 210 RENDITION_DRIVER_NAME, 211 MODULEVENDORSTRING, 212 MODINFOSTRING1, 213 MODINFOSTRING2, 214 XORG_VERSION_CURRENT, 215 RENDITION_VERSION_MAJOR, RENDITION_VERSION_MINOR, RENDITION_PATCHLEVEL, 216 ABI_CLASS_VIDEODRV, 217 ABI_VIDEODRV_VERSION, 218 MOD_CLASS_VIDEODRV, 219 {0, 0, 0, 0} 220}; 221 222_X_EXPORT XF86ModuleData renditionModuleData = 223 { &renditionVersionRec, renditionSetup, NULL }; 224 225static pointer 226renditionSetup(pointer Module, pointer Options, int *ErrorMajor, 227 int *ErrorMinor) 228{ 229 static Bool Initialised = FALSE; 230 231 if (!Initialised) { 232 Initialised = TRUE; 233 xf86AddDriver(&RENDITION, Module, 1); 234 return (pointer) TRUE; 235 } 236 237 if (ErrorMajor) 238 *ErrorMajor = LDR_ONCEONLY; 239 240 return NULL; 241} 242 243#endif 244 245 246/* 247 * functions 248 */ 249 250static const OptionInfoRec * 251renditionAvailableOptions(int chipid, int busid) 252{ 253 return renditionOptions; 254} 255 256static void 257renditionIdentify(int flags) 258{ 259 xf86PrintChipsets(RENDITION_NAME, 260 "rendition driver (version " RENDITION_VERSION_NAME ") for chipsets", 261 renditionChipsets); 262} 263 264 265 266#ifdef XSERVER_LIBPCIACCESS 267static Bool 268renditionPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev, 269 intptr_t match_data) 270{ 271 ScrnInfoPtr pScrn; 272 273 274 /* Allocate a ScrnInfoRec and claim the slot */ 275 pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL, RES_SHARED_VGA, 276 NULL, NULL, NULL, NULL); 277 if (pScrn != NULL) { 278 renditionPtr pRendition; 279 280 281 pScrn->driverVersion = RENDITION_VERSION_CURRENT; 282 pScrn->driverName = RENDITION_DRIVER_NAME; 283 pScrn->name = RENDITION_NAME; 284 pScrn->Probe = NULL; 285 pScrn->PreInit = renditionPreInit; 286 pScrn->ScreenInit = renditionScreenInit; 287 pScrn->SwitchMode = renditionSwitchMode; 288 pScrn->AdjustFrame = renditionAdjustFrame; 289 pScrn->EnterVT = renditionEnterVT; 290 pScrn->LeaveVT = renditionLeaveVT; 291 pScrn->FreeScreen = renditionFreeScreen; 292 pScrn->ValidMode = renditionValidMode; 293 294 /* allocate driver private structure */ 295 pRendition = renditionGetRec(pScrn); 296 if (pRendition == NULL) { 297 return FALSE; 298 } 299 300 pRendition->pEnt = xf86GetEntityInfo(entity_num); 301 pRendition->PciInfo = dev; 302 } 303 304 return (pScrn != NULL); 305} 306 307#else 308 309/* 310 * This function is called once, at the start of the first server generation to 311 * do a minimal probe for supported hardware. 312 */ 313static Bool 314renditionProbe(DriverPtr drv, int flags) 315{ 316 Bool foundScreen=FALSE; 317 int numDevSections, numUsed; 318 GDevPtr *devSections; 319 int *usedChips; 320 int c; 321 322 /* Find the config file Device sections that match this 323 * driver, and return if there are none. */ 324 if ((numDevSections=xf86MatchDevice(RENDITION_DRIVER_NAME, &devSections)) <= 0) 325 return FALSE; 326 327 /* PCI BUS */ 328 if (xf86GetPciVideoInfo()) { 329 numUsed=xf86MatchPciInstances(RENDITION_DRIVER_NAME, PCI_VENDOR_RENDITION, 330 renditionChipsets, renditionPCIchipsets, 331 devSections, numDevSections, drv, &usedChips); 332 333 xfree(devSections); 334 if (numUsed <= 0) 335 return FALSE; 336 337 if (flags & PROBE_DETECT) 338 foundScreen = TRUE; 339 else for (c=0; c<numUsed; c++) { 340 ScrnInfoPtr pScrn; 341 /* Allocate a ScrnInfoRec and claim the slot */ 342 pScrn=NULL; 343 if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[c], 344 renditionPCIchipsets, NULL, 345 NULL, NULL, NULL, NULL))) { 346 347 pScrn->driverVersion=RENDITION_VERSION_CURRENT; 348 pScrn->driverName =RENDITION_DRIVER_NAME; 349 pScrn->name =RENDITION_NAME; 350 pScrn->Probe =renditionProbe; 351 pScrn->PreInit =renditionPreInit; 352 pScrn->ScreenInit =renditionScreenInit; 353 pScrn->SwitchMode =renditionSwitchMode; 354 pScrn->AdjustFrame =renditionAdjustFrame; 355 pScrn->EnterVT =renditionEnterVT; 356 pScrn->LeaveVT =renditionLeaveVT; 357 pScrn->FreeScreen =renditionFreeScreen; 358 pScrn->ValidMode =renditionValidMode; 359 foundScreen=TRUE; 360 } 361 } 362 xfree(usedChips); 363 } 364 return foundScreen; 365} 366#endif 367 368#if 0 369static Bool 370renditionClockSelect(ScrnInfoPtr pScreenInfo, int ClockNumber) 371{ 372 vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); 373 static CARD8 save_misc; 374 375 switch (ClockNumber) 376 { 377 case CLK_REG_SAVE: 378 save_misc = inb(pvgaHW->PIOOffset + VGA_MISC_OUT_R); 379 break; 380 381 case CLK_REG_RESTORE: 382 outb(pvgaHW->PIOOffset + VGA_MISC_OUT_W, save_misc); 383 break; 384 385 default: 386 outb(pvgaHW->PIOOffset + VGA_MISC_OUT_W, 387 (save_misc & 0xF3) | ((ClockNumber << 2) & 0x0C)); 388 break; 389 } 390 391 return TRUE; 392} 393#endif 394 395static renditionPtr 396renditionGetRec(ScrnInfoPtr pScreenInfo) 397{ 398#ifdef DEBUG 399 ErrorF("GetRec ...!!!!\n"); 400 sleep(1); 401#endif 402 if (!pScreenInfo->driverPrivate) 403 pScreenInfo->driverPrivate=xcalloc(sizeof(renditionRec), 1); 404 405 /* perhaps some initialization? <ml> */ 406 407#ifdef DEBUG 408 ErrorF("GetRec ...!!!!\n"); 409 sleep(1); 410#endif 411 return (renditionPtr)pScreenInfo->driverPrivate; 412} 413 414 415static void 416renditionFreeRec(ScrnInfoPtr pScreenInfo) 417{ 418#ifdef DEBUG 419 ErrorF("FreeRec...!!!!\n"); 420 sleep(1); 421#endif 422 if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) 423 vgaHWFreeHWRec(pScreenInfo); 424 xfree(pScreenInfo->driverPrivate); 425 pScreenInfo->driverPrivate=NULL; 426 427#ifdef DEBUG 428 ErrorF("FreeRec OK...!!!!\n"); 429 sleep(1); 430#endif 431} 432 433#if 0 434static void 435renditionProtect(ScrnInfoPtr pScreenInfo, Bool On) 436{ 437#ifdef DEBUG 438 ErrorF("Protect...!!!!\n"); 439 sleep(1); 440#endif 441 442 vgaHWProtect(pScreenInfo, On); 443 444#ifdef DEBUG 445 ErrorF("Protect OK...!!!!\n"); 446 sleep(1); 447#endif 448} 449#endif 450 451static Bool 452renditionSaveScreen(ScreenPtr pScreen, int mode) 453{ 454#ifdef DEBUG 455 ErrorF("Savescreen...!!!!\n"); 456 sleep(1); 457#endif 458 459 return vgaHWSaveScreen(pScreen, mode); 460} 461 462#if 0 463static void 464renditionBlankScreen(ScrnInfoPtr pScreenInfo, Bool Unblank) 465{ 466#ifdef DEBUG 467 ErrorF("Blankscreen...!!!!\n"); 468 sleep(1); 469#endif 470 471 vgaHWBlankScreen(pScreenInfo, Unblank); 472#ifdef DEBUG 473 ErrorF("Blankscreen OK...!!!!\n"); 474 sleep(1); 475#endif 476} 477#endif 478 479 480/* 481 * This function is called once for each screen at the start of the first 482 * server generation to initialise the screen for all server generations. 483 */ 484 485static Bool 486renditionPreInit(ScrnInfoPtr pScreenInfo, int flags) 487{ 488 static ClockRange renditionClockRange = {NULL, 0, 135000, -1, FALSE, TRUE, 1, 1, 0}; 489 MessageType From; 490 int videoRam, Rounding, nModes = 0; 491 renditionPtr pRendition; 492 char *in_string; 493 vgaHWPtr pvgaHW; 494 495#ifdef DEBUG 496 ErrorF("Rendition: renditionPreInit() called\n"); 497#endif 498 499 /* Check the number of entities, and fail if it isn't one. */ 500 if (pScreenInfo->numEntities != 1) 501 return FALSE; 502 503#ifndef XSERVER_LIBPCIACCESS 504 /* allocate driver private structure */ 505 if (!renditionGetRec(pScreenInfo)) 506 return FALSE; 507#endif 508 509 pRendition=RENDITIONPTR(pScreenInfo); 510 511#ifndef XSERVER_LIBPCIACCESS 512 /* Get the entity, and make sure it is PCI. */ 513 pRendition->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[0]); 514 if (pRendition->pEnt->location.type != BUS_PCI) 515 return FALSE; 516#endif 517 518 if (flags & PROBE_DETECT) { 519 ConfiguredMonitor = 520 renditionProbeDDC(pScreenInfo, pRendition->pEnt->index); 521 return TRUE; 522 } 523 524 /* set the monitor */ 525 pScreenInfo->monitor=pScreenInfo->confScreen->monitor; 526 527 /* Initialize the card through int10 interface if needed */ 528 if (xf86LoadSubModule(pScreenInfo, "int10")){ 529 xf86Int10InfoPtr pInt=NULL; 530 531 xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Initializing int10\n"); 532 pInt = xf86InitInt10(pRendition->pEnt->index); 533 xf86FreeInt10(pInt); 534 } 535 536#ifndef XSERVER_LIBPCIACCESS 537 /* Find the PCI info for this screen */ 538 pRendition->PciInfo = xf86GetPciInfoForEntity(pRendition->pEnt->index); 539 pRendition->pcitag= pciTag(pRendition->PciInfo->bus, 540 pRendition->PciInfo->device, pRendition->PciInfo->func); 541#endif 542 543 /* 544 * XXX This could be refined if some VGA memory resources are not 545 * decoded in operating mode. 546 */ 547 xf86SetOperatingState(resVgaMem, pRendition->pEnt->index, ResUnusedOpr); 548 549 if (xf86RegisterResources(pRendition->pEnt->index, NULL, ResExclusive)) 550 return FALSE; 551 552 /* Operations for which memory access is required. */ 553 pScreenInfo->racMemFlags = RAC_FB | RAC_CURSOR; 554 /* Operations for which I/O access is required. (XXX Check this) */ 555 pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; 556 557 /* determine depth, bpp, etc. */ 558 if (!xf86SetDepthBpp(pScreenInfo, 0, 0, 0, Support32bppFb)) 559 return FALSE; 560 561 /* Verify that the color depth is supported. */ 562 switch( pScreenInfo->depth ) { 563 564 case 8: 565 case 16: 566 case 24: 567 { 568 break; 569 } 570 571 case 15: 572 { 573 if (PCI_CHIP_V1000 == DEVICE_ID(pRendition->PciInfo)) { 574 xf86DrvMsg( pScreenInfo->scrnIndex, X_ERROR, 575 "Given depth (%d) is not supported by this chipset.\n", 576 pScreenInfo->depth); 577 return FALSE; 578 } 579 } 580 581 default: 582 { 583 xf86DrvMsg( pScreenInfo->scrnIndex, X_ERROR, 584 "Given depth (%d) is not supported by this driver\n", 585 pScreenInfo->depth ); 586 return FALSE; 587 } 588 589 } /* End of switch( pScreenInfo->depth ) {*/ 590 591 592 /* Print the color depth and frame buffer bits per pixel. */ 593 xf86PrintDepthBpp( pScreenInfo ); 594 595 596 /* collect all of the options flags and process them */ 597 598 xf86CollectOptions(pScreenInfo, NULL); 599 if (!(pRendition->Options = xalloc(sizeof(renditionOptions)))) 600 return FALSE; 601 memcpy(pRendition->Options, renditionOptions, sizeof(renditionOptions)); 602 xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, 603 pRendition->Options); 604 605 606 /* Load fb */ 607 if (!xf86LoadSubModule(pScreenInfo, "fb")) 608 return FALSE; 609 610 /* determine colour weights */ 611 pScreenInfo->rgbBits=8; 612 613 if (pScreenInfo->depth > 8) { 614 rgb defaultWeight = {0, 0, 0}; 615 rgb defaultMask = {0, 0, 0}; 616 617 xf86PrintDepthBpp(pScreenInfo); 618 619 /* Standard defaults are OK if depths are OK */ 620 if (!xf86SetWeight(pScreenInfo, defaultWeight, defaultMask)) 621 return FALSE; 622 else{ 623 /* XXX: Check that returned weight is supported */ 624 } 625 } 626 627 /* determine default visual */ 628 if (!xf86SetDefaultVisual(pScreenInfo, -1)) 629 return FALSE; 630 631 /* the gamma fields must be initialised when using the new cmap code */ 632 if (pScreenInfo->depth > 1) { 633 Gamma zeros = {0.0, 0.0, 0.0}; 634 635 if (!xf86SetGamma(pScreenInfo, zeros)) 636 return FALSE; 637 } 638 639 /* the Rendition chips have a programmable clock */ 640 pScreenInfo->progClock=TRUE; 641 642 /* set various fields according to the given options */ 643 /* to be filled in <ml> */ 644 645 if (PCI_CHIP_V1000 == DEVICE_ID(pRendition->PciInfo)) { 646 pRendition->board.chip=V1000_DEVICE; 647 } 648 else { 649 pRendition->board.chip=V2000_DEVICE; 650 renditionClockRange.maxClock = 170000; 651 renditionClockRange.clockIndex = -1; 652 } 653 654 if (!xf86LoadSubModule(pScreenInfo, "vgahw")){ 655 return FALSE; 656 } 657 658 if (!vgaHWGetHWRec(pScreenInfo)) 659 return FALSE; 660 661 pvgaHW = VGAHWPTR(pScreenInfo); 662 pvgaHW->MapSize = 0x00010000; /* Standard 64kB VGA window */ 663 vgaHWGetIOBase(pvgaHW); /* Get VGA I/O base */ 664 665 pRendition->board.accel=0; 666 pRendition->board.vgaio_base = pvgaHW->PIOOffset; 667 pRendition->board.io_base = pRendition->board.vgaio_base 668#ifdef XSERVER_LIBPCIACCESS 669 + pRendition->PciInfo->regions[1].base_addr; 670#else 671 + pRendition->PciInfo->ioBase[1] 672#endif 673 ; 674 pRendition->board.mmio_base=0; 675 pRendition->board.vmmio_base=0; 676 pRendition->board.mem_size=0; 677#ifndef XSERVER_LIBPCIACCESS 678 pRendition->board.mem_base=(vu8 *)pRendition->PciInfo->memBase[0]; 679#endif 680 pRendition->board.vmem_base=NULL; 681 pRendition->board.init=0; 682 683 if (pScreenInfo->chipset) 684 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Chipset: \"%s\".\n", 685 pScreenInfo->chipset); 686 else 687 xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "Chipset: \"%s\".\n", 688 renditionChipsets[ 689 pRendition->board.chip==V1000_DEVICE ? 0:1].name); 690 691 /* I do not get the IO base addres <ml> */ 692 /* XXX Is this still true? If so, the wrong base is being checked */ 693 xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, 694 "Rendition %s @ %lx/%lx\n", 695 renditionChipsets[pRendition->board.chip==V1000_DEVICE ? 0:1] 696 .name, 697#ifdef XSERVER_LIBPCIACCESS 698 pRendition->PciInfo->regions[1].base_addr, 699 pRendition->PciInfo->regions[0].base_addr 700#else 701 pRendition->PciInfo->ioBase[1], 702 pRendition->PciInfo->memBase[0] 703#endif 704 ); 705 706 /* First of all get a "clean" starting state */ 707 verite_resetboard(pScreenInfo); 708 709 /* determine video ram -- to do so, we assume a full size memory of 16M, 710 * then map it and use verite_getmemorysize() to determine the real 711 * amount of memory */ 712 pScreenInfo->videoRam = 16<<10; 713 pRendition->board.mem_size = pScreenInfo->videoRam * 1024; 714 renditionMapMem(pScreenInfo); 715 716 videoRam=verite_getmemorysize(pScreenInfo)>>10; 717 renditionUnmapMem(pScreenInfo); 718 719 From = X_PROBED; 720 xf86DrvMsg(pScreenInfo->scrnIndex, From, "videoRam: %d kBytes\n", videoRam); 721 pScreenInfo->videoRam=videoRam; 722 pRendition->board.mem_size=videoRam * 1024; 723 724 /* Load the needed symbols */ 725 726 pRendition->board.shadowfb=TRUE; 727 728 if ((in_string = xf86GetOptValString(pRendition->Options, OPTION_ROTATE))){ 729 if(!xf86NameCmp(in_string, "CW")) { 730 /* accel is disabled below for shadowFB */ 731 pRendition->board.shadowfb = TRUE; 732 pRendition->board.rotate = 1; 733 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 734 "Rotating screen clockwise - acceleration disabled\n"); 735 } else if(!xf86NameCmp(in_string, "CCW")) { 736 pRendition->board.shadowfb = TRUE; 737 pRendition->board.rotate = -1; 738 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Rotating screen " 739 "counter clockwise - acceleration disabled\n"); 740 } else { 741 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 742 "\"%s\" is not a valid value for Option \"Rotate\"\n", 743 in_string); 744 xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 745 "Valid options are \"CW\" or \"CCW\"\n"); 746 } 747 } 748 749 if (xf86ReturnOptValBool(pRendition->Options, OPTION_SHADOW_FB,1)|| 750 pRendition->board.rotate) { 751 if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { 752 xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 753 "Oops, \"ShadowFB\" module loading failed, disabling ShadowFB!\n"); 754 } 755 else{ 756 pRendition->board.shadowfb=TRUE; 757 xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 758 "Using \"Shadow Framebuffer\"\n"); 759 } 760 } 761 else { 762 pRendition->board.shadowfb=FALSE; 763 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 764 "\"Shadow Framebuffer\" disabled\n"); 765 } 766 767 768 /* Load Ramdac module if needed */ 769 if (!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0) && 770 !pRendition->board.rotate){ 771 if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { 772 return FALSE; 773 } 774 } 775 776#if 0 777 /* Load DDC module if needed */ 778 if (!xf86ReturnOptValBool(pRendition->Options, OPTION_NO_DDC,0)){ 779 if (!xf86LoadSubModule(pScreenInfo, "ddc")) { 780 xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, 781 ("Loading of DDC library failed, skipping DDC-probe\n")); 782 } 783 else { 784 pScreenInfo->monitor->DDC = renditionDDC(pScreenInfo); 785 } 786 } 787 else { 788 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 789 ("Skipping DDC probe on users request\n")); 790 } 791#else 792 /* Load DDC module if needed */ 793 if (!xf86ReturnOptValBool(pRendition->Options, OPTION_NO_DDC,0)){ 794 if (!xf86LoadSubModule(pScreenInfo, "ddc")) { 795 xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, 796 ("Loading of DDC library failed, skipping DDC-probe\n")); 797 } 798 else { 799 xf86MonPtr mon; 800 mon = renditionProbeDDC(pScreenInfo, pRendition->pEnt->index); 801 xf86PrintEDID(mon); 802 xf86SetDDCproperties(pScreenInfo, mon); 803 } 804 } 805 else { 806 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 807 ("Skipping DDC probe on users request\n")); 808 } 809#endif 810 811 /* Set the virtual X rounding (in bits) */ 812 if (pScreenInfo->depth == 8) 813 Rounding = 16 * 8; 814 else 815 Rounding = 16; 816 817 /* 818 * Validate the modes. Note that the limits passed to 819 * xf86ValidateModes() are VGA CRTC architectural limits. 820 */ 821 pScreenInfo->maxHValue = MAX_HTOTAL; 822 pScreenInfo->maxVValue = MAX_VTOTAL; 823 nModes = xf86ValidateModes(pScreenInfo, 824 pScreenInfo->monitor->Modes, pScreenInfo->display->modes, 825 &renditionClockRange, NULL, 8, MAX_HDISPLAY, Rounding, 826 1, MAX_VDISPLAY, pScreenInfo->display->virtualX, 827 pScreenInfo->display->virtualY, 828 0x10000, LOOKUP_CLOSEST_CLOCK | LOOKUP_CLKDIV2); 829 830 if (nModes < 0) 831 return FALSE; 832 833 /* Remove invalid modes */ 834 xf86PruneDriverModes(pScreenInfo); 835 836 /* Set CRTC values for the modes */ 837 xf86SetCrtcForModes(pScreenInfo, 0); 838 839 /* Set current mode to the first in list */ 840 pScreenInfo->currentMode = pScreenInfo->modes; 841 842 /* Print mode list */ 843 xf86PrintModes(pScreenInfo); 844 845 /* Set display resolution */ 846 xf86SetDpi(pScreenInfo, 0, 0); 847 848 /* Only one chipset here */ 849 if (!pScreenInfo->chipset) 850 pScreenInfo->chipset = (char *)renditionChipsets[0].name; 851 852 if(!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0)){ 853 if(!pRendition->board.rotate) 854 /* Do preemtive things for HW cursor */ 855 RenditionHWCursorPreInit(pScreenInfo); 856 else{ 857 xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 858 "Hardware cursor not supported on rotated screen\n"); 859 xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 860 "Software cursor activated\n"); 861 } 862 } 863 else 864 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 865 "Software cursor selected\n"); 866 867 /* Unmapping delayed until after micrcode loading */ 868 /****************************************/ 869 /* Reserve memory and load the microcode */ 870 /****************************************/ 871#if USE_ACCEL 872 if (!xf86ReturnOptValBool(pRendition->Options, OPTION_NOACCEL,0) && 873 !pRendition->board.shadowfb) { 874 /* Load XAA if needed */ 875 if (xf86LoadSubModule(pScreenInfo, "xaa")) { 876 renditionMapMem(pScreenInfo); 877 RENDITIONAccelPreInit (pScreenInfo); 878 renditionUnmapMem(pScreenInfo); 879 pRendition->board.accel = TRUE; 880 } else xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 881 ("XAA module not found: " 882 "Skipping acceleration\n")); 883 } 884 else 885 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 886 ("Skipping acceleration on users request\n")); 887#else 888 xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 889 ("Skipping acceleration\n")); 890#endif 891 892#ifdef DEBUG 893 ErrorF("PreInit OK...!!!!\n"); 894 sleep(2); 895#endif 896 897 return TRUE; /* Tada! */ 898} 899 900 901/* Save mode on server entry */ 902static void 903renditionSave(ScrnInfoPtr pScreenInfo) 904{ 905#ifdef DEBUG 906 ErrorF("Save...!!!!\n"); 907 sleep(1); 908#endif 909 vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg,VGA_SR_ALL); 910 911#ifdef DEBUG 912 ErrorF("Save OK...!!!!\n"); 913 sleep(1); 914#endif 915} 916 917#if 0 918/* Restore the mode that was saved on server entry */ 919static void 920renditionRestore(ScrnInfoPtr pScreenInfo) 921{ 922#ifdef DEBUG 923 ErrorF("Restore...!!!!\n"); 924 sleep(1); 925#endif 926 927 vgaHWProtect(pScreenInfo, TRUE); 928 vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); 929 vgaHWProtect(pScreenInfo, FALSE); 930 931 verite_setmode(pScreenInfo, &RENDITIONPTR(pScreenInfo)->mode); 932 933#ifdef DEBUG 934 ErrorF("Restore OK...!!!!\n"); 935 sleep(1); 936#endif 937} 938#endif 939 940/* Set a graphics mode */ 941static Bool 942renditionSetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) 943{ 944 struct verite_modeinfo_t *modeinfo=&RENDITIONPTR(pScreenInfo)->mode; 945 946#ifdef DEBUG 947 ErrorF("RENDITION: renditionSetMode() called\n"); 948 ErrorF("Setmode...!!!!\n"); 949 sleep(1); 950#endif 951 952 /* construct a modeinfo for the verite_setmode function */ 953 modeinfo->clock=pMode->SynthClock; 954 modeinfo->hdisplay=pMode->HDisplay; 955 modeinfo->hsyncstart=pMode->HSyncStart; 956 modeinfo->hsyncend=pMode->HSyncEnd; 957 modeinfo->htotal=pMode->HTotal; 958 modeinfo->hskew=pMode->HSkew; 959 modeinfo->vdisplay=pMode->VDisplay; 960 modeinfo->vsyncstart=pMode->VSyncStart; 961 modeinfo->vsyncend=pMode->VSyncEnd; 962 modeinfo->vtotal=pMode->VTotal; 963 964 modeinfo->screenwidth = pMode->HDisplay; 965 modeinfo->virtualwidth = pScreenInfo->virtualX & 0xfff8; 966 modeinfo->screenheight = pMode->VDisplay; 967 modeinfo->virtualheight = pScreenInfo->virtualY & 0xfff8; 968 969 if ((pMode->Flags&(V_PHSYNC|V_NHSYNC)) 970 && (pMode->Flags&(V_PVSYNC|V_NVSYNC))) { 971 modeinfo->hsynchi=((pMode->Flags&V_PHSYNC) == V_PHSYNC); 972 modeinfo->vsynchi=((pMode->Flags&V_PVSYNC) == V_PVSYNC); 973 } 974 else { 975 int VDisplay=pMode->VDisplay; 976 if (pMode->Flags & V_DBLSCAN) 977 VDisplay*=2; 978 if (VDisplay < 400) { 979 /* +hsync -vsync */ 980 modeinfo->hsynchi=1; 981 modeinfo->vsynchi=0; 982 } 983 else if (VDisplay < 480) { 984 /* -hsync +vsync */ 985 modeinfo->hsynchi=0; 986 modeinfo->vsynchi=1; 987 } 988 else if (VDisplay < 768) { 989 /* -hsync -vsync */ 990 modeinfo->hsynchi=0; 991 modeinfo->vsynchi=0; 992 } 993 else { 994 /* +hsync +vsync */ 995 modeinfo->hsynchi=1; 996 modeinfo->vsynchi=1; 997 } 998 } 999 1000 switch (pScreenInfo->bitsPerPixel) { 1001 case 8: 1002 modeinfo->bitsperpixel=8; 1003 modeinfo->pixelformat=V_PIXFMT_8I; 1004 break; 1005 case 16: 1006 modeinfo->bitsperpixel=16; 1007 if (pScreenInfo->weight.green == 5) 1008 /* on a V1000, this looks too 'red/magenta' <ml> */ 1009 modeinfo->pixelformat=V_PIXFMT_1555; 1010 else 1011 modeinfo->pixelformat=V_PIXFMT_565; 1012 break; 1013 case 32: 1014 modeinfo->bitsperpixel=32; 1015 modeinfo->pixelformat=V_PIXFMT_8888; 1016 break; 1017 } 1018 modeinfo->fifosize=128; 1019 modeinfo->flags=pMode->Flags; 1020 1021 verite_setmode(pScreenInfo,&RENDITIONPTR(pScreenInfo)->mode); 1022#ifdef DEBUG 1023 ErrorF("Setmode OK...!!!!\n"); 1024 sleep(1); 1025#endif 1026 return TRUE; 1027} 1028 1029static void 1030renditionLeaveGraphics(ScrnInfoPtr pScreenInfo) 1031{ 1032 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1033 1034#ifdef DEBUG 1035 ErrorF("RENDITION: renditionLeaveGraphics() called\n"); 1036 sleep(1); 1037#endif 1038 verite_restore(pScreenInfo, &pRendition->saveRegs); 1039 1040 vgaHWProtect(pScreenInfo, TRUE); 1041 vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); 1042 vgaHWProtect(pScreenInfo, FALSE); 1043 1044 vgaHWLock(VGAHWPTR(pScreenInfo)); 1045 1046#ifdef DEBUG 1047 ErrorF("Leavegraphics OK...!!!!\n"); 1048 sleep(1); 1049#endif 1050} 1051 1052 1053/* Unravel the screen */ 1054static Bool 1055renditionCloseScreen(int scrnIndex, ScreenPtr pScreen) 1056{ 1057 ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 1058 renditionPtr prenditionPriv=renditionGetRec(pScreenInfo); 1059 Bool Closed = TRUE; 1060 1061#ifdef DEBUG 1062 ErrorF("RENDITION: renditionCloseScreen() called\n"); 1063 sleep(1); 1064#endif 1065 1066 if (prenditionPriv->board.hwcursor_used) 1067 RenditionHWCursorRelease(pScreenInfo); 1068 1069 if (prenditionPriv->board.accel) 1070 RENDITIONAccelNone(pScreenInfo); 1071 1072 if (pScreenInfo->vtSema) 1073 renditionLeaveGraphics(pScreenInfo); 1074 1075 pScreenInfo->vtSema = FALSE; 1076 1077 if (prenditionPriv 1078 && (pScreen->CloseScreen = prenditionPriv->CloseScreen)) { 1079 prenditionPriv->CloseScreen = NULL; 1080 Closed = (*pScreen->CloseScreen)(scrnIndex, pScreen); 1081 } 1082 1083#ifdef DEBUG 1084 ErrorF("Closescreen OK...!!!!\n"); 1085 sleep(1); 1086#endif 1087 return Closed; 1088} 1089 1090 1091static void 1092renditionDPMSSet(ScrnInfoPtr pScreen, int mode, int flags) 1093{ 1094#ifdef DEBUG 1095 ErrorF("RENDITION: renditionDPMSSet() called\n"); 1096#endif 1097 1098 vgaHWDPMSSet(pScreen, mode, flags); 1099} 1100 1101static Bool 1102renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) 1103{ 1104 ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 1105 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1106 Bool Inited = FALSE; 1107 unsigned char *FBBase; 1108 VisualPtr visual; 1109 vgaHWPtr pvgaHW; 1110 int displayWidth,width,height; 1111 1112#ifdef DEBUG 1113 ErrorF("RENDITION: renditionScreenInit() called\n"); 1114 sleep(1); 1115#endif 1116 /* Get vgahw private */ 1117 pvgaHW = VGAHWPTR(pScreenInfo); 1118 1119 /* Get driver private */ 1120 pRendition=renditionGetRec(pScreenInfo); 1121 1122 /* Save the current state and setup the current mode */ 1123 renditionSave(pScreenInfo); 1124 1125 /* Map VGA aperture */ 1126 if (!vgaHWMapMem(pScreenInfo)) 1127 return FALSE; 1128 1129 if (!renditionMapMem(pScreenInfo)) 1130 return FALSE; 1131 1132 /* Unlock VGA registers */ 1133 vgaHWUnlock(pvgaHW); 1134 1135 verite_save(pScreenInfo); 1136 1137 pScreenInfo->vtSema = TRUE; 1138 1139 if (!renditionSetMode(pScreenInfo, pScreenInfo->currentMode)) 1140 return FALSE; 1141 1142 /* blank the screen */ 1143 renditionSaveScreen(pScreen, SCREEN_SAVER_ON); 1144 1145 (*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex, 1146 pScreenInfo->frameX0, pScreenInfo->frameY0, 0); 1147 1148 1149 miClearVisualTypes(); 1150 1151 if (!miSetVisualTypes(pScreenInfo->depth, 1152 miGetDefaultVisualMask(pScreenInfo->depth), 1153 pScreenInfo->rgbBits, pScreenInfo->defaultVisual)) 1154 return FALSE; 1155 1156 miSetPixmapDepths (); 1157 1158 if (pRendition->board.rotate) { 1159 height = pScreenInfo->virtualX; 1160 width = pScreenInfo->virtualY; 1161 } else { 1162 width = pScreenInfo->virtualX; 1163 height = pScreenInfo->virtualY; 1164 } 1165 1166 if(pRendition->board.shadowfb) { 1167 pRendition->board.shadowPitch 1168 = BitmapBytePad(pScreenInfo->bitsPerPixel * width); 1169 pRendition->board.shadowPtr 1170 = xalloc(pRendition->board.shadowPitch * height); 1171 displayWidth = pRendition->board.shadowPitch 1172 / (pScreenInfo->bitsPerPixel >> 3); 1173 FBBase = pRendition->board.shadowPtr; 1174 } else { 1175 pRendition->board.shadowPtr = NULL; 1176 FBBase = pRendition->board.vmem_base+pRendition->board.fbOffset; 1177 displayWidth=pScreenInfo->displayWidth; 1178 } 1179 1180 Inited = fbScreenInit(pScreen, FBBase, 1181 width, height, 1182 pScreenInfo->xDpi, pScreenInfo->yDpi, 1183 displayWidth, 1184 pScreenInfo->bitsPerPixel); 1185 1186 if (!Inited) 1187 return FALSE; 1188 1189 if (pScreenInfo->bitsPerPixel > 8) { 1190 /* Fixup RGB ordering */ 1191 visual=pScreen->visuals+pScreen->numVisuals; 1192 while (--visual >= pScreen->visuals) { 1193 if ((visual->class | DynamicClass) == DirectColor){ 1194 visual->offsetRed = pScreenInfo->offset.red; 1195 visual->offsetGreen = pScreenInfo->offset.green; 1196 visual->offsetBlue = pScreenInfo->offset.blue; 1197 visual->redMask = pScreenInfo->mask.red; 1198 visual->greenMask = pScreenInfo->mask.green; 1199 visual->blueMask = pScreenInfo->mask.blue; 1200 } 1201 } 1202 } 1203 1204 /* must be after RGB ordering fixed */ 1205 fbPictureInit (pScreen, 0, 0); 1206 1207 xf86SetBlackWhitePixels(pScreen); 1208 miInitializeBackingStore(pScreen); 1209 1210 /*********************************************************/ 1211 /* The actual setup of the driver-specific code */ 1212 /* has to be after fbScreenInit and before cursor init */ 1213 /*********************************************************/ 1214#if USE_ACCEL 1215 if (pRendition->board.accel) 1216 RENDITIONAccelXAAInit (pScreen); 1217#endif 1218 1219 /* Initialise cursor functions */ 1220 xf86SetSilkenMouse(pScreen); 1221 miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); 1222 1223 if(!xf86ReturnOptValBool(pRendition->Options, OPTION_SW_CURSOR,0)&& 1224 !pRendition->board.rotate){ 1225 /* Initialise HW cursor */ 1226 if(!RenditionHWCursorInit(scrnIndex, pScreen)){ 1227 xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, 1228 "Hardware Cursor initalization failed!!\n"); 1229 } 1230 } 1231 1232 if (pRendition->board.shadowfb) { 1233 RefreshAreaFuncPtr refreshArea = renditionRefreshArea; 1234 1235 if(pRendition->board.rotate) { 1236 if (!pRendition->board.PointerMoved) { 1237 pRendition->board.PointerMoved = pScreenInfo->PointerMoved; 1238 pScreenInfo->PointerMoved = renditionPointerMoved; 1239 } 1240 1241 switch(pScreenInfo->bitsPerPixel) { 1242 case 8: refreshArea = renditionRefreshArea8; break; 1243 case 16: refreshArea = renditionRefreshArea16; break; 1244 case 24: refreshArea = renditionRefreshArea24; break; 1245 case 32: refreshArea = renditionRefreshArea32; break; 1246 } 1247 } 1248 1249 ShadowFBInit(pScreen, refreshArea); 1250 } 1251 1252 /* Setup default colourmap */ 1253 if (!miCreateDefColormap(pScreen)) 1254 return FALSE; 1255 1256 /* Try the new code based on the new colormap layer */ 1257 if (pScreenInfo->depth > 1) 1258 if (!xf86HandleColormaps(pScreen, 256, pScreenInfo->rgbBits, 1259 renditionLoadPalette, NULL, 1260 CMAP_RELOAD_ON_MODE_SWITCH)) { 1261 xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, 1262 "Colormap initialization failed\n"); 1263 return FALSE; 1264 } 1265 1266 xf86DPMSInit(pScreen, renditionDPMSSet, 0); 1267 1268 if (xf86ReturnOptValBool(pRendition->Options, OPTION_OVERCLOCK_MEM,0)) { 1269 pRendition->board.overclock_mem=TRUE; 1270 } 1271 1272 /* Wrap the screen's CloseScreen vector and set its SaveScreen vector */ 1273 pRendition->CloseScreen = pScreen->CloseScreen; 1274 pScreen->CloseScreen = renditionCloseScreen; 1275 pScreen->SaveScreen = renditionSaveScreen; 1276 1277 if (!Inited) 1278 renditionCloseScreen(scrnIndex, pScreen); 1279 1280 if (serverGeneration == 1) 1281 xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); 1282 1283#ifdef DEBUG 1284 ErrorF("ScreenInit OK...!!!!\n"); 1285 sleep(1); 1286#endif 1287 return Inited; 1288} 1289 1290static Bool 1291renditionSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) 1292{ 1293#ifdef DEBUG 1294 ErrorF("RENDITION: renditionSwitchMode() called\n"); 1295#endif 1296 return renditionSetMode(xf86Screens[scrnIndex], pMode); 1297} 1298 1299 1300static void 1301renditionAdjustFrame(int scrnIndex, int x, int y, int flags) 1302{ 1303 ScrnInfoPtr pScreenInfo=xf86Screens[scrnIndex]; 1304 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1305 int offset, virtualwidth, bitsPerPixel; 1306 1307#ifdef DEBUG 1308 ErrorF("RENDITION: renditionAdjustFrame() called\n"); 1309#endif 1310 1311 bitsPerPixel=pScreenInfo->bitsPerPixel; 1312 virtualwidth=pRendition->mode.virtualwidth; 1313 offset=(y*virtualwidth+x)*(bitsPerPixel>>3); 1314 1315 offset+= pRendition->board.fbOffset; 1316 1317#ifdef DEBUG 1318 ErrorF ("MOVING SCREEN %d bytes!!\n",offset); 1319#endif 1320 verite_setframebase(pScreenInfo, offset); 1321} 1322 1323 1324static Bool 1325renditionEnterVT(int scrnIndex, int flags) 1326{ 1327 ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 1328 vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); 1329 1330#ifdef DEBUG 1331 ErrorF("RENDITION: renditionEnterVT() called\n"); 1332#endif 1333 1334 /* Map VGA aperture */ 1335 if (!vgaHWMapMem(pScreenInfo)) 1336 return FALSE; 1337 1338 /* Unlock VGA registers */ 1339 vgaHWUnlock(pvgaHW); 1340 1341 if (!renditionSetMode(pScreenInfo, pScreenInfo->currentMode)) 1342 return FALSE; 1343 1344 (*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex, 1345 pScreenInfo->frameX0, pScreenInfo->frameY0, 0); 1346 1347 return TRUE; 1348} 1349 1350 1351static void 1352renditionLeaveVT(int scrnIndex, int flags) 1353{ 1354#ifdef DEBUG 1355 ErrorF("RENDITION: renditionLeaveVT() called\n"); 1356#endif 1357 renditionLeaveGraphics(xf86Screens[scrnIndex]); 1358} 1359 1360 1361static void 1362renditionFreeScreen(int scrnIndex, int flags) 1363{ 1364 renditionFreeRec(xf86Screens[scrnIndex]); 1365} 1366 1367 1368static ModeStatus 1369renditionValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, 1370 int flags) 1371{ 1372 if (pMode->Flags & V_INTERLACE) 1373 return MODE_NO_INTERLACE; 1374 1375 return MODE_OK; 1376} 1377 1378static Bool 1379renditionMapMem(ScrnInfoPtr pScreenInfo) 1380{ 1381 Bool WriteCombine; 1382 int mapOption; 1383 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1384#ifdef XSERVER_LIBPCIACCESS 1385 int err; 1386#endif 1387 1388#ifdef DEBUG 1389 ErrorF("Mapping ...\n"); 1390#ifndef XSERVER_LIBPCIACCESS 1391 ErrorF("%d %d %d %x %d\n", pScreenInfo->scrnIndex, VIDMEM_FRAMEBUFFER, 1392 pRendition->pcitag, 1393 pRendition->board.mem_base, pScreenInfo->videoRam * 1024); 1394#endif 1395#endif 1396 1397 if (pRendition->board.chip == V1000_DEVICE){ 1398 /* Some V1000 boards are known to have problems with Write-Combining */ 1399 /* V2x00 also found to have similar problems with memcpy & WC ! */ 1400 WriteCombine = 0; 1401 } else { 1402 /* Activate Write_Combine if possible */ 1403 WriteCombine = 1; 1404 } 1405 /* Override on users request */ 1406 WriteCombine 1407 = xf86ReturnOptValBool(pRendition->Options, OPTION_FBWC, WriteCombine); 1408 if (WriteCombine) { 1409 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 1410 ("Requesting Write-Combined memory access\n")); 1411 mapOption = VIDMEM_FRAMEBUFFER; 1412 } else { 1413 xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 1414 ("Requesting MMIO-style memory access\n")); 1415 mapOption = VIDMEM_MMIO; 1416 } 1417 1418#ifdef XSERVER_LIBPCIACCESS 1419 err = pci_device_map_region(pRendition->PciInfo, 0, TRUE); 1420 pRendition->board.vmem_base = pRendition->PciInfo->regions[0].memory; 1421 1422 return (err == 0); 1423#else 1424 pRendition->board.vmem_base= 1425 xf86MapPciMem(pScreenInfo->scrnIndex, mapOption, 1426 pRendition->pcitag, 1427 (unsigned long)pRendition->board.mem_base, 1428 pScreenInfo->videoRam * 1024); 1429 return TRUE; 1430#endif 1431 1432#ifdef DEBUG0 1433 ErrorF("Done\n"); 1434#endif 1435} 1436 1437static Bool 1438renditionUnmapMem(ScrnInfoPtr pScreenInfo) 1439{ 1440 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1441#ifdef DEBUG 1442 ErrorF("Unmapping ...\n"); 1443#endif 1444 1445#ifndef XSERVER_LIBPCIACCESS 1446 xf86UnMapVidMem(pScreenInfo->scrnIndex, 1447 pRendition->board.vmem_base, 1448 pScreenInfo->videoRam * 1024); 1449#else 1450 pci_device_unmap_range(pRendition->PciInfo, 1451 pRendition->board.vmem_base, 1452 pScreenInfo->videoRam * 1024); 1453#endif 1454 return TRUE; 1455#ifdef DEBUG0 1456 ErrorF("Done\n"); 1457#endif 1458} 1459 1460static void 1461renditionLoadPalette(ScrnInfoPtr pScreenInfo, int numColors, 1462 int *indices, LOCO *colors, 1463 VisualPtr pVisual) 1464{ 1465 verite_setpalette(pScreenInfo, numColors, indices, colors, pVisual); 1466} 1467 1468xf86MonPtr 1469renditionProbeDDC(ScrnInfoPtr pScreenInfo, int index) 1470{ 1471 vbeInfoPtr pVbe; 1472 xf86MonPtr mon = NULL; 1473 1474 if (xf86LoadSubModule(pScreenInfo, "vbe")) { 1475 pVbe = VBEInit(NULL,index); 1476 mon = vbeDoEDID(pVbe, NULL); 1477 vbeFree(pVbe); 1478 } 1479 return mon; 1480} 1481 1482# if 0 1483static xf86MonPtr 1484renditionDDC (ScrnInfoPtr pScreenInfo) 1485{ 1486 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1487 IOADDRESS iob=pRendition->board.io_base; 1488 vu32 temp; 1489 1490 xf86MonPtr MonInfo = NULL; 1491 temp = verite_in32(iob+CRTCCTL); /* Remember original value */ 1492 1493 /* Enable DDC1 */ 1494 verite_out32(iob+CRTCCTL,(temp| 1495 CRTCCTL_ENABLEDDC| 1496 CRTCCTL_VSYNCENABLE| 1497 CRTCCTL_VIDEOENABLE)); 1498 1499 MonInfo = xf86DoEDID_DDC1(pScreenInfo->scrnIndex, 1500 vgaHWddc1SetSpeed, 1501 renditionDDC1Read ); 1502 1503 verite_out32(iob+CRTCCTL,temp); /* return the original values */ 1504 1505 xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 1506 "DDC Monitor info: %p\n", MonInfo); 1507 1508 xf86PrintEDID( MonInfo ); 1509 xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 1510 "end of DDC Monitor info\n\n"); 1511 1512 /* xf86SetDDCproperties(pScreenInfo, MonInfo); */ 1513 return MonInfo; 1514} 1515 1516static unsigned int 1517renditionDDC1Read (ScrnInfoPtr pScreenInfo) 1518{ 1519 renditionPtr pRendition = RENDITIONPTR(pScreenInfo); 1520 IOADDRESS iob=pRendition->board.io_base; 1521 vu32 value = 0; 1522 1523 /* wait for Vsync */ 1524 while (!(verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC)); 1525 while (verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC); 1526 1527 /* Read the value */ 1528 value = verite_in32(iob+CRTCCTL) & CRTCCTL_DDCDATA; 1529 return value; 1530} 1531 1532#endif 1533