Saturday, November 18, 2017

Multiple X displays

I once talked about Compiz Fusion which led me to a little X11 issue related to X11 screen composition settings and extensions. By that time I had just one monitor connected to my nVIDIA GT 610 video card:

$ xrandr
Screen 0: minimum 8 x 8, current 1680 x 1050, ...
DVI-I-0 disconnected primary (...)
VGA-0 disconnected (...)

DVI-I-1 connected 1680x1050+0+0 (...)
...
HDMI-0 disconnected (...) 
...

Since then I've revived another old monitor, a 19" (TFT) Samsung SyncMaster 950B, that could be physically rotated, which I thought it would be useful as a secondary monitor for easing long readings, helping in more lengthy writings or codings and so on.

The problem began because my original single monitor configuration used a 22" (TFT) Samsung SyncMaster 225MS, which only has DVI or HDMI connections, but with the HDMI one only supporting terribly low refresh rates, rendering it virtually unusable. Hence, I had to use the VGA connection on my video card to add in the secondary monitor (the first idea I had to give up was using the DVI connection to the 950B and the HDMI connection to the 225MS).

When I started Solaris 11.3 with both monitors, I immediately noticed that my primary screen had been switched to the monitor on the VGA connection, which, by the way, was sideways, rotated to the right as I had physically rotated the newly added monitor.

I thought it could be very easy to perform the adjustments, after all, I just had to (counter)rotate left the viewport of the newly added monitor, then expand my desktop and redefine my primary video. This should be simple tasks to be performed via the Monitor Preferences GNOME applet launched via System | Preferences | Monitors main menu:


I was partially successful by:
  • Making sure both monitors were "On"
  • Clearing the "Same image in all monitors" checkbox
  • Adjusting the parameters (Refresh, Rotation) of the newly added monitor

But I couldn't immediately fix the issue of the correct primary monitor. Furthermore, I've noticed another issue: the above adjustments affected only the GNOME session, that is, the GDM screen was still messed up with the login screen on the newly added monitor, which had become the primary monitor, in addition to still be displaying sideways due to the physical rotation. So my login screen was on the wrong monitor and rotated right: not a very big problem, but certainly an unpleasant one.

The solution I present does not fix the secondary display rotation upon GDM login, but successfully moves the login dialog box to the desired display (on the right-hand side), which displays correctly.  This mitigates the problem, as the secondary monitor (to the left) just displays a rotated GDM login background during login. In fact, it seems that there's no "static solution" to this remaining issue, because there are unsolv(ed|able) conflicts between GNOME, X and nVIDIA.

I didn't know if the issue, the undesired switch of the primary monitor, was due to the video card itself or due to some other X11 default behavior. Anyway, opening the nVIDIA X Server Settings in System | Preferences I've noticed the checkbox "Make this the primary display for the X screen", which temporarily (and partially) solved the issue:


The issue was temporarily solved and I mean temporarily because I had to make it through the xorg.conf file in order to persist it across reboots.

NOTE
I certainly took a look at the Preview option after clicking on the "Save to X Configuration File" button. But I didn't let any automatic changes to happen because I wanted to stay in strict control of my xorg.conf file (for instance, I had already spent some time in carefully adjusting it for Compiz Fusion).
But at this point I came to a tricky thing:
The Monitor Preferences GNOME applet "dynamically tempers" with the X11 "metamodes Option" within the "Screen Section". If you try to manually do some fancy thing with this option in xorg.conf you'll probably end up with some unexpected wrong result.
Bottom line:
Completely remove the "metamodes Option" from xorg.conf line and let GNOME play its trick with monitors' resolution, refresh-rate and rotations.
The only manual tweak to xorg.conf that needs to be done is to include the setting which defines to X11 what should be the primary monitor:
...
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"

    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    Option         "RenderAccel" "True"
    Option         "AllowGLXWithComposite" "True"
    Option         "AddARGBGLXVisuals" "True"
    SubSection     "Display"
        Depth       24
        Modes      "nvidia-auto-select"
    EndSubSection
EndSection

...
NOTE
I'm not yet ;-) an X11 expert, but DFP seems to mean Digital Flat Panel, in contrast to to legacy CRT, Cathode Ray Tube. Nevertheless, in terms of X configuration and nVIDIA, these have been somewhat relaxed (and don't ask me why) to designate display devices, although, perhaps, it would be more accurate to say "designate display connections". In my particular case, DFP-0 designates my DVI connection while CRT-1 designate my VGA connection. Furthermore, I must conclude/assume that DVI-I-1 is associated to DFP-0 because it's the firstly used (active) connection of this type (DFP).
After everything is reasonable, I get the following report from xrandr:

$ xrandr
Screen 0: 

   minimum 8 x 8, 
   current 2704 x 1280, 
   maximum 16384 x 16384 
DVI-I-0 disconnected  
   (normal left inverted right x axis y axis) 
VGA-0 connected 1024x1280+0+0 left 
   (normal left inverted right x axis y axis) 380mm x 300mm
   1280x1024      60.0 +   75.0*
   1280x960       60.0 
   1152x864       75.0 
   1024x768       75.0     70.1     60.0 
   800x600        75.0     72.2     60.3     56.2 
   640x480        75.0     72.8     59.9   

DVI-I-1 connected primary 1680x1050+1024+0 
   (normal left inverted right x axis y axis) 477mm x 300mm
   1680x1050      59.9*+
   1280x1024      75.0     60.0 
   1280x960       60.0 
   1152x864       75.0 
   1024x768       75.0     70.1     60.0 
   800x600        75.0     72.2     60.3     56.2 
   640x480        75.0     72.8     59.9   

HDMI-0 disconnected  
   (normal left inverted right x axis y axis)

I don't have enough time to research more at this moment.
But some references that might add more useful information are: 

NOTE
The nVIDIA driver of Solaris 11.3 GA is version 346.35.
At the time of this writing, version 384.59 (81.4 MB) was available.
Many bugs have been fixed and some enhancements added.
 
But there may be some trouble upgrading:
New nVIDIA Driver Solaris11.3 Install Problems
I haven't tested but perhaps it's advisable to completely remove the old nVIDIA driver, then reboot to a VESA driver before installing any newer nVIDIA driver.