diff options
Diffstat (limited to 'monitor-parse-edid')
-rwxr-xr-x | monitor-parse-edid | 463 |
1 files changed, 461 insertions, 2 deletions
diff --git a/monitor-parse-edid b/monitor-parse-edid index b8f3515..9228d12 100755 --- a/monitor-parse-edid +++ b/monitor-parse-edid @@ -165,6 +165,454 @@ my %subfields = ( ) ], ); +my %cea_video_modes = ( # EIA/CEA-861-B + # 60/59.94 Hz formats: + 1 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 25.175, 25.200 ], + 'horizontal_active' => 640, + 'horizontal_blanking' => 160, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 16, + 'horizontal_sync_pulse_width' => 96, + 'vertical_sync_offset' => 10, + 'vertical_sync_pulse_width' => 2, + }, + 2 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 720, + 'horizontal_blanking' => 138, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 16, + 'horizontal_sync_pulse_width' => 62, + 'vertical_sync_offset' => 9, + 'vertical_sync_pulse_width' => 6, + }, + 3 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 720, + 'horizontal_blanking' => 138, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 16, + 'horizontal_sync_pulse_width' => 62, + 'vertical_sync_offset' => 9, + 'vertical_sync_pulse_width' => 6, + }, + 4 => { + 'vertical_active' => 720, + 'vertical_blanking' => 30, + 'pixel_clock' => [ 74.175, 74.250 ], + 'horizontal_active' => 1280, + 'horizontal_blanking' => 370, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 110, + 'horizontal_sync_pulse_width' => 40, + 'vertical_sync_offset' => 5, + 'vertical_sync_pulse_width' => 5, + }, + 5 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, # alternating 22,23 per field + 'pixel_clock' => [ 74.175, 74.250 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 280, + 'interlaced' => 1, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 88, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, # alternating 2,2.5 per field + 'vertical_sync_pulse_width' => 10, # 5 per field + }, + 6 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, # alternating 22,23 per field + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 1, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 38, + 'horizontal_sync_pulse_width' => 124, + 'vertical_sync_offset' => 8, # alternating 4,4.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 7 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, # alternating 22,23 per field + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 1, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 38, + 'horizontal_sync_pulse_width' => 124, + 'vertical_sync_offset' => 8, # alternating 4,4.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 8 => { + 'vertical_active' => 240, + 'vertical_blanking' => 22, # 23 also allowed + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 38, + 'horizontal_sync_pulse_width' => 124, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 3, + }, + 9 => { + 'vertical_active' => 240, + 'vertical_blanking' => 22, # 23 also allowed + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 38, + 'horizontal_sync_pulse_width' => 124, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 3, + }, + 10 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, # alternating 22,23 per field + 'pixel_clock' => [ 54.000, 54.054 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 1, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 76, + 'horizontal_sync_pulse_width' => 248, + 'vertical_sync_offset' => 8, # alternating 4,4.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 11 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, # alternating 22,23 per field + 'pixel_clock' => [ 54.000, 54.054 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 1, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 76, + 'horizontal_sync_pulse_width' => 248, + 'vertical_sync_offset' => 8, # alternating 4,4.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 12 => { + 'vertical_active' => 240, + 'vertical_blanking' => 22, # 23 also allowed + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 76, + 'horizontal_sync_pulse_width' => 248, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 3, + }, + 13 => { + 'vertical_active' => 240, + 'vertical_blanking' => 22, # 23 also allowed + 'pixel_clock' => [ 27.000, 27.027 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 76, + 'horizontal_sync_pulse_width' => 248, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 3, + }, + 14 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 54.000, 54.054 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 32, + 'horizontal_sync_pulse_width' => 124, + 'vertical_sync_offset' => 9, + 'vertical_sync_pulse_width' => 6, + }, + 15 => { + 'vertical_active' => 480, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 54.000, 54.054 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 32, + 'horizontal_sync_pulse_width' => 124, + 'vertical_sync_offset' => 9, + 'vertical_sync_pulse_width' => 6, + }, + 16 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 148.350, 148.500 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 280, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 88, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 5, + }, + # 50 Hz formats: + 17 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, + 'pixel_clock' => [ 27.000 ], + 'horizontal_active' => 720, + 'horizontal_blanking' => 144, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 12, + 'horizontal_sync_pulse_width' => 64, + 'vertical_sync_offset' => 5, + 'vertical_sync_pulse_width' => 5, + }, + 18 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, + 'pixel_clock' => [ 27.000 ], + 'horizontal_active' => 720, + 'horizontal_blanking' => 144, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 12, + 'horizontal_sync_pulse_width' => 64, + 'vertical_sync_offset' => 5, + 'vertical_sync_pulse_width' => 5, + }, + 19 => { + 'vertical_active' => 720, + 'vertical_blanking' => 30, + 'pixel_clock' => [ 74.250 ], + 'horizontal_active' => 1280, + 'horizontal_blanking' => 700, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 440, + 'horizontal_sync_pulse_width' => 50, + 'vertical_sync_offset' => 5, + 'vertical_sync_pulse_width' => 5, + }, + 20 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, # alternating 22,23 per field + 'pixel_clock' => [ 74.250 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 720, + 'interlaced' => 1, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 528, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, # alternating 2,2.5 per field + 'vertical_sync_pulse_width' => 10, + }, + 21 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, # alternating 24,25 per field + 'pixel_clock' => [ 27.000 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 1, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 24, + 'horizontal_sync_pulse_width' => 126, + 'vertical_sync_offset' => 4, # alternating 2,2.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 22 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, # alternating 24,25 per field + 'pixel_clock' => [ 27.000 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 1, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 24, + 'horizontal_sync_pulse_width' => 126, + 'vertical_sync_offset' => 4, # alternating 2,2.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 23 => { + 'vertical_active' => 288, + 'vertical_blanking' => 24, # or 25 or 26 + 'pixel_clock' => [ 27.000 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 24, + 'horizontal_sync_pulse_width' => 126, + 'vertical_sync_offset' => 2, + 'vertical_sync_pulse_width' => 3, + }, + 24 => { + 'vertical_active' => 288, + 'vertical_blanking' => 24, # or 25 or 26 + 'pixel_clock' => [ 27.000 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 276, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 24, + 'horizontal_sync_pulse_width' => 126, + 'vertical_sync_offset' => 2, + 'vertical_sync_pulse_width' => 3, + }, + 25 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, # alternating 24,25 per field + 'pixel_clock' => [ 54.000 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 1, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 48, + 'horizontal_sync_pulse_width' => 252, + 'vertical_sync_offset' => 4, # alternating 2,2.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 26 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, # alternating 24,25 per field + 'pixel_clock' => [ 54.000 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 1, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 48, + 'horizontal_sync_pulse_width' => 252, + 'vertical_sync_offset' => 4, # alternating 2,2.5 per field + 'vertical_sync_pulse_width' => 6, + }, + 27 => { + 'vertical_active' => 288, + 'vertical_blanking' => 24, # or 25 or 26 + 'pixel_clock' => [ 54.000 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 48, + 'horizontal_sync_pulse_width' => 252, + 'vertical_sync_offset' => 2, + 'vertical_sync_pulse_width' => 3, + }, + 28 => { + 'vertical_active' => 288, + 'vertical_blanking' => 24, # or 25 or 26 + 'pixel_clock' => [ 54.000 ], + 'horizontal_active' => 2880, + 'horizontal_blanking' => 552, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 48, + 'horizontal_sync_pulse_width' => 252, + 'vertical_sync_offset' => 2, + 'vertical_sync_pulse_width' => 3, + }, + 29 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, + 'pixel_clock' => [ 54.000 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 288, + 'interlaced' => 0, + 'aspect_ratio' => "4:3", + 'horizontal_sync_offset' => 24, + 'horizontal_sync_pulse_width' => 128, + 'vertical_sync_offset' => 5, + 'vertical_sync_pulse_width' => 5, + }, + 30 => { + 'vertical_active' => 576, + 'vertical_blanking' => 49, + 'pixel_clock' => [ 54.000 ], + 'horizontal_active' => 1440, + 'horizontal_blanking' => 288, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 24, + 'horizontal_sync_pulse_width' => 128, + 'vertical_sync_offset' => 5, + 'vertical_sync_pulse_width' => 5, + }, + 31 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 148.500 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 720, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 528, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 5, + }, + # other formats: + 32 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 74.175, 74.250 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 830, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 638, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 5, + }, + 33 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 74.250 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 720, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 528, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 5, + }, + 34 => { + 'vertical_active' => 1080, + 'vertical_blanking' => 45, + 'pixel_clock' => [ 74.175, 74.250 ], + 'horizontal_active' => 1920, + 'horizontal_blanking' => 280, + 'interlaced' => 0, + 'aspect_ratio' => "16:9", + 'horizontal_sync_offset' => 528, + 'horizontal_sync_pulse_width' => 44, + 'vertical_sync_offset' => 4, + 'vertical_sync_pulse_width' => 5, + }, + ); + sub within_limit { my ($value, $type, $limit) = @_; $type eq 'min' ? $value >= $limit : $value <= $limit; @@ -338,9 +786,20 @@ sub parse_edid { my $h = get_many_bits($v, 'cea_data_block_collection'); $dtd_offset -= $h->{size} + 1; - $v = unpack("x x$h->{size} a*", $v); + my $vv; + ($vv, $v) = unpack("x a$h->{size} a*", $v); if ($h->{type} == 0x02) { # Video Data Block - $verbose && warn "video data block not handled\n"; + my @vmodes = unpack("a" x $h->{size}, $vv); + foreach my $vmode (@vmodes) { + $h = get_many_bits($vmode, 'cea_video_data_block'); + my $cea_mode = $cea_video_modes{$h->{mode}}; + next if !$cea_mode; + foreach my $pixclock (@{$cea_mode->{pixel_clock}}) { + my %det_mode = %$cea_mode; + $det_mode{pixel_clock} = $pixclock; + push @{$edid{detailed_timings}}, \%det_mode; + } + } } } |