From 53c6afea2261f2665780ef3164f1da06f7f0f080 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 1 Mar 2005 11:26:17 +0000 Subject: create {preferred_resolution} out of the edid detailed_timings and use it --- perl-install/Xconfig/monitor.pm | 9 +++-- perl-install/Xconfig/resolution_and_depth.pm | 50 ++++++++++++++++++---------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/perl-install/Xconfig/monitor.pm b/perl-install/Xconfig/monitor.pm index 964380899..d84a5a0a5 100644 --- a/perl-install/Xconfig/monitor.pm +++ b/perl-install/Xconfig/monitor.pm @@ -178,10 +178,15 @@ sub getinfoFromDDC() { $monitor->{VideoRam_probed} = $1; } $monitor->{ModeLine} = Xconfig::xfree::default_ModeLine(); - foreach (@{$monitor->{detailed_timings} || []}) { - next if $_->{bad_ratio}; + my $detailed_timings = $monitor->{detailed_timings} || []; + foreach (grep { !$_->{bad_ratio} } @$detailed_timings) { unshift @{$monitor->{ModeLine}}, { val => $_->{ModeLine}, pre_comment => $_->{ModeLine_comment} . "\n" }; + + if (@$detailed_timings == 1) { + #- should we care about {has_preferred_timing} ? + $monitor->{preferred_resolution} = { X => $_->{horizontal_active}, Y => $_->{vertical_active} }; + } } if ($monitor->{EISA_ID}) { diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm index 9287ddce4..83df2fbed 100644 --- a/perl-install/Xconfig/resolution_and_depth.pm +++ b/perl-install/Xconfig/resolution_and_depth.pm @@ -143,24 +143,37 @@ sub choices { @resolutions = filter_using_HorizSync_VertRefresh($monitors->[0]{HorizSync}, $monitors->[0]{VertRefresh}, @resolutions) if $monitors->[0]{HorizSync}; @resolutions = filter_using_VideoRam($card->{VideoRam}, @resolutions) if $card->{VideoRam}; - my $x_res = do { - my $res = $resolution_wanted->{X} || ($monitors->[0]{ModelName} =~ /^Flat Panel (\d+x\d+)$/ ? $1 : size2default_resolution($monitors->[0]{diagonal_size} * 1.08 || 14)); - my $x_res = first(split 'x', $res); + if ($resolution_wanted->{X} && !$resolution_wanted->{Y}) { + #- assuming ratio 4/3 + $resolution_wanted->{Y} = round($resolution_wanted->{X} * 3 / 4); + } elsif (!$resolution_wanted->{X}) { + if ($monitors->[0]{preferred_resolution}) { + put_in_hash($resolution_wanted, $monitors->[0]{preferred_resolution}); + } elsif ($monitors->[0]{ModelName} =~ /^Flat Panel (\d+)x(\d+)$/) { + put_in_hash($resolution_wanted, { X => $1, Y => $2 }); + } else { + my ($X, $Y) = split('x', size2default_resolution($monitors->[0]{diagonal_size} * 1.08 || 14)); + put_in_hash($resolution_wanted, { X => $X, Y => $Y }); + } + } + my @matching = grep { $_->{X} eq $resolution_wanted->{X} && $_->{Y} eq $resolution_wanted->{Y} } @resolutions; + if (!@matching) { + #- hard choice :-( + #- first trying the greater resolution with same ratio + my $ratio = $resolution_wanted->{X} / $resolution_wanted->{Y}; + @matching = grep { abs($ratio - $_->{X} / $_->{Y}) < 0.01 } @resolutions; + } + if (!@matching) { + #- really hard choice :'-( #- take the first available resolution <= the wanted resolution - max map { if_($_->{X} <= $x_res, $_->{X}) } @resolutions; - }; - - my @matching = grep { $_->{X} eq $x_res } @resolutions; - my @Depths = map { $_->{Depth} } @matching; - - my $Depth = $resolution_wanted->{Depth}; - $Depth = $prefered_depth if !$Depth || !member($Depth, @Depths); - $Depth = max(@Depths) if !$Depth || !member($Depth, @Depths); + @matching = grep { $_->{X} < $resolution_wanted->{X} } @resolutions; + } - #- finding it in @resolutions (well @matching) - #- (that way, we check it exists, and we get field "bios" for fbdev) - my @default_resolutions = sort { $b->{Y} <=> $a->{Y} } grep { $_->{Depth} eq $Depth } @matching; - my $default_resolution = (find { $resolution_wanted->{Y} eq $_->{Y} } @default_resolutions) || $default_resolutions[0]; + my $max_Depth = max(map { $_->{Depth} } @matching); + my $default_resolution; + foreach my $Depth ($resolution_wanted->{Depth}, $prefered_depth, $max_Depth) { + $default_resolution = find { $_->{Depth} eq $Depth } @matching and last; + } $default_resolution, @resolutions; } @@ -190,7 +203,10 @@ sub configure { sub configure_auto_install { my ($raw_X, $card, $monitors, $old_X) = @_; - my $resolution_wanted = { X => $old_X->{resolution_wanted}, Depth => $old_X->{default_depth} }; + my $resolution_wanted = do { + my ($X, $Y) = split('x', $old_X->{resolution_wanted}); + { X => $X, Y => $Y, Depth => $old_X->{default_depth} }; + }; my ($default_resolution) = choices($raw_X, $resolution_wanted, $card, $monitors); $default_resolution or die "you selected an unusable depth"; -- cgit v1.2.1