b21fb18
From 1240532ba6033494d02f41f631965eaad1b49c47 Mon Sep 17 00:00:00 2001
b21fb18
From: Adam Jackson <ajax@redhat.com>
b21fb18
Date: Wed, 10 Feb 2010 13:12:47 -0500
b21fb18
Subject: [PATCH] randr unify abi compat hack
b21fb18
b21fb18
---
b21fb18
 hw/xfree86/loader/sdksyms.c    |    3 +++
b21fb18
 hw/xfree86/modes/xf86Crtc.c    |   19 +++++++++++++++----
b21fb18
 hw/xfree86/modes/xf86Crtc.h    |    3 ++-
b21fb18
 hw/xfree86/modes/xf86RandR12.c |   22 ++++++++++++++++++++++
b21fb18
 4 files changed, 42 insertions(+), 5 deletions(-)
b21fb18
b21fb18
diff --git a/hw/xfree86/loader/sdksyms.c b/hw/xfree86/loader/sdksyms.c
b21fb18
index 61ed4b9..54307c6 100644
b21fb18
--- a/hw/xfree86/loader/sdksyms.c
b21fb18
+++ b/hw/xfree86/loader/sdksyms.c
b21fb18
@@ -454,6 +454,7 @@ _X_HIDDEN void *xorg_symbols[] = {
b21fb18
     (void *) &Ones,
b21fb18
     (void *) &globalSerialNumber,
b21fb18
     (void *) &serverGeneration,
b21fb18
+    (void *) &omg_wtf_aborting,
b21fb18
     (void *) &AddScreen,
b21fb18
     (void *) &GetScratchPixmapHeader,
b21fb18
     (void *) &FreeScratchPixmapHeader,
b21fb18
@@ -1506,6 +1507,8 @@ _X_HIDDEN void *xorg_symbols[] = {
b21fb18
     (void *) &xf86DestroyCursorInfoRec,
b21fb18
     (void *) &xf86ForceHWCursor,
b21fb18
     (void *) &xf86CrtcConfigPrivateIndex,
b21fb18
+    (void *) &xf86GetPrimaryOutput,
b21fb18
+    (void *) &xf86GetPrimaryCrtc,
b21fb18
     (void *) &xf86CrtcConfigInit,
b21fb18
     (void *) &xf86CrtcSetSizeRange,
b21fb18
     (void *) &xf86CrtcCreate,
b21fb18
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
b21fb18
index 906981b..544d62a 100644
b21fb18
--- a/hw/xfree86/modes/xf86Crtc.c
b21fb18
+++ b/hw/xfree86/modes/xf86Crtc.c
b21fb18
@@ -1809,6 +1809,8 @@ biggestMode(DisplayModePtr a, DisplayModePtr b)
b21fb18
  *
b21fb18
  * hilariously, this can get called before ->pScreen is filled in.  that's
b21fb18
  * way early in screen init, so we'll assume it just doesn't matter yet.
b21fb18
+ *
b21fb18
+ * for ABI compat with older drivers we also fill in ->compat_output.  weep.
b21fb18
  */
b21fb18
 xf86OutputPtr
b21fb18
 xf86GetPrimaryOutput(ScrnInfoPtr scrn)
b21fb18
@@ -1820,21 +1822,30 @@ xf86GetPrimaryOutput(ScrnInfoPtr scrn)
b21fb18
         rrScrPrivPtr rrScrPriv = rrGetScrPriv(scrn->pScreen);
b21fb18
 
b21fb18
         /* defaults to NULL */
b21fb18
-        if (rrScrPriv->primaryOutput)
b21fb18
-            return rrScrPriv->primaryOutput->devPrivate;
b21fb18
+        if (rrScrPriv->primaryOutput) {
b21fb18
+            xf86OutputPtr ret = rrScrPriv->primaryOutput->devPrivate;
b21fb18
+            for (i = 0; i < config->num_output; i++)
b21fb18
+                if (config->output[i] == ret)
b21fb18
+                    config->compat_output = i;
b21fb18
+            return ret;
b21fb18
+        }
b21fb18
     }
b21fb18
 
b21fb18
     for (i = 0; i < config->num_output; i++) {
b21fb18
         xf86OutputPtr output = config->output[i];
b21fb18
-        if (output->status == XF86OutputStatusConnected)
b21fb18
+        if (output->status == XF86OutputStatusConnected) {
b21fb18
+            config->compat_output = i;
b21fb18
             return output;
b21fb18
+        }
b21fb18
     }
b21fb18
 
b21fb18
     /* desperation */
b21fb18
     for (i = 0; i < config->num_output; i++) {
b21fb18
         xf86OutputPtr output = config->output[i];
b21fb18
-        if (output->status == XF86OutputStatusUnknown)
b21fb18
+        if (output->status == XF86OutputStatusUnknown) {
b21fb18
+            config->compat_output = i;
b21fb18
             return output;
b21fb18
+        }
b21fb18
     }
b21fb18
 
b21fb18
     return NULL;
b21fb18
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
b21fb18
index 39ba81d..b497df7 100644
b21fb18
--- a/hw/xfree86/modes/xf86Crtc.h
b21fb18
+++ b/hw/xfree86/modes/xf86Crtc.h
b21fb18
@@ -631,7 +631,8 @@ typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);
b21fb18
 typedef struct _xf86CrtcConfig {
b21fb18
     int			num_output;
b21fb18
     xf86OutputPtr	*output;
b21fb18
-    int			unused;
b21fb18
+    /* ABI hack, sigh */
b21fb18
+    int			compat_output;
b21fb18
 
b21fb18
     int			num_crtc;
b21fb18
     xf86CrtcPtr		*crtc;
b21fb18
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
b21fb18
index 1510735..a470429 100644
b21fb18
--- a/hw/xfree86/modes/xf86RandR12.c
b21fb18
+++ b/hw/xfree86/modes/xf86RandR12.c
b21fb18
@@ -62,6 +62,7 @@ typedef struct _xf86RandR12Info {
b21fb18
      * See https://bugs.freedesktop.org/show_bug.cgi?id=21554
b21fb18
      */
b21fb18
     xf86EnterVTProc *orig_EnterVT;
b21fb18
+    xf86AdjustFrameProc *orig_AdjustFrame;
b21fb18
 } XF86RandRInfoRec, *XF86RandRInfoPtr;
b21fb18
 
b21fb18
 #ifdef RANDR_12_INTERFACE
b21fb18
@@ -1766,6 +1767,24 @@ xf86RandR12EnterVT (int screen_index, int flags)
b21fb18
     return RRGetInfo (pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
b21fb18
 }
b21fb18
 
b21fb18
+/*
b21fb18
+ * gross ABI hack.  need to ensure compat_output is current before calling
b21fb18
+ * down to driver AdjustFrame, which xf86GetPrimaryOutput does as a side effect
b21fb18
+ */
b21fb18
+static void
b21fb18
+xf86RandR12AdjustFrame(int scrnIndex, int x, int y, int flags)
b21fb18
+{
b21fb18
+    ScrnInfoPtr scrn = xf86Screens[scrnIndex];
b21fb18
+    XF86RandRInfoPtr randrp = XF86RANDRINFO(scrn->pScreen);
b21fb18
+    
b21fb18
+    (void) xf86GetPrimaryOutput(scrn);
b21fb18
+
b21fb18
+    scrn->AdjustFrame = randrp->orig_AdjustFrame;
b21fb18
+    scrn->AdjustFrame(scrnIndex, x, y, flags);
b21fb18
+    randrp->orig_AdjustFrame = scrn->AdjustFrame;
b21fb18
+    scrn->AdjustFrame = xf86RandR12AdjustFrame;
b21fb18
+}
b21fb18
+
b21fb18
 static Bool
b21fb18
 xf86RandR12Init12 (ScreenPtr pScreen)
b21fb18
 {
b21fb18
@@ -1794,6 +1813,9 @@ xf86RandR12Init12 (ScreenPtr pScreen)
b21fb18
     randrp->orig_EnterVT = pScrn->EnterVT;
b21fb18
     pScrn->EnterVT = xf86RandR12EnterVT;
b21fb18
 
b21fb18
+    randrp->orig_AdjustFrame = pScrn->AdjustFrame;
b21fb18
+    pScrn->AdjustFrame = xf86RandR12AdjustFrame;
b21fb18
+
b21fb18
     if (!xf86RandR12CreateObjects12 (pScreen))
b21fb18
 	return FALSE;
b21fb18
 
b21fb18
-- 
b21fb18
1.6.5.2
b21fb18