Bug 31517

Summary: xorg.conf Gamma and xrandr --gamma compute totally different curves with the same values.
Product: xorg Reporter: Nick Bowler <nbowler>
Component: Server/DDX/XorgAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: bugs.freedesktop.org, higuita
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Nick Bowler 2010-11-09 20:37:57 UTC
Trying to set the gamma correction for my monitor in xorg.conf revealed a
little surprise: setting the Gamma option in xorg.conf results in a totally
different curve from xrandr --gamma.  The xgamma tool does the same thing as
xorg.conf.

Printing out the gamma curves when they're passed to the video driver reveals
the following (only showing the red curve here):

With Gamma 0.7 0.7 0.7 in xorg.conf
0 23 64 114 172 237 307 383 464 549 638 732 828 929 1033 1140 1250 1363 1479 1598 1719 1843 1970 2099 2231 2365 2501 2640 2781 2924 3069 3216 3365 3516 3670 3825 3982 4141 4302 4464 4629 4795 4963 5133 5304 5477 5652 5828 6006 6186 6367 6550 6734 6920 7107 7296 7486 7678 7871 8065 8261 8459 8658 8858 9059 9262 9467 9672 9879 10087 10297 10508 10720 10933 11147 11363 11580 11799 12018 12239 12461 12684 12908 13134 13360 13588 13817 14047 14279 14511 14744 14979 15215 15451 15689 15928 16168 16410 16652 16895 17139 17385 17631 17879 18127 18377 18627 18879 19131 19385 19639 19895 20152 20409 20668 20927 21188 21449 21711 21975 22239 22504 22770 23037 23306 23574 23844 24115 24387 24660 24933 25208 25483 25759 26036 26314 26593 26873 27154 27435 27718 28001 28285 28570 28856 29142 29430 29718 30008 30298 30589 30880 31173 31466 31761 32056 32351 32648 32946 33244 33543 33843 34144 34445 34747 35050 35354 35659 35964 36271 36578 36885 37194 37503 37813 38124 38436 38748 39061 39375 39690 40005 40321 40638 40956 41274 41593 41913 42234 42555 42877 43200 43523 43847 44172 44498 44824 45151 45479 45808 46137 46467 46797 47129 47461 47793 48127 48461 48796 49131 49467 49804 50142 50480 50819 51158 51499 51840 52181 52523 52866 53210 53554 53899 54245 54591 54938 55286 55634 55983 56332 56683 57034 57385 57737 58090 58443 58798 59152 59508 59864 60220 60578 60936 61294 61653 62013 62374 62735 63096 63459 63822 64185 64549 64914 65280

With xrandr --output VGA-1 --gamma 0.7:0.7:0.7
0 1354 2200 2923 3575 4179 4748 5290 5808 6307 6790 7258 7714 8159 8593 9019 9435 9844 10246 10641 11031 11414 11792 12164 12532 12895 13254 13609 13960 14307 14651 14991 15328 15662 15993 16320 16645 16968 17287 17605 17919 18232 18542 18850 19156 19460 19761 20061 20359 20655 20949 21241 21532 21821 22109 22394 22679 22961 23243 23522 23801 24078 24353 24628 24901 25172 25443 25712 25980 26247 26513 26777 27041 27303 27564 27825 28084 28342 28599 28855 29111 29365 29618 29871 30122 30373 30622 30871 31119 31366 31612 31858 32103 32346 32590 32832 33073 33314 33554 33794 34032 34270 34507 34744 34979 35214 35449 35683 35916 36148 36380 36611 36842 37072 37301 37530 37758 37986 38213 38439 38665 38890 39115 39339 39563 39786 40008 40230 40452 40673 40893 41113 41333 41551 41770 41988 42205 42422 42639 42855 43070 43286 43500 43714 43928 44142 44354 44567 44779 44990 45202 45412 45623 45833 46042 46251 46460 46668 46876 47083 47291 47497 47704 47910 48115 48320 48525 48730 48934 49137 49341 49544 49746 49949 50151 50352 50553 50754 50955 51155 51355 51554 51754 51953 52151 52349 52547 52745 52942 53139 53336 53532 53728 53924 54119 54314 54509 54704 54898 55092 55286 55479 55672 55865 56057 56250 56441 56633 56825 57016 57206 57397 57587 57777 57967 58157 58346 58535 58723 58912 59100 59288 59476 59663 59850 60037 60224 60410 60596 60782 60968 61153 61339 61523 61708 61893 62077 62261 62445 62628 62812 62995 63178 63360 63543 63725 63907 64088 64270 64451 64632 64813 64994 65174 65354 65535

These curves aren't even remotely similar: the former is much darker than the
default 1.0/1.0/1.0 and the latter is much brighter.  Closer inspection reveals
that the inputs to these tools are reciprocal to each other: a setting of
1/0.7 ~= 1.43 in xorg.conf roughly matches a setting of 0.7 to xrandr and
vice versa.

These tools should do the same thing when given the same inputs, or else this
disparity should be mentioned in their documentation.

This occurs with git xserver and xrandr 1.3.4.
Comment 1 higuita 2012-01-14 19:33:07 UTC
this is very weird... kgamma gave me some gamma values, but when used in xrandr i get totally wrong colors...

after founding this i used the 1/x value and the colors are correct.

at very least document it! a single line in the man page is enough
Comment 2 Jeff Smith 2018-02-05 18:05:12 UTC
This was an issue with the xrandr tool, and was fixed with

https://cgit.freedesktop.org/xorg/app/xrandr/commit/?
id=6bf48ae8d8db58ab74182383e54332f120f024c2

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.