Monday 2 August 2010

Add support in Ubuntu Lucid for 1680x1050 displays

I said it would be a "few days" until I posted this; four weeks later, all I'm going to say in my own defense is that I didn't say how few days.

In my previous post, I noted that I had had some initial difficulty in configuring my primary display widescreen LCD monitor. My new Lucid install started with an initial resolution of 1365x768. Since the native resolution my monitor is 1680x1050, naturally this looked both stretched and blurry.

The original solution to this problem was to edit Xorg.conf, the main configuration file for the X Window System, the software that provides the GUI for UNIX and UNIX-like operating systems. However, after Jaunty, Canonical has changed the way Ubuntu configures X: either Xorg.conf is gone, or it's been buried so deeply that even Indiana Jones couldn't dig it up. After a little googling, though, I found a workable solution, which I hope is helpful to others as well.

CAUTION: This solution requires the use of a terminal window. This might seem like a daunting proposition to someone whose computer experience is largely limited to 1995 or after. But keep in mind that prior to Windows 95, you pretty much had to work off the command line for something. Plus, for certain kinds of tasks, the command line can be faster and more powerful. It's always worth your effort to familiarize yourself with the terminal.

I use the GNOME desktop environment, so I start start a terminal window by choosing Applications > Accessories > Terminal.

To add 1680x1050 support to X

This procedure uses the Xrandr utility to add a new video mode to your system. Xrandr (which stands for "X Resize and Rotate") is a command-line utility for setting the size and orientation of an X Window output. It's capable of all sorts of interesting things, most of which I don't understand, but for our purposes here we're simply interested in its ability to create a new, usable resolution for your default monitor. (Note also that while in X, a technical distinction is made between, say, a monitor, screen, or display. I am using these terms informally and interchangeably, meaning the display hardware connected to your PC and the image shown upon it.)

  1. In the terminal window, type: xrandr

    This command will display some information about your screen configuration, such as:

    Screen 0: minimum 320 x 200, current 1024 x 768, maximum 4096 x 4096
    VGA-0 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
       1360x768       59.8  
       1024x768       60.0* 
       800x600        60.3     56.2  
       848x480        60.0  
       640x480        59.9     59.9  
    DVI-0 disconnected (normal left inverted right x axis y axis)
    S-video disconnected (normal left inverted right x axis y axis)
    

    VGA-0 is the default VGA display on my PC: what this says is that this video adapter is capable of displaying images as small as 320x200 (which I don't think I used even back in 1991!) or as large as 4096x4096, it is currently (for the purposes of this demonstration) set to 1024x768, and it is capable of a number of different resolutions and aspect ratios - none of which is the one I want.

  2. We want to add a video mode to this list, so now type this at the command prompt: cvt 1680 1050

    cvt stands for Coordinated Video Timing. This command calculates a new "mode line," which is a line of code to configure X to display an image at a specific resolution. It outputs something like the following:

    # 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
    Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
    
  3. For instant gratification, we can add this new mode to the server now, by using Xrandr and the new modeline we just generated, like this:

    xrandr --newmode "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync

    The part in quotation marks ("1680x1050_60.00" in my case) is a name for the new mode, which we'll be using again.

  4. Now, associate this mode with the correct output device (in my case, VGA-0):

    xrandr --addmode VGA-0 1680x1050_60.00

  5. Finally, tell the server to display this new mode:

    xrandr --output VGA-0 --mode 1680x1050

    Congratulations! X can now produce output at the native resolution of your monitor. If you open the Monitor Preferences application (System > Preferences > Monitor), you should be able to find this mode in the Resolution drop-down list.

    However, this is only a temporary solution. It will disappear the next time you have to reboot. To make the change persistent, we have to add the above three Xrandr commands to the default initialization script for GDM (the GNOME Display Manager).

  6. Type the following:

    sudo gedit /etc/gdm/Init/Default

    Since this is a system file, we have to use the sudo command to edit it as a superuser, and the system will ask for your password before proceeding. If you prefer another text editor to gedit, just substitute the appropriate name, but keep the location of the Default file the same.

    In the text editor, find the two lines that read:

    PATH="/usr/bin:$PATH"
    OLD_IFS=$IFS
    

    Underneath them, add the above three Xrandr commands (your own version, of course), in the same order. Save the file and exit the editor. Now, a 1680x1050 mode is available every time you start X.

On the downside, this feels like a jury-rigged solution compared to the old way of just adding the modeline to the Xorg.conf file. X isn't permanently configured with this mode; it's just fixed every time the computer starts. It makes me wonder whether it's a contributing factor to my current inability to watch full-motion video smoothly on this system.

To give credit where due, I adapted this solution from this thread on the Ubuntu Forums. Your mileage may vary, so if you try my instructions and have no luck, some of the other posts in the thread might be helpful to you. For my part, it worked on the first try with no further problems.

No comments:

Post a Comment