Dual Head on Ubuntu Hardy with Intel GM965 (Part 1)

Yesterday I got a LCD monitor that I plugged in to the docking station of my Dell D830. Using cloned mode where both the laptop display and the external monitor display the same, worked right away. But I wanted to use extended mode so that I can have a bigger workspace. Here’s how I got it to work.

I tried to change it through the Monitor Resolution Settings dialog (System/Preferences/Screen Resolution), but it didn’t work.

There are several places on the web that explain how you can set this up, but none of them really works with Compiz. Then I found a bug report that contained the solution: The driver for i965 has a bug that limits the screen size to 2048×2048.

Here is what I did:

1. Patching

$ apt-get source xserver-xorg-video-intel
$ cd xserver-xorg-video-intel-2.2.1

Then I changed the file src/i965_render.c and applied the following patch:

The diff for this file is

- if ((w > 0x7ff) || (h > 0x7ff))
+ if ((w > 8192) || (h > 8192))

This enables support for larger resolutions (8192×8192).

Then I edited the file debian/changelog and added a new entry with a new version number (I choose 2:2.2.1-1ubuntu13.6-1) at the top of the file (so that apt knows the package I’m going to create is newer than the currently installed package, otherwise it might decide to reinstall the unpatched version from the official repository). I built the package:

$ dpkg-buildpackage -rfakeroot -uc -b

and installed it:

$ sudo dpkg -i ../xserver-xorg-video-intel_2.2.1-1ubuntu13.6-1_amd64.deb

In addition the Mesa driver also needs to be modified:

$ cd ..
$ apt-get source mesa
$ cd mesa-7.0.3-rc2

I patched the file src/mesa/drivers/dri/i965/brw_context.c with the following patch (also taken from the bug report):

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_c!
index 1601f6d..c06f5da 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -138,10 +138,10 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
/* Advertise the full hardware capabilities. The new memory
* manager should cope much better with overload situations:
- ctx->Const.MaxTextureLevels = 12;
+ ctx->Const.MaxTextureLevels = 13;
ctx->Const.Max3DTextureLevels = 9;
ctx->Const.MaxCubeTextureLevels = 12;
- ctx->Const.MaxTextureRectSize = (1<<11);
+ ctx->Const.MaxTextureRectSize = (1<<12);
ctx->Const.MaxTextureUnits = BRW_MAX_TEX_UNIT;

/* ctx->Const.MaxNativeVertexProgramTemps = 32; */

Again I edited the file debian/changelog and built the package:

$ dpkg-buildpackage -rfakeroot -uc -b

I installed only those packages that I already had installed. To verify that larger resolutions are possible now I did a

$ glxinfo -l | grep GL_MAX_TEXTURE_SIZE

which gave me


The 4096 is a general limit in Mesa, but it is enough to run my external LCD monitor and my laptop screen with 1680×1050 each.

Changing Settings

I also had to modify my xorg.conf: in the section “Screen” I added a new subsection “Display”:

SubSection "Display"
Virtual 4096 4096

After that I tried to get the expanded mode to work – no success. However, this morning after having rebooted it suddenly worked:

Doing a xrandr displays the names of the output ports and the possible screen resolutions. Then I did a

$ xrandr --output TMDS-1 --left-of LVDS

and it worked!


