Monday, 30 December 2013

Ubuntu resolution problem

(or never overlook the obvious)

The problem

Over the years I have mainly used Windows based PCs but have also dabbled with Linux based systems.  I have tried a few different Linux distributions but have settled on Ubuntu as my distribution of choice. 

There was one problem that I was never able to resolve, that was really bugging me. When I connected my Linux box to a monitor via the VGA connector I could never set a usable resolution. My pair of Dell 22" run at a native 1920 x 1080 but I was lucky if I could get it working at 1024 x 768 which is also a 4:3 aspect ratio rather than the native resolutions 16:9 making squares look like rectangles and circles look squashed.

If I connected the PC via a digital connection such as a DVI or HDMI cable the resolution was always correctly selected. The left hand green monitor is connected with a DVI cable and the right hand yellow monitor is connected by a VGA cable. This was going to be a problem as I was planning on setting up a Linux Ubuntu PC as a replacement for an ageing Windows XP PC for a friend that is the wrong side of 70, who only had a VGA monitor.

The non solution

The graphics card in the PC that I had Ubuntu loaded on to it had Nvidia chipset loaded on to it. Researching the problem on the internet it seemed that the Nvidia drivers could be an issue, so I tried many different variations of driver from the Nvidia stable as well as the Ubuntu Nouveau drivers. There were also articles stating that you could insert custom resolutions into an xorg file. On several occasions I broke my Linux installation to such an extent I had to reinstall it. 

Now I am not too bad when it comes to PC use (usually Windows), but the problem I have found with Linux in general, is that if you want to do anything more than basic things you need to have a reasonable knowledge of the Linux operating system, but you can't get that reasonable knowledge because you can't do anything but the basics. A bit of a Catch 22 situation. So playing around with xorg and drivers can seem a bit daunting and very frustrating.

In Windows you have the option of choosing the resolution and refresh rate that you want to run the monitor at. It is up to you to apply the correct settings. With Ubuntu, and probably other Linux distributions, the operating system tries to determine the correct resolution so as not to apply a resolution that could potentially damage the monitor.

After many attempts at getting a usable resolution on VGA I was frustrated and resigned my self to just being able to connect via DVI.

The real solution

My pivotal moment was when I realised that my Sons dual monitor Ubuntu setup was using DVI and VGA connections just like mine, but he was using the correct resolutions on both monitors. In my defence he is away at university most of the year and I thought both monitors were connected via DVI.

With this small piece of information I started investigating my resolution problem with renewed vigour knowing that it was possible to run a VGA monitor in Ubuntu at the correct resolution.

So where does the problem lie? Well what you have to understand first is my PC setup. I don't just have an Ubuntu PC, I have two PCs at my desk. My main PC (at the moment) is a Windows 8 machine that sits in the cupboard to my left, and an Ubuntu box at my feet. I have twin 22" Dell monitors that each have a DVI and VGA input. The Windows box runs on a single graphics card that has a a VGA and DVI output. Therefore one monitor is connected to the Windows box via VGA and the other via DVI. This means that there is a spare input into each monitor, these are therefore available for the Ubuntu box at my feet. When I want to use the Ubuntu box I just switch the input on the monitor. Before fixing the problem I connected the Ubuntu box to a monitor using just the DVI cable and therefore using just one monitor rather than the twin monitor set-up that the Windows PC has.

The monitor on the right is the one that is connected to the Ubuntu box via VGA and was the one that I could never set to the correct resolution. To try and keep the cables relatively tidy they are cable tied and routed in a way that means that I don't catch them with my feet. This meant that the VGA cable that was supplied with the monitor would not reach the Ubuntu box at my feet.

A cable that is not long enough is not a problem as there are many solutions, I could have bought a longer cable or I could use an extension cable. Well I had a good quality VGA extension cable made by Belkin which is what I had used for quite a while and had served me well when I was working on Windows PCs.

It had a nice thick cable, was a reasonable length, it even had gold plated connectors what more could I want?

Well it seems that I need just a little bit more. A good resource on VGA pin outs is the Wikipedia VGA page  It would seem that my high quality Belkin VGA extension cable does not have all of the pins connected. Pin 9 is missing completely from one end but this seems to be a +5v power feed and does not have any affect in my set up. More importantly pins 12 and 15 are not connected through. Pins 12 and 15 appear to be involved with an I2C bus between the monitor and graphics card that is used to identify the monitor to the graphics card so that the monitor know what the monitors supported resolutions are. Eureka! 

To prove the theory I plugged the monitor VGA port directly in to the graphics card without the extension lead. Success I could now choose the correct resolution for the monitor

So now I had to locate a VGA extension cable that had all of the pins connected. This was not as difficult as I thought it would be, however you have to be careful, you can't go by price, brand, size of cable or whether any part of it is made of gold. It needs to explicitly state that all pins are connected in the description. In the end I opted for a very expensive (not) lead from an Amazon seller for about £3.

The cable is thinner than the Belkin, shorter than the Belkin, has less gold than the Belkin but it enables me to run my VGA monitor at its correct resolution. Result!

So the lesson learnt here is to never overlook the obvious. This cable worked perfectly under Windows where I was able to select the correct resolution, but not under Ubuntu which was trying to query the monitor over the non-existent I2C bus. 

So I have a twin monitor Ubuntu set-up but more importantly my 70+ year old family friend now has a fresh PC running Ubuntu, instead of her old XP set-up.