diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index 0db7717..61b3390 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -919,11 +919,6 @@ Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma) { MessageType from = X_DEFAULT; - /* Pretend we succeeded if we support better a gamma system. - * This avoids a confusing message. - */ - if (xf86_crtc_supports_gamma(scrp)) - return TRUE; #if 0 xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC); #endif @@ -955,6 +950,11 @@ xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma) scrp->gamma.green = 1.0; scrp->gamma.blue = 1.0; } + /* Pretend we succeeded if we support better a gamma system. + * This avoids a confusing message. + */ + if (xf86_crtc_supports_gamma(scrp)) + return TRUE; xf86DrvMsg(scrp->scrnIndex, from, "Using gamma correction (%.1f, %.1f, %.1f)\n", scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue); diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c6eed33..0e09ebc 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -2228,19 +2228,19 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, red[i] = i << 8; else red[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)gamma_red) * (double)(size - 1) * 256); + 1. / (double)gamma_red) * (double)(size - 1) * 256); if (gamma_green == 1.0) green[i] = i << 8; else green[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)gamma_green) * (double)(size - 1) * 256); + 1. / (double)gamma_green) * (double)(size - 1) * 256); if (gamma_blue == 1.0) blue[i] = i << 8; else blue[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)gamma_blue) * (double)(size - 1) * 256); + 1. / (double)gamma_blue) * (double)(size - 1) * 256); } /* Default size is 256, so anything else is failure. */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index f941a3b..1e3b70c 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1703,7 +1703,7 @@ gamma_to_ramp(float gamma, CARD16 *ramp, int size) if (gamma == 1.0) ramp[i] = i << 8; else - ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), gamma) + ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), 1. / gamma) * (double)(size - 1) * 256); } } @@ -1740,6 +1740,8 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma) xfree(points); + pScrn->gamma = gamma; + return Success; }