1f29dbc25Smrg/* 2c744f008Smrg * Copyright (c) 2006 Advanced Micro Devices, Inc. 3f29dbc25Smrg * 4f29dbc25Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5f29dbc25Smrg * copy of this software and associated documentation files (the "Software"), 6f29dbc25Smrg * to deal in the Software without restriction, including without limitation 7f29dbc25Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8f29dbc25Smrg * and/or sell copies of the Software, and to permit persons to whom the 9f29dbc25Smrg * Software is furnished to do so, subject to the following conditions: 10f29dbc25Smrg * 11f29dbc25Smrg * The above copyright notice and this permission notice shall be included in 12f29dbc25Smrg * all copies or substantial portions of the Software. 13f29dbc25Smrg * 14f29dbc25Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15f29dbc25Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16f29dbc25Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17f29dbc25Smrg * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18f29dbc25Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19f29dbc25Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20f29dbc25Smrg * DEALINGS IN THE SOFTWARE. 21f29dbc25Smrg * 22f29dbc25Smrg * Neither the name of the Advanced Micro Devices, Inc. nor the names of its 23f29dbc25Smrg * contributors may be used to endorse or promote products derived from this 24f29dbc25Smrg * software without specific prior written permission. 25f29dbc25Smrg */ 26f29dbc25Smrg 27f29dbc25Smrg/* 28f29dbc25Smrg * File Contents: This is the main module configures the interfacing 29f29dbc25Smrg * with the X server. The individual modules will be 30f29dbc25Smrg * loaded based upon the options selected from the 31f29dbc25Smrg * XF86Config. This file also has modules for finding 32f29dbc25Smrg * supported modes, turning on the modes based on options. 33f29dbc25Smrg * 34f29dbc25Smrg * Project: Amd Xfree Frame buffer device driver. 35f29dbc25Smrg * 36f29dbc25Smrg */ 37f29dbc25Smrg 38f29dbc25Smrg#ifdef HAVE_CONFIG_H 39f29dbc25Smrg#include "config.h" 40f29dbc25Smrg#endif 41f29dbc25Smrg 4200be8644Schristos#include "xorg-server.h" 4300be8644Schristos 44f29dbc25Smrg/* Includes that are used by all drivers */ 45f29dbc25Smrg#include "xf86.h" 46f29dbc25Smrg#include "xf86_OSproc.h" 47f29dbc25Smrg#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 48f29dbc25Smrg#include "xf86Resources.h" 49f29dbc25Smrg#endif 50f29dbc25Smrg#include "compiler.h" 5100be8644Schristos// #include "xf86PciInfo.h" 52f29dbc25Smrg#include "xf86Pci.h" 53f29dbc25Smrg#include "xf86cmap.h" 54f29dbc25Smrg 55f29dbc25Smrg#include "geode.h" 56f29dbc25Smrg 57f29dbc25Smrg#define RC_MAX_DEPTH 24 58f29dbc25Smrg 59f29dbc25Smrg#include "fb.h" 60f29dbc25Smrg 61f29dbc25Smrg/* Machine independent stuff */ 62f29dbc25Smrg#include "mipointer.h" 63f29dbc25Smrg#include "micmap.h" 64f29dbc25Smrg#include "vgaHW.h" 65f29dbc25Smrg#include "vbe.h" 66f29dbc25Smrg 67f29dbc25Smrg#ifdef DPMSExtension 68f29dbc25Smrg#include "globals.h" 69f29dbc25Smrg#include "opaque.h" 70f29dbc25Smrg#ifdef HAVE_XEXTPROTO_71 71f29dbc25Smrg#include <X11/extensions/dpmsconst.h> 72f29dbc25Smrg#else 73f29dbc25Smrg#define DPMS_SERVER 74f29dbc25Smrg#include <X11/extensions/dpms.h> 75f29dbc25Smrg#endif 76f29dbc25Smrg 7704007ebaSmrg#endif /* DPMSExtension */ 78f29dbc25Smrg 79f29dbc25Smrg/* A few things all drivers should have */ 80f29dbc25Smrg#define GEODE_NAME "GEODE" 81f29dbc25Smrg#define GEODE_DRIVER_NAME "geode" 82f29dbc25Smrg#define GEODE_VERSION 4000 83f29dbc25Smrg#define GEODE_VERSION_MAJOR PACKAGE_VERSION_MAJOR 84f29dbc25Smrg#define GEODE_VERSION_MINOR PACKAGE_VERSION_MINOR 85f29dbc25Smrg#define GEODE_VERSION_PATCH PACKAGE_VERSION_PATCHLEVEL 86f29dbc25Smrg 87f29dbc25Smrg/* Forward definitions */ 88f29dbc25Smrgstatic const OptionInfoRec *AmdAvailableOptions(int chipid, int busid); 89f29dbc25Smrgstatic void AmdIdentify(int); 90f29dbc25Smrg 91f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 92f29dbc25Smrgstatic Bool AmdPciProbe(DriverPtr, int, struct pci_device *, intptr_t); 93f29dbc25Smrg#else 94f29dbc25Smrgstatic Bool AmdProbe(DriverPtr, int); 95f29dbc25Smrg#endif 96f29dbc25Smrg 97f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 98f29dbc25Smrgstatic const struct pci_id_match amdDeviceMatch[] = { 99f29dbc25Smrg {PCI_VENDOR_ID_NS, PCI_CHIP_GEODEGX, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 10004007ebaSmrg 0}, 101f29dbc25Smrg {PCI_VENDOR_ID_AMD, PCI_CHIP_GEODELX, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 10204007ebaSmrg 0}, 103f29dbc25Smrg {0, 0, 0} 104f29dbc25Smrg}; 10504007ebaSmrg#endif /* XSERVER_LIBPCIACCESS */ 106f29dbc25Smrg 107f29dbc25Smrg/* driver record contains the functions needed by the server after loading 108f29dbc25Smrg * the driver module. 109f29dbc25Smrg */ 110f29dbc25Smrg_X_EXPORT DriverRec AMD = { 111f29dbc25Smrg GEODE_VERSION, 112f29dbc25Smrg "amd", 113f29dbc25Smrg AmdIdentify, 114f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 115f29dbc25Smrg NULL, 116f29dbc25Smrg#else 117f29dbc25Smrg AmdProbe, 118f29dbc25Smrg#endif 119f29dbc25Smrg AmdAvailableOptions, 120f29dbc25Smrg NULL, 121f29dbc25Smrg 0, 122f29dbc25Smrg NULL, 123f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 124f29dbc25Smrg amdDeviceMatch, 125f29dbc25Smrg AmdPciProbe 126f29dbc25Smrg#endif 127f29dbc25Smrg}; 128f29dbc25Smrg 129f29dbc25Smrg_X_EXPORT DriverRec GEODE = { 130f29dbc25Smrg GEODE_VERSION, 131f29dbc25Smrg "geode", 132f29dbc25Smrg AmdIdentify, 133f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 134f29dbc25Smrg NULL, 135f29dbc25Smrg#else 136f29dbc25Smrg AmdProbe, 137f29dbc25Smrg#endif 138f29dbc25Smrg AmdAvailableOptions, 139f29dbc25Smrg NULL, 140f29dbc25Smrg 0, 141f29dbc25Smrg NULL, 142f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 143f29dbc25Smrg amdDeviceMatch, 144f29dbc25Smrg AmdPciProbe 145f29dbc25Smrg#endif 146f29dbc25Smrg}; 147f29dbc25Smrg 148f29dbc25Smrg/* Advanced Micro Devices Chip Models */ 14904007ebaSmrgtypedef struct _DEVICE_MODEL { 150f29dbc25Smrg int DeviceId; 151f29dbc25Smrg int Model; 15204007ebaSmrg} DeviceModel; 153f29dbc25Smrg 154f29dbc25SmrgDeviceModel ChipModel[] = { 155f29dbc25Smrg#ifdef HAVE_LX 156f29dbc25Smrg {PCI_CHIP_GEODELX, LX}, 157f29dbc25Smrg#endif 158f29dbc25Smrg#ifdef HAVE_GX 159f29dbc25Smrg {PCI_CHIP_GEODEGX, GX}, 160f29dbc25Smrg#endif 161f29dbc25Smrg {-1, 0} 162f29dbc25Smrg}; 163f29dbc25Smrg 164f29dbc25Smrg/* Supported chipsets */ 165f29dbc25SmrgSymTabRec GeodeChipsets[] = { 166f29dbc25Smrg#ifdef HAVE_LX 167f29dbc25Smrg {PCI_CHIP_GEODELX, "Geode LX"}, 168f29dbc25Smrg#endif 169f29dbc25Smrg#ifdef HAVE_GX 170f29dbc25Smrg {PCI_CHIP_GEODEGX, "Geode GX"}, 171f29dbc25Smrg#endif 172f29dbc25Smrg {-1, NULL} 173f29dbc25Smrg}; 174f29dbc25Smrg 175f29dbc25SmrgPciChipsets GeodePCIchipsets[] = { 176f29dbc25Smrg#ifdef HAVE_LX 177f29dbc25Smrg {PCI_CHIP_GEODELX, PCI_CHIP_GEODELX, RES_SHARED_VGA}, 178f29dbc25Smrg#endif 179f29dbc25Smrg#ifdef HAVE_GX 180f29dbc25Smrg {PCI_CHIP_GEODEGX, PCI_CHIP_GEODEGX, RES_SHARED_VGA}, 181f29dbc25Smrg#endif 182f29dbc25Smrg {-1, -1, RES_UNDEFINED}, 183f29dbc25Smrg}; 184f29dbc25Smrg 185f29dbc25Smrg#ifdef HAVE_LX 186f29dbc25Smrg 187f29dbc25SmrgOptionInfoRec LX_GeodeOptions[] = { 188f29dbc25Smrg {LX_OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, 189f29dbc25Smrg {LX_OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE}, 190f29dbc25Smrg {LX_OPTION_NOCOMPRESSION, "NoCompression", OPTV_BOOLEAN, {0}, FALSE}, 191f29dbc25Smrg {LX_OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, 192f29dbc25Smrg {LX_OPTION_TV_SUPPORT, "TV", OPTV_ANYSTR, {0}, FALSE}, 193f29dbc25Smrg {LX_OPTION_TV_OUTPUT, "TV_Output", OPTV_ANYSTR, {0}, FALSE}, 194f29dbc25Smrg {LX_OPTION_TV_OVERSCAN, "TVOverscan", OPTV_ANYSTR, {0}, FALSE}, 195f29dbc25Smrg {LX_OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, 196f29dbc25Smrg {LX_OPTION_NOPANEL, "NoPanel", OPTV_BOOLEAN, {0}, FALSE}, 197f29dbc25Smrg {LX_OPTION_EXA_SCRATCH_BFRSZ, "ExaScratch", OPTV_INTEGER, {0}, FALSE}, 198f29dbc25Smrg {LX_OPTION_FBSIZE, "FBSize", OPTV_INTEGER, {0}, FALSE}, 199f29dbc25Smrg {LX_OPTION_PANEL_MODE, "PanelMode", OPTV_STRING, {0}, FALSE}, 200f29dbc25Smrg {-1, NULL, OPTV_NONE, {0}, FALSE} 201f29dbc25Smrg}; 202f29dbc25Smrg 203f29dbc25Smrg#endif 204f29dbc25Smrg 205f29dbc25Smrg#ifdef HAVE_GX 206f29dbc25Smrg 207f29dbc25SmrgOptionInfoRec GX_GeodeOptions[] = { 208f29dbc25Smrg {GX_OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, 209f29dbc25Smrg {GX_OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE}, 210f29dbc25Smrg {GX_OPTION_NOCOMPRESSION, "NoCompression", OPTV_BOOLEAN, {0}, FALSE}, 211f29dbc25Smrg {GX_OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, 212f29dbc25Smrg {GX_OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, FALSE}, 213f29dbc25Smrg {GX_OPTION_TV_SUPPORT, "TV", OPTV_ANYSTR, {0}, FALSE}, 214f29dbc25Smrg {GX_OPTION_TV_OUTPUT, "TV_Output", OPTV_ANYSTR, {0}, FALSE}, 215f29dbc25Smrg {GX_OPTION_TV_OVERSCAN, "TVOverscan", OPTV_ANYSTR, {0}, FALSE}, 216f29dbc25Smrg {GX_OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, 217f29dbc25Smrg {GX_OPTION_NOPANEL, "NoPanel", OPTV_BOOLEAN, {0}, FALSE}, 218f29dbc25Smrg {GX_OPTION_OSM_IMG_BUFS, "OSMImageBuffers", OPTV_INTEGER, {0}, FALSE}, 219f29dbc25Smrg {GX_OPTION_OSM_CLR_BUFS, "OSMColorExpBuffers", OPTV_INTEGER, {0}, FALSE}, 220f29dbc25Smrg {GX_OPTION_FBSIZE, "FBSize", OPTV_INTEGER, {0}, FALSE}, 221f29dbc25Smrg {GX_OPTION_PANEL_GEOMETRY, "PanelGeometry", OPTV_STRING, {0}, FALSE}, 222f29dbc25Smrg {-1, NULL, OPTV_NONE, {0}, FALSE} 223f29dbc25Smrg}; 224f29dbc25Smrg#endif 225f29dbc25Smrg 226f29dbc25SmrgOptionInfoRec no_GeodeOptions[] = { 227f29dbc25Smrg {-1, NULL, OPTV_NONE, {0}, FALSE} 228f29dbc25Smrg}; 229f29dbc25Smrg 230f29dbc25Smrg#ifdef XFree86LOADER 231f29dbc25Smrg 232f29dbc25Smrg/* Module loader interface */ 233f29dbc25Smrg 234f29dbc25Smrgstatic MODULESETUPPROTO(AmdSetup); 235f29dbc25Smrg 236f29dbc25Smrgstatic XF86ModuleVersionInfo AmdVersionRec = { 237f29dbc25Smrg "amd", 238f29dbc25Smrg MODULEVENDORSTRING, 239f29dbc25Smrg MODINFOSTRING1, 240f29dbc25Smrg MODINFOSTRING2, 241f29dbc25Smrg XORG_VERSION_CURRENT, 242f29dbc25Smrg GEODE_VERSION_MAJOR, GEODE_VERSION_MINOR, GEODE_VERSION_PATCH, 24304007ebaSmrg ABI_CLASS_VIDEODRV, /* This is a video driver */ 244f29dbc25Smrg ABI_VIDEODRV_VERSION, 245f29dbc25Smrg MOD_CLASS_VIDEODRV, 246f29dbc25Smrg {0, 0, 0, 0} 247f29dbc25Smrg}; 248f29dbc25Smrg 249f29dbc25Smrgstatic XF86ModuleVersionInfo GeodeVersionRec = { 250f29dbc25Smrg "geode", 251f29dbc25Smrg MODULEVENDORSTRING, 252f29dbc25Smrg MODINFOSTRING1, 253f29dbc25Smrg MODINFOSTRING2, 254f29dbc25Smrg XORG_VERSION_CURRENT, 255f29dbc25Smrg GEODE_VERSION_MAJOR, GEODE_VERSION_MINOR, GEODE_VERSION_PATCH, 25604007ebaSmrg ABI_CLASS_VIDEODRV, /* This is a video driver */ 257f29dbc25Smrg ABI_VIDEODRV_VERSION, 258f29dbc25Smrg MOD_CLASS_VIDEODRV, 259f29dbc25Smrg {0, 0, 0, 0} 260f29dbc25Smrg}; 261f29dbc25Smrg 262f29dbc25Smrgstatic pointer 263f29dbc25SmrgGeodeSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) 264f29dbc25Smrg{ 265f29dbc25Smrg static Bool init = FALSE; 266f29dbc25Smrg int flag = 0; 267f29dbc25Smrg 268f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 269f29dbc25Smrg flag = HaveDriverFuncs; 270f29dbc25Smrg#endif 271f29dbc25Smrg if (init) { 27204007ebaSmrg *ErrorMajor = LDR_ONCEONLY; 27304007ebaSmrg return (pointer) NULL; 274f29dbc25Smrg } 275f29dbc25Smrg 276f29dbc25Smrg init = TRUE; 277f29dbc25Smrg xf86AddDriver(&GEODE, Module, flag); 278f29dbc25Smrg 279f29dbc25Smrg return (pointer) TRUE; 280f29dbc25Smrg} 281f29dbc25Smrg 282f29dbc25Smrgstatic pointer 283f29dbc25SmrgAmdSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) 284f29dbc25Smrg{ 285f29dbc25Smrg static Bool Initialised = FALSE; 286f29dbc25Smrg 287f29dbc25Smrg if (!Initialised) { 28804007ebaSmrg Initialised = TRUE; 28904007ebaSmrg xf86AddDriver(&AMD, Module, 290f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 29104007ebaSmrg HaveDriverFuncs 292f29dbc25Smrg#else 29304007ebaSmrg 0 294f29dbc25Smrg#endif 29504007ebaSmrg ); 296f29dbc25Smrg 29704007ebaSmrg return (pointer) TRUE; 298f29dbc25Smrg } 299f29dbc25Smrg 300f29dbc25Smrg /*The return value must be non-NULL on success */ 301f29dbc25Smrg if (ErrorMajor) 30204007ebaSmrg *ErrorMajor = LDR_ONCEONLY; 303f29dbc25Smrg return NULL; 304f29dbc25Smrg} 305f29dbc25Smrg 306f29dbc25Smrg_X_EXPORT XF86ModuleData amdModuleData = { &AmdVersionRec, AmdSetup, NULL }; 307f29dbc25Smrg_X_EXPORT XF86ModuleData geodeModuleData = 308f29dbc25Smrg { &GeodeVersionRec, GeodeSetup, NULL }; 309f29dbc25Smrg 31004007ebaSmrg#endif /*End of XFree86Loader */ 311f29dbc25Smrg 312f29dbc25Smrg/*------------------------------------------------------------------------- 313f29dbc25Smrg * AmdIdentify. 314f29dbc25Smrg * 315f29dbc25Smrg * Description : This function identify an Amdfamily version. 316f29dbc25Smrg * 317f29dbc25Smrg * 318f29dbc25Smrg * Parameters. 319f29dbc25Smrg * flags : flags may be used in PreInit* 320f29dbc25Smrg * 321f29dbc25Smrg * Returns : none 322f29dbc25Smrg * 323f29dbc25Smrg * Comments : none 324f29dbc25Smrg * 325f29dbc25Smrg*------------------------------------------------------------------------ 326f29dbc25Smrg*/ 327f29dbc25Smrgstatic void 328f29dbc25SmrgAmdIdentify(int flags) 329f29dbc25Smrg{ 330f29dbc25Smrg xf86PrintChipsets(GEODE_NAME, "Driver for AMD Geode Chipsets", 33104007ebaSmrg GeodeChipsets); 332f29dbc25Smrg} 333f29dbc25Smrg 334f29dbc25Smrg/*---------------------------------------------------------------------------- 335f29dbc25Smrg * AmdAvailableOptions. 336f29dbc25Smrg * 337f29dbc25Smrg * Description :This function returns the geodeoptions set geodeoption 338f29dbc25Smrg * 339f29dbc25Smrg * Parameters. 340f29dbc25Smrg * chipid :This will identify the chipset. 341f29dbc25Smrg * busid :This will identify the PCI busid 342f29dbc25Smrg * 343f29dbc25Smrg * Returns :ptr to GeodeOptions. 344f29dbc25Smrg * 345f29dbc25Smrg * Comments :none 346f29dbc25Smrg * 347f29dbc25Smrg*---------------------------------------------------------------------------- 348f29dbc25Smrg*/ 349f29dbc25Smrgstatic const OptionInfoRec * 350f29dbc25SmrgAmdAvailableOptions(int chipid, int busid) 351f29dbc25Smrg{ 352f29dbc25Smrg switch (chipid) { 353f29dbc25Smrg#ifdef HAVE_LX 354f29dbc25Smrg case PCI_CHIP_GEODELX: 35504007ebaSmrg return LX_GeodeOptions; 356f29dbc25Smrg#endif 357f29dbc25Smrg#ifdef HAVE_GX 358f29dbc25Smrg case PCI_CHIP_GEODEGX: 35904007ebaSmrg return GX_GeodeOptions; 360f29dbc25Smrg#endif 361f29dbc25Smrg } 362f29dbc25Smrg return no_GeodeOptions; 363f29dbc25Smrg} 364f29dbc25Smrg 365f29dbc25Smrg#ifdef XSERVER_LIBPCIACCESS 366f29dbc25Smrg 367f29dbc25Smrgstatic Bool 368f29dbc25SmrgAmdPciProbe(DriverPtr driver, 36904007ebaSmrg int entity_num, struct pci_device *device, intptr_t match_data) 370f29dbc25Smrg{ 371f29dbc25Smrg ScrnInfoPtr scrn = NULL; 372f29dbc25Smrg 373f29dbc25Smrg ErrorF("AmdPciProbe: Probing for supported devices!\n"); 374f29dbc25Smrg 375f29dbc25Smrg scrn = xf86ConfigPciEntity(scrn, 0, entity_num, GeodePCIchipsets, 37604007ebaSmrg NULL, NULL, NULL, NULL, NULL); 377f29dbc25Smrg 378f29dbc25Smrg if (scrn != NULL) { 37904007ebaSmrg scrn->driverName = GEODE_DRIVER_NAME; 38004007ebaSmrg scrn->driverVersion = GEODE_VERSION; 38104007ebaSmrg scrn->name = GEODE_NAME; 38204007ebaSmrg scrn->Probe = NULL; 383f29dbc25Smrg 38404007ebaSmrg switch (device->device_id) { 385f29dbc25Smrg#ifdef HAVE_LX 38604007ebaSmrg case PCI_CHIP_GEODELX: 38704007ebaSmrg LXSetupChipsetFPtr(scrn); 38804007ebaSmrg break; 389f29dbc25Smrg#endif 390f29dbc25Smrg#ifdef HAVE_GX 39104007ebaSmrg case PCI_CHIP_GEODEGX: 39204007ebaSmrg GXSetupChipsetFPtr(scrn); 39304007ebaSmrg break; 394f29dbc25Smrg#endif 39504007ebaSmrg default: 39604007ebaSmrg ErrorF("AmdPciProbe: unknown device ID\n"); 39704007ebaSmrg return FALSE; 39804007ebaSmrg } 399f29dbc25Smrg } 400f29dbc25Smrg return scrn != NULL; 401f29dbc25Smrg} 402f29dbc25Smrg 40304007ebaSmrg#else /* XSERVER_LIBPCIACCESS */ 404f29dbc25Smrg 405f29dbc25Smrg/*---------------------------------------------------------------------------- 406f29dbc25Smrg * AmdProbe. 407f29dbc25Smrg * 408f29dbc25Smrg * Description :This is to find that hardware is claimed by another 409f29dbc25Smrg * driver if not claim the slot & allocate ScreenInfoRec. 410f29dbc25Smrg * 411f29dbc25Smrg * Parameters. 412f29dbc25Smrg * drv :a pointer to the geode driver 413f29dbc25Smrg * flags :flags may passed to check the config and probe detect 414f29dbc25Smrg * 415f29dbc25Smrg * Returns :TRUE on success and FALSE on failure. 416f29dbc25Smrg * 417f29dbc25Smrg * Comments :This should be minimal probe and it should under no 418f29dbc25Smrg * circumstances change the state of the hardware.Don't do 419c744f008Smrg * any initializations other than the required 420f29dbc25Smrg * ScreenInforec. 421f29dbc25Smrg*---------------------------------------------------------------------------- 422f29dbc25Smrg*/ 423f29dbc25Smrg 424f29dbc25Smrgstatic Bool 425f29dbc25SmrgAmdProbe(DriverPtr drv, int flags) 426f29dbc25Smrg{ 427f29dbc25Smrg Bool foundScreen = FALSE; 428f29dbc25Smrg int numDevSections, numUsed; 429f29dbc25Smrg GDevPtr *devSections = NULL; 430f29dbc25Smrg int *usedChips = NULL; 431f29dbc25Smrg int i; 432f29dbc25Smrg void (*drvr_setup) (ScrnInfoPtr pScrni) = NULL; 433f29dbc25Smrg int CPUDetected; 434f29dbc25Smrg 435f29dbc25Smrg DEBUGMSG(1, (0, X_INFO, "AmdProbe: Probing for supported devices!\n")); 436f29dbc25Smrg /* 437f29dbc25Smrg * * Find the config file Device sections that match this 438f29dbc25Smrg * * driver, and return if there are none. 439f29dbc25Smrg */ 440f29dbc25Smrg if ((numDevSections = xf86MatchDevice(GEODE_NAME, &devSections)) <= 0) { 44104007ebaSmrg DEBUGMSG(1, (0, X_INFO, "AmdProbe: failed 1!\n")); 44204007ebaSmrg return FALSE; 443f29dbc25Smrg } 444f29dbc25Smrg DEBUGMSG(1, (0, X_INFO, "AmdProbe: Before MatchPciInstances!\n")); 445f29dbc25Smrg /* PCI BUS */ 446f29dbc25Smrg if (xf86GetPciVideoInfo()) { 44704007ebaSmrg numUsed = xf86MatchPciInstances(GEODE_NAME, PCI_VENDOR_ID_NS, 44804007ebaSmrg GeodeChipsets, GeodePCIchipsets, 44904007ebaSmrg devSections, numDevSections, drv, 45004007ebaSmrg &usedChips); 45104007ebaSmrg 45204007ebaSmrg if (numUsed <= 0) 45304007ebaSmrg numUsed = xf86MatchPciInstances(GEODE_NAME, PCI_VENDOR_ID_AMD, 45404007ebaSmrg GeodeChipsets, GeodePCIchipsets, 45504007ebaSmrg devSections, numDevSections, drv, 45604007ebaSmrg &usedChips); 45704007ebaSmrg 45804007ebaSmrg DEBUGMSG(1, (0, X_INFO, "AmdProbe: MatchPCI (%d)!\n", numUsed)); 45904007ebaSmrg 46004007ebaSmrg if (numUsed > 0) { 46104007ebaSmrg if (flags & PROBE_DETECT) 46204007ebaSmrg foundScreen = TRUE; 46304007ebaSmrg else { 46404007ebaSmrg /* Durango only supports one instance, */ 46504007ebaSmrg /* so take the first one */ 46604007ebaSmrg for (i = 0; i < numUsed; i++) { 46704007ebaSmrg /* Allocate a ScrnInfoRec */ 46804007ebaSmrg ScrnInfoPtr pScrni = NULL; 46904007ebaSmrg EntityInfoPtr pEnt = xf86GetEntityInfo(usedChips[i]); 47004007ebaSmrg PciChipsets *p_id; 47104007ebaSmrg 47204007ebaSmrg pScrni = xf86ConfigPciEntity(pScrni, 0, usedChips[i], 47304007ebaSmrg GeodePCIchipsets, NULL, NULL, 47404007ebaSmrg NULL, NULL, NULL); 47504007ebaSmrg for (p_id = GeodePCIchipsets; p_id->numChipset != -1; 47604007ebaSmrg p_id++) { 47704007ebaSmrg if (pEnt->chipset == p_id->numChipset) { 47804007ebaSmrg switch (pEnt->chipset) { 479f29dbc25Smrg#ifdef HAVE_LX 48004007ebaSmrg case PCI_CHIP_GEODELX: 48104007ebaSmrg CPUDetected = LX; 48204007ebaSmrg drvr_setup = &LXSetupChipsetFPtr; 48304007ebaSmrg break; 484f29dbc25Smrg#endif 485f29dbc25Smrg#ifdef HAVE_GX 48604007ebaSmrg case PCI_CHIP_GEODEGX: 48704007ebaSmrg CPUDetected = GX; 48804007ebaSmrg drvr_setup = &GXSetupChipsetFPtr; 48904007ebaSmrg break; 490f29dbc25Smrg#endif 49104007ebaSmrg default: 49204007ebaSmrg break; 49304007ebaSmrg } 49404007ebaSmrg break; 49504007ebaSmrg } 49604007ebaSmrg } 49704007ebaSmrg free(pEnt); 49804007ebaSmrg if (drvr_setup == NULL) 49904007ebaSmrg return FALSE; 50004007ebaSmrg 50104007ebaSmrg DEBUGMSG(1, (0, X_INFO, "AmdProbe: CPUDetected %d!\n", 50204007ebaSmrg CPUDetected)); 50304007ebaSmrg 50404007ebaSmrg pScrni->driverName = GEODE_DRIVER_NAME; 50504007ebaSmrg pScrni->driverVersion = GEODE_VERSION; 50604007ebaSmrg pScrni->name = GEODE_NAME; 50704007ebaSmrg pScrni->Probe = AmdProbe; 50804007ebaSmrg drvr_setup(pScrni); 50904007ebaSmrg 51004007ebaSmrg foundScreen = TRUE; 51104007ebaSmrg 51204007ebaSmrg } 51304007ebaSmrg } 51404007ebaSmrg } 515f29dbc25Smrg } 516f29dbc25Smrg 517f29dbc25Smrg if (usedChips) 51804007ebaSmrg free(usedChips); 519f29dbc25Smrg if (devSections) 52004007ebaSmrg free(devSections); 521f29dbc25Smrg DEBUGMSG(1, (0, X_INFO, "AmdProbe: result (%d)!\n", foundScreen)); 522f29dbc25Smrg return foundScreen; 523f29dbc25Smrg} 524f29dbc25Smrg 52504007ebaSmrg#endif /* else XSERVER_LIBPCIACCESS */ 526