xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 3 19:46:48 UTC 2024


 fb/fb.h                         |    3 +++
 fb/fbcmap_mi.c                  |   35 +++++++++++++++++++++++++++++++++++
 fb/fbscreen.c                   |   12 +++++++++---
 hw/xfree86/common/xf86.h        |   10 ++++++++++
 hw/xfree86/common/xf86Globals.c |    1 +
 hw/xfree86/common/xf86Helper.c  |   16 ++++++++++++++--
 hw/xfree86/common/xf86Init.c    |    5 +++++
 hw/xfree86/common/xf86Priv.h    |    1 +
 hw/xfree86/doc/ddxDesign.xml    |   25 +++++++++++++++++++++++++
 hw/xfree86/man/Xorg.man         |    3 +++
 hw/xfree86/vgahw/vgaHW.c        |    4 +++-
 11 files changed, 109 insertions(+), 6 deletions(-)

New commits:
commit f2b019d2b3ab5ed75a824e5b46507491bd416938
Author: Izumi Tsutsui <tsutsui at ceres.dti.ne.jp>
Date:   Thu Apr 20 01:32:15 2023 +0900

    fb: Fix 1bpp Xservers on "whitePixel=0, blackPixel=1" VRAMs
    
    Closes: #1057

diff --git a/fb/fb.h b/fb/fb.h
index d157b6956..c2c4cae78 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -734,6 +734,9 @@ fbResolveColor(unsigned short *pred,
 extern _X_EXPORT Bool
  fbInitializeColormap(ColormapPtr pmap);
 
+extern _X_EXPORT Bool
+ mfbCreateColormap(ColormapPtr pmap);
+
 extern _X_EXPORT int
 
 fbExpandDirectColors(ColormapPtr pmap,
diff --git a/fb/fbcmap_mi.c b/fb/fbcmap_mi.c
index c9c6d8027..a71828a11 100644
--- a/fb/fbcmap_mi.c
+++ b/fb/fbcmap_mi.c
@@ -66,6 +66,41 @@ fbInitializeColormap(ColormapPtr pmap)
     return miInitializeColormap(pmap);
 }
 
+Bool
+mfbCreateColormap(ColormapPtr pmap)
+{
+    ScreenPtr	pScreen;
+    unsigned short  red0, green0, blue0;
+    unsigned short  red1, green1, blue1;
+    Pixel pix;
+
+    pScreen = pmap->pScreen;
+    if (pScreen->whitePixel == 0)
+    {
+	red0 = green0 = blue0 = ~0;
+	red1 = green1 = blue1 = 0;
+    }
+    else
+    {
+	red0 = green0 = blue0 = 0;
+	red1 = green1 = blue1 = ~0;
+    }
+
+    /* this is a monochrome colormap, it only has two entries, just fill
+     * them in by hand.  If it were a more complex static map, it would be
+     * worth writing a for loop or three to initialize it */
+
+    /* this will be pixel 0 */
+    pix = 0;
+    if (AllocColor(pmap, &red0, &green0, &blue0, &pix, 0) != Success)
+	return FALSE;
+
+    /* this will be pixel 1 */
+    if (AllocColor(pmap, &red1, &green1, &blue1, &pix, 0) != Success)
+	return FALSE;
+    return TRUE;
+}
+
 int
 fbExpandDirectColors(ColormapPtr pmap,
                      int ndef, xColorItem * indefs, xColorItem * outdefs)
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 4ab807ab5..42efaa911 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -100,8 +100,10 @@ fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */
     if (!fbAllocatePrivates(pScreen))
         return FALSE;
     pScreen->defColormap = FakeClientID(0);
-    /* let CreateDefColormap do whatever it wants for pixels */
-    pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+    if (bpp > 1) {
+	/* let CreateDefColormap do whatever it wants for pixels */
+	pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+    }
     pScreen->QueryBestSize = fbQueryBestSize;
     /* SaveScreen */
     pScreen->GetImage = fbGetImage;
@@ -118,7 +120,11 @@ fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */
     pScreen->RealizeFont = fbRealizeFont;
     pScreen->UnrealizeFont = fbUnrealizeFont;
     pScreen->CreateGC = fbCreateGC;
-    pScreen->CreateColormap = fbInitializeColormap;
+    if (bpp == 1) {
+	pScreen->CreateColormap = mfbCreateColormap;
+    } else {
+	pScreen->CreateColormap = fbInitializeColormap;
+    }
     pScreen->DestroyColormap = (void (*)(ColormapPtr)) NoopDDA;
     pScreen->InstallColormap = fbInstallColormap;
     pScreen->UninstallColormap = fbUninstallColormap;
commit 15624bb5bca0490a0cd87a1689393cc5bcaa47e6
Author: Izumi Tsutsui <tsutsui at ceres.dti.ne.jp>
Date:   Thu Apr 20 01:17:41 2023 +0900

    Revert "xfree86: Remove -flippixels"
    
    This reverts commit d1c00c859c6676fbb540420c9055788bc19cb18f except
    hw/xfree86/common/xf86str.h that was not used by -flipPixels option.

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 927a7a7f1..8d0cb0532 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -79,6 +79,14 @@ extern _X_EXPORT Bool xf86DRI2Enabled(void);
 
 #define XF86SCRNINFO(p) xf86ScreenToScrn(p)
 
+#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")
 
 /* Compatibility functions for pre-input-thread drivers */
@@ -278,6 +286,8 @@ xf86GetWeight(void);
 extern _X_EXPORT Gamma
 xf86GetGamma(void);
 extern _X_EXPORT Bool
+xf86GetFlipPixels(void);
+extern _X_EXPORT Bool
 xf86ServerIsExiting(void);
 extern _X_EXPORT Bool
 xf86ServerIsResetting(void);
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 65a3192df..b48b7aada 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -188,6 +188,7 @@ int xf86FbBpp = -1;
 int xf86Depth = -1;
 rgb xf86Weight = { 0, 0, 0 };
 
+Bool xf86FlipPixels = FALSE;
 Gamma xf86Gamma = { 0.0, 0.0, 0.0 };
 
 Bool xf86AllowMouseOpenFail = FALSE;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 0389945a7..2786e6c6c 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -952,8 +952,14 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
 void
 xf86SetBlackWhitePixels(ScreenPtr pScreen)
 {
-    pScreen->whitePixel = 1;
-    pScreen->blackPixel = 0;
+    if (xf86FlipPixels) {
+        pScreen->whitePixel = 0;
+        pScreen->blackPixel = 1;
+    }
+    else {
+        pScreen->whitePixel = 1;
+        pScreen->blackPixel = 0;
+    }
 }
 
 /*
@@ -1394,6 +1400,12 @@ xf86GetGamma(void)
     return xf86Gamma;
 }
 
+Bool
+xf86GetFlipPixels(void)
+{
+    return xf86FlipPixels;
+}
+
 Bool
 xf86ServerIsExiting(void)
 {
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 5695e71ac..07284f49e 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -954,6 +954,10 @@ ddxProcessArgument(int argc, char **argv, int i)
         xf86ConfigDir = argv[i + 1];
         return 2;
     }
+    if (!strcmp(argv[i], "-flipPixels")) {
+        xf86FlipPixels = TRUE;
+        return 1;
+    }
 #ifdef XF86VIDMODE
     if (!strcmp(argv[i], "-disableVidMode")) {
         xf86VidModeDisabled = TRUE;
@@ -1233,6 +1237,7 @@ ddxUseMsg(void)
     ErrorF
         ("-pointer name          specify the core pointer InputDevice name\n");
     ErrorF("-nosilk                disable Silken Mouse\n");
+    ErrorF("-flipPixels            swap default black/white Pixel values\n");
 #ifdef XF86VIDMODE
     ErrorF("-disableVidMode        disable mode adjustments with xvidtune\n");
     ErrorF
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index d5185d8df..662db054c 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -69,6 +69,7 @@ extern _X_EXPORT char *xf86KeyboardName;
 extern _X_EXPORT int xf86FbBpp;
 extern _X_EXPORT int xf86Depth;
 extern _X_EXPORT rgb xf86Weight;
+extern _X_EXPORT Bool xf86FlipPixels;
 extern _X_EXPORT Gamma xf86Gamma;
 
 /* Other parameters */
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index 1eed293fe..b7da50de3 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -1833,6 +1833,7 @@ Some of them are:
     xf86Depth                 -depth from the command line
     xf86Weight                -weight from the command line
     xf86Gamma                 -{r,g,b,}gamma from the command line
+    xf86FlipPixels            -flippixels from the command line
     xf86ProbeOnly             -probeonly from the command line
     defaultColorVisualClass   -cc from the command line
 	</literallayout>
@@ -1893,6 +1894,17 @@ functions:
 
 	</para></blockquote>
 
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86GetFlipPixels();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if <option>-flippixels</option> is
+      present on the command line, and <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+
     </sect2>
 
     <sect2>
@@ -6002,6 +6014,19 @@ strongly encouraged to improve the consistency of driver behaviour.
 
 	  </blockquote></para></blockquote>
 
+      <blockquote><para>
+	  <programlisting>
+    void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      This functions sets the <structfield>blackPixel</structfield> and
+      <structfield>whitePixel</structfield> fields of the <structname>ScrnInfoRec</structname>
+      according to whether or not the <option>-flipPixels</option> command
+      line options is present.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
       <blockquote><para>
 	  <programlisting>
     const char *xf86GetVisualName(int visual);
diff --git a/hw/xfree86/man/Xorg.man b/hw/xfree86/man/Xorg.man
index 3ec6e2c25..2084653f8 100644
--- a/hw/xfree86/man/Xorg.man
+++ b/hw/xfree86/man/Xorg.man
@@ -171,6 +171,9 @@ bpp framebuffer rather than the (possibly default) 32 bpp framebuffer
 (or vice versa).  Legal values are 1, 8, 16, 24, 32.  Not all drivers
 support all values.
 .TP 8
+.B \-flipPixels
+Swap the default values for the black and white pixels.
+.TP 8
 .BI \-gamma " value"
 Set the gamma correction.
 .I value
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index f6888009c..902b54070 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1314,8 +1314,10 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
     if (depth == 1) {
         /* Initialise the Mono map according to which bit-plane gets used */
 
+        Bool flipPixels = xf86GetFlipPixels();
+
         for (i = 0; i < 16; i++)
-            if ((i & (1 << BIT_PLANE)) != 0)
+            if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
                 regp->Attribute[i] = WHITE_VALUE;
             else
                 regp->Attribute[i] = BLACK_VALUE;


More information about the xorg-commit mailing list