aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmonitor-parse-edid29
1 files changed, 29 insertions, 0 deletions
diff --git a/monitor-parse-edid b/monitor-parse-edid
index ba14847..f6ebde0 100755
--- a/monitor-parse-edid
+++ b/monitor-parse-edid
@@ -121,3 +121,32 @@ sub print_edid {
print "\tModeLine ", $h->{ModeLine}, "\n";
}
}
+
+sub to_MonitorsDB {
+ my ($edid) = @_;
+
+ if (!$edid->{monitor_range}) {
+ print STDERR "No monitor range data in EDID.\n";
+ return;
+ }
+ if (!$edid->{EISA_ID}) {
+ print STDERR "No monitor EISA_ID in EDID.\n";
+ return;
+ }
+
+ my $detailed_timings = $edid->{detailed_timings} || [];
+ my @preferred_resolutions = map {
+ join('x', $_->{horizontal_active}, $_->{vertical_active});
+ } grep { !$_->{bad_ratio} } @$detailed_timings;
+
+ (my $monitor_name = $edid->{monitor_name}) =~ s/;/,/g;
+ my ($raw_vendor, $raw_model) = $edid->{EISA_ID} =~ /(...)(.*)/;
+ my ($VendorName, $only_Model) = $monitor_name =~ /(\S+)\s(.*)/ ?
+ ($1, $2) : ($raw_vendor, $monitor_name || $raw_model);
+ join('; ',
+ $VendorName, "$VendorName $only_Model", $edid->{EISA_ID},
+ sprintf("%u-%u", $edid->{monitor_range}{horizontal_min}, $edid->{monitor_range}{horizontal_max}),
+ sprintf("%u-%u", $edid->{monitor_range}{vertical_min}, $edid->{monitor_range}{vertical_max}),
+ @$detailed_timings == 1 ? @preferred_resolutions : (),
+ );
+}