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