xf86DefaultMode() picks incorrect resolution for 4K monitor
Submitted by Zachary Tahenakos
Assigned to Xorg Project Team
Description
With multiple 4K monitors, such as 2 HP Z27s, attached to the system, if the user has configured the monitors, the wrong resolution will be chosen. For example, if the user generates an Xorg conf such that the first display is extended to the left of the second, but hasn't chosen a resolution, the X Server will use 1920x1200 as the resolution rather than 3840x2160. This hapepns with Open Source DDX drivers, it has not been seen with closed source drivers.
Going through and debugging a bit, the problem seems to come in when X is trying to find the best resolution to use if the user has done any sort of configuration. In this scenario, the X Server goes through and ends up having the resolution set via xf86TargetUserpref rather than Xf86TargetAspect. In this path, it eventually calls xf86DefaultMode, which tries to get a mode to use. In this function, it tries to find a resolution closest to DEFAULT_DPI. For a monitor with a native mode of 3840x2160 and diagonal screen size of 27inches, the DPI is around 163, much higher than 96. The mode is chosen, but the next mode down, 2560x1600, will subsequently be chosen because it is closer to 96. Eventually, 1920x1200 is chosen and no lower modes will be selected.
If no PreferredMode is specified by the xorg conf, shouldn't the X server choose the native mode of the monitor, assuming there are no other restrictions, such as a Virtual Screen that cannot accommodate the resolution?