6420309: auto-config improve: Need to move VBE DDC fallback probing from server to drivers
authorHenry Zhao <Henry.Zhao@Sun.COM>
Mon, 12 Jun 2006 13:53:11 -0700
changeset 31 6fef7fb81fc7
parent 30 09d07a831488
child 32 235a80428f96
6420309: auto-config improve: Need to move VBE DDC fallback probing from server to drivers
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86.h
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/vbe/vbe.c
XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/vbe/vbe_module.c
XORG_NV/sun-src/xf86-video-ati-6.5.8.0/src/r128_driver.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86.h	Mon Jun 12 13:53:11 2006 -0700
@@ -0,0 +1,449 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.173 2004/01/27 01:31:44 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains declarations for public XFree86 functions and variables,
+ * and definitions of public macros.
+ *
+ * "public" means available to video drivers.
+ */
+
+#ifndef _XF86_H
+#define _XF86_H
+
+#include "xf86str.h"
+#include "xf86Opt.h"
+#include <X11/Xfuncproto.h>
+#ifndef IN_MODULE
+#include <stdarg.h>
+#else
+#include "xf86_ansic.h"
+#endif
+#ifdef RANDR
+#include <X11/extensions/randr.h>
+#endif
+
+#include "propertyst.h"
+
+/* General parameters */
+extern int xf86DoConfigure;
+extern Bool xf86DoConfigurePass1;
+extern int xf86ScreenIndex;		/* Index into pScreen.devPrivates */
+extern int xf86CreateRootWindowIndex;	/* Index into pScreen.devPrivates */
+extern int xf86PixmapIndex;
+extern Bool xf86ResAccessEnter;
+extern ScrnInfoPtr *xf86Screens;	/* List of pointers to ScrnInfoRecs */
+extern const unsigned char byte_reversed[256];
+extern ScrnInfoPtr xf86CurrentScreen;
+extern Bool pciSlotClaimed;
+extern Bool isaSlotClaimed;
+extern Bool fbSlotClaimed;
+#ifdef __sparc__
+extern Bool sbusSlotClaimed;
+#endif
+extern confDRIRec xf86ConfigDRI;
+extern Bool xf86inSuspend;
+
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
+
+#define XF86FLIP_PIXELS() \
+	do { \
+	    if (xf86GetFlipPixels()) { \
+		pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
+		pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
+	   } \
+	while (0)
+
+#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
+
+#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
+			(((p) == Pix24Use32) ? 32 : 0))
+
+/* variables for debugging */
+#ifdef BUILDDEBUG
+extern char* xf86p8bit[];
+extern CARD32 xf86DummyVar1;
+extern CARD32 xf86DummyVar2;
+extern CARD32 xf86DummyVar3;
+#endif
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Bus.c */
+
+Bool xf86CheckPciSlot(int bus, int device, int func);
+int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+		     int chipset, GDevPtr dev, Bool active);
+Bool xf86ParsePciBusString(const char *busID, int *bus, int *device,
+			   int *func);
+Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
+void xf86FormatPciBusNumber(int busnum, char *buffer);
+pciVideoPtr *xf86GetPciVideoInfo(void);
+pciConfigPtr *xf86GetPciConfigInfo(void);
+void xf86SetPciVideo(pciVideoPtr, resType);
+void xf86PrintResList(int verb, resPtr list);
+resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex);
+int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+int xf86GetIsaInfoForScreen(int scrnIndex);
+int  xf86GetFbInfoForScreen(int scrnIndex);
+Bool xf86ParseIsaBusString(const char *busID);
+int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+void xf86EnableAccess(ScrnInfoPtr pScrn);
+void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn);
+Bool xf86IsPrimaryPci(pciVideoPtr pPci);
+Bool xf86IsPrimaryIsa(void);
+int xf86CheckPciGAType(pciVideoPtr pPci);
+/* new RAC */
+resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex);
+resPtr xf86JoinResLists(resPtr rlist1, resPtr rlist2);
+resPtr xf86DupResList(const resPtr rlist);
+void xf86FreeResList(resPtr rlist);
+void xf86ClaimFixedResources(resList list, int entityIndex);
+Bool xf86DriverHasEntities(DriverPtr drvp);
+void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
+void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
+				    int instance);
+int xf86GetNumEntityInstances(int entityIndex);
+GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
+void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+EntityInfoPtr xf86GetEntityInfo(int entityIndex);
+pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
+int xf86GetPciEntity(int bus, int dev, int func);
+Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
+			EntityProc enter, EntityProc leave, pointer);
+void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type);
+resPtr xf86RegisterResources(int entityIndex, resList list,
+			     unsigned long Access);
+Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
+void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+			xf86SetAccessFuncPtr oldFuncs);
+Bool xf86IsEntityPrimary(int entityIndex);
+Bool xf86FixPciResource(int entityIndex, int prt, memType alignment,
+			unsigned long type);
+resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
+resPtr xf86SetOperatingState(resList list, int entityIndex, int mask);
+void xf86EnterServerState(xf86State state);
+resRange xf86GetBlock(unsigned long type, memType size,
+		      memType window_start, memType window_end,
+		      memType align_mask, resPtr avoid);
+resRange xf86GetSparse(unsigned long type, memType fixed_bits,
+		       memType decode_mask, memType address_mask,
+		       resPtr avoid);
+memType xf86ChkConflict(resRange *rgp, int entityIndex);
+Bool xf86IsPciDevPresent(int bus, int dev, int func);
+ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
+Bool xf86NoSharedResources(int screenIndex, resType res);
+resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
+pciVideoPtr xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
+				    char n, pciVideoPtr pvp_exclude);
+pciVideoPtr xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
+			     char n, pciVideoPtr pvp_exclude);
+#ifdef INCLUDE_DEPRECATED
+void xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable);
+#endif
+void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
+Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
+#ifdef async
+Bool xf86QueueAsyncEvent(void (*func)(pointer),pointer arg);
+#endif
+
+int xf86GetLastScrnFlag(int entityIndex);
+void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
+Bool xf86IsEntityShared(int entityIndex);
+void xf86SetEntityShared(int entityIndex);
+Bool xf86IsEntitySharable(int entityIndex);
+void xf86SetEntitySharable(int entityIndex);
+Bool xf86IsPrimInitDone(int entityIndex);
+void xf86SetPrimInitDone(int entityIndex);
+void xf86ClearPrimInitDone(int entityIndex);
+int xf86AllocateEntityPrivateIndex(void);
+DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
+
+/* xf86Configure.c */
+GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
+				    void *busData, int chipset);
+GDevPtr xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo,
+				 int chipset);
+
+/* xf86Cursor.c */
+
+void xf86LockZoom(ScreenPtr pScreen, int lock);
+void xf86InitViewport(ScrnInfoPtr pScr);
+void xf86SetViewport(ScreenPtr pScreen, int x, int y);
+void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
+Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode);
+void *xf86GetPointerScreenFuncs(void);
+void xf86InitOrigins(void);
+void xf86ReconfigureLayout(void);
+
+/* xf86DPMS.c */
+
+Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
+
+/* xf86DGA.c */
+
+Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
+			int num);
+Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num);
+xf86SetDGAModeProc xf86SetDGAMode;
+
+/* xf86Events.c */
+
+void SetTimeSinceLastInputEvent(void);
+pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
+int xf86RemoveInputHandler(pointer handler);
+void xf86DisableInputHandler(pointer handler);
+void xf86EnableInputHandler(pointer handler);
+void xf86InterceptSignals(int *signo);
+void xf86InterceptSigIll(void (*sigillhandler)(void));
+Bool xf86EnableVTSwitch(Bool new);
+Bool xf86CommonSpecialKey(int key, Bool down, int modifiers);
+void xf86ProcessActionEvent(ActionEvent action, void *arg);
+
+/* xf86Helper.c */
+
+void xf86AddDriver(DriverPtr driver, pointer module, int flags);
+void xf86DeleteDriver(int drvIndex);
+ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
+void xf86DeleteScreen(int scrnIndex, int flags);
+int xf86AllocateScrnInfoPrivateIndex(void);
+Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
+Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
+		     int depth24flags);
+void xf86PrintDepthBpp(ScrnInfoPtr scrp);
+Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
+Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
+void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
+void xf86SetBlackWhitePixels(ScreenPtr pScreen);
+void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
+void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
+		     const char *format, va_list args);
+void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+		    const char *format, ...) _printf_attribute(4,5);
+void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+		_printf_attribute(3,4);
+void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+		_printf_attribute(3,4);
+void xf86Msg(MessageType type, const char *format, ...) _printf_attribute(2,3);
+void xf86ErrorFVerb(int verb, const char *format, ...) _printf_attribute(2,3);
+void xf86ErrorF(const char *format, ...) _printf_attribute(1,2);
+const char *xf86TokenToString(SymTabPtr table, int token);
+int xf86StringToToken(SymTabPtr table, const char *string);
+void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
+void xf86PrintChipsets(const char *drvname, const char *drvmsg,
+		       SymTabPtr chips);
+int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
+int xf86MatchPciInstances(const char *driverName, int vendorID,
+		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
+		      GDevPtr *devList, int numDevs, DriverPtr drvp,
+		      int **foundEntities);
+int xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
+			  IsaChipsets *ISAchipsets, DriverPtr drvp,
+			  FindIsaDevProc FindIsaDevice, GDevPtr *devList,
+			  int numDevs, int **foundEntities);
+void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+		   Bool (*ClockFunc)(ScrnInfoPtr, int),
+		   void (*ProtectRegs)(ScrnInfoPtr, Bool),
+		   void (*BlankScreen)(ScrnInfoPtr, Bool),
+		   IOADDRESS vertsyncreg, int maskval,
+		   int knownclkindex, int knownclkvalue);
+void xf86SetPriority(Bool up);
+const char *xf86GetVisualName(int visual);
+int xf86GetVerbosity(void);
+Pix24Flags xf86GetPix24(void);
+int xf86GetDepth(void);
+rgb xf86GetWeight(void);
+Gamma xf86GetGamma(void);
+Bool xf86GetFlipPixels(void);
+const char *xf86GetServerName(void);
+Bool xf86ServerIsExiting(void);
+Bool xf86ServerIsResetting(void);
+Bool xf86ServerIsInitialising(void);
+Bool xf86ServerIsOnlyDetecting(void);
+Bool xf86ServerIsOnlyProbing(void);
+Bool xf86CaughtSignal(void);
+Bool xf86GetVidModeAllowNonLocal(void);
+Bool xf86GetVidModeEnabled(void);
+Bool xf86GetModInDevAllowNonLocal(void);
+Bool xf86GetModInDevEnabled(void);
+Bool xf86GetAllowMouseOpenFail(void);
+Bool xf86IsPc98(void);
+void xf86DisableRandR(void);
+CARD32 xf86GetVersion(void);
+CARD32 xorgGetVersion(void);
+CARD32 xf86GetModuleVersion(pointer module);
+pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+pointer xf86LoadOneModule(char *name, pointer optlist);
+void xf86UnloadSubModule(pointer mod);
+Bool xf86LoaderCheckSymbol(const char *name);
+void xf86LoaderReqSymLists(const char **, ...);
+void xf86LoaderReqSymbols(const char *, ...);
+void xf86LoaderRefSymLists(const char **, ...);
+void xf86LoaderRefSymbols(const char *, ...);
+void xf86SetBackingStore(ScreenPtr pScreen);
+void xf86SetSilkenMouse(ScreenPtr pScreen);
+int xf86NewSerialNumber(WindowPtr p, pointer unused);
+pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
+			  char **adaptor_name, pointer *adaptor_options);
+void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
+ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag,
+				int entityIndex,PciChipsets *p_chip,
+				resList res, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag,
+				int entityIndex, IsaChipsets *i_chip,
+				resList res, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
+			       int entityIndex, EntityProc init,
+			       EntityProc enter, EntityProc leave,
+			       pointer private);
+/* Obsolete! don't use */
+Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
+				int entityIndex,PciChipsets *p_chip,
+				resList res, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+/* Obsolete! don't use */
+Bool xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn,
+				int entityIndex, IsaChipsets *i_chip,
+				resList res, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+void xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+				 resList res, EntityProc init,
+				 EntityProc enter, EntityProc leave,
+				 pointer private);
+void xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip,
+				 resList res, EntityProc init,
+				 EntityProc enter, EntityProc leave,
+				 pointer private);
+void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+Bool xf86IsScreenPrimary(int scrnIndex);
+int  xf86RegisterRootWindowProperty(int ScrnIndex, Atom	property, Atom type,
+				    int format, unsigned long len,
+				    pointer value);
+Bool xf86IsUnblank(int mode);
+
+#ifdef XFree86LOADER
+void xf86AddModuleInfo(ModuleInfoPtr info, pointer module);
+void xf86DeleteModuleInfo(int idx);
+#endif
+
+/* xf86Debug.c */
+#ifdef BUILDDEBUG
+ void xf86Break1(void);
+void xf86Break2(void);
+void xf86Break3(void);
+CARD8  xf86PeekFb8(CARD8  *p);
+CARD16 xf86PeekFb16(CARD16 *p);
+CARD32 xf86PeekFb32(CARD32 *p);
+void xf86PokeFb8(CARD8  *p, CARD8  v);
+void xf86PokeFb16(CARD16 *p, CARD16 v);
+void xf86PokeFb32(CARD16 *p, CARD32 v);
+CARD8  xf86PeekMmio8(pointer Base, unsigned long Offset);
+CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset);
+CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset);
+void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8  v);
+void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v);
+void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v);
+extern void xf86SPTimestamp(xf86TsPtr* timestamp, char* string);
+extern void xf86STimestamp(xf86TsPtr* timestamp);
+#endif
+
+/* xf86Init.c */
+
+PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
+int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
+
+/* xf86Mode.c */
+
+int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+			int DivFactor, int MulFactor, int *divider);
+const char *xf86ModeStatusToString(ModeStatus status);
+ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+			  ClockRangePtr clockRanges, LookupModeFlags strategy);
+ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
+ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+					 ClockRangePtr clockRanges,
+					 LookupModeFlags strategy,
+					 int maxPitch, int virtualX,
+					 int virtualY);
+ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+				  int flags);
+int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+		      char **modeNames, ClockRangePtr clockRanges,
+		      int *linePitches, int minPitch, int maxPitch,
+		      int minHeight, int maxHeight, int pitchInc,
+		      int virtualX, int virtualY, int apertureSize,
+		      LookupModeFlags strategy);
+void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
+void xf86PruneDriverModes(ScrnInfoPtr scrp);
+void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+void xf86PrintModes(ScrnInfoPtr scrp);
+void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
+		      Bool Reduced, Bool Interlaced);
+
+/* xf86Option.c */
+
+void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
+
+
+/* xf86RandR.c */
+#ifdef RANDR
+Bool xf86RandRInit (ScreenPtr    pScreen);
+void xf86RandRSetInitialMode (ScreenPtr pScreen);
+Rotation xf86GetRotation(ScreenPtr pScreen);
+Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
+			int newvirtX, int newvirtY,
+			int newmmWidth, int newmmHeight, Bool resetMode);
+#endif
+
+/* xf86VidModeExtentionInit.c */
+
+Bool VidModeExtensionInit(ScreenPtr pScreen);
+
+/* xf86Versions.c */
+CARD32 xf86GetBuiltinInterfaceVersion(BuiltinInterface iface, int flag);
+Bool xf86RegisterBuiltinInterfaceVersion(BuiltinInterface iface,
+					 CARD32 version, int flags);
+
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+#endif /* _XF86_H */
--- a/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c	Mon Jun 12 11:08:27 2006 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,256 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Globals.c,v 1.42 2004/01/27 01:31:44 dawes Exp $ */
-
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains all the XFree86 global variables.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "windowstr.h"
-#include "propertyst.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Parser.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "xf86DDC.h"
-
-/* Globals that video drivers may access */
-
-int xf86ScreenIndex = -1;	/* Index of ScrnInfo in pScreen.devPrivates */
-int xf86CreateRootWindowIndex = -1;	/* Index into pScreen.devPrivates */
-ScrnInfoPtr *xf86Screens = NULL;	/* List of ScrnInfos */
-int xf86PixmapIndex = 0;
-const unsigned char byte_reversed[256] =
-{
-    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-    0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-    0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-    0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-    0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-    0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-    0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-    0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-    0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-    0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-    0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-    0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-    0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-    0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-    0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-    0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-    0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-    0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-    0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-    0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
-/* Globals that input drivers may access */
-InputInfoPtr xf86InputDevs = NULL;
-
-
-/* Globals that video drivers may not access */
-
-xf86InfoRec xf86Info = {
-	NULL,		/* pKeyboard */
-	NULL,		/* kbdProc */
-	NULL,		/* kbdEvents */
-	-1,		/* consoleFd */
-	-1,		/* kbdFd */
-	-1,		/* vtno */
-	-1,		/* kbdType */
-	-1,		/* kbdRate */
-	-1, 		/* kbdDelay */
-	-1,		/* bell_pitch */
-	-1,		/* bell_duration */
-	TRUE,		/* autoRepeat */
-	0,		/* leds */
-	0,		/* xleds */
-	NULL,		/* vtinit */
-	0,		/* scanPrefix */
-	FALSE,		/* capsLock */
-	FALSE,		/* numLock */
-	FALSE,		/* scrollLock */
-	FALSE,		/* modeSwitchLock */
-	FALSE,		/* composeLock */
-	FALSE,		/* vtSysreq */
-	SKWhenNeeded,	/* ddxSpecialKeys */
-	FALSE,		/* ActionKeyBindingsSet */
-#if defined(SVR4) && defined(i386)
-	FALSE,		/* panix106 */
-#endif
-#if defined(__OpenBSD__) || defined(__NetBSD__)
-	0,		/* wskbdType */
-#endif
-	NULL,		/* pMouse */
-#ifdef XINPUT
-	NULL,		/* mouseLocal */
-#endif
-	-1,		/* lastEventTime */
-	FALSE,		/* vtRequestsPending */
-	FALSE,		/* inputPending */
-	FALSE,		/* dontVTSwitch */
-	FALSE,		/* dontZap */
-	FALSE,		/* dontZoom */
-	FALSE,		/* notrapSignals */
-	FALSE,		/* caughtSignal */
-	FALSE,		/* sharedMonitor */
-	NULL,		/* currentScreen */
-#ifdef CSRG_BASED
-	-1,		/* screenFd */
-	-1,		/* consType */
-#endif
-#ifdef XKB
-	NULL,		/* xkbkeymap */
-	NULL,		/* xkbkeycodes */
-	NULL,		/* xkbtypes */
-	NULL,		/* xkbcompat */
-	NULL,		/* xkbsymbols */
-	NULL,		/* xkbgeometry */
-	FALSE,		/* xkbcomponents_specified */
-	NULL,		/* xkbrules */
-	NULL,		/* xkbmodel */
-	NULL,		/* xkblayout */
-	NULL,		/* xkbvariant */
-	NULL,		/* xkboptions */
-#endif
-	FALSE,		/* allowMouseOpenFail */
-	TRUE,		/* vidModeEnabled */
-	FALSE,		/* vidModeAllowNonLocal */
-	TRUE,		/* miscModInDevEnabled */
-	FALSE,		/* miscModInDevAllowNonLocal */
-	PCIOsConfig,	/* pciFlags */
-	Pix24DontCare,	/* pixmap24 */
-	X_DEFAULT,	/* pix24From */
-#if defined(i386) || defined(__i386__)
-	FALSE,		/* pc98 */
-#endif
-	TRUE,		/* pmFlag */
-	LogNone,	/* syncLog */
-	0,		/* estimateSizesAggressively */
-	FALSE,		/* kbdCustomKeycodes */
-	FALSE,		/* disableRandR */
-	X_DEFAULT	/* randRFrom */
-};
-const char *xf86ConfigFile = NULL;
-const char *xf86InputDeviceList = NULL;
-const char *xf86ModulePath = DEFAULT_MODULE_PATH;
-MessageType xf86ModPathFrom = X_DEFAULT;
-const char *xf86LogFile = DEFAULT_LOGPREFIX;
-MessageType xf86LogFileFrom = X_DEFAULT;
-Bool xf86LogFileWasOpened = FALSE;
-serverLayoutRec xf86ConfigLayout = {NULL, };
-confDRIRec xf86ConfigDRI = {0, };
-XF86ConfigPtr xf86configptr = NULL;
-Bool xf86Resetting = FALSE;
-Bool xf86Initialising = FALSE;
-Bool xf86ProbeFailed = FALSE;
-Bool xf86DoProbe = FALSE;
-Bool xf86DoConfigure = FALSE;
-#ifdef XFree86LOADER
-DriverPtr *xf86DriverList = NULL;
-int xf86NumDrivers = 0;
-InputDriverPtr *xf86InputDriverList = NULL;
-int xf86NumInputDrivers = 0;
-ModuleInfoPtr *xf86ModuleInfoList = NULL;
-int xf86NumModuleInfos = 0;
-xf86MonPtr (*xf86FallbackDDCProbe) (int entityIndex, ScrnInfoPtr scrp) = NULL;
-#endif
-int xf86NumScreens = 0;
-
-const char *xf86VisualNames[] = {
-	"StaticGray",
-	"GrayScale",
-	"StaticColor",
-	"PseudoColor",
-	"TrueColor",
-	"DirectColor"
-};
-
-/* Parameters set only from the command line */
-char *xf86ServerName = "no-name";
-Bool xf86fpFlag = FALSE;
-Bool xf86coFlag = FALSE;
-Bool xf86sFlag = FALSE;
-Bool xf86bsEnableFlag = FALSE;
-Bool xf86bsDisableFlag = FALSE;
-Bool xf86silkenMouseDisableFlag = FALSE;
-Bool xf86acpiDisableFlag = FALSE;
-char *xf86LayoutName = NULL;
-char *xf86ScreenName = NULL;
-char *xf86PointerName = NULL;
-char *xf86KeyboardName = NULL;
-Bool xf86ProbeOnly = FALSE;
-int xf86Verbose = DEFAULT_VERBOSE;
-int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
-int xf86FbBpp = -1;
-Pix24Flags xf86Pix24 = Pix24DontCare;
-int xf86Depth = -1;
-rgb xf86Weight = {0, 0, 0};
-Bool xf86FlipPixels = FALSE;
-Gamma xf86Gamma = {0.0, 0.0, 0.0};
-Bool xf86ShowUnresolved = DEFAULT_UNRESOLVED;
-Bool xf86BestRefresh = DEFAULT_BEST_REFRESH;
-Bool xf86AllowMouseOpenFail = FALSE;
-#ifdef XF86VIDMODE
-Bool xf86VidModeDisabled = FALSE;
-Bool xf86VidModeAllowNonLocal = FALSE;
-#endif
-#ifdef XF86MISC
-Bool xf86MiscModInDevDisabled = FALSE;
-Bool xf86MiscModInDevAllowNonLocal = FALSE;
-#endif
-RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
-Bool xf86inSuspend = FALSE;
-Bool xorgHWAccess = FALSE;
-PciBusId xf86IsolateDevice;
-
-#ifdef DLOPEN_HACK
-/*
- * This stuff is a hack to allow dlopen() modules to work.  It is intended
- * only to be used when using dlopen() modules for debugging purposes.
- */
-#endif
--- a/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c	Mon Jun 12 11:08:27 2006 -0700
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c	Mon Jun 12 13:53:11 2006 -0700
@@ -1200,9 +1200,6 @@
 }
 
 
