aboutsummaryrefslogtreecommitdiffstats
path: root/monitor-parse-edid
diff options
context:
space:
mode:
Diffstat (limited to 'monitor-parse-edid')
-rwxr-xr-xmonitor-parse-edid36
1 files changed, 33 insertions, 3 deletions
diff --git a/monitor-parse-edid b/monitor-parse-edid
index 596017f..60f5894 100755
--- a/monitor-parse-edid
+++ b/monitor-parse-edid
@@ -21,7 +21,7 @@ my @edid_info = group_by2(
a => 'feature_support',
a10 => '_color_characteristics',
a3 => '_established_timings',
- a16 => '_standard_timings',
+ a16 => 'standard_timings',
a72 => 'monitor_details',
C => 'extension_flag',
@@ -89,6 +89,11 @@ my %subfields = (
1 => '',
) ],
+ standard_timing => [ group_by2(
+ 8 => 'X',
+ 2 => 'aspect',
+ 6 => 'vfreq',
+ ) ],
monitor_range => [ group_by2(
8 => 'vertical_min',
8 => 'vertical_max',
@@ -165,6 +170,23 @@ sub parse_edid {
$v = get_many_bits($v, 'video_input_definition');
} elsif ($field eq 'feature_support') {
$v = get_many_bits($v, 'feature_support');
+ } elsif ($field eq 'standard_timings') {
+ my @aspect2ratio = (
+ $edid{edid_version} > 1 || $edid{edid_revision} > 2 ? '16/10' : '1/1',
+ '4/3', '5/4', '16/9',
+ );
+ $v = [ map {
+ my $h = get_many_bits($_, 'standard_timing');
+ $h->{X} = ($h->{X} + 31) * 8;
+ if ($_ ne "\x20\x20" && $h->{X} > 256) { # cf VALID_TIMING in Xorg edid.h
+ $h->{vfreq} += 60;
+ if ($h->{ratio} = $aspect2ratio[$h->{aspect}]) {
+ delete $h->{aspect};
+ $h->{Y} = $h->{X} / eval($h->{ratio});
+ }
+ $h;
+ } else { () }
+ } unpack('a2' x 8, $v) ];
} elsif ($field eq 'monitor_details') {
while ($v) {
(my $pixel_clock, my $vv, $v) = unpack("v a16 a*", $v);
@@ -325,7 +347,7 @@ sub ratio_name {
}
sub print_edid {
- my ($edid) = @_;
+ my ($edid, $verbose) = @_;
print "Name: $edid->{monitor_name}\n";
print "EISA ID: $edid->{EISA_ID}\n";
@@ -339,6 +361,14 @@ sub print_edid {
print "Gamma: ", $edid->{gamma} / 100 + 1, "\n";
printf "%s signal\n", $edid->{video_input_definition}{digital} ? 'Digital' : 'Analog';
+ if ($verbose && $edid->{standard_timings}) {
+ foreach (@{$edid->{standard_timings}}) {
+ print "Standard resolution: $_->{X}x$_->{Y} @ $_->{vfreq} Hz, ratio $_->{ratio}",
+ $edid->{ratio_name} && $_->{ratio} ne $edid->{ratio_name} ? ' (!)' : '',
+ "\n";
+ }
+ }
+
if ($edid->{monitor_range}) {
printf "Max video bandwidth: %u MHz\n", $edid->{monitor_range}{pixel_clock_max};
print "\n";
@@ -388,7 +418,7 @@ if ($raw_perl) {
$s =~ s/.*? = {/+{/; # remove variable name we don't want
print $s;
} else {
- print_edid($edid);
+ print_edid($edid, $verbose);
}