>> If so, does this what you want:
>> 1. for palette_size <= 256, keep the original way
>> 2. for palette_size > 256, enlarge the crtc gamma_size and copy into it
>
> Not sure what you mean by "copy into it". The driver should simply make
> sure the CRTC gamma CLUT is large enough, in which case the code changed
> by your patch works as is.
>
So you mean in DDX init, we should check if crtc gamma size is big enough,
and enlarge when needed instead of doing the check and enlarge in xserver
like the attached patch?
Regards,
Qiang
From b4981919402e1841e52b99eafdb0554dc17ceb34 Mon Sep 17 00:00:00 2001
From: Qiang Yu <[email protected]>
Date: Tue, 31 Oct 2017 17:02:49 +0800
Subject: [PATCH xserver] xfree86: fix gamma compute when gamma_size > 256
gama_size > crtc->gamma_size (=256)
this may happen when screen has per RGB chanel > 8bit,
i.e. 30bit depth screen 10bit per RGB.
Signed-off-by: Qiang Yu <[email protected]>
---
hw/xfree86/modes/xf86RandR12.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index aac02db..3b37cb9 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1249,6 +1249,21 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
}
static void
+xf86RandR12CrtcResizeGamma(xf86CrtcPtr crtc, int gamma_size)
+{
+ int new_gamma_size = max(gamma_size, 256);
+
+ if (crtc->gamma_size != new_gamma_size) {
+ free(crtc->gamma_red);
+
+ crtc->gamma_size = new_gamma_size;
+ crtc->gamma_red = xallocarray(crtc->gamma_size, 3 * sizeof(CARD16));
+ crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
+ crtc->gamma_blue = crtc->gamma_green + crtc->gamma_size;
+ }
+}
+
+static void
xf86RandR12CrtcComputeGamma(xf86CrtcPtr crtc, LOCO *palette,
int palette_red_size, int palette_green_size,
int palette_blue_size, CARD16 *gamma_red,
@@ -1260,6 +1275,8 @@ xf86RandR12CrtcComputeGamma(xf86CrtcPtr crtc, LOCO *palette,
CARD32 value;
int i, j;
+ xf86RandR12CrtcResizeGamma(crtc, gamma_size);
+
for (shift = 0; (gamma_size << shift) < (1 << 16); shift++);
gamma_slots = crtc->gamma_size / palette_red_size;
--
2.7.4
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel