modesetting: Adapt xf86HandleColorMaps() for > 24 color depth. (v2)

This retains old behavior for depths <= 24, but allows gamma
table and colormap updates to work properly at depth 30.

This needs the xf86Randr12CrtcComputeGamma() fix for depth 30
from a previous commit to work. Otherwise the server will work,
but gamma table updates will silently fail, iow. the server
would always run with a default identity gamma lut.

v2: Simplify as proposed by Michel.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Antoine Martin <antoine@nagafix.co.uk> (v1)
This commit is contained in:
Mario Kleiner 2018-02-27 03:05:31 +01:00 committed by Adam Jackson
parent b5f9fcd50a
commit 7bc86c7d23

View File

@ -2262,13 +2262,17 @@ drmmode_load_palette(ScrnInfoPtr pScrn, int numColors,
Bool
drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
{
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, "Initializing kms color map\n");
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
"Initializing kms color map for depth %d, %d bpc.\n",
pScrn->depth, pScrn->rgbBits);
if (!miCreateDefColormap(pScreen))
return FALSE;
/* all radeons support 10 bit CLUTs */
if (!xf86HandleColormaps(pScreen, 256, 10, drmmode_load_palette, NULL,
CMAP_PALETTED_TRUECOLOR |
CMAP_RELOAD_ON_MODE_SWITCH))
/* Adapt color map size and depth to color depth of screen. */
if (!xf86HandleColormaps(pScreen, 1 << pScrn->rgbBits, 10,
drmmode_load_palette, NULL,
CMAP_PALETTED_TRUECOLOR |
CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
return TRUE;
}