nsc_gx1_driver.c revision ce2d3770
1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_gx1_driver.c,v 1.10tsi Exp $ */ 2/* 3 * $Workfile: nsc_gx1_driver.c $ 4 * $Revision: 1.2 $ 5 * $Author: mrg $ 6 * 7 * File Contents: This is the main module configures the interfacing 8 * with the X server. The individual modules will be 9 * loaded based upon the options selected from the 10 * XF86Config. This file also has modules for finding 11 * supported modes, turning on the modes based on options. 12 * 13 * Project: Geode Xfree Frame buffer device driver. 14 * 15 */ 16 17/* 18 * NSC_LIC_ALTERNATIVE_PREAMBLE 19 * 20 * Revision 1.0 21 * 22 * National Semiconductor Alternative GPL-BSD License 23 * 24 * National Semiconductor Corporation licenses this software 25 * ("Software"): 26 * 27 * National Xfree frame buffer driver 28 * 29 * under one of the two following licenses, depending on how the 30 * Software is received by the Licensee. 31 * 32 * If this Software is received as part of the Linux Framebuffer or 33 * other GPL licensed software, then the GPL license designated 34 * NSC_LIC_GPL applies to this Software; in all other circumstances 35 * then the BSD-style license designated NSC_LIC_BSD shall apply. 36 * 37 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */ 38 39/* NSC_LIC_BSD 40 * 41 * National Semiconductor Corporation Open Source License for 42 * 43 * National Xfree frame buffer driver 44 * 45 * (BSD License with Export Notice) 46 * 47 * Copyright (c) 1999-2001 48 * National Semiconductor Corporation. 49 * All rights reserved. 50 * 51 * Redistribution and use in source and binary forms, with or without 52 * modification, are permitted provided that the following conditions 53 * are met: 54 * 55 * * Redistributions of source code must retain the above copyright 56 * notice, this list of conditions and the following disclaimer. 57 * 58 * * Redistributions in binary form must reproduce the above 59 * copyright notice, this list of conditions and the following 60 * disclaimer in the documentation and/or other materials provided 61 * with the distribution. 62 * 63 * * Neither the name of the National Semiconductor Corporation nor 64 * the names of its contributors may be used to endorse or promote 65 * products derived from this software without specific prior 66 * written permission. 67 * 68 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 69 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 70 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 71 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 72 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 73 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 74 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 75 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 76 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 77 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 78 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 79 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 80 * OF SUCH DAMAGE. 81 * 82 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 83 * YOUR JURISDICTION. It is licensee's responsibility to comply with 84 * any export regulations applicable in licensee's jurisdiction. Under 85 * CURRENT (2001) U.S. export regulations this software 86 * is eligible for export from the U.S. and can be downloaded by or 87 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 88 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 89 * Syria, Sudan, Afghanistan and any other country to which the U.S. 90 * has embargoed goods and services. 91 * 92 * END_NSC_LIC_BSD */ 93 94/* NSC_LIC_GPL 95 * 96 * National Semiconductor Corporation Gnu General Public License for 97 * 98 * National Xfree frame buffer driver 99 * 100 * (GPL License with Export Notice) 101 * 102 * Copyright (c) 1999-2001 103 * National Semiconductor Corporation. 104 * All rights reserved. 105 * 106 * Redistribution and use in source and binary forms, with or without 107 * modification, are permitted under the terms of the GNU General 108 * Public License as published by the Free Software Foundation; either 109 * version 2 of the License, or (at your option) any later version 110 * 111 * In addition to the terms of the GNU General Public License, neither 112 * the name of the National Semiconductor Corporation nor the names of 113 * its contributors may be used to endorse or promote products derived 114 * from this software without specific prior written permission. 115 * 116 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 117 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 118 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 119 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 120 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 121 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 122 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 123 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 124 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 125 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 126 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 127 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 128 * OF SUCH DAMAGE. See the GNU General Public License for more details. 129 * 130 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 131 * YOUR JURISDICTION. It is licensee's responsibility to comply with 132 * any export regulations applicable in licensee's jurisdiction. Under 133 * CURRENT (2001) U.S. export regulations this software 134 * is eligible for export from the U.S. and can be downloaded by or 135 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 136 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 137 * Syria, Sudan, Afghanistan and any other country to which the U.S. 138 * has embargoed goods and services. 139 * 140 * You should have received a copy of the GNU General Public License 141 * along with this file; if not, write to the Free Software Foundation, 142 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 143 * 144 * END_NSC_LIC_GPL */ 145 146/* 147 * Lots of fixes & updates 148 * Alan Hourihane <alanh@fairlite.demon.co.uk> 149 */ 150 151#ifdef HAVE_CONFIG_H 152#include "config.h" 153#endif 154 155#define DEBUG(x) 156#define GEODE_TRACE 0 157#define HWVGA 0 158 159/* Includes that are used by all drivers */ 160#include "xf86.h" 161#include "xf86_OSproc.h" 162#include "xf86Resources.h" 163 164/* We may want inb() and outb() */ 165#include "compiler.h" 166 167/* We may want to access the PCI config space */ 168#include "xf86PciInfo.h" 169#include "xf86Pci.h" 170 171/* Colormap handling stuff */ 172#include "xf86cmap.h" 173 174/* Frame buffer stuff */ 175#include "fb.h" 176 177#include "shadowfb.h" 178 179/* Machine independent stuff */ 180#include "mipointer.h" 181#include "mibank.h" 182#include "micmap.h" 183#include "vgaHW.h" 184#include "vbe.h" 185 186/* Check for some extensions */ 187#ifdef XFreeXDGA 188#define _XF86_DGA_SERVER_ 189#include <X11/extensions/xf86dgastr.h> 190#endif /* XFreeXDGA */ 191 192#include "globals.h" 193#include "opaque.h" 194#define DPMS_SERVER 195#include <X11/extensions/dpms.h> 196 197/* Our private include file (this also includes the durango headers) */ 198#include "nsc.h" 199 200#if GEODE_TRACE 201/* ANSI C does not allow var arg macros */ 202#define GeodeDebug(args) DebugPort(DCount++);ErrorF args 203#else 204#define GeodeDebug(args) 205#endif 206 207extern SymTabRec GeodeChipsets[]; 208extern OptionInfoRec GeodeOptions[]; 209 210typedef struct _MemOffset 211{ 212 unsigned long xres; 213 unsigned long yres; 214 unsigned long bpp; 215 unsigned long CBOffset; 216 unsigned short CBPitch; 217 unsigned short CBSize; 218 unsigned long CurOffset; 219 unsigned long OffScreenOffset; 220} 221MemOffset; 222 223/* predefined memory address for compression and cursor offsets 224 * if COMPRESSION enabled. 225 */ 226MemOffset GeodeMemOffset[] = { 227 {640, 480, 8, 640, 1024, 272, 0x78000, 0x78100}, 228 {640, 480, 16, 1280, 2048, 272, 0x610, 0xF0000}, 229 {800, 600, 8, 800, 1024, 208, 0x96000, 0x96100}, 230 {800, 600, 16, 1600, 2048, 272, 0x12C000, 0x12C100}, 231 {1024, 768, 8, 0xC0000, 272, 272, 0xF3000, 0xF3100}, 232 {1024, 768, 16, 0x180000, 272, 272, 0x1B3000, 0x1B3100}, 233 {1152, 864, 8, 1152, 2048, 272, 0x590, 0x1B0000}, 234 {1152, 864, 16, 2304, 4096, 272, 0xA10, 0x360000}, 235 {1280, 1024, 8, 1280, 2048, 272, 0x610, 0x200000}, 236 {1280, 1024, 16, 2560, 4096, 272, 0xB10, 0x400000}, 237 238 /* PAL TV modes */ 239 240 {704, 576, 16, 1408, 2048, 272, 0x690, 0x120000}, 241 {720, 576, 16, 1440, 2048, 272, 0x6B0, 0x120000}, 242 {768, 576, 16, 1536, 2048, 256, 0x700, 0x120000}, 243 244 /* NTSC TV modes */ 245 246 {704, 480, 16, 1408, 2048, 272, 0x690, 0xF0000}, 247 {720, 480, 16, 1440, 2048, 272, 0x6B0, 0xF0000} 248 249}; 250static int MemIndex = 0; 251 252static Bool GX1PreInit(ScrnInfoPtr, int); 253static Bool GX1ScreenInit(int, ScreenPtr, int, char **); 254static Bool GX1EnterVT(int, int); 255static void GX1LeaveVT(int, int); 256static void GX1FreeScreen(int, int); 257void GX1AdjustFrame(int, int, int, int); 258Bool GX1SwitchMode(int, DisplayModePtr, int); 259static ModeStatus GX1ValidMode(int, DisplayModePtr, Bool, int); 260static void GX1LoadPalette(ScrnInfoPtr pScreenInfo, 261 int numColors, int *indizes, 262 LOCO * colors, VisualPtr pVisual); 263static Bool GX1MapMem(ScrnInfoPtr); 264static Bool GX1UnmapMem(ScrnInfoPtr); 265 266extern Bool GX1AccelInit(ScreenPtr pScreen); 267extern Bool GX1HWCursorInit(ScreenPtr pScreen); 268extern void GX1HideCursor(ScrnInfoPtr pScreenInfo); 269extern void GX1ShowCursor(ScrnInfoPtr pScreenInfo); 270extern void GX1PointerMoved(int index, int x, int y); 271extern void GX1RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 272extern void GX1RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 273extern void GX1RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 274extern void GX1InitVideo(ScreenPtr pScreen); 275extern Bool GX1DGAInit(ScreenPtr pScreen); 276extern void GX1LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src); 277extern unsigned int GetVideoMemSize(void); 278 279void get_tv_overscan_geom(const char *options, int *X, int *Y, int *W, 280 int *H); 281void GX1SetupChipsetFPtr(ScrnInfoPtr pScrn); 282GeodePtr GX1GetRec(ScrnInfoPtr pScreenInfo); 283void gx1_clear_screen(int width, int height); 284 285#if !defined(STB_X) 286extern unsigned char *XpressROMPtr; 287#endif /* STB_X */ 288 289/* List of symbols from other modules that this module references.The purpose 290* is that to avoid unresolved symbol warnings 291*/ 292extern const char *nscVgahwSymbols[]; 293extern const char *nscVbeSymbols[]; 294extern const char *nscInt10Symbols[]; 295 296extern const char *nscFbSymbols[]; 297extern const char *nscXaaSymbols[]; 298extern const char *nscRamdacSymbols[]; 299extern const char *nscShadowSymbols[]; 300 301void 302GX1SetupChipsetFPtr(ScrnInfoPtr pScrn) 303{ 304 GeodeDebug(("GX1SetupChipsetFPtr!\n")); 305 306 pScrn->PreInit = GX1PreInit; 307 pScrn->ScreenInit = GX1ScreenInit; 308 pScrn->SwitchMode = GX1SwitchMode; 309 pScrn->AdjustFrame = GX1AdjustFrame; 310 pScrn->EnterVT = GX1EnterVT; 311 pScrn->LeaveVT = GX1LeaveVT; 312 pScrn->FreeScreen = GX1FreeScreen; 313 pScrn->ValidMode = GX1ValidMode; 314} 315 316/*---------------------------------------------------------------------------- 317 * GX1GetRec. 318 * 319 * Description :This function allocate an GeodeRec and hooked into 320 * pScreenInfo str driverPrivate member of ScreeenInfo 321 * structure. 322 * Parameters. 323 * pScreenInfo :Pointer handle to the screenonfo structure. 324 * 325 * Returns :allocated pScreeninfo structure. 326 * 327 * Comments :none 328 * 329*---------------------------------------------------------------------------- 330*/ 331GeodePtr 332GX1GetRec(ScrnInfoPtr pScreenInfo) 333{ 334 if (!pScreenInfo->driverPrivate) 335 pScreenInfo->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1); 336 return GEODEPTR(pScreenInfo); 337} 338 339/*---------------------------------------------------------------------------- 340 * GX1FreeRec. 341 * 342 * Description :This function deallocate an GeodeRec and freed from 343 * pScreenInfo str driverPrivate member of ScreeenInfo 344 * structure. 345 * Parameters. 346 * pScreenInfo :Pointer handle to the screenonfo structure. 347 * 348 * Returns :none 349 * 350 * Comments :none 351 * 352*---------------------------------------------------------------------------- 353*/ 354static void 355GX1FreeRec(ScrnInfoPtr pScreenInfo) 356{ 357 if (pScreenInfo->driverPrivate == NULL) { 358 return; 359 } 360 xfree(pScreenInfo->driverPrivate); 361 pScreenInfo->driverPrivate = NULL; 362} 363 364/*---------------------------------------------------------------------------- 365 * GX1SaveScreen. 366 * 367 * Description :This is todo the screen blanking 368 * 369 * Parameters. 370 * pScreen :Handle to ScreenPtr structure. 371 * mode :mode is used by vgaHWSaveScren to check blnak os on. 372 * 373 * Returns :TRUE on success and FALSE on failure. 374 * 375 * Comments :none 376*---------------------------------------------------------------------------- 377*/ 378static Bool 379GX1SaveScreen(ScreenPtr pScreen, int mode) 380{ 381#if !defined(STB_X) 382 ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; 383 384 GeodeDebug(("GX2SaveScreen!\n")); 385 386 if (!pScreenInfo->vtSema) 387 return vgaHWSaveScreen(pScreen, mode); 388 389#endif /* STB_X */ 390 return TRUE; 391} 392 393/*---------------------------------------------------------------------------- 394 * get_tv_overscan_geom. 395 * 396 * Description :This is todo the screen blanking 397 * 398 * Parameters: 399 * options : Pointer to the display options. 400 * X: Pointer to the offset of the screen X-co-ordinate. 401 * Y: Pointer to the offset of the screen Y-co-ordinate. 402 * W: Pointer to the width of the screen. 403 * H: Pointer to the height of the screen. 404 * Returns : none. 405 * 406 * Comments :none 407 *------------------------------------------------------------------------ 408 */ 409void 410get_tv_overscan_geom(const char *options, int *X, int *Y, int *W, int *H) 411{ 412 char *tv_opt; 413 414 tv_opt = strtok((char *)options, ":"); 415 *X = strtoul(tv_opt, NULL, 0); 416 tv_opt = strtok(NULL, ":"); 417 *Y = strtoul(tv_opt, NULL, 0); 418 tv_opt = strtok(NULL, ":"); 419 *W = strtoul(tv_opt, NULL, 0); 420 tv_opt = strtok(NULL, ":"); 421 *H = strtoul(tv_opt, NULL, 0); 422} 423 424static void 425GX1ProbeDDC(ScrnInfoPtr pScrn, int index) 426{ 427 vbeInfoPtr pVbe; 428 429 if (xf86LoadSubModule(pScrn, "vbe")) { 430 pVbe = VBEInit(NULL, index); 431 ConfiguredMonitor = vbeDoEDID(pVbe, NULL); 432 vbeFree(pVbe); 433 } 434} 435 436/*---------------------------------------------------------------------------- 437 * GX1PreInit. 438 * 439 * Description :This function is called only once ate teh server startup 440 * 441 * Parameters. 442 * pScreenInfo :Handle to ScreenPtr structure. 443 * flags :flags may be used to check the probeed one with config. 444 * 445 * Returns :TRUE on success and FALSE on failure. 446 * 447 * Comments :none. 448 *---------------------------------------------------------------------------- 449 */ 450static Bool 451GX1PreInit(ScrnInfoPtr pScreenInfo, int flags) 452{ 453 static ClockRange GeodeClockRange = 454 { NULL, 25175, 135000, 0, FALSE, TRUE, 1, 1, 0 }; 455 MessageType from; 456 int i = 0; 457 GeodePtr pGeode; 458 459#if defined(STB_X) 460 GAL_ADAPTERINFO sAdapterInfo; 461#endif /* STB_X */ 462 unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0; 463 unsigned int minHeight = 0, maxHeight = 0; 464 const char *s; 465 char **modes; 466 char **tvmodes_defa; 467 468 GeodeDebug(("GX1PreInit!\n")); 469 /* Allocate driver private structure */ 470 if (!(pGeode = GX1GetRec(pScreenInfo))) 471 return FALSE; 472 473 /* This is the general case */ 474 for (i = 0; i < pScreenInfo->numEntities; i++) { 475 pGeode->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[i]); 476 if (pGeode->pEnt->resources) 477 return FALSE; 478 pGeode->Chipset = pGeode->pEnt->chipset; 479 pScreenInfo->chipset = (char *)xf86TokenToString(GeodeChipsets, 480 pGeode->pEnt->chipset); 481 } 482 483 if (flags & PROBE_DETECT) { 484 GX1ProbeDDC(pScreenInfo, pGeode->pEnt->index); 485 return TRUE; 486 } 487 488 pGeode->FBVGAActive = 0; /* KFB will Knock of VGA */ 489 490#if !defined(STB_X) 491 /* If the vgahw module would be needed it would be loaded here */ 492 if (!xf86LoadSubModule(pScreenInfo, "vgahw")) { 493 return FALSE; 494 } 495 496 xf86LoaderReqSymLists(nscVgahwSymbols, NULL); 497#endif /* STB_X */ 498 GeodeDebug(("GX1PreInit(1)!\n")); 499 500 /* Do the durango hardware detection */ 501#if defined(STB_X) 502 if (!Gal_initialize_interface()) 503 return FALSE; 504 if (Gal_get_adapter_info(&sAdapterInfo)) { 505 pGeode->cpu_version = sAdapterInfo.dwCPUVersion; 506 pGeode->vid_version = sAdapterInfo.dwVideoVersion; 507 pGeode->FBSize = sAdapterInfo.dwFrameBufferSize; 508 /* update the max clock from the one system suports */ 509 GeodeClockRange.maxClock = sAdapterInfo.dwMaxSupportedPixelClock; 510 pGeode->FBLinearAddr = sAdapterInfo.dwFrameBufferBase; 511 512 if (!GX1MapMem(pScreenInfo)) 513 return FALSE; 514 515 } else { 516 return FALSE; 517 } 518#else 519 pGeode->cpu_version = gfx_detect_cpu(); 520 pGeode->vid_version = gfx_detect_video(); 521 pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); 522 /* update the max clock from the one system suports */ 523 GeodeClockRange.maxClock = gfx_get_max_supported_pixel_clock(); 524 525 if (!GX1MapMem(pScreenInfo)) 526 return FALSE; 527 528 DEBUGMSG(1, 529 (0, X_INFO, 530 "Geode chip info: cpu:%x vid:%x size:%x base:%x, rom:%X\n", 531 pGeode->cpu_version, pGeode->vid_version, pGeode->FBSize, 532 pGeode->FBBase, XpressROMPtr)); 533#endif /* STB_X */ 534 535 /* Fill in the monitor field */ 536 pScreenInfo->monitor = pScreenInfo->confScreen->monitor; 537 GeodeDebug(("GX1PreInit(2)!\n")); 538 /* Determine depth, bpp, etc. */ 539 if (!xf86SetDepthBpp(pScreenInfo, 16, 0, 0, 0)) { 540 return FALSE; 541 542 } else { 543 544 switch (pScreenInfo->depth) { 545 case 8: 546 case 16: 547 break; 548 default: 549 /* Depth not supported */ 550 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 551 "Given depth (%d bpp) is not supported by this driver\n", 552 pScreenInfo->depth)); 553 return FALSE; 554 } 555 } 556 557 /*This must happen after pScreenInfo->display has been set 558 * * because xf86SetWeight references it. 559 */ 560 if (pScreenInfo->depth > 8) { 561 /* The defaults are OK for us */ 562 rgb zeros = { 0, 0, 0 }; 563 564 if (!xf86SetWeight(pScreenInfo, zeros, zeros)) { 565 return FALSE; 566 } else { 567 /* XXX Check if the returned weight is supported */ 568 } 569 } 570 xf86PrintDepthBpp(pScreenInfo); 571 GeodeDebug(("GX1PreInit(3)!\n")); 572 if (!xf86SetDefaultVisual(pScreenInfo, -1)) 573 return FALSE; 574 GeodeDebug(("GX1PreInit(4)!\n")); 575 576 /* The new cmap layer needs this to be initialized */ 577 if (pScreenInfo->depth > 1) { 578 Gamma zeros = { 0.0, 0.0, 0.0 }; 579 580 if (!xf86SetGamma(pScreenInfo, zeros)) { 581 return FALSE; 582 } 583 } 584 GeodeDebug(("GX1PreInit(5)!\n")); 585 /* We use a programmable clock */ 586 pScreenInfo->progClock = TRUE; 587 588 /*Collect all of the relevant option flags 589 * *(fill in pScreenInfo->options) 590 */ 591 xf86CollectOptions(pScreenInfo, NULL); 592 593 /*Process the options */ 594 xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, 595 GeodeOptions); 596 597 /*Set the bits per RGB for 8bpp mode */ 598 if (pScreenInfo->depth == 8) { 599 /* Default to 8 */ 600 pScreenInfo->rgbBits = 8; 601 } 602 from = X_DEFAULT; 603 pGeode->HWCursor = TRUE; 604 /* 605 * *The preferred method is to use the "hw cursor" option as a tri-state 606 * *option, with the default set above. 607 */ 608 if (xf86GetOptValBool(GeodeOptions, OPTION_HW_CURSOR, &pGeode->HWCursor)) { 609 from = X_CONFIG; 610 } 611 /* For compatibility, accept this too (as an override) */ 612 if (xf86ReturnOptValBool(GeodeOptions, OPTION_SW_CURSOR, FALSE)) { 613 from = X_CONFIG; 614 pGeode->HWCursor = FALSE; 615 } 616 DEBUGMSG(1, (pScreenInfo->scrnIndex, from, "Using %s cursor\n", 617 pGeode->HWCursor ? "HW" : "SW")); 618 619 pGeode->Compression = TRUE; 620 if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOCOMPRESSION, FALSE)) { 621 pGeode->Compression = FALSE; 622 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "NoCompression\n")); 623 } 624 625 pGeode->NoAccel = FALSE; 626 if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOACCEL, FALSE)) { 627 pGeode->NoAccel = TRUE; 628 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Acceleration \ 629 disabled\n")); 630 } 631 632 if (!xf86GetOptValInteger(GeodeOptions, OPTION_OSM_IMG_BUFS, 633 &(pGeode->NoOfImgBuffers))) 634 pGeode->NoOfImgBuffers = DEFAULT_NUM_OF_BUF; /* default # of buffers */ 635 if (pGeode->NoOfImgBuffers <= 0) 636 pGeode->NoOfImgBuffers = 0; 637 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "No of Buffers %d\n", 638 pGeode->NoOfImgBuffers)); 639 640 pGeode->TVSupport = FALSE; 641 642 pGeode->FBTVActive = 0; 643 GFX(get_tv_enable(&(pGeode->FBTVActive))); 644 DEBUGMSG(1, (1, X_PROBED, "FB TV %d \n", pGeode->FBTVActive)); 645 646 if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_SUPPORT))) { 647 648 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "TV = %s\n", s)); 649 if (!xf86NameCmp(s, "PAL-768x576")) { 650 pGeode->TvParam.wStandard = TV_STANDARD_PAL; 651 pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; 652 pGeode->TvParam.wWidth = 768; 653 pGeode->TvParam.wHeight = 576; 654 pGeode->TVSupport = TRUE; 655 } else if (!xf86NameCmp(s, "PAL-720x576")) { 656 pGeode->TvParam.wStandard = TV_STANDARD_PAL; 657 pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; 658 pGeode->TvParam.wWidth = 720; 659 pGeode->TvParam.wHeight = 576; 660 pGeode->TVSupport = TRUE; 661 } else if (!xf86NameCmp(s, "NTSC-640x480")) { 662 pGeode->TvParam.wStandard = TV_STANDARD_NTSC; 663 pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; 664 pGeode->TvParam.wWidth = 640; 665 pGeode->TvParam.wHeight = 480; 666 pGeode->TVSupport = TRUE; 667 } else if (!xf86NameCmp(s, "NTSC-720x480")) { 668 pGeode->TvParam.wStandard = TV_STANDARD_NTSC; 669 pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; 670 pGeode->TvParam.wWidth = 720; 671 pGeode->TvParam.wHeight = 480; 672 pGeode->TVSupport = TRUE; 673 } 674 675 if (pGeode->TVSupport == TRUE) { 676 pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; /* default */ 677 678 /* Now find the output */ 679 if (pGeode->TVSupport) { 680 if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OUTPUT))) { 681 if (!xf86NameCmp(s, "COMPOSITE")) { 682 pGeode->TvParam.wOutput = TV_OUTPUT_COMPOSITE; 683 } else if (!xf86NameCmp(s, "SVIDEO")) { 684 pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; 685 } else if (!xf86NameCmp(s, "YUV")) { 686 pGeode->TvParam.wOutput = TV_OUTPUT_YUV; 687 } else if (!xf86NameCmp(s, "SCART")) { 688 pGeode->TvParam.wOutput = TV_OUTPUT_SCART; 689 } 690 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 691 "TVOutput = %s %d\n", s, 692 pGeode->TvParam.wOutput)); 693 } 694 } 695 } 696/* Only SC1200 can support TV modes */ 697 if ((pGeode->vid_version != GFX_VID_SC1200) 698 && (pGeode->TVSupport == TRUE)) { 699 pGeode->TVSupport = FALSE; 700 } 701 702 /*TV can be turned on only in 16BPP mode */ 703 if ((pScreenInfo->depth == 8) && (pGeode->TVSupport == TRUE)) { 704 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 705 "Warning TV Disabled, TV Can't be supported in 8Bpp !!!\n")); 706 pGeode->TVSupport = FALSE; 707 } 708 } 709 710 /* If TV Supported then check for TVO support */ 711 if (pGeode->TVSupport == TRUE) { 712 pGeode->TVOx = 0; 713 pGeode->TVOy = 0; 714 pGeode->TVOw = 0; 715 pGeode->TVOh = 0; 716 pGeode->TV_Overscan_On = FALSE; 717 if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OVERSCAN))) { 718 get_tv_overscan_geom(s, &(pGeode->TVOx), 719 &(pGeode->TVOy), &(pGeode->TVOw), 720 &(pGeode->TVOh)); 721 722 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 723 "TVO %d %d %d %d\n", pGeode->TVOx, pGeode->TVOy, 724 pGeode->TVOw, pGeode->TVOh)); 725 726 if ((pGeode->TVOx >= 0 && pGeode->TVOy >= 0) && 727 (pGeode->TVOh > 0 && pGeode->TVOw > 0)) { 728 if (((pGeode->TVOx + pGeode->TVOw) <= pGeode->TvParam.wWidth) && 729 ((pGeode->TVOy + pGeode->TVOh) <= pGeode->TvParam.wHeight)) { 730 pGeode->TV_Overscan_On = TRUE; 731 } 732 } 733 } 734 } 735 736 /* If TV is not selected and currently TV is enabled, disable the TV out */ 737 if (pGeode->TVSupport == FALSE) { 738 unsigned int status = 0; 739 740 GFX(get_tv_enable(&status)); 741 if (status) 742 GFX(set_tv_enable(0)); 743 } 744 745 pGeode->Panel = FALSE; 746 if (xf86ReturnOptValBool(GeodeOptions, OPTION_FLATPANEL, FALSE)) { 747 DEBUGMSG(0, (pScreenInfo->scrnIndex, X_CONFIG, "FlatPanel Selected\n")); 748 pGeode->Panel = TRUE; 749 } 750 751 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 752 "Quering FP Bios %d\n", pGeode->Panel)); 753 754 /* if FP not supported in BIOS, then turn off user option */ 755 if (pGeode->Panel) { 756 int ret; 757 758 /* check if bios supports FP */ 759#if defined(STB_X) 760 Gal_get_softvga_state(&ret); 761 if (!ret) { 762 /* its time to wakeup softvga */ 763 Gal_set_softvga_state(TRUE); 764 Gal_vga_mode_switch(0); 765 } 766 Gal_pnl_enabled_in_bios(&pGeode->Panel); 767 768 if (pGeode->Panel) { 769 Gal_pnl_info_from_bios(&pGeode->FPBX, &pGeode->FPBY, 770 &pGeode->FPBB, &pGeode->FPBF); 771 } 772 if (!ret) { 773 /* its time to put softvga back to sleep */ 774 Gal_set_softvga_state(FALSE); 775 Gal_vga_mode_switch(1); 776 } 777#else 778 ret = gfx_get_softvga_active(); 779 if (!ret) { 780 /* its time to wakeup softvga */ 781 gfx_enable_softvga(); 782 gfx_vga_mode_switch(0); 783 } 784 pGeode->Panel = Pnl_IsPanelEnabledInBIOS(); 785 if (pGeode->Panel) { 786 Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, 787 &pGeode->FPBB, &pGeode->FPBF); 788 } 789 if (!ret) { 790 /* its time to put softvga back to sleep */ 791 gfx_disable_softvga(); 792 gfx_vga_mode_switch(1); 793 } 794#endif 795 } 796 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 797 "Quering FP Bios %d %d %d %d\n", 798 pGeode->FPBX, pGeode->FPBY, pGeode->FPBB, pGeode->FPBF)); 799 800 /* if panel not selected and Panel can be supported. 801 * Power down the panel. 802 */ 803 if (!pGeode->Panel) { 804#if defined(STB_X) 805 Gal_pnl_powerdown(); 806#else 807 Pnl_PowerDown(); 808#endif /* STB_X */ 809 } else { 810#if defined(STB_X) 811 Gal_pnl_powerup(); 812#else 813 Pnl_PowerUp(); 814#endif /* STB_X */ 815 } 816 817 pGeode->ShadowFB = FALSE; 818 if (xf86ReturnOptValBool(GeodeOptions, OPTION_SHADOW_FB, FALSE)) { 819 pGeode->ShadowFB = TRUE; 820 pGeode->NoAccel = TRUE; 821 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 822 "Using \"Shadow Framebuffer\" - acceleration disabled\n")); 823 } 824 825 pGeode->Rotate = 0; 826 if ((s = xf86GetOptValString(GeodeOptions, OPTION_ROTATE))) { 827 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Rotating - %s\n", s)); 828 if (!xf86NameCmp(s, "CW")) { 829 pGeode->ShadowFB = TRUE; 830 pGeode->NoAccel = TRUE; 831 pGeode->HWCursor = FALSE; 832 pGeode->Rotate = 1; 833 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 834 "Rotating screen clockwise - acceleration disabled\n")); 835 } else { 836 if (!xf86NameCmp(s, "CCW")) { 837 pGeode->ShadowFB = TRUE; 838 pGeode->NoAccel = TRUE; 839 pGeode->HWCursor = FALSE; 840 pGeode->Rotate = -1; 841 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 842 "Rotating screen counter clockwise - acceleration \ 843 disabled\n")); 844 } else { 845 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 846 "\"%s\" is not a valid value for Option \"Rotate\"\n", 847 s)); 848 DEBUGMSG(1, 849 (pScreenInfo->scrnIndex, X_INFO, 850 "Valid options are \"CW\" or \"CCW\"\n")); 851 } 852 } 853 } 854 855 /* Disable Rotation when TV Over Scan is enabled */ 856 if (pGeode->TV_Overscan_On) 857 pGeode->Rotate = 0; 858 859 /* XXX Init further private data here */ 860 861 /* 862 * * This shouldn't happen because such problems should be caught in 863 * * GeodeProbe(), but check it just in case. 864 */ 865 if (pScreenInfo->chipset == NULL) { 866 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 867 "ChipID 0x%04X is not recognised\n", pGeode->Chipset)); 868 return FALSE; 869 } 870 if (pGeode->Chipset < 0) { 871 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 872 "Chipset \"%s\" is not recognised\n", 873 pScreenInfo->chipset)); 874 return FALSE; 875 } 876 GeodeDebug(("GX1PreInit(6)!\n")); 877 878 /* 879 * * Init the screen with some values 880 */ 881#if !defined(STB_X) 882 883 DEBUGMSG(1, (pScreenInfo->scrnIndex, from, 884 "Video I/O registers at 0x%08lX\n", 885 (unsigned long)VGAHW_GET_IOBASE())); 886#endif /* STB_X */ 887 888 if (pScreenInfo->memPhysBase == 0) { 889 from = X_PROBED; 890#if defined(STB_X) 891 pScreenInfo->memPhysBase = sAdapterInfo.dwFrameBufferBase; 892#else /* STB_X */ 893 pScreenInfo->memPhysBase = gfx_get_frame_buffer_base(); 894#endif /* STB_X */ 895 } 896 DEBUGMSG(1, (pScreenInfo->scrnIndex, from, 897 "Linear framebuffer at 0x%08lX\n", 898 (unsigned long)pScreenInfo->memPhysBase)); 899 900 if (pGeode->pEnt->device->videoRam == 0) { 901 from = X_PROBED; 902 pScreenInfo->videoRam = pGeode->FBSize / 1024; 903 } else { 904 pScreenInfo->videoRam = pGeode->pEnt->device->videoRam; 905 from = X_CONFIG; 906 } 907 DEBUGMSG(1, (pScreenInfo->scrnIndex, from, 908 "VideoRam: %d kByte\n", 909 (unsigned long)pScreenInfo->videoRam)); 910 911 GeodeDebug(("GX1PreInit(7)!\n")); 912 913 /* 914 * * xf86ValidateModes will check that the mode HTotal and VTotal values 915 * * don't exceed the chipset's limit if pScreenInfo->maxHValue adn 916 * * pScreenInfo->maxVValue are set. Since our GX1ValidMode() 917 * * already takes care of this, we don't worry about setting them here. 918 */ 919 /* Select valid modes from those available */ 920 /* 921 * * min pitch 1024, max 2048 (Pixel count) 922 * * min height 480, max 1024 (Pixel count) 923 */ 924 minPitch = 1024; 925 maxPitch = 2048; 926 minHeight = 480; 927 maxHeight = 1024; /* Can support upto 1280x1024 16Bpp */ 928 if (pScreenInfo->depth == 16) { 929 PitchInc = 2048; 930 } else { 931 PitchInc = 1024; 932 } 933 PitchInc <<= 3; /* in bits */ 934 935 /* by default use what user sets in the XF86Config file */ 936 modes = pScreenInfo->display->modes; 937 if (pGeode->TVSupport == TRUE) { 938 char str[20]; 939 940 sprintf(str, "%dx%d-%d", 941 pGeode->TvParam.wWidth, 942 pGeode->TvParam.wHeight, 943 ((pGeode->TvParam.wStandard == TV_STANDARD_PAL) ? 50 : 60)); 944 945 tvmodes_defa = (char **)malloc(sizeof(char *) * 2); 946 tvmodes_defa[0] = (char *)malloc(strlen(str)); 947 tvmodes_defa[1] = NULL; 948 strcpy(str, tvmodes_defa[0]); 949 950 modes = tvmodes_defa; 951 } 952 953 i = xf86ValidateModes(pScreenInfo, 954 pScreenInfo->monitor->Modes, 955 modes, 956 &GeodeClockRange, 957 NULL, minPitch, maxPitch, 958 PitchInc, minHeight, maxHeight, 959 pScreenInfo->display->virtualX, 960 pScreenInfo->display->virtualY, 961#if defined(STB_X) 962 sAdapterInfo.dwFrameBufferSize, 963#else 964 pGeode->FBSize, 965#endif /* STB_X */ 966 LOOKUP_BEST_REFRESH); 967 968 DEBUGMSG(0, (pScreenInfo->scrnIndex, from, 969 "xf86ValidateModes: %d %d %d\n", 970 pScreenInfo->virtualX, 971 pScreenInfo->virtualY, pScreenInfo->displayWidth)); 972 if (i == -1) { 973 GX1FreeRec(pScreenInfo); 974 return FALSE; 975 } 976 GeodeDebug(("GX1PreInit(8)!\n")); 977 /* Prune the modes marked as invalid */ 978 xf86PruneDriverModes(pScreenInfo); 979 GeodeDebug(("GX1PreInit(9)!\n")); 980 if (i == 0 || pScreenInfo->modes == NULL) { 981 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 982 "No valid modes found\n")); 983 GX1FreeRec(pScreenInfo); 984 return FALSE; 985 } 986 GeodeDebug(("GX1PreInit(10)!\n")); 987 xf86SetCrtcForModes(pScreenInfo, 0); 988 GeodeDebug(("GX1PreInit(11)!\n")); 989 /* Set the current mode to the first in the list */ 990 pScreenInfo->currentMode = pScreenInfo->modes; 991 GeodeDebug(("GX1PreInit(12)!\n")); 992 /* Print the list of modes being used */ 993 xf86PrintModes(pScreenInfo); 994 GeodeDebug(("GX1PreInit(13)!\n")); 995 /* Set the display resolution */ 996 xf86SetDpi(pScreenInfo, 0, 0); 997 GeodeDebug(("GX1PreInit(14)!\n")); 998 999 if (xf86LoadSubModule(pScreenInfo, "fb") == NULL) { 1000 GX1FreeRec(pScreenInfo); 1001 return FALSE; 1002 } 1003 1004 xf86LoaderReqSymLists(nscFbSymbols, NULL); 1005 GeodeDebug(("GX1PreInit(15)!\n")); 1006 if (pGeode->NoAccel == FALSE) { 1007 if (!xf86LoadSubModule(pScreenInfo, "xaa")) { 1008 GX1FreeRec(pScreenInfo); 1009 return FALSE; 1010 } 1011 xf86LoaderReqSymLists(nscXaaSymbols, NULL); 1012 } 1013 GeodeDebug(("GX1PreInit(16)!\n")); 1014 if (pGeode->HWCursor == TRUE) { 1015 if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { 1016 GX1FreeRec(pScreenInfo); 1017 return FALSE; 1018 } 1019 xf86LoaderReqSymLists(nscRamdacSymbols, NULL); 1020 } 1021 GeodeDebug(("GX1PreInit(17)!\n")); 1022 /* Load shadowfb if needed */ 1023 if (pGeode->ShadowFB) { 1024 if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { 1025 GX1FreeRec(pScreenInfo); 1026 return FALSE; 1027 } 1028 xf86LoaderReqSymLists(nscShadowSymbols, NULL); 1029 } 1030 GeodeDebug(("GX2PreInit(18)!\n")); 1031 if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) { 1032 DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 1033 "xf86RegisterResources() found resource conflicts\n")); 1034 GX1FreeRec(pScreenInfo); 1035 return FALSE; 1036 } 1037 GX1UnmapMem(pScreenInfo); 1038 GeodeDebug(("GX1PreInit(19)!\n")); 1039 GeodeDebug(("GX1PreInit(20)!\n")); 1040 GeodeDebug(("GX1PreInit ... done successfully!\n")); 1041 (void) from; 1042 return TRUE; 1043} 1044 1045/*---------------------------------------------------------------------------- 1046 * GX1RestoreEx. 1047 * 1048 * Description :This function restores the mode that was saved on server 1049 entry 1050 * Parameters. 1051 * pScreenInfo :Handle to ScreenPtr structure. 1052 * Pmode :poits to screen mode 1053 * 1054 * Returns :none. 1055 * 1056 * Comments :none. 1057*---------------------------------------------------------------------------- 1058*/ 1059static void 1060GX1RestoreEx(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) 1061{ 1062 GeodePtr pGeode; 1063 1064 GeodeDebug(("GX1RestoreEx!\n")); 1065 /* Get driver private structure */ 1066 if (!(pGeode = GX1GetRec(pScreenInfo))) 1067 return; 1068 /* Restore the extended registers */ 1069#if defined(STB_X) 1070 pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | 1071 GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; 1072 Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); 1073#else 1074 gfx_vga_restore(&(pGeode->FBgfxVgaRegs), 1075 GFX_VGA_FLAG_MISC_OUTPUT | 1076 GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); 1077#endif /* STB_X */ 1078} 1079 1080/*---------------------------------------------------------------------------- 1081 * GX1CalculatePitchBytes. 1082 * 1083 * Description :This function restores the mode that was saved on server 1084 * 1085 * Parameters. 1086 * pScreenInfo :Handle to ScreenPtr structure. 1087 * Pmode :Points to screenmode 1088 * 1089 * Returns :none. 1090 * 1091 * Comments :none. 1092*---------------------------------------------------------------------------- 1093*/ 1094static int 1095GX1CalculatePitchBytes(unsigned int width, unsigned int bpp) 1096{ 1097 int lineDelta = width * (bpp >> 3); 1098 1099 if (width < 640) { 1100 /* low resolutions have both pixel and line doubling */ 1101 DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n", 1102 width, lineDelta)); 1103 lineDelta <<= 1; 1104 } 1105 /* needed in Rotate mode when in accel is turned off */ 1106 if (1) { /*!pGeode->NoAccel */ 1107 if (lineDelta > 2048) 1108 lineDelta = 4096; 1109 else if (lineDelta > 1024) 1110 lineDelta = 2048; 1111 else 1112 lineDelta = 1024; 1113 } 1114 1115 DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta)); 1116 1117 return lineDelta; 1118} 1119 1120/*---------------------------------------------------------------------------- 1121 * GX1GetRefreshRate. 1122 * 1123 * Description :This function restores the mode that saved on server 1124 * 1125 * Parameters. 1126 * Pmode :Pointer to the screen modes 1127 * 1128 * Returns :It returns the selected refresh rate. 1129 * 1130 * Comments :none. 1131*---------------------------------------------------------------------------- 1132*/ 1133static int 1134GX1GetRefreshRate(DisplayModePtr pMode) 1135{ 1136#define THRESHOLD 2 1137 unsigned int i; 1138 static int validRates[] = { 50, 56, 60, 70, 72, 75, 85 }; /* Hz */ 1139 unsigned long dotClock; 1140 int refreshRate; 1141 int selectedRate; 1142 1143 dotClock = pMode->SynthClock * 1000; 1144 refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal; 1145 1146 if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480)) 1147 refreshRate >>= 2; /* double pixel and double scan */ 1148 1149 DEBUGMSG(1, (0, X_PROBED, "dotclock %d %d\n", dotClock, refreshRate)); 1150 1151 selectedRate = validRates[0]; 1152 for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) { 1153 if (validRates[i] < (refreshRate + THRESHOLD)) { 1154 selectedRate = validRates[i]; 1155 } 1156 } 1157 return selectedRate; 1158} 1159 1160void 1161gx1_clear_screen(int width, int height) 1162{ 1163 /* clean up the frame buffer memory */ 1164 GFX(set_solid_pattern(0)); 1165 GFX(set_raster_operation(0xF0)); 1166 GFX(pattern_fill(0, 0, width, height)); 1167} 1168 1169/*---------------------------------------------------------------------------- 1170 * GX1SetMode. 1171 * 1172 * Description :This function sets parametrs for screen mode 1173 * 1174 * Parameters. 1175 * pScreenInfo :Pointer to the screenInfo structure. 1176 * Pmode :Pointer to the screen modes 1177 * 1178 * Returns :TRUE on success and FALSE on Failure. 1179 * 1180 * Comments :none. 1181*---------------------------------------------------------------------------- 1182*/ 1183 1184static Bool 1185GX1SetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) 1186{ 1187 GeodePtr pGeode; 1188 1189 /* unsigned int compOffset, compPitch, compSize; */ 1190 GeodeDebug(("GX1SetMode!\n")); 1191 pGeode = GEODEPTR(pScreenInfo); 1192 /* Set the VT semaphore */ 1193 pScreenInfo->vtSema = TRUE; 1194 DEBUGMSG(1, (0, X_NONE, "Set mode")); 1195 /* The timing will be adjusted later */ 1196 GeodeDebug(("Set display mode: %dx%d-%d (%dHz)\n", 1197 pMode->CrtcHDisplay, 1198 pMode->CrtcVDisplay, 1199 pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); 1200 GeodeDebug(("Before setting the mode\n")); 1201 if ((pMode->CrtcHDisplay >= 640) && (pMode->CrtcVDisplay >= 480)) 1202 1203 GFX(set_display_bpp(pScreenInfo->bitsPerPixel)); 1204 1205 if (pGeode->TVSupport == TRUE) { 1206 pGeode->TvParam.bState = 1; /* enable */ 1207 /* wWidth and wHeight already set in init. */ 1208#if defined(STB_X) 1209 Gal_tv_set_params(GAL_TVSTATE | GAL_TVOUTPUT | 1210 GAL_TVFORMAT | GAL_TVRESOLUTION, &(pGeode->TvParam)); 1211#else 1212 /* sequence might be important */ 1213 gfx_set_tv_display(pGeode->TvParam.wWidth, pGeode->TvParam.wHeight); 1214 gfx_set_tv_format((TVStandardType)pGeode->TvParam.wStandard, 1215 (GfxOnTVType)pGeode->TvParam.wType); 1216 gfx_set_tv_output(pGeode->TvParam.wOutput); 1217 gfx_set_tv_enable(pGeode->TvParam.bState); 1218 1219#endif /* STB_X */ 1220 } else { /* TV not selected */ 1221 1222 DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT or TFT\n")); 1223 1224 if (pGeode->Panel) { 1225 DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n")); 1226 DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n", 1227 pGeode->FPBX, pGeode->FPBY, 1228 pMode->CrtcHDisplay, 1229 pMode->CrtcVDisplay, pScreenInfo->bitsPerPixel)); 1230 1231 GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY, 1232 pMode->CrtcHDisplay, 1233 pMode->CrtcVDisplay, 1234 pScreenInfo->bitsPerPixel)); 1235 } else { 1236 /* display is crt */ 1237 DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT\n")); 1238 GFX(set_display_mode(pMode->CrtcHDisplay, 1239 pMode->CrtcVDisplay, 1240 pScreenInfo->bitsPerPixel, 1241 GX1GetRefreshRate(pMode))); 1242 1243 /* adjust the pitch */ 1244 GFX(set_display_pitch(pGeode->Pitch)); 1245 1246 } 1247 /* enable crt */ 1248 GFX(set_crt_enable(CRT_ENABLE)); 1249 } 1250 1251 GFX(set_display_offset(0L)); 1252 GFX(wait_vertical_blank()); 1253 1254 /* enable compression if option selected */ 1255 if (pGeode->Compression) { 1256 /* set the compression parameters,and it will be turned on later. */ 1257#if defined(STB_X) 1258 Gal_set_compression_parameters(GAL_COMPRESSION_ALL, 1259 pGeode->CBOffset, 1260 pGeode->CBPitch, pGeode->CBSize); 1261 1262 /* set the compression buffer, all parameters already set */ 1263 Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); 1264#else 1265 gfx_set_compression_offset(pGeode->CBOffset); 1266 gfx_set_compression_pitch(pGeode->CBPitch); 1267 gfx_set_compression_size(pGeode->CBSize); 1268 1269 /* set the compression buffer, all parameters already set */ 1270 gfx_set_compression_enable(1); 1271#endif /* STB_X */ 1272 1273 } 1274 if (pGeode->HWCursor) { 1275 /* Load blank cursor */ 1276 GX1LoadCursorImage(pScreenInfo, NULL); 1277 GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0)); 1278 GFX(set_cursor_enable(1)); 1279 } else { 1280 GeodeDebug(("GX1RestoreEx ... ")); 1281 GX1RestoreEx(pScreenInfo, pMode); 1282 GeodeDebug(("done.\n")); 1283 } 1284 1285 GeodeDebug(("done.\n")); 1286 /* Reenable the hardware cursor after the mode switch */ 1287 if (pGeode->HWCursor == TRUE) { 1288 GeodeDebug(("GX1ShowCursor ... ")); 1289 GX1ShowCursor(pScreenInfo); 1290 GeodeDebug(("done.\n")); 1291 } 1292 /* Restore the contents in the screen info */ 1293 GeodeDebug(("After setting the mode\n")); 1294 return TRUE; 1295} 1296 1297/*---------------------------------------------------------------------------- 1298 * GX1EnterGraphics. 1299 * 1300 * Description :This function will intiallize the displaytiming 1301 structure for nextmode and switch to VGA mode. 1302 * 1303 * Parameters. 1304 * pScreen :Screen information will be stored in this structure. 1305 * pScreenInfo :Pointer to the screenInfo structure. 1306 * 1307 * Returns :TRUE on success and FALSE on Failure. 1308 * 1309 * Comments :gfx_vga_mode_switch() will start and end the 1310 * switching based on the arguments 0 or 1.soft_vga 1311 * is disabled in this function. 1312*---------------------------------------------------------------------------- 1313*/ 1314static Bool 1315GX1EnterGraphics(ScreenPtr pScreen, ScrnInfoPtr pScreenInfo) 1316{ 1317 GeodePtr pGeode; 1318 1319#if !defined(STB_X) 1320 1321 vgaHWPtr hwp = VGAHWPTR(pScreenInfo); 1322 1323 vgaHWUnlock(hwp); 1324#endif 1325 1326 GeodeDebug(("GX1EnterGraphics!\n")); 1327 1328 DEBUGMSG(1, (0, X_NONE, "EnterGraphics\n")); 1329 /* Should we re-save the text mode on each VT enter? */ 1330 pGeode = GX1GetRec(pScreenInfo); 1331#if 0 1332 print_gxm_gfx_reg(pGeode, 0x4C); 1333 print_gxm_vga_reg(); 1334#endif 1335 /* This routine saves the current VGA state in Durango VGA structure */ 1336#if defined(STB_X) 1337 Gal_get_softvga_state(&pGeode->FBVGAActive); 1338 pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | 1339 GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; 1340 Gal_vga_save(&(pGeode->FBgfxVgaRegs)); 1341#else 1342 pGeode->FBVGAActive = gfx_get_softvga_active(); 1343 gfx_vga_save(&(pGeode->FBgfxVgaRegs), 1344 GFX_VGA_FLAG_MISC_OUTPUT | 1345 GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); 1346#endif /* STB_X */ 1347 DEBUGMSG(1, (0, X_PROBED, "VSA = %d\n", pGeode->FBVGAActive)); 1348 1349#if !defined(STB_X) 1350 1351 vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); 1352#endif 1353 1354#if defined(STB_X) 1355 Gal_get_display_timing(&pGeode->FBgfxdisplaytiming); 1356 Gal_tv_get_timings(0, &pGeode->FBgfxtvtiming); 1357 1358 /* Save Display offset */ 1359 Gal_get_display_offset(&(pGeode->FBDisplayOffset)); 1360 1361 /* Save the current Compression state */ 1362 Gal_get_compression_enable(&(pGeode->FBCompressionEnable)); 1363 Gal_get_compression_parameters(GAL_COMPRESSION_ALL, 1364 &(pGeode->FBCompressionOffset), 1365 &(pGeode->FBCompressionPitch), 1366 &(pGeode->FBCompressionSize)); 1367 1368 /* Save Cursor offset */ 1369 { 1370 unsigned short x, y, xhot, yhot; 1371 1372 Gal_get_cursor_position(&(pGeode->FBCursorOffset), 1373 &x, &y, &xhot, &yhot); 1374 } 1375 /* Save the Panel state */ 1376 Gal_pnl_save(); 1377 1378 /* its time to put softvga to sleep */ 1379 Gal_set_softvga_state(FALSE); 1380 Gal_vga_mode_switch(1); 1381 1382#else 1383 /* Save TV State */ 1384 gfx_get_tv_enable(&(pGeode->FBTVEnabled)); 1385 if (pGeode->FBTVEnabled) { 1386 /* TV Format */ 1387 pGeode->FBtvtiming.HorzTim = READ_VID32(SC1200_TVOUT_HORZ_TIM); 1388 pGeode->FBtvtiming.HorzSync = READ_VID32(SC1200_TVOUT_HORZ_SYNC); 1389 pGeode->FBtvtiming.VertSync = READ_VID32(SC1200_TVOUT_VERT_SYNC); 1390 pGeode->FBtvtiming.LineEnd = READ_VID32(SC1200_TVOUT_LINE_END); 1391 pGeode->FBtvtiming.VertDownscale = 1392 READ_VID32(SC1200_TVOUT_VERT_DOWNSCALE); 1393 pGeode->FBtvtiming.HorzScaling = READ_VID32(SC1200_TVOUT_HORZ_SCALING); 1394 pGeode->FBtvtiming.TimCtrl1 = READ_VID32(SC1200_TVENC_TIM_CTRL_1); 1395 pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); 1396 pGeode->FBtvtiming.Subfreq = READ_VID32(SC1200_TVENC_SUB_FREQ); 1397 pGeode->FBtvtiming.DispPos = READ_VID32(SC1200_TVENC_DISP_POS); 1398 pGeode->FBtvtiming.DispSize = READ_VID32(SC1200_TVENC_DISP_SIZE); 1399 /* TV Output */ 1400 pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); 1401 pGeode->FBtvtiming.Debug = READ_VID32(SC1200_TVOUT_DEBUG); 1402 /* TV Enable */ 1403 pGeode->FBtvtiming.DacCtrl = READ_VID32(SC1200_TVENC_DAC_CONTROL); 1404 } 1405 1406 /* Save CRT State */ 1407 pGeode->FBgfxdisplaytiming.dwDotClock = gfx_get_clock_frequency(); 1408 pGeode->FBgfxdisplaytiming.wPitch = gfx_get_display_pitch(); 1409 pGeode->FBgfxdisplaytiming.wBpp = gfx_get_display_bpp(); 1410 pGeode->FBgfxdisplaytiming.wHTotal = gfx_get_htotal(); 1411 pGeode->FBgfxdisplaytiming.wHActive = gfx_get_hactive(); 1412 pGeode->FBgfxdisplaytiming.wHSyncStart = gfx_get_hsync_start(); 1413 pGeode->FBgfxdisplaytiming.wHSyncEnd = gfx_get_hsync_end(); 1414 pGeode->FBgfxdisplaytiming.wHBlankStart = gfx_get_hblank_start(); 1415 pGeode->FBgfxdisplaytiming.wHBlankEnd = gfx_get_hblank_end(); 1416 pGeode->FBgfxdisplaytiming.wVTotal = gfx_get_vtotal(); 1417 pGeode->FBgfxdisplaytiming.wVActive = gfx_get_vactive(); 1418 pGeode->FBgfxdisplaytiming.wVSyncStart = gfx_get_vsync_start(); 1419 pGeode->FBgfxdisplaytiming.wVSyncEnd = gfx_get_vsync_end(); 1420 pGeode->FBgfxdisplaytiming.wVBlankStart = gfx_get_vblank_start(); 1421 pGeode->FBgfxdisplaytiming.wVBlankEnd = gfx_get_vblank_end(); 1422 pGeode->FBgfxdisplaytiming.wPolarity = gfx_get_sync_polarities(); 1423 1424 /* Save Display offset */ 1425 pGeode->FBDisplayOffset = gfx_get_display_offset(); 1426 1427 /* Save the current Compression state */ 1428 pGeode->FBCompressionEnable = gfx_get_compression_enable(); 1429 pGeode->FBCompressionOffset = gfx_get_compression_offset(); 1430 pGeode->FBCompressionPitch = gfx_get_compression_pitch(); 1431 pGeode->FBCompressionSize = gfx_get_compression_size(); 1432 1433 /* Save Cursor offset */ 1434 pGeode->FBCursorOffset = gfx_get_cursor_offset(); 1435 1436 /* Save the Panel state */ 1437 Pnl_SavePanelState(); 1438 1439 /* its time to put softvga to sleep */ 1440 gfx_disable_softvga(); 1441 gfx_vga_mode_switch(1); 1442 1443#endif /* STB_X */ 1444 1445 if (!GX1SetMode(pScreenInfo, pScreenInfo->currentMode)) { 1446 return FALSE; 1447 } 1448#if 1 1449 /* clear the frame buffer, for annoying noise during mode switch */ 1450 gx1_clear_screen(pScreenInfo->currentMode->CrtcHDisplay, 1451 pScreenInfo->currentMode->CrtcVDisplay); 1452#endif 1453 return TRUE; 1454} 1455 1456/*---------------------------------------------------------------------------- 1457 * GX1LeaveGraphics: 1458 * 1459 * Description :This function will restore the displaymode parameters 1460 * and switches the VGA mode 1461 * 1462 * Parameters. 1463 * pScreen :Screen information will be stored in this structure. 1464 * pScreenInfo :Pointer to the screenInfo structure. 1465 * 1466 * 1467 * Returns :none. 1468 * 1469 * Comments : gfx_vga_mode_switch() will start and end the switching 1470 * based on the arguments 0 or 1.soft_vga is disabled in 1471 * this function. 1472*---------------------------------------------------------------------------- 1473*/ 1474static void 1475GX1LeaveGraphics(ScrnInfoPtr pScreenInfo) 1476{ 1477 GeodePtr pGeode; 1478 1479 GeodeDebug(("GX1LeaveGraphics!\n")); 1480 pGeode = GEODEPTR(pScreenInfo); 1481 1482 if (!pGeode->FBTVActive) { 1483 GFX(set_tv_enable(0)); 1484 } 1485 /* clear the frame buffer, when leaving X */ 1486 gx1_clear_screen(pScreenInfo->virtualX, pScreenInfo->virtualY); 1487 1488#if defined(STB_X) 1489 Gal_set_display_timing(&pGeode->FBgfxdisplaytiming); 1490 Gal_tv_set_timings(0, &pGeode->FBgfxtvtiming); 1491 Gal_set_display_offset(pGeode->FBDisplayOffset); 1492 1493 /* Restore Cursor */ 1494 Gal_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); 1495 1496 /* Restore the previous Compression state */ 1497 if (pGeode->FBCompressionEnable) { 1498 Gal_set_compression_parameters(GAL_COMPRESSION_ALL, 1499 pGeode->FBCompressionOffset, 1500 pGeode->FBCompressionPitch, 1501 pGeode->FBCompressionSize); 1502 1503 Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); 1504 } 1505#else 1506 /* Restore TV */ 1507 if (pGeode->FBTVEnabled) { 1508 /* TV Format */ 1509 WRITE_VID32(SC1200_TVOUT_HORZ_TIM, pGeode->FBtvtiming.HorzTim); 1510 WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, pGeode->FBtvtiming.HorzSync); 1511 WRITE_VID32(SC1200_TVOUT_VERT_SYNC, pGeode->FBtvtiming.VertSync); 1512 WRITE_VID32(SC1200_TVOUT_LINE_END, pGeode->FBtvtiming.LineEnd); 1513 WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, 1514 pGeode->FBtvtiming.VertDownscale); 1515 WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, pGeode->FBtvtiming.HorzScaling); 1516 WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, pGeode->FBtvtiming.TimCtrl1); 1517 WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); 1518 WRITE_VID32(SC1200_TVENC_SUB_FREQ, pGeode->FBtvtiming.Subfreq); 1519 WRITE_VID32(SC1200_TVENC_DISP_POS, pGeode->FBtvtiming.DispPos); 1520 WRITE_VID32(SC1200_TVENC_DISP_SIZE, pGeode->FBtvtiming.DispSize); 1521 /* TV Output */ 1522 WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); 1523 /* WRITE_VID32(SC1200_TVENC_DAC_CONTROL, tmp); */ 1524 WRITE_VID32(SC1200_TVOUT_DEBUG, pGeode->FBtvtiming.Debug); 1525 /* TV Enable */ 1526 WRITE_VID32(SC1200_TVENC_DAC_CONTROL, pGeode->FBtvtiming.DacCtrl); 1527 } 1528 1529 /* Restore CRT */ 1530 gfx_set_display_timings(pGeode->FBgfxdisplaytiming.wBpp, 1531 pGeode->FBgfxdisplaytiming.wPolarity, 1532 pGeode->FBgfxdisplaytiming.wHActive, 1533 pGeode->FBgfxdisplaytiming.wHBlankStart, 1534 pGeode->FBgfxdisplaytiming.wHSyncStart, 1535 pGeode->FBgfxdisplaytiming.wHSyncEnd, 1536 pGeode->FBgfxdisplaytiming.wHBlankEnd, 1537 pGeode->FBgfxdisplaytiming.wHTotal, 1538 pGeode->FBgfxdisplaytiming.wVActive, 1539 pGeode->FBgfxdisplaytiming.wVBlankStart, 1540 pGeode->FBgfxdisplaytiming.wVSyncStart, 1541 pGeode->FBgfxdisplaytiming.wVSyncEnd, 1542 pGeode->FBgfxdisplaytiming.wVBlankEnd, 1543 pGeode->FBgfxdisplaytiming.wVTotal, 1544 pGeode->FBgfxdisplaytiming.dwDotClock); 1545 1546 gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch); 1547 1548 gfx_set_display_offset(pGeode->FBDisplayOffset); 1549 1550 /* Restore Cursor */ 1551 gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); 1552 1553 /* Restore the previous Compression state */ 1554 if (pGeode->FBCompressionEnable) { 1555 gfx_set_compression_offset(pGeode->FBCompressionOffset); 1556 gfx_set_compression_pitch(pGeode->FBCompressionPitch); 1557 gfx_set_compression_size(pGeode->FBCompressionSize); 1558 gfx_set_compression_enable(1); 1559 } 1560#endif /* STB_X */ 1561 1562 /* We need this to get back to vga mode when soft-vga 1563 * * kicks in. 1564 * * We actually need to examine the attribute Ctlr to find out 1565 * * what kinda crap (grafix or text) we need to enter in 1566 * * For now just lookout for 720x400 1567 */ 1568#if 0 1569 if ((pGeode->FBgfxdisplaytiming.wHActive == 720) && 1570 (pGeode->FBgfxdisplaytiming.wVActive == 400)) 1571#else 1572 if (pGeode->FBVGAActive) 1573#endif 1574 { 1575 /* VSA was active before we started. Since we disabled it 1576 * we got to enable it */ 1577#if defined(STB_X) 1578 Gal_set_softvga_state(TRUE); 1579 Gal_vga_mode_switch(1); 1580 Gal_vga_clear_extended(); 1581#else 1582 gfx_enable_softvga(); 1583 gfx_vga_mode_switch(1); 1584 gfx_vga_clear_extended(); 1585#endif /* STB_X */ 1586 1587#if !defined(STB_X) 1588 1589 vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); 1590#endif 1591 1592#if defined(STB_X) 1593 pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | 1594 GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; 1595 Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); 1596 Gal_vga_mode_switch(0); 1597#else 1598 gfx_vga_restore(&(pGeode->FBgfxVgaRegs), 1599 GFX_VGA_FLAG_MISC_OUTPUT | 1600 GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); 1601 gfx_vga_mode_switch(0); 1602#endif /* STB_X */ 1603 } 1604#if 0 1605 print_gxm_gfx_reg(pGeode, 0x4C); 1606 print_gxm_vga_reg(); 1607#endif 1608} 1609 1610/*---------------------------------------------------------------------------- 1611 * GX1CloseScreen. 1612 * 1613 * Description :This function will restore the original mode 1614 * and also it unmap video memory 1615 * 1616 * Parameters. 1617 * ScrnIndex :Screen index value of the screen will be closed. 1618 * pScreen :Pointer to the screen structure. 1619 * 1620 * 1621 * Returns :TRUE on success and FALSE on Failure. 1622 * 1623 * Comments :none. 1624*---------------------------------------------------------------------------- 1625*/ 1626static Bool 1627GX1CloseScreen(int scrnIndex, ScreenPtr pScreen) 1628{ 1629 ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 1630 GeodePtr pGeode = GEODEPTR(pScreenInfo); 1631 1632 DEBUGMSG(1, (scrnIndex, X_PROBED, "GX1CloseScreen\n")); 1633 GeodeDebug(("GX1CloseScreen!\n")); 1634 GX1LeaveGraphics(pScreenInfo); 1635 if (pGeode->AccelInfoRec) 1636 XAADestroyInfoRec(pGeode->AccelInfoRec); 1637 pScreenInfo->vtSema = FALSE; 1638 if (pGeode->DGAModes) 1639 xfree(pGeode->DGAModes); 1640 pGeode->DGAModes = 0; 1641 if (pGeode->ShadowPtr) 1642 xfree(pGeode->ShadowPtr); 1643 1644 if (pGeode->AccelImageWriteBufferOffsets) { 1645 xfree(pGeode->AccelImageWriteBufferOffsets); 1646 pGeode->AccelImageWriteBufferOffsets = 0x0; 1647 } 1648 /* free the allocated off screen area */ 1649 xf86FreeOffscreenArea(pGeode->AccelImgArea); 1650 xf86FreeOffscreenArea(pGeode->CompressionArea); 1651 1652 GX1UnmapMem(pScreenInfo); 1653 1654 pScreen->CloseScreen = pGeode->CloseScreen; 1655 return (*pScreen->CloseScreen) (scrnIndex, pScreen); 1656 1657} 1658 1659/*---------------------------------------------------------------------------- 1660 * GX1DPMSet. 1661 * 1662 * Description :This function sets geode into Power Management 1663 * Signalling mode. 1664 * 1665 * Parameters. 1666 * pScreenInfo :Pointer to screen info strucrure. 1667 * mode :Specifies the power management mode. 1668 * 1669 * Returns :none. 1670 * 1671 * Comments :none. 1672*---------------------------------------------------------------------------- 1673*/ 1674static void 1675GX1DPMSSet(ScrnInfoPtr pScreenInfo, int mode, int flags) 1676{ 1677 GeodePtr pGeode; 1678 1679 pGeode = GEODEPTR(pScreenInfo); 1680 1681 GeodeDebug(("GX1DPMSSet!\n")); 1682 1683 /* Check if we are actively controlling the display */ 1684 if (!pScreenInfo->vtSema) { 1685 ErrorF("GX1DPMSSet called when we not controlling the VT!\n"); 1686 return; 1687 } 1688 switch (mode) { 1689 case DPMSModeOn: 1690 /* Screen: On; HSync: On; VSync: On */ 1691 GFX(set_crt_enable(CRT_ENABLE)); 1692#if defined(STB_X) 1693 if (pGeode->Panel) 1694 Gal_pnl_powerup(); 1695#else 1696 if (pGeode->Panel) 1697 Pnl_PowerUp(); 1698#endif /* STB_X */ 1699 if (pGeode->TVSupport) 1700 GFX(set_tv_enable(1)); 1701 break; 1702 1703 case DPMSModeStandby: 1704 /* Screen: Off; HSync: Off; VSync: On */ 1705 GFX(set_crt_enable(CRT_STANDBY)); 1706#if defined(STB_X) 1707 if (pGeode->Panel) 1708 Gal_pnl_powerdown(); 1709#else 1710 if (pGeode->Panel) 1711 Pnl_PowerDown(); 1712#endif /* STB_X */ 1713 if (pGeode->TVSupport) 1714 GFX(set_tv_enable(0)); 1715 break; 1716 1717 case DPMSModeSuspend: 1718 /* Screen: Off; HSync: On; VSync: Off */ 1719 GFX(set_crt_enable(CRT_SUSPEND)); 1720#if defined(STB_X) 1721 if (pGeode->Panel) 1722 Gal_pnl_powerdown(); 1723#else 1724 if (pGeode->Panel) 1725 Pnl_PowerDown(); 1726#endif /* STB_X */ 1727 if (pGeode->TVSupport) 1728 GFX(set_tv_enable(0)); 1729 break; 1730 case DPMSModeOff: 1731 /* Screen: Off; HSync: Off; VSync: Off */ 1732 GFX(set_crt_enable(CRT_DISABLE)); 1733#if defined(STB_X) 1734 if (pGeode->Panel) 1735 Gal_pnl_powerdown(); 1736#else 1737 if (pGeode->Panel) 1738 Pnl_PowerDown(); 1739#endif /* STB_X */ 1740 if (pGeode->TVSupport) 1741 GFX(set_tv_enable(0)); 1742 break; 1743 } 1744} 1745 1746/*---------------------------------------------------------------------------- 1747 * GX1ScreenInit. 1748 * 1749 * Description :This function will be called at the each ofserver 1750 * generation. 1751 * 1752 * Parameters. 1753 * scrnIndex :Specfies the screenindex value during generation. 1754 * pScreen :Pointer to screen info strucrure. 1755 * argc :parameters for command line arguments count 1756 * argv :command line arguments if any it is not used. 1757 * 1758 * Returns :none. 1759 * 1760 * Comments :none. 1761*---------------------------------------------------------------------------- 1762*/ 1763static Bool 1764GX1ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) 1765{ 1766 ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; 1767 GeodePtr pGeode; 1768 int i; 1769 Bool Inited = FALSE; 1770 unsigned char *FBStart; 1771 unsigned int req_offscreenmem; 1772 int width, height, displayWidth; 1773 VisualPtr visual; 1774 BoxRec AvailBox; 1775 RegionRec OffscreenRegion; 1776 1777 DCount = 30; 1778 1779 GeodeDebug(("GX1ScreenInit!\n")); 1780 /* Get driver private */ 1781 pGeode = GX1GetRec(pScreenInfo); 1782 GeodeDebug(("GX1ScreenInit(0)!\n")); 1783 1784#if !defined(STB_X) 1785 /* 1786 * * Allocate a vgaHWRec 1787 */ 1788 if (!vgaHWGetHWRec(pScreenInfo)) 1789 return FALSE; 1790 VGAHWPTR(pScreenInfo)->MapSize = 0x10000; /* Standard 64k VGA window */ 1791 if (!vgaHWMapMem(pScreenInfo)) 1792 return FALSE; 1793#endif 1794 1795 if (!GX1MapMem(pScreenInfo)) 1796 return FALSE; 1797 1798#if !defined(STB_X) 1799 vgaHWGetIOBase(VGAHWPTR(pScreenInfo)); 1800#endif 1801 1802 pGeode->Pitch = GX1CalculatePitchBytes(pScreenInfo->virtualX, 1803 pScreenInfo->bitsPerPixel); 1804 1805 /* find the index to our operating mode the offsets are located */ 1806 for (i = 0; i < (int)((sizeof(GeodeMemOffset) / sizeof(MemOffset))); i++) { 1807 if ((pScreenInfo->virtualX == (int)GeodeMemOffset[i].xres) && 1808 (pScreenInfo->virtualY == (int)GeodeMemOffset[i].yres) && 1809 (pScreenInfo->bitsPerPixel == (int)GeodeMemOffset[i].bpp)) { 1810 MemIndex = i; 1811 break; 1812 } 1813 } 1814 if (MemIndex == -1) /* no match */ 1815 return FALSE; 1816 1817 /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */ 1818 AvailBox.x1 = 0; 1819 AvailBox.y1 = pScreenInfo->virtualY; 1820 AvailBox.x2 = pScreenInfo->displayWidth; 1821 AvailBox.y2 = (pGeode->FBSize / pGeode->Pitch); 1822 1823 pGeode->CursorSize = 8 * 32; /* 32 DWORDS */ 1824 1825 if (pGeode->HWCursor) { 1826 /* Compute cursor buffer */ 1827 /* Default cursor offset, end of the frame buffer */ 1828 pGeode->CursorStartOffset = pGeode->FBSize - pGeode->CursorSize; 1829 AvailBox.y2 -= 1; 1830 } 1831 1832 DEBUGMSG(1, (scrnIndex, X_PROBED, 1833 "Memory manager initialized to (%d,%d) (%d,%d) %d %d\n", 1834 AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2, 1835 pGeode->Pitch, pScreenInfo->displayWidth)); 1836 /* set the offscreen offset accordingly */ 1837 if (pGeode->Compression) { 1838 1839 pGeode->CBOffset = GeodeMemOffset[MemIndex].CBOffset; 1840 pGeode->CBSize = GeodeMemOffset[MemIndex].CBSize - 16; 1841 pGeode->CBPitch = GeodeMemOffset[MemIndex].CBPitch; 1842 1843 if ((pScreenInfo->virtualX == 1024) && (pScreenInfo->virtualY == 768)) { 1844 req_offscreenmem = pScreenInfo->virtualY * pGeode->CBPitch; 1845 req_offscreenmem += pGeode->Pitch - 1; 1846 req_offscreenmem /= pGeode->Pitch; 1847 pGeode->CBOffset = AvailBox.y1 * pGeode->Pitch; 1848 AvailBox.y1 += req_offscreenmem; 1849 } 1850 } 1851 DEBUGMSG(1, (scrnIndex, X_PROBED, 1852 "Memory manager initialized to (%d,%d) (%d,%d)\n", 1853 AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); 1854 1855 if (!pGeode->NoAccel) { 1856 if (pGeode->NoOfImgBuffers > 0) { 1857 if (pGeode->NoOfImgBuffers <= (AvailBox.y2 - AvailBox.y1)) { 1858 pGeode->AccelImageWriteBufferOffsets = 1859 xalloc(sizeof(unsigned long) * pGeode->NoOfImgBuffers); 1860 1861 pGeode->AccelImageWriteBufferOffsets[0] = 1862 ((unsigned char *)pGeode->FBBase) + 1863 (AvailBox.y1 * pGeode->Pitch); 1864 1865 for (i = 1; i < pGeode->NoOfImgBuffers; i++) { 1866 pGeode->AccelImageWriteBufferOffsets[i] = 1867 pGeode->AccelImageWriteBufferOffsets[i - 1] + 1868 pGeode->Pitch; 1869 } 1870 1871 for (i = 0; i < pGeode->NoOfImgBuffers; i++) { 1872 DEBUGMSG(1, (scrnIndex, X_PROBED, 1873 "memory %d %x\n", i, 1874 pGeode->AccelImageWriteBufferOffsets[i])); 1875 } 1876 AvailBox.y1 += pGeode->NoOfImgBuffers; 1877 } else { 1878 xf86DrvMsg(scrnIndex, X_ERROR, 1879 "Unable to reserve scanline area\n"); 1880 } 1881 } 1882 DEBUGMSG(1, (scrnIndex, X_PROBED, 1883 "Memory manager initialized to (%d,%d) (%d,%d)\n", 1884 AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); 1885 1886 REGION_INIT(pScreen, &OffscreenRegion, &AvailBox, 2); 1887 1888 if (!xf86InitFBManagerRegion(pScreen, &OffscreenRegion)) { 1889 xf86DrvMsg(scrnIndex, X_ERROR, 1890 "Memory manager initialization to (%d,%d) (%d,%d) failed\n", 1891 AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); 1892 } else { 1893 xf86DrvMsg(scrnIndex, X_INFO, 1894 "Memory manager initialized to (%d,%d) (%d,%d)\n", 1895 AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); 1896 } 1897 REGION_UNINIT(pScreen, &OffscreenRegion); 1898 } 1899 1900 /* Initialise graphics mode */ 1901 if (!GX1EnterGraphics(pScreen, pScreenInfo)) 1902 return FALSE; 1903 1904 GX1AdjustFrame(scrnIndex, pScreenInfo->frameX0, pScreenInfo->frameY0, 0); 1905 GeodeDebug(("GX1ScreenInit(1)!\n")); 1906 1907 /* Reset visual list */ 1908 miClearVisualTypes(); 1909 GeodeDebug(("GX1ScreenInit(2)!\n")); 1910 1911 /* Setup the visual we support */ 1912 if (pScreenInfo->bitsPerPixel > 8) { 1913 if (!miSetVisualTypes(pScreenInfo->depth, 1914 TrueColorMask, 1915 pScreenInfo->rgbBits, 1916 pScreenInfo->defaultVisual)) { 1917 return FALSE; 1918 } 1919 } else { 1920 if (!miSetVisualTypes(pScreenInfo->depth, 1921 miGetDefaultVisualMask(pScreenInfo->depth), 1922 pScreenInfo->rgbBits, 1923 pScreenInfo->defaultVisual)) { 1924 return FALSE; 1925 } 1926 } 1927 GeodeDebug(("GX1ScreenInit(3)!\n")); 1928 /* Set this for RENDER extension */ 1929 miSetPixmapDepths(); 1930 /* Call the framebuffer layer's ScreenInit function, and fill in other 1931 * * pScreen fields. 1932 */ 1933 1934 if (pGeode->TV_Overscan_On) { 1935 width = pGeode->TVOw; 1936 height = pGeode->TVOh; 1937 GeodeDebug(("width : %d , height : %d", width, height)); 1938 } else { 1939 width = pScreenInfo->virtualX; 1940 height = pScreenInfo->virtualY; 1941 } 1942 1943 displayWidth = pScreenInfo->displayWidth; 1944 if (pGeode->Rotate) { 1945 if (pGeode->TV_Overscan_On) { 1946 width = pGeode->TVOh; 1947 height = pGeode->TVOw; 1948 } else { 1949 width = pScreenInfo->virtualY; 1950 height = pScreenInfo->virtualX; 1951 } 1952 } 1953 if (pGeode->ShadowFB) { 1954 pGeode->ShadowPitch = BitmapBytePad(pScreenInfo->bitsPerPixel * width); 1955 pGeode->ShadowPtr = xalloc(pGeode->ShadowPitch * height); 1956 displayWidth = pGeode->ShadowPitch / (pScreenInfo->bitsPerPixel >> 3); 1957 FBStart = pGeode->ShadowPtr; 1958 } else { 1959 pGeode->ShadowPtr = NULL; 1960 1961 if (pGeode->TV_Overscan_On) { 1962 GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); 1963 FBStart = pGeode->FBBase + (pGeode->Pitch * pGeode->TVOy) + 1964 (pGeode->TVOx << ((pScreenInfo->depth >> 3) - 1)); 1965 } else { 1966 FBStart = pGeode->FBBase; 1967 } 1968 DEBUGMSG(1, (0, X_PROBED, "FBStart %X \n", FBStart)); 1969 } 1970 1971 /* Initialise the framebuffer */ 1972 switch (pScreenInfo->bitsPerPixel) { 1973 case 8: 1974 case 16: 1975 Inited = fbScreenInit(pScreen, FBStart, width, height, 1976 pScreenInfo->xDpi, pScreenInfo->yDpi, 1977 displayWidth, pScreenInfo->bitsPerPixel); 1978 break; 1979 default: 1980 xf86DrvMsg(scrnIndex, X_ERROR, 1981 "Internal error: invalid bpp (%d) in ScreenInit\n", 1982 pScreenInfo->bitsPerPixel); 1983 Inited = FALSE; 1984 break; 1985 } 1986 if (!Inited) 1987 return FALSE; 1988 1989 GeodeDebug(("GX1ScreenInit(4)!\n")); 1990 1991 xf86SetBlackWhitePixels(pScreen); 1992 1993 if (!pGeode->ShadowFB && (!pGeode->TV_Overscan_On)) { 1994 GX1DGAInit(pScreen); 1995 } 1996 GeodeDebug(("GX1ScreenInit(5)!\n")); 1997 if (pScreenInfo->bitsPerPixel > 8) { 1998 /* Fixup RGB ordering */ 1999 visual = pScreen->visuals + pScreen->numVisuals; 2000 while (--visual >= pScreen->visuals) { 2001 if ((visual->class | DynamicClass) == DirectColor) { 2002 visual->offsetRed = pScreenInfo->offset.red; 2003 visual->offsetGreen = pScreenInfo->offset.green; 2004 visual->offsetBlue = pScreenInfo->offset.blue; 2005 visual->redMask = pScreenInfo->mask.red; 2006 visual->greenMask = pScreenInfo->mask.green; 2007 visual->blueMask = pScreenInfo->mask.blue; 2008 } 2009 } 2010 } 2011 /* must be after RGB ordering fixed */ 2012 fbPictureInit(pScreen, 0, 0); 2013 2014 GeodeDebug(("GX1ScreenInit(6)!\n")); 2015 if (!pGeode->NoAccel) { 2016 GX1AccelInit(pScreen); 2017 } 2018 GeodeDebug(("GX1ScreenInit(7)!\n")); 2019 xf86SetBackingStore(pScreen); 2020 2021 GeodeDebug(("GX1ScreenInit(8)!\n")); 2022 /* Initialise software cursor */ 2023 miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); 2024 /* Initialize HW cursor layer. 2025 * * Must follow software cursor initialization 2026 */ 2027 if (pGeode->HWCursor) { 2028 if (!GX1HWCursorInit(pScreen)) 2029 xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, 2030 "Hardware cursor initialization failed\n"); 2031 } 2032 GeodeDebug(("GX1ScreenInit(9)!\n")); 2033 2034 /* Setup default colourmap */ 2035 if (!miCreateDefColormap(pScreen)) { 2036 return FALSE; 2037 } 2038 2039 GeodeDebug(("GX1ScreenInit(10)!\n")); 2040 /* Initialize colormap layer. 2041 * * Must follow initialization of the default colormap 2042 */ 2043 if (!xf86HandleColormaps(pScreen, 256, 8, 2044 GX1LoadPalette, NULL, 2045 CMAP_PALETTED_TRUECOLOR | 2046 CMAP_RELOAD_ON_MODE_SWITCH)) { 2047 return FALSE; 2048 } 2049 GeodeDebug(("GX1ScreenInit(11)!\n")); 2050 2051 if (pGeode->ShadowFB) { 2052 RefreshAreaFuncPtr refreshArea = GX1RefreshArea; 2053 2054 if (pGeode->Rotate) { 2055 if (!pGeode->PointerMoved) { 2056 pGeode->PointerMoved = pScreenInfo->PointerMoved; 2057 pScreenInfo->PointerMoved = GX1PointerMoved; 2058 } 2059 switch (pScreenInfo->bitsPerPixel) { 2060 case 8: 2061 refreshArea = GX1RefreshArea8; 2062 break; 2063 case 16: 2064 refreshArea = GX1RefreshArea16; 2065 break; 2066 } 2067 } 2068 ShadowFBInit(pScreen, refreshArea); 2069 } 2070 xf86DPMSInit(pScreen, GX1DPMSSet, 0); 2071 GeodeDebug(("GX1ScreenInit(12)!\n")); 2072 2073 if (pGeode->TV_Overscan_On) { 2074 GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); 2075 2076 pScreenInfo->memPhysBase = (unsigned long)(pGeode->FBBase + 2077 (pGeode->Pitch * 2078 pGeode->TVOy) + 2079 (pGeode-> 2080 TVOx << 2081 ((pScreenInfo->depth >> 3) - 2082 1))); 2083 GeodeDebug(("->memPhysBase (%X)!\n", pScreenInfo->memPhysBase)); 2084 } else { 2085 pScreenInfo->memPhysBase = (unsigned long)pGeode->FBBase; 2086 } 2087 pScreenInfo->fbOffset = 0; 2088 2089 GeodeDebug(("GX1ScreenInit(13)!\n")); 2090 GX1InitVideo(pScreen); /* needed for video */ 2091 /* Wrap the screen's CloseScreen vector and set its 2092 * SaveScreen vector 2093 */ 2094 pGeode->CloseScreen = pScreen->CloseScreen; 2095 pScreen->CloseScreen = GX1CloseScreen; 2096 2097 pScreen->SaveScreen = GX1SaveScreen; 2098 GeodeDebug(("GX1ScreenInit(14)!\n")); 2099 /* Report any unused options */ 2100 if (serverGeneration == 1) { 2101 xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); 2102 } 2103 GeodeDebug(("GX2ScreenInit(15)!\n")); 2104 return TRUE; 2105} 2106 2107/*---------------------------------------------------------------------------- 2108 * GX1SwitchMode. 2109 * 2110 * Description :This function will switches the screen mode 2111 * 2112 * Parameters: 2113 * scrnIndex :Specfies the screen index value. 2114 * pMode :pointer to the mode structure. 2115 * flags :may be used for status check?. 2116 * 2117 * Returns :Returns TRUE on success and FALSE on failure. 2118 * 2119 * Comments :none. 2120*---------------------------------------------------------------------------- 2121*/ 2122Bool 2123GX1SwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) 2124{ 2125 GeodeDebug(("GX1SwitchMode!\n")); 2126 return GX1SetMode(xf86Screens[scrnIndex], pMode); 2127} 2128 2129/*---------------------------------------------------------------------------- 2130 * GX1AdjustFrame. 2131 * 2132 * Description :This function is used to intiallize the start 2133 * address of the memory. 2134 * Parameters. 2135 * scrnIndex :Specfies the screen index value. 2136 * x :x co-ordinate value interms of pixels. 2137 * y :y co-ordinate value interms of pixels. 2138 * 2139 * Returns :none. 2140 * 2141 * Comments :none. 2142*---------------------------------------------------------------------------- 2143*/ 2144void 2145GX1AdjustFrame(int scrnIndex, int x, int y, int flags) 2146{ 2147 ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 2148 GeodePtr pGeode; 2149 unsigned long offset; 2150 2151 pGeode = GX1GetRec(pScreenInfo); 2152 offset = (unsigned long)y *(unsigned long)pGeode->Pitch; 2153 2154 offset += x; 2155 if (pScreenInfo->bitsPerPixel > 8) { 2156 offset += x; 2157 } 2158 GFX(set_display_offset(offset)); 2159} 2160 2161/*---------------------------------------------------------------------------- 2162 * GX1EnterVT. 2163 * 2164 * Description :This is called when VT switching back to the X server 2165 * 2166 * Parameters. 2167 * scrnIndex :Specfies the screen index value. 2168 * flags :Not used inside the function. 2169 * 2170 * Returns :none. 2171 * 2172 * Comments :none. 2173*---------------------------------------------------------------------------- 2174*/ 2175static Bool 2176GX1EnterVT(int scrnIndex, int flags) 2177{ 2178 GeodeDebug(("GX1EnterVT!\n")); 2179 return GX1EnterGraphics(NULL, xf86Screens[scrnIndex]); 2180} 2181 2182/*---------------------------------------------------------------------------- 2183 * GX1LeaveVT. 2184 * 2185 * Description :This is called when VT switching X server text mode. 2186 * 2187 * Parameters. 2188 * scrnIndex :Specfies the screen index value. 2189 * flags :Not used inside the function. 2190 * 2191 * Returns :none. 2192 * 2193 * Comments :none. 2194*---------------------------------------------------------------------------- 2195*/ 2196static void 2197GX1LeaveVT(int scrnIndex, int flags) 2198{ 2199 GeodeDebug(("GX1LeaveVT!\n")); 2200 GX1LeaveGraphics(xf86Screens[scrnIndex]); 2201} 2202 2203/*---------------------------------------------------------------------------- 2204 * GX1FreeScreen. 2205 * 2206 * Description :This is called to free any persistent data structures. 2207 * 2208 * Parameters. 2209 * scrnIndex :Specfies the screen index value. 2210 * flags :Not used inside the function. 2211 * 2212 * Returns :none. 2213 * 2214 * Comments :This will be called only when screen being deleted.. 2215*---------------------------------------------------------------------------- 2216*/ 2217static void 2218GX1FreeScreen(int scrnIndex, int flags) 2219{ 2220 GeodeDebug(("GX1FreeScreen!\n")); 2221#if !defined(STB_X) 2222 2223 if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) 2224 vgaHWFreeHWRec(xf86Screens[scrnIndex]); 2225#endif 2226 GX1FreeRec(xf86Screens[scrnIndex]); 2227} 2228 2229/*---------------------------------------------------------------------------- 2230 * GX1ValidMode. 2231 * 2232 * Description :This function checks if a mode is suitable for selected 2233 * chipset. 2234 * Parameters. 2235 * scrnIndex :Specfies the screen index value. 2236 * pMode :Pointer to the screen mode structure.. 2237 * verbose :not used for implementation. 2238 * flags :not used for implementation 2239 * 2240 * Returns :MODE_OK if the specified mode is supported or 2241 * MODE_NO_INTERLACE. 2242 * Comments :none. 2243*---------------------------------------------------------------------------- 2244*/ 2245static ModeStatus 2246GX1ValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) 2247{ 2248 ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 2249 unsigned int total_memory_required; 2250 int ret = -1; 2251 GeodePtr pGeode = GX1GetRec(pScreenInfo); 2252 2253 DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", 2254 pMode->CrtcHDisplay, pMode->CrtcVDisplay, 2255 pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); 2256 2257 if (pGeode->TVSupport == TRUE) { 2258 if ((pGeode->TvParam.wWidth == pMode->CrtcHDisplay) && 2259 (pGeode->TvParam.wHeight == pMode->CrtcVDisplay)) { 2260 DEBUGMSG(1, (0, X_NONE, "TV mode\n")); 2261 2262#if defined(STB_X) 2263 Gal_is_tv_mode_supported(0, &(pGeode->TvParam), &ret); 2264#else 2265 ret = gfx_is_tv_display_mode_supported(pMode->CrtcHDisplay, 2266 pMode->CrtcVDisplay, 2267 (TVStandardType)pGeode->TvParam.wStandard); 2268#endif 2269 } 2270 } else { 2271 DEBUGMSG(1, (0, X_NONE, "CRT mode\n")); 2272 2273 if (pMode->Flags & V_INTERLACE) 2274 return MODE_NO_INTERLACE; 2275 2276#if defined(STB_X) 2277 Gal_is_display_mode_supported(pMode->CrtcHDisplay, pMode->CrtcVDisplay, 2278 pScreenInfo->bitsPerPixel, 2279 GX1GetRefreshRate(pMode), &ret); 2280#else 2281 ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay, 2282 pMode->CrtcVDisplay, 2283 pScreenInfo->bitsPerPixel, 2284 GX1GetRefreshRate(pMode)); 2285#endif /* STB_X */ 2286 } 2287 2288 if (ret < 0) 2289 return MODE_NOMODE; 2290 2291 total_memory_required = GX1CalculatePitchBytes(pMode->CrtcHDisplay, 2292 pScreenInfo->bitsPerPixel) * 2293 pMode->CrtcVDisplay; 2294 2295 DEBUGMSG(0, (0, X_NONE, "Total Mem %X %X", 2296 total_memory_required, pGeode->FBSize)); 2297 2298 if (total_memory_required > pGeode->FBSize) 2299 return MODE_MEM; 2300 2301 return MODE_OK; 2302} 2303 2304/*---------------------------------------------------------------------------- 2305 * GX1LoadPalette. 2306 * 2307 * Description :This function sets the palette entry used for graphics data 2308 * 2309 * Parameters. 2310 * pScreenInfo:Points the screeninfo structure. 2311 * numColors:Specifies the no of colors it supported. 2312 * indizes :This is used get index value . 2313 * LOCO :to be added. 2314 * pVisual :to be added. 2315 * 2316 * Returns :MODE_OK if the specified mode is supported or 2317 * MODE_NO_INTERLACE. 2318 * Comments :none. 2319*---------------------------------------------------------------------------- 2320*/ 2321 2322static void 2323GX1LoadPalette(ScrnInfoPtr pScreenInfo, 2324 int numColors, int *indizes, LOCO * colors, VisualPtr pVisual) 2325{ 2326 int i, index, color; 2327 2328 for (i = 0; i < numColors; i++) { 2329 index = indizes[i] & 0xFF; 2330 color = (((unsigned long)(colors[index].red & 0xFF)) << 16) | 2331 (((unsigned long)(colors[index].green & 0xFF)) << 8) | 2332 ((unsigned long)(colors[index].blue & 0xFF)); 2333 DEBUGMSG(0, (0, X_NONE, "GX1LoadPalette: %d %d %X\n", 2334 numColors, index, color)); 2335 2336 GFX(set_display_palette_entry(index, color)); 2337 } 2338} 2339 2340static Bool 2341GX1MapMem(ScrnInfoPtr pScreenInfo) 2342{ 2343 GeodePtr pGeode = GEODEPTR(pScreenInfo); 2344 2345#if defined(STB_X) 2346 pGeode->FBBase = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 2347 VIDMEM_FRAMEBUFFER, 2348 pGeode->FBLinearAddr, 2349 pGeode->FBSize); 2350 2351#else 2352 /* SET DURANGO REGISTER POINTERS 2353 * * The method of mapping from a physical address to a linear address 2354 * * is operating system independent. Set variables to linear address. 2355 */ 2356 gfx_virt_regptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 2357 VIDMEM_MMIO, 2358 (unsigned int) 2359 gfx_get_cpu_register_base 2360 (), 0x9000); 2361 gfx_virt_spptr = gfx_virt_regptr; 2362 gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 2363 VIDMEM_MMIO, 2364 (unsigned int) 2365 gfx_get_vid_register_base 2366 (), 0x1000); 2367 pGeode->FBSize = GetVideoMemSize(); 2368 gfx_virt_fbptr = 2369 (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 2370 VIDMEM_FRAMEBUFFER, 2371 pGeode->FBLinearAddr, pGeode->FBSize); 2372 2373 /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */ 2374 if ((!gfx_virt_regptr) || 2375 (!gfx_virt_spptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) { 2376 DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n")); 2377 return (FALSE); 2378 } 2379 2380 /* Map the XpressROM ptr to read what platform are we on */ 2381 XpressROMPtr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 2382 VIDMEM_FRAMEBUFFER, 0xF0000, 2383 0x10000); 2384 2385 if (!XpressROMPtr) 2386 return FALSE; 2387 2388 pGeode->FBBase = gfx_virt_fbptr; 2389#endif 2390 2391 return TRUE; 2392} 2393 2394/* 2395 * Unmap the framebuffer and MMIO memory. 2396 */ 2397 2398static Bool 2399GX1UnmapMem(ScrnInfoPtr pScreenInfo) 2400{ 2401#if !defined(STB_X) 2402 GeodePtr pGeode = GEODEPTR(pScreenInfo); 2403 2404 /* unmap all the memory map's */ 2405 xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_regptr, 0x9000); 2406 xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_vidptr, 0x1000); 2407 xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_fbptr, pGeode->FBSize); 2408 xf86UnMapVidMem(pScreenInfo->scrnIndex, XpressROMPtr, 0x10000); 2409#endif /* STB_X */ 2410 2411 return TRUE; 2412} 2413 2414/* End of file */ 2415