Monday, September 4, 2006

xorg.conf battles

So I'm a little further along. Not too much, but a little. I spent over two days, probably at least 8 - 10 hours, playing with my X config file, trying to get my ATI X850 dual monitor card to work. Each monitor was showing the same image, a clone of each other. Not quite what I wanted. On Windows, I have my cheapo 14" LCD monitor set up to the left of my 19" CRT, and it is very easy to use the Display Properties dialog to move things around. The CRT is in 1280x1024 mode, while the LCD is in 1024x768, which works just fine in Windows.



But under X it is a whole new ballgame. It was *very* difficult to get the appropriate information on the web. What I could find was one or more of a] out of date, b] for Linux, c] for nVidia and/or d] for a different ATI card. I would have been happy to find a reasonable man page even for the magical xorg.conf file, and especially the ATI driver. But most pages talked about the various ATI proprietary drivers for Linux, which didn't help me at all for my PC-BSD installation. And those that did talk about BSD were using a different card to do dual monitors.



See, ATI has two ways of doing dual monitors. One is a card with one VGA plug on the back, and a splitter cable that has two VGA plugs to plug two monitors into. A similar setup is for a laptop showing on both the internal and external display. But mine actually has two plugs on the board, one for VGA and one for DVI (which came with a DVI->VGA adapter, as my LCD isn't DVI - told you it was cheap).



So this meant all talk about the flgrx couldn't be used, as that has never been ported to BSD. I'd love to see a petition for ATI to make BSD drivers! And there was a lot of talk about Screen 0 and Screen 1, but that never seemed to work for me.



Anyway, after a gazillion hours of experimentation, I was sure I had to ignore all the advice saying to use Screen 0 and Screen 1 in the "Driver" section. For instance, the xorg.conf file found here has:


Section "Device"
Identifier "aticonfig-Device[0]"
Driver "fglrx"
BusID "PCI:1:0:0"
EndSection

Section "Device"
Identifier "aticonfig-Device[1]"
Driver "fglrx"
BusID "PCI:1:0:0"
Screen 1
EndSection


(note especially the BusID - we'll come back to that later) This is a typically recommended configuration for dual monitor with ATI cards. In this case, it is for a laptop to use both the internal and an attached external monitor. Or another found on the web:




Section "Device"
Identifier "Card0"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "Radeon X300"
BusID "PCI:1:0:0"
Screen 0
EndSection

Section "Device"
Identifier "Card1"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "Radeon X300"
BusID "PCI:1:0:0"
Screen 1
EndSection


Again, note the matching BusID and the different Screen numbers. Basically, this tells X that there are two screens, and, in a "Screen" section, you'll tell it which monitor is on which screen, thusly:




Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultColorDepth 16
SubSection "Display"
Depth 1
Modes "1024x768" "800x600" "640x480"
EndSubSection
EndSection

Section "Screen"
Identifier "Screen1"
Device "Card1"
Monitor "Monitor1"
DefaultColorDepth 16
SubSection "Display"
Depth 1
Modes "1024x768" "800x600" "640x480"
EndSubSection
EndSection


So I tried a million variations on this, and would either get the driver complaining about devices not being found ("no matching Device section for instance (BusID PCI:1:0:1)", mismatched devices or it would just go "poof", with no report, no display and a reset button press in my future. Round and round I went, often starting over using "X -configure" to generate me a new xorg.conf and trying to change one piece at a time to see exactly what was happening. Change a piece, type in "X -config xorg.conf.test", read /var/log/Xorg.0.log and try to decipher its nearly 1000 lines of technical jargon for some kind of help.



To work on this, I would boot into X, then type, from a root Konsole window, "shutdown now". This would drop me into single user text mode. From there I could edit the test config file, run X to see what it would do (of course, it was running a bare metal X, so nothing was really working), Ctrl-Alt-Backspace to kill the X server and try again. There was the added frustration that Ctrl-G (to cancel a command in emacs) would kill emacs and drop me back to the command shell. A command shell that was in some weird mode that didn't echo back any characters. I thought at first it was hung, but it was actually getting the characters, but Enter wasn't being recognized. I had to hit Ctrl-J to enter the (invisible) line. Oh, what fun I had! And to add to my frustration, PC-BSD intermittently hangs. sigh.



(BTW, a better method of doing this would be to use the alternate terminals in X. Ctrl-Alt-F7 puts you into tty6, in text mode. Edit the xorg.conf file, switch back to the X "terminal" with Ctrl-Alt-F9, and the reset the X driver with Ctrl-Alt-Backspace. This would give me a real KDE display, rather than the basic X of black and white crosshatch.)



After many hours of this, I felt like I was no closer, but by now I was determined to get to the bottom of it. I was certain, given the kinds of errors I was getting, that the Screen 0 and Screen 1 stuff wasn't for me. I eventually came to the conclusion it is for the dual head that uses the single VGA connector with the split, which makes sense, The BusID says which bus to talk to on the video card, and the screen number says which cable to talk to. But that wasn't my set up, and I was certain I needed to heed the warnings about "No matching Device section" and so I created two device sections, one for BusID "PCI:1:0:0" and one for "PCI:1:0:1". This would bring up X on both windows, but still they were clones of each and not two different displays.



So I reached deep into my Google-fu and I finally found this page: MergedFB on Freedesktop.org. I liked the idea of the Virtual command, but I wasn't exactly sure how he meant it to be used. But the Radeon man page linked from there was also a huge help, in explaining the options, explaining the arguments and telling me what they actually did. And it explained an incredibly important option - change the default setting of the "CRT2Position" option from "Clone" (sound familiar?) to be "RightOf". Now who in their sickest dreams would decide that the default setup for a two monitor computer should be where the two monitors are clones? How many people would actually want that? I wouldn't be surprised to learn but for want of that one option I could have been saved hours and hours of tweaking!



The other important option, as mentioned, is the Virtual one. This tells X how to layout your two screen desktops. It will only work with rectangular regions, unlike Windows which just abuts the two different rectangular screens, even if they are of different sizes. So I defined a Virtual area of (1280+1024)=2304 by 1028, so it abuts the LCD monitor to the left of the CRT (the LCD is always the CRT1 for the X850 card), with a desktop that scrolls from top to bottom (as the desktop is 1024 pixels vertically but the display is only 768). There's a small bit of "tear" from the mouse cursor when the desktop scrolls up and down, but it goes away immediately and thus isn't too bad.



I also had to play some games with the monitor refresh, as X insisted on setting the horizontal to slightly less than the LCD would handle, but luckily the monitor actually gave me a nice error message, saying the mode wasn't supported and showing me the mode that was being tried. I'm not sure why X thought that 59.9 was enough for a monitor that wanted 60!



I also played with the Xinerama mode, which is slightly different than the MergedFB mode. But it won't do the irregular layout of my two displays, and instead finds the highest common denominator, in this case 1024x768. It is, however, nice that the task bar goes across both monitors and it really acts like a big 2048x786 screen. MergedFB is more like Windows, in that there are two displays and many things when asked to be put in the center, will go in the center of Screen 0. In Xinerama, it will really just go in the middle of both screens! Oh, and another option I set was "MergedXineramaCRT2IsScreen0", as CRT2 is my CRT, which is right in front of me (and Display 1 for Windows), while without this option, centered dialogs (like the login dialog for X) show up on my little LCD monitor.



So that's my X window story. I would really hate to think of just how long I banged my head on the keyboard working at this. Most of Friday night, on and off through most of Saturday, until late Saturday night I finally got it working correctly. I really think that had the "CRT2Position" option defaulted to the more expected "RightOf" or "LeftOf"(you can even do "Above" or "Below"!), I may have figured it out a few hours before. Because when you don't know what you are doing, you change lots of things, but without that option, it never looked right. And nearly everything on the web (including the few bits of help I found on the PC-BSD forums) talked about setting Screen 0 and Screen 1, which just isn't right for my card.



So, here's my complete xorg.conf file. I'm not sure what other tweaks I made. Some options can be put in the "Device" section or the "Screen" section, but I could never figure out which. I mean, what exactly does this mean (from the xorg.conf(5) man page):



Note that most of the Options listed here (but not the other entries) may be specified in the Screen section instead of here in the Device section.


Speaking some other language than English, I think! So I made sure AGP was turned on and tweaked a few other performance options. Rereading the Radeon man page just now, I noticed the "MergedNonRectangular" option, which would exactly match my Windows setup. I'll have to think about whether I want to use it or not, although I am not a big fan of scrolling desktops.




Section "ServerLayout"
Identifier "ATI Dual Monitor"
Screen "Screen0" 0 0
Screen "Screen1" RightOf "Screen0"
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
# Option "Xinerama" "True"
EndSection

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
ModulePath "/usr/X11R6/lib/modules"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/TTF/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/CID/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
EndSection

Section "Module"
Load "extmod"
Load "glx"
Load "dri"
Load "dbe"
Load "record"
Load "xtrap"
Load "type1"
Load "freetype"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/sysmouse"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
#DisplaySize 280 210 # mm
Identifier "LCD-Mon"
VendorName "PTS"
ModelName "PZ456"
### Comment all HorizSync and VertSync values to use DDC:
# HorizSync 30.0 - 60.0
VertRefresh 61.0 - 75.0
Option "DPMS"
EndSection

Section "Monitor"
#DisplaySize 350 260 # mm
Identifier "CRT-Mon"
VendorName "SAM"
ModelName "SyncMaster"
### Comment all HorizSync and VertSync values to use DDC:
HorizSync 30.0 - 96.0
VertRefresh 50.0 - 160.0
Option "DPMS"
EndSection

Section "Device"
Identifier "ATI Port 1"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "R480 [Radeon X850Pro]"
BusID "PCI:1:0:0"

# MergedFB options
Option "MergedFB" "True"
Option "EnablePageFlip" "True"
Option "AGPMode" "4"
Option "AGPFastWrite" "True"
Option "MergedXineramaCRT2IsScreen0" "True"
Option "CRT2Position" "RightOf"
EndSection

Section "Device"
Identifier "ATI Port 2"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "R480 [Radeon X850Pro]"
BusID "PCI:1:0:1"
EndSection

Section "Screen"
Identifier "Screen0"
Device "ATI Port 1"
Monitor "LCD-Mon"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1024x768" "800x600"
Virtual 2304 1024
EndSubSection
EndSection

Section "Screen"
Identifier "Screen1"
Device "ATI Port 2"
Monitor "CRT-Mon"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024" "1024x768" "800x600"
EndSubSection
EndSection





2 comments:

  1. Glad I could be of some help! I actually haven't been running this config, as it tends to hang my system after a bit (anywhere from 10 minutes to an hour, so not very long). I've received a few other pointers and hope to try it again this weekend. I'd be real curious to know if you can get your x800 to work using this setup. I'm wondering if one of my problems is the fact the two monitors operate at different sizes.

    ReplyDelete
  2. I'm actually having issues right now. I got too "jonesy" and started trying to run X this way without updating my system... I don't know if that has anything to do with my issue but it might.
    The problem is that whenever I start X the system just hangs. I ran X -configure as root and used the new xorg.conf.new as the config and it did the same thing so it's not the fancy config we have going on for dual-head... It must be something else.
    I'll try the xorg.conf.new and the dual-head version after my system updates.
    I'll let you know how it goes. Also, let me know about the tweaks you plan to make and I'll see what they do for me as well.
    Jeff

    ReplyDelete