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