[Nouveau] [PATCH] Fix colormap handling at screen depth 30. (v2)

Mario Kleiner mario.kleiner.de at gmail.com
Tue Jun 12 15:58:06 UTC 2018


The various clut handling functions like a setup
consistent with the x-screen color depth. Otherwise
we observe improper sampling in the gamma tables
at depth 30.

Tested at depths 16, 24 and 30 and tested at depths
24 and 30 that xgamma and gamma table animations work,
and with measurement equipment to make sure identity
gamma ramps actually are identity mappings at the output.

v2: Also deal with X-Server 1.19 and earlier, which as of
    v1.19.6 lack a fix to color palette handling and can
    not deal with depths/bpc > 24/8 bpc. On < 1.20 we skip
    xf86HandleColormaps() setup at > 8 bpc. This disables
    color palette handling on such servers at > 8 bpc, but
    still keeps RandR gamma table handling intact.

    Tested on 1.19.6 and 1.20.0 to do the right thing.

Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
---
 src/nv_driver.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/nv_driver.c b/src/nv_driver.c
index 32062eb..a5d50c1 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1565,11 +1565,14 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
 
 	/*
 	 * Initialize colormap layer.
-	 * Must follow initialization of the default colormap 
+	 * Must follow initialization of the default colormap.
+	 * X-Server < 1.20 mishandles > 256 slots / > 8 bpc color maps, so skip
+	 * color map setup on old servers at > 8 bpc. Gamma luts still work.
 	 */
-	if (xf86_config->num_crtc &&
-	    !xf86HandleColormaps(pScreen, 256, 8, NVLoadPalette,
-				 NULL, CMAP_PALETTED_TRUECOLOR))
+	if (xf86_config->num_crtc && (pScrn->rgbBits <= 8 ||
+	    XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,20,0,0,0)) &&
+	    !xf86HandleColormaps(pScreen, 1 << pScrn->rgbBits, pScrn->rgbBits,
+				 NVLoadPalette, NULL, CMAP_PALETTED_TRUECOLOR))
 		return FALSE;
 
 	/* Report any unused options (only for the first generation) */
-- 
2.17.1



More information about the Nouveau mailing list