cg6_driver.c revision 093ea8b6
1/* 2 * GX and Turbo GX framebuffer driver. 3 * 4 * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c,v 1.7 2002/12/06 16:44:38 tsi Exp $ */ 24 25#ifdef HAVE_CONFIG_H 26#include "config.h" 27#endif 28 29/* need this for PRIxPTR macro */ 30#include <machine/int_fmtio.h> 31 32#include <string.h> 33 34#include "xf86.h" 35#include "xf86_OSproc.h" 36#include "xf86Version.h" 37#include "mipointer.h" 38#include "mibstore.h" 39#include "micmap.h" 40 41#include "fb.h" 42#include "xf86cmap.h" 43#include "cg6.h" 44 45static const OptionInfoRec * CG6AvailableOptions(int chipid, int busid); 46static void CG6Identify(int flags); 47static Bool CG6Probe(DriverPtr drv, int flags); 48static Bool CG6PreInit(ScrnInfoPtr pScrn, int flags); 49static Bool CG6ScreenInit(int Index, ScreenPtr pScreen, int argc, 50 char **argv); 51static Bool CG6EnterVT(int scrnIndex, int flags); 52static void CG6LeaveVT(int scrnIndex, int flags); 53static Bool CG6CloseScreen(int scrnIndex, ScreenPtr pScreen); 54static Bool CG6SaveScreen(ScreenPtr pScreen, int mode); 55 56/* Required if the driver supports mode switching */ 57static Bool CG6SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); 58/* Required if the driver supports moving the viewport */ 59static void CG6AdjustFrame(int scrnIndex, int x, int y, int flags); 60 61/* Optional functions */ 62static void CG6FreeScreen(int scrnIndex, int flags); 63static ModeStatus CG6ValidMode(int scrnIndex, DisplayModePtr mode, 64 Bool verbose, int flags); 65 66void CG6Sync(ScrnInfoPtr pScrn); 67 68#define CG6_VERSION 4000 69#define CG6_NAME "SUNCG6" 70#define CG6_DRIVER_NAME "suncg6" 71#define CG6_MAJOR_VERSION 1 72#define CG6_MINOR_VERSION 1 73#define CG6_PATCHLEVEL 0 74 75/* 76 * This contains the functions needed by the server after loading the driver 77 * module. It must be supplied, and gets passed back by the SetupProc 78 * function in the dynamic case. In the static case, a reference to this 79 * is compiled in, and this requires that the name of this DriverRec be 80 * an upper-case version of the driver name. 81 */ 82 83_X_EXPORT DriverRec SUNCG6 = { 84 CG6_VERSION, 85 CG6_DRIVER_NAME, 86 CG6Identify, 87 CG6Probe, 88 CG6AvailableOptions, 89 NULL, 90 0 91}; 92 93typedef enum { 94 OPTION_SW_CURSOR, 95 OPTION_HW_CURSOR, 96 OPTION_NOACCEL 97} CG6Opts; 98 99static const OptionInfoRec CG6Options[] = { 100 { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, 101 { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, 102 { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, 103 { -1, NULL, OPTV_NONE, {0}, FALSE } 104}; 105 106static const char *xaaSymbols[] = 107{ 108 "XAACreateInfoRec", 109 "XAADestroyInfoRec", 110 "XAAInit", 111 NULL 112}; 113 114#ifdef XFree86LOADER 115 116static MODULESETUPPROTO(cg6Setup); 117 118static XF86ModuleVersionInfo suncg6VersRec = 119{ 120 "suncg6", 121 MODULEVENDORSTRING, 122 MODINFOSTRING1, 123 MODINFOSTRING2, 124 XORG_VERSION_CURRENT, 125 CG6_MAJOR_VERSION, CG6_MINOR_VERSION, CG6_PATCHLEVEL, 126 ABI_CLASS_VIDEODRV, 127 ABI_VIDEODRV_VERSION, 128 MOD_CLASS_VIDEODRV, 129 {0,0,0,0} 130}; 131 132_X_EXPORT XF86ModuleData suncg6ModuleData = { &suncg6VersRec, cg6Setup, NULL }; 133 134pointer 135cg6Setup(pointer module, pointer opts, int *errmaj, int *errmin) 136{ 137 static Bool setupDone = FALSE; 138 139 if (!setupDone) { 140 setupDone = TRUE; 141 xf86AddDriver(&SUNCG6, module, 0); 142 143 /* 144 * Modules that this driver always requires can be loaded here 145 * by calling LoadSubModule(). 146 */ 147 148 /* 149 * The return value must be non-NULL on success even though there 150 * is no TearDownProc. 151 */ 152 return (pointer)TRUE; 153 } else { 154 if (errmaj) *errmaj = LDR_ONCEONLY; 155 return NULL; 156 } 157} 158 159#endif /* XFree86LOADER */ 160 161static Bool 162CG6GetRec(ScrnInfoPtr pScrn) 163{ 164 /* 165 * Allocate an Cg6Rec, and hook it into pScrn->driverPrivate. 166 * pScrn->driverPrivate is initialised to NULL, so we can check if 167 * the allocation has already been done. 168 */ 169 if (pScrn->driverPrivate != NULL) 170 return TRUE; 171 172 pScrn->driverPrivate = xnfcalloc(sizeof(Cg6Rec), 1); 173 return TRUE; 174} 175 176static void 177CG6FreeRec(ScrnInfoPtr pScrn) 178{ 179 Cg6Ptr pCg6; 180 181 if (pScrn->driverPrivate == NULL) 182 return; 183 184 pCg6 = GET_CG6_FROM_SCRN(pScrn); 185 186 xfree(pScrn->driverPrivate); 187 pScrn->driverPrivate = NULL; 188 189 return; 190} 191 192static const OptionInfoRec * 193CG6AvailableOptions(int chipid, int busid) 194{ 195 return CG6Options; 196} 197 198/* Mandatory */ 199static void 200CG6Identify(int flags) 201{ 202 xf86Msg(X_INFO, "%s: driver for CGsix (GX and Turbo GX)\n", CG6_NAME); 203} 204 205 206/* Mandatory */ 207static Bool 208CG6Probe(DriverPtr drv, int flags) 209{ 210 int i; 211 GDevPtr *devSections; 212 int *usedChips; 213 int numDevSections; 214 int numUsed; 215 Bool foundScreen = FALSE; 216 EntityInfoPtr pEnt; 217 218 /* 219 * The aim here is to find all cards that this driver can handle, 220 * and for the ones not already claimed by another driver, claim the 221 * slot, and allocate a ScrnInfoRec. 222 * 223 * This should be a minimal probe, and it should under no circumstances 224 * change the state of the hardware. Because a device is found, don't 225 * assume that it will be used. Don't do any initialisations other than 226 * the required ScrnInfoRec initialisations. Don't allocate any new 227 * data structures. 228 */ 229 230 /* 231 * Next we check, if there has been a chipset override in the config file. 232 * For this we must find out if there is an active device section which 233 * is relevant, i.e., which has no driver specified or has THIS driver 234 * specified. 235 */ 236 237 if ((numDevSections = xf86MatchDevice(CG6_DRIVER_NAME, 238 &devSections)) <= 0) { 239 /* 240 * There's no matching device section in the config file, so quit 241 * now. 242 */ 243 return FALSE; 244 } 245 246 /* 247 * We need to probe the hardware first. We then need to see how this 248 * fits in with what is given in the config file, and allow the config 249 * file info to override any contradictions. 250 */ 251 252 numUsed = xf86MatchSbusInstances(CG6_NAME, SBUS_DEVICE_CG6, 253 devSections, numDevSections, 254 drv, &usedChips); 255 256 xfree(devSections); 257 if (numUsed <= 0) 258 return FALSE; 259 260 if (flags & PROBE_DETECT) 261 foundScreen = TRUE; 262 else for (i = 0; i < numUsed; i++) { 263 pEnt = xf86GetEntityInfo(usedChips[i]); 264 265 /* 266 * Check that nothing else has claimed the slots. 267 */ 268 if(pEnt->active) { 269 ScrnInfoPtr pScrn; 270 271 /* Allocate a ScrnInfoRec and claim the slot */ 272 pScrn = xf86AllocateScreen(drv, 0); 273 274 /* Fill in what we can of the ScrnInfoRec */ 275 pScrn->driverVersion = CG6_VERSION; 276 pScrn->driverName = CG6_DRIVER_NAME; 277 pScrn->name = CG6_NAME; 278 pScrn->Probe = CG6Probe; 279 pScrn->PreInit = CG6PreInit; 280 pScrn->ScreenInit = CG6ScreenInit; 281 pScrn->SwitchMode = CG6SwitchMode; 282 pScrn->AdjustFrame = CG6AdjustFrame; 283 pScrn->EnterVT = CG6EnterVT; 284 pScrn->LeaveVT = CG6LeaveVT; 285 pScrn->FreeScreen = CG6FreeScreen; 286 pScrn->ValidMode = CG6ValidMode; 287 xf86AddEntityToScreen(pScrn, pEnt->index); 288 foundScreen = TRUE; 289 } 290 xfree(pEnt); 291 } 292 xfree(usedChips); 293 return foundScreen; 294} 295 296/* Mandatory */ 297static Bool 298CG6PreInit(ScrnInfoPtr pScrn, int flags) 299{ 300 Cg6Ptr pCg6; 301 sbusDevicePtr psdp; 302 MessageType from; 303 int i; 304 305 if (flags & PROBE_DETECT) return FALSE; 306 307 /* 308 * Note: This function is only called once at server startup, and 309 * not at the start of each server generation. This means that 310 * only things that are persistent across server generations can 311 * be initialised here. xf86Screens[] is (pScrn is a pointer to one 312 * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex() 313 * are too, and should be used for data that must persist across 314 * server generations. 315 * 316 * Per-generation data should be allocated with 317 * AllocateScreenPrivateIndex() from the ScreenInit() function. 318 */ 319 320 /* Allocate the Cg6Rec driverPrivate */ 321 if (!CG6GetRec(pScrn)) { 322 return FALSE; 323 } 324 pCg6 = GET_CG6_FROM_SCRN(pScrn); 325 326 /* Set pScrn->monitor */ 327 pScrn->monitor = pScrn->confScreen->monitor; 328 329 /* This driver doesn't expect more than one entity per screen */ 330 if (pScrn->numEntities > 1) 331 return FALSE; 332 /* This is the general case */ 333 for (i = 0; i < pScrn->numEntities; i++) { 334 EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]); 335 336 /* CG6 is purely SBUS */ 337 if (pEnt->location.type == BUS_SBUS) { 338 psdp = xf86GetSbusInfoForEntity(pEnt->index); 339 pCg6->psdp = psdp; 340 } else 341 return FALSE; 342 } 343 344 /********************* 345 deal with depth 346 *********************/ 347 348 if (!xf86SetDepthBpp(pScrn, 0, 0, 0, NoDepth24Support)) { 349 return FALSE; 350 } else { 351 /* Check that the returned depth is one we support */ 352 switch (pScrn->depth) { 353 case 8: 354 /* OK */ 355 break; 356 default: 357 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 358 "Given depth (%d) is not supported by this driver\n", 359 pScrn->depth); 360 return FALSE; 361 } 362 } 363 364 /* Collect all of the relevant option flags (fill in pScrn->options) */ 365 xf86CollectOptions(pScrn, NULL); 366 /* Process the options */ 367 if (!(pCg6->Options = xalloc(sizeof(CG6Options)))) 368 return FALSE; 369 memcpy(pCg6->Options, CG6Options, sizeof(CG6Options)); 370 xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pCg6->Options); 371 372 if (!xf86SetDefaultVisual(pScrn, -1)) 373 return FALSE; 374 375 /* 376 * The new cmap code requires this to be initialised. 377 */ 378 379 { 380 Gamma zeros = {0.0, 0.0, 0.0}; 381 382 if (!xf86SetGamma(pScrn, zeros)) { 383 return FALSE; 384 } 385 } 386 387 /* Set the bits per RGB for 8bpp mode */ 388 from = X_DEFAULT; 389 390 /* determine whether we use hardware or software cursor */ 391 392 pCg6->HWCursor = TRUE; 393 if (xf86GetOptValBool(pCg6->Options, OPTION_HW_CURSOR, &pCg6->HWCursor)) 394 from = X_CONFIG; 395 if (xf86ReturnOptValBool(pCg6->Options, OPTION_SW_CURSOR, FALSE)) { 396 from = X_CONFIG; 397 pCg6->HWCursor = FALSE; 398 } 399 400 xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", 401 pCg6->HWCursor ? "HW" : "SW"); 402 403 if (xf86ReturnOptValBool(pCg6->Options, OPTION_NOACCEL, FALSE)) { 404 pCg6->NoAccel = TRUE; 405 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); 406 } 407 408 if (xf86LoadSubModule(pScrn, "fb") == NULL) { 409 CG6FreeRec(pScrn); 410 return FALSE; 411 } 412 413 if (pCg6->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) { 414 CG6FreeRec(pScrn); 415 return FALSE; 416 } 417 418 if (pCg6->HWCursor && xf86LoadSubModule(pScrn, "xaa") == NULL) { 419 CG6FreeRec(pScrn); 420 return FALSE; 421 } 422 xf86LoaderReqSymLists(xaaSymbols, NULL); 423 424 /********************* 425 set up clock and mode stuff 426 *********************/ 427 428 pScrn->progClock = TRUE; 429 430 if(pScrn->display->virtualX || pScrn->display->virtualY) { 431 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, 432 "CG6 does not support a virtual desktop\n"); 433 pScrn->display->virtualX = 0; 434 pScrn->display->virtualY = 0; 435 } 436 437 xf86SbusUseBuiltinMode(pScrn, pCg6->psdp); 438 pScrn->currentMode = pScrn->modes; 439 pScrn->displayWidth = pScrn->virtualX; 440 441 /* Set display resolution */ 442 xf86SetDpi(pScrn, 0, 0); 443 444 return TRUE; 445} 446 447/* Mandatory */ 448 449/* This gets called at the start of each server generation */ 450 451static Bool 452CG6ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) 453{ 454 ScrnInfoPtr pScrn; 455 Cg6Ptr pCg6; 456 sbusDevicePtr psdp; 457 int ret; 458 459 /* 460 * First get the ScrnInfoRec 461 */ 462 pScrn = xf86Screens[pScreen->myNum]; 463 pCg6 = GET_CG6_FROM_SCRN(pScrn); 464 psdp = pCg6->psdp; 465 466 /* Map the CG6 memory */ 467 468 pCg6->fbc = xf86MapSbusMem(psdp, CG6_FBC_VOFF, sizeof(*pCg6->fbc)); 469 pCg6->thc = xf86MapSbusMem(psdp, CG6_THC_VOFF, sizeof(*pCg6->thc)); 470 471 /* 472 * XXX need something better here - we rely on the OS to allow mmap()ing 473 * usable VRAM ONLY. Works with NetBSD, may crash and burn on other OSes. 474 */ 475 pCg6->vidmem = 2 * 1024 * 1024; 476 pCg6->fb = xf86MapSbusMem(psdp, CG6_RAM_VOFF, pCg6->vidmem); 477 478 if (pCg6->fb == NULL) { 479 /* mapping 2MB failed - try 1MB */ 480 pCg6->vidmem = 1024 * 1024; 481 pCg6->fb = xf86MapSbusMem(psdp, CG6_RAM_VOFF, pCg6->vidmem); 482 } 483 484 if (pCg6->fb == NULL) { 485 /* we can't map all video RAM - fall back to width*height */ 486 pCg6->vidmem = psdp->width * psdp->height; 487 pCg6->fb = xf86MapSbusMem(psdp, CG6_RAM_VOFF, pCg6->vidmem); 488 } 489 490 if (pCg6->fb != NULL) { 491 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "mapped %d KB video RAM\n", 492 pCg6->vidmem >> 10); 493 } 494 495 if (!pCg6->fbc || !pCg6->thc || !pCg6->fb) { 496 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 497 "xf86MapSbusMem failed fbc:%" PRIxPTR " fb:%" PRIxPTR 498 " thc:%" PRIxPTR "\n", 499 pCg6->fbc, pCg6->fb, pCg6->thc ); 500 501 if (pCg6->fbc) { 502 xf86UnmapSbusMem(psdp, pCg6->fbc, sizeof(*pCg6->fbc)); 503 pCg6->fbc = NULL; 504 } 505 506 if (pCg6->thc) { 507 xf86UnmapSbusMem(psdp, pCg6->thc, sizeof(*pCg6->thc)); 508 pCg6->thc = NULL; 509 } 510 511 if (pCg6->fb) { 512 xf86UnmapSbusMem(psdp, pCg6->fb, pCg6->vidmem); 513 pCg6->fb = NULL; 514 } 515 516 return FALSE; 517 } 518 519 /* Darken the screen for aesthetic reasons and set the viewport */ 520 CG6SaveScreen(pScreen, SCREEN_SAVER_ON); 521 522 /* 523 * The next step is to setup the screen's visuals, and initialise the 524 * framebuffer code. In cases where the framebuffer's default 525 * choices for things like visual layouts and bits per RGB are OK, 526 * this may be as simple as calling the framebuffer's ScreenInit() 527 * function. If not, the visuals will need to be setup before calling 528 * a fb ScreenInit() function and fixed up after. 529 */ 530 531 /* 532 * Reset visual list. 533 */ 534 miClearVisualTypes(); 535 536 /* Set the bits per RGB for 8bpp mode */ 537 pScrn->rgbBits = 8; 538 539 /* Setup the visuals we support. */ 540 541 if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), 542 pScrn->rgbBits, pScrn->defaultVisual)) 543 return FALSE; 544 545 miSetPixmapDepths (); 546 547 /* 548 * Call the framebuffer layer's ScreenInit function, and fill in other 549 * pScreen fields. 550 */ 551 552 ret = fbScreenInit(pScreen, pCg6->fb, pScrn->virtualX, 553 pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, 554 pScrn->virtualX, 8); 555 if (!ret) 556 return FALSE; 557 558 pCg6->width = pScrn->virtualX; 559 pCg6->height = pScrn->virtualY; 560 pCg6->maxheight = (pCg6->vidmem / pCg6->width) & 0xffff; 561 562 fbPictureInit (pScreen, 0, 0); 563 564 miInitializeBackingStore(pScreen); 565 xf86SetBackingStore(pScreen); 566 xf86SetSilkenMouse(pScreen); 567 568 xf86SetBlackWhitePixels(pScreen); 569 570 if (!pCg6->NoAccel) { 571 BoxRec bx; 572 pCg6->pXAA=XAACreateInfoRec(); 573 CG6AccelInit(pScrn); 574 bx.x1=bx.y1=0; 575 bx.x2=pCg6->width; 576 bx.y2=pCg6->maxheight; 577 xf86InitFBManager(pScreen,&bx); 578 if(!XAAInit(pScreen, pCg6->pXAA)) 579 return FALSE; 580 581 xf86Msg(X_INFO, "%s: Using acceleration\n", pCg6->psdp->device); 582 } 583 584 /* setup DGA */ 585 Cg6DGAInit(pScreen); 586 587 588 /* Initialise cursor functions */ 589 miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); 590 591 /* Initialize HW cursor layer. 592 Must follow software cursor initialization*/ 593 if (pCg6->HWCursor) { 594 extern Bool CG6HWCursorInit(ScreenPtr pScreen); 595 596 if(!CG6HWCursorInit(pScreen)) { 597 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 598 "Hardware cursor initialization failed\n"); 599 return(FALSE); 600 } 601 xf86SbusHideOsHwCursor(pCg6->psdp); 602 } 603 604 /* Initialise default colourmap */ 605 if (!miCreateDefColormap(pScreen)) 606 return FALSE; 607 608 if(!xf86SbusHandleColormaps(pScreen, pCg6->psdp)) 609 return FALSE; 610 611 pCg6->CloseScreen = pScreen->CloseScreen; 612 pScreen->CloseScreen = CG6CloseScreen; 613 pScreen->SaveScreen = CG6SaveScreen; 614 615 /* Report any unused options (only for the first generation) */ 616 if (serverGeneration == 1) { 617 xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); 618 } 619 620 /* unblank the screen */ 621 CG6SaveScreen(pScreen, SCREEN_SAVER_OFF); 622 623 /* Done */ 624 return TRUE; 625} 626 627 628/* Usually mandatory */ 629static Bool 630CG6SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) 631{ 632 return TRUE; 633} 634 635 636/* 637 * This function is used to initialize the Start Address - the first 638 * displayed location in the video memory. 639 */ 640/* Usually mandatory */ 641static void 642CG6AdjustFrame(int scrnIndex, int x, int y, int flags) 643{ 644 /* we don't support virtual desktops */ 645 return; 646} 647 648/* 649 * This is called when VT switching back to the X server. Its job is 650 * to reinitialise the video mode. 651 */ 652 653/* Mandatory */ 654static Bool 655CG6EnterVT(int scrnIndex, int flags) 656{ 657 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 658 Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 659 660 if (pCg6->HWCursor) { 661 xf86SbusHideOsHwCursor (pCg6->psdp); 662 pCg6->CursorFg = 0; 663 pCg6->CursorBg = 0; 664 } 665 return TRUE; 666} 667 668 669/* 670 * This is called when VT switching away from the X server. 671 */ 672 673/* Mandatory */ 674static void 675CG6LeaveVT(int scrnIndex, int flags) 676{ 677 return; 678} 679 680 681/* 682 * This is called at the end of each server generation. It restores the 683 * original (text) mode. It should really also unmap the video memory too. 684 */ 685 686/* Mandatory */ 687static Bool 688CG6CloseScreen(int scrnIndex, ScreenPtr pScreen) 689{ 690 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 691 Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 692 693 pScrn->vtSema = FALSE; 694 695 xf86UnmapSbusMem(pCg6->psdp, pCg6->fbc, 696 CG6_RAM_VOFF - CG6_FBC_VOFF + 697 (pCg6->psdp->width * pCg6->psdp->height)); 698 699 if (pCg6->HWCursor) 700 xf86SbusHideOsHwCursor(pCg6->psdp); 701 702 pScreen->CloseScreen = pCg6->CloseScreen; 703 return (*pScreen->CloseScreen)(scrnIndex, pScreen); 704 return FALSE; 705} 706 707 708/* Free up any per-generation data structures */ 709 710/* Optional */ 711static void 712CG6FreeScreen(int scrnIndex, int flags) 713{ 714 CG6FreeRec(xf86Screens[scrnIndex]); 715} 716 717 718/* Checks if a mode is suitable for the selected chipset. */ 719 720/* Optional */ 721static ModeStatus 722CG6ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) 723{ 724 if (mode->Flags & V_INTERLACE) 725 return(MODE_BAD); 726 727 return(MODE_OK); 728} 729 730/* Do screen blanking */ 731 732/* Mandatory */ 733static Bool 734CG6SaveScreen(ScreenPtr pScreen, int mode) 735{ 736 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 737 Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); 738 unsigned int tmp = pCg6->thc->thc_misc; 739 740 switch(mode) 741 { 742 case SCREEN_SAVER_ON: 743 case SCREEN_SAVER_CYCLE: 744 tmp &= ~CG6_THC_MISC_SYNC_ENAB; 745 break; 746 case SCREEN_SAVER_OFF: 747 case SCREEN_SAVER_FORCER: 748 tmp |= CG6_THC_MISC_SYNC_ENAB; 749 break; 750 default: 751 return FALSE; 752 } 753 754 pCg6->thc->thc_misc = tmp; 755 return TRUE; 756} 757 758/* 759 * This is the implementation of the Sync() function. 760 */ 761void 762CG6Sync(ScrnInfoPtr pScrn) 763{ 764 return; 765} 766