5

There is a Flatron E2042 in the office I work in and it's having the worst [firmware] problem I've ever seen in a display: it can't always work in full resolution.

Today is the day when it worked and I'd like to get the modeline for the correct resolution. It's not in Xorg.0.log and gtf/cvt are for calculating a modeline. AFAIU xrandr --verbose is showing all the needed numbers but rearranged and not readily available for later use in --newmode. And xvidtune -show lists only the internal display with nothing in the manual about selecting another one.

So, any other way to get the current modeline?

Update:

Script that I now use to make it work:

#!/bin/bash
modeline="flatron_e2042 108.00 1600 1624 1704 1800 900 901 904 1000 +hsync +vsync"
xrandr --newmode $modeline
modename="$(echo ${modeline%% *})"
xrandr --addmode VGA1 $modename
xrandr --output VGA1 --mode $modename
int_ua
  • 8,912

4 Answers4

4

Try with xvidtune:

xvidtune -show
  • Why did this answer get accepted? It only shows the internal display (as mentioned in the question), and it's also what I'm looking for. – Thomas Feb 14 '21 at 14:10
  • What happens when you switch off the internal display and have only external one switched on? – int_ua Feb 15 '21 at 00:11
3

parse-edid is obsolete. Just use xrandr, it has all the information.

You can reformat xrandr output to a modeline using e.g. a Perl script like this

#!/usr/bin/perl

use strict; use warnings;

my ($dp, $width, $height, $opts, $current, $clock, $sync, $hpart, $vpart, $refresh); my $preferred = ""; sub flush() { print " Option "PreferredMode" "$preferred"\n" if ($preferred); print "EndSection\n" if ($dp); $preferred = ""; $dp = ""; }

open(my $F, "xrandr --verbose |") or die $!;

while(<$F>) { chomp; if (/^(\S+) (\S+)/) { flush(); $dp = $2 eq "connected" && $1; next unless $dp; print "Section &quot;Monitor&quot;\n"; print " Identifier &quot;$dp&quot;\n"; next; } next unless $dp; if (/^\s+(\d+)x(\d+)\s+\S\s+(\d+.?\d)\S+\s+([-+]HSync\s+[-+]VSync)\s(.)/i) { $width = $1; $height = $2; $clock = $3; $sync = lc $4; $opts = $5; $current = $opts =~ /current/; if ($opts !~ /preferred/) { flush(); next; } } if (/^\s+h: width\s+(\d+)\s+start\s+(\d+)\s+end\s+(\d+)\s+total\s+(\d+)/) { $hpart = "$1 $2 $3 $4"; } if (/^\s+v: height\s+(\d+)\s+start\s+(\d+)\s+end\s+(\d+)\s+total\s+(\d+).*?\bclock\s+(\d+)/) { $vpart = "$1 $2 $3 $4"; $refresh = $5; my $mode = "${width}x${height}_${refresh}"; print " Modeline &quot;$mode&quot; $clock $hpart $vpart $sync ($width x $height @ $refresh)\n"; if ($current) { $preferred = $mode; } } } flush(); close($F);

rustyx
  • 1,106
3

Not exactly the modeline, but you can download the monitor's EDID information where all supported resolutions are listed. I would use get-edid and parse-edid tools from read-edid package (http://manpages.ubuntu.com/manpages/oneiric/man1/get-edid.1.html). Then try to use the EDID information when starting X instead of asking the monitor for that information every time.

I know that nvidia driver has very good support for custom EDID file. I am not sure how it is supported in other drivers. I am sure you will figure it out.

Commands:

sudo get-edid > ~/lg_edid
parse-edid < ~/lg_edid
int_ua
  • 8,912
nobody
  • 4,420
1

The accepted answer claims that to get the current ModeLine one should use 'xvidtune' tool. Unfortunately, this program is showing the ModeLine that X server was started with but not the current one. Just try to change resolution (either using 'xrandr' or your window manager monitor controlling tool) and then run 'xvidtune -show' again and you'll see what I'm talking about. Probably, a better way to get current ModeLine is using 'xrandr' tool itself like this:

$ xrandr --verbose

For example, in my case the result is something like this (the only lines with the current ModeLine):

1920x1080 (0x251) 148.500MHz +HSync +VSync *current h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz

As you can see, the current ModeLine is designated by the '*current' mark. In case of using more than one monitor, one would probably need to look for the apropriate section in xrandr's output marked with the output's name to which the monitor in question is connected (something like HDMI-0, DVI-D-0, VGA-0, etc).

folivore
  • 161
  • 2
  • 6
  • Thank you, I've reverted the change of the accepted answer – int_ua Mar 03 '21 at 10:47
  • Actually, I don't see how the accepted answer fits your original question. You asked how to get current ModeLine for an external display. Looking at the EDID of the monitor does not answer what the effective current display mode is. Although a correct EDID does clearly answer what the desired resolution of the monitor is, the correct way to get the effective ModeLine is by directly querying the X's extension that's responsible for controlling display resolution and frequency. And this extension is called RANDR, hence 'xrandr' is a way to go about it. IMHO. – folivore Mar 08 '21 at 17:08
  • As mentioned in the question, xrandr --verbose didn't work for me at the time, was it changed? parse-edid was the only thing that worked in that particular case. – int_ua Mar 08 '21 at 21:10
  • Looking at the EDID info doesn't show the current display mode, it shows the table of approved monitor modes by the monitor's manufacturer, stored inside the monitor's EEPROM (internal memory, accessible using I2C bus). EDID is a static block of data, it is not changed no matter what the current display mode is.

    xvidtune uses XFree86-VidModeExtension, but it reports erroneous result as I've already mentioned before.

    – folivore Mar 12 '21 at 15:06
  • Let me stress it once again: your question is "How to get current Modeline for an external display?". But EDID answers another question "How to get all the display modes that my monitor's manufacturer deems as safely operable for this monitor". In no way looking at the EDID answers what the current monitor's modeline is. – folivore Mar 12 '21 at 15:22
  • I don't remember how it looked and cannot test right now but it looks like the required modeline must've been amongst the list of all possible modelines from EDID. And xrandr --verbose did not provide a working modeline at the time. Does it now? – int_ua Mar 12 '21 at 15:28
  • Yes, the EDID block may have the native resolution info of its monitor (or the correct one using your terminology) and usually indeed contains it. But again, your question is "How to get CURRENT Modeline for an external display?", current - not the correct one, but current. Current means the one that is in use at the moment of request. You should probably change your question or fix your logic. – folivore Apr 16 '21 at 04:10
  • Again, the display in question was working only on some days and I wanted the current modeline and xrandr --verbose did not provide it. And now this problem is no longer relevant for me. – int_ua Apr 17 '21 at 20:30
  • "How to get the native resolution's modeline from the EDID data block of display?" - I believe your quesion must sound like this. And I'm sure this quesion is many times duplcated. The phrase you're looking for is NATIVE RESOLUTION. This is the correct term. Correct isn't a term. There is no such thing as a single correct resolution for a display. – folivore Apr 19 '21 at 16:02
  • I recommend to read what xrandr actually is. A couple of links might help to clarify the matter:

    https://en.wikipedia.org/wiki/X.Org_Server#Other_DDX_components

    https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt

    Randr is an essential part of Xorg server. It is the thing that sets your display's resolution and refresh rate. Your quesion is wrong, xrandr output is correct.

    – folivore Apr 19 '21 at 16:28
  • The only thing I can recommend is including the links into the answer – int_ua Apr 22 '21 at 21:00