From 0d0986bf3b924ccb26e4bc6a8c06aed41f238683 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Fri, 1 Oct 2021 07:42:01 +0200 Subject: [PATCH] modesetting: Enable GAMMA_LUT for lut's with up to 4096 slots. A lut size of 4096 slots has been verified to work correctly, as tested with amdgpu-kms. Intel Tigerlake Gen12 hw has a very large GAMMA_LUT size of 262145 slots, but also issues with its current GAMMA_LUT implementation, as of Linux 5.14. Therefore we keep GAMMA_LUT off for large lut's. This currently excludes Intel Icelake, Tigerlake and later. This can be overriden via the "UseGammaLUT" boolean xorg.conf option to force use of GAMMA_LUT on or off. See following link for the Tigerlake situation: https://gitlab.freedesktop.org/drm/intel/-/issues/3916#note_1085315 Signed-off-by: Mario Kleiner (cherry picked from commit 66e5a5bb12c58413a4d71781c5a7f63f675bfe55) --- .../drivers/modesetting/drmmode_display.c | 21 +++++++++++++++---- .../drivers/modesetting/modesetting.man | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index c10504c32..d6df28f5a 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -2404,10 +2404,23 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG, "Allocated crtc nr. %d to this screen.\n", num); - drmmode_crtc->use_gamma_lut = - drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].prop_id && - drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].value && - xf86ReturnOptValBool(drmmode->Options, OPTION_USE_GAMMA_LUT, TRUE); + if (drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].prop_id && + drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].value) { + /* + * GAMMA_LUT property supported, and so far tested to be safe to use by + * default for lut sizes up to 4096 slots. Intel Tigerlake+ has some + * issues, and a large GAMMA_LUT with 262145 slots, so keep GAMMA_LUT + * off for large lut sizes by default for now. + */ + drmmode_crtc->use_gamma_lut = drmmode_crtc->props[DRMMODE_CRTC_GAMMA_LUT_SIZE].value <= 4096; + + /* Allow config override. */ + drmmode_crtc->use_gamma_lut = xf86ReturnOptValBool(drmmode->Options, + OPTION_USE_GAMMA_LUT, + drmmode_crtc->use_gamma_lut); + } else { + drmmode_crtc->use_gamma_lut = FALSE; + } if (drmmode_crtc->use_gamma_lut && drmmode_crtc->props[DRMMODE_CRTC_CTM].prop_id) { diff --git a/hw/xfree86/drivers/modesetting/modesetting.man b/hw/xfree86/drivers/modesetting/modesetting.man index 0145344d2..bb948380b 100644 --- a/hw/xfree86/drivers/modesetting/modesetting.man +++ b/hw/xfree86/drivers/modesetting/modesetting.man @@ -99,8 +99,8 @@ will assign xrandr outputs LVDS and VGA-0 to this instance of the driver. .BI "Option \*qUseGammaLUT\*q \*q" boolean \*q Enable or disable use of the GAMMA_LUT property, when available. When enabled, this option allows the driver to use gamma ramps with more -entries, if supported by the kernel. -Default: on. +entries, if supported by the kernel. By default, GAMMA_LUT will be used for +kms drivers which are known to be safe for use of GAMMA_LUT. .TP .SH "SEE ALSO" @xservername@(@appmansuffix@), @xconfigfile@(@filemansuffix@), Xserver(@appmansuffix@),