-extern DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
-    Bool Reduced, Bool Interlaced);
-
 /*
  * xf86ValidateModes
  *
@@ -1285,7 +1282,10 @@
     int numDtModelines = 0;
     int numStdModes = 0;
     char **rmodeNames;
-    DisplayModePtr modePool;
+    float hmin = 1e6, hmax = 0.0, vmin = 1e6, vmax = 0.0;
+    int useBuiltin = FALSE;
+    float builtinHSync = 0.0;
+    float builtinVRfrsh = 0.0;
 
 #ifdef DEBUG
     ErrorF("xf86ValidateModes(%p, %p, %p, %p,\n\t\t  %p, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x)\n",
@@ -1316,44 +1316,6 @@
     }
 
     /*
-     * If DDC is empty, try VBE DDC probing, since xf86DoEDID_DDC2
-     * probing, which at least nv and ati drivers count on, sometimes
-     * fails for some CRT monitors
-     */
-#ifdef sun
-#ifdef improve_for_nvidia_driver
-    /* 
-     * With nvidia driver, EDID modes are added to availModes with type 0, 
-     * reconstruct them.
-     */
-    if (!strcmp (scrp->driverName, "nvidia")) {
-	for (p = availModes; p != NULL; p = p->next)
-	    if (p->type == 0) {
-		dt_modes[numDtModelines] = *p;
-		dt_modes[numDtModelines].type = M_T_EDID;
-		dt_mode_names[numDtModes++] = xnfstrdup(p->name);
-		dt_mode_names[numDtModes] = NULL;
-	    }
-	/* 
-         * If monitor probing failed with nvidia driver, try the results from
-	 * VBE probing 
-	 */
-    }
-    if ((!scrp->monitor->DDC) && (strcmp (scrp->driverName, "nvidia") || 
-	(!numDtModelines))) {
-#else
-    if ((!scrp->monitor->DDC) && strcmp (scrp->driverName, "nvidia")) {
-#endif
-#else
-    if (!scrp->monitor->DDC) {
-#endif
-	int entityIndex = scrp->entityList[0];
-
-	if ((xf86LoadSubModule(scrp, "vbe")) && xf86FallbackDDCProbe)
-	    	scrp->monitor->DDC = xf86FallbackDDCProbe (entityIndex, scrp);
-    }
-
-    /*
      * Probe monitor so that we can enforce/warn about its limits.
      * If one or more DS_RANGES descriptions are present, use the parameters
      * that they provide.  Otherwise, deduce limits based on the modes that
@@ -1365,7 +1327,6 @@
 	MonPtr monitor = scrp->monitor;
 	xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
 	int i, j, c;
-	float hmin = 1e6, hmax = 0.0, vmin = 1e6, vmax = 0.0;
 	float h;
 	struct std_timings *t;
 	struct detailed_timings *dt;
@@ -1557,60 +1518,86 @@
 		numTimings++;
 	    }
 	}
+    } else {
+	/* Check built-in modes */
+	for (p = scrp->modePool; p != NULL; p = p->next) {
+	    if (p->type == M_T_BUILTIN) {
+		std_mode_names[numStdModes++]	= xnfstrdup(p->name);
+		std_mode_names[numStdModes] = NULL;
+		useBuiltin = TRUE;
+		if (ModeHSync(p) > builtinHSync)
+		    builtinHSync = ModeHSync(p);
+		if ((float) ModeVRefresh(p) > builtinVRfrsh)
+		    builtinVRfrsh = (float) ModeVRefresh(p);
+	    }
+	}
+	if (numStdModes == 0) 
+	    for (p = scrp->monitor->Modes; p != NULL; p = p->next) {
+	    	if (p->type == M_T_BUILTIN) {
+		    std_mode_names[numStdModes++]	= xnfstrdup(p->name);
+		    std_mode_names[numStdModes] = NULL;
+		    useBuiltin = TRUE;
+		    if (ModeHSync(p) > builtinHSync)
+		    	builtinHSync = ModeHSync(p);
+		    if ((float) ModeVRefresh(p) > builtinVRfrsh)
+		    	builtinVRfrsh = (float) ModeVRefresh(p);
+	    	}
+	    }
+    }
 
-	if (numTimings > 0) {
+    if (numTimings > 0) {
+	MonPtr monitor = scrp->monitor;
+	int i, j;
 
 #ifdef DEBUG
-	    for (i = 0; i < numTimings; i++) {
-		ErrorF("DDC - Hsync %.1f-%.1f kHz - Vrefresh %.1f-%.1f Hz\n",
-		       hsync[i].lo, hsync[i].hi,
-		       vrefresh[i].lo, vrefresh[i].hi);
-	    }
+        for (i = 0; i < numTimings; i++) {
+	    ErrorF("DDC - Hsync %.1f-%.1f kHz - Vrefresh %.1f-%.1f Hz\n",
+	    	hsync[i].lo, hsync[i].hi, vrefresh[i].lo, vrefresh[i].hi);
+    	}
 #endif
 
 #define DDC_SYNC_TOLERANCE SYNC_TOLERANCE
-	    if (monitor->nHsync > 0) {
-		for (i = 0; i < monitor->nHsync; i++) {
-		    Bool good = FALSE;
-		    for (j = 0; j < numTimings; j++) {
-			if ((1.0 - DDC_SYNC_TOLERANCE) * hsync[j].lo <=
-				monitor->hsync[i].lo &&
-			    (1.0 + DDC_SYNC_TOLERANCE) * hsync[j].hi >=
-				monitor->hsync[i].hi) {
-			    good = TRUE;
-			    break;
-			}
+  	if (monitor->nHsync > 0) {
+	    for (i = 0; i < monitor->nHsync; i++) {
+	    	Bool good = FALSE;
+	    	for (j = 0; j < numTimings; j++) {
+		    if ((1.0 - DDC_SYNC_TOLERANCE) * hsync[j].lo <=
+			monitor->hsync[i].lo &&
+		    	(1.0 + DDC_SYNC_TOLERANCE) * hsync[j].hi >=
+			monitor->hsync[i].hi) {
+		    	good = TRUE;
+		    	break;
 		    }
-		    if (!good) {
-			xf86DrvMsg(scrp->scrnIndex, X_WARNING,
-			  "config file hsync range %g-%gkHz not within DDC "
-			  "hsync ranges.\n",
-			  monitor->hsync[i].lo, monitor->hsync[i].hi);
-		    }
+	 	}
+	    	if (!good) {
+		    xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+		       	"config file hsync range %g-%gkHz not within DDC "
+			"hsync ranges.\n",
+ 			monitor->hsync[i].lo, monitor->hsync[i].hi);
 		}
 	    }
+	}
 
-	    if (monitor->nVrefresh > 0) {
-		for (i = 0; i < monitor->nVrefresh; i++) {
-		    Bool good = FALSE;
-		    for (j = 0; j < numTimings; j++) {
-			if ((1.0 - DDC_SYNC_TOLERANCE) * vrefresh[j].lo <=
-				monitor->vrefresh[0].lo &&
-			    (1.0 + DDC_SYNC_TOLERANCE) * vrefresh[j].hi >=
-				monitor->vrefresh[0].hi) {
-			    good = TRUE;
-			    break;
-			}
+	if (monitor->nVrefresh > 0) {
+	    for (i = 0; i < monitor->nVrefresh; i++) {
+	    	Bool good = FALSE;
+	    	for (j = 0; j < numTimings; j++) {
+		    if ((1.0 - DDC_SYNC_TOLERANCE) * vrefresh[j].lo <=
+			monitor->vrefresh[0].lo &&
+			(1.0 + DDC_SYNC_TOLERANCE) * vrefresh[j].hi >=
+			monitor->vrefresh[0].hi) {
+		    	good = TRUE;
+		    	break;
 		    }
-		    if (!good) {
-			xf86DrvMsg(scrp->scrnIndex, X_WARNING,
-			  "config file vrefresh range %g-%gHz not within DDC "
-			  "vrefresh ranges.\n",
-			  monitor->vrefresh[i].lo, monitor->vrefresh[i].hi);
-		    }
+	 	}
+	    	if (!good) {
+		    xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+	 		"config file vrefresh range %g-%gHz not within DDC "
+			"vrefresh ranges.\n",
+			monitor->vrefresh[i].lo, monitor->vrefresh[i].hi);
 		}
 	    }
-        }
+	}
     }
 
     /*
@@ -1631,7 +1618,11 @@
 		}
 	    } else {
 		scrp->monitor->hsync[0].lo = 28;
-		scrp->monitor->hsync[0].hi = 60;
+		if (useBuiltin)
+		    scrp->monitor->hsync[0].hi = builtinHSync * 
+			(1.0 + SYNC_TOLERANCE);
+		else
+		    scrp->monitor->hsync[0].hi = 60;
 		scrp->monitor->nHsync = 1;
 	    }
 	    type = "default ";
@@ -1660,7 +1651,11 @@
 		}
 	    } else {
 		scrp->monitor->vrefresh[0].lo = 43;
-		scrp->monitor->vrefresh[0].hi = 72;
+		if (useBuiltin)
+		    scrp->monitor->vrefresh[0].hi = builtinVRfrsh *
+			(1.0 + SYNC_TOLERANCE);
+		else
+		    scrp->monitor->vrefresh[0].hi = 72;
 		scrp->monitor->nVrefresh = 1;
 	    }
 	    type = "default ";
@@ -1800,7 +1795,7 @@
 		    * Don't prepend EDID mode if there exits a user-defined or 
 		    * built-in mode having the same name.
 		    */
-		   if (((s->type & M_T_USERDEF) || (s->type & M_T_BUILTIN)) && 
+		   if ((s->type & M_T_USERDEF) && 
 			(!strcmp(p->name, s->name)))
 			break;
 		}
@@ -1818,21 +1813,6 @@
 	    else {
 	    	if ((p = r) == NULL)
 		    break;
-		else {
-#ifdef sun
-#ifdef improve_for_nvidia_driver
-		   /*
-		    * Type 0 modes are EDID modes added by nvidia driver, ignore 
-                    * them because they were converted to type EDID in dt_modes[] 
-                    * and have been prepended.
-		    */
-	            if (p->type == 0) {
-			r = r->next;
-			continue;
-		    }
-#endif
-#endif
-		}
 	    }
 	    
 	    status = xf86InitialCheckModeForDriver(scrp, p, clockRanges,
@@ -1861,23 +1841,23 @@
 
 		switch (p->type) {
 		case M_T_BUILTIN:	
-		    typestring = xnfstrdup("builtin");
+		    typestring = xnfstrdup("(B)");
 		    break;
 		case M_T_USERDEF:	
-		    typestring = xnfstrdup("user");
+		    typestring = xnfstrdup("(U)");
 		    break;
 		case M_T_EDID:	
-		    typestring = xnfstrdup("EDID");
+		    typestring = xnfstrdup("(E)");
 		    break;
 		case M_T_DEFAULT:	
-		    typestring = xnfstrdup("default");
+		    typestring = xnfstrdup("(D)");
 		    break;
 		default:	
 		    typestring = xnfstrdup("");
 		    break;
 		}
 		xf86DrvMsg(scrp->scrnIndex, X_INFO,
-		    "Not including %s \"%s\" %.1fMHz (%s) in pool\n", typestring,
+		    "Excluding %s \"%s\" %.1fMHz (%s)\n", typestring,
 		    p->name, p->Clock/1000.0, xf86ModeStatusToString(status));
 	    }
 	    if (i < numDtModelines)
@@ -1968,26 +1948,36 @@
 	for (i = 0; rmodeNames[i] != NULL; i++) {
 	    if (fallbackMode)
 	    	xf86DrvMsg(scrp->scrnIndex, X_INFO, 
-		    "Prepend Fallback mode name \"%s\" to validation list\n", 
+		    "Prepend Fallback mode name (F) \"%s\" to validation list\n", 
 		    rmodeNames[i]);
 	    else {
 	    	if (userModes)
 	    	    xf86DrvMsg(scrp->scrnIndex, X_INFO, 
-		    	"Prepend User mode name \"%s\" to validation list\n", 
+		    	"Prepend User mode name (U) \"%s\" to validation list\n", 
 		    	rmodeNames[i]);
 		else
-	    	    xf86DrvMsg(scrp->scrnIndex, X_INFO, 
-		    	"Prepend EDID mode name \"%s\" to validation list\n", rmodeNames[i]);
+		    if (useBuiltin)
+	    	    	xf86DrvMsg(scrp->scrnIndex, X_INFO, 
+		    	    "Prepend BUILTIN mode name (B) \"%s\" to validation list\n", 
+			    rmodeNames[i]);
+		    else
+	    	    	xf86DrvMsg(scrp->scrnIndex, X_INFO, 
+		    	    "Prepend EDID mode name (E) \"%s\" to validation list\n", 
+			    rmodeNames[i]);
 	    }
 	    new = xnfcalloc(1, sizeof(DisplayModeRec));
 	    new->prev = last;
 	    if (userModes)
 	    	new->type = M_T_USERDEF;
-	    else {
-		if (fallbackMode)
-	    	    new->type = M_T_DEFAULT;
-		else
-	    	    new->type = M_T_EDID;
+	    else  {
+	    	if (useBuiltin)
+	    	    new->type = M_T_BUILTIN;
+		else {
+		    if (fallbackMode)
+	    	    	new->type = M_T_DEFAULT;
+		    else
+	    	    	new->type = M_T_EDID;
+		}
 	    }
 	    new->name = xnfalloc(strlen(rmodeNames[i]) + 1);
 	    strcpy(new->name, rmodeNames[i]);
@@ -2088,16 +2078,16 @@
 
 	    switch (p->type) {
 	    	case M_T_BUILTIN:	
-	    	    typestring = xnfstrdup("builtin");
+	    	    typestring = xnfstrdup("(B)");
 		    break;
 	    	case M_T_USERDEF:	
-	    	    typestring = xnfstrdup("user");
+	    	    typestring = xnfstrdup("(U)");
 		    break;
 	    	case M_T_EDID:	
-	    	    typestring = xnfstrdup("EDID");
+	    	    typestring = xnfstrdup("(E)");
 		    break;
 	    	case M_T_DEFAULT:	
-		    typestring = xnfstrdup("default");
+		    typestring = xnfstrdup("(D)");
 		    break;
 	    	default:	
 	    	    typestring = xnfstrdup("");
@@ -2117,16 +2107,16 @@
 
 	    switch (p->type) {
 	    	case M_T_BUILTIN:	
-	    	    typestring = xnfstrdup("builtin");
+	    	    typestring = xnfstrdup("(B)");
 		    break;
 	    	case M_T_USERDEF:	
-	    	    typestring = xnfstrdup("user");
+	    	    typestring = xnfstrdup("(U)");
 		    break;
 	    	case M_T_EDID:	
-	    	    typestring = xnfstrdup("EDID");
+	    	    typestring = xnfstrdup("(E)");
 		    break;
 	    	case M_T_DEFAULT:	
-		    typestring = xnfstrdup("default");
+		    typestring = xnfstrdup("(D)");
 		    break;
 	    	default:	
 	    	    typestring = xnfstrdup("");
@@ -2258,7 +2248,7 @@
 	    break;
     if (p) {
 	xf86DrvMsg(scrp->scrnIndex, X_INFO,
-	    "Valid mode on top of list : \"%s\" %.1f MHz %.1f kHz, %.1f Hz with --\n", 
+	    "Valid mode on top: \"%s\" %.1f MHz %.1f kHz, %.1f Hz with --\n", 
 	    p->name, p->Clock/1000.0, ModeHSync(p), ModeVRefresh(p));
 	PrintModeline(scrp->scrnIndex, p);
     }
@@ -2446,7 +2436,7 @@
     if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2");
 #endif
     xf86DrvMsgVerb(scrnIndex, X_INFO, 3,
-		   "Modeline \"%s\"  %6.2f  %i %i %i %i  %i %i %i %i%s\n",
+		   "\"%s\" %6.2f  %i %i %i %i  %i %i %i %i%s\n",
 		   mode->name, mode->Clock/1000., mode->HDisplay,
 		   mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
 		   mode->VDisplay, mode->VSyncStart, mode->VSyncEnd,
@@ -2486,13 +2476,13 @@
 	    desc2 = " (VScan)";
 	}
 	if (!(p->type) || (p->type & M_T_EDID))
-            prefix = "EDID mode";
+            prefix = "(E)";
 	else if (p->type & M_T_USERDEF)
-	    prefix = "User mode";
+	    prefix = "(U)";
 	else if (p->type & M_T_BUILTIN)
-	    prefix = "Builtin mode";
+	    prefix = "(B)";
 	else if (p->type & M_T_DEFAULT)
-	    prefix = "Default mode";
+	    prefix = "(D)";
 	else
 	    prefix = "Mode";
 	uprefix = "";
--- a/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	Mon Jun 12 11:08:27 2006 -0700
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	Mon Jun 12 13:53:11 2006 -0700
@@ -934,7 +934,7 @@
     if(pNv->fpWidth && pNv->fpHeight) {
       if((pNv->fpWidth < mode->HDisplay) || (pNv->fpHeight < mode->VDisplay)) {
          xf86DrvMsg(scrnIndex, X_INFO, "Mode \"%s\" is larger than "
-                    "BIOS programmed panel size of %d x %d.  Removing.\n",
+                    "BIOS panel size of %d x %d.  Removing.\n",
                      mode->name, pNv->fpWidth, pNv->fpHeight);
          return (MODE_BAD);
       }
@@ -943,19 +943,21 @@
     return (MODE_OK);
 }
 
-static void
+xf86MonPtr
 nvProbeDDC(ScrnInfoPtr pScrn, int index)
 {
     vbeInfoPtr pVbe;
+    xf86MonPtr monitor;
 
     if (xf86LoadSubModule(pScrn, "vbe")) {
         pVbe = VBEInit(NULL,index);
-        ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+        monitor = vbeDoEDID(pVbe, NULL);
 	vbeFree(pVbe);
-    }
+	return (monitor);
+    } else
+	return (NULL);
 }
 
-
 Bool NVI2CInit(ScrnInfoPtr pScrn)
 {
     char *mod = "i2c";
@@ -987,7 +989,8 @@
     const char *s;
 
     if (flags & PROBE_DETECT) {
-        nvProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index );
+        ConfiguredMonitor = nvProbeDDC( pScrn, 
+	    xf86GetEntityInfo(pScrn->entityList[0])->index );
 	return TRUE;
     }
 
@@ -1499,6 +1502,19 @@
        max_height = 4096;
     }
 
+    /* If DFP, add a modeline corresponding to its panel size */
+    if (pNv->FlatPanel && !pNv->Television && pNv->fpWidth && pNv->fpHeight) {
+	DisplayModePtr Mode;
+	
+	Mode = xnfcalloc(1, sizeof(DisplayModeRec));
+        Mode = xf86CVTMode(pNv->fpWidth, pNv->fpHeight, 60.00, TRUE, FALSE);
+	Mode->type = M_T_BUILTIN;
+	Mode->HSync = 0;
+	Mode->next = pScrn->monitor->Modes;
+	pScrn->monitor->Modes->prev = Mode;
+	pScrn->monitor->Modes = Mode;
+    }
+
     /*
      * xf86ValidateModes will check that the mode HTotal and VTotal values
      * don't exceed the chipset's limit if pScrn->maxHValue and
--- a/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	Mon Jun 12 11:08:27 2006 -0700
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	Mon Jun 12 13:53:11 2006 -0700
@@ -323,6 +323,8 @@
 }
 
 
+extern xf86MonPtr nvProbeDDC(ScrnInfoPtr pScrn, int index);
+
 void
 NVCommonSetup(ScrnInfoPtr pScrn)
 {
@@ -470,7 +472,11 @@
 
     if(!pNv->twoHeads) {
        pNv->CRTCnumber = 0;
-       if((monitorA = NVProbeDDC(pScrn, 0))) {
+       if(!(monitorA = NVProbeDDC(pScrn, 0)))
+              monitorA = nvProbeDDC(pScrn, 
+              	xf86GetEntityInfo(pScrn->entityList[0])->index);
+
+       if (monitorA) {
            FlatPanel = monitorA->features.input_type ? 1 : 0;
 
            /* NV4 doesn't support FlatPanels */
@@ -557,6 +563,10 @@
        monitorA = NVProbeDDC(pScrn, 0);
        monitorB = NVProbeDDC(pScrn, 1);
 
+       if (!monitorA && !monitorB)
+              monitorA = nvProbeDDC(pScrn, 
+              	xf86GetEntityInfo(pScrn->entityList[0])->index);
+
        if(slaved_on_A && !tvA) {
           CRTCnumber = 0;
           FlatPanel = 1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/vbe/vbe.c	Mon Jun 12 13:53:11 2006 -0700
@@ -0,0 +1,1094 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/vbe/vbe.c,v 1.2tsi Exp $ */
+
+/*
+ *                   XFree86 vbe module
+ *               Copyright 2000 Egbert Eich
+ *
+ * The mode query/save/set/restore functions from the vesa driver 
+ * have been moved here.
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * Authors: Paulo César Pereira de Andrade <[email protected]> 
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "vbe.h"
+#include <X11/Xarch.h>
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+
+#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x)
+
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+#define B_O16(x)  (x) 
+#define B_O32(x)  (x)
+#else
+#define B_O16(x)  ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
+#define B_O32(x)  ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \
+                  | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
+#endif
+#define L_ADD(x)  (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00)
+
+#define FARP(p)		(((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff))
+#define R16(v)		((v) & 0xffff)
+
+static unsigned char * vbeReadEDID(vbeInfoPtr pVbe);
+static Bool vbeProbeDDC(vbeInfoPtr pVbe);
+
+const char *vbe_ddcSymbols[] = {
+    "xf86InterpretEDID",
+    NULL
+};
+
+static const char vbeVersionString[] = "VBE2";
+
+vbeInfoPtr
+VBEInit(xf86Int10InfoPtr pInt, int entityIndex)
+{
+    return VBEExtendedInit(pInt, entityIndex, 0);
+}
+
+vbeInfoPtr
+VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
+{
+    int RealOff;
+    pointer page = NULL;
+    ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex);
+    vbeControllerInfoPtr vbe = NULL;
+    Bool init_int10 = FALSE;
+    vbeInfoPtr vip = NULL;
+    int screen;
+
+    if (!pScrn) return NULL;
+    screen = pScrn->scrnIndex;
+    
+    if (!pInt) {
+	if (!xf86LoadSubModule(pScrn, "int10"))
+	    goto error;
+
+	xf86DrvMsg(screen,X_INFO,"initializing int10\n");
+	pInt = xf86ExtendedInitInt10(entityIndex,Flags);
+	if (!pInt)
+	    goto error;
+	init_int10 = TRUE;
+    }
+    
+    page = xf86Int10AllocPages(pInt,1,&RealOff);
+    if (!page) goto error;
+    vbe = (vbeControllerInfoPtr) page;    
+    memcpy(vbe->VbeSignature,vbeVersionString,4);
+
+    pInt->ax = 0x4F00;
+    pInt->es = SEG_ADDR(RealOff);
+    pInt->di = SEG_OFF(RealOff);
+    pInt->num = 0x10;
+    
+    xf86ExecX86int10(pInt);
+
+    if ((pInt->ax & 0xff) != 0x4f) {
+	xf86DrvMsgVerb(screen,X_INFO,3,"VESA BIOS not detected\n");
+	goto error;
+    }
+    
+    switch (pInt->ax & 0xff00) {
+    case 0:
+	xf86DrvMsg(screen,X_INFO,"VESA BIOS detected\n");
+	break;
+    case 0x100:
+	xf86DrvMsg(screen,X_INFO,"VESA BIOS function failed\n");
+	goto error;
+    case 0x200:
+	xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported\n");
+	goto error;
+    case 0x300:
+	xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported in current mode\n");
+	goto error;
+    default:
+	xf86DrvMsg(screen,X_INFO,"Invalid\n");
+	goto error;
+    }
+    
+    xf86DrvMsgVerb(screen, X_INFO, 4,
+		"VbeVersion is %d, OemStringPtr is 0x%08lx,\n"
+		"\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n"
+		"\tOemProductRevPtr is 0x%08lx\n",
+		vbe->VbeVersion, (unsigned long)vbe->OemStringPtr,
+		(unsigned long)vbe->OemVendorNamePtr,
+		(unsigned long)vbe->OemProductNamePtr,
+		(unsigned long)vbe->OemProductRevPtr);
+
+    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Version %i.%i\n",
+		   VERSION(vbe->VbeVersion));
+    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Total Mem: %i kB\n",
+		   vbe->TotalMem * 64);
+    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM: %s\n",
+		   (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemStringPtr)));
+    
+    if (B_O16(vbe->VbeVersion) >= 0x200) {
+	xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Software Rev: %i.%i\n",
+		    VERSION(vbe->OemSoftwareRev));
+	if (vbe->OemVendorNamePtr)
+	    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Vendor: %s\n",
+		    (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemVendorNamePtr)));
+	if (vbe->OemProductNamePtr)
+	    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product: %s\n",
+		    (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductNamePtr)));
+	if (vbe->OemProductRevPtr)
+	    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product Rev: %s\n",
+		    (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductRevPtr)));
+    }
+    vip = (vbeInfoPtr)xnfalloc(sizeof(vbeInfoRec));
+    vip->version = B_O16(vbe->VbeVersion);
+    vip->pInt10 = pInt;
+    vip->ddc = DDC_UNCHECKED;
+    vip->memory = page;
+    vip->real_mode_base = RealOff;
+    vip->num_pages = 1;
+    vip->init_int10 = init_int10;
+
+    return vip;
+
+ error:
+    if (page)
+	xf86Int10FreePages(pInt, page, 1);
+    if (init_int10)
+	xf86FreeInt10(pInt);
+    return NULL;
+}
+
+void
+vbeFree(vbeInfoPtr pVbe)
+{
+    if (!pVbe)
+	return;
+
+    xf86Int10FreePages(pVbe->pInt10,pVbe->memory,pVbe->num_pages);
+    /* If we have initalized int10 we ought to free it, too */
+    if (pVbe->init_int10) 
+	xf86FreeInt10(pVbe->pInt10);
+    xfree(pVbe);
+    return;
+}
+
+static Bool
+vbeProbeDDC(vbeInfoPtr pVbe)
+{
+    char *ddc_level;
+    int screen = pVbe->pInt10->scrnIndex;
+    
+    if (!pVbe || (pVbe->ddc == DDC_NONE))
+	return FALSE;
+    if (pVbe->ddc != DDC_UNCHECKED)
+	return TRUE;
+
+    pVbe->pInt10->ax = 0x4F15;
+    pVbe->pInt10->bx = 0;
+    pVbe->pInt10->cx = 0;
+    pVbe->pInt10->es = 0;
+    pVbe->pInt10->di = 0;
+    pVbe->pInt10->num = 0x10;
+
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
+        xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC not supported\n");
+	pVbe->ddc = DDC_NONE;
+	return FALSE;
+    }
+
+    switch ((pVbe->pInt10->ax >> 8) & 0xff) {
+    case 0:
+	xf86DrvMsg(screen,X_INFO,"VESA VBE DDC supported\n");
+	switch (pVbe->pInt10->bx & 0x3) {
+	case 0:
+  	    ddc_level = " none"; 
+	    pVbe->ddc = DDC_NONE;
+	    break;
+	case 1:
+  	    ddc_level = " 1";
+	    pVbe->ddc = DDC_1;
+	    break;
+	case 2:
+  	    ddc_level = " 2"; 
+	    pVbe->ddc = DDC_2;
+	    break;
+	case 3:
+  	    ddc_level = " 1 + 2"; 
+	    pVbe->ddc = DDC_1_2;
+	    break;
+	default:
+ 	    ddc_level = "";
+	    pVbe->ddc = DDC_NONE;
+	    break;
+	}
+  	xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level%s\n",ddc_level); 
+  	if (pVbe->pInt10->bx & 0x4) {
+    	    xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Screen blanked" 
+    			"for data transfer\n"); 
+    	    pVbe->ddc_blank = TRUE;
+    	}  else
+    	    pVbe->ddc_blank = FALSE;
+	    
+  	xf86DrvMsgVerb(screen,X_INFO,3,
+		       "VESA VBE DDC transfer in appr. %x sec.\n", 
+		       (pVbe->pInt10->bx >> 8) & 0xff); 
+    }
+    
+    return TRUE; 
+}
+
+typedef enum {
+  VBEOPT_NOVBE,
+    VBEOPT_NODDC
+} VBEOpts;
+
+static const OptionInfoRec VBEOptions[] = {
+    { VBEOPT_NOVBE,	"NoVBE",	OPTV_BOOLEAN,	{0},	FALSE },
+    { VBEOPT_NODDC,	"NoDDC",	OPTV_BOOLEAN,	{0},	FALSE },
+    { -1,		NULL,		OPTV_NONE,	{0},	FALSE },
+};
+
+static unsigned char *
+vbeReadEDID(vbeInfoPtr pVbe)
+{
+    int RealOff = pVbe->real_mode_base;
+    pointer page = pVbe->memory;
+    unsigned char *tmp = NULL;
+    Bool novbe = FALSE;
+    Bool noddc = FALSE;
+    int screen = pVbe->pInt10->scrnIndex;
+    OptionInfoPtr options;
+
+    if (!page) return NULL;
+
+    options = xnfalloc(sizeof(VBEOptions));
+    (void)memcpy(options, VBEOptions, sizeof(VBEOptions));
+    xf86ProcessOptions(screen, xf86Screens[screen]->options, options);
+    xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe);
+    xf86GetOptValBool(options, VBEOPT_NODDC, &noddc);
+    xfree(options);
+    if (novbe || noddc) return NULL;
+    
+    if (!vbeProbeDDC(pVbe)) goto error;
+
+    memset(page,0,sizeof(vbeInfoPtr));
+    strcpy(page,vbeVersionString);
+
+    pVbe->pInt10->ax = 0x4F15;
+    pVbe->pInt10->bx = 0x01;
+    pVbe->pInt10->cx = 0;
+    pVbe->pInt10->dx = 0;
+    pVbe->pInt10->es = SEG_ADDR(RealOff);
+    pVbe->pInt10->di = SEG_OFF(RealOff);
+    pVbe->pInt10->num = 0x10;
+
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
+        xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC invalid\n");
+	goto error;
+    }
+    switch (pVbe->pInt10->ax & 0xff00) {
+    case 0x0:
+	xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read successfully\n");
+  	tmp = (unsigned char *)xnfalloc(128); 
+  	memcpy(tmp,page,128); 
+	break;
+    case 0x100:
+	xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read failed\n");	
+	break;
+    default:
+	xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC unkown failure %i\n",
+		       pVbe->pInt10->ax & 0xff00);
+	break;
+    }
+    
+ error:
+    return tmp;
+}
+
+xf86MonPtr
+vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule)
+{
+    xf86MonPtr    pMonitor;
+    pointer       pModule;
+    unsigned char *DDC_data = NULL;
+    ScrnInfoPtr   scrp;
+    
+    if (!pVbe) return NULL;
+    if (pVbe->version < 0x200)
+	return NULL;
+
+    scrp = xf86Screens[pVbe->pInt10->scrnIndex];
+
+    if (!(pModule = pDDCModule)) {
+	pModule =
+	    xf86LoadSubModule(scrp, "ddc");
+	if (!pModule)
+	    return NULL;
+
+	xf86LoaderReqSymLists(vbe_ddcSymbols, NULL);
+    }
+        
+    DDC_data = vbeReadEDID(pVbe);
+
+    if (!DDC_data) 
+	return NULL;
+    
+    pMonitor = xf86InterpretEDID(pVbe->pInt10->scrnIndex, DDC_data);
+
+    if (pMonitor) {
+	xf86DrvMsg(scrp->scrnIndex, X_PROBED,
+	"VBE DDC detected a %s:\n", pMonitor->features.input_type ?
+	"DFP" : "CRT");
+	xf86PrintEDID(pMonitor);
+	xf86DrvMsg(scrp->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n");
+    }
+
+    if (!pDDCModule)
+        xf86UnloadSubModule(pModule);
+    return pMonitor;
+}
+
+#define GET_UNALIGNED2(x) \
+            ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16)
+
+VbeInfoBlock *
+VBEGetVBEInfo(vbeInfoPtr pVbe)
+{
+    VbeInfoBlock *block = NULL;
+    int i, pStr, pModes;
+    char *str;
+    CARD16 major, *modes;
+
+    bzero(pVbe->memory, sizeof(VbeInfoBlock));
+
+    /*
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 00h	Return Super VGA information
+	ES:DI := Pointer to buffer
+
+    Output:
+	AX    := status
+	(All other registers are preserved)
+     */
+
+    ((char*)pVbe->memory)[0] = 'V';
+    ((char*)pVbe->memory)[1] = 'B';
+    ((char*)pVbe->memory)[2] = 'E';
+    ((char*)pVbe->memory)[3] = '2';
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f00;
+    pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+    pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (NULL);
+
+    block = xcalloc(sizeof(VbeInfoBlock), 1);
+    block->VESASignature[0] = ((char*)pVbe->memory)[0];
+    block->VESASignature[1] = ((char*)pVbe->memory)[1];
+    block->VESASignature[2] = ((char*)pVbe->memory)[2];
+    block->VESASignature[3] = ((char*)pVbe->memory)[3];
+
+    block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4);
+    major = (unsigned)block->VESAVersion >> 8;
+
+    pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6));
+    str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+    block->OEMStringPtr = strdup(str);
+
+    block->Capabilities[0] = ((char*)pVbe->memory)[10];
+    block->Capabilities[1] = ((char*)pVbe->memory)[11];
+    block->Capabilities[2] = ((char*)pVbe->memory)[12];
+    block->Capabilities[3] = ((char*)pVbe->memory)[13];
+
+    pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14));
+    modes = xf86int10Addr(pVbe->pInt10, FARP(pModes));
+    i = 0;
+    while (modes[i] != 0xffff)
+	i++;
+    block->VideoModePtr = xalloc(sizeof(CARD16) * i + 1);
+    memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
+    block->VideoModePtr[i] = 0xffff;
+
+    block->TotalMemory = *(CARD16*)(((char*)pVbe->memory) + 18);
+
+    if (major < 2)
+	memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236);
+    else {
+	block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20);
+	pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22));
+	str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+	block->OemVendorNamePtr = strdup(str);
+	pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26));
+	str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+	block->OemProductNamePtr = strdup(str);
+	pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30));
+	str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+	block->OemProductRevPtr = strdup(str);
+	memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222);
+	memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256);
+    }
+
+    return (block);
+}
+
+void
+VBEFreeVBEInfo(VbeInfoBlock *block)
+{
+    xfree(block->OEMStringPtr);
+    xfree(block->VideoModePtr);
+    if (((unsigned)block->VESAVersion >> 8) >= 2) {
+	xfree(block->OemVendorNamePtr);
+	xfree(block->OemProductNamePtr);
+	xfree(block->OemProductRevPtr);
+    }
+    xfree(block);
+}
+
+Bool
+VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *block)
+{
+    /*
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 02h	Set Super VGA video mode
+	BX    := Video mode
+	    D0-D8  := Mode number
+	    D9-D10 := Reserved (must be 0)
+	    D11    := 0 Use current default refresh rate
+		   := 1 Use user specified CRTC values for refresh rate
+	    D12-13	Reserved for VBE/AF (must be 0)
+	    D14    := 0 Use windowed frame buffer model
+		   := 1 Use linear/flat frame buffer model
+	    D15    := 0 Clear video memory
+		   := 1 Don't clear video memory
+	ES:DI := Pointer to VbeCRTCInfoBlock structure
+
+    Output: AX = Status
+	(All other registers are preserved)
+    */
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f02;
+    pVbe->pInt10->bx = mode;
+    if (block) {
+	pVbe->pInt10->bx |= 1 << 11;
+	memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock));
+	pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+	pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+    } else
+	pVbe->pInt10->bx &= ~(1 << 11);
+
+    xf86ExecX86int10(pVbe->pInt10);
+
+    return (R16(pVbe->pInt10->ax) == 0x4f);
+}
+
+Bool
+VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
+{
+    /*
+    Input:
+	AH := 4Fh	Super VGA support
+	AL := 03h	Return current video mode
+
+    Output:
+	AX := Status
+	BX := Current video mode
+	(All other registers are preserved)
+    */
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f03;
+
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) == 0x4f) {
+	*mode = R16(pVbe->pInt10->bx);
+
+	return (TRUE);
+    }
+
+    return (FALSE);
+}
+
+VbeModeInfoBlock *
+VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
+{
+    VbeModeInfoBlock *block = NULL;
+
+    bzero(pVbe->memory, sizeof(VbeModeInfoBlock));
+
+    /*
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 01h	Return Super VGA mode information
+	CX    := 	Super VGA video mode
+			(mode number must be one of those returned by Function 0)
+	ES:DI := Pointer to buffer
+
+    Output:
+	AX    := status
+	(All other registers are preserved)
+     */
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f01;
+    pVbe->pInt10->cx = mode;
+    pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+    pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+    xf86ExecX86int10(pVbe->pInt10);
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (NULL);
+
+    block = xcalloc(sizeof(VbeModeInfoBlock), 1);
+
+    block->ModeAttributes = *(CARD16*)pVbe->memory;
+    block->WinAAttributes = ((char*)pVbe->memory)[2];
+    block->WinBAttributes = ((char*)pVbe->memory)[3];
+    block->WinGranularity = *(CARD16*)(((char*)pVbe->memory) + 4);
+    block->WinSize = *(CARD16*)(((char*)pVbe->memory) + 6);
+    block->WinASegment = *(CARD16*)(((char*)pVbe->memory) + 8);
+    block->WinBSegment = *(CARD16*)(((char*)pVbe->memory) + 10);
+    block->WinFuncPtr = *(CARD32*)(((char*)pVbe->memory) + 12);
+    block->BytesPerScanline = *(CARD16*)(((char*)pVbe->memory) + 16);
+
+    /* mandatory information for VBE 1.2 and above */
+    block->XResolution = *(CARD16*)(((char*)pVbe->memory) + 18);
+    block->YResolution = *(CARD16*)(((char*)pVbe->memory) + 20);
+    block->XCharSize = ((char*)pVbe->memory)[22];
+    block->YCharSize = ((char*)pVbe->memory)[23];
+    block->NumberOfPlanes = ((char*)pVbe->memory)[24];
+    block->BitsPerPixel = ((char*)pVbe->memory)[25];
+    block->NumberOfBanks = ((char*)pVbe->memory)[26];
+    block->MemoryModel = ((char*)pVbe->memory)[27];
+    block->BankSize = ((char*)pVbe->memory)[28];
+    block->NumberOfImages = ((char*)pVbe->memory)[29];
+    block->Reserved = ((char*)pVbe->memory)[30];
+
+    /* Direct color fields (required for direct/6 and YUV/7 memory models) */
+    block->RedMaskSize = ((char*)pVbe->memory)[31];
+    block->RedFieldPosition = ((char*)pVbe->memory)[32];
+    block->GreenMaskSize = ((char*)pVbe->memory)[33];
+    block->GreenFieldPosition = ((char*)pVbe->memory)[34];
+    block->BlueMaskSize = ((char*)pVbe->memory)[35];
+    block->BlueFieldPosition = ((char*)pVbe->memory)[36];
+    block->RsvdMaskSize = ((char*)pVbe->memory)[37];
+    block->RsvdFieldPosition = ((char*)pVbe->memory)[38];
+    block->DirectColorModeInfo = ((char*)pVbe->memory)[39];
+
+    /* Mandatory information for VBE 2.0 and above */
+    if (pVbe->version >= 0x200) {
+	block->PhysBasePtr = *(CARD32*)(((char*)pVbe->memory) + 40);
+	block->Reserved32 = *(CARD32*)(((char*)pVbe->memory) + 44);
+	block->Reserved16 = *(CARD16*)(((char*)pVbe->memory) + 48);
+
+	/* Mandatory information for VBE 3.0 and above */
+	if (pVbe->version >= 0x300) {
+	    block->LinBytesPerScanLine = *(CARD16*)(((char*)pVbe->memory) + 50);
+	    block->BnkNumberOfImagePages = ((char*)pVbe->memory)[52];
+	    block->LinNumberOfImagePages = ((char*)pVbe->memory)[53];
+	    block->LinRedMaskSize = ((char*)pVbe->memory)[54];
+	    block->LinRedFieldPosition = ((char*)pVbe->memory)[55];
+	    block->LinGreenMaskSize = ((char*)pVbe->memory)[56];
+	    block->LinGreenFieldPosition = ((char*)pVbe->memory)[57];
+	    block->LinBlueMaskSize = ((char*)pVbe->memory)[58];
+	    block->LinBlueFieldPosition = ((char*)pVbe->memory)[59];
+	    block->LinRsvdMaskSize = ((char*)pVbe->memory)[60];
+	    block->LinRsvdFieldPosition = ((char*)pVbe->memory)[61];
+	    block->MaxPixelClock = *(CARD32*)(((char*)pVbe->memory) + 62);
+	    memcpy(&block->Reserved2, ((char*)pVbe->memory) + 66, 188);
+	}
+	else
+	memcpy(&block->LinBytesPerScanLine, ((char*)pVbe->memory) + 50, 206);
+    }
+    else
+	memcpy(&block->PhysBasePtr, ((char*)pVbe->memory) + 40, 216);
+
+    return (block);
+}
+
+void
+VBEFreeModeInfo(VbeModeInfoBlock *block)
+{
+    xfree(block);
+}
+
+Bool
+VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function, 
+	       pointer *memory, int *size, int *real_mode_pages)
+{
+    /*
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 04h	Save/restore Super VGA video state
+	DL    := 00h	Return save/restore state buffer size
+	CX    := Requested states
+		D0 = Save/restore video hardware state
+		D1 = Save/restore video BIOS data state
+		D2 = Save/restore video DAC state
+		D3 = Save/restore Super VGA state
+
+    Output:
+	AX = Status
+	BX = Number of 64-byte blocks to hold the state buffer
+	(All other registers are preserved)
+
+
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 04h	Save/restore Super VGA video state
+	DL    := 01h	Save Super VGA video state
+	CX    := Requested states (see above)
+	ES:BX := Pointer to buffer
+
+    Output:
+	AX    := Status
+	(All other registers are preserved)
+
+
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 04h	Save/restore Super VGA video state
+	DL    := 02h	Restore Super VGA video state
+	CX    := Requested states (see above)
+	ES:BX := Pointer to buffer
+
+    Output:
+	AX     := Status
+	(All other registers are preserved)
+     */
+
+    if ((pVbe->version & 0xff00) > 0x100) {
+        int screen = pVbe->pInt10->scrnIndex;
+        if (function == MODE_QUERY ||
+	    (function == MODE_SAVE && !*memory)) {
+	    /* Query amount of memory to save state */
+
+	    pVbe->pInt10->num = 0x10;
+	    pVbe->pInt10->ax = 0x4f04;
+	    pVbe->pInt10->dx = 0;
+	    pVbe->pInt10->cx = 0x000f;
+	    xf86ExecX86int10(pVbe->pInt10);
+	    if (R16(pVbe->pInt10->ax) != 0x4f)
+	        return (FALSE);
+
+	    if (function == MODE_SAVE) {
+	        int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
+		if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages,
+						   real_mode_pages)) == NULL) {
+		    xf86DrvMsg(screen, X_ERROR,
+			       "Cannot allocate memory to save SVGA state.\n");
+		    return (FALSE);
+		}
+	    }
+	    *size = pVbe->pInt10->bx * 64;
+	}
+
+	/* Save/Restore Super VGA state */
+	if (function != MODE_QUERY) {
+	    
+	    if (!*memory) return FALSE;
+	    pVbe->pInt10->num = 0x10;
+	    pVbe->pInt10->ax = 0x4f04;
+	    switch (function) {
+	    case MODE_SAVE:
+	      pVbe->pInt10->dx = 1;
+	      break;
+	    case MODE_RESTORE:
+	      pVbe->pInt10->dx = 2;
+	      break;
+	    case MODE_QUERY:
+	      return FALSE;
+	    }
+	    pVbe->pInt10->cx = 0x000f;
+	    
+	    pVbe->pInt10->es = SEG_ADDR(*real_mode_pages);
+	    pVbe->pInt10->bx = SEG_OFF(*real_mode_pages);
+	    xf86ExecX86int10(pVbe->pInt10);
+	    return (R16(pVbe->pInt10->ax) == 0x4f);
+
+	}
+    }
+    return TRUE;
+}
+
+Bool
+VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
+{
+    /*
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 05h
+
+    Output:
+     */
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f05;
+    pVbe->pInt10->bx = window;
+    pVbe->pInt10->dx = iBank;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (FALSE);
+
+    return (TRUE);
+}
+
+Bool
+VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
+				int width, int *pixels, int *bytes, int *max)
+{
+    if (command < SCANWID_SET || command > SCANWID_GET_MAX)
+	return (FALSE);
+
+    /*
+    Input:
+	AX := 4F06h VBE Set/Get Logical Scan Line Length
+	BL := 00h Set Scan Line Length in Pixels
+	   := 01h Get Scan Line Length
+	   := 02h Set Scan Line Length in Bytes
+	   := 03h Get Maximum Scan Line Length
+	CX := If BL=00h Desired Width in Pixels
+	      If BL=02h Desired Width in Bytes
+	      (Ignored for Get Functions)
+
+    Output:
+	AX := VBE Return Status
+	BX := Bytes Per Scan Line
+	CX := Actual Pixels Per Scan Line
+	      (truncated to nearest complete pixel)
+	DX := Maximum Number of Scan Lines
+     */
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f06;
+    pVbe->pInt10->bx = command;
+    if (command == SCANWID_SET || command == SCANWID_SET_BYTES)
+	pVbe->pInt10->cx = width;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (FALSE);
+
+    if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
+	if (pixels)
+	    *pixels = R16(pVbe->pInt10->cx);
+	if (bytes)
+	    *bytes = R16(pVbe->pInt10->bx);
+	if (max)
+	    *max = R16(pVbe->pInt10->dx);
+    }
+
+    return (TRUE);
+}
+
+Bool
+VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace)
+{
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f07;
+    pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00;
+    pVbe->pInt10->cx = x;
+    pVbe->pInt10->dx = y;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (FALSE);
+
+    return (TRUE);
+}
+
+Bool
+VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y)
+{
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f07;
+    pVbe->pInt10->bx = 0x01;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (FALSE);
+
+    *x = pVbe->pInt10->cx;
+    *y = pVbe->pInt10->dx;
+
+    return (TRUE);
+}
+
+int
+VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits)
+{
+    /*
+    Input:
+	AX := 4F08h VBE Set/Get Palette Format
+	BL := 00h Set DAC Palette Format
+	   := 01h Get DAC Palette Format
+	BH := Desired bits of color per primary
+	      (Set DAC Palette Format only)
+
+    Output:
+	AX := VBE Return Status
+	BH := Current number of bits of color per primary
+     */
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f08;
+    if (!bits)
+	pVbe->pInt10->bx = 0x01;
+    else 
+	pVbe->pInt10->bx = (bits & 0x00ff) << 8;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (0);
+
+    return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
+}
+
+CARD32 *
+VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
+		      CARD32 *data, Bool secondary, Bool wait_retrace)
+{
+    /*
+    Input:
+    (16-bit)
+	AX    := 4F09h VBE Load/Unload Palette Data
+	BL    := 00h Set Palette Data
+	      := 01h Get Palette Data
+	      := 02h Set Secondary Palette Data
+	      := 03h Get Secondary Palette Data
+	      := 80h Set Palette Data during Vertical Retrace
+	CX    := Number of palette registers to update (to a maximum of 256)
+	DX    := First of the palette registers to update (start)
+	ES:DI := Table of palette values (see below for format)
+
+    Output:
+	AX    := VBE Return Status
+
+
+    Input:
+    (32-bit)
+	BL     := 00h Set Palette Data
+	       := 80h Set Palette Data during Vertical Retrace
+	CX     := Number of palette registers to update (to a maximum of 256)
+	DX     := First of the palette registers to update (start)
+	ES:EDI := Table of palette values (see below for format)
+	DS     := Selector for memory mapped registers
+     */
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f09;
+    if (!secondary)
+	pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1;
+    else
+	pVbe->pInt10->bx = set ? 2 : 3;
+    pVbe->pInt10->cx = num;
+    pVbe->pInt10->dx = first;
+    pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+    pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+    if (set)
+	memcpy(pVbe->memory, data, num * sizeof(CARD32));
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (NULL);
+
+    if (set)
+	return (data);
+
+    data = xalloc(num * sizeof(CARD32));
+    memcpy(data, pVbe->memory, num * sizeof(CARD32));
+
+    return (data);
+}
+
+VBEpmi *
+VBEGetVBEpmi(vbeInfoPtr pVbe)
+{
+    VBEpmi *pmi;
+
+    /*
+    Input:
+	AH    := 4Fh	Super VGA support
+	AL    := 0Ah	Protected Mode Interface
+	BL    := 00h	Return Protected Mode Table
+
+    Output:
+	AX    := Status
+	ES    := Real Mode Segment of Table
+	DI    := Offset of Table
+	CX    := Lenght of Table including protected mode code in bytes (for copying purposes)
+	(All other registers are preserved)
+     */
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f0a;
+    pVbe->pInt10->bx = 0;
+    pVbe->pInt10->di = 0;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (NULL);
+
+    pmi = xalloc(sizeof(VBEpmi));
+    pmi->seg_tbl = R16(pVbe->pInt10->es);
+    pmi->tbl_off = R16(pVbe->pInt10->di);
+    pmi->tbl_len = R16(pVbe->pInt10->cx);
+
+    return (pmi);
+}
+
+#if 0
+vbeModeInfoPtr
+VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock *vbe)
+{
+    vbeModeInfoPtr ModeList = NULL;
+
+    int i = 0;
+    while (vbe->VideoModePtr[i] != 0xffff) {
+	vbeModeInfoPtr m;
+	VbeModeInfoBlock *mode;
+	int id = vbe->VideoModePtr[i++];
+	int bpp;
+
+	if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
+	    continue;
+
+ 	bpp = mode->BitsPerPixel;
+
+	m = xnfcalloc(sizeof(vbeModeInfoRec),1);
+	m->width = mode->XResolution;
+	m->height = mode->YResolution;
+	m->bpp = bpp;
+	m->n = id;
+	m->next = ModeList;
+
+	xf86DrvMsgVerb(pVbe->pInt10->scrnIndex, X_PROBED, 3,
+		       "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n",
+		       m->n, m->width, m->height, m->bpp);
+
+	ModeList = m;
+
+	VBEFreeModeInfo(mode);
+    }
+    return ModeList;
+}
+
+unsigned short 
+VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp)
+{
+    while (m) {
+	if (bpp == m->bpp 
+	    && mode->HDisplay == m->width 
+	    && mode->VDisplay == m->height)
+	    return m->n;
+	m = m->next;
+    }
+    return 0;
+}
+#endif
+
+void
+VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
+		  vbeSaveRestoreFunction function)
+{
+    Bool SaveSucc = FALSE;
+
+    if (VBE_VERSION_MAJOR(pVbe->version) > 1
+	&& (function == MODE_SAVE || vbe_sr->pstate)) {
+	if (function == MODE_RESTORE)
+	    memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize);
+	ErrorF("VBESaveRestore\n");
+	if ((VBESaveRestore(pVbe,function,
+			    (pointer)&vbe_sr->state,
+			    &vbe_sr->stateSize,&vbe_sr->statePage))) {
+	    if (function == MODE_SAVE) {
+		SaveSucc = TRUE;
+		vbe_sr->stateMode = -1; /* invalidate */
+		/* don't rely on the memory not being touched */
+		if (vbe_sr->pstate == NULL)
+		    vbe_sr->pstate = xalloc(vbe_sr->stateSize);
+		memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
+	    }
+	    ErrorF("VBESaveRestore done with success\n");
+	    return;
+	}
+	ErrorF("VBESaveRestore done\n");
+    } 
+    
+    if (function == MODE_SAVE && !SaveSucc)
+	    (void)VBEGetVBEMode(pVbe, &vbe_sr->stateMode);
+	
+    if (function == MODE_RESTORE && vbe_sr->stateMode != -1)
+	    VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL);
+
+}
+
+int
+VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
+{
+    /*
+    Input:
+	AX := 4F0Bh VBE Get Pixel Clock
+	BL := 01h Get Pixel Clock
+	ECX := pixel clock in units of Hz
+        DX := mode number
+     
+    Output:
+	AX := VBE Return Status
+	ECX := Closest pixel clock
+     */
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f0b;
+    pVbe->pInt10->bx = 0x01;
+    pVbe->pInt10->cx = clock;
+    pVbe->pInt10->dx = mode;
+    xf86ExecX86int10(pVbe->pInt10);
+
+    if (R16(pVbe->pInt10->ax) != 0x4f)
+	return (0);
+
+    return (pVbe->pInt10->cx);
+}
+
+Bool
+VBEDPMSSet(vbeInfoPtr pVbe, int mode)
+{
+    /*
+    Input:
+	AX := 4F10h DPMS
+	BL := 01h Set Display Power State
+	BH := requested power state
+     
+    Output:
+	AX := VBE Return Status
+     */
+
+    pVbe->pInt10->num = 0x10;
+    pVbe->pInt10->ax = 0x4f10;
+    pVbe->pInt10->bx = 0x01;
+    switch (mode) {
+    case DPMSModeOn:
+	break;
+    case DPMSModeStandby:
+	pVbe->pInt10->bx |= 0x100;
+	break;
+    case DPMSModeSuspend:
+	pVbe->pInt10->bx |= 0x200;
+	break;
+    case DPMSModeOff:
+	pVbe->pInt10->bx |= 0x400;
+	break;
+    }
+    xf86ExecX86int10(pVbe->pInt10);
+    return (R16(pVbe->pInt10->ax) == 0x4f);
+}
+
--- a/XORG_NV/sun-src/xc/programs/Xserver/hw/xfree86/vbe/vbe_module.c	Mon Jun 12 11:08:27 2006 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe_module.c,v 1.4 2002/09/16 18:06:15 eich Exp $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86str.h"
-#include "vbe.h"
-
-extern const char *vbe_ddcSymbols[];
-
-#ifdef XFree86LOADER
-
-static MODULESETUPPROTO(vbeSetup);
-
-static XF86ModuleVersionInfo vbeVersRec =
-{
-    "vbe",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    1, 1, 0,
-    ABI_CLASS_VIDEODRV,		/* needs the video driver ABI */
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_NONE,
-    {0,0,0,0}
-};
-
-XF86ModuleData vbeModuleData = { &vbeVersRec, vbeSetup, NULL };
-
-static xf86MonPtr
-vbeProbeDDC(int entityIndex, ScrnInfoPtr scrp)
-{
-   vbeInfoPtr pVbe;
-   xf86MonPtr MonInfo = NULL;
-
-   pVbe = VBEInit(NULL, entityIndex);
-   MonInfo = vbeDoEDID(pVbe, NULL);
-   if (MonInfo) {
-        xf86DrvMsg(scrp->scrnIndex, X_PROBED,
-        "VBE DDC detected a %s:\n", MonInfo->features.input_type ?
-        "DFP" : "CRT");
-        xf86PrintEDID( MonInfo );
-        xf86DrvMsg(scrp->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n");
-   }
-
-   return (MonInfo);
-}
-
-static pointer
-vbeSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = FALSE;
-    
-    if (!setupDone) {
-	setupDone = TRUE;
-	LoaderRefSymLists(vbe_ddcSymbols,NULL);
-	/*
-	 * Tell the loader about symbols from other modules that this module
-	 * might refer to.
-	 */
-	xf86FallbackDDCProbe = vbeProbeDDC;
-    } 
-    /*
-     * The return value must be non-NULL on success even though there
-     * is no TearDownProc.
-     */
-    return (pointer)1;
-}
-
-#endif
-
--- a/XORG_NV/sun-src/xf86-video-ati-6.5.8.0/src/r128_driver.c	Mon Jun 12 11:08:27 2006 -0700
+++ b/XORG_NV/sun-src/xf86-video-ati-6.5.8.0/src/r128_driver.c	Mon Jun 12 13:53:11 2006 -0700
@@ -1465,6 +1465,21 @@
     return TRUE;
 }
 
