[PATCH 0/3 v2] xrandr: fix misc --gamma bugs

Aaron Plattner aplattner at nvidia.com
Fri Aug 24 20:58:16 PDT 2012


On 08/24/2012 03:53 PM, Andy Ritger wrote:
> As I understand it: the gamma-correction tables configured through
> XRR[GS]etCrtcGamma store 16:16:16 X Colors.  An X Color has some number
> of significant bits, stored in the MSBs of the X Color (reported
> in Visual::bits_per_rgb, though the gamma-correction tables are
> visual-independent).  The significant bits of the X Color dictate the
> size of the gamma-correction table (XRRGetCrtcGammaSize() == 2^sigbits).
>
> PATCH 1/3 corrects xrandr to do gamma *correction* (i.e., 1/gamma)
> PATCH 2/3 removes an assumption that XRRGetCrtcGammaSize() == 256.
> PATCH 3/3 adjusts gamma-correction computation to produce results in
>      the range [0,2^sigbits) << (16 - sigbits).
>
> I found these links helpful:
> http://www.poynton.com/PDFs/TIDV/Gamma.pdf (Gamma in computer graphics, page 17)
> http://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/common/xf86cmap.c:ComputeGamma()
>
> If you compare against the code in xf86cmap.c, note that
> CMapScreenPtr::gamma[] is stored in the range [0,2^sigbits), and is
> * converted from [0,65536) in ComputeGammaRamp()
> * converted to [0,65536) in xf86GetGammaRamp()
>
> In the cover letter for v1 of this patch set, I asked these questions:
>
>> * PATCH 1 changes long standing behavior in xrandr(1).  While the patch
>>    makes the semantics consistent with xgamma(1) and xorg.conf options,
>>    maybe it would be better to keep the existing behavior and just document
>>    that behavior in the man page and --help?
>
> If no one else has an opinion, I'm inclined to make the semantics
> consistent with xgamma(1) and xorg.conf.
>
>> * hw/xfree86/common/xf86cmap.c:xf86GetGammaRamp() makes up some values
>>    to pack in the low bits of each component of each entry.  Only the MSBs
>>    should matter for hardware, but for consistency maybe xrandr(1) should
>>    do something similar to populate the low bits?
>
> If no one else has an opinion, I'm inclined to not bother filling out
> the low bits in xrandr(1).
>
> Thanks,
> - Andy
>
>
> Changes since v1:
> - in PATCH 2/3: add a comment and sanity check, clarifying why it is
>    safe to assume that the size of the gamma ramp is <= 16-bits.
>
> Andy Ritger (3):
>    xrandr: use 1/gamma to compute gamma-correction
>    xrandr: fix gamma == 1.0 && sigbits != 8
>    xrandr: compute gamma-correction in [0,2^sigbits)
>
>   xrandr.c |   63 +++++++++++++++++++++++++++++++++++++++++++++++--------------
>   1 files changed, 48 insertions(+), 15 deletions(-)

To ssh://git.freedesktop.org/git/xorg/app/xrandr
    755234b..b501dd3  master -> master

-- Aaron



More information about the xorg-devel mailing list