diff options
author | Guillaume Rousse <guillomovitch@gmail.com> | 2019-09-07 09:44:31 +0200 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@gmail.com> | 2019-09-07 09:44:31 +0200 |
commit | a721bc39a62d52a43f3a1cf8e5202b4cd606ff11 (patch) | |
tree | d78363126001be97dfc53eaa8777a6977ea5e54e | |
parent | f7b20f813d3d8dedf52632370599d7fa485ccffb (diff) | |
download | monitor-edid-a721bc39a62d52a43f3a1cf8e5202b4cd606ff11.tar monitor-edid-a721bc39a62d52a43f3a1cf8e5202b4cd606ff11.tar.gz monitor-edid-a721bc39a62d52a43f3a1cf8e5202b4cd606ff11.tar.bz2 monitor-edid-a721bc39a62d52a43f3a1cf8e5202b4cd606ff11.tar.xz monitor-edid-a721bc39a62d52a43f3a1cf8e5202b4cd606ff11.zip |
return of to_MonitorsDB function
this function was erroneously removed while exporting the parsing code
in Parse::EDID module.
-rwxr-xr-x | monitor-parse-edid | 29 |
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 : (), + ); +} |