+static xf86MonPtr 
+R128ProbeDDC(ScrnInfoPtr pScrn, int indx)
+{
+    vbeInfoPtr pVbe;
+    xf86MonPtr monitor;
+
+    if (xf86LoadSubModule(pScrn, "vbe")) {
+	pVbe = VBEInit(NULL,indx);
+	monitor = vbeDoEDID(pVbe, NULL);
+	vbeFree(pVbe);
+	return (monitor);
+    } else
+	return (NULL);
+}
+
 /* return TRUE is a DFP is indeed connected to a DVI port */
 static Bool R128GetDFPInfo(ScrnInfoPtr pScrn)
 {
@@ -1486,6 +1501,10 @@
            & ~(CARD32)(R128_GPIO_MONID_A_0 | R128_GPIO_MONID_A_3));
 
     MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, info->pI2CBus);
+
+    if(!MonInfo)
+	    MonInfo = R128ProbeDDC(pScrn, info->pEnt->index);
+
     if(!MonInfo) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                    "No DFP detected\n");
@@ -1684,7 +1703,6 @@
     }
 }
 
-
 /***********
    xfree's xf86ValidateModes routine deosn't work well with DFPs
    here is our own validation routine. All modes between
@@ -2068,17 +2086,6 @@
 }
 #endif
 
-static void
-R128ProbeDDC(ScrnInfoPtr pScrn, int indx)
-{
-    vbeInfoPtr pVbe;
-    if (xf86LoadSubModule(pScrn, "vbe")) {
-	pVbe = VBEInit(NULL,indx);
-	ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
-	vbeFree(pVbe);
-    }
-}
-
 /* R128PreInit is called once at server startup. */
 _X_EXPORT Bool R128PreInit(ScrnInfoPtr pScrn, int flags)
 {
@@ -2132,7 +2139,7 @@
     }
 
     if (flags & PROBE_DETECT) {
-	R128ProbeDDC(pScrn, info->pEnt->index);
+	ConfiguredMonitor = R128ProbeDDC(pScrn, info->pEnt->index);
 	return TRUE;
     }