nsc_gx1_driver.c revision 71d7fec4
171d7fec4Smrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_gx1_driver.c,v 1.10tsi Exp $ */ 271d7fec4Smrg/* 371d7fec4Smrg * $Workfile: nsc_gx1_driver.c $ 471d7fec4Smrg * $Revision: 1.1.1.1 $ 571d7fec4Smrg * $Author: mrg $ 671d7fec4Smrg * 771d7fec4Smrg * File Contents: This is the main module configures the interfacing 871d7fec4Smrg * with the X server. The individual modules will be 971d7fec4Smrg * loaded based upon the options selected from the 1071d7fec4Smrg * XF86Config. This file also has modules for finding 1171d7fec4Smrg * supported modes, turning on the modes based on options. 1271d7fec4Smrg * 1371d7fec4Smrg * Project: Geode Xfree Frame buffer device driver. 1471d7fec4Smrg * 1571d7fec4Smrg */ 1671d7fec4Smrg 1771d7fec4Smrg/* 1871d7fec4Smrg * NSC_LIC_ALTERNATIVE_PREAMBLE 1971d7fec4Smrg * 2071d7fec4Smrg * Revision 1.0 2171d7fec4Smrg * 2271d7fec4Smrg * National Semiconductor Alternative GPL-BSD License 2371d7fec4Smrg * 2471d7fec4Smrg * National Semiconductor Corporation licenses this software 2571d7fec4Smrg * ("Software"): 2671d7fec4Smrg * 2771d7fec4Smrg * National Xfree frame buffer driver 2871d7fec4Smrg * 2971d7fec4Smrg * under one of the two following licenses, depending on how the 3071d7fec4Smrg * Software is received by the Licensee. 3171d7fec4Smrg * 3271d7fec4Smrg * If this Software is received as part of the Linux Framebuffer or 3371d7fec4Smrg * other GPL licensed software, then the GPL license designated 3471d7fec4Smrg * NSC_LIC_GPL applies to this Software; in all other circumstances 3571d7fec4Smrg * then the BSD-style license designated NSC_LIC_BSD shall apply. 3671d7fec4Smrg * 3771d7fec4Smrg * END_NSC_LIC_ALTERNATIVE_PREAMBLE */ 3871d7fec4Smrg 3971d7fec4Smrg/* NSC_LIC_BSD 4071d7fec4Smrg * 4171d7fec4Smrg * National Semiconductor Corporation Open Source License for 4271d7fec4Smrg * 4371d7fec4Smrg * National Xfree frame buffer driver 4471d7fec4Smrg * 4571d7fec4Smrg * (BSD License with Export Notice) 4671d7fec4Smrg * 4771d7fec4Smrg * Copyright (c) 1999-2001 4871d7fec4Smrg * National Semiconductor Corporation. 4971d7fec4Smrg * All rights reserved. 5071d7fec4Smrg * 5171d7fec4Smrg * Redistribution and use in source and binary forms, with or without 5271d7fec4Smrg * modification, are permitted provided that the following conditions 5371d7fec4Smrg * are met: 5471d7fec4Smrg * 5571d7fec4Smrg * * Redistributions of source code must retain the above copyright 5671d7fec4Smrg * notice, this list of conditions and the following disclaimer. 5771d7fec4Smrg * 5871d7fec4Smrg * * Redistributions in binary form must reproduce the above 5971d7fec4Smrg * copyright notice, this list of conditions and the following 6071d7fec4Smrg * disclaimer in the documentation and/or other materials provided 6171d7fec4Smrg * with the distribution. 6271d7fec4Smrg * 6371d7fec4Smrg * * Neither the name of the National Semiconductor Corporation nor 6471d7fec4Smrg * the names of its contributors may be used to endorse or promote 6571d7fec4Smrg * products derived from this software without specific prior 6671d7fec4Smrg * written permission. 6771d7fec4Smrg * 6871d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6971d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7071d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 7171d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 7271d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 7371d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 7471d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 7571d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 7671d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 7771d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 7871d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 7971d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 8071d7fec4Smrg * OF SUCH DAMAGE. 8171d7fec4Smrg * 8271d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 8371d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with 8471d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under 8571d7fec4Smrg * CURRENT (2001) U.S. export regulations this software 8671d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or 8771d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 8871d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 8971d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S. 9071d7fec4Smrg * has embargoed goods and services. 9171d7fec4Smrg * 9271d7fec4Smrg * END_NSC_LIC_BSD */ 9371d7fec4Smrg 9471d7fec4Smrg/* NSC_LIC_GPL 9571d7fec4Smrg * 9671d7fec4Smrg * National Semiconductor Corporation Gnu General Public License for 9771d7fec4Smrg * 9871d7fec4Smrg * National Xfree frame buffer driver 9971d7fec4Smrg * 10071d7fec4Smrg * (GPL License with Export Notice) 10171d7fec4Smrg * 10271d7fec4Smrg * Copyright (c) 1999-2001 10371d7fec4Smrg * National Semiconductor Corporation. 10471d7fec4Smrg * All rights reserved. 10571d7fec4Smrg * 10671d7fec4Smrg * Redistribution and use in source and binary forms, with or without 10771d7fec4Smrg * modification, are permitted under the terms of the GNU General 10871d7fec4Smrg * Public License as published by the Free Software Foundation; either 10971d7fec4Smrg * version 2 of the License, or (at your option) any later version 11071d7fec4Smrg * 11171d7fec4Smrg * In addition to the terms of the GNU General Public License, neither 11271d7fec4Smrg * the name of the National Semiconductor Corporation nor the names of 11371d7fec4Smrg * its contributors may be used to endorse or promote products derived 11471d7fec4Smrg * from this software without specific prior written permission. 11571d7fec4Smrg * 11671d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 11771d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 11871d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 11971d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 12071d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 12171d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 12271d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 12371d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 12471d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 12571d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 12671d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 12771d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 12871d7fec4Smrg * OF SUCH DAMAGE. See the GNU General Public License for more details. 12971d7fec4Smrg * 13071d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 13171d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with 13271d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under 13371d7fec4Smrg * CURRENT (2001) U.S. export regulations this software 13471d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or 13571d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 13671d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 13771d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S. 13871d7fec4Smrg * has embargoed goods and services. 13971d7fec4Smrg * 14071d7fec4Smrg * You should have received a copy of the GNU General Public License 14171d7fec4Smrg * along with this file; if not, write to the Free Software Foundation, 14271d7fec4Smrg * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14371d7fec4Smrg * 14471d7fec4Smrg * END_NSC_LIC_GPL */ 14571d7fec4Smrg 14671d7fec4Smrg/* 14771d7fec4Smrg * Lots of fixes & updates 14871d7fec4Smrg * Alan Hourihane <alanh@fairlite.demon.co.uk> 14971d7fec4Smrg */ 15071d7fec4Smrg 15171d7fec4Smrg#ifdef HAVE_CONFIG_H 15271d7fec4Smrg#include "config.h" 15371d7fec4Smrg#endif 15471d7fec4Smrg 15571d7fec4Smrg#define DEBUG(x) 15671d7fec4Smrg#define GEODE_TRACE 0 15771d7fec4Smrg#define HWVGA 0 15871d7fec4Smrg 15971d7fec4Smrg/* Includes that are used by all drivers */ 16071d7fec4Smrg#include "xf86.h" 16171d7fec4Smrg#include "xf86_OSproc.h" 16271d7fec4Smrg#include "xf86Resources.h" 16371d7fec4Smrg 16471d7fec4Smrg/* We may want inb() and outb() */ 16571d7fec4Smrg#include "compiler.h" 16671d7fec4Smrg 16771d7fec4Smrg/* We may want to access the PCI config space */ 16871d7fec4Smrg#include "xf86PciInfo.h" 16971d7fec4Smrg#include "xf86Pci.h" 17071d7fec4Smrg 17171d7fec4Smrg/* Colormap handling stuff */ 17271d7fec4Smrg#include "xf86cmap.h" 17371d7fec4Smrg 17471d7fec4Smrg/* Frame buffer stuff */ 17571d7fec4Smrg#include "fb.h" 17671d7fec4Smrg 17771d7fec4Smrg#include "shadowfb.h" 17871d7fec4Smrg 17971d7fec4Smrg/* Machine independent stuff */ 18071d7fec4Smrg#include "mipointer.h" 18171d7fec4Smrg#include "mibank.h" 18271d7fec4Smrg#include "micmap.h" 18371d7fec4Smrg/* All drivers implementing backing store need this */ 18471d7fec4Smrg#include "mibstore.h" 18571d7fec4Smrg#include "vgaHW.h" 18671d7fec4Smrg#include "vbe.h" 18771d7fec4Smrg 18871d7fec4Smrg/* Check for some extensions */ 18971d7fec4Smrg#ifdef XFreeXDGA 19071d7fec4Smrg#define _XF86_DGA_SERVER_ 19171d7fec4Smrg#include <X11/extensions/xf86dgastr.h> 19271d7fec4Smrg#endif /* XFreeXDGA */ 19371d7fec4Smrg 19471d7fec4Smrg#include "globals.h" 19571d7fec4Smrg#include "opaque.h" 19671d7fec4Smrg#define DPMS_SERVER 19771d7fec4Smrg#include <X11/extensions/dpms.h> 19871d7fec4Smrg 19971d7fec4Smrg/* Our private include file (this also includes the durango headers) */ 20071d7fec4Smrg#include "nsc.h" 20171d7fec4Smrg 20271d7fec4Smrg#if GEODE_TRACE 20371d7fec4Smrg/* ANSI C does not allow var arg macros */ 20471d7fec4Smrg#define GeodeDebug(args) DebugPort(DCount++);ErrorF args 20571d7fec4Smrg#else 20671d7fec4Smrg#define GeodeDebug(args) 20771d7fec4Smrg#endif 20871d7fec4Smrg 20971d7fec4Smrgextern SymTabRec GeodeChipsets[]; 21071d7fec4Smrgextern OptionInfoRec GeodeOptions[]; 21171d7fec4Smrg 21271d7fec4Smrgtypedef struct _MemOffset 21371d7fec4Smrg{ 21471d7fec4Smrg unsigned long xres; 21571d7fec4Smrg unsigned long yres; 21671d7fec4Smrg unsigned long bpp; 21771d7fec4Smrg unsigned long CBOffset; 21871d7fec4Smrg unsigned short CBPitch; 21971d7fec4Smrg unsigned short CBSize; 22071d7fec4Smrg unsigned long CurOffset; 22171d7fec4Smrg unsigned long OffScreenOffset; 22271d7fec4Smrg} 22371d7fec4SmrgMemOffset; 22471d7fec4Smrg 22571d7fec4Smrg/* predefined memory address for compression and cursor offsets 22671d7fec4Smrg * if COMPRESSION enabled. 22771d7fec4Smrg */ 22871d7fec4SmrgMemOffset GeodeMemOffset[] = { 22971d7fec4Smrg {640, 480, 8, 640, 1024, 272, 0x78000, 0x78100}, 23071d7fec4Smrg {640, 480, 16, 1280, 2048, 272, 0x610, 0xF0000}, 23171d7fec4Smrg {800, 600, 8, 800, 1024, 208, 0x96000, 0x96100}, 23271d7fec4Smrg {800, 600, 16, 1600, 2048, 272, 0x12C000, 0x12C100}, 23371d7fec4Smrg {1024, 768, 8, 0xC0000, 272, 272, 0xF3000, 0xF3100}, 23471d7fec4Smrg {1024, 768, 16, 0x180000, 272, 272, 0x1B3000, 0x1B3100}, 23571d7fec4Smrg {1152, 864, 8, 1152, 2048, 272, 0x590, 0x1B0000}, 23671d7fec4Smrg {1152, 864, 16, 2304, 4096, 272, 0xA10, 0x360000}, 23771d7fec4Smrg {1280, 1024, 8, 1280, 2048, 272, 0x610, 0x200000}, 23871d7fec4Smrg {1280, 1024, 16, 2560, 4096, 272, 0xB10, 0x400000}, 23971d7fec4Smrg 24071d7fec4Smrg /* PAL TV modes */ 24171d7fec4Smrg 24271d7fec4Smrg {704, 576, 16, 1408, 2048, 272, 0x690, 0x120000}, 24371d7fec4Smrg {720, 576, 16, 1440, 2048, 272, 0x6B0, 0x120000}, 24471d7fec4Smrg {768, 576, 16, 1536, 2048, 256, 0x700, 0x120000}, 24571d7fec4Smrg 24671d7fec4Smrg /* NTSC TV modes */ 24771d7fec4Smrg 24871d7fec4Smrg {704, 480, 16, 1408, 2048, 272, 0x690, 0xF0000}, 24971d7fec4Smrg {720, 480, 16, 1440, 2048, 272, 0x6B0, 0xF0000} 25071d7fec4Smrg 25171d7fec4Smrg}; 25271d7fec4Smrgstatic int MemIndex = 0; 25371d7fec4Smrg 25471d7fec4Smrgstatic Bool GX1PreInit(ScrnInfoPtr, int); 25571d7fec4Smrgstatic Bool GX1ScreenInit(int, ScreenPtr, int, char **); 25671d7fec4Smrgstatic Bool GX1EnterVT(int, int); 25771d7fec4Smrgstatic void GX1LeaveVT(int, int); 25871d7fec4Smrgstatic void GX1FreeScreen(int, int); 25971d7fec4Smrgvoid GX1AdjustFrame(int, int, int, int); 26071d7fec4SmrgBool GX1SwitchMode(int, DisplayModePtr, int); 26171d7fec4Smrgstatic ModeStatus GX1ValidMode(int, DisplayModePtr, Bool, int); 26271d7fec4Smrgstatic void GX1LoadPalette(ScrnInfoPtr pScreenInfo, 26371d7fec4Smrg int numColors, int *indizes, 26471d7fec4Smrg LOCO * colors, VisualPtr pVisual); 26571d7fec4Smrgstatic Bool GX1MapMem(ScrnInfoPtr); 26671d7fec4Smrgstatic Bool GX1UnmapMem(ScrnInfoPtr); 26771d7fec4Smrg 26871d7fec4Smrgextern Bool GX1AccelInit(ScreenPtr pScreen); 26971d7fec4Smrgextern Bool GX1HWCursorInit(ScreenPtr pScreen); 27071d7fec4Smrgextern void GX1HideCursor(ScrnInfoPtr pScreenInfo); 27171d7fec4Smrgextern void GX1ShowCursor(ScrnInfoPtr pScreenInfo); 27271d7fec4Smrgextern void GX1PointerMoved(int index, int x, int y); 27371d7fec4Smrgextern void GX1RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 27471d7fec4Smrgextern void GX1RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 27571d7fec4Smrgextern void GX1RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 27671d7fec4Smrgextern void GX1InitVideo(ScreenPtr pScreen); 27771d7fec4Smrgextern Bool GX1DGAInit(ScreenPtr pScreen); 27871d7fec4Smrgextern void GX1LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src); 27971d7fec4Smrgextern unsigned int GetVideoMemSize(void); 28071d7fec4Smrg 28171d7fec4Smrgvoid get_tv_overscan_geom(const char *options, int *X, int *Y, int *W, 28271d7fec4Smrg int *H); 28371d7fec4Smrgvoid GX1SetupChipsetFPtr(ScrnInfoPtr pScrn); 28471d7fec4SmrgGeodePtr GX1GetRec(ScrnInfoPtr pScreenInfo); 28571d7fec4Smrgvoid gx1_clear_screen(int width, int height); 28671d7fec4Smrg 28771d7fec4Smrg#if !defined(STB_X) 28871d7fec4Smrgextern unsigned char *XpressROMPtr; 28971d7fec4Smrg#endif /* STB_X */ 29071d7fec4Smrg 29171d7fec4Smrg/* List of symbols from other modules that this module references.The purpose 29271d7fec4Smrg* is that to avoid unresolved symbol warnings 29371d7fec4Smrg*/ 29471d7fec4Smrgextern const char *nscVgahwSymbols[]; 29571d7fec4Smrgextern const char *nscVbeSymbols[]; 29671d7fec4Smrgextern const char *nscInt10Symbols[]; 29771d7fec4Smrg 29871d7fec4Smrgextern const char *nscFbSymbols[]; 29971d7fec4Smrgextern const char *nscXaaSymbols[]; 30071d7fec4Smrgextern const char *nscRamdacSymbols[]; 30171d7fec4Smrgextern const char *nscShadowSymbols[]; 30271d7fec4Smrg 30371d7fec4Smrgvoid 30471d7fec4SmrgGX1SetupChipsetFPtr(ScrnInfoPtr pScrn) 30571d7fec4Smrg{ 30671d7fec4Smrg GeodeDebug(("GX1SetupChipsetFPtr!\n")); 30771d7fec4Smrg 30871d7fec4Smrg pScrn->PreInit = GX1PreInit; 30971d7fec4Smrg pScrn->ScreenInit = GX1ScreenInit; 31071d7fec4Smrg pScrn->SwitchMode = GX1SwitchMode; 31171d7fec4Smrg pScrn->AdjustFrame = GX1AdjustFrame; 31271d7fec4Smrg pScrn->EnterVT = GX1EnterVT; 31371d7fec4Smrg pScrn->LeaveVT = GX1LeaveVT; 31471d7fec4Smrg pScrn->FreeScreen = GX1FreeScreen; 31571d7fec4Smrg pScrn->ValidMode = GX1ValidMode; 31671d7fec4Smrg} 31771d7fec4Smrg 31871d7fec4Smrg/*---------------------------------------------------------------------------- 31971d7fec4Smrg * GX1GetRec. 32071d7fec4Smrg * 32171d7fec4Smrg * Description :This function allocate an GeodeRec and hooked into 32271d7fec4Smrg * pScreenInfo str driverPrivate member of ScreeenInfo 32371d7fec4Smrg * structure. 32471d7fec4Smrg * Parameters. 32571d7fec4Smrg * pScreenInfo :Pointer handle to the screenonfo structure. 32671d7fec4Smrg * 32771d7fec4Smrg * Returns :allocated pScreeninfo structure. 32871d7fec4Smrg * 32971d7fec4Smrg * Comments :none 33071d7fec4Smrg * 33171d7fec4Smrg*---------------------------------------------------------------------------- 33271d7fec4Smrg*/ 33371d7fec4SmrgGeodePtr 33471d7fec4SmrgGX1GetRec(ScrnInfoPtr pScreenInfo) 33571d7fec4Smrg{ 33671d7fec4Smrg if (!pScreenInfo->driverPrivate) 33771d7fec4Smrg pScreenInfo->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1); 33871d7fec4Smrg return GEODEPTR(pScreenInfo); 33971d7fec4Smrg} 34071d7fec4Smrg 34171d7fec4Smrg/*---------------------------------------------------------------------------- 34271d7fec4Smrg * GX1FreeRec. 34371d7fec4Smrg * 34471d7fec4Smrg * Description :This function deallocate an GeodeRec and freed from 34571d7fec4Smrg * pScreenInfo str driverPrivate member of ScreeenInfo 34671d7fec4Smrg * structure. 34771d7fec4Smrg * Parameters. 34871d7fec4Smrg * pScreenInfo :Pointer handle to the screenonfo structure. 34971d7fec4Smrg * 35071d7fec4Smrg * Returns :none 35171d7fec4Smrg * 35271d7fec4Smrg * Comments :none 35371d7fec4Smrg * 35471d7fec4Smrg*---------------------------------------------------------------------------- 35571d7fec4Smrg*/ 35671d7fec4Smrgstatic void 35771d7fec4SmrgGX1FreeRec(ScrnInfoPtr pScreenInfo) 35871d7fec4Smrg{ 35971d7fec4Smrg if (pScreenInfo->driverPrivate == NULL) { 36071d7fec4Smrg return; 36171d7fec4Smrg } 36271d7fec4Smrg xfree(pScreenInfo->driverPrivate); 36371d7fec4Smrg pScreenInfo->driverPrivate = NULL; 36471d7fec4Smrg} 36571d7fec4Smrg 36671d7fec4Smrg/*---------------------------------------------------------------------------- 36771d7fec4Smrg * GX1SaveScreen. 36871d7fec4Smrg * 36971d7fec4Smrg * Description :This is todo the screen blanking 37071d7fec4Smrg * 37171d7fec4Smrg * Parameters. 37271d7fec4Smrg * pScreen :Handle to ScreenPtr structure. 37371d7fec4Smrg * mode :mode is used by vgaHWSaveScren to check blnak os on. 37471d7fec4Smrg * 37571d7fec4Smrg * Returns :TRUE on success and FALSE on failure. 37671d7fec4Smrg * 37771d7fec4Smrg * Comments :none 37871d7fec4Smrg*---------------------------------------------------------------------------- 37971d7fec4Smrg*/ 38071d7fec4Smrgstatic Bool 38171d7fec4SmrgGX1SaveScreen(ScreenPtr pScreen, int mode) 38271d7fec4Smrg{ 38371d7fec4Smrg#if !defined(STB_X) 38471d7fec4Smrg ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; 38571d7fec4Smrg 38671d7fec4Smrg GeodeDebug(("GX2SaveScreen!\n")); 38771d7fec4Smrg 38871d7fec4Smrg if (!pScreenInfo->vtSema) 38971d7fec4Smrg return vgaHWSaveScreen(pScreen, mode); 39071d7fec4Smrg 39171d7fec4Smrg#endif /* STB_X */ 39271d7fec4Smrg return TRUE; 39371d7fec4Smrg} 39471d7fec4Smrg 39571d7fec4Smrg/*---------------------------------------------------------------------------- 39671d7fec4Smrg * get_tv_overscan_geom. 39771d7fec4Smrg * 39871d7fec4Smrg * Description :This is todo the screen blanking 39971d7fec4Smrg * 40071d7fec4Smrg * Parameters: 40171d7fec4Smrg * options : Pointer to the display options. 40271d7fec4Smrg * X: Pointer to the offset of the screen X-co-ordinate. 40371d7fec4Smrg * Y: Pointer to the offset of the screen Y-co-ordinate. 40471d7fec4Smrg * W: Pointer to the width of the screen. 40571d7fec4Smrg * H: Pointer to the height of the screen. 40671d7fec4Smrg * Returns : none. 40771d7fec4Smrg * 40871d7fec4Smrg * Comments :none 40971d7fec4Smrg *------------------------------------------------------------------------ 41071d7fec4Smrg */ 41171d7fec4Smrgvoid 41271d7fec4Smrgget_tv_overscan_geom(const char *options, int *X, int *Y, int *W, int *H) 41371d7fec4Smrg{ 41471d7fec4Smrg char *tv_opt; 41571d7fec4Smrg 41671d7fec4Smrg tv_opt = strtok((char *)options, ":"); 41771d7fec4Smrg *X = strtoul(tv_opt, NULL, 0); 41871d7fec4Smrg tv_opt = strtok(NULL, ":"); 41971d7fec4Smrg *Y = strtoul(tv_opt, NULL, 0); 42071d7fec4Smrg tv_opt = strtok(NULL, ":"); 42171d7fec4Smrg *W = strtoul(tv_opt, NULL, 0); 42271d7fec4Smrg tv_opt = strtok(NULL, ":"); 42371d7fec4Smrg *H = strtoul(tv_opt, NULL, 0); 42471d7fec4Smrg} 42571d7fec4Smrg 42671d7fec4Smrgstatic void 42771d7fec4SmrgGX1ProbeDDC(ScrnInfoPtr pScrn, int index) 42871d7fec4Smrg{ 42971d7fec4Smrg vbeInfoPtr pVbe; 43071d7fec4Smrg 43171d7fec4Smrg if (xf86LoadSubModule(pScrn, "vbe")) { 43271d7fec4Smrg pVbe = VBEInit(NULL, index); 43371d7fec4Smrg ConfiguredMonitor = vbeDoEDID(pVbe, NULL); 43471d7fec4Smrg vbeFree(pVbe); 43571d7fec4Smrg } 43671d7fec4Smrg} 43771d7fec4Smrg 43871d7fec4Smrg/*---------------------------------------------------------------------------- 43971d7fec4Smrg * GX1PreInit. 44071d7fec4Smrg * 44171d7fec4Smrg * Description :This function is called only once ate teh server startup 44271d7fec4Smrg * 44371d7fec4Smrg * Parameters. 44471d7fec4Smrg * pScreenInfo :Handle to ScreenPtr structure. 44571d7fec4Smrg * flags :flags may be used to check the probeed one with config. 44671d7fec4Smrg * 44771d7fec4Smrg * Returns :TRUE on success and FALSE on failure. 44871d7fec4Smrg * 44971d7fec4Smrg * Comments :none. 45071d7fec4Smrg *---------------------------------------------------------------------------- 45171d7fec4Smrg */ 45271d7fec4Smrgstatic Bool 45371d7fec4SmrgGX1PreInit(ScrnInfoPtr pScreenInfo, int flags) 45471d7fec4Smrg{ 45571d7fec4Smrg static ClockRange GeodeClockRange = 45671d7fec4Smrg { NULL, 25175, 135000, 0, FALSE, TRUE, 1, 1, 0 }; 45771d7fec4Smrg MessageType from; 45871d7fec4Smrg int i = 0; 45971d7fec4Smrg GeodePtr pGeode; 46071d7fec4Smrg 46171d7fec4Smrg#if defined(STB_X) 46271d7fec4Smrg GAL_ADAPTERINFO sAdapterInfo; 46371d7fec4Smrg#endif /* STB_X */ 46471d7fec4Smrg unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0; 46571d7fec4Smrg unsigned int minHeight = 0, maxHeight = 0; 46671d7fec4Smrg const char *s; 46771d7fec4Smrg char **modes; 46871d7fec4Smrg char **tvmodes_defa; 46971d7fec4Smrg 47071d7fec4Smrg GeodeDebug(("GX1PreInit!\n")); 47171d7fec4Smrg /* Allocate driver private structure */ 47271d7fec4Smrg if (!(pGeode = GX1GetRec(pScreenInfo))) 47371d7fec4Smrg return FALSE; 47471d7fec4Smrg 47571d7fec4Smrg /* This is the general case */ 47671d7fec4Smrg for (i = 0; i < pScreenInfo->numEntities; i++) { 47771d7fec4Smrg pGeode->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[i]); 47871d7fec4Smrg if (pGeode->pEnt->resources) 47971d7fec4Smrg return FALSE; 48071d7fec4Smrg pGeode->Chipset = pGeode->pEnt->chipset; 48171d7fec4Smrg pScreenInfo->chipset = (char *)xf86TokenToString(GeodeChipsets, 48271d7fec4Smrg pGeode->pEnt->chipset); 48371d7fec4Smrg } 48471d7fec4Smrg 48571d7fec4Smrg if (flags & PROBE_DETECT) { 48671d7fec4Smrg GX1ProbeDDC(pScreenInfo, pGeode->pEnt->index); 48771d7fec4Smrg return TRUE; 48871d7fec4Smrg } 48971d7fec4Smrg 49071d7fec4Smrg pGeode->FBVGAActive = 0; /* KFB will Knock of VGA */ 49171d7fec4Smrg 49271d7fec4Smrg#if !defined(STB_X) 49371d7fec4Smrg /* If the vgahw module would be needed it would be loaded here */ 49471d7fec4Smrg if (!xf86LoadSubModule(pScreenInfo, "vgahw")) { 49571d7fec4Smrg return FALSE; 49671d7fec4Smrg } 49771d7fec4Smrg 49871d7fec4Smrg xf86LoaderReqSymLists(nscVgahwSymbols, NULL); 49971d7fec4Smrg#endif /* STB_X */ 50071d7fec4Smrg GeodeDebug(("GX1PreInit(1)!\n")); 50171d7fec4Smrg 50271d7fec4Smrg /* Do the durango hardware detection */ 50371d7fec4Smrg#if defined(STB_X) 50471d7fec4Smrg if (!Gal_initialize_interface()) 50571d7fec4Smrg return FALSE; 50671d7fec4Smrg if (Gal_get_adapter_info(&sAdapterInfo)) { 50771d7fec4Smrg pGeode->cpu_version = sAdapterInfo.dwCPUVersion; 50871d7fec4Smrg pGeode->vid_version = sAdapterInfo.dwVideoVersion; 50971d7fec4Smrg pGeode->FBSize = sAdapterInfo.dwFrameBufferSize; 51071d7fec4Smrg /* update the max clock from the one system suports */ 51171d7fec4Smrg GeodeClockRange.maxClock = sAdapterInfo.dwMaxSupportedPixelClock; 51271d7fec4Smrg pGeode->FBLinearAddr = sAdapterInfo.dwFrameBufferBase; 51371d7fec4Smrg 51471d7fec4Smrg if (!GX1MapMem(pScreenInfo)) 51571d7fec4Smrg return FALSE; 51671d7fec4Smrg 51771d7fec4Smrg } else { 51871d7fec4Smrg return FALSE; 51971d7fec4Smrg } 52071d7fec4Smrg#else 52171d7fec4Smrg pGeode->cpu_version = gfx_detect_cpu(); 52271d7fec4Smrg pGeode->vid_version = gfx_detect_video(); 52371d7fec4Smrg pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); 52471d7fec4Smrg /* update the max clock from the one system suports */ 52571d7fec4Smrg GeodeClockRange.maxClock = gfx_get_max_supported_pixel_clock(); 52671d7fec4Smrg 52771d7fec4Smrg if (!GX1MapMem(pScreenInfo)) 52871d7fec4Smrg return FALSE; 52971d7fec4Smrg 53071d7fec4Smrg DEBUGMSG(1, 53171d7fec4Smrg (0, X_INFO, 53271d7fec4Smrg "Geode chip info: cpu:%x vid:%x size:%x base:%x, rom:%X\n", 53371d7fec4Smrg pGeode->cpu_version, pGeode->vid_version, pGeode->FBSize, 53471d7fec4Smrg pGeode->FBBase, XpressROMPtr)); 53571d7fec4Smrg#endif /* STB_X */ 53671d7fec4Smrg 53771d7fec4Smrg /* Fill in the monitor field */ 53871d7fec4Smrg pScreenInfo->monitor = pScreenInfo->confScreen->monitor; 53971d7fec4Smrg GeodeDebug(("GX1PreInit(2)!\n")); 54071d7fec4Smrg /* Determine depth, bpp, etc. */ 54171d7fec4Smrg if (!xf86SetDepthBpp(pScreenInfo, 16, 0, 0, 0)) { 54271d7fec4Smrg return FALSE; 54371d7fec4Smrg 54471d7fec4Smrg } else { 54571d7fec4Smrg 54671d7fec4Smrg switch (pScreenInfo->depth) { 54771d7fec4Smrg case 8: 54871d7fec4Smrg case 16: 54971d7fec4Smrg break; 55071d7fec4Smrg default: 55171d7fec4Smrg /* Depth not supported */ 55271d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 55371d7fec4Smrg "Given depth (%d bpp) is not supported by this driver\n", 55471d7fec4Smrg pScreenInfo->depth)); 55571d7fec4Smrg return FALSE; 55671d7fec4Smrg } 55771d7fec4Smrg } 55871d7fec4Smrg 55971d7fec4Smrg /*This must happen after pScreenInfo->display has been set 56071d7fec4Smrg * * because xf86SetWeight references it. 56171d7fec4Smrg */ 56271d7fec4Smrg if (pScreenInfo->depth > 8) { 56371d7fec4Smrg /* The defaults are OK for us */ 56471d7fec4Smrg rgb zeros = { 0, 0, 0 }; 56571d7fec4Smrg 56671d7fec4Smrg if (!xf86SetWeight(pScreenInfo, zeros, zeros)) { 56771d7fec4Smrg return FALSE; 56871d7fec4Smrg } else { 56971d7fec4Smrg /* XXX Check if the returned weight is supported */ 57071d7fec4Smrg } 57171d7fec4Smrg } 57271d7fec4Smrg xf86PrintDepthBpp(pScreenInfo); 57371d7fec4Smrg GeodeDebug(("GX1PreInit(3)!\n")); 57471d7fec4Smrg if (!xf86SetDefaultVisual(pScreenInfo, -1)) 57571d7fec4Smrg return FALSE; 57671d7fec4Smrg GeodeDebug(("GX1PreInit(4)!\n")); 57771d7fec4Smrg 57871d7fec4Smrg /* The new cmap layer needs this to be initialized */ 57971d7fec4Smrg if (pScreenInfo->depth > 1) { 58071d7fec4Smrg Gamma zeros = { 0.0, 0.0, 0.0 }; 58171d7fec4Smrg 58271d7fec4Smrg if (!xf86SetGamma(pScreenInfo, zeros)) { 58371d7fec4Smrg return FALSE; 58471d7fec4Smrg } 58571d7fec4Smrg } 58671d7fec4Smrg GeodeDebug(("GX1PreInit(5)!\n")); 58771d7fec4Smrg /* We use a programmable clock */ 58871d7fec4Smrg pScreenInfo->progClock = TRUE; 58971d7fec4Smrg 59071d7fec4Smrg /*Collect all of the relevant option flags 59171d7fec4Smrg * *(fill in pScreenInfo->options) 59271d7fec4Smrg */ 59371d7fec4Smrg xf86CollectOptions(pScreenInfo, NULL); 59471d7fec4Smrg 59571d7fec4Smrg /*Process the options */ 59671d7fec4Smrg xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, 59771d7fec4Smrg GeodeOptions); 59871d7fec4Smrg 59971d7fec4Smrg /*Set the bits per RGB for 8bpp mode */ 60071d7fec4Smrg if (pScreenInfo->depth == 8) { 60171d7fec4Smrg /* Default to 8 */ 60271d7fec4Smrg pScreenInfo->rgbBits = 8; 60371d7fec4Smrg } 60471d7fec4Smrg from = X_DEFAULT; 60571d7fec4Smrg pGeode->HWCursor = TRUE; 60671d7fec4Smrg /* 60771d7fec4Smrg * *The preferred method is to use the "hw cursor" option as a tri-state 60871d7fec4Smrg * *option, with the default set above. 60971d7fec4Smrg */ 61071d7fec4Smrg if (xf86GetOptValBool(GeodeOptions, OPTION_HW_CURSOR, &pGeode->HWCursor)) { 61171d7fec4Smrg from = X_CONFIG; 61271d7fec4Smrg } 61371d7fec4Smrg /* For compatibility, accept this too (as an override) */ 61471d7fec4Smrg if (xf86ReturnOptValBool(GeodeOptions, OPTION_SW_CURSOR, FALSE)) { 61571d7fec4Smrg from = X_CONFIG; 61671d7fec4Smrg pGeode->HWCursor = FALSE; 61771d7fec4Smrg } 61871d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, from, "Using %s cursor\n", 61971d7fec4Smrg pGeode->HWCursor ? "HW" : "SW")); 62071d7fec4Smrg 62171d7fec4Smrg pGeode->Compression = TRUE; 62271d7fec4Smrg if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOCOMPRESSION, FALSE)) { 62371d7fec4Smrg pGeode->Compression = FALSE; 62471d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "NoCompression\n")); 62571d7fec4Smrg } 62671d7fec4Smrg 62771d7fec4Smrg pGeode->NoAccel = FALSE; 62871d7fec4Smrg if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOACCEL, FALSE)) { 62971d7fec4Smrg pGeode->NoAccel = TRUE; 63071d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Acceleration \ 63171d7fec4Smrg disabled\n")); 63271d7fec4Smrg } 63371d7fec4Smrg 63471d7fec4Smrg if (!xf86GetOptValInteger(GeodeOptions, OPTION_OSM_IMG_BUFS, 63571d7fec4Smrg &(pGeode->NoOfImgBuffers))) 63671d7fec4Smrg pGeode->NoOfImgBuffers = DEFAULT_NUM_OF_BUF; /* default # of buffers */ 63771d7fec4Smrg if (pGeode->NoOfImgBuffers <= 0) 63871d7fec4Smrg pGeode->NoOfImgBuffers = 0; 63971d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "No of Buffers %d\n", 64071d7fec4Smrg pGeode->NoOfImgBuffers)); 64171d7fec4Smrg 64271d7fec4Smrg pGeode->TVSupport = FALSE; 64371d7fec4Smrg 64471d7fec4Smrg pGeode->FBTVActive = 0; 64571d7fec4Smrg GFX(get_tv_enable(&(pGeode->FBTVActive))); 64671d7fec4Smrg DEBUGMSG(1, (1, X_PROBED, "FB TV %d \n", pGeode->FBTVActive)); 64771d7fec4Smrg 64871d7fec4Smrg if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_SUPPORT))) { 64971d7fec4Smrg 65071d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "TV = %s\n", s)); 65171d7fec4Smrg if (!xf86NameCmp(s, "PAL-768x576")) { 65271d7fec4Smrg pGeode->TvParam.wStandard = TV_STANDARD_PAL; 65371d7fec4Smrg pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; 65471d7fec4Smrg pGeode->TvParam.wWidth = 768; 65571d7fec4Smrg pGeode->TvParam.wHeight = 576; 65671d7fec4Smrg pGeode->TVSupport = TRUE; 65771d7fec4Smrg } else if (!xf86NameCmp(s, "PAL-720x576")) { 65871d7fec4Smrg pGeode->TvParam.wStandard = TV_STANDARD_PAL; 65971d7fec4Smrg pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; 66071d7fec4Smrg pGeode->TvParam.wWidth = 720; 66171d7fec4Smrg pGeode->TvParam.wHeight = 576; 66271d7fec4Smrg pGeode->TVSupport = TRUE; 66371d7fec4Smrg } else if (!xf86NameCmp(s, "NTSC-640x480")) { 66471d7fec4Smrg pGeode->TvParam.wStandard = TV_STANDARD_NTSC; 66571d7fec4Smrg pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; 66671d7fec4Smrg pGeode->TvParam.wWidth = 640; 66771d7fec4Smrg pGeode->TvParam.wHeight = 480; 66871d7fec4Smrg pGeode->TVSupport = TRUE; 66971d7fec4Smrg } else if (!xf86NameCmp(s, "NTSC-720x480")) { 67071d7fec4Smrg pGeode->TvParam.wStandard = TV_STANDARD_NTSC; 67171d7fec4Smrg pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; 67271d7fec4Smrg pGeode->TvParam.wWidth = 720; 67371d7fec4Smrg pGeode->TvParam.wHeight = 480; 67471d7fec4Smrg pGeode->TVSupport = TRUE; 67571d7fec4Smrg } 67671d7fec4Smrg 67771d7fec4Smrg if (pGeode->TVSupport == TRUE) { 67871d7fec4Smrg pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; /* default */ 67971d7fec4Smrg 68071d7fec4Smrg /* Now find the output */ 68171d7fec4Smrg if (pGeode->TVSupport) { 68271d7fec4Smrg if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OUTPUT))) { 68371d7fec4Smrg if (!xf86NameCmp(s, "COMPOSITE")) { 68471d7fec4Smrg pGeode->TvParam.wOutput = TV_OUTPUT_COMPOSITE; 68571d7fec4Smrg } else if (!xf86NameCmp(s, "SVIDEO")) { 68671d7fec4Smrg pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; 68771d7fec4Smrg } else if (!xf86NameCmp(s, "YUV")) { 68871d7fec4Smrg pGeode->TvParam.wOutput = TV_OUTPUT_YUV; 68971d7fec4Smrg } else if (!xf86NameCmp(s, "SCART")) { 69071d7fec4Smrg pGeode->TvParam.wOutput = TV_OUTPUT_SCART; 69171d7fec4Smrg } 69271d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 69371d7fec4Smrg "TVOutput = %s %d\n", s, 69471d7fec4Smrg pGeode->TvParam.wOutput)); 69571d7fec4Smrg } 69671d7fec4Smrg } 69771d7fec4Smrg } 69871d7fec4Smrg/* Only SC1200 can support TV modes */ 69971d7fec4Smrg if ((pGeode->vid_version != GFX_VID_SC1200) 70071d7fec4Smrg && (pGeode->TVSupport == TRUE)) { 70171d7fec4Smrg pGeode->TVSupport = FALSE; 70271d7fec4Smrg } 70371d7fec4Smrg 70471d7fec4Smrg /*TV can be turned on only in 16BPP mode */ 70571d7fec4Smrg if ((pScreenInfo->depth == 8) && (pGeode->TVSupport == TRUE)) { 70671d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 70771d7fec4Smrg "Warning TV Disabled, TV Can't be supported in 8Bpp !!!\n")); 70871d7fec4Smrg pGeode->TVSupport = FALSE; 70971d7fec4Smrg } 71071d7fec4Smrg } 71171d7fec4Smrg 71271d7fec4Smrg /* If TV Supported then check for TVO support */ 71371d7fec4Smrg if (pGeode->TVSupport == TRUE) { 71471d7fec4Smrg pGeode->TVOx = 0; 71571d7fec4Smrg pGeode->TVOy = 0; 71671d7fec4Smrg pGeode->TVOw = 0; 71771d7fec4Smrg pGeode->TVOh = 0; 71871d7fec4Smrg pGeode->TV_Overscan_On = FALSE; 71971d7fec4Smrg if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OVERSCAN))) { 72071d7fec4Smrg get_tv_overscan_geom(s, &(pGeode->TVOx), 72171d7fec4Smrg &(pGeode->TVOy), &(pGeode->TVOw), 72271d7fec4Smrg &(pGeode->TVOh)); 72371d7fec4Smrg 72471d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 72571d7fec4Smrg "TVO %d %d %d %d\n", pGeode->TVOx, pGeode->TVOy, 72671d7fec4Smrg pGeode->TVOw, pGeode->TVOh)); 72771d7fec4Smrg 72871d7fec4Smrg if ((pGeode->TVOx >= 0 && pGeode->TVOy >= 0) && 72971d7fec4Smrg (pGeode->TVOh > 0 && pGeode->TVOw > 0)) { 73071d7fec4Smrg if (((pGeode->TVOx + pGeode->TVOw) <= pGeode->TvParam.wWidth) && 73171d7fec4Smrg ((pGeode->TVOy + pGeode->TVOh) <= pGeode->TvParam.wHeight)) { 73271d7fec4Smrg pGeode->TV_Overscan_On = TRUE; 73371d7fec4Smrg } 73471d7fec4Smrg } 73571d7fec4Smrg } 73671d7fec4Smrg } 73771d7fec4Smrg 73871d7fec4Smrg /* If TV is not selected and currently TV is enabled, disable the TV out */ 73971d7fec4Smrg if (pGeode->TVSupport == FALSE) { 74071d7fec4Smrg unsigned int status = 0; 74171d7fec4Smrg 74271d7fec4Smrg GFX(get_tv_enable(&status)); 74371d7fec4Smrg if (status) 74471d7fec4Smrg GFX(set_tv_enable(0)); 74571d7fec4Smrg } 74671d7fec4Smrg 74771d7fec4Smrg pGeode->Panel = FALSE; 74871d7fec4Smrg if (xf86ReturnOptValBool(GeodeOptions, OPTION_FLATPANEL, FALSE)) { 74971d7fec4Smrg DEBUGMSG(0, (pScreenInfo->scrnIndex, X_CONFIG, "FlatPanel Selected\n")); 75071d7fec4Smrg pGeode->Panel = TRUE; 75171d7fec4Smrg } 75271d7fec4Smrg 75371d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 75471d7fec4Smrg "Quering FP Bios %d\n", pGeode->Panel)); 75571d7fec4Smrg 75671d7fec4Smrg /* if FP not supported in BIOS, then turn off user option */ 75771d7fec4Smrg if (pGeode->Panel) { 75871d7fec4Smrg int ret; 75971d7fec4Smrg 76071d7fec4Smrg /* check if bios supports FP */ 76171d7fec4Smrg#if defined(STB_X) 76271d7fec4Smrg Gal_get_softvga_state(&ret); 76371d7fec4Smrg if (!ret) { 76471d7fec4Smrg /* its time to wakeup softvga */ 76571d7fec4Smrg Gal_set_softvga_state(TRUE); 76671d7fec4Smrg Gal_vga_mode_switch(0); 76771d7fec4Smrg } 76871d7fec4Smrg Gal_pnl_enabled_in_bios(&pGeode->Panel); 76971d7fec4Smrg 77071d7fec4Smrg if (pGeode->Panel) { 77171d7fec4Smrg Gal_pnl_info_from_bios(&pGeode->FPBX, &pGeode->FPBY, 77271d7fec4Smrg &pGeode->FPBB, &pGeode->FPBF); 77371d7fec4Smrg } 77471d7fec4Smrg if (!ret) { 77571d7fec4Smrg /* its time to put softvga back to sleep */ 77671d7fec4Smrg Gal_set_softvga_state(FALSE); 77771d7fec4Smrg Gal_vga_mode_switch(1); 77871d7fec4Smrg } 77971d7fec4Smrg#else 78071d7fec4Smrg ret = gfx_get_softvga_active(); 78171d7fec4Smrg if (!ret) { 78271d7fec4Smrg /* its time to wakeup softvga */ 78371d7fec4Smrg gfx_enable_softvga(); 78471d7fec4Smrg gfx_vga_mode_switch(0); 78571d7fec4Smrg } 78671d7fec4Smrg pGeode->Panel = Pnl_IsPanelEnabledInBIOS(); 78771d7fec4Smrg if (pGeode->Panel) { 78871d7fec4Smrg Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, 78971d7fec4Smrg &pGeode->FPBB, &pGeode->FPBF); 79071d7fec4Smrg } 79171d7fec4Smrg if (!ret) { 79271d7fec4Smrg /* its time to put softvga back to sleep */ 79371d7fec4Smrg gfx_disable_softvga(); 79471d7fec4Smrg gfx_vga_mode_switch(1); 79571d7fec4Smrg } 79671d7fec4Smrg#endif 79771d7fec4Smrg } 79871d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 79971d7fec4Smrg "Quering FP Bios %d %d %d %d\n", 80071d7fec4Smrg pGeode->FPBX, pGeode->FPBY, pGeode->FPBB, pGeode->FPBF)); 80171d7fec4Smrg 80271d7fec4Smrg /* if panel not selected and Panel can be supported. 80371d7fec4Smrg * Power down the panel. 80471d7fec4Smrg */ 80571d7fec4Smrg if (!pGeode->Panel) { 80671d7fec4Smrg#if defined(STB_X) 80771d7fec4Smrg Gal_pnl_powerdown(); 80871d7fec4Smrg#else 80971d7fec4Smrg Pnl_PowerDown(); 81071d7fec4Smrg#endif /* STB_X */ 81171d7fec4Smrg } else { 81271d7fec4Smrg#if defined(STB_X) 81371d7fec4Smrg Gal_pnl_powerup(); 81471d7fec4Smrg#else 81571d7fec4Smrg Pnl_PowerUp(); 81671d7fec4Smrg#endif /* STB_X */ 81771d7fec4Smrg } 81871d7fec4Smrg 81971d7fec4Smrg pGeode->ShadowFB = FALSE; 82071d7fec4Smrg if (xf86ReturnOptValBool(GeodeOptions, OPTION_SHADOW_FB, FALSE)) { 82171d7fec4Smrg pGeode->ShadowFB = TRUE; 82271d7fec4Smrg pGeode->NoAccel = TRUE; 82371d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 82471d7fec4Smrg "Using \"Shadow Framebuffer\" - acceleration disabled\n")); 82571d7fec4Smrg } 82671d7fec4Smrg 82771d7fec4Smrg pGeode->Rotate = 0; 82871d7fec4Smrg if ((s = xf86GetOptValString(GeodeOptions, OPTION_ROTATE))) { 82971d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Rotating - %s\n", s)); 83071d7fec4Smrg if (!xf86NameCmp(s, "CW")) { 83171d7fec4Smrg pGeode->ShadowFB = TRUE; 83271d7fec4Smrg pGeode->NoAccel = TRUE; 83371d7fec4Smrg pGeode->HWCursor = FALSE; 83471d7fec4Smrg pGeode->Rotate = 1; 83571d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 83671d7fec4Smrg "Rotating screen clockwise - acceleration disabled\n")); 83771d7fec4Smrg } else { 83871d7fec4Smrg if (!xf86NameCmp(s, "CCW")) { 83971d7fec4Smrg pGeode->ShadowFB = TRUE; 84071d7fec4Smrg pGeode->NoAccel = TRUE; 84171d7fec4Smrg pGeode->HWCursor = FALSE; 84271d7fec4Smrg pGeode->Rotate = -1; 84371d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 84471d7fec4Smrg "Rotating screen counter clockwise - acceleration \ 84571d7fec4Smrg disabled\n")); 84671d7fec4Smrg } else { 84771d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, 84871d7fec4Smrg "\"%s\" is not a valid value for Option \"Rotate\"\n", 84971d7fec4Smrg s)); 85071d7fec4Smrg DEBUGMSG(1, 85171d7fec4Smrg (pScreenInfo->scrnIndex, X_INFO, 85271d7fec4Smrg "Valid options are \"CW\" or \"CCW\"\n")); 85371d7fec4Smrg } 85471d7fec4Smrg } 85571d7fec4Smrg } 85671d7fec4Smrg 85771d7fec4Smrg /* Disable Rotation when TV Over Scan is enabled */ 85871d7fec4Smrg if (pGeode->TV_Overscan_On) 85971d7fec4Smrg pGeode->Rotate = 0; 86071d7fec4Smrg 86171d7fec4Smrg /* XXX Init further private data here */ 86271d7fec4Smrg 86371d7fec4Smrg /* 86471d7fec4Smrg * * This shouldn't happen because such problems should be caught in 86571d7fec4Smrg * * GeodeProbe(), but check it just in case. 86671d7fec4Smrg */ 86771d7fec4Smrg if (pScreenInfo->chipset == NULL) { 86871d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 86971d7fec4Smrg "ChipID 0x%04X is not recognised\n", pGeode->Chipset)); 87071d7fec4Smrg return FALSE; 87171d7fec4Smrg } 87271d7fec4Smrg if (pGeode->Chipset < 0) { 87371d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 87471d7fec4Smrg "Chipset \"%s\" is not recognised\n", 87571d7fec4Smrg pScreenInfo->chipset)); 87671d7fec4Smrg return FALSE; 87771d7fec4Smrg } 87871d7fec4Smrg GeodeDebug(("GX1PreInit(6)!\n")); 87971d7fec4Smrg 88071d7fec4Smrg /* 88171d7fec4Smrg * * Init the screen with some values 88271d7fec4Smrg */ 88371d7fec4Smrg#if !defined(STB_X) 88471d7fec4Smrg 88571d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, from, 88671d7fec4Smrg "Video I/O registers at 0x%08lX\n", 88771d7fec4Smrg (unsigned long)VGAHW_GET_IOBASE())); 88871d7fec4Smrg#endif /* STB_X */ 88971d7fec4Smrg 89071d7fec4Smrg if (pScreenInfo->memPhysBase == 0) { 89171d7fec4Smrg from = X_PROBED; 89271d7fec4Smrg#if defined(STB_X) 89371d7fec4Smrg pScreenInfo->memPhysBase = sAdapterInfo.dwFrameBufferBase; 89471d7fec4Smrg#else /* STB_X */ 89571d7fec4Smrg pScreenInfo->memPhysBase = gfx_get_frame_buffer_base(); 89671d7fec4Smrg#endif /* STB_X */ 89771d7fec4Smrg } 89871d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, from, 89971d7fec4Smrg "Linear framebuffer at 0x%08lX\n", 90071d7fec4Smrg (unsigned long)pScreenInfo->memPhysBase)); 90171d7fec4Smrg 90271d7fec4Smrg if (pGeode->pEnt->device->videoRam == 0) { 90371d7fec4Smrg from = X_PROBED; 90471d7fec4Smrg pScreenInfo->videoRam = pGeode->FBSize / 1024; 90571d7fec4Smrg } else { 90671d7fec4Smrg pScreenInfo->videoRam = pGeode->pEnt->device->videoRam; 90771d7fec4Smrg from = X_CONFIG; 90871d7fec4Smrg } 90971d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, from, 91071d7fec4Smrg "VideoRam: %d kByte\n", 91171d7fec4Smrg (unsigned long)pScreenInfo->videoRam)); 91271d7fec4Smrg 91371d7fec4Smrg GeodeDebug(("GX1PreInit(7)!\n")); 91471d7fec4Smrg 91571d7fec4Smrg /* 91671d7fec4Smrg * * xf86ValidateModes will check that the mode HTotal and VTotal values 91771d7fec4Smrg * * don't exceed the chipset's limit if pScreenInfo->maxHValue adn 91871d7fec4Smrg * * pScreenInfo->maxVValue are set. Since our GX1ValidMode() 91971d7fec4Smrg * * already takes care of this, we don't worry about setting them here. 92071d7fec4Smrg */ 92171d7fec4Smrg /* Select valid modes from those available */ 92271d7fec4Smrg /* 92371d7fec4Smrg * * min pitch 1024, max 2048 (Pixel count) 92471d7fec4Smrg * * min height 480, max 1024 (Pixel count) 92571d7fec4Smrg */ 92671d7fec4Smrg minPitch = 1024; 92771d7fec4Smrg maxPitch = 2048; 92871d7fec4Smrg minHeight = 480; 92971d7fec4Smrg maxHeight = 1024; /* Can support upto 1280x1024 16Bpp */ 93071d7fec4Smrg if (pScreenInfo->depth == 16) { 93171d7fec4Smrg PitchInc = 2048; 93271d7fec4Smrg } else { 93371d7fec4Smrg PitchInc = 1024; 93471d7fec4Smrg } 93571d7fec4Smrg PitchInc <<= 3; /* in bits */ 93671d7fec4Smrg 93771d7fec4Smrg /* by default use what user sets in the XF86Config file */ 93871d7fec4Smrg modes = pScreenInfo->display->modes; 93971d7fec4Smrg if (pGeode->TVSupport == TRUE) { 94071d7fec4Smrg char str[20]; 94171d7fec4Smrg 94271d7fec4Smrg sprintf(str, "%dx%d-%d", 94371d7fec4Smrg pGeode->TvParam.wWidth, 94471d7fec4Smrg pGeode->TvParam.wHeight, 94571d7fec4Smrg ((pGeode->TvParam.wStandard == TV_STANDARD_PAL) ? 50 : 60)); 94671d7fec4Smrg 94771d7fec4Smrg tvmodes_defa = (char **)malloc(sizeof(char *) * 2); 94871d7fec4Smrg tvmodes_defa[0] = (char *)malloc(strlen(str)); 94971d7fec4Smrg tvmodes_defa[1] = NULL; 95071d7fec4Smrg strcpy(str, tvmodes_defa[0]); 95171d7fec4Smrg 95271d7fec4Smrg modes = tvmodes_defa; 95371d7fec4Smrg } 95471d7fec4Smrg 95571d7fec4Smrg i = xf86ValidateModes(pScreenInfo, 95671d7fec4Smrg pScreenInfo->monitor->Modes, 95771d7fec4Smrg modes, 95871d7fec4Smrg &GeodeClockRange, 95971d7fec4Smrg NULL, minPitch, maxPitch, 96071d7fec4Smrg PitchInc, minHeight, maxHeight, 96171d7fec4Smrg pScreenInfo->display->virtualX, 96271d7fec4Smrg pScreenInfo->display->virtualY, 96371d7fec4Smrg#if defined(STB_X) 96471d7fec4Smrg sAdapterInfo.dwFrameBufferSize, 96571d7fec4Smrg#else 96671d7fec4Smrg pGeode->FBSize, 96771d7fec4Smrg#endif /* STB_X */ 96871d7fec4Smrg LOOKUP_BEST_REFRESH); 96971d7fec4Smrg 97071d7fec4Smrg DEBUGMSG(0, (pScreenInfo->scrnIndex, from, 97171d7fec4Smrg "xf86ValidateModes: %d %d %d\n", 97271d7fec4Smrg pScreenInfo->virtualX, 97371d7fec4Smrg pScreenInfo->virtualY, pScreenInfo->displayWidth)); 97471d7fec4Smrg if (i == -1) { 97571d7fec4Smrg GX1FreeRec(pScreenInfo); 97671d7fec4Smrg return FALSE; 97771d7fec4Smrg } 97871d7fec4Smrg GeodeDebug(("GX1PreInit(8)!\n")); 97971d7fec4Smrg /* Prune the modes marked as invalid */ 98071d7fec4Smrg xf86PruneDriverModes(pScreenInfo); 98171d7fec4Smrg GeodeDebug(("GX1PreInit(9)!\n")); 98271d7fec4Smrg if (i == 0 || pScreenInfo->modes == NULL) { 98371d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 98471d7fec4Smrg "No valid modes found\n")); 98571d7fec4Smrg GX1FreeRec(pScreenInfo); 98671d7fec4Smrg return FALSE; 98771d7fec4Smrg } 98871d7fec4Smrg GeodeDebug(("GX1PreInit(10)!\n")); 98971d7fec4Smrg xf86SetCrtcForModes(pScreenInfo, 0); 99071d7fec4Smrg GeodeDebug(("GX1PreInit(11)!\n")); 99171d7fec4Smrg /* Set the current mode to the first in the list */ 99271d7fec4Smrg pScreenInfo->currentMode = pScreenInfo->modes; 99371d7fec4Smrg GeodeDebug(("GX1PreInit(12)!\n")); 99471d7fec4Smrg /* Print the list of modes being used */ 99571d7fec4Smrg xf86PrintModes(pScreenInfo); 99671d7fec4Smrg GeodeDebug(("GX1PreInit(13)!\n")); 99771d7fec4Smrg /* Set the display resolution */ 99871d7fec4Smrg xf86SetDpi(pScreenInfo, 0, 0); 99971d7fec4Smrg GeodeDebug(("GX1PreInit(14)!\n")); 100071d7fec4Smrg 100171d7fec4Smrg if (xf86LoadSubModule(pScreenInfo, "fb") == NULL) { 100271d7fec4Smrg GX1FreeRec(pScreenInfo); 100371d7fec4Smrg return FALSE; 100471d7fec4Smrg } 100571d7fec4Smrg 100671d7fec4Smrg xf86LoaderReqSymLists(nscFbSymbols, NULL); 100771d7fec4Smrg GeodeDebug(("GX1PreInit(15)!\n")); 100871d7fec4Smrg if (pGeode->NoAccel == FALSE) { 100971d7fec4Smrg if (!xf86LoadSubModule(pScreenInfo, "xaa")) { 101071d7fec4Smrg GX1FreeRec(pScreenInfo); 101171d7fec4Smrg return FALSE; 101271d7fec4Smrg } 101371d7fec4Smrg xf86LoaderReqSymLists(nscXaaSymbols, NULL); 101471d7fec4Smrg } 101571d7fec4Smrg GeodeDebug(("GX1PreInit(16)!\n")); 101671d7fec4Smrg if (pGeode->HWCursor == TRUE) { 101771d7fec4Smrg if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { 101871d7fec4Smrg GX1FreeRec(pScreenInfo); 101971d7fec4Smrg return FALSE; 102071d7fec4Smrg } 102171d7fec4Smrg xf86LoaderReqSymLists(nscRamdacSymbols, NULL); 102271d7fec4Smrg } 102371d7fec4Smrg GeodeDebug(("GX1PreInit(17)!\n")); 102471d7fec4Smrg /* Load shadowfb if needed */ 102571d7fec4Smrg if (pGeode->ShadowFB) { 102671d7fec4Smrg if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { 102771d7fec4Smrg GX1FreeRec(pScreenInfo); 102871d7fec4Smrg return FALSE; 102971d7fec4Smrg } 103071d7fec4Smrg xf86LoaderReqSymLists(nscShadowSymbols, NULL); 103171d7fec4Smrg } 103271d7fec4Smrg GeodeDebug(("GX2PreInit(18)!\n")); 103371d7fec4Smrg if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) { 103471d7fec4Smrg DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, 103571d7fec4Smrg "xf86RegisterResources() found resource conflicts\n")); 103671d7fec4Smrg GX1FreeRec(pScreenInfo); 103771d7fec4Smrg return FALSE; 103871d7fec4Smrg } 103971d7fec4Smrg GX1UnmapMem(pScreenInfo); 104071d7fec4Smrg GeodeDebug(("GX1PreInit(19)!\n")); 104171d7fec4Smrg GeodeDebug(("GX1PreInit(20)!\n")); 104271d7fec4Smrg GeodeDebug(("GX1PreInit ... done successfully!\n")); 104371d7fec4Smrg (void) from; 104471d7fec4Smrg return TRUE; 104571d7fec4Smrg} 104671d7fec4Smrg 104771d7fec4Smrg/*---------------------------------------------------------------------------- 104871d7fec4Smrg * GX1RestoreEx. 104971d7fec4Smrg * 105071d7fec4Smrg * Description :This function restores the mode that was saved on server 105171d7fec4Smrg entry 105271d7fec4Smrg * Parameters. 105371d7fec4Smrg * pScreenInfo :Handle to ScreenPtr structure. 105471d7fec4Smrg * Pmode :poits to screen mode 105571d7fec4Smrg * 105671d7fec4Smrg * Returns :none. 105771d7fec4Smrg * 105871d7fec4Smrg * Comments :none. 105971d7fec4Smrg*---------------------------------------------------------------------------- 106071d7fec4Smrg*/ 106171d7fec4Smrgstatic void 106271d7fec4SmrgGX1RestoreEx(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) 106371d7fec4Smrg{ 106471d7fec4Smrg GeodePtr pGeode; 106571d7fec4Smrg 106671d7fec4Smrg GeodeDebug(("GX1RestoreEx!\n")); 106771d7fec4Smrg /* Get driver private structure */ 106871d7fec4Smrg if (!(pGeode = GX1GetRec(pScreenInfo))) 106971d7fec4Smrg return; 107071d7fec4Smrg /* Restore the extended registers */ 107171d7fec4Smrg#if defined(STB_X) 107271d7fec4Smrg pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | 107371d7fec4Smrg GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; 107471d7fec4Smrg Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); 107571d7fec4Smrg#else 107671d7fec4Smrg gfx_vga_restore(&(pGeode->FBgfxVgaRegs), 107771d7fec4Smrg GFX_VGA_FLAG_MISC_OUTPUT | 107871d7fec4Smrg GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); 107971d7fec4Smrg#endif /* STB_X */ 108071d7fec4Smrg} 108171d7fec4Smrg 108271d7fec4Smrg/*---------------------------------------------------------------------------- 108371d7fec4Smrg * GX1CalculatePitchBytes. 108471d7fec4Smrg * 108571d7fec4Smrg * Description :This function restores the mode that was saved on server 108671d7fec4Smrg * 108771d7fec4Smrg * Parameters. 108871d7fec4Smrg * pScreenInfo :Handle to ScreenPtr structure. 108971d7fec4Smrg * Pmode :Points to screenmode 109071d7fec4Smrg * 109171d7fec4Smrg * Returns :none. 109271d7fec4Smrg * 109371d7fec4Smrg * Comments :none. 109471d7fec4Smrg*---------------------------------------------------------------------------- 109571d7fec4Smrg*/ 109671d7fec4Smrgstatic int 109771d7fec4SmrgGX1CalculatePitchBytes(unsigned int width, unsigned int bpp) 109871d7fec4Smrg{ 109971d7fec4Smrg int lineDelta = width * (bpp >> 3); 110071d7fec4Smrg 110171d7fec4Smrg if (width < 640) { 110271d7fec4Smrg /* low resolutions have both pixel and line doubling */ 110371d7fec4Smrg DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n", 110471d7fec4Smrg width, lineDelta)); 110571d7fec4Smrg lineDelta <<= 1; 110671d7fec4Smrg } 110771d7fec4Smrg /* needed in Rotate mode when in accel is turned off */ 110871d7fec4Smrg if (1) { /*!pGeode->NoAccel */ 110971d7fec4Smrg if (lineDelta > 2048) 111071d7fec4Smrg lineDelta = 4096; 111171d7fec4Smrg else if (lineDelta > 1024) 111271d7fec4Smrg lineDelta = 2048; 111371d7fec4Smrg else 111471d7fec4Smrg lineDelta = 1024; 111571d7fec4Smrg } 111671d7fec4Smrg 111771d7fec4Smrg DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta)); 111871d7fec4Smrg 111971d7fec4Smrg return lineDelta; 112071d7fec4Smrg} 112171d7fec4Smrg 112271d7fec4Smrg/*---------------------------------------------------------------------------- 112371d7fec4Smrg * GX1GetRefreshRate. 112471d7fec4Smrg * 112571d7fec4Smrg * Description :This function restores the mode that saved on server 112671d7fec4Smrg * 112771d7fec4Smrg * Parameters. 112871d7fec4Smrg * Pmode :Pointer to the screen modes 112971d7fec4Smrg * 113071d7fec4Smrg * Returns :It returns the selected refresh rate. 113171d7fec4Smrg * 113271d7fec4Smrg * Comments :none. 113371d7fec4Smrg*---------------------------------------------------------------------------- 113471d7fec4Smrg*/ 113571d7fec4Smrgstatic int 113671d7fec4SmrgGX1GetRefreshRate(DisplayModePtr pMode) 113771d7fec4Smrg{ 113871d7fec4Smrg#define THRESHOLD 2 113971d7fec4Smrg unsigned int i; 114071d7fec4Smrg static int validRates[] = { 50, 56, 60, 70, 72, 75, 85 }; /* Hz */ 114171d7fec4Smrg unsigned long dotClock; 114271d7fec4Smrg int refreshRate; 114371d7fec4Smrg int selectedRate; 114471d7fec4Smrg 114571d7fec4Smrg dotClock = pMode->SynthClock * 1000; 114671d7fec4Smrg refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal; 114771d7fec4Smrg 114871d7fec4Smrg if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480)) 114971d7fec4Smrg refreshRate >>= 2; /* double pixel and double scan */ 115071d7fec4Smrg 115171d7fec4Smrg DEBUGMSG(1, (0, X_PROBED, "dotclock %d %d\n", dotClock, refreshRate)); 115271d7fec4Smrg 115371d7fec4Smrg selectedRate = validRates[0]; 115471d7fec4Smrg for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) { 115571d7fec4Smrg if (validRates[i] < (refreshRate + THRESHOLD)) { 115671d7fec4Smrg selectedRate = validRates[i]; 115771d7fec4Smrg } 115871d7fec4Smrg } 115971d7fec4Smrg return selectedRate; 116071d7fec4Smrg} 116171d7fec4Smrg 116271d7fec4Smrgvoid 116371d7fec4Smrggx1_clear_screen(int width, int height) 116471d7fec4Smrg{ 116571d7fec4Smrg /* clean up the frame buffer memory */ 116671d7fec4Smrg GFX(set_solid_pattern(0)); 116771d7fec4Smrg GFX(set_raster_operation(0xF0)); 116871d7fec4Smrg GFX(pattern_fill(0, 0, width, height)); 116971d7fec4Smrg} 117071d7fec4Smrg 117171d7fec4Smrg/*---------------------------------------------------------------------------- 117271d7fec4Smrg * GX1SetMode. 117371d7fec4Smrg * 117471d7fec4Smrg * Description :This function sets parametrs for screen mode 117571d7fec4Smrg * 117671d7fec4Smrg * Parameters. 117771d7fec4Smrg * pScreenInfo :Pointer to the screenInfo structure. 117871d7fec4Smrg * Pmode :Pointer to the screen modes 117971d7fec4Smrg * 118071d7fec4Smrg * Returns :TRUE on success and FALSE on Failure. 118171d7fec4Smrg * 118271d7fec4Smrg * Comments :none. 118371d7fec4Smrg*---------------------------------------------------------------------------- 118471d7fec4Smrg*/ 118571d7fec4Smrg 118671d7fec4Smrgstatic Bool 118771d7fec4SmrgGX1SetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) 118871d7fec4Smrg{ 118971d7fec4Smrg GeodePtr pGeode; 119071d7fec4Smrg 119171d7fec4Smrg /* unsigned int compOffset, compPitch, compSize; */ 119271d7fec4Smrg GeodeDebug(("GX1SetMode!\n")); 119371d7fec4Smrg pGeode = GEODEPTR(pScreenInfo); 119471d7fec4Smrg /* Set the VT semaphore */ 119571d7fec4Smrg pScreenInfo->vtSema = TRUE; 119671d7fec4Smrg DEBUGMSG(1, (0, X_NONE, "Set mode")); 119771d7fec4Smrg /* The timing will be adjusted later */ 119871d7fec4Smrg GeodeDebug(("Set display mode: %dx%d-%d (%dHz)\n", 119971d7fec4Smrg pMode->CrtcHDisplay, 120071d7fec4Smrg pMode->CrtcVDisplay, 120171d7fec4Smrg pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); 120271d7fec4Smrg GeodeDebug(("Before setting the mode\n")); 120371d7fec4Smrg if ((pMode->CrtcHDisplay >= 640) && (pMode->CrtcVDisplay >= 480)) 120471d7fec4Smrg 120571d7fec4Smrg GFX(set_display_bpp(pScreenInfo->bitsPerPixel)); 120671d7fec4Smrg 120771d7fec4Smrg if (pGeode->TVSupport == TRUE) { 120871d7fec4Smrg pGeode->TvParam.bState = 1; /* enable */ 120971d7fec4Smrg /* wWidth and wHeight already set in init. */ 121071d7fec4Smrg#if defined(STB_X) 121171d7fec4Smrg Gal_tv_set_params(GAL_TVSTATE | GAL_TVOUTPUT | 121271d7fec4Smrg GAL_TVFORMAT | GAL_TVRESOLUTION, &(pGeode->TvParam)); 121371d7fec4Smrg#else 121471d7fec4Smrg /* sequence might be important */ 121571d7fec4Smrg gfx_set_tv_display(pGeode->TvParam.wWidth, pGeode->TvParam.wHeight); 121671d7fec4Smrg gfx_set_tv_format((TVStandardType)pGeode->TvParam.wStandard, 121771d7fec4Smrg (GfxOnTVType)pGeode->TvParam.wType); 121871d7fec4Smrg gfx_set_tv_output(pGeode->TvParam.wOutput); 121971d7fec4Smrg gfx_set_tv_enable(pGeode->TvParam.bState); 122071d7fec4Smrg 122171d7fec4Smrg#endif /* STB_X */ 122271d7fec4Smrg } else { /* TV not selected */ 122371d7fec4Smrg 122471d7fec4Smrg DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT or TFT\n")); 122571d7fec4Smrg 122671d7fec4Smrg if (pGeode->Panel) { 122771d7fec4Smrg DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n")); 122871d7fec4Smrg DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n", 122971d7fec4Smrg pGeode->FPBX, pGeode->FPBY, 123071d7fec4Smrg pMode->CrtcHDisplay, 123171d7fec4Smrg pMode->CrtcVDisplay, pScreenInfo->bitsPerPixel)); 123271d7fec4Smrg 123371d7fec4Smrg GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY, 123471d7fec4Smrg pMode->CrtcHDisplay, 123571d7fec4Smrg pMode->CrtcVDisplay, 123671d7fec4Smrg pScreenInfo->bitsPerPixel)); 123771d7fec4Smrg } else { 123871d7fec4Smrg /* display is crt */ 123971d7fec4Smrg DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT\n")); 124071d7fec4Smrg GFX(set_display_mode(pMode->CrtcHDisplay, 124171d7fec4Smrg pMode->CrtcVDisplay, 124271d7fec4Smrg pScreenInfo->bitsPerPixel, 124371d7fec4Smrg GX1GetRefreshRate(pMode))); 124471d7fec4Smrg 124571d7fec4Smrg /* adjust the pitch */ 124671d7fec4Smrg GFX(set_display_pitch(pGeode->Pitch)); 124771d7fec4Smrg 124871d7fec4Smrg } 124971d7fec4Smrg /* enable crt */ 125071d7fec4Smrg GFX(set_crt_enable(CRT_ENABLE)); 125171d7fec4Smrg } 125271d7fec4Smrg 125371d7fec4Smrg GFX(set_display_offset(0L)); 125471d7fec4Smrg GFX(wait_vertical_blank()); 125571d7fec4Smrg 125671d7fec4Smrg /* enable compression if option selected */ 125771d7fec4Smrg if (pGeode->Compression) { 125871d7fec4Smrg /* set the compression parameters,and it will be turned on later. */ 125971d7fec4Smrg#if defined(STB_X) 126071d7fec4Smrg Gal_set_compression_parameters(GAL_COMPRESSION_ALL, 126171d7fec4Smrg pGeode->CBOffset, 126271d7fec4Smrg pGeode->CBPitch, pGeode->CBSize); 126371d7fec4Smrg 126471d7fec4Smrg /* set the compression buffer, all parameters already set */ 126571d7fec4Smrg Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); 126671d7fec4Smrg#else 126771d7fec4Smrg gfx_set_compression_offset(pGeode->CBOffset); 126871d7fec4Smrg gfx_set_compression_pitch(pGeode->CBPitch); 126971d7fec4Smrg gfx_set_compression_size(pGeode->CBSize); 127071d7fec4Smrg 127171d7fec4Smrg /* set the compression buffer, all parameters already set */ 127271d7fec4Smrg gfx_set_compression_enable(1); 127371d7fec4Smrg#endif /* STB_X */ 127471d7fec4Smrg 127571d7fec4Smrg } 127671d7fec4Smrg if (pGeode->HWCursor) { 127771d7fec4Smrg /* Load blank cursor */ 127871d7fec4Smrg GX1LoadCursorImage(pScreenInfo, NULL); 127971d7fec4Smrg GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0)); 128071d7fec4Smrg GFX(set_cursor_enable(1)); 128171d7fec4Smrg } else { 128271d7fec4Smrg GeodeDebug(("GX1RestoreEx ... ")); 128371d7fec4Smrg GX1RestoreEx(pScreenInfo, pMode); 128471d7fec4Smrg GeodeDebug(("done.\n")); 128571d7fec4Smrg } 128671d7fec4Smrg 128771d7fec4Smrg GeodeDebug(("done.\n")); 128871d7fec4Smrg /* Reenable the hardware cursor after the mode switch */ 128971d7fec4Smrg if (pGeode->HWCursor == TRUE) { 129071d7fec4Smrg GeodeDebug(("GX1ShowCursor ... ")); 129171d7fec4Smrg GX1ShowCursor(pScreenInfo); 129271d7fec4Smrg GeodeDebug(("done.\n")); 129371d7fec4Smrg } 129471d7fec4Smrg /* Restore the contents in the screen info */ 129571d7fec4Smrg GeodeDebug(("After setting the mode\n")); 129671d7fec4Smrg return TRUE; 129771d7fec4Smrg} 129871d7fec4Smrg 129971d7fec4Smrg/*---------------------------------------------------------------------------- 130071d7fec4Smrg * GX1EnterGraphics. 130171d7fec4Smrg * 130271d7fec4Smrg * Description :This function will intiallize the displaytiming 130371d7fec4Smrg structure for nextmode and switch to VGA mode. 130471d7fec4Smrg * 130571d7fec4Smrg * Parameters. 130671d7fec4Smrg * pScreen :Screen information will be stored in this structure. 130771d7fec4Smrg * pScreenInfo :Pointer to the screenInfo structure. 130871d7fec4Smrg * 130971d7fec4Smrg * Returns :TRUE on success and FALSE on Failure. 131071d7fec4Smrg * 131171d7fec4Smrg * Comments :gfx_vga_mode_switch() will start and end the 131271d7fec4Smrg * switching based on the arguments 0 or 1.soft_vga 131371d7fec4Smrg * is disabled in this function. 131471d7fec4Smrg*---------------------------------------------------------------------------- 131571d7fec4Smrg*/ 131671d7fec4Smrgstatic Bool 131771d7fec4SmrgGX1EnterGraphics(ScreenPtr pScreen, ScrnInfoPtr pScreenInfo) 131871d7fec4Smrg{ 131971d7fec4Smrg GeodePtr pGeode; 132071d7fec4Smrg 132171d7fec4Smrg#if !defined(STB_X) 132271d7fec4Smrg 132371d7fec4Smrg vgaHWPtr hwp = VGAHWPTR(pScreenInfo); 132471d7fec4Smrg 132571d7fec4Smrg vgaHWUnlock(hwp); 132671d7fec4Smrg#endif 132771d7fec4Smrg 132871d7fec4Smrg GeodeDebug(("GX1EnterGraphics!\n")); 132971d7fec4Smrg 133071d7fec4Smrg DEBUGMSG(1, (0, X_NONE, "EnterGraphics\n")); 133171d7fec4Smrg /* Should we re-save the text mode on each VT enter? */ 133271d7fec4Smrg pGeode = GX1GetRec(pScreenInfo); 133371d7fec4Smrg#if 0 133471d7fec4Smrg print_gxm_gfx_reg(pGeode, 0x4C); 133571d7fec4Smrg print_gxm_vga_reg(); 133671d7fec4Smrg#endif 133771d7fec4Smrg /* This routine saves the current VGA state in Durango VGA structure */ 133871d7fec4Smrg#if defined(STB_X) 133971d7fec4Smrg Gal_get_softvga_state(&pGeode->FBVGAActive); 134071d7fec4Smrg pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | 134171d7fec4Smrg GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; 134271d7fec4Smrg Gal_vga_save(&(pGeode->FBgfxVgaRegs)); 134371d7fec4Smrg#else 134471d7fec4Smrg pGeode->FBVGAActive = gfx_get_softvga_active(); 134571d7fec4Smrg gfx_vga_save(&(pGeode->FBgfxVgaRegs), 134671d7fec4Smrg GFX_VGA_FLAG_MISC_OUTPUT | 134771d7fec4Smrg GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); 134871d7fec4Smrg#endif /* STB_X */ 134971d7fec4Smrg DEBUGMSG(1, (0, X_PROBED, "VSA = %d\n", pGeode->FBVGAActive)); 135071d7fec4Smrg 135171d7fec4Smrg#if !defined(STB_X) 135271d7fec4Smrg 135371d7fec4Smrg vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); 135471d7fec4Smrg#endif 135571d7fec4Smrg 135671d7fec4Smrg#if defined(STB_X) 135771d7fec4Smrg Gal_get_display_timing(&pGeode->FBgfxdisplaytiming); 135871d7fec4Smrg Gal_tv_get_timings(0, &pGeode->FBgfxtvtiming); 135971d7fec4Smrg 136071d7fec4Smrg /* Save Display offset */ 136171d7fec4Smrg Gal_get_display_offset(&(pGeode->FBDisplayOffset)); 136271d7fec4Smrg 136371d7fec4Smrg /* Save the current Compression state */ 136471d7fec4Smrg Gal_get_compression_enable(&(pGeode->FBCompressionEnable)); 136571d7fec4Smrg Gal_get_compression_parameters(GAL_COMPRESSION_ALL, 136671d7fec4Smrg &(pGeode->FBCompressionOffset), 136771d7fec4Smrg &(pGeode->FBCompressionPitch), 136871d7fec4Smrg &(pGeode->FBCompressionSize)); 136971d7fec4Smrg 137071d7fec4Smrg /* Save Cursor offset */ 137171d7fec4Smrg { 137271d7fec4Smrg unsigned short x, y, xhot, yhot; 137371d7fec4Smrg 137471d7fec4Smrg Gal_get_cursor_position(&(pGeode->FBCursorOffset), 137571d7fec4Smrg &x, &y, &xhot, &yhot); 137671d7fec4Smrg } 137771d7fec4Smrg /* Save the Panel state */ 137871d7fec4Smrg Gal_pnl_save(); 137971d7fec4Smrg 138071d7fec4Smrg /* its time to put softvga to sleep */ 138171d7fec4Smrg Gal_set_softvga_state(FALSE); 138271d7fec4Smrg Gal_vga_mode_switch(1); 138371d7fec4Smrg 138471d7fec4Smrg#else 138571d7fec4Smrg /* Save TV State */ 138671d7fec4Smrg gfx_get_tv_enable(&(pGeode->FBTVEnabled)); 138771d7fec4Smrg if (pGeode->FBTVEnabled) { 138871d7fec4Smrg /* TV Format */ 138971d7fec4Smrg pGeode->FBtvtiming.HorzTim = READ_VID32(SC1200_TVOUT_HORZ_TIM); 139071d7fec4Smrg pGeode->FBtvtiming.HorzSync = READ_VID32(SC1200_TVOUT_HORZ_SYNC); 139171d7fec4Smrg pGeode->FBtvtiming.VertSync = READ_VID32(SC1200_TVOUT_VERT_SYNC); 139271d7fec4Smrg pGeode->FBtvtiming.LineEnd = READ_VID32(SC1200_TVOUT_LINE_END); 139371d7fec4Smrg pGeode->FBtvtiming.VertDownscale = 139471d7fec4Smrg READ_VID32(SC1200_TVOUT_VERT_DOWNSCALE); 139571d7fec4Smrg pGeode->FBtvtiming.HorzScaling = READ_VID32(SC1200_TVOUT_HORZ_SCALING); 139671d7fec4Smrg pGeode->FBtvtiming.TimCtrl1 = READ_VID32(SC1200_TVENC_TIM_CTRL_1); 139771d7fec4Smrg pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); 139871d7fec4Smrg pGeode->FBtvtiming.Subfreq = READ_VID32(SC1200_TVENC_SUB_FREQ); 139971d7fec4Smrg pGeode->FBtvtiming.DispPos = READ_VID32(SC1200_TVENC_DISP_POS); 140071d7fec4Smrg pGeode->FBtvtiming.DispSize = READ_VID32(SC1200_TVENC_DISP_SIZE); 140171d7fec4Smrg /* TV Output */ 140271d7fec4Smrg pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); 140371d7fec4Smrg pGeode->FBtvtiming.Debug = READ_VID32(SC1200_TVOUT_DEBUG); 140471d7fec4Smrg /* TV Enable */ 140571d7fec4Smrg pGeode->FBtvtiming.DacCtrl = READ_VID32(SC1200_TVENC_DAC_CONTROL); 140671d7fec4Smrg } 140771d7fec4Smrg 140871d7fec4Smrg /* Save CRT State */ 140971d7fec4Smrg pGeode->FBgfxdisplaytiming.dwDotClock = gfx_get_clock_frequency(); 141071d7fec4Smrg pGeode->FBgfxdisplaytiming.wPitch = gfx_get_display_pitch(); 141171d7fec4Smrg pGeode->FBgfxdisplaytiming.wBpp = gfx_get_display_bpp(); 141271d7fec4Smrg pGeode->FBgfxdisplaytiming.wHTotal = gfx_get_htotal(); 141371d7fec4Smrg pGeode->FBgfxdisplaytiming.wHActive = gfx_get_hactive(); 141471d7fec4Smrg pGeode->FBgfxdisplaytiming.wHSyncStart = gfx_get_hsync_start(); 141571d7fec4Smrg pGeode->FBgfxdisplaytiming.wHSyncEnd = gfx_get_hsync_end(); 141671d7fec4Smrg pGeode->FBgfxdisplaytiming.wHBlankStart = gfx_get_hblank_start(); 141771d7fec4Smrg pGeode->FBgfxdisplaytiming.wHBlankEnd = gfx_get_hblank_end(); 141871d7fec4Smrg pGeode->FBgfxdisplaytiming.wVTotal = gfx_get_vtotal(); 141971d7fec4Smrg pGeode->FBgfxdisplaytiming.wVActive = gfx_get_vactive(); 142071d7fec4Smrg pGeode->FBgfxdisplaytiming.wVSyncStart = gfx_get_vsync_start(); 142171d7fec4Smrg pGeode->FBgfxdisplaytiming.wVSyncEnd = gfx_get_vsync_end(); 142271d7fec4Smrg pGeode->FBgfxdisplaytiming.wVBlankStart = gfx_get_vblank_start(); 142371d7fec4Smrg pGeode->FBgfxdisplaytiming.wVBlankEnd = gfx_get_vblank_end(); 142471d7fec4Smrg pGeode->FBgfxdisplaytiming.wPolarity = gfx_get_sync_polarities(); 142571d7fec4Smrg 142671d7fec4Smrg /* Save Display offset */ 142771d7fec4Smrg pGeode->FBDisplayOffset = gfx_get_display_offset(); 142871d7fec4Smrg 142971d7fec4Smrg /* Save the current Compression state */ 143071d7fec4Smrg pGeode->FBCompressionEnable = gfx_get_compression_enable(); 143171d7fec4Smrg pGeode->FBCompressionOffset = gfx_get_compression_offset(); 143271d7fec4Smrg pGeode->FBCompressionPitch = gfx_get_compression_pitch(); 143371d7fec4Smrg pGeode->FBCompressionSize = gfx_get_compression_size(); 143471d7fec4Smrg 143571d7fec4Smrg /* Save Cursor offset */ 143671d7fec4Smrg pGeode->FBCursorOffset = gfx_get_cursor_offset(); 143771d7fec4Smrg 143871d7fec4Smrg /* Save the Panel state */ 143971d7fec4Smrg Pnl_SavePanelState(); 144071d7fec4Smrg 144171d7fec4Smrg /* its time to put softvga to sleep */ 144271d7fec4Smrg gfx_disable_softvga(); 144371d7fec4Smrg gfx_vga_mode_switch(1); 144471d7fec4Smrg 144571d7fec4Smrg#endif /* STB_X */ 144671d7fec4Smrg 144771d7fec4Smrg if (!GX1SetMode(pScreenInfo, pScreenInfo->currentMode)) { 144871d7fec4Smrg return FALSE; 144971d7fec4Smrg } 145071d7fec4Smrg#if 1 145171d7fec4Smrg /* clear the frame buffer, for annoying noise during mode switch */ 145271d7fec4Smrg gx1_clear_screen(pScreenInfo->currentMode->CrtcHDisplay, 145371d7fec4Smrg pScreenInfo->currentMode->CrtcVDisplay); 145471d7fec4Smrg#endif 145571d7fec4Smrg return TRUE; 145671d7fec4Smrg} 145771d7fec4Smrg 145871d7fec4Smrg/*---------------------------------------------------------------------------- 145971d7fec4Smrg * GX1LeaveGraphics: 146071d7fec4Smrg * 146171d7fec4Smrg * Description :This function will restore the displaymode parameters 146271d7fec4Smrg * and switches the VGA mode 146371d7fec4Smrg * 146471d7fec4Smrg * Parameters. 146571d7fec4Smrg * pScreen :Screen information will be stored in this structure. 146671d7fec4Smrg * pScreenInfo :Pointer to the screenInfo structure. 146771d7fec4Smrg * 146871d7fec4Smrg * 146971d7fec4Smrg * Returns :none. 147071d7fec4Smrg * 147171d7fec4Smrg * Comments : gfx_vga_mode_switch() will start and end the switching 147271d7fec4Smrg * based on the arguments 0 or 1.soft_vga is disabled in 147371d7fec4Smrg * this function. 147471d7fec4Smrg*---------------------------------------------------------------------------- 147571d7fec4Smrg*/ 147671d7fec4Smrgstatic void 147771d7fec4SmrgGX1LeaveGraphics(ScrnInfoPtr pScreenInfo) 147871d7fec4Smrg{ 147971d7fec4Smrg GeodePtr pGeode; 148071d7fec4Smrg 148171d7fec4Smrg GeodeDebug(("GX1LeaveGraphics!\n")); 148271d7fec4Smrg pGeode = GEODEPTR(pScreenInfo); 148371d7fec4Smrg 148471d7fec4Smrg if (!pGeode->FBTVActive) { 148571d7fec4Smrg GFX(set_tv_enable(0)); 148671d7fec4Smrg } 148771d7fec4Smrg /* clear the frame buffer, when leaving X */ 148871d7fec4Smrg gx1_clear_screen(pScreenInfo->virtualX, pScreenInfo->virtualY); 148971d7fec4Smrg 149071d7fec4Smrg#if defined(STB_X) 149171d7fec4Smrg Gal_set_display_timing(&pGeode->FBgfxdisplaytiming); 149271d7fec4Smrg Gal_tv_set_timings(0, &pGeode->FBgfxtvtiming); 149371d7fec4Smrg Gal_set_display_offset(pGeode->FBDisplayOffset); 149471d7fec4Smrg 149571d7fec4Smrg /* Restore Cursor */ 149671d7fec4Smrg Gal_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); 149771d7fec4Smrg 149871d7fec4Smrg /* Restore the previous Compression state */ 149971d7fec4Smrg if (pGeode->FBCompressionEnable) { 150071d7fec4Smrg Gal_set_compression_parameters(GAL_COMPRESSION_ALL, 150171d7fec4Smrg pGeode->FBCompressionOffset, 150271d7fec4Smrg pGeode->FBCompressionPitch, 150371d7fec4Smrg pGeode->FBCompressionSize); 150471d7fec4Smrg 150571d7fec4Smrg Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); 150671d7fec4Smrg } 150771d7fec4Smrg#else 150871d7fec4Smrg /* Restore TV */ 150971d7fec4Smrg if (pGeode->FBTVEnabled) { 151071d7fec4Smrg /* TV Format */ 151171d7fec4Smrg WRITE_VID32(SC1200_TVOUT_HORZ_TIM, pGeode->FBtvtiming.HorzTim); 151271d7fec4Smrg WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, pGeode->FBtvtiming.HorzSync); 151371d7fec4Smrg WRITE_VID32(SC1200_TVOUT_VERT_SYNC, pGeode->FBtvtiming.VertSync); 151471d7fec4Smrg WRITE_VID32(SC1200_TVOUT_LINE_END, pGeode->FBtvtiming.LineEnd); 151571d7fec4Smrg WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, 151671d7fec4Smrg pGeode->FBtvtiming.VertDownscale); 151771d7fec4Smrg WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, pGeode->FBtvtiming.HorzScaling); 151871d7fec4Smrg WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, pGeode->FBtvtiming.TimCtrl1); 151971d7fec4Smrg WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); 152071d7fec4Smrg WRITE_VID32(SC1200_TVENC_SUB_FREQ, pGeode->FBtvtiming.Subfreq); 152171d7fec4Smrg WRITE_VID32(SC1200_TVENC_DISP_POS, pGeode->FBtvtiming.DispPos); 152271d7fec4Smrg WRITE_VID32(SC1200_TVENC_DISP_SIZE, pGeode->FBtvtiming.DispSize); 152371d7fec4Smrg /* TV Output */ 152471d7fec4Smrg WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); 152571d7fec4Smrg /* WRITE_VID32(SC1200_TVENC_DAC_CONTROL, tmp); */ 152671d7fec4Smrg WRITE_VID32(SC1200_TVOUT_DEBUG, pGeode->FBtvtiming.Debug); 152771d7fec4Smrg /* TV Enable */ 152871d7fec4Smrg WRITE_VID32(SC1200_TVENC_DAC_CONTROL, pGeode->FBtvtiming.DacCtrl); 152971d7fec4Smrg } 153071d7fec4Smrg 153171d7fec4Smrg /* Restore CRT */ 153271d7fec4Smrg gfx_set_display_timings(pGeode->FBgfxdisplaytiming.wBpp, 153371d7fec4Smrg pGeode->FBgfxdisplaytiming.wPolarity, 153471d7fec4Smrg pGeode->FBgfxdisplaytiming.wHActive, 153571d7fec4Smrg pGeode->FBgfxdisplaytiming.wHBlankStart, 153671d7fec4Smrg pGeode->FBgfxdisplaytiming.wHSyncStart, 153771d7fec4Smrg pGeode->FBgfxdisplaytiming.wHSyncEnd, 153871d7fec4Smrg pGeode->FBgfxdisplaytiming.wHBlankEnd, 153971d7fec4Smrg pGeode->FBgfxdisplaytiming.wHTotal, 154071d7fec4Smrg pGeode->FBgfxdisplaytiming.wVActive, 154171d7fec4Smrg pGeode->FBgfxdisplaytiming.wVBlankStart, 154271d7fec4Smrg pGeode->FBgfxdisplaytiming.wVSyncStart, 154371d7fec4Smrg pGeode->FBgfxdisplaytiming.wVSyncEnd, 154471d7fec4Smrg pGeode->FBgfxdisplaytiming.wVBlankEnd, 154571d7fec4Smrg pGeode->FBgfxdisplaytiming.wVTotal, 154671d7fec4Smrg pGeode->FBgfxdisplaytiming.dwDotClock); 154771d7fec4Smrg 154871d7fec4Smrg gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch); 154971d7fec4Smrg 155071d7fec4Smrg gfx_set_display_offset(pGeode->FBDisplayOffset); 155171d7fec4Smrg 155271d7fec4Smrg /* Restore Cursor */ 155371d7fec4Smrg gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); 155471d7fec4Smrg 155571d7fec4Smrg /* Restore the previous Compression state */ 155671d7fec4Smrg if (pGeode->FBCompressionEnable) { 155771d7fec4Smrg gfx_set_compression_offset(pGeode->FBCompressionOffset); 155871d7fec4Smrg gfx_set_compression_pitch(pGeode->FBCompressionPitch); 155971d7fec4Smrg gfx_set_compression_size(pGeode->FBCompressionSize); 156071d7fec4Smrg gfx_set_compression_enable(1); 156171d7fec4Smrg } 156271d7fec4Smrg#endif /* STB_X */ 156371d7fec4Smrg 156471d7fec4Smrg /* We need this to get back to vga mode when soft-vga 156571d7fec4Smrg * * kicks in. 156671d7fec4Smrg * * We actually need to examine the attribute Ctlr to find out 156771d7fec4Smrg * * what kinda crap (grafix or text) we need to enter in 156871d7fec4Smrg * * For now just lookout for 720x400 156971d7fec4Smrg */ 157071d7fec4Smrg#if 0 157171d7fec4Smrg if ((pGeode->FBgfxdisplaytiming.wHActive == 720) && 157271d7fec4Smrg (pGeode->FBgfxdisplaytiming.wVActive == 400)) 157371d7fec4Smrg#else 157471d7fec4Smrg if (pGeode->FBVGAActive) 157571d7fec4Smrg#endif 157671d7fec4Smrg { 157771d7fec4Smrg /* VSA was active before we started. Since we disabled it 157871d7fec4Smrg * we got to enable it */ 157971d7fec4Smrg#if defined(STB_X) 158071d7fec4Smrg Gal_set_softvga_state(TRUE); 158171d7fec4Smrg Gal_vga_mode_switch(1); 158271d7fec4Smrg Gal_vga_clear_extended(); 158371d7fec4Smrg#else 158471d7fec4Smrg gfx_enable_softvga(); 158571d7fec4Smrg gfx_vga_mode_switch(1); 158671d7fec4Smrg gfx_vga_clear_extended(); 158771d7fec4Smrg#endif /* STB_X */ 158871d7fec4Smrg 158971d7fec4Smrg#if !defined(STB_X) 159071d7fec4Smrg 159171d7fec4Smrg vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); 159271d7fec4Smrg#endif 159371d7fec4Smrg 159471d7fec4Smrg#if defined(STB_X) 159571d7fec4Smrg pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | 159671d7fec4Smrg GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; 159771d7fec4Smrg Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); 159871d7fec4Smrg Gal_vga_mode_switch(0); 159971d7fec4Smrg#else 160071d7fec4Smrg gfx_vga_restore(&(pGeode->FBgfxVgaRegs), 160171d7fec4Smrg GFX_VGA_FLAG_MISC_OUTPUT | 160271d7fec4Smrg GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); 160371d7fec4Smrg gfx_vga_mode_switch(0); 160471d7fec4Smrg#endif /* STB_X */ 160571d7fec4Smrg } 160671d7fec4Smrg#if 0 160771d7fec4Smrg print_gxm_gfx_reg(pGeode, 0x4C); 160871d7fec4Smrg print_gxm_vga_reg(); 160971d7fec4Smrg#endif 161071d7fec4Smrg} 161171d7fec4Smrg 161271d7fec4Smrg/*---------------------------------------------------------------------------- 161371d7fec4Smrg * GX1CloseScreen. 161471d7fec4Smrg * 161571d7fec4Smrg * Description :This function will restore the original mode 161671d7fec4Smrg * and also it unmap video memory 161771d7fec4Smrg * 161871d7fec4Smrg * Parameters. 161971d7fec4Smrg * ScrnIndex :Screen index value of the screen will be closed. 162071d7fec4Smrg * pScreen :Pointer to the screen structure. 162171d7fec4Smrg * 162271d7fec4Smrg * 162371d7fec4Smrg * Returns :TRUE on success and FALSE on Failure. 162471d7fec4Smrg * 162571d7fec4Smrg * Comments :none. 162671d7fec4Smrg*---------------------------------------------------------------------------- 162771d7fec4Smrg*/ 162871d7fec4Smrgstatic Bool 162971d7fec4SmrgGX1CloseScreen(int scrnIndex, ScreenPtr pScreen) 163071d7fec4Smrg{ 163171d7fec4Smrg ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 163271d7fec4Smrg GeodePtr pGeode = GEODEPTR(pScreenInfo); 163371d7fec4Smrg 163471d7fec4Smrg DEBUGMSG(1, (scrnIndex, X_PROBED, "GX1CloseScreen\n")); 163571d7fec4Smrg GeodeDebug(("GX1CloseScreen!\n")); 163671d7fec4Smrg GX1LeaveGraphics(pScreenInfo); 163771d7fec4Smrg if (pGeode->AccelInfoRec) 163871d7fec4Smrg XAADestroyInfoRec(pGeode->AccelInfoRec); 163971d7fec4Smrg pScreenInfo->vtSema = FALSE; 164071d7fec4Smrg if (pGeode->DGAModes) 164171d7fec4Smrg xfree(pGeode->DGAModes); 164271d7fec4Smrg pGeode->DGAModes = 0; 164371d7fec4Smrg if (pGeode->ShadowPtr) 164471d7fec4Smrg xfree(pGeode->ShadowPtr); 164571d7fec4Smrg 164671d7fec4Smrg if (pGeode->AccelImageWriteBufferOffsets) { 164771d7fec4Smrg xfree(pGeode->AccelImageWriteBufferOffsets); 164871d7fec4Smrg pGeode->AccelImageWriteBufferOffsets = 0x0; 164971d7fec4Smrg } 165071d7fec4Smrg /* free the allocated off screen area */ 165171d7fec4Smrg xf86FreeOffscreenArea(pGeode->AccelImgArea); 165271d7fec4Smrg xf86FreeOffscreenArea(pGeode->CompressionArea); 165371d7fec4Smrg 165471d7fec4Smrg GX1UnmapMem(pScreenInfo); 165571d7fec4Smrg 165671d7fec4Smrg pScreen->CloseScreen = pGeode->CloseScreen; 165771d7fec4Smrg return (*pScreen->CloseScreen) (scrnIndex, pScreen); 165871d7fec4Smrg 165971d7fec4Smrg} 166071d7fec4Smrg 166171d7fec4Smrg/*---------------------------------------------------------------------------- 166271d7fec4Smrg * GX1DPMSet. 166371d7fec4Smrg * 166471d7fec4Smrg * Description :This function sets geode into Power Management 166571d7fec4Smrg * Signalling mode. 166671d7fec4Smrg * 166771d7fec4Smrg * Parameters. 166871d7fec4Smrg * pScreenInfo :Pointer to screen info strucrure. 166971d7fec4Smrg * mode :Specifies the power management mode. 167071d7fec4Smrg * 167171d7fec4Smrg * Returns :none. 167271d7fec4Smrg * 167371d7fec4Smrg * Comments :none. 167471d7fec4Smrg*---------------------------------------------------------------------------- 167571d7fec4Smrg*/ 167671d7fec4Smrgstatic void 167771d7fec4SmrgGX1DPMSSet(ScrnInfoPtr pScreenInfo, int mode, int flags) 167871d7fec4Smrg{ 167971d7fec4Smrg GeodePtr pGeode; 168071d7fec4Smrg 168171d7fec4Smrg pGeode = GEODEPTR(pScreenInfo); 168271d7fec4Smrg 168371d7fec4Smrg GeodeDebug(("GX1DPMSSet!\n")); 168471d7fec4Smrg 168571d7fec4Smrg /* Check if we are actively controlling the display */ 168671d7fec4Smrg if (!pScreenInfo->vtSema) { 168771d7fec4Smrg ErrorF("GX1DPMSSet called when we not controlling the VT!\n"); 168871d7fec4Smrg return; 168971d7fec4Smrg } 169071d7fec4Smrg switch (mode) { 169171d7fec4Smrg case DPMSModeOn: 169271d7fec4Smrg /* Screen: On; HSync: On; VSync: On */ 169371d7fec4Smrg GFX(set_crt_enable(CRT_ENABLE)); 169471d7fec4Smrg#if defined(STB_X) 169571d7fec4Smrg if (pGeode->Panel) 169671d7fec4Smrg Gal_pnl_powerup(); 169771d7fec4Smrg#else 169871d7fec4Smrg if (pGeode->Panel) 169971d7fec4Smrg Pnl_PowerUp(); 170071d7fec4Smrg#endif /* STB_X */ 170171d7fec4Smrg if (pGeode->TVSupport) 170271d7fec4Smrg GFX(set_tv_enable(1)); 170371d7fec4Smrg break; 170471d7fec4Smrg 170571d7fec4Smrg case DPMSModeStandby: 170671d7fec4Smrg /* Screen: Off; HSync: Off; VSync: On */ 170771d7fec4Smrg GFX(set_crt_enable(CRT_STANDBY)); 170871d7fec4Smrg#if defined(STB_X) 170971d7fec4Smrg if (pGeode->Panel) 171071d7fec4Smrg Gal_pnl_powerdown(); 171171d7fec4Smrg#else 171271d7fec4Smrg if (pGeode->Panel) 171371d7fec4Smrg Pnl_PowerDown(); 171471d7fec4Smrg#endif /* STB_X */ 171571d7fec4Smrg if (pGeode->TVSupport) 171671d7fec4Smrg GFX(set_tv_enable(0)); 171771d7fec4Smrg break; 171871d7fec4Smrg 171971d7fec4Smrg case DPMSModeSuspend: 172071d7fec4Smrg /* Screen: Off; HSync: On; VSync: Off */ 172171d7fec4Smrg GFX(set_crt_enable(CRT_SUSPEND)); 172271d7fec4Smrg#if defined(STB_X) 172371d7fec4Smrg if (pGeode->Panel) 172471d7fec4Smrg Gal_pnl_powerdown(); 172571d7fec4Smrg#else 172671d7fec4Smrg if (pGeode->Panel) 172771d7fec4Smrg Pnl_PowerDown(); 172871d7fec4Smrg#endif /* STB_X */ 172971d7fec4Smrg if (pGeode->TVSupport) 173071d7fec4Smrg GFX(set_tv_enable(0)); 173171d7fec4Smrg break; 173271d7fec4Smrg case DPMSModeOff: 173371d7fec4Smrg /* Screen: Off; HSync: Off; VSync: Off */ 173471d7fec4Smrg GFX(set_crt_enable(CRT_DISABLE)); 173571d7fec4Smrg#if defined(STB_X) 173671d7fec4Smrg if (pGeode->Panel) 173771d7fec4Smrg Gal_pnl_powerdown(); 173871d7fec4Smrg#else 173971d7fec4Smrg if (pGeode->Panel) 174071d7fec4Smrg Pnl_PowerDown(); 174171d7fec4Smrg#endif /* STB_X */ 174271d7fec4Smrg if (pGeode->TVSupport) 174371d7fec4Smrg GFX(set_tv_enable(0)); 174471d7fec4Smrg break; 174571d7fec4Smrg } 174671d7fec4Smrg} 174771d7fec4Smrg 174871d7fec4Smrg/*---------------------------------------------------------------------------- 174971d7fec4Smrg * GX1ScreenInit. 175071d7fec4Smrg * 175171d7fec4Smrg * Description :This function will be called at the each ofserver 175271d7fec4Smrg * generation. 175371d7fec4Smrg * 175471d7fec4Smrg * Parameters. 175571d7fec4Smrg * scrnIndex :Specfies the screenindex value during generation. 175671d7fec4Smrg * pScreen :Pointer to screen info strucrure. 175771d7fec4Smrg * argc :parameters for command line arguments count 175871d7fec4Smrg * argv :command line arguments if any it is not used. 175971d7fec4Smrg * 176071d7fec4Smrg * Returns :none. 176171d7fec4Smrg * 176271d7fec4Smrg * Comments :none. 176371d7fec4Smrg*---------------------------------------------------------------------------- 176471d7fec4Smrg*/ 176571d7fec4Smrgstatic Bool 176671d7fec4SmrgGX1ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) 176771d7fec4Smrg{ 176871d7fec4Smrg ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; 176971d7fec4Smrg GeodePtr pGeode; 177071d7fec4Smrg int i; 177171d7fec4Smrg Bool Inited = FALSE; 177271d7fec4Smrg unsigned char *FBStart; 177371d7fec4Smrg unsigned int req_offscreenmem; 177471d7fec4Smrg int width, height, displayWidth; 177571d7fec4Smrg VisualPtr visual; 177671d7fec4Smrg BoxRec AvailBox; 177771d7fec4Smrg RegionRec OffscreenRegion; 177871d7fec4Smrg 177971d7fec4Smrg DCount = 30; 178071d7fec4Smrg 178171d7fec4Smrg GeodeDebug(("GX1ScreenInit!\n")); 178271d7fec4Smrg /* Get driver private */ 178371d7fec4Smrg pGeode = GX1GetRec(pScreenInfo); 178471d7fec4Smrg GeodeDebug(("GX1ScreenInit(0)!\n")); 178571d7fec4Smrg 178671d7fec4Smrg#if !defined(STB_X) 178771d7fec4Smrg /* 178871d7fec4Smrg * * Allocate a vgaHWRec 178971d7fec4Smrg */ 179071d7fec4Smrg if (!vgaHWGetHWRec(pScreenInfo)) 179171d7fec4Smrg return FALSE; 179271d7fec4Smrg VGAHWPTR(pScreenInfo)->MapSize = 0x10000; /* Standard 64k VGA window */ 179371d7fec4Smrg if (!vgaHWMapMem(pScreenInfo)) 179471d7fec4Smrg return FALSE; 179571d7fec4Smrg#endif 179671d7fec4Smrg 179771d7fec4Smrg if (!GX1MapMem(pScreenInfo)) 179871d7fec4Smrg return FALSE; 179971d7fec4Smrg 180071d7fec4Smrg#if !defined(STB_X) 180171d7fec4Smrg vgaHWGetIOBase(VGAHWPTR(pScreenInfo)); 180271d7fec4Smrg#endif 180371d7fec4Smrg 180471d7fec4Smrg pGeode->Pitch = GX1CalculatePitchBytes(pScreenInfo->virtualX, 180571d7fec4Smrg pScreenInfo->bitsPerPixel); 180671d7fec4Smrg 180771d7fec4Smrg /* find the index to our operating mode the offsets are located */ 180871d7fec4Smrg for (i = 0; i < (int)((sizeof(GeodeMemOffset) / sizeof(MemOffset))); i++) { 180971d7fec4Smrg if ((pScreenInfo->virtualX == (int)GeodeMemOffset[i].xres) && 181071d7fec4Smrg (pScreenInfo->virtualY == (int)GeodeMemOffset[i].yres) && 181171d7fec4Smrg (pScreenInfo->bitsPerPixel == (int)GeodeMemOffset[i].bpp)) { 181271d7fec4Smrg MemIndex = i; 181371d7fec4Smrg break; 181471d7fec4Smrg } 181571d7fec4Smrg } 181671d7fec4Smrg if (MemIndex == -1) /* no match */ 181771d7fec4Smrg return FALSE; 181871d7fec4Smrg 181971d7fec4Smrg /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */ 182071d7fec4Smrg AvailBox.x1 = 0; 182171d7fec4Smrg AvailBox.y1 = pScreenInfo->virtualY; 182271d7fec4Smrg AvailBox.x2 = pScreenInfo->displayWidth; 182371d7fec4Smrg AvailBox.y2 = (pGeode->FBSize / pGeode->Pitch); 182471d7fec4Smrg 182571d7fec4Smrg pGeode->CursorSize = 8 * 32; /* 32 DWORDS */ 182671d7fec4Smrg 182771d7fec4Smrg if (pGeode->HWCursor) { 182871d7fec4Smrg /* Compute cursor buffer */ 182971d7fec4Smrg /* Default cursor offset, end of the frame buffer */ 183071d7fec4Smrg pGeode->CursorStartOffset = pGeode->FBSize - pGeode->CursorSize; 183171d7fec4Smrg AvailBox.y2 -= 1; 183271d7fec4Smrg } 183371d7fec4Smrg 183471d7fec4Smrg DEBUGMSG(1, (scrnIndex, X_PROBED, 183571d7fec4Smrg "Memory manager initialized to (%d,%d) (%d,%d) %d %d\n", 183671d7fec4Smrg AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2, 183771d7fec4Smrg pGeode->Pitch, pScreenInfo->displayWidth)); 183871d7fec4Smrg /* set the offscreen offset accordingly */ 183971d7fec4Smrg if (pGeode->Compression) { 184071d7fec4Smrg 184171d7fec4Smrg pGeode->CBOffset = GeodeMemOffset[MemIndex].CBOffset; 184271d7fec4Smrg pGeode->CBSize = GeodeMemOffset[MemIndex].CBSize - 16; 184371d7fec4Smrg pGeode->CBPitch = GeodeMemOffset[MemIndex].CBPitch; 184471d7fec4Smrg 184571d7fec4Smrg if ((pScreenInfo->virtualX == 1024) && (pScreenInfo->virtualY == 768)) { 184671d7fec4Smrg req_offscreenmem = pScreenInfo->virtualY * pGeode->CBPitch; 184771d7fec4Smrg req_offscreenmem += pGeode->Pitch - 1; 184871d7fec4Smrg req_offscreenmem /= pGeode->Pitch; 184971d7fec4Smrg pGeode->CBOffset = AvailBox.y1 * pGeode->Pitch; 185071d7fec4Smrg AvailBox.y1 += req_offscreenmem; 185171d7fec4Smrg } 185271d7fec4Smrg } 185371d7fec4Smrg DEBUGMSG(1, (scrnIndex, X_PROBED, 185471d7fec4Smrg "Memory manager initialized to (%d,%d) (%d,%d)\n", 185571d7fec4Smrg AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); 185671d7fec4Smrg 185771d7fec4Smrg if (!pGeode->NoAccel) { 185871d7fec4Smrg if (pGeode->NoOfImgBuffers > 0) { 185971d7fec4Smrg if (pGeode->NoOfImgBuffers <= (AvailBox.y2 - AvailBox.y1)) { 186071d7fec4Smrg pGeode->AccelImageWriteBufferOffsets = 186171d7fec4Smrg xalloc(sizeof(unsigned long) * pGeode->NoOfImgBuffers); 186271d7fec4Smrg 186371d7fec4Smrg pGeode->AccelImageWriteBufferOffsets[0] = 186471d7fec4Smrg ((unsigned char *)pGeode->FBBase) + 186571d7fec4Smrg (AvailBox.y1 * pGeode->Pitch); 186671d7fec4Smrg 186771d7fec4Smrg for (i = 1; i < pGeode->NoOfImgBuffers; i++) { 186871d7fec4Smrg pGeode->AccelImageWriteBufferOffsets[i] = 186971d7fec4Smrg pGeode->AccelImageWriteBufferOffsets[i - 1] + 187071d7fec4Smrg pGeode->Pitch; 187171d7fec4Smrg } 187271d7fec4Smrg 187371d7fec4Smrg for (i = 0; i < pGeode->NoOfImgBuffers; i++) { 187471d7fec4Smrg DEBUGMSG(1, (scrnIndex, X_PROBED, 187571d7fec4Smrg "memory %d %x\n", i, 187671d7fec4Smrg pGeode->AccelImageWriteBufferOffsets[i])); 187771d7fec4Smrg } 187871d7fec4Smrg AvailBox.y1 += pGeode->NoOfImgBuffers; 187971d7fec4Smrg } else { 188071d7fec4Smrg xf86DrvMsg(scrnIndex, X_ERROR, 188171d7fec4Smrg "Unable to reserve scanline area\n"); 188271d7fec4Smrg } 188371d7fec4Smrg } 188471d7fec4Smrg DEBUGMSG(1, (scrnIndex, X_PROBED, 188571d7fec4Smrg "Memory manager initialized to (%d,%d) (%d,%d)\n", 188671d7fec4Smrg AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); 188771d7fec4Smrg 188871d7fec4Smrg REGION_INIT(pScreen, &OffscreenRegion, &AvailBox, 2); 188971d7fec4Smrg 189071d7fec4Smrg if (!xf86InitFBManagerRegion(pScreen, &OffscreenRegion)) { 189171d7fec4Smrg xf86DrvMsg(scrnIndex, X_ERROR, 189271d7fec4Smrg "Memory manager initialization to (%d,%d) (%d,%d) failed\n", 189371d7fec4Smrg AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); 189471d7fec4Smrg } else { 189571d7fec4Smrg xf86DrvMsg(scrnIndex, X_INFO, 189671d7fec4Smrg "Memory manager initialized to (%d,%d) (%d,%d)\n", 189771d7fec4Smrg AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); 189871d7fec4Smrg } 189971d7fec4Smrg REGION_UNINIT(pScreen, &OffscreenRegion); 190071d7fec4Smrg } 190171d7fec4Smrg 190271d7fec4Smrg /* Initialise graphics mode */ 190371d7fec4Smrg if (!GX1EnterGraphics(pScreen, pScreenInfo)) 190471d7fec4Smrg return FALSE; 190571d7fec4Smrg 190671d7fec4Smrg GX1AdjustFrame(scrnIndex, pScreenInfo->frameX0, pScreenInfo->frameY0, 0); 190771d7fec4Smrg GeodeDebug(("GX1ScreenInit(1)!\n")); 190871d7fec4Smrg 190971d7fec4Smrg /* Reset visual list */ 191071d7fec4Smrg miClearVisualTypes(); 191171d7fec4Smrg GeodeDebug(("GX1ScreenInit(2)!\n")); 191271d7fec4Smrg 191371d7fec4Smrg /* Setup the visual we support */ 191471d7fec4Smrg if (pScreenInfo->bitsPerPixel > 8) { 191571d7fec4Smrg if (!miSetVisualTypes(pScreenInfo->depth, 191671d7fec4Smrg TrueColorMask, 191771d7fec4Smrg pScreenInfo->rgbBits, 191871d7fec4Smrg pScreenInfo->defaultVisual)) { 191971d7fec4Smrg return FALSE; 192071d7fec4Smrg } 192171d7fec4Smrg } else { 192271d7fec4Smrg if (!miSetVisualTypes(pScreenInfo->depth, 192371d7fec4Smrg miGetDefaultVisualMask(pScreenInfo->depth), 192471d7fec4Smrg pScreenInfo->rgbBits, 192571d7fec4Smrg pScreenInfo->defaultVisual)) { 192671d7fec4Smrg return FALSE; 192771d7fec4Smrg } 192871d7fec4Smrg } 192971d7fec4Smrg GeodeDebug(("GX1ScreenInit(3)!\n")); 193071d7fec4Smrg /* Set this for RENDER extension */ 193171d7fec4Smrg miSetPixmapDepths(); 193271d7fec4Smrg /* Call the framebuffer layer's ScreenInit function, and fill in other 193371d7fec4Smrg * * pScreen fields. 193471d7fec4Smrg */ 193571d7fec4Smrg 193671d7fec4Smrg if (pGeode->TV_Overscan_On) { 193771d7fec4Smrg width = pGeode->TVOw; 193871d7fec4Smrg height = pGeode->TVOh; 193971d7fec4Smrg GeodeDebug(("width : %d , height : %d", width, height)); 194071d7fec4Smrg } else { 194171d7fec4Smrg width = pScreenInfo->virtualX; 194271d7fec4Smrg height = pScreenInfo->virtualY; 194371d7fec4Smrg } 194471d7fec4Smrg 194571d7fec4Smrg displayWidth = pScreenInfo->displayWidth; 194671d7fec4Smrg if (pGeode->Rotate) { 194771d7fec4Smrg if (pGeode->TV_Overscan_On) { 194871d7fec4Smrg width = pGeode->TVOh; 194971d7fec4Smrg height = pGeode->TVOw; 195071d7fec4Smrg } else { 195171d7fec4Smrg width = pScreenInfo->virtualY; 195271d7fec4Smrg height = pScreenInfo->virtualX; 195371d7fec4Smrg } 195471d7fec4Smrg } 195571d7fec4Smrg if (pGeode->ShadowFB) { 195671d7fec4Smrg pGeode->ShadowPitch = BitmapBytePad(pScreenInfo->bitsPerPixel * width); 195771d7fec4Smrg pGeode->ShadowPtr = xalloc(pGeode->ShadowPitch * height); 195871d7fec4Smrg displayWidth = pGeode->ShadowPitch / (pScreenInfo->bitsPerPixel >> 3); 195971d7fec4Smrg FBStart = pGeode->ShadowPtr; 196071d7fec4Smrg } else { 196171d7fec4Smrg pGeode->ShadowPtr = NULL; 196271d7fec4Smrg 196371d7fec4Smrg if (pGeode->TV_Overscan_On) { 196471d7fec4Smrg GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); 196571d7fec4Smrg FBStart = pGeode->FBBase + (pGeode->Pitch * pGeode->TVOy) + 196671d7fec4Smrg (pGeode->TVOx << ((pScreenInfo->depth >> 3) - 1)); 196771d7fec4Smrg } else { 196871d7fec4Smrg FBStart = pGeode->FBBase; 196971d7fec4Smrg } 197071d7fec4Smrg DEBUGMSG(1, (0, X_PROBED, "FBStart %X \n", FBStart)); 197171d7fec4Smrg } 197271d7fec4Smrg 197371d7fec4Smrg /* Initialise the framebuffer */ 197471d7fec4Smrg switch (pScreenInfo->bitsPerPixel) { 197571d7fec4Smrg case 8: 197671d7fec4Smrg case 16: 197771d7fec4Smrg Inited = fbScreenInit(pScreen, FBStart, width, height, 197871d7fec4Smrg pScreenInfo->xDpi, pScreenInfo->yDpi, 197971d7fec4Smrg displayWidth, pScreenInfo->bitsPerPixel); 198071d7fec4Smrg break; 198171d7fec4Smrg default: 198271d7fec4Smrg xf86DrvMsg(scrnIndex, X_ERROR, 198371d7fec4Smrg "Internal error: invalid bpp (%d) in ScreenInit\n", 198471d7fec4Smrg pScreenInfo->bitsPerPixel); 198571d7fec4Smrg Inited = FALSE; 198671d7fec4Smrg break; 198771d7fec4Smrg } 198871d7fec4Smrg if (!Inited) 198971d7fec4Smrg return FALSE; 199071d7fec4Smrg 199171d7fec4Smrg GeodeDebug(("GX1ScreenInit(4)!\n")); 199271d7fec4Smrg 199371d7fec4Smrg xf86SetBlackWhitePixels(pScreen); 199471d7fec4Smrg 199571d7fec4Smrg if (!pGeode->ShadowFB && (!pGeode->TV_Overscan_On)) { 199671d7fec4Smrg GX1DGAInit(pScreen); 199771d7fec4Smrg } 199871d7fec4Smrg GeodeDebug(("GX1ScreenInit(5)!\n")); 199971d7fec4Smrg if (pScreenInfo->bitsPerPixel > 8) { 200071d7fec4Smrg /* Fixup RGB ordering */ 200171d7fec4Smrg visual = pScreen->visuals + pScreen->numVisuals; 200271d7fec4Smrg while (--visual >= pScreen->visuals) { 200371d7fec4Smrg if ((visual->class | DynamicClass) == DirectColor) { 200471d7fec4Smrg visual->offsetRed = pScreenInfo->offset.red; 200571d7fec4Smrg visual->offsetGreen = pScreenInfo->offset.green; 200671d7fec4Smrg visual->offsetBlue = pScreenInfo->offset.blue; 200771d7fec4Smrg visual->redMask = pScreenInfo->mask.red; 200871d7fec4Smrg visual->greenMask = pScreenInfo->mask.green; 200971d7fec4Smrg visual->blueMask = pScreenInfo->mask.blue; 201071d7fec4Smrg } 201171d7fec4Smrg } 201271d7fec4Smrg } 201371d7fec4Smrg /* must be after RGB ordering fixed */ 201471d7fec4Smrg fbPictureInit(pScreen, 0, 0); 201571d7fec4Smrg 201671d7fec4Smrg GeodeDebug(("GX1ScreenInit(6)!\n")); 201771d7fec4Smrg if (!pGeode->NoAccel) { 201871d7fec4Smrg GX1AccelInit(pScreen); 201971d7fec4Smrg } 202071d7fec4Smrg GeodeDebug(("GX1ScreenInit(7)!\n")); 202171d7fec4Smrg miInitializeBackingStore(pScreen); 202271d7fec4Smrg xf86SetBackingStore(pScreen); 202371d7fec4Smrg 202471d7fec4Smrg GeodeDebug(("GX1ScreenInit(8)!\n")); 202571d7fec4Smrg /* Initialise software cursor */ 202671d7fec4Smrg miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); 202771d7fec4Smrg /* Initialize HW cursor layer. 202871d7fec4Smrg * * Must follow software cursor initialization 202971d7fec4Smrg */ 203071d7fec4Smrg if (pGeode->HWCursor) { 203171d7fec4Smrg if (!GX1HWCursorInit(pScreen)) 203271d7fec4Smrg xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, 203371d7fec4Smrg "Hardware cursor initialization failed\n"); 203471d7fec4Smrg } 203571d7fec4Smrg GeodeDebug(("GX1ScreenInit(9)!\n")); 203671d7fec4Smrg 203771d7fec4Smrg /* Setup default colourmap */ 203871d7fec4Smrg if (!miCreateDefColormap(pScreen)) { 203971d7fec4Smrg return FALSE; 204071d7fec4Smrg } 204171d7fec4Smrg 204271d7fec4Smrg GeodeDebug(("GX1ScreenInit(10)!\n")); 204371d7fec4Smrg /* Initialize colormap layer. 204471d7fec4Smrg * * Must follow initialization of the default colormap 204571d7fec4Smrg */ 204671d7fec4Smrg if (!xf86HandleColormaps(pScreen, 256, 8, 204771d7fec4Smrg GX1LoadPalette, NULL, 204871d7fec4Smrg CMAP_PALETTED_TRUECOLOR | 204971d7fec4Smrg CMAP_RELOAD_ON_MODE_SWITCH)) { 205071d7fec4Smrg return FALSE; 205171d7fec4Smrg } 205271d7fec4Smrg GeodeDebug(("GX1ScreenInit(11)!\n")); 205371d7fec4Smrg 205471d7fec4Smrg if (pGeode->ShadowFB) { 205571d7fec4Smrg RefreshAreaFuncPtr refreshArea = GX1RefreshArea; 205671d7fec4Smrg 205771d7fec4Smrg if (pGeode->Rotate) { 205871d7fec4Smrg if (!pGeode->PointerMoved) { 205971d7fec4Smrg pGeode->PointerMoved = pScreenInfo->PointerMoved; 206071d7fec4Smrg pScreenInfo->PointerMoved = GX1PointerMoved; 206171d7fec4Smrg } 206271d7fec4Smrg switch (pScreenInfo->bitsPerPixel) { 206371d7fec4Smrg case 8: 206471d7fec4Smrg refreshArea = GX1RefreshArea8; 206571d7fec4Smrg break; 206671d7fec4Smrg case 16: 206771d7fec4Smrg refreshArea = GX1RefreshArea16; 206871d7fec4Smrg break; 206971d7fec4Smrg } 207071d7fec4Smrg } 207171d7fec4Smrg ShadowFBInit(pScreen, refreshArea); 207271d7fec4Smrg } 207371d7fec4Smrg xf86DPMSInit(pScreen, GX1DPMSSet, 0); 207471d7fec4Smrg GeodeDebug(("GX1ScreenInit(12)!\n")); 207571d7fec4Smrg 207671d7fec4Smrg if (pGeode->TV_Overscan_On) { 207771d7fec4Smrg GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); 207871d7fec4Smrg 207971d7fec4Smrg pScreenInfo->memPhysBase = (unsigned long)(pGeode->FBBase + 208071d7fec4Smrg (pGeode->Pitch * 208171d7fec4Smrg pGeode->TVOy) + 208271d7fec4Smrg (pGeode-> 208371d7fec4Smrg TVOx << 208471d7fec4Smrg ((pScreenInfo->depth >> 3) - 208571d7fec4Smrg 1))); 208671d7fec4Smrg GeodeDebug(("->memPhysBase (%X)!\n", pScreenInfo->memPhysBase)); 208771d7fec4Smrg } else { 208871d7fec4Smrg pScreenInfo->memPhysBase = (unsigned long)pGeode->FBBase; 208971d7fec4Smrg } 209071d7fec4Smrg pScreenInfo->fbOffset = 0; 209171d7fec4Smrg 209271d7fec4Smrg GeodeDebug(("GX1ScreenInit(13)!\n")); 209371d7fec4Smrg GX1InitVideo(pScreen); /* needed for video */ 209471d7fec4Smrg /* Wrap the screen's CloseScreen vector and set its 209571d7fec4Smrg * SaveScreen vector 209671d7fec4Smrg */ 209771d7fec4Smrg pGeode->CloseScreen = pScreen->CloseScreen; 209871d7fec4Smrg pScreen->CloseScreen = GX1CloseScreen; 209971d7fec4Smrg 210071d7fec4Smrg pScreen->SaveScreen = GX1SaveScreen; 210171d7fec4Smrg GeodeDebug(("GX1ScreenInit(14)!\n")); 210271d7fec4Smrg /* Report any unused options */ 210371d7fec4Smrg if (serverGeneration == 1) { 210471d7fec4Smrg xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); 210571d7fec4Smrg } 210671d7fec4Smrg GeodeDebug(("GX2ScreenInit(15)!\n")); 210771d7fec4Smrg return TRUE; 210871d7fec4Smrg} 210971d7fec4Smrg 211071d7fec4Smrg/*---------------------------------------------------------------------------- 211171d7fec4Smrg * GX1SwitchMode. 211271d7fec4Smrg * 211371d7fec4Smrg * Description :This function will switches the screen mode 211471d7fec4Smrg * 211571d7fec4Smrg * Parameters: 211671d7fec4Smrg * scrnIndex :Specfies the screen index value. 211771d7fec4Smrg * pMode :pointer to the mode structure. 211871d7fec4Smrg * flags :may be used for status check?. 211971d7fec4Smrg * 212071d7fec4Smrg * Returns :Returns TRUE on success and FALSE on failure. 212171d7fec4Smrg * 212271d7fec4Smrg * Comments :none. 212371d7fec4Smrg*---------------------------------------------------------------------------- 212471d7fec4Smrg*/ 212571d7fec4SmrgBool 212671d7fec4SmrgGX1SwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) 212771d7fec4Smrg{ 212871d7fec4Smrg GeodeDebug(("GX1SwitchMode!\n")); 212971d7fec4Smrg return GX1SetMode(xf86Screens[scrnIndex], pMode); 213071d7fec4Smrg} 213171d7fec4Smrg 213271d7fec4Smrg/*---------------------------------------------------------------------------- 213371d7fec4Smrg * GX1AdjustFrame. 213471d7fec4Smrg * 213571d7fec4Smrg * Description :This function is used to intiallize the start 213671d7fec4Smrg * address of the memory. 213771d7fec4Smrg * Parameters. 213871d7fec4Smrg * scrnIndex :Specfies the screen index value. 213971d7fec4Smrg * x :x co-ordinate value interms of pixels. 214071d7fec4Smrg * y :y co-ordinate value interms of pixels. 214171d7fec4Smrg * 214271d7fec4Smrg * Returns :none. 214371d7fec4Smrg * 214471d7fec4Smrg * Comments :none. 214571d7fec4Smrg*---------------------------------------------------------------------------- 214671d7fec4Smrg*/ 214771d7fec4Smrgvoid 214871d7fec4SmrgGX1AdjustFrame(int scrnIndex, int x, int y, int flags) 214971d7fec4Smrg{ 215071d7fec4Smrg ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 215171d7fec4Smrg GeodePtr pGeode; 215271d7fec4Smrg unsigned long offset; 215371d7fec4Smrg 215471d7fec4Smrg pGeode = GX1GetRec(pScreenInfo); 215571d7fec4Smrg offset = (unsigned long)y *(unsigned long)pGeode->Pitch; 215671d7fec4Smrg 215771d7fec4Smrg offset += x; 215871d7fec4Smrg if (pScreenInfo->bitsPerPixel > 8) { 215971d7fec4Smrg offset += x; 216071d7fec4Smrg } 216171d7fec4Smrg GFX(set_display_offset(offset)); 216271d7fec4Smrg} 216371d7fec4Smrg 216471d7fec4Smrg/*---------------------------------------------------------------------------- 216571d7fec4Smrg * GX1EnterVT. 216671d7fec4Smrg * 216771d7fec4Smrg * Description :This is called when VT switching back to the X server 216871d7fec4Smrg * 216971d7fec4Smrg * Parameters. 217071d7fec4Smrg * scrnIndex :Specfies the screen index value. 217171d7fec4Smrg * flags :Not used inside the function. 217271d7fec4Smrg * 217371d7fec4Smrg * Returns :none. 217471d7fec4Smrg * 217571d7fec4Smrg * Comments :none. 217671d7fec4Smrg*---------------------------------------------------------------------------- 217771d7fec4Smrg*/ 217871d7fec4Smrgstatic Bool 217971d7fec4SmrgGX1EnterVT(int scrnIndex, int flags) 218071d7fec4Smrg{ 218171d7fec4Smrg GeodeDebug(("GX1EnterVT!\n")); 218271d7fec4Smrg return GX1EnterGraphics(NULL, xf86Screens[scrnIndex]); 218371d7fec4Smrg} 218471d7fec4Smrg 218571d7fec4Smrg/*---------------------------------------------------------------------------- 218671d7fec4Smrg * GX1LeaveVT. 218771d7fec4Smrg * 218871d7fec4Smrg * Description :This is called when VT switching X server text mode. 218971d7fec4Smrg * 219071d7fec4Smrg * Parameters. 219171d7fec4Smrg * scrnIndex :Specfies the screen index value. 219271d7fec4Smrg * flags :Not used inside the function. 219371d7fec4Smrg * 219471d7fec4Smrg * Returns :none. 219571d7fec4Smrg * 219671d7fec4Smrg * Comments :none. 219771d7fec4Smrg*---------------------------------------------------------------------------- 219871d7fec4Smrg*/ 219971d7fec4Smrgstatic void 220071d7fec4SmrgGX1LeaveVT(int scrnIndex, int flags) 220171d7fec4Smrg{ 220271d7fec4Smrg GeodeDebug(("GX1LeaveVT!\n")); 220371d7fec4Smrg GX1LeaveGraphics(xf86Screens[scrnIndex]); 220471d7fec4Smrg} 220571d7fec4Smrg 220671d7fec4Smrg/*---------------------------------------------------------------------------- 220771d7fec4Smrg * GX1FreeScreen. 220871d7fec4Smrg * 220971d7fec4Smrg * Description :This is called to free any persistent data structures. 221071d7fec4Smrg * 221171d7fec4Smrg * Parameters. 221271d7fec4Smrg * scrnIndex :Specfies the screen index value. 221371d7fec4Smrg * flags :Not used inside the function. 221471d7fec4Smrg * 221571d7fec4Smrg * Returns :none. 221671d7fec4Smrg * 221771d7fec4Smrg * Comments :This will be called only when screen being deleted.. 221871d7fec4Smrg*---------------------------------------------------------------------------- 221971d7fec4Smrg*/ 222071d7fec4Smrgstatic void 222171d7fec4SmrgGX1FreeScreen(int scrnIndex, int flags) 222271d7fec4Smrg{ 222371d7fec4Smrg GeodeDebug(("GX1FreeScreen!\n")); 222471d7fec4Smrg#if !defined(STB_X) 222571d7fec4Smrg 222671d7fec4Smrg if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) 222771d7fec4Smrg vgaHWFreeHWRec(xf86Screens[scrnIndex]); 222871d7fec4Smrg#endif 222971d7fec4Smrg GX1FreeRec(xf86Screens[scrnIndex]); 223071d7fec4Smrg} 223171d7fec4Smrg 223271d7fec4Smrg/*---------------------------------------------------------------------------- 223371d7fec4Smrg * GX1ValidMode. 223471d7fec4Smrg * 223571d7fec4Smrg * Description :This function checks if a mode is suitable for selected 223671d7fec4Smrg * chipset. 223771d7fec4Smrg * Parameters. 223871d7fec4Smrg * scrnIndex :Specfies the screen index value. 223971d7fec4Smrg * pMode :Pointer to the screen mode structure.. 224071d7fec4Smrg * verbose :not used for implementation. 224171d7fec4Smrg * flags :not used for implementation 224271d7fec4Smrg * 224371d7fec4Smrg * Returns :MODE_OK if the specified mode is supported or 224471d7fec4Smrg * MODE_NO_INTERLACE. 224571d7fec4Smrg * Comments :none. 224671d7fec4Smrg*---------------------------------------------------------------------------- 224771d7fec4Smrg*/ 224871d7fec4Smrgstatic ModeStatus 224971d7fec4SmrgGX1ValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) 225071d7fec4Smrg{ 225171d7fec4Smrg ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; 225271d7fec4Smrg unsigned int total_memory_required; 225371d7fec4Smrg int ret = -1; 225471d7fec4Smrg GeodePtr pGeode = GX1GetRec(pScreenInfo); 225571d7fec4Smrg 225671d7fec4Smrg DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", 225771d7fec4Smrg pMode->CrtcHDisplay, pMode->CrtcVDisplay, 225871d7fec4Smrg pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); 225971d7fec4Smrg 226071d7fec4Smrg if (pGeode->TVSupport == TRUE) { 226171d7fec4Smrg if ((pGeode->TvParam.wWidth == pMode->CrtcHDisplay) && 226271d7fec4Smrg (pGeode->TvParam.wHeight == pMode->CrtcVDisplay)) { 226371d7fec4Smrg DEBUGMSG(1, (0, X_NONE, "TV mode\n")); 226471d7fec4Smrg 226571d7fec4Smrg#if defined(STB_X) 226671d7fec4Smrg Gal_is_tv_mode_supported(0, &(pGeode->TvParam), &ret); 226771d7fec4Smrg#else 226871d7fec4Smrg ret = gfx_is_tv_display_mode_supported(pMode->CrtcHDisplay, 226971d7fec4Smrg pMode->CrtcVDisplay, 227071d7fec4Smrg (TVStandardType)pGeode->TvParam.wStandard); 227171d7fec4Smrg#endif 227271d7fec4Smrg } 227371d7fec4Smrg } else { 227471d7fec4Smrg DEBUGMSG(1, (0, X_NONE, "CRT mode\n")); 227571d7fec4Smrg 227671d7fec4Smrg if (pMode->Flags & V_INTERLACE) 227771d7fec4Smrg return MODE_NO_INTERLACE; 227871d7fec4Smrg 227971d7fec4Smrg#if defined(STB_X) 228071d7fec4Smrg Gal_is_display_mode_supported(pMode->CrtcHDisplay, pMode->CrtcVDisplay, 228171d7fec4Smrg pScreenInfo->bitsPerPixel, 228271d7fec4Smrg GX1GetRefreshRate(pMode), &ret); 228371d7fec4Smrg#else 228471d7fec4Smrg ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay, 228571d7fec4Smrg pMode->CrtcVDisplay, 228671d7fec4Smrg pScreenInfo->bitsPerPixel, 228771d7fec4Smrg GX1GetRefreshRate(pMode)); 228871d7fec4Smrg#endif /* STB_X */ 228971d7fec4Smrg } 229071d7fec4Smrg 229171d7fec4Smrg if (ret < 0) 229271d7fec4Smrg return MODE_NOMODE; 229371d7fec4Smrg 229471d7fec4Smrg total_memory_required = GX1CalculatePitchBytes(pMode->CrtcHDisplay, 229571d7fec4Smrg pScreenInfo->bitsPerPixel) * 229671d7fec4Smrg pMode->CrtcVDisplay; 229771d7fec4Smrg 229871d7fec4Smrg DEBUGMSG(0, (0, X_NONE, "Total Mem %X %X", 229971d7fec4Smrg total_memory_required, pGeode->FBSize)); 230071d7fec4Smrg 230171d7fec4Smrg if (total_memory_required > pGeode->FBSize) 230271d7fec4Smrg return MODE_MEM; 230371d7fec4Smrg 230471d7fec4Smrg return MODE_OK; 230571d7fec4Smrg} 230671d7fec4Smrg 230771d7fec4Smrg/*---------------------------------------------------------------------------- 230871d7fec4Smrg * GX1LoadPalette. 230971d7fec4Smrg * 231071d7fec4Smrg * Description :This function sets the palette entry used for graphics data 231171d7fec4Smrg * 231271d7fec4Smrg * Parameters. 231371d7fec4Smrg * pScreenInfo:Points the screeninfo structure. 231471d7fec4Smrg * numColors:Specifies the no of colors it supported. 231571d7fec4Smrg * indizes :This is used get index value . 231671d7fec4Smrg * LOCO :to be added. 231771d7fec4Smrg * pVisual :to be added. 231871d7fec4Smrg * 231971d7fec4Smrg * Returns :MODE_OK if the specified mode is supported or 232071d7fec4Smrg * MODE_NO_INTERLACE. 232171d7fec4Smrg * Comments :none. 232271d7fec4Smrg*---------------------------------------------------------------------------- 232371d7fec4Smrg*/ 232471d7fec4Smrg 232571d7fec4Smrgstatic void 232671d7fec4SmrgGX1LoadPalette(ScrnInfoPtr pScreenInfo, 232771d7fec4Smrg int numColors, int *indizes, LOCO * colors, VisualPtr pVisual) 232871d7fec4Smrg{ 232971d7fec4Smrg int i, index, color; 233071d7fec4Smrg 233171d7fec4Smrg for (i = 0; i < numColors; i++) { 233271d7fec4Smrg index = indizes[i] & 0xFF; 233371d7fec4Smrg color = (((unsigned long)(colors[index].red & 0xFF)) << 16) | 233471d7fec4Smrg (((unsigned long)(colors[index].green & 0xFF)) << 8) | 233571d7fec4Smrg ((unsigned long)(colors[index].blue & 0xFF)); 233671d7fec4Smrg DEBUGMSG(0, (0, X_NONE, "GX1LoadPalette: %d %d %X\n", 233771d7fec4Smrg numColors, index, color)); 233871d7fec4Smrg 233971d7fec4Smrg GFX(set_display_palette_entry(index, color)); 234071d7fec4Smrg } 234171d7fec4Smrg} 234271d7fec4Smrg 234371d7fec4Smrgstatic Bool 234471d7fec4SmrgGX1MapMem(ScrnInfoPtr pScreenInfo) 234571d7fec4Smrg{ 234671d7fec4Smrg GeodePtr pGeode = GEODEPTR(pScreenInfo); 234771d7fec4Smrg 234871d7fec4Smrg#if defined(STB_X) 234971d7fec4Smrg pGeode->FBBase = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 235071d7fec4Smrg VIDMEM_FRAMEBUFFER, 235171d7fec4Smrg pGeode->FBLinearAddr, 235271d7fec4Smrg pGeode->FBSize); 235371d7fec4Smrg 235471d7fec4Smrg#else 235571d7fec4Smrg /* SET DURANGO REGISTER POINTERS 235671d7fec4Smrg * * The method of mapping from a physical address to a linear address 235771d7fec4Smrg * * is operating system independent. Set variables to linear address. 235871d7fec4Smrg */ 235971d7fec4Smrg gfx_virt_regptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 236071d7fec4Smrg VIDMEM_MMIO, 236171d7fec4Smrg (unsigned int) 236271d7fec4Smrg gfx_get_cpu_register_base 236371d7fec4Smrg (), 0x9000); 236471d7fec4Smrg gfx_virt_spptr = gfx_virt_regptr; 236571d7fec4Smrg gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 236671d7fec4Smrg VIDMEM_MMIO, 236771d7fec4Smrg (unsigned int) 236871d7fec4Smrg gfx_get_vid_register_base 236971d7fec4Smrg (), 0x1000); 237071d7fec4Smrg pGeode->FBSize = GetVideoMemSize(); 237171d7fec4Smrg gfx_virt_fbptr = 237271d7fec4Smrg (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 237371d7fec4Smrg VIDMEM_FRAMEBUFFER, 237471d7fec4Smrg pGeode->FBLinearAddr, pGeode->FBSize); 237571d7fec4Smrg 237671d7fec4Smrg /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */ 237771d7fec4Smrg if ((!gfx_virt_regptr) || 237871d7fec4Smrg (!gfx_virt_spptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) { 237971d7fec4Smrg DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n")); 238071d7fec4Smrg return (FALSE); 238171d7fec4Smrg } 238271d7fec4Smrg 238371d7fec4Smrg /* Map the XpressROM ptr to read what platform are we on */ 238471d7fec4Smrg XpressROMPtr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, 238571d7fec4Smrg VIDMEM_FRAMEBUFFER, 0xF0000, 238671d7fec4Smrg 0x10000); 238771d7fec4Smrg 238871d7fec4Smrg if (!XpressROMPtr) 238971d7fec4Smrg return FALSE; 239071d7fec4Smrg 239171d7fec4Smrg pGeode->FBBase = gfx_virt_fbptr; 239271d7fec4Smrg#endif 239371d7fec4Smrg 239471d7fec4Smrg return TRUE; 239571d7fec4Smrg} 239671d7fec4Smrg 239771d7fec4Smrg/* 239871d7fec4Smrg * Unmap the framebuffer and MMIO memory. 239971d7fec4Smrg */ 240071d7fec4Smrg 240171d7fec4Smrgstatic Bool 240271d7fec4SmrgGX1UnmapMem(ScrnInfoPtr pScreenInfo) 240371d7fec4Smrg{ 240471d7fec4Smrg#if !defined(STB_X) 240571d7fec4Smrg GeodePtr pGeode = GEODEPTR(pScreenInfo); 240671d7fec4Smrg 240771d7fec4Smrg /* unmap all the memory map's */ 240871d7fec4Smrg xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_regptr, 0x9000); 240971d7fec4Smrg xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_vidptr, 0x1000); 241071d7fec4Smrg xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_fbptr, pGeode->FBSize); 241171d7fec4Smrg xf86UnMapVidMem(pScreenInfo->scrnIndex, XpressROMPtr, 0x10000); 241271d7fec4Smrg#endif /* STB_X */ 241371d7fec4Smrg 241471d7fec4Smrg return TRUE; 241571d7fec4Smrg} 241671d7fec4Smrg 241771d7fec4Smrg/* End of file */ 2418