22 thoughts on “Dual Head on Ubuntu Hardy with Intel GM965 (Part 1)

  1. Here is my xorg.conf:

    Section "InputDevice"
    Identifier "Generic Keyboard"
    Driver "kbd"
    Option "XkbRules" "xorg"
    Option "XkbModel" "pc105"
    Option "XkbLayout" "us"

    Section "InputDevice"
    Identifier "Configured Mouse"
    Driver "vmmouse"

    Section "InputDevice"
    Identifier "Synaptics Touchpad"
    Driver "synaptics"
    Option "SendCoreEvents" "true"
    Option "Device" "/dev/psaux"
    Option "Protocol" "auto-dev"
    Option "HorizEdgeScroll" "0"

    Section "Device"
    Identifier "Configured Video Device"

    Section "Monitor"
    Identifier "LVDS"

    Section "Monitor"
    Identifier "Samsung"
    Option "LeftOf" "LVDS"

    Section "Screen"
    Identifier "Default Screen"
    Monitor "LVDS"
    Device "Configured Video Device"
    SubSection "Display"
    Depth 24
    Virtual 3360 1536

    Section "ServerLayout"
    Identifier "Default Layout"
    Screen "Default Screen"
    InputDevice "Synaptics Touchpad"

  2. Hi. I’m really new to ubuntu and also trying to make my dual head work. I was able to follow until the rebuilding of package. dpkg-buildpackage -rfakeroot -uc -b gave me:

    dpkg-checkbuilddeps: Unmet build dependencies: debhelper (>= 5) quilt xserver-xorg-dev (>= 2:1.4.1~git20080131-1ubuntu4) x11proto-gl-dev x11proto-video-dev libgl1-mesa-dev | libgl-dev libxvmc-dev (>= 1:1.0.1-1) x11proto-core-dev x11proto-fonts-dev x11proto-randr-dev (>= 1.2) x11proto-render-dev x11proto-xinerama-dev libdrm-dev (>= 2.2) x11proto-xf86dri-dev
    dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
    dpkg-buildpackage: warning: (Use -d flag to override.)

    Little help would be much appreciated 🙂

  3. |Again I edited the file debian/changelog and built the package:
    | $ dpkg-buildpackage -rfakeroot -uc -b
    |I installed only those packages that I already had installed….

    How do I know those packages that were installed?


  4. @zkiard: Looks like you figured it out yourself. Great!

    In case anyone else is wondering about the answers to those questions:

    If you get an error about unmet build dependencies you have to install the packages it’s complaining about:
    sudo apt-get install debhelper quilt etc.

    The dpkg-buildpackage command creates one or more *.deb files. To check if any of these are installed, you can do a

    dpkg -l

    e.g. for the package mesa-swx11-source_7.0.3~rc2-1ubuntu4-1_all.deb you can do a

    dpkg -l mesa-swx11-source

    This gives the output:
    | Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
    |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
    ||/ Name Version Description
    pn mesa-swx11-sou (no description available)

    The second character in the last line tells you the status; an i means it is installed.

  5. Thanks! Another problem I encountered before was setting virtual to 4096 4096. It still seems it can’t handle it but lowering it a little bit (like what your xorg.conf looks like – 3360 1536 – work!). xrandr now shows:
    $ xrandr
    Screen 0: minimum 320 x 200, current 2560 x 1024, maximum 3360 x 1536
    VGA connected 1280×1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
    1280×1024 60.0*+ 75.0 59.9
    1152×864 74.8
    1024×768 75.1 60.0
    800×600 75.0 60.3
    640×480 75.0 60.0
    720×400 70.1
    LVDS connected 1280×800+1280+224 (normal left inverted right x axis y axis) 0mm x 0mm
    1280×800 57.7*+ 60.0
    1280×768 60.0
    1152×768 54.8
    1024×768 85.0 75.0 70.1 60.0
    832×624 74.6
    800×600 85.1 72.2 75.0 60.3 56.2
    640×480 85.0 72.8 75.0 59.9
    720×400 85.0
    640×400 85.1
    640×350 85.1
    TV disconnected (normal left inverted right x axis y axis)

    Also, the screen resolution tool now works perfectly though Compiz sometimes needs to be restarted when plugging a new monitor.

    Awesome blog dude. Share some more stuff. Thanks!

  6. Hi. I’m trying to do the same thing. I have an intel GM965 with Ubuntu 8.04. My laptop can do 1280×1024 and my 19″ lcd can do 1440×900. I followed the steps up to editing the file from the intel driver. I cannot find a debian/changelog file on my pc though?? Also, when I try to build the package, I get an error saying that the debian/changelog file cannot be read. Can anyone please help me with this?

    Thank you very much

  7. The first step: apt-get source xserver-xorg-video-intel
    creates a subdirectory xserver-xorg-video-intel-2.4.1
    Inside of that you should find a subdirectory debian with a file changelog.

  8. hi eb.what lines (repositories) do i need to add to my sources.list to be able to download the source for the package?i use a local campus repository and the xserver source doesn’t appear to be there.

  9. I’ll tell you what I did. I added the following:

    deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ hardy multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
    deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
    deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse

    Do you know how to fix this?

    W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/multiverse/binary-i386/Packages.bz2 Hash Sum mismatch

    W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/hardy-updates/multiverse/source/Sources.bz2 Hash Sum mismatch

    E: Some index files failed to download, they have been ignored, or old ones used instead.

    I’ve tried to get the source files without including the two hardy-updates lines,but I get an error saying that no source files was found. So maybe the hardy-updates repository contains the source files that I need?

  10. Hi

    I managed to get dualscreen to work (mind you I took my Samsung 19” widescreen back two times because of dead pixels and finally got an acer one). I just added the driver “intel”, identifier “intel” and virtual parts to xorg.conf. Both outputs work now with xrandr if i say:

    xrandr –output VGA –auto and
    xrandr –output VGA –right-of LVDS

    I just want to know if I can make LVDS my default screen because the taskbar and panel ends up on VGA. Also, if I open up a new window, it pops up on VGA. How can I change this to make it my laptop screen?


  11. Sorry, can’t help on this. On my machine LVDS comes up as the default screen. But I remember that I tried changing the default screen before on a different machine with a different graphics card and couldn’t get it to work (or didn’t spend enough time to get it to work 🙂

  12. Thanks! This worked perfectly for me on intrepid. I only had to patch mesa however, the intel driver patch was already applied.

    With regard to the panel position, you can try the following (I’ve yet to test this as I’m not connected to my external monitor).

    gconftool -s /apps/panel/toplevels/top_panel_screen0/screen 1
    gconftool -s /apps/panel/toplevels/bottom_panel_screen0/screen 1

    This will move the top/bottom panels to the 1st screen (which should be the LCD screen). If you have other panels, run gconf-editor and look in apps->panel->toplevel to see what the panel names are. These commands could be run as part of a script that enables/disables the external monitor.

  13. I’ve now had a chance to test this. The following will switch to Dual monitors, and move the panel to the LCD:

    xrandr –output LVDS –auto –output VGA –auto –right-of LVDS
    gconftool -s /apps/panel/toplevels/top_panel_screen0/monitor 1 -t int
    gconftool -s /apps/panel/toplevels/bottom_panel_screen0/monitor 1 -t int

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s