Sunday, September 16, 2012

Reading monitor supported resolutions...

I was browsing David Underhill's blog and this post caught my attention. Namely, in that post he explains how he had problem with a newly bought monitor that different operating systems he has set to a wrong resolution. But, the interesting thing is that there are tools in both Linux and Windows that allow you to query monitor information. The tools on Fedora are monitor-get-edid, monitor-parse-edid, and monitor-edid, all part of monitor-edid package and all written in perl. So, this is what I get running those tools on my W510:
$ monitor-get-edid | monitor-parse-edid
EISA ID: LEN40b1
EDID version: 1.3
EDID extension blocks: 0
Screen size: 34.4 cm x 19.3 cm (15.53 inches, aspect ratio 16/9 = 1.78)
Gamma: 2.2
Digital signal

    # Monitor preferred modeline (60.2 Hz vsync, 54.9 kHz hsync, ratio 16/9, 118 dpi)
    ModeLine "1600x900" 106 1600 1664 1706 1930 900 903 906 912 -hsync -vsync

    # Monitor supported modeline (50.0 Hz vsync, 45.6 kHz hsync, ratio 16/9, 118 dpi)
    ModeLine "1600x900" 106 1600 1664 1706 2324 900 903 906 912 -hsync -vsync
As it can be seen, monitor-get-edid obtains EDID information and dumps it on standard output while monitor-parse-edid reads data from standard input and produces formatted output on standard output.

Modelines produced are used to tell X server how to configure and control monitor. These were used to be defined in /etc/X11/Xorg.conf (or before that in /etc/X11/XF86Config before that). In those days the whole ingenuity of setting up graphical interface was to guess those modeline lines. Modern X Server do that automatically, so in majority of cases users don't see those. But, sometimes things don't work as expected and they have to get their hands dirty.

Ok, I tried this tool on W500, too. This is what I got:
# monitor-edid
mmap /dev/mem: Permission denied
EISA ID: IBM2887
EDID version: 1.3
EDID extension blocks: 0
Screen size: 33.1 cm x 20.7 cm (15.37 inches, aspect ratio 16/10 = 1.60)
Gamma: 2.2
Digital signal

    # Monitor preferred modeline (60.0 Hz vsync, 63.9 kHz hsync, ratio 16/10, 128 dpi)
    ModeLine "1680x1050" 120.6 1680 1712 1760 1888 1050 1051 1054 1065 -hsync -vsync

    # Monitor supported modeline (50.0 Hz vsync, 53.2 kHz hsync, ratio 16/10, 128 dpi)
    ModeLine "1680x1050" 100.53 1680 1712 1760 1888 1050 1051 1054 1065 -hsync -vsync
Note that command monitor-edid reads and parses data in one go, so it is not necessary to separately specify those commands.

I was curious so I also run those tools inside VMWare Workstation but I didn't get enything useful.

The way this information is obtained from monitor is by using I2C interface and EDID data structure. This structure can be read even if the monitor itself is turned off.

Additionally, the information about monitor can also be obtained using xrandr tool. Here is what I get on W510:
$ xrandr
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 8192 x 8192
LVDS-1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1600x900       60.2*+   50.0 
   1152x864       60.0 
   1024x768       59.9 
   800x600        59.9 
   640x480        59.4 
   720x400        59.6 
   640x400        60.0 
   640x350        59.8 
VGA-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
What can be seen is that currently used monitor is attached to LVDS-1 (which is laptop's integrated LCD) and that it is running with the resolution 1600x9000 and 60.2Hz refresh rate. Also are listed other supported modes. Finally, all the other connectors don't have anything connected to them.

Again, output from W510 is:
# xrandr
Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 8192 x 8192
LVDS2 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
   1680x1050      60.0*+   60.0     59.9     50.0
   1400x1050      60.0     59.9
   1280x1024      60.0
   1440x900       59.9     59.9
   1280x960       60.0
   1360x768       60.0
   1280x800       59.8     59.9
   1280x768       59.9     60.0
   1024x768       60.0
   800x600        60.3     56.2
   848x480        60.0
   640x480        59.9
VGA2 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
xrandr by itself is very interesting and capable tool. For example, once it happened to me that I started a game that uses SDL which switched to a lower resolution while in full screen mode. Well, the problem was that the application didn't end regularly, but it crashed and left me with unusable resolution. I used xrandr to set correct resolution. This was the command line I used:
xrandr --output LVDS-1 --auto
Note the argument of output option. It is the one reported by xrandr without any arguments.

No comments:

About Me

scientist, consultant, security specialist, networking guy, system administrator, philosopher ;)

Blog Archive