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