Подключение двух мониторов (Dual head)

     If you haven't tried to put together a working XFree86 4.0.x setup, it can be quite an effort. Distributions have been slow to create packages and drivers are evolving faster than releases. Combine this with the fact that DRI drivers typically require a kernel module that must be specifically compiled for your kernel and the process gets even more involved.

     With Matrox cards, there is a further consideration. XFree86 comes with DRI enabled drivers in XFree86 4.0.1 that work with all Matrox cards prior to the G450 (DRI only on the G200/G400). However, recently Matrox released a driver on their own site for the G200/G400/G450 with support for Dual Head and more advanced 3D acceleration. Further, there's the DRI CVS tree, which has been rolling the Matrox changes back into their code which supports previous Matrox cards as well.

     Why worry about those older cards? Some users would like to use their older Millennium IIs to drive a third monitor, with a G4x0 driving the other two. An experienced Linux user would immediately consider using the Matrox drivers with the G4x0 and the XFree86 drivers with the Millennium II, but this isn't possible as the two drivers share the same name and symbols. Hacks exist to rewrite all the exported symbols, but we have yet to verify whether or not they work.

     So where do you start? This test focuses on XFree86 4.0.1, compiled locally on the test machine, combined with the drivers from Matrox's site. Since the test machine runs Red Hat 6.2, agpgart was already installed. For those of you new to this, agpgart is the kernel AGP/GART interface module. It is required for most DRI modules and requires patching your kernel if you have a 2.2.x kernel, or using 2.3.51 or higher, which come with the module included. Note that you only need agpgart and mga kernel modules if you plan on using direct rendered OpenGL. After quite a while compiling (XFree86 is huge), it was ready to go.

     The first problem was that the second display could only achieve 60Hz on at 1280x1024 which, to me, is unacceptable. Apparently, the Matrox drivers hard code the speed of the secondary RAMDAC to 112MHz. After changing the guilty line of code, line 1901 of mga_driver.c, to 200000 (for 200MHz, the secondary RAMDAC speed of the G450), the secondary display came up at 75Hz. Why this would be fixed at compile time is beyond us.

     Dual Head setup is relatively simple once you've seen it, but at first it can be quite intimidating. Here's an excerpt from our test XF86Config:

    Section "Device"
      Identifier  "G450-1"
      Driver      "mga"
      BusID       "PCI:1:0:0"
      Screen      0
    EndSection

    Section "Device"
      Identifier  "G450-2"
      Driver      "mga"
      BusID       "PCI:1:0:0"
      Screen      1
    EndSection

    Section "Screen"
      Identifier    "Screen 1"
      Device        "G450-1"
      Monitor       "Sun"
      DefaultDepth  16

      SubSection "Display"
        Depth       16
        Modes       "1280x1024" "1024x768" "800x600" "640x480"
      EndSubSection
    EndSection

    Section "Screen"
      Identifier    "Screen 2"
      Device        "G450-2"
      Monitor       "ViewMate"
      DefaultDepth  16

      SubSection "Display"
        Depth       16
        Modes       "1280x1024" "1024x768" "800x600" "640x480"
      EndSubSection
    EndSection

    Section "ServerLayout"
      Identifier    "DualHead"
      Screen        "Screen 1" LeftOf "Screen 2"
      Screen        "Screen 2"
      Option        "Xinerama"
    EndSection