nsc_driver.c revision 71d7fec4
171d7fec4Smrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/nsc_driver.c,v 1.4tsi Exp $ */ 271d7fec4Smrg/* 371d7fec4Smrg * $Workfile: nsc_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: Nsc 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 NSC_TRACE 0 15271d7fec4Smrg#define HWVGA 1 15371d7fec4Smrg 15471d7fec4Smrg/* Includes that are used by all drivers */ 15571d7fec4Smrg#include "xf86.h" 15671d7fec4Smrg#include "xf86_OSproc.h" 15771d7fec4Smrg#include "xf86Resources.h" 15871d7fec4Smrg 15971d7fec4Smrg/* We may want inb() and outb() */ 16071d7fec4Smrg#include "compiler.h" 16171d7fec4Smrg 16271d7fec4Smrg/* We may want to access the PCI config space */ 16371d7fec4Smrg#include "xf86PciInfo.h" 16471d7fec4Smrg#include "xf86Pci.h" 16571d7fec4Smrg 16671d7fec4Smrg/* Colormap handling stuff */ 16771d7fec4Smrg#include "xf86cmap.h" 16871d7fec4Smrg 16971d7fec4Smrg#define RC_MAX_DEPTH 24 17071d7fec4Smrg 17171d7fec4Smrg/* Frame buffer stuff */ 17271d7fec4Smrg#include "fb.h" 17371d7fec4Smrg 17471d7fec4Smrg#include "shadowfb.h" 17571d7fec4Smrg 17671d7fec4Smrg/* Machine independent stuff */ 17771d7fec4Smrg#include "mipointer.h" 17871d7fec4Smrg#include "mibank.h" 17971d7fec4Smrg#include "micmap.h" 18071d7fec4Smrg/* All drivers implementing backing store need this */ 18171d7fec4Smrg#include "mibstore.h" 18271d7fec4Smrg#include "vgaHW.h" 18371d7fec4Smrg#include "vbe.h" 18471d7fec4Smrg 18571d7fec4Smrg/* Check for some extensions */ 18671d7fec4Smrg#ifdef XFreeXDGA 18771d7fec4Smrg#define _XF86_DGA_SERVER_ 18871d7fec4Smrg#include <X11/extensions/xf86dgastr.h> 18971d7fec4Smrg#endif /* XFreeXDGA */ 19071d7fec4Smrg 19171d7fec4Smrg#include "globals.h" 19271d7fec4Smrg#include "opaque.h" 19371d7fec4Smrg#define DPMS_SERVER 19471d7fec4Smrg#include <X11/extensions/dpms.h> 19571d7fec4Smrg 19671d7fec4Smrg#define EXTERN 19771d7fec4Smrg/* Our private include file (this also includes the durango headers) */ 19871d7fec4Smrg#include "nsc.h" 19971d7fec4Smrg 20071d7fec4Smrg#if NSC_TRACE 20171d7fec4Smrg/* ANSI C does not allow var arg macros */ 20271d7fec4Smrg#define GeodeDebug(args) DebugPort(DCount++);ErrorF args 20371d7fec4Smrg#else 20471d7fec4Smrg#define GeodeDebug(args) 20571d7fec4Smrg#endif 20671d7fec4Smrg 20771d7fec4Smrg/* A few things all drivers should have */ 20871d7fec4Smrg#define NSC_NAME "NSC" 20971d7fec4Smrg#define NSC_DRIVER_NAME "nsc" 21071d7fec4Smrg 21171d7fec4Smrg/* This should match the durango code version. 21271d7fec4Smrg * The patchlevel may be used to indicate changes in geode.c 21371d7fec4Smrg */ 21471d7fec4Smrg#define NSC_VERSION_NAME "2.8.1" 21571d7fec4Smrg#define NSC_VERSION_MAJOR 2 21671d7fec4Smrg#define NSC_VERSION_MINOR 8 21771d7fec4Smrg#define NSC_PATCHLEVEL 1 21871d7fec4Smrg 21971d7fec4Smrg#define NSC_VERSION_CURRENT ((NSC_VERSION_MAJOR << 24) | \ 22071d7fec4Smrg (NSC_VERSION_MINOR << 16) | NSC_PATCHLEVEL) 22171d7fec4Smrg 22271d7fec4Smrg/* Forward definitions */ 22371d7fec4Smrgstatic const OptionInfoRec *NscAvailableOptions(int chipid, int busid); 22471d7fec4Smrgstatic void NscIdentify(int); 22571d7fec4Smrgstatic Bool NscProbe(DriverPtr, int); 22671d7fec4Smrgstatic int CPUDetected; 22771d7fec4Smrg 22871d7fec4Smrgextern void GX1SetupChipsetFPtr(ScrnInfoPtr pScrn); 22971d7fec4Smrgextern void GX2SetupChipsetFPtr(ScrnInfoPtr pScrn); 23071d7fec4Smrg 23171d7fec4Smrg#if !defined(STB_X) 23271d7fec4Smrgextern unsigned char *XpressROMPtr; 23371d7fec4Smrg#endif /* STB_X */ 23471d7fec4Smrg 23571d7fec4Smrg/* driver record contains the functions needed by the server after loading 23671d7fec4Smrg * the driver module. 23771d7fec4Smrg */ 23871d7fec4Smrg_X_EXPORT DriverRec NSC = { 23971d7fec4Smrg NSC_VERSION_CURRENT, 24071d7fec4Smrg NSC_DRIVER_NAME, 24171d7fec4Smrg NscIdentify, 24271d7fec4Smrg NscProbe, 24371d7fec4Smrg NscAvailableOptions, 24471d7fec4Smrg NULL, 24571d7fec4Smrg 0 24671d7fec4Smrg}; 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#define PCI_VENDOR_ID_CYRIX 0x1078 25571d7fec4Smrg#define PCI_VENDOR_ID_NS 0x100B 25671d7fec4Smrg 25771d7fec4Smrg#define PCI_CHIP_5530 0x0104 25871d7fec4Smrg#define PCI_CHIP_SC1200 0x0504 25971d7fec4Smrg#define PCI_CHIP_SC1400 0x0104 26071d7fec4Smrg#define PCI_CHIP_REDCLOUD 0x0030 26171d7fec4Smrg 26271d7fec4Smrg/* National Chip Models */ 26371d7fec4Smrgtypedef struct _DEVICE_MODEL 26471d7fec4Smrg{ 26571d7fec4Smrg int DeviceId; 26671d7fec4Smrg int Model; 26771d7fec4Smrg} 26871d7fec4SmrgDeviceModel; 26971d7fec4Smrg 27071d7fec4SmrgDeviceModel ChipModel[] = { 27171d7fec4Smrg {PCI_CHIP_5530, GX1}, 27271d7fec4Smrg {PCI_CHIP_SC1200, GX1}, 27371d7fec4Smrg {PCI_CHIP_SC1400, GX1}, 27471d7fec4Smrg {PCI_CHIP_REDCLOUD, GX2}, 27571d7fec4Smrg {-1, 0} 27671d7fec4Smrg}; 27771d7fec4Smrg 27871d7fec4Smrg/* Supported chipsets */ 27971d7fec4SmrgSymTabRec GeodeChipsets[] = { 28071d7fec4Smrg {PCI_CHIP_5530, "5530"}, 28171d7fec4Smrg {PCI_CHIP_SC1200, "SC1200"}, 28271d7fec4Smrg {PCI_CHIP_SC1400, "SC1400"}, 28371d7fec4Smrg {PCI_CHIP_REDCLOUD, "REDCLOUD"}, 28471d7fec4Smrg {-1, NULL} 28571d7fec4Smrg}; 28671d7fec4Smrg 28771d7fec4SmrgPciChipsets GeodePCIchipsets[] = { 28871d7fec4Smrg {PCI_CHIP_5530, PCI_CHIP_5530, RES_SHARED_VGA}, 28971d7fec4Smrg {PCI_CHIP_SC1200, PCI_CHIP_SC1200, RES_SHARED_VGA}, 29071d7fec4Smrg {PCI_CHIP_SC1400, PCI_CHIP_SC1400, RES_SHARED_VGA}, 29171d7fec4Smrg {PCI_CHIP_REDCLOUD, PCI_CHIP_REDCLOUD, RES_SHARED_VGA}, 29271d7fec4Smrg {-1, -1, RES_UNDEFINED}, 29371d7fec4Smrg}; 29471d7fec4Smrg 29571d7fec4SmrgOptionInfoRec GeodeOptions[] = { 29671d7fec4Smrg {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, 29771d7fec4Smrg {OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE}, 29871d7fec4Smrg {OPTION_NOCOMPRESSION, "NoCompression", OPTV_BOOLEAN, {0}, FALSE}, 29971d7fec4Smrg {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, 30071d7fec4Smrg {OPTION_TV_SUPPORT, "TV", OPTV_ANYSTR, {0}, FALSE}, 30171d7fec4Smrg {OPTION_TV_OUTPUT, "TV_Output", OPTV_ANYSTR, {0}, FALSE}, 30271d7fec4Smrg {OPTION_TV_OVERSCAN, "TVOverscan", OPTV_ANYSTR, {0}, FALSE}, 30371d7fec4Smrg {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, 30471d7fec4Smrg {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, 30571d7fec4Smrg {OPTION_FLATPANEL, "FlatPanel", OPTV_BOOLEAN, {0}, FALSE}, 30671d7fec4Smrg {OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE}, 30771d7fec4Smrg {OPTION_OSM_IMG_BUFS, "OSMImageBuffers", OPTV_INTEGER, {0}, FALSE}, 30871d7fec4Smrg {-1, NULL, OPTV_NONE, {0}, FALSE} 30971d7fec4Smrg}; 31071d7fec4Smrg 31171d7fec4Smrg/* List of symbols from other modules that this module references.The purpose 31271d7fec4Smrg* is that to avoid unresolved symbol warnings 31371d7fec4Smrg*/ 31471d7fec4Smrgconst char *nscVgahwSymbols[] = { 31571d7fec4Smrg "vgaHWGetHWRec", 31671d7fec4Smrg "vgaHWUnlock", 31771d7fec4Smrg "vgaHWInit", 31871d7fec4Smrg "vgaHWSave", 31971d7fec4Smrg "vgaHWRestore", 32071d7fec4Smrg "vgaHWProtect", 32171d7fec4Smrg "vgaHWGetIOBase", 32271d7fec4Smrg "vgaHWMapMem", 32371d7fec4Smrg "vgaHWLock", 32471d7fec4Smrg "vgaHWFreeHWRec", 32571d7fec4Smrg "vgaHWSaveScreen", 32671d7fec4Smrg NULL 32771d7fec4Smrg}; 32871d7fec4Smrg 32971d7fec4Smrgconst char *nscVbeSymbols[] = { 33071d7fec4Smrg "VBEInit", 33171d7fec4Smrg "vbeDoEDID", 33271d7fec4Smrg "vbeFree", 33371d7fec4Smrg NULL 33471d7fec4Smrg}; 33571d7fec4Smrg 33671d7fec4Smrgconst char *nscInt10Symbols[] = { 33771d7fec4Smrg "xf86ExecX86int10", 33871d7fec4Smrg "xf86InitInt10", 33971d7fec4Smrg "xf86Int10AllocPages", 34071d7fec4Smrg "xf86Int10Addr", 34171d7fec4Smrg NULL 34271d7fec4Smrg}; 34371d7fec4Smrg 34471d7fec4Smrgconst char *nscFbSymbols[] = { 34571d7fec4Smrg "fbScreenInit", 34671d7fec4Smrg "fbPictureInit", 34771d7fec4Smrg NULL 34871d7fec4Smrg}; 34971d7fec4Smrg 35071d7fec4Smrgconst char *nscXaaSymbols[] = { 35171d7fec4Smrg "XAADestroyInfoRec", 35271d7fec4Smrg "XAACreateInfoRec", 35371d7fec4Smrg "XAAInit", 35471d7fec4Smrg NULL 35571d7fec4Smrg}; 35671d7fec4Smrg 35771d7fec4Smrgconst char *nscRamdacSymbols[] = { 35871d7fec4Smrg "xf86InitCursor", 35971d7fec4Smrg "xf86CreateCursorInfoRec", 36071d7fec4Smrg "xf86DestroyCursorInfoRec", 36171d7fec4Smrg NULL 36271d7fec4Smrg}; 36371d7fec4Smrg 36471d7fec4Smrgconst char *nscShadowSymbols[] = { 36571d7fec4Smrg "ShadowFBInit", 36671d7fec4Smrg NULL 36771d7fec4Smrg}; 36871d7fec4Smrg 36971d7fec4Smrg#ifdef XFree86LOADER 37071d7fec4Smrg 37171d7fec4Smrg/* Module loader interface */ 37271d7fec4Smrg 37371d7fec4Smrgstatic MODULESETUPPROTO(NscSetup); 37471d7fec4Smrg 37571d7fec4Smrgstatic XF86ModuleVersionInfo NscVersionRec = { 37671d7fec4Smrg "nsc", 37771d7fec4Smrg MODULEVENDORSTRING, 37871d7fec4Smrg MODINFOSTRING1, 37971d7fec4Smrg MODINFOSTRING2, 38071d7fec4Smrg XORG_VERSION_CURRENT, 38171d7fec4Smrg NSC_VERSION_MAJOR, NSC_VERSION_MINOR, NSC_PATCHLEVEL, 38271d7fec4Smrg ABI_CLASS_VIDEODRV, /* This is a video driver */ 38371d7fec4Smrg ABI_VIDEODRV_VERSION, 38471d7fec4Smrg MOD_CLASS_VIDEODRV, 38571d7fec4Smrg {0, 0, 0, 0} 38671d7fec4Smrg}; 38771d7fec4Smrg 38871d7fec4Smrg/* 38971d7fec4Smrg * This data is accessed by the loader. The name must be the module name 39071d7fec4Smrg * followed by "ModuleInit". 39171d7fec4Smrg */ 39271d7fec4Smrg_X_EXPORT XF86ModuleData nscModuleData = { &NscVersionRec, NscSetup, NULL }; 39371d7fec4Smrg 39471d7fec4Smrg/*------------------------------------------------------------------------- 39571d7fec4Smrg * NscSetup. 39671d7fec4Smrg * 39771d7fec4Smrg * Description :This function sets up the driver in X list and load the 39871d7fec4Smrg * module symbols through xf86loader routines.. 39971d7fec4Smrg * 40071d7fec4Smrg * Parameters. 40171d7fec4Smrg * Module :Pointer to the geode module 40271d7fec4Smrg * options :Driver module options. 40371d7fec4Smrg * ErrorMajor:Major no 40471d7fec4Smrg * ErrorMinor:Minor no. 40571d7fec4Smrg * 40671d7fec4Smrg * Returns :NULL on success 40771d7fec4Smrg * 40871d7fec4Smrg * Comments :Module setup is done by this function 40971d7fec4Smrg * 41071d7fec4Smrg *------------------------------------------------------------------------- 41171d7fec4Smrg*/ 41271d7fec4Smrgstatic pointer 41371d7fec4SmrgNscSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) 41471d7fec4Smrg{ 41571d7fec4Smrg static Bool Initialised = FALSE; 41671d7fec4Smrg 41771d7fec4Smrg if (!Initialised) { 41871d7fec4Smrg Initialised = TRUE; 41971d7fec4Smrg xf86AddDriver(&NSC, Module, 0); 42071d7fec4Smrg /* Tell the loader about symbols from other modules that this 42171d7fec4Smrg * module might refer to. 42271d7fec4Smrg */ 42371d7fec4Smrg LoaderRefSymLists(nscVgahwSymbols, nscVbeSymbols, 42471d7fec4Smrg nscFbSymbols, 42571d7fec4Smrg nscXaaSymbols, 42671d7fec4Smrg nscInt10Symbols, nscRamdacSymbols, nscShadowSymbols, 42771d7fec4Smrg NULL); 42871d7fec4Smrg return (pointer) TRUE; 42971d7fec4Smrg } 43071d7fec4Smrg /*The return value must be non-NULL on success */ 43171d7fec4Smrg if (ErrorMajor) 43271d7fec4Smrg *ErrorMajor = LDR_ONCEONLY; 43371d7fec4Smrg return NULL; 43471d7fec4Smrg} 43571d7fec4Smrg#endif /*End of XFree86Loader */ 43671d7fec4Smrg 43771d7fec4Smrg/*------------------------------------------------------------------------- 43871d7fec4Smrg * NscIdentify. 43971d7fec4Smrg * 44071d7fec4Smrg * Description : This function identify an Nscfamily version. 44171d7fec4Smrg * 44271d7fec4Smrg * 44371d7fec4Smrg * Parameters. 44471d7fec4Smrg * flags : flags may be used in PreInit* 44571d7fec4Smrg * 44671d7fec4Smrg * Returns : none 44771d7fec4Smrg * 44871d7fec4Smrg * Comments : none 44971d7fec4Smrg * 45071d7fec4Smrg*------------------------------------------------------------------------ 45171d7fec4Smrg*/ 45271d7fec4Smrgstatic void 45371d7fec4SmrgNscIdentify(int flags) 45471d7fec4Smrg{ 45571d7fec4Smrg xf86PrintChipsets(NSC_NAME, 45671d7fec4Smrg "Nsc family driver (version " NSC_VERSION_NAME ") " 45771d7fec4Smrg "for chipsets", GeodeChipsets); 45871d7fec4Smrg} 45971d7fec4Smrg 46071d7fec4Smrg/*---------------------------------------------------------------------------- 46171d7fec4Smrg * NscAvailableOptions. 46271d7fec4Smrg * 46371d7fec4Smrg * Description :This function returns the geodeoptions set geodeoption 46471d7fec4Smrg * 46571d7fec4Smrg * Parameters. 46671d7fec4Smrg * chipid :This will identify the chipset. 46771d7fec4Smrg * busid :This will identify the PCI busid 46871d7fec4Smrg * 46971d7fec4Smrg * Returns :ptr to GeodeOptions. 47071d7fec4Smrg * 47171d7fec4Smrg * Comments :none 47271d7fec4Smrg * 47371d7fec4Smrg*---------------------------------------------------------------------------- 47471d7fec4Smrg*/ 47571d7fec4Smrgstatic const OptionInfoRec * 47671d7fec4SmrgNscAvailableOptions(int chipid, int busid) 47771d7fec4Smrg{ 47871d7fec4Smrg return GeodeOptions; 47971d7fec4Smrg} 48071d7fec4Smrg 48171d7fec4Smrg/*---------------------------------------------------------------------------- 48271d7fec4Smrg * NscProbe. 48371d7fec4Smrg * 48471d7fec4Smrg * Description :This is to find that hardware is claimed by another 48571d7fec4Smrg * driver if not claim the slot & allocate ScreenInfoRec. 48671d7fec4Smrg * 48771d7fec4Smrg * Parameters. 48871d7fec4Smrg * drv :a pointer to the geode driver 48971d7fec4Smrg * flags :flags may passed to check the config and probe detect 49071d7fec4Smrg * 49171d7fec4Smrg * Returns :TRUE on success and FALSE on failure. 49271d7fec4Smrg * 49371d7fec4Smrg * Comments :This should ne minimal probe and it should under no 49471d7fec4Smrg * circumstances change the state of the hardware.Don't do 49571d7fec4Smrg * any intiallizations other than the required 49671d7fec4Smrg * ScreenInforec. 49771d7fec4Smrg*---------------------------------------------------------------------------- 49871d7fec4Smrg*/ 49971d7fec4Smrg 50071d7fec4Smrgstatic Bool 50171d7fec4SmrgNscProbe(DriverPtr drv, int flags) 50271d7fec4Smrg{ 50371d7fec4Smrg Bool foundScreen = FALSE; 50471d7fec4Smrg int numDevSections, numUsed; 50571d7fec4Smrg GDevPtr *devSections = NULL; 50671d7fec4Smrg int *usedChips = NULL; 50771d7fec4Smrg int i; 50871d7fec4Smrg 50971d7fec4Smrg GeodeDebug(("NscProbe: Probing for supported devices!\n")); 51071d7fec4Smrg /* 51171d7fec4Smrg * * Find the config file Device sections that match this 51271d7fec4Smrg * * driver, and return if there are none. 51371d7fec4Smrg */ 51471d7fec4Smrg if ((numDevSections = xf86MatchDevice(NSC_NAME, &devSections)) <= 0) { 51571d7fec4Smrg GeodeDebug(("NscProbe: failed 1!\n")); 51671d7fec4Smrg return FALSE; 51771d7fec4Smrg } 51871d7fec4Smrg GeodeDebug(("NscProbe: Before MatchPciInstances!\n")); 51971d7fec4Smrg /* PCI BUS */ 52071d7fec4Smrg if (xf86GetPciVideoInfo()) { 52171d7fec4Smrg numUsed = xf86MatchPciInstances(NSC_NAME, PCI_VENDOR_ID_NS, 52271d7fec4Smrg GeodeChipsets, GeodePCIchipsets, 52371d7fec4Smrg devSections, numDevSections, 52471d7fec4Smrg drv, &usedChips); 52571d7fec4Smrg if (numUsed <= 0) { 52671d7fec4Smrg /* Check for old CYRIX vendor ID (5530) */ 52771d7fec4Smrg numUsed = xf86MatchPciInstances(NSC_NAME, 52871d7fec4Smrg PCI_VENDOR_ID_CYRIX, 52971d7fec4Smrg GeodeChipsets, GeodePCIchipsets, 53071d7fec4Smrg devSections, numDevSections, 53171d7fec4Smrg drv, &usedChips); 53271d7fec4Smrg } 53371d7fec4Smrg 53471d7fec4Smrg GeodeDebug(("NscProbe: MatchPCI (%d)!\n", numUsed)); 53571d7fec4Smrg 53671d7fec4Smrg if (numUsed > 0) { 53771d7fec4Smrg if (flags & PROBE_DETECT) 53871d7fec4Smrg foundScreen = TRUE; 53971d7fec4Smrg else { 54071d7fec4Smrg /* Durango only supports one instance, */ 54171d7fec4Smrg /* so take the first one */ 54271d7fec4Smrg for (i = 0; i < numUsed; i++) { 54371d7fec4Smrg /* Allocate a ScrnInfoRec */ 54471d7fec4Smrg ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); 54571d7fec4Smrg 54671d7fec4Smrg EntityInfoPtr pEnt = xf86GetEntityInfo(usedChips[i]); 54771d7fec4Smrg PciChipsets *p_id; 54871d7fec4Smrg 54971d7fec4Smrg for (p_id = GeodePCIchipsets; p_id->numChipset != -1; p_id++) { 55071d7fec4Smrg if (pEnt->chipset == p_id->numChipset) { 55171d7fec4Smrg CPUDetected = GX1; 55271d7fec4Smrg if (pEnt->chipset == PCI_CHIP_REDCLOUD) 55371d7fec4Smrg CPUDetected = GX2; 55471d7fec4Smrg break; 55571d7fec4Smrg } 55671d7fec4Smrg } 55771d7fec4Smrg xfree(pEnt); 55871d7fec4Smrg GeodeDebug(("NscProbe: CPUDetected %d!\n", CPUDetected)); 55971d7fec4Smrg 56071d7fec4Smrg pScrn->driverName = NSC_DRIVER_NAME; 56171d7fec4Smrg pScrn->name = NSC_NAME; 56271d7fec4Smrg pScrn->Probe = NscProbe; 56371d7fec4Smrg 56471d7fec4Smrg if (CPUDetected == GX1) { 56571d7fec4Smrg GX1SetupChipsetFPtr(pScrn); 56671d7fec4Smrg } else { /* GX2 */ 56771d7fec4Smrg GX2SetupChipsetFPtr(pScrn); 56871d7fec4Smrg } 56971d7fec4Smrg 57071d7fec4Smrg foundScreen = TRUE; 57171d7fec4Smrg xf86ConfigActivePciEntity(pScrn, 57271d7fec4Smrg usedChips[i], 57371d7fec4Smrg GeodePCIchipsets, 57471d7fec4Smrg NULL, NULL, NULL, NULL, NULL); 57571d7fec4Smrg } 57671d7fec4Smrg } 57771d7fec4Smrg } 57871d7fec4Smrg } 57971d7fec4Smrg 58071d7fec4Smrg if (usedChips) 58171d7fec4Smrg xfree(usedChips); 58271d7fec4Smrg if (devSections) 58371d7fec4Smrg xfree(devSections); 58471d7fec4Smrg GeodeDebug(("NscProbe: result (%d)!\n", foundScreen)); 58571d7fec4Smrg return foundScreen; 58671d7fec4Smrg} 587