[PATCH] xf86: add rgb ordering helper

Dave Airlie airlied at gmail.com
Thu Jan 26 03:36:47 PST 2012


From: Dave Airlie <airlied at redhat.com>

At least the intel, nouveau and radeon driver contain this chunk of code.

We should move it into the server just for the sake of stopping further cut-n-paste.

Drivers can be adapted to use it later.

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

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index b711f05..00dd229 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -227,6 +227,7 @@ extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int
 extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp);
 extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
 extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+extern _X_EXPORT void xf86FixupRGBOrdering(ScrnInfoPtr scrn, ScreenPtr screen);
 extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
 extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
 extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen);
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 248ccf4..0cfbece 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -808,6 +808,22 @@ xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)
     }
 }
 
+void xf86FixupRGBOrdering(ScrnInfoPtr scrn, ScreenPtr screen)
+{
+    VisualPtr visual;
+    visual = screen->visuals + screen->numVisuals;
+    while (--visual >= screen->visuals) {
+	if ((visual->class | DynamicClass) == DirectColor) {
+	    visual->offsetRed = scrn->offset.red;
+	    visual->offsetGreen = scrn->offset.green;
+	    visual->offsetBlue = scrn->offset.blue;
+	    visual->redMask = scrn->mask.red;
+	    visual->greenMask = scrn->mask.green;
+	    visual->blueMask = scrn->mask.blue;
+	}
+    }
+}
+
 #define TEST_GAMMA(g) \
 	(g).red > GAMMA_ZERO || (g).green > GAMMA_ZERO || (g).blue > GAMMA_ZERO
 
-- 
1.7.6



More information about the xorg-devel mailing list