Bug 100294

Summary: [BISECTED] Gamma is not initializing properly when xinerama enabled
Product: xorg Reporter: Mariusz Białończyk <manio>
Component: Server/GeneralAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
xorg.conf
none
log
none
a reverting patch to have it back working (fwiw)
none
First monitor of the xinerama set
none
Second monitor of the xinerama set
none
A clean desktop for the comparision
none
Example fix for the radeon driver none

Description Mariusz Białończyk 2017-03-21 06:34:05 UTC
After the commit:

commit 62f44052573b475a7b4c24f8e2da9bd6a8f1bd70
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Tue Jun 21 15:41:45 2016 +0900

    xfree86/modes: Move gamma initialization to xf86RandR12Init12 v2

With xinerama enabled, every screen on xinerama uses "different" random color on startup instead of default black color. The effect is that eg one screen is orange, next one is blue etc.
Comment 1 Mariusz Białończyk 2017-03-21 06:34:23 UTC
Created attachment 130335 [details]
xorg.conf
Comment 2 Mariusz Białończyk 2017-03-21 06:36:56 UTC
Created attachment 130336 [details]
log
Comment 3 Mariusz Białończyk 2017-03-29 08:11:20 UTC
Only for your information when you're at this bug:
Reverting the changes from file: xf86Crtc.c are sufficient to make it all work back again - the monitors are black when starting Xorg, no gamma problems on xinerama.

Overall - I have to revert the xf86Crtc.c changes and also apply a patch from bug: https://bugs.freedesktop.org/show_activity.cgi?id=100293 to have my Xorg working properly.
Comment 4 Michel Dänzer 2017-03-29 08:12:07 UTC
I get updates about this report via the xorg-team mailing list.

Thanks for the report, I'll look into it when I get a chance.
Comment 5 Mariusz Białończyk 2017-04-03 19:44:16 UTC
Created attachment 130656 [details] [review]
a reverting patch to have it back working (fwiw)
Comment 6 Michel Dänzer 2017-04-06 03:32:05 UTC
The issue here appears to be that the colormap isn't applied properly with Xinerama enabled. The code moved by the bisected commit merely papered over this, AFAICT e.g. changing gamma wouldn't have any effect on any screens but the first one before either.

FWIW, changing gamma e.g. with xgamma works around the issue on the first screen for now.
Comment 7 Mariusz Białończyk 2017-04-06 19:18:13 UTC
Created attachment 130733 [details]
First monitor of the xinerama set
Comment 8 Mariusz Białończyk 2017-04-06 19:18:54 UTC
Created attachment 130734 [details]
Second monitor of the xinerama set
Comment 9 Mariusz Białończyk 2017-04-06 19:23:38 UTC
Created attachment 130735 [details]
A clean desktop for the comparision
Comment 10 Michel Dänzer 2017-04-10 09:59:44 UTC
Created attachment 130773 [details] [review]
Example fix for the radeon driver

Actually, this happens because the driver's drmmode_set_mode_major uses crtc->gamma_red/green/blue directly. Since Xorg 1.19, those do not contain the final gamma values to be loaded to the hardware anymore[0].

This is an example fix for the radeon driver, should be easy to adapt to the nouveau driver.

[0] Even with RandR enabled; this can result in other incorrect behaviour, e.g. when switching modes or VTs while something like redshift is setting a non-default gamma.
Comment 11 Michel Dänzer 2017-04-11 02:11:18 UTC
Never mind, I'll send a different patch or patches to fix this bug and bug 100293.
Comment 12 Michel Dänzer 2017-04-12 09:40:10 UTC
Comment on attachment 130773 [details] [review]
Example fix for the radeon driver

Fix posted for review:

https://patchwork.freedesktop.org/patch/149863/
Comment 13 Mariusz Białończyk 2017-04-13 04:30:45 UTC
The patch is working. Please close this bug after merging.
Thank you.
Comment 14 Michel Dänzer 2017-04-17 07:35:58 UTC
Thanks for the report, fixed in Git master:

https://cgit.freedesktop.org/xorg/xserver/commit/?id=41dafcc2a2942fc4c94ce3cbafc4a1b413c460c3

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.