[PATCH 1/4] xf86: add helper functions to convert to from ScrnInfoPtr/ScreenPtr

Dave Airlie airlied at gmail.com
Sat May 5 01:49:23 PDT 2012


These are just simple functions that we should start migrating drivers
to using.

The end goal is to remove xf86Screens and screenInfo from the ABI.

This includes a define XF86_HAS_SCRN_CONV that drivers can ifdef to provide
their own copies. I'll probably post a generic compat.h file for drivers later.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/common/xf86.h       |    7 +++++++
 hw/xfree86/common/xf86Helper.c |   12 ++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index fc4c34e..6f4f084 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -449,6 +449,13 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
 extern _X_EXPORT Bool
 VidModeExtensionInit(ScreenPtr pScreen);
 
+/* convert ScreenPtr to ScrnInfoPtr */
+extern _X_EXPORT ScrnInfoPtr xf86ScreenToScrn(ScreenPtr pScreen);
+/* convert ScrnInfoPtr to ScreenPtr */
+extern _X_EXPORT ScreenPtr xf86ScrnToScreen(ScrnInfoPtr pScrn);
+
 #endif                          /* _NO_XF86_PROTOTYPES */
 
+#define XF86_HAS_SCRN_CONV 1 /* define for drivers to use in api compat */
+
 #endif                          /* _XF86_H */
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 8c948cf..e071602 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1834,3 +1834,15 @@ xf86MotionHistoryAllocate(InputInfoPtr pInfo)
 {
     AllocateMotionHistory(pInfo->dev);
 }
+
+ScrnInfoPtr
+xf86ScreenToScrn(ScreenPtr pScreen)
+{
+    return xf86Screens[pScreen->myNum];
+}
+
+ScreenPtr
+xf86ScrnToScreen(ScrnInfoPtr pScrn)
+{
+    return screenInfo.screens[pScrn->scrnIndex];
+}
-- 
1.7.7.6



More information about the xorg-devel mailing list