summaryrefslogtreecommitdiffstats
path: root/perl-install/Xconfig
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/Xconfig')
-rw-r--r--perl-install/Xconfig/FILES8
-rw-r--r--perl-install/Xconfig/card.pm570
-rw-r--r--perl-install/Xconfig/default.pm67
-rw-r--r--perl-install/Xconfig/main.pm108
-rw-r--r--perl-install/Xconfig/monitor.pm191
-rw-r--r--perl-install/Xconfig/parse.pm21
-rw-r--r--perl-install/Xconfig/proprietary.pm32
-rw-r--r--perl-install/Xconfig/resolution_and_depth.pm185
-rw-r--r--perl-install/Xconfig/screen.pm42
-rw-r--r--perl-install/Xconfig/test.pm140
-rw-r--r--perl-install/Xconfig/various.pm58
-rw-r--r--perl-install/Xconfig/xfree.pm77
-rw-r--r--perl-install/Xconfig/xfree3.pm198
-rw-r--r--perl-install/Xconfig/xfree4.pm95
-rw-r--r--perl-install/Xconfig/xfreeX.pm255
15 files changed, 1991 insertions, 56 deletions
diff --git a/perl-install/Xconfig/FILES b/perl-install/Xconfig/FILES
new file mode 100644
index 000000000..deefdedec
--- /dev/null
+++ b/perl-install/Xconfig/FILES
@@ -0,0 +1,8 @@
+
+ xfree3
+ / \
+parse - -- xfreeX -- xfree ---- default ------------------ main
+ \ / \--- card -------------------/ test
+ xfree4 \-- monitor ---------------/ various
+ \- screen ---------------/ proprietary
+ \ resolution_and_depth-/
diff --git a/perl-install/Xconfig/card.pm b/perl-install/Xconfig/card.pm
new file mode 100644
index 000000000..654db6ab1
--- /dev/null
+++ b/perl-install/Xconfig/card.pm
@@ -0,0 +1,570 @@
+package Xconfig::card; # $Id$
+
+use diagnostics;
+use strict;
+
+use common;
+use modules;
+use log;
+
+
+my $force_xf4 = arch() =~ /ppc|ia64/;
+
+
+my %VideoRams = (
+ 256 => __("256 kB"),
+ 512 => __("512 kB"),
+ 1024 => __("1 MB"),
+ 2048 => __("2 MB"),
+ 4096 => __("4 MB"),
+ 8192 => __("8 MB"),
+ 16384 => __("16 MB"),
+ 32768 => __("32 MB"),
+ 65536 => __("64 MB or more"),
+);
+
+our %serversdriver = arch() =~ /^sparc/ ? (
+ 'Mach64' => "accel",
+ '3DLabs' => "accel",
+ 'Sun' => "fbdev",
+ 'Sun24' => "fbdev",
+ 'SunMono' => "fbdev",
+ 'VGA16' => "vga16",
+ 'FBDev' => "fbdev",
+) : (
+ 'SVGA' => "svga",
+ 'S3' => "accel",
+ 'Mach32' => "accel",
+ 'Mach8' => "accel",
+ '8514' => "accel",
+ 'P9000' => "accel",
+ 'AGX' => "accel",
+ 'W32' => "accel",
+ 'Mach64' => "accel",
+ 'I128' => "accel",
+ 'S3V' => "accel",
+ '3DLabs' => "accel",
+ 'VGA16' => "vga16",
+ 'FBDev' => "fbdev",
+);
+my @allbutfbservers = grep { arch() =~ /^sparc/ || $serversdriver{$_} ne "fbdev" } keys(%serversdriver);
+my @allservers = keys(%serversdriver);
+
+my @xfree4_Drivers = ((arch() =~ /^sparc/ ? qw(sunbw2 suncg14 suncg3 suncg6 sunffb sunleo suntcx) :
+ qw(apm ark chips cirrus cyrix glide i128 i740 i810 imstt
+ mga neomagic newport nv rendition r128 radeon vesa
+ s3 s3virge savage siliconmotion sis tdfx tga trident tseng vmware)),
+ qw(ati glint vga fbdev));
+
+
+#- using XF4 if {Driver} && !{prefer_xf3} otherwise using XF3
+#- error if $force_xf4 && !{Driver} || !{Driver} && !{server}
+#- internal error if $force_xf4 && {prefer_xf3} || {prefer_xf3} && !{server}
+
+sub using_xf4 {
+ my ($card) = @_;
+ $card->{Driver} && !$card->{prefer_xf3};
+}
+
+sub server_binary {
+ my ($card) = @_;
+ "/usr/X11R6/bin/" .
+ (using_xf4($card) ? 'XFree86' :
+ $card->{server} =~ /Sun(.*)/ ? "Xsun$1" :
+ $card->{server} eq 'Xpmac' ? 'Xpmac' :
+ "XF86_$card->{server}");
+}
+
+sub from_raw_X {
+ my ($raw_X) = @_;
+
+ my $device = $raw_X->get_device or die "no card configured";
+
+ my $card = {
+ use_UTAH_GLX => int(grep { /glx/ } $raw_X->{xfree3}->get_modules),
+ use_DRI_GLX => int(grep { /glx/ } $raw_X->{xfree4}->get_modules),
+ server => $raw_X->{xfree3_server},
+ prefer_xf3 => readlink("$::prefix/etc/X11/X") !~ /XFree86/ && !$force_xf4,
+ %$device,
+ };
+ add_to_card__using_Cards($card, $card->{BoardName});
+ $card->{prog} = server_binary($card);
+ $card;
+}
+
+sub to_raw_X {
+ my ($card, $raw_X) = @_;
+
+ $raw_X->set_devices($card, @{$card->{cards} || []});
+
+ $raw_X->{xfree4}->get_ServerLayout->{Xinerama} = { commented => !$card->{Xinerama}, Option => 1 }
+ if defined $card->{Xinerama};
+
+ $raw_X->{xfree3}->set_load_module('glx-3.so', $card->{use_UTAH_GLX}); #- glx.so may clash with server version 4.
+
+ $raw_X->{xfree4}->set_load_module($_, $card->{use_DRI_GLX} && !$card->{DRI_GLX_SPECIAL})
+ foreach 'dri', 'glx';
+
+ # This loads the NVIDIA GLX extension module.
+ # IT IS IMPORTANT TO KEEP NAME AS FULL PATH TO libglx.so ELSE
+ # IT WILL LOAD XFree86 glx module and the server will crash.
+ $raw_X->{xfree4}->set_load_module('/usr/X11R6/lib/modules/extensions/libglx.so', $card->{DRI_GLX_SPECIAL});
+
+ $raw_X->{xfree4}->remove_Section('DRI');
+ $raw_X->{xfree4}->add_Section('DRI', { Mode => { val => '0666' } }) if $card->{use_DRI_GLX};
+
+ $raw_X->{xfree4}->remove_load_module('v4l') if $card->{use_DRI_GLX} && $card->{Driver} eq 'r128';
+}
+
+sub probe() {
+#-for Pixel tests
+ my @c = { driver => 'Card:Matrox Millennium G400 DualHead', description => 'Matrox|Millennium G400 Dual HeadCard' };
+#- my @c = grep { $_->{driver} =~ /(Card|Server|Driver):/ } detect_devices::probeall();
+
+ my @cards = map {
+ my @l = $_->{description} =~ /(.*?)\|(.*)/;
+ my $card = {
+ description => $_->{description},
+ VendorName => $l[0], BoardName => $l[1],
+ BusID => "PCI:$_->{pci_bus}:$_->{pci_device}:$_->{pci_function}",
+ };
+ if ($_->{driver} =~ /Card:(.*)/) { $card->{BoardName} = $1; add_to_card__using_Cards($card, $1) }
+ elsif ($_->{driver} =~ /Server:(.*)/) { $card->{server} = $1 }
+ elsif ($_->{driver} =~ /Driver:(.*)/) { $card->{Driver} = $1 }
+ else { internal_error() }
+
+ $_->{VideoRam} = 4096 if $_->{Driver} eq 'i810';
+ $_->{Options_xfree4}{UseFBDev} = "on" if arch =~ /ppc/ && $_->{Driver} eq 'r128';
+
+ $card;
+ } @c;
+
+ if (@cards >= 2 && $cards[0]{card_name} eq $cards[1]{card_name} && $cards[0]{card_name} eq 'Intel 830') {
+ shift @cards;
+ }
+ #- take a default on sparc if nothing has been found.
+ if (arch() =~ /^sparc/ && !@cards) {
+ log::l("Using probe with /proc/fb as nothing has been found!");
+ local $_ = cat_("/proc/fb");
+ @cards = { server => /Mach64/ ? "Mach64" : /Permedia2/ ? "3DLabs" : "Sun24" };
+ }
+
+ #- disabling MULTI_HEAD when not available
+ foreach (@cards) {
+ $_->{MULTI_HEAD} && $_->{card_name} =~ /G[24]00/ or next;
+ if ($ENV{MATROX_HAL}) {
+# $_->{need_MATROX_HAL} = 1;
+ } else {
+ delete $_->{MULTI_HEAD};
+ }
+ }
+
+ #- in case of only one cards, remove all BusID reference, this will avoid
+ #- need of change of it if the card is moved.
+ #- on many PPC machines, card is on-board, BusID is important, leave?
+ if (@cards == 1 && arch() !~ /ppc/) {
+ delete $cards[0]{BusID};
+ }
+
+ @cards;
+}
+
+sub card_config__not_listed {
+ my ($in, $card, $options) = @_;
+
+ my $vendors_regexp = join '|', map { quotemeta } (
+ '3Dlabs',
+ 'AOpen', 'ASUS', 'ATI', 'Ark Logic', 'Avance Logic',
+ 'Cardex', 'Chaintech', 'Chips & Technologies', 'Cirrus Logic', 'Compaq', 'Creative Labs',
+ 'Dell', 'Diamond', 'Digital',
+ 'ET', 'Elsa',
+ 'Genoa', 'Guillemot', 'Hercules', 'Intel', 'Leadtek',
+ 'Matrox', 'Miro', 'NVIDIA', 'NeoMagic', 'Number Nine',
+ 'Oak', 'Orchid',
+ 'RIVA', 'Rendition Verite',
+ 'S3', 'Silicon Motion', 'STB', 'SiS', 'Sun',
+ 'Toshiba', 'Trident',
+ 'VideoLogic',
+ );
+ my $cards = readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+");
+
+ my @xf3 = $options->{allowFB} ? @allservers : @allbutfbservers;
+ my @xf4 = grep { $options->{allowFB} || $_ ne 'fbdev' } @xfree4_Drivers;
+ my @list = (
+ (map { 'Vendor|' . $_ } keys %$cards),
+ if_(!$force_xf4, map { 'XFree 3|' . $_ } @xf3),
+ (map { 'XFree 4|' . $_ } @xf4),
+ );
+
+ my $r = $in->ask_from_treelistf(
+ _("X server"), _("Choose a X server"), '|',
+ sub { $_[0] =~ /^Vendor\|($vendors_regexp)\s*-?(.*)/ ? "Vendor|$1|$2" :
+ $_[0] =~ /^Vendor\|(.*)/ ? "Vendor|Other|$1" : $_[0] },
+ \@list, 'XFree 4|vesa') or return;
+
+ my ($kind, $s) = $r =~ /(.*?)\|(.*)/;
+
+ %$card = ();
+ if ($kind eq 'Vendor') {
+ add_to_card__using_Cards($card, $s);
+ } elsif ($kind eq 'XFree 3') {
+ $card->{server} = $s;
+ } else {
+ $card->{Driver} = $s;
+ }
+ $card->{manually_chosen} = 1;
+ 1;
+}
+
+sub multi_head_choose {
+ my ($in, @cards) = @_;
+
+ my @choices = multi_head_choices(@cards);
+
+ my $tc = $in->ask_from_listf(_("Multi-head configuration"),
+ _("Your system support multiple head configuration.
+What do you want to do?"), sub { $_[0]{text} }, \@choices) or return;
+
+ $tc->{code} or die internal_error();
+ return $tc->{code}();
+}
+
+sub configure_auto_install {
+ my ($raw_X, $do_pkgs, $old_X, $options) = @_;
+
+ {
+ my $card = $old_X->{card} || {};
+ if ($card->{card_name}) {
+ #- try to get info from given card_name
+ add_to_card__using_Cards($card, $card->{card_name});
+ undef $card->{card_name} if !$card->{server} && !$card->{Driver}; #- bad card_name as we can't find the server
+ }
+ return if $card->{server} || $card->{Driver};
+ }
+
+ my @cards = probe();
+ my ($choice) = multi_head_choices(@cards) or log::l('no graphic card probed, try providing one using $o->{card}{Driver} or $o->{card}{server} or $o->{card}{card_name}'), return;
+ my $card = $choice->{code}();
+
+ my ($glx_choice) = xfree_and_glx_choices($card);
+ log::l("Using $glx_choice->{text}");
+ $glx_choice->{code}();
+ set_glx_restrictions($card);
+
+ $card->{prog} = install_server($card, $options, $do_pkgs);
+ if ($card->{needVideoRam} && !$card->{VideoRam}) {
+ $card->{VideoRam} = 4096;
+ log::l("argh, I need to know VideoRam! Taking a default value: VideoRam = $card->{VideoRam}");
+ }
+ to_raw_X($card, $raw_X);
+ $card;
+}
+
+sub configure {
+ my ($in, $raw_X, $do_pkgs, $auto, $options) = @_;
+
+ my @cards = probe();
+ my $card = multi_head_choose($in, @cards) or return;
+
+ $card->{Driver} = 'fbdev' if $options->{allowFB} && !$card->{server} && !$card->{Driver};
+
+ if (!$card->{server} && !$card->{Driver}) {
+ card_config__not_listed($in, $card, $options) or return;
+ }
+
+ xfree_and_glx_choose($in, $card, $auto);
+
+ $card->{prog} = install_server($card, $options, $do_pkgs);
+
+ $in->ask_from('', _("Select the memory size of your graphics card"),
+ [ { val => \$card->{VideoRam},
+ type => 'list',
+ list => [ ikeys %VideoRams ],
+ format => sub { translate($VideoRams{$_[0]}) },
+ not_edit => !$::expert } ]) or return
+ if $card->{needVideoRam} && !$card->{VideoRam};
+
+ to_raw_X($card, $raw_X);
+ $card;
+}
+
+sub install_server {
+ my ($card, $options, $do_pkgs) = @_;
+
+ my $prog = server_binary($card);
+
+ my @packages = ();
+ push @packages, using_xf4($card) ? 'XFree86-server' : "XFree86-$card->{server}" if ! -x "$::prefix$prog";
+
+ #- additional packages to install according available card.
+ #- add XFree86-libs-DRI here if using DRI (future split of XFree86 TODO)
+ if ($card->{use_DRI_GLX}) {
+ push @packages, 'Glide_V5' if $card->{card_name} eq 'Voodoo5 (generic)';
+ push @packages, 'Glide_V3-DRI' if member($card->{card_name}, 'Voodoo3 (generic)', 'Voodoo Banshee (generic)');
+ push @packages, 'XFree86-glide-module' if $card->{card_name} =~ /Voodoo/;
+ }
+ if ($card->{use_UTAH_GLX}) {
+ push @packages, 'Mesa';
+ }
+ #- 3D acceleration configuration for XFree 4 using NVIDIA driver (TNT, TN2 and GeForce cards only).
+ push @packages, @{$options->{allowNVIDIA_rpms}} if $card->{Driver2} eq 'nvidia' && $options->{allowNVIDIA_rpms};
+
+ $do_pkgs->install(@packages) if @packages;
+ -x "$::prefix$prog" or die "server $card->{server} is not available (should be in $::prefix$prog)";
+
+ #- make sure everything is correct at this point, packages have really been installed
+ #- and driver and GLX extension is present.
+ if ($card->{Driver2} eq 'nvidia' &&
+ -e "$::prefix/usr/X11R6/lib/modules/drivers/nvidia_drv.o" &&
+ -e "$::prefix/usr/X11R6/lib/modules/extensions/libglx.so") {
+ log::l("Using specific NVIDIA driver and GLX extensions");
+ $card->{Driver} = 'nvidia';
+ $card->{DRI_GLX_SPECIAL} = 1;
+ }
+
+ if ($card->{need_MATROX_HAL}) {
+ require Xconfig::proprietary;
+ Xconfig::proprietary::install_matrox_hal($::prefix);
+ }
+
+ $prog;
+}
+
+sub xfree_and_glx_choose {
+ my ($in, $card, $auto) = @_;
+
+ my @choices = xfree_and_glx_choices($card);
+
+ my $tc =
+ $auto ? $choices[0] :
+ $in->ask_from_listf(_("XFree configuration"),
+ formatAlaTeX(join("\n\n\n", (grep {$_} map { $_->{more_messages} } @choices),
+ _("Which configuration of XFree do you want to have?"))),
+ sub { $_[0]{text} }, \@choices) or return;
+ log::l("Using $tc->{text}");
+ $tc->{code}();
+ set_glx_restrictions($card);
+}
+
+sub multi_head_choices {
+ my (@cards) = @_;
+ my @choices;
+
+ my $has_multi_head = @cards > 1 || $cards[0]{MULTI_HEAD} > 1;
+ my $disable_multi_head = grep {
+ $_->{Driver} or log::l("found card $_->{description} not supported by XF4, disabling multi-head support");
+ !$_->{Driver};
+ } @cards;
+
+ if ($has_multi_head && !$disable_multi_head) {
+ my $configure_multi_head = sub {
+
+ #- special case for multi head card using only one BusID.
+ @cards = map {
+ map_index { { screen => $::i, %$_ } } ($_) x ($_->{MULTI_HEAD} || 1);
+ } @cards;
+
+ delete $_->{server} foreach @cards; #- XFree 3 doesn't handle multi head (?)
+ my $card = shift @cards; #- assume good default.
+ $card->{cards} = \@cards;
+ $card->{Xinerama} = $_[0];
+ $card;
+ };
+ push @choices, { text => _("Configure all heads independently"), code => sub { $configure_multi_head->('') } };
+ push @choices, { text => _("Use Xinerama extension"), code => sub { $configure_multi_head->(1) } };
+ }
+
+ foreach my $c (@cards) {
+ push @choices, { text => _("Configure only card \"%s\"%s", $c->{description}, $c->{BusID} && " ($c->{BusID})"),
+ code => sub { $c } };
+ }
+ @choices;
+}
+
+sub xfree_and_glx_choices {
+ my ($card) = @_;
+
+ #- XFree version available, better to parse available package and get version from it.
+ my ($xf4_ver, $xf3_ver) = ('4.2.0', '3.3.6');
+
+ my @choices = do {
+ #- basic installation, use of XFree 4.2 or XFree 3.3.
+ my $xf3 = { text => _("XFree %s", $xf3_ver), code => sub { $card->{prefer_xf3} = 1 } };
+ my $xf4 = { text => _("XFree %s", $xf4_ver), code => sub { $card->{prefer_xf3} = 0 } };
+ $card->{prefer_xf3} ? ($xf3, $xf4) : ($xf4, $xf3);
+ };
+
+ #- no GLX with Xinerama
+ return @choices if $card->{Xinerama};
+
+ #- try to figure if 3D acceleration is supported
+ #- by XFree 3.3 but not XFree 4 then ask user to keep XFree 3.3 ?
+ if ($card->{UTAH_GLX}) {
+ unshift @choices, { text => _("XFree %s with 3D hardware acceleration", $xf3_ver),
+ code => sub { $card->{prefer_xf3} = 1; $card->{use_UTAH_GLX} = 1 },
+ more_messages => ($card->{Driver} && !$card->{DRI_GLX} ?
+_("Your card can have 3D hardware acceleration support but only with XFree %s.
+Your card is supported by XFree %s which may have a better support in 2D.", $xf3_ver, $xf4_ver) :
+_("Your card can have 3D hardware acceleration support with XFree %s.", $xf3_ver)),
+ };
+ }
+
+ #- an expert user may want to try to use an EXPERIMENTAL 3D acceleration, currenlty
+ #- this is with Utah GLX and so, it can provide a way of testing.
+ if ($card->{UTAH_GLX_EXPERIMENTAL} && $::expert) {
+ push @choices, { text => _("XFree %s with EXPERIMENTAL 3D hardware acceleration", $xf3_ver),
+ code => sub { $card->{prefer_xf3} = 1; $card->{use_UTAH_GLX} = 1 },
+ more_messages => (using_xf4($card) && !$card->{DRI_GLX} ?
+_("Your card can have 3D hardware acceleration support but only with XFree %s,
+NOTE THIS IS EXPERIMENTAL SUPPORT AND MAY FREEZE YOUR COMPUTER.
+Your card is supported by XFree %s which may have a better support in 2D.", $xf3_ver, $xf4_ver) :
+_("Your card can have 3D hardware acceleration support with XFree %s,
+NOTE THIS IS EXPERIMENTAL SUPPORT AND MAY FREEZE YOUR COMPUTER.", $xf3_ver)),
+ };
+ }
+
+ #- ask the expert or any user on second pass user to enable or not hardware acceleration support.
+ if ($card->{DRI_GLX}) {
+ unshift @choices, { text => _("XFree %s with 3D hardware acceleration", $xf4_ver),
+ code => sub { $card->{prefer_xf3} = 0; $card->{use_DRI_GLX} = 1 },
+ more_messages => _("Your card can have 3D hardware acceleration support with XFree %s.", $xf4_ver),
+ };
+ }
+
+ #- an expert user may want to try to use an EXPERIMENTAL 3D acceleration.
+ if ($card->{DRI_GLX_EXPERIMENTAL} && $::expert) {
+ push @choices, { text => _("XFree %s with EXPERIMENTAL 3D hardware acceleration", $xf4_ver),
+ code => sub { $card->{prefer_xf3} = 0; $card->{use_DRI_GLX} = 1 },
+ more_messages => _("Your card can have 3D hardware acceleration support with XFree %s,
+NOTE THIS IS EXPERIMENTAL SUPPORT AND MAY FREEZE YOUR COMPUTER.", $xf4_ver),
+ };
+ }
+
+ if (arch() =~ /ppc/ && $ENV{DISPLAY}) {
+ push @choices, { text => _("Xpmac (installation display driver)"), code => sub {
+ #- HACK: re-allowing XFree 3
+ $::force_xf4 = 0;
+ $card->{server} = "Xpmac";
+ $card->{prefer_xf3} = 1;
+ }};
+ }
+ @choices;
+}
+
+sub set_glx_restrictions {
+ my ($card) = @_;
+
+ #- hack for ATI Mach64 cards where two options should be used if using Utah-GLX.
+ if (member($card->{card_name}, 'ATI Mach64 Utah', 'ATI Rage Mobility')) {
+ $card->{Options_xfree3}{no_font_cache} = $card->{use_UTAH_GLX};
+ $card->{Options_xfree3}{no_pixmap_cache} = $card->{use_UTAH_GLX};
+ }
+ #- hack for SiS cards where an option should be used if using Utah-GLX.
+ if (member($card->{card_name}, 'SiS 6326', 'SiS 630')) {
+ $card->{Options_xfree3}{no_pixmap_cache} = $card->{use_UTAH_GLX};
+ }
+
+ #- 3D acceleration configuration for XFree 4 using DRI, this is enabled by default
+ #- but for some there is a need to specify VideoRam (else it won't run).
+ if ($card->{use_DRI_GLX}) {
+ #- always enable (as a reminder for people using a better AGP mode to change it at their own risk).
+ $card->{Options_xfree4}{AGPMode} = 'true';
+
+ $card->{needVideoRam} = 1 if $card->{description} =~ /Matrox.* G[245][05]0/;
+ ($card->{needVideoRam}, $card->{VideoRam}) = (1, 16384)
+ if member($card->{card_name}, 'Intel 810', 'Intel 815');
+
+ #- hack for ATI Rage 128 card using a bttv or peripheral with PCI bus mastering exchange
+ #- AND using DRI at the same time.
+ if (member($card->{card_name}, 'ATI Rage 128', 'ATI Rage 128 Mobility')) {
+ $card->{Options_xfree4}{UseCCEFor2D} = bool2text(modules::probe_category('multimedia/tv'));
+ }
+ }
+
+ #- check for Matrox G200 PCI cards, disable AGP in such cases, causes black screen else.
+ if (member($card->{card_name}, 'Matrox Millennium 200', 'Matrox Millennium 200', 'Matrox Mystique') && $card->{description} !~ /AGP/) {
+ log::l("disabling AGP mode for Matrox card, as it seems to be a PCI card");
+ log::l("this is only used for XFree 3.3.6, see /etc/X11/glx.conf");
+ substInFile { s/^\s*#*\s*mga_dma\s*=\s*\d+\s*$/mga_dma = 0\n/ } "$::prefix/etc/X11/glx.conf";
+ }
+}
+
+sub add_to_card__using_Cards {
+ my ($card, $name) = @_;
+ my $cards = readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+");
+ add2hash($card, $cards->{$name});
+
+ delete @$card{'server'} if $force_xf4;
+
+ delete @$card{'UTAH_GLX', 'UTAH_GLX_EXPERIMENTAL'}
+ if $force_xf4 || availableRamMB() > 800; #- no Utah GLX if more than 800 Mb (server, or kernel-enterprise, Utha GLX does not work with latest).
+
+ $card->{prefer_xf3} = 1 if $card->{Driver} eq 'neomagic' && !$force_xf4;
+
+ $card;
+}
+
+#- needed for bad cards not restoring cleanly framebuffer, according to which version of XFree are used.
+sub check_bad_card {
+ my ($card) = @_;
+ my $bad_card = using_xf4($card) ? $card->{BAD_FB_RESTORE} : $card->{BAD_FB_RESTORE_XF3};
+ $bad_card ||= $card->{Driver} eq 'i810' || $card->{Driver} eq 'fbdev';
+ $bad_card ||= $card->{Driver} eq 's3virge' if $::live;
+ $bad_card ||= $card->{Driver} eq 'nvidia' if !$::isStandalone; #- avoid testing during install at any price.
+ $bad_card ||= $card->{server} =~ 'FBDev|Sun' if !using_xf4($card);
+
+ log::l("the graphics card does not like X in framebuffer") if $bad_card;
+
+ !$bad_card;
+}
+
+sub readCardsDB {
+ my ($file) = @_;
+ my ($card, %cards);
+
+ my $F = common::openFileMaybeCompressed($file);
+
+ my ($lineno, $cmd, $val) = 0;
+ my $fs = {
+ NAME => sub {
+ $cards{$card->{card_name}} = $card if $card;
+ $card = { card_name => $val };
+ },
+ SEE => sub {
+ my $c = $cards{$val} or die "Error in database, invalid reference $val at line $lineno";
+ add2hash($card, $c);
+ },
+ LINE => sub { $val =~ s/^\s*//; $card->{raw_LINES} .= "$val\n" },
+ CHIPSET => sub { $card->{Chipset} = $val },
+ SERVER => sub { $card->{server} = $val },
+ DRIVER => sub { $card->{Driver} = $val },
+ DRIVER2 => sub { $card->{Driver2} = $val },
+ NEEDVIDEORAM => sub { $card->{needVideoRam} = 1 },
+ DRI_GLX => sub { $card->{DRI_GLX} = 1 if $card->{Driver} },
+ UTAH_GLX => sub { $card->{UTAH_GLX} = 1 if $card->{server} },
+ DRI_GLX_EXPERIMENTAL => sub { $card->{DRI_GLX_EXPERIMENTAL} = 1 if $card->{Driver} },
+ UTAH_GLX_EXPERIMENTAL => sub { $card->{UTAH_GLX_EXPERIMENTAL} = 1 if $card->{server} },
+ MULTI_HEAD => sub { $card->{MULTI_HEAD} = $val if $card->{Driver} },
+ BAD_FB_RESTORE => sub { $card->{BAD_FB_RESTORE} = 1 },
+ BAD_FB_RESTORE_XF3 => sub { $card->{BAD_FB_RESTORE_XF3} = 1 },
+ UNSUPPORTED => sub { delete $card->{Driver} },
+
+ COMMENT => sub {},
+ };
+
+ local $_;
+ while (<$F>) { $lineno++;
+ s/\s+$//;
+ /^#/ and next;
+ /^$/ and next;
+ /^END/ and do { $cards{$card->{card_name}} = $card if $card; last };
+
+ ($cmd, $val) = /(\S+)\s*(.*)/ or next;
+
+ my $f = $fs->{$cmd};
+
+ $f ? $f->() : log::l("unknown line $lineno ($_)");
+ }
+ \%cards;
+}
+1;
diff --git a/perl-install/Xconfig/default.pm b/perl-install/Xconfig/default.pm
new file mode 100644
index 000000000..6801eb49a
--- /dev/null
+++ b/perl-install/Xconfig/default.pm
@@ -0,0 +1,67 @@
+package Xconfig::default; # $Id$
+
+use diagnostics;
+use strict;
+
+use Xconfig::xfree;
+use keyboard;
+use common;
+use mouse;
+
+
+sub configure {
+ my ($keyboard, $mouse) = @_;
+
+ $keyboard ||= keyboard::read($::prefix);
+ $mouse ||= $::noauto ? mouse::read($::prefix) : mouse::detect();
+
+
+ my $raw_X = Xconfig::xfree->empty_config;
+
+ $raw_X->{xfree4}->add_load_module($_) foreach qw(dbe v4l extmod type1 freetype);
+
+ config_keyboard($raw_X, $keyboard);
+ config_mouse($raw_X, $mouse);
+
+ $raw_X;
+}
+
+sub config_mouse {
+ my ($raw_X, $mouse) = @_;
+ mouse::set_xfree_conf($mouse, $raw_X);
+ if (my @wacoms = @{$mouse->{wacom} || []}) {
+ $raw_X->set_wacoms(map { { Device => "/dev/$_", USB => m|input/event| } } @wacoms);
+ $raw_X->{xfree3}->add_load_module('xf86Wacom.so');
+ }
+}
+
+sub config_keyboard {
+ my ($raw_X, $keyboard) = @_;
+
+ my $XkbLayout = keyboard::keyboard2xkb($keyboard);
+
+ if (!$XkbLayout || $XkbLayout =~ /([^(]*)/ && !-e "$::prefix/usr/X11R6/lib/X11/xkb/symbols/$1") {
+ my $f = keyboard::xmodmap_file($keyboard);
+ cp_af($f, "$::prefix/etc/X11/xinit/Xmodmap");
+ $XkbLayout = '';
+ }
+
+ {
+ my $f = "$::prefix/etc/sysconfig/i18n";
+ setVarsInSh($f, add2hash_({ XKB_IN_USE => $XkbLayout ? '': 'no' }, { getVarsFromSh($f) })) if !$::testing;
+ }
+
+ my $XkbModel =
+ arch() =~ /sparc/ ? 'sun' :
+ $XkbLayout eq 'jp' ? 'jp106' :
+ $XkbLayout eq 'br' ? 'abnt2' : 'pc105';
+
+ my $xkb = { $XkbLayout ? (
+ XkbLayout => $XkbLayout,
+ XkbModel => $XkbModel,
+ ) : (XkbDisable => undef) };
+ $raw_X->set_keyboard($xkb);
+}
+
+1;
+
diff --git a/perl-install/Xconfig/main.pm b/perl-install/Xconfig/main.pm
new file mode 100644
index 000000000..7a07b2b07
--- /dev/null
+++ b/perl-install/Xconfig/main.pm
@@ -0,0 +1,108 @@
+package Xconfig::main; # $Id$
+
+use diagnostics;
+use strict;
+
+use Xconfig::monitor;
+use Xconfig::card;
+use Xconfig::resolution_and_depth;
+use Xconfig::various;
+use Xconfig::screen;
+use Xconfig::test;
+use common;
+use any;
+
+
+sub configure_monitor {
+ my ($in, $raw_X) = @_;
+
+ Xconfig::monitor::configure($in, $raw_X) or return;
+ $raw_X->write;
+ 'config_changed';
+}
+
+sub configure_resolution {
+ my ($in, $raw_X) = @_;
+
+ my $card = Xconfig::card::from_raw_X($raw_X);
+ my $monitor = Xconfig::monitor::from_raw_X($raw_X);
+ Xconfig::resolution_and_depth::configure($in, $raw_X, $card, $monitor) or return;
+ $raw_X->write;
+ 'config_changed';
+}
+
+
+sub configure_everything_auto_install {
+ my ($raw_X, $do_pkgs, $old_X, $options) = @_;
+
+ my $card = Xconfig::card::configure_auto_install($raw_X, $do_pkgs, $old_X, $options) or return;
+ my $monitor = Xconfig::monitor::configure_auto_install($raw_X, $old_X) or return;
+ Xconfig::screen::configure($raw_X, $card) or return;
+ my $resolution = Xconfig::resolution_and_depth::configure_auto_install($raw_X, $card, $monitor, $old_X);
+
+ export_to_install_X($card, $monitor, $resolution);
+ $raw_X->write;
+ symlinkf "../..$card->{prog}", "$::prefix/etc/X11/X" if $card->{server} !~ /Xpmac/;
+
+ any::runlevel($::prefix, $old_X->{xdm} ? 5 : 3);
+}
+
+sub configure_everything {
+ my ($in, $raw_X, $do_pkgs, $auto, $options) = @_;
+
+ my $ok = 1;
+ $ok &&= my $card = Xconfig::card::configure($in, $raw_X, $do_pkgs, $auto, $options);
+ $ok &&= my $monitor = Xconfig::monitor::configure($in, $raw_X, $auto);
+ $ok &&= Xconfig::screen::configure($raw_X, $card);
+ $ok &&= my $resolution = Xconfig::resolution_and_depth::configure($in, $raw_X, $card, $monitor, $auto);
+ $ok &&= Xconfig::test::test($in, $raw_X, $card, $auto);
+
+ $ok ||= $in->ask_yesorno('', _("Keep the changes?
+The current configuration is:
+
+%s", Xconfig::various::info($raw_X)));
+
+ if ($ok) {
+ export_to_install_X($card, $monitor, $resolution);
+ $raw_X->write;
+ symlinkf "../..$card->{prog}", "$::prefix/etc/X11/X" if $card->{server} !~ /Xpmac/;
+ }
+ Xconfig::various::choose_xdm($in, $auto);
+
+ $ok && 'config_changed';
+}
+
+
+sub export_to_install_X {
+ my ($card, $monitor, $resolution) = @_;
+
+ $::isInstall or return;
+
+ $::o->{X}{resolution_wanted} = $resolution->{X};
+ $::o->{X}{default_depth} = $resolution->{Depth};
+ $::o->{X}{bios_vga_mode} = $resolution->{bios};
+ $::o->{X}{monitor} = $monitor if $monitor->{manually_chosen};
+ $::o->{X}{card} = $monitor if $card->{manually_chosen};
+}
+
+
+#- most usefull XFree86-4.0.1 server options. Default values is the first ones.
+our @options_serverflags = (
+ 'DontZap' => [ "Off", "On" ],
+ 'DontZoom' => [ "Off", "On" ],
+ 'DisableVidModeExtension' => [ "Off", "On" ],
+ 'AllowNonLocalXvidtune' => [ "Off", "On" ],
+ 'DisableModInDev' => [ "Off", "On" ],
+ 'AllowNonLocalModInDev' => [ "Off", "On" ],
+ 'AllowMouseOpenFail' => [ "False", "True" ],
+ 'VTSysReq' => [ "Off", "On" ],
+ 'BlankTime' => [ "10", "5", "3", "15", "30" ],
+ 'StandByTime' => [ "20", "10", "6", "30", "60" ],
+ 'SuspendTime' => [ "30", "15", "9", "45", "90" ],
+ 'OffTime' => [ "40", "20", "12", "60", "120" ],
+ 'Pixmap' => [ "32", "24" ],
+ 'PC98' => [ "auto-detected", "False", "True" ],
+ 'NoPM' => [ "False", "True" ],
+);
+
+1;
diff --git a/perl-install/Xconfig/monitor.pm b/perl-install/Xconfig/monitor.pm
new file mode 100644
index 000000000..923fc8fb9
--- /dev/null
+++ b/perl-install/Xconfig/monitor.pm
@@ -0,0 +1,191 @@
+package Xconfig::monitor; #- $Id$
+
+use diagnostics;
+use strict;
+
+use detect_devices;
+use common;
+use any;
+use log;
+
+
+my $good_default_monitor = arch() !~ /ppc/ ? 'Generic|1024x768 @ 70 Hz' :
+ detect_devices::get_mac_model =~ /^iBook/ ? 'Apple|iBook 800x600' : 'Apple|iMac/PowerBook 1024x768';
+my $low_default_monitor = 'Generic|800x600 @ 56 Hz';
+
+my @VertRefresh_ranges = ("50-70", "50-90", "50-100", "40-150");
+
+my @HorizSync_ranges = (
+ "31.5",
+ "31.5-35.1",
+ "31.5-37.9",
+ "31.5-48.5",
+ "31.5-57.0",
+ "31.5-64.3",
+ "31.5-79.0",
+ "31.5-82.0",
+ "31.5-88.0",
+ "31.5-94.0",
+);
+
+
+sub from_raw_X {
+ my ($raw_X) = @_;
+
+ my $monitor = $raw_X->get_monitor;
+ if (!$monitor->{HorizSync}) {
+ put_in_hash($monitor, getinfoFromDDC());
+ }
+ $monitor;
+}
+
+sub configure {
+ my ($in, $raw_X, $auto) = @_;
+
+ my $monitor = from_raw_X($raw_X);
+ choose($in, $monitor, $auto) or return;
+ $raw_X->set_monitors($monitor);
+ $monitor;
+}
+
+sub configure_auto_install {
+ my ($raw_X, $old_X) = @_;
+
+ my $old_monitor = $old_X->{monitor} || {};
+ $old_monitor->{VertRefresh} ||= $old_monitor->{vsyncrange};
+ $old_monitor->{HorizSync} ||= $old_monitor->{hsyncrange};
+
+ my $monitor = from_raw_X($raw_X);
+ put_in_hash($monitor, $old_monitor);
+
+ my $monitors = monitors();
+ configure_automatic($monitor, $monitors) or put_in_hash($monitor, $monitors->{$low_default_monitor});
+ $raw_X->set_monitors($monitor);
+ $monitor;
+}
+
+sub choose {
+ my ($in, $monitor, $auto) = @_;
+
+ my $monitors = monitors();
+
+ configure_automatic($monitor, $monitors) and $auto and return 1;
+
+ my $merged_name = do {
+ if ($monitor->{VendorName} eq "Plug'n Play") {
+ $monitor->{VendorName};
+ } else {
+ my $merged_name = $monitor->{VendorName} . '|' . $monitor->{ModelName};
+
+ if (!exists $monitors->{$merged_name}) {
+ $merged_name = $monitor->{HorizSync} ? 'Custom' : $good_default_monitor;
+ }
+ }
+ };
+
+ $in->ask_from(_("Monitor"), _("Choose a monitor"),
+ [ { val => \$merged_name, separator => '|',
+ list => ['Custom', "Plug'n Play", sort keys %$monitors],
+ format => sub { $_[0] eq 'Custom' ? _("Custom") :
+ $_[0] eq "Plug'n Play" ? _("Plug'n Play") . " ($monitor->{ModelName})" :
+ $_[0] =~ /^Generic\|(.*)/ ? _("Generic") . "|$1" :
+ _("Vendor") . "|$_[0]" },
+ sort => 0 } ]) or return;
+
+ if ($merged_name eq "Plug'n Play") {
+ local $::noauto = 0; #- hey, you asked for plug'n play, so i do probe!
+ put_in_hash($monitor, getinfoFromDDC());
+ configure_automatic($monitor, $monitors);
+ $monitor->{VendorName} = "Plug'n Play";
+ } elsif ($merged_name eq 'Custom') {
+ $in->ask_from('',
+_("The two critical parameters are the vertical refresh rate, which is the rate
+at which the whole screen is refreshed, and most importantly the horizontal
+sync rate, which is the rate at which scanlines are displayed.
+
+It is VERY IMPORTANT that you do not specify a monitor type with a sync range
+that is beyond the capabilities of your monitor: you may damage your monitor.
+ If in doubt, choose a conservative setting."),
+ [ { val => \$monitor->{HorizSync}, list => \@HorizSync_ranges, label => _("Horizontal refresh rate"), not_edit => 0 },
+ { val => \$monitor->{VertRefresh}, list => \@VertRefresh_ranges, label => _("Vertical refresh rate"), not_edit => 0 } ]) or goto &choose;
+ delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'};
+ } else {
+ put_in_hash($monitor, $monitors->{$merged_name});
+ }
+ $monitor->{manually_chosen} = 1;
+ 1;
+}
+
+sub configure_automatic {
+ my ($monitor, $monitors) = @_;
+
+ if ($monitor->{EISA_ID}) {
+ log::l("EISA_ID: $monitor->{EISA_ID}");
+ if (my ($mon) = grep { lc($_->{EISA_ID}) eq $monitor->{EISA_ID} } values %$monitors) {
+ add2hash($monitor, $mon);
+ log::l("EISA_ID corresponds to: $monitor->{ModelName}");
+ }
+ }
+ my $merged_name = $monitor->{VendorName} . '|' . $monitor->{ModelName};
+
+ put_in_hash($monitor, $monitors->{$merged_name});
+
+ return $monitor->{HorizSync} && $monitor->{VertRefresh};
+}
+
+sub getinfoFromDDC {
+ my ($VideoRam, @l) = any::ddcxinfos() or return;
+
+ my @Modes;
+ local $_;
+ while (($_ = shift @l) ne "\n") {
+ my ($depth, $x, $y) = split;
+ $depth = int(log($depth) / log(2));
+
+ push @Modes, [ $x, $y, $depth ];
+ }
+
+ my ($h, $v, $size, @m) = @l;
+ {
+ VideoRam => $VideoRam,
+ HorizSync => first($h =~ /^(\S*)/),
+ VertRefresh => first($v =~ /^(\S*)/),
+ size => to_float($size),
+ if_($size =~ /EISA ID=(\S*)/, EISA_ID => lc($1), VendorName => "Plug'n Play"),
+ #- not-used-anymore Modes => \@Modes,
+ #- not-used-anymore ModeLines => join('', @m),
+ };
+}
+
+sub monitors {
+ readMonitorsDB("$ENV{SHARE_PATH}/ldetect-lst/MonitorsDB");
+}
+sub readMonitorsDB {
+ my ($file) = @_;
+
+ my (%monitors, %standard_monitors);
+
+ my $F = common::openFileMaybeCompressed($file);
+ local $_;
+ my $lineno = 0; while (<$F>) {
+ $lineno++;
+ s/\s+$//;
+ /^#/ and next;
+ /^$/ and next;
+
+ my @fields = qw(VendorName ModelName EISA_ID HorizSync VertRefresh dpms);
+ my @l = split /\s*;\s*/;
+
+ my %l; @l{@fields} = @l;
+ if ($monitors{$l{ModelName}}) {
+ my $i; for ($i = 0; $monitors{"$l{ModelName} ($i)"}; $i++) {}
+ $l{ModelName} = "$l{ModelName} ($i)";
+ }
+ $monitors{"$l{VendorName}|$l{ModelName}"} = \%l;
+ }
+ \%monitors;
+}
+
+
+1;
+
diff --git a/perl-install/Xconfig/parse.pm b/perl-install/Xconfig/parse.pm
index b61651ceb..d94c772c9 100644
--- a/perl-install/Xconfig/parse.pm
+++ b/perl-install/Xconfig/parse.pm
@@ -3,7 +3,7 @@ package Xconfig::parse; # $Id$
use diagnostics;
use strict;
-use MDK::Common;
+use common;
sub read_XF86Config {
@@ -55,8 +55,9 @@ sub raw_from_file { #- internal
if (/^$/) {
$comment .= "\n" if $comment;
next;
- } elsif (/^#\s+(.*)/) {
- $comment .= "# $1\n";
+ } elsif (/^#\W/) {
+ s/^#\s+/# /;
+ $comment .= "$_\n";
next;
}
@@ -89,8 +90,12 @@ sub raw_from_file { #- internal
my $comment_on_line;
s/(\s*#.*)/$comment_on_line = $1; ''/e;
+ if (/^$/) {
+ die "$line: weird";
+ }
+
(my $name, my $Option, $_) =
- /^Option\s*"(.*?)"(.*)/ ? ($1, 1, $2) : /^(\S+)(.*)/ ? ($1, 0, $2) : internal_error();
+ /^Option\s*"(.*?)"(.*)/ ? ($1, 1, $2) : /^(\S+)(.*)/ ? ($1, 0, $2) : internal_error($_);
my ($val) = /(\S.*)/;
my %e = (Option => $Option, commented => $commented, comment_on_line => $comment_on_line, pre_comment => $comment);
@@ -128,13 +133,13 @@ my %kind_names = (
Mouse => [ qw(DeviceName Protocol Device AlwaysCore Emulate3Buttons Emulate3Timeout) ], # Subsection in XInput
Keyboard => [ qw(Protocol Driver XkbModel XkbLayout XkbDisable) ],
Monitor => [ qw(Identifier VendorName ModelName HorizSync VertRefresh) ],
- Device => [ qw(Identifier VendorName BoardName Chipset Driver VideoRam Screen BusID) ],
+ Device => [ qw(Identifier VendorName BoardName Chipset Driver VideoRam Screen BusID DPMS power_saver) ],
Display => [ qw(Depth Modes) ], # Subsection in Device
Screen => [ qw(Identifier Driver Device Monitor DefaultColorDepth) ],
- InputDevice => [ qw(Identifier Driver Protocol Device XkbModel XkbLayout XkbDisable Emulate3Buttons Emulate3Timeout) ],
- ServerLayout => [ qw(Identifier Screen) ],
+ InputDevice => [ qw(Identifier Driver Protocol Device Type Mode XkbModel XkbLayout XkbDisable Emulate3Buttons Emulate3Timeout) ],
+ ServerLayout => [ qw(Identifier) ],
);
-my @want_string = qw(Identifier DeviceName VendorName ModelName BoardName Driver Device Chipset Monitor Protocol XkbModel XkbLayout);
+my @want_string = qw(Identifier DeviceName VendorName ModelName BoardName Driver Device Chipset Monitor Protocol XkbModel XkbLayout Load);
%kind_names = map_each { lc $::a => [ map { lc } @$::b ] } %kind_names;
@want_string = map { lc } @want_string;
diff --git a/perl-install/Xconfig/proprietary.pm b/perl-install/Xconfig/proprietary.pm
new file mode 100644
index 000000000..bd94aba13
--- /dev/null
+++ b/perl-install/Xconfig/proprietary.pm
@@ -0,0 +1,32 @@
+package Xconfig::proprietary; # $Id$
+
+use diagnostics;
+use strict;
+
+use common;
+
+
+sub install_matrox_hal {
+ my ($prefix) = @_;
+ my $tmpdir = "$prefix/root/tmp";
+
+ my $tar = "mgadrivers-2.0.tgz";
+ my $dir_in_tar = "mgadrivers";
+ my $dest_dir = "$prefix/usr/X11R6/lib/modules/drivers";
+
+ #- already installed
+ return if -e "$dest_dir/mga_hal_drv.o";
+
+ system("wget -O $tmpdir/$tar ftp://ftp.matrox.com/pub/mga/archive/linux/2002/$tar") if !-e "$tmpdir/$tar";
+ system("tar xzC $tmpdir -f $tmpdir/$tar");
+
+ my $src_dir = "$tmpdir/$dir_in_tar/xfree86/4.2.0/drivers";
+ foreach (all($src_dir)) {
+ my $src = "$src_dir/$_";
+ my $dest = "$dest_dir/$_";
+ rename $dest, "$dest.non_hal";
+ cp_af($src, $dest_dir);
+ }
+ rm_rf("$tmpdir/$tar");
+ rm_rf("$tmpdir/$dir_in_tar");
+}
diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm
new file mode 100644
index 000000000..bb23b8f95
--- /dev/null
+++ b/perl-install/Xconfig/resolution_and_depth.pm
@@ -0,0 +1,185 @@
+package Xconfig::resolution_and_depth; # $Id$
+
+use diagnostics;
+use strict;
+
+use Xconfig::card;
+use Xconfig::monitor;
+use common;
+
+
+our %depth2text = (
+ 8 => __("256 colors (8 bits)"),
+ 15 => __("32 thousand colors (15 bits)"),
+ 16 => __("65 thousand colors (16 bits)"),
+ 24 => __("16 million colors (24 bits)"),
+ 32 => __("4 billion colors (32 bits)"),
+);
+our @depths_available = ikeys(%depth2text);
+
+my %min_hsync4x_res = (
+ 640 => 31.5,
+ 800 => 35.1,
+ 1024 => 35.5,
+ 1152 => 44.0,
+ 1280 => 51.0,
+ 1400 => 65.5,
+ 1600 => 75.0,
+ 1920 => 90.0,
+ 2048 => 136.5,
+);
+
+my @bios_vga_modes = (
+ { bios => 769, X => 640, Y => 480, Depth => 8 },
+ { bios => 771, X => 800, Y => 600, Depth => 8 },
+ { bios => 773, X => 1024, Y => 768, Depth => 8 },
+ { bios => 775, X => 1280, Y => 1024, Depth => 8 },
+ { bios => 784, X => 640, Y => 480, Depth => 15 },
+ { bios => 787, X => 800, Y => 600, Depth => 15 },
+ { bios => 790, X => 1024, Y => 768, Depth => 15 },
+ { bios => 793, X => 1280, Y => 1024, Depth => 15 },
+ { bios => 785, X => 640, Y => 480, Depth => 16 },
+ { bios => 788, X => 800, Y => 600, Depth => 16 },
+ { bios => 791, X => 1024, Y => 768, Depth => 16 },
+ { bios => 794, X => 1280, Y => 1024, Depth => 16 },
+);
+
+sub size2default_resolution {
+ my ($size) = @_; #- size in inch
+
+ if (arch() =~ /ppc/) {
+ return "1024x768" if detect_devices::get_mac_model =~ /^PowerBook|^iMac/;
+ }
+
+ my %monitorSize2resolution = (
+ 13 => "640x480",
+ 14 => "800x600",
+ 15 => "800x600",
+ 16 => "1024x768",
+ 17 => "1024x768",
+ 18 => "1024x768",
+ 19 => "1280x1024",
+ 20 => "1280x1024",
+ 21 => "1600x1200",
+ 22 => "1600x1200",
+ );
+ $monitorSize2resolution{round($size)} || ($size < 13 ? "640x480" : "1600x1200");
+}
+
+sub allowed {
+ my ($card) = @_;
+
+ my ($prefered_depth, @depths, @resolutions, @resolution_and_depth);
+
+ my $using_xf4 = Xconfig::card::using_xf4($card);
+
+ if ($using_xf4 ? $card->{Driver} eq 'fbdev' : $card->{server} eq 'FBDev') {
+ push @resolution_and_depth, grep { $_->{Depth} == 16 } @bios_vga_modes;
+ } elsif ($using_xf4) {
+ if ($card->{use_DRI_GLX} || $card->{use_UTAH_GLX}) {
+ $prefered_depth = 16;
+ push @depths, 16;
+ push @depths, 24 if member($card->{Driver}, 'mga', 'tdfx', 'r128', 'radeon');
+ }
+ } else {
+ if ($card->{server} eq 'Sun24') { push @depths, 24, 8, 2 }
+ elsif ($card->{server} eq 'Sun') { push @depths, 8, 2 }
+ elsif ($card->{server} eq 'SunMono') { push @depths, 2 }
+ elsif ($card->{server} eq 'VGA16') { push @depths, 8; push @resolutions, '640x480' }
+ elsif ($card->{BoardName} =~ /SiS/) { push @depths, 24, 16, 8 }
+ elsif ($card->{BoardName} eq 'S3 Trio3D') { push @depths, 24, 16, 8 }
+ }
+ if (!@resolution_and_depth || @depths || @resolutions) {
+ @depths = grep { !($using_xf4 && /32/) } (our @depths_available) if !@depths;
+ @resolutions = @Xconfig::xfreeX::resolutions if !@resolutions;
+
+ push @resolution_and_depth,
+ map {
+ my $Depth = $_;
+ map { /(\d+)x(\d+)/; { X => $1, Y => $2, Depth => $Depth } } @resolutions;
+ } @depths;
+ }
+ $prefered_depth, @resolution_and_depth;
+}
+
+# ($card->{VideoRam} || ($card->{server} eq 'FBDev' ? 2048 : 32768))
+sub filter_using_VideoRam {
+ my ($VideoRam, @resolutions) = @_;
+ my $mem = 1024 * $VideoRam;
+ grep { $_->{X} * $_->{Y} * $_->{Depth}/8 <= $mem } @resolutions;
+
+}
+sub filter_using_HorizSync {
+ my ($HorizSync, @resolutions) = @_;
+ my $hsync = max(split(/[,-]/, $HorizSync));
+ grep { ($min_hsync4x_res{$_->{X}} || 0) <= $hsync } @resolutions;
+}
+
+sub choose {
+ my ($in, $default_resolution, @resolutions) = @_;
+
+ if (0 && $in->isa('interactive::gtk')) {
+ chooseResolutionsGtk($default_resolution, @resolutions);
+ } else {
+ $in->ask_from_listf(_("Resolutions"), "",
+ sub { "$_->{X}x$_->{Y} $_->{Depth}bpp" },
+ \@resolutions, $default_resolution || {});
+ }
+}
+
+
+sub choices {
+ my ($raw_X, $resolution_wanted, $card, $monitor) = @_;
+ $resolution_wanted ||= {};
+
+ my ($prefered_depth, @resolutions) = allowed($card);
+
+ @resolutions = filter_using_HorizSync($monitor->{HorizSync}, @resolutions) if $monitor->{HorizSync};
+ @resolutions = filter_using_VideoRam($card->{VideoRam}, @resolutions) if $card->{VideoRam};
+
+ my $x_res = do {
+ my $res = $resolution_wanted->{X} || size2default_resolution($monitor->{size});
+ my $x_res = first(split 'x', $res);
+ #- 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);
+
+ #- finding it in @resolutions (well @matching)
+ #- (that way, we check it exists, and we get field "bios" for fbdev)
+ my ($default_resolution) = grep { $_->{Depth} eq $Depth } @matching;
+
+ $default_resolution, @resolutions;
+}
+
+sub configure {
+ my ($in, $raw_X, $card, $monitor, $auto) = @_;
+
+ my ($default_resolution, @resolutions) = choices($raw_X, $raw_X->get_resolution, $card, $monitor);
+
+ $default_resolution = choose($in, $default_resolution, @resolutions) or return;
+ $raw_X->set_resolution($default_resolution);
+
+ $default_resolution;
+}
+
+sub configure_auto_install {
+ my ($raw_X, $card, $monitor, $old_X) = @_;
+
+ my $resolution_wanted = { X => $old_X->{resolution_wanted}, Depth => $old_X->{default_depth} };
+
+ my ($default_resolution) = choices($raw_X, $raw_X->get_resolution, $card, $monitor);
+ $default_resolution or die "you selected an unusable depth";
+
+ $raw_X->set_resolution($default_resolution);
+
+ $default_resolution;
+}
+
+1;
diff --git a/perl-install/Xconfig/screen.pm b/perl-install/Xconfig/screen.pm
new file mode 100644
index 000000000..761c5defd
--- /dev/null
+++ b/perl-install/Xconfig/screen.pm
@@ -0,0 +1,42 @@
+package Xconfig::screen; # $Id$
+
+use diagnostics;
+use strict;
+
+use common;
+
+
+sub configure {
+ my ($raw_X, $card) = @_;
+
+ my @devices = $raw_X->get_devices;
+ my @monitors = $raw_X->get_monitors;
+
+ if (@monitors < @devices) {
+ $raw_X->set_monitors(@monitors, ({}) x (@devices - @monitors));
+ @monitors = $raw_X->get_monitors;
+ }
+
+ if ($card->{server}) {
+ $raw_X->{xfree3}->set_screens({ Device => $devices[0]{Identifier}, Monitor => $monitors[0]{Identifier},
+ Driver => $Xconfig::card::serversdriver{$card->{server}} || internal_error("bad XFree3 server $card->{server}"),
+ });
+ } else {
+ @{$raw_X->{xfree3}} = ();
+ }
+
+ if ($card->{Driver}) {
+ my @sections = mapn {
+ my ($device, $monitor) = @_;
+ { Device => $device->{Identifier}, Monitor => $monitor->{Identifier} }
+ } \@devices, \@monitors;
+
+ $raw_X->{xfree4}->set_screens(@sections);
+ } else {
+ @{$raw_X->{xfree4}} = ();
+ }
+
+ 1;
+}
+
+1;
diff --git a/perl-install/Xconfig/test.pm b/perl-install/Xconfig/test.pm
new file mode 100644
index 000000000..4c011d175
--- /dev/null
+++ b/perl-install/Xconfig/test.pm
@@ -0,0 +1,140 @@
+package Xconfig::test; # $Id$
+
+use diagnostics;
+use strict;
+
+use Xconfig::card;
+use run_program;
+use common;
+use log;
+
+
+my $tmpconfig = "/tmp/Xconfig";
+
+
+sub xtest {
+ my ($display) = @_;
+ $::isStandalone ?
+ system("DISPLAY=$display /usr/X11R6/bin/xtest") == 0 :
+ c::Xtest($display);
+}
+
+sub test {
+ my ($in, $raw_X, $card, $auto) = @_;
+
+ Xconfig::card::check_bad_card($card) or return 1;
+ $in->ask_yesorno(_("Test of the configuration"), _("Do you want to test the configuration?"), 1) or return 1 if !$auto;
+
+
+ unlink "$::prefix/tmp/.X9-lock";
+
+ #- create a link from the non-prefixed /tmp/.X11-unix/X9 to the prefixed one
+ #- that way, you can talk to :9 without doing a chroot
+ #- but take care of non X11 install :-)
+ if (-d "/tmp/.X11-unix") {
+ symlinkf "$::prefix/tmp/.X11-unix/X9", "/tmp/.X11-unix/X9" if $::prefix;
+ } else {
+ symlinkf "$::prefix/tmp/.X11-unix", "/tmp/.X11-unix" if $::prefix;
+ }
+
+ #- ensure xfs is running
+ fuzzy_pidofs(qr/\bxfs\b/) or run_program::rooted($::prefix, "/etc/rc.d/init.d/xfs", "start");
+ fuzzy_pidofs(qr/\bxfs\b/) or die "xfs is not running";
+
+ my $f = $::testing ? $tmpconfig : "/etc/X11/XF86Config.test";
+ $raw_X->{Xconfig::card::using_xf4($card) ? 'xfree4' : 'xfree3'}->write("$::prefix/$f");
+
+ $ENV{HOME} || $::isInstall or die q($HOME is unset, so I don't know where to put my temporary files);
+ my $f_err = "$::prefix$ENV{HOME}/tmp/.drakx.Xoutput";
+ my $pid;
+ unless ($pid = fork) {
+ system("xauth add :9 . `mcookie`");
+ open STDERR, ">$f_err";
+ chroot $::prefix if $::prefix;
+ exec $card->{prog},
+ if_($card->{prog} !~ /Xsun/, "-xf86config", $f),
+ ":9" or c::_exit(0);
+ }
+
+ do { sleep 1 } until xtest(":9") || waitpid($pid, c::WNOHANG());
+
+ my $b = before_leaving { unlink $f_err };
+
+ if (!xtest(":9")) {
+ local $_;
+ local *F; open F, $f_err;
+ i: while (<F>) {
+ if (Xconfig::card::using_xf4($card)) {
+ if (/^\(EE\)/ && !/Disabling/ || /^Fatal\b/) {
+ my @msg = !/error/ && $_ ;
+ while (<F>) {
+ /reporting a problem/ and last;
+ push @msg, $_;
+ $in->ask_warn('', [ _("An error occurred:"), " ", @msg, _("\ntry to change some parameters") ]);
+ return 0;
+ }
+ }
+ } else {
+ if (/\b(error|not supported)\b/i) {
+ my @msg = !/error/ && $_ ;
+ while (<F>) {
+ /not fatal/ and last i;
+ /^$/ and last;
+ push @msg, $_;
+ }
+ $in->ask_warn('', [ _("An error occurred:"), " ", @msg, _("\ntry to change some parameters") ]);
+ return 0;
+ }
+ }
+ }
+ }
+
+ $::noShadow = 1;
+ local *F;
+ open F, "|perl 2>/dev/null";
+ print F "use lib qw(", join(' ', @INC), ");\n";
+ print F q{
+ require lang;
+ require my_gtk;
+ my_gtk->import(qw(:wrappers)); #- help perl_checker
+ use interactive::gtk;
+ use run_program;
+
+ $::prefix = "} . $::prefix . q{";
+ $::isStandalone = 1;
+
+ lang::bindtextdomain();
+
+ $ENV{DISPLAY} = ":9";
+
+ gtkset_background(200 * 257, 210 * 257, 210 * 257);
+ my ($h, $w) = Gtk::Gdk::Window->new_foreign(Gtk::Gdk->ROOT_WINDOW)->get_size;
+ $my_gtk::force_position = [ $w / 3, $h / 2.4 ];
+ $my_gtk::force_focus = 1;
+ my $text = Gtk::Label->new;
+ my $time = 8;
+ Gtk->timeout_add(1000, sub {
+ $text->set(_("Leaving in %d seconds", $time));
+ $time-- or Gtk->main_quit;
+ 1;
+ });
+
+ my $background = "/usr/share/pixmaps/backgrounds/linux-mandrake/XFdrake-image-test.jpg";
+ my $qiv = "/usr/bin/qiv";
+ run_program::rooted($::prefix, $qiv, "-y", $background)
+ if -r "$::prefix/$background" && -x "$::prefix/$qiv";
+
+ my $in = interactive::gtk->new;
+ $in->exit($in->ask_yesorno('', [ _("Is this the correct setting?"), $text ], 0) ? 0 : 222);
+ };
+ my $rc = close F;
+ my $err = $?;
+
+ unlink "$::prefix/$f", "$::prefix/$f-4";
+ unlink "/tmp/.X11-unix/X9" if $::prefix;
+ kill 2, $pid;
+ $::noShadow = 0;
+
+ $rc || $err == 222 << 8 or $in->ask_warn('', _("An error occurred, try to change some parameters"));
+ $rc;
+}
diff --git a/perl-install/Xconfig/various.pm b/perl-install/Xconfig/various.pm
new file mode 100644
index 000000000..1c2d1ae73
--- /dev/null
+++ b/perl-install/Xconfig/various.pm
@@ -0,0 +1,58 @@
+package Xconfig::various; # $Id$
+
+use diagnostics;
+use strict;
+
+use Xconfig::card;
+use common;
+use any;
+
+
+sub show_info {
+ my ($in, $X) = @_;
+ $in->ask_warn('', info($X));
+}
+
+sub info {
+ my ($raw_X, $card) = @_;
+ my $info;
+ my $xf_ver = Xconfig::card::using_xf4($card) ? "4.2.0" : "3.3.6";
+ my $title = $card->{use_DRI_GLX} || $card->{use_UTAH_GLX} ?
+ _("XFree %s with 3D hardware acceleration", $xf_ver) : _("XFree %s", $xf_ver);
+ my $keyboard = eval { $raw_X->get_keyboard } || {};
+ my $monitor = eval { $raw_X->get_monitor } || {};
+ my $device = eval { $raw_X->get_device } || {};
+ my $mouse = eval { first($raw_X->get_mice) } || {};
+
+ $info .= _("Keyboard layout: %s\n", $keyboard->{XkbLayout});
+ $info .= _("Mouse type: %s\n", $mouse->{Protocol});
+ $info .= _("Mouse device: %s\n", $mouse->{Device}) if $::expert;
+ $info .= _("Monitor: %s\n", $monitor->{ModelName});
+ $info .= _("Monitor HorizSync: %s\n", $monitor->{HorizSync}) if $::expert;
+ $info .= _("Monitor VertRefresh: %s\n", $monitor->{VertRefresh}) if $::expert;
+ $info .= _("Graphics card: %s\n", $device->{VendorName} . ' '. $device->{BoardName});
+ $info .= _("Graphics memory: %s kB\n", $device->{VideoRam}) if $device->{VideoRam};
+ if (my $resolution = eval { $raw_X->get_resolution }) {
+ $info .= _("Color depth: %s\n", translate($Xconfig::xfreeX::depths{$resolution->{Depth}}));
+ $info .= _("Resolution: %s\n", join('x', @$resolution{'X', 'Y'}));
+ }
+ $info .= _("XFree86 server: %s\n", $card->{server}) if $card->{server};
+ $info .= _("XFree86 driver: %s\n", $device->{Driver}) if $device->{Driver};
+ "$title\n\n$info";
+}
+
+sub choose_xdm {
+ my ($in, $auto) = @_;
+ my $xdm = $::isStandalone ? any::runlevel($::prefix) : 1;
+
+ if (!$auto || $::isStandalone) {
+ $in->set_help('configureXxdm') if !$::isStandalone;
+
+ $xdm = $in->ask_yesorno(_("Graphical interface at startup"),
+_("I can setup your computer to automatically start the graphical interface (XFree) upon booting.
+Would you like XFree to start when you reboot?"), $xdm) or return
+ }
+ any::runlevel($::prefix, $xdm ? 5 : 3);
+}
+
+1;
diff --git a/perl-install/Xconfig/xfree.pm b/perl-install/Xconfig/xfree.pm
index 43c4fe885..69c1b307e 100644
--- a/perl-install/Xconfig/xfree.pm
+++ b/perl-install/Xconfig/xfree.pm
@@ -3,22 +3,24 @@ package Xconfig::xfree; # $Id$
use diagnostics;
use strict;
-use MDK::Common;
+use common;
use Xconfig::parse;
use Xconfig::xfree3;
use Xconfig::xfree4;
use log;
+#- files are optional
sub read {
- my ($class) = @_;
- bless { xfree3 => Xconfig::xfree3->read,
- xfree4 => Xconfig::xfree4->read }, $class;
+ my ($class, $xfree3_file, $xfree4_file) = @_;
+ bless { xfree3 => Xconfig::xfree3->read($xfree3_file),
+ xfree4 => Xconfig::xfree4->read($xfree4_file) }, $class;
}
+#- files are optional
sub write {
- my ($both) = @_;
- $both->{xfree3}->write;
- $both->{xfree4}->write;
+ my ($both, $xfree3_file, $xfree4_file) = @_;
+ $both->{xfree3}->write($xfree3_file);
+ $both->{xfree4}->write($xfree4_file);
}
sub empty_config {
@@ -32,8 +34,18 @@ sub set_keyboard { set_both('set_keyboard', @_) }
sub get_mice { get_both('get_mice', @_) }
sub set_mice { set_both('set_mice', @_) }
+sub get_resolution { get_both('get_resolution', @_) }
+sub set_resolution { set_both('set_resolution', @_) }
+
+sub get_device { get_both('get_device', @_) }
+sub get_devices { get_both('get_devices', @_) }
+sub set_devices { set_both('set_devices', @_) }
+sub set_wacoms { set_both('set_wacoms', @_) }
+sub get_monitor { get_both('get_monitor', @_) }
+sub get_monitors { get_both('get_monitors', @_) }
+sub set_monitors { set_both('set_monitors', @_) }
#-##############################################################################
#- helpers
@@ -43,36 +55,51 @@ sub get_both {
my @l3 = $both->{xfree3}->$getter;
my @l4 = $both->{xfree4}->$getter;
- my @r = mapn {
+ merge_values(\@l3, \@l4);
+}
+sub set_both {
+ my ($setter, $both, @l) = @_;
+
+ $both->{xfree3}->$setter(@l);
+ $both->{xfree4}->$setter(@l);
+}
+
+sub merge_values {
+ my ($l3, $l4) = @_;
+
+ sub merge_values__hashes {
my ($h3, $h4) = @_;
+ $h3 || $h4 or return;
+ $h3 or return $h4;
+ $h4 or return $h3;
+
my %h = %$h4;
foreach (keys %$h3) {
- if (exists $h{$_}) {
- my $s4 = join(", ", deref_array($h{$_}));
- my $s3 = join(", ", deref_array($h3->{$_}));
- my $s3_ = join(", ", map { qq("$_") } deref_array($h3->{$_}));
- if ($s4 eq $s3_) {
- #- keeping the non-double-quoted value
- $h{$_} = $h3->{$_};
+ if (exists $h{$_}) {
+ if (ref($h{$_}) eq 'HASH' && ref($h3->{$_}) eq 'HASH') {
+ #- needed for "Options" of Devices
+ $h{$_} = +{ %{$h3->{$_}}, %{$h{$_}} };
} else {
- $s4 eq $s3 or log::l(qq(XFree: conflicting value for $_, "$s4" and "$s3" are different));
+ my $s4 = join(", ", deref_array($h{$_}));
+ my $s3 = join(", ", deref_array($h3->{$_}));
+ my $s3_ = join(", ", map { qq("$_") } deref_array($h3->{$_}));
+ if ($s4 eq $s3_) {
+ #- keeping the non-double-quoted value
+ $h{$_} = $h3->{$_};
+ } else {
+ $s4 eq $s3 or log::l(qq(XFree: conflicting value for $_, "$s4" and "$s3" are different));
+ }
}
} else {
$h{$_} = $h3->{$_};
}
}
\%h;
- } \@l3, \@l4;
+ }
- @r == 1 ? $r[0] : @r;
-}
-sub set_both {
- my ($setter, $both, @l) = @_;
+ my @r = mapn(\&merge_values__hashes, $l3, $l4);
- $both->{xfree3}->$setter(@l);
- $both->{xfree4}->$setter(@l);
+ @r == 1 ? $r[0] : @r;
}
-
-
1;
diff --git a/perl-install/Xconfig/xfree3.pm b/perl-install/Xconfig/xfree3.pm
index 7b2081dfc..106f14ed8 100644
--- a/perl-install/Xconfig/xfree3.pm
+++ b/perl-install/Xconfig/xfree3.pm
@@ -3,12 +3,13 @@ package Xconfig::xfree3; # $Id$
use diagnostics;
use strict;
-use MDK::Common;
+use common;
use Xconfig::parse;
use Xconfig::xfreeX;
our @ISA = 'Xconfig::xfreeX';
+sub name { 'xfree3' }
sub config_file { '/etc/X11/XF86Config' }
@@ -16,7 +17,6 @@ sub get_keyboard_section {
my ($raw_X) = @_;
return $raw_X->get_Section('Keyboard') or die "no keyboard section";
}
-
sub new_keyboard_section {
my ($raw_X) = @_;
return $raw_X->add_Section('Keyboard', { Protocol => { val => 'Standard' } });
@@ -44,13 +44,205 @@ sub new_mouse_sections {
if ($nb_new == 1) {
$main;
} else {
- my @l = map { { DeviceName => { val => "Mouse$_" }, AlwaysCore => {} } } (2 .. $nb_new);
+ my @l = map { { AlwaysCore => {} } } (2 .. $nb_new);
$XInput ||= $raw_X->add_Section('XInput', {});
$XInput->{Mouse} = [ map { { l => $_ } } @l ];
$main, @l;
}
}
+sub set_wacoms {
+ my ($raw_X, @wacoms) = @_;
+
+ my %Modes = (Stylus => 'Absolute', Erasor => 'Absolute', Cursor => 'Relative');
+
+ my $XInput = $raw_X->get_Section('XInput');
+ if ($XInput) {
+ delete $XInput->{"Wacom$_"} foreach keys %Modes;
+ $raw_X->remove_Section('XInput') if !@wacoms && $XInput && !%$XInput;
+ }
+ #- only wacom is handled in XFree 3
+ my ($wacom) = @wacoms or return;
+
+ $XInput ||= $raw_X->add_Section('XInput', {});
+ foreach (keys %Modes) {
+ $XInput->{"Wacom$_"} = [ { l => { Port => { val => qq("$wacom->{Device}") },
+ Mode => { val => $Modes{$_} },
+ if_($wacom->{USB}, USB => {}),
+ AlwaysCore => {} } } ];
+ }
+}
+
+sub depths { 8, 15, 16, 24, 32 }
+sub set_resolution {
+ my ($raw_X, $resolution, $Screen) = @_;
+ $Screen ||= $raw_X->get_default_screen or return {};
+
+ $resolution = +{ %$resolution };
+
+ #- use framebuffer if Screen is
+ $resolution->{fbdev} = 1 if val($Screen->{Driver}) eq 'fbdev';
+
+ $raw_X->SUPER::set_resolution($resolution, $Screen);
+}
+
+sub get_device_section_fields {
+ qw(VendorName BoardName Chipset VideoRam); #-);
+}
+
+sub default_ModeLine {
+ my ($raw_X) = @_;
+ $raw_X->SUPER::default_ModeLine . our $default_ModeLine;
+}
+
+sub new_device_sections {
+ my ($raw_X, $nb_new) = @_;
+ my @l = $raw_X->SUPER::new_device_sections($nb_new);
+ $_->{power_saver} = { Option => 1 } foreach @l;
+ @l;
+}
+
sub set_Option {}
+
+sub val {
+ my ($ref) = @_;
+ $ref && $ref->{val};
+}
+
+our $default_ModeLine = <<'END';
+ # This is a set of standard mode timings. Modes that are out of monitor spec
+ # are automatically deleted by the server (provided the HorizSync and
+ # VertRefresh lines are correct), so there's no immediate need to
+ # delete mode timings (unless particular mode timings don't work on your
+ # monitor). With these modes, the best standard mode that your monitor
+ # and video card can support for a given resolution is automatically
+ # used.
+
+ # 640x400 @ 70 Hz, 31.5 kHz hsync
+ ModeLine "640x400" 25.175 640 664 760 800 400 409 411 450
+ # 640x480 @ 60 Hz, 31.5 kHz hsync
+ ModeLine "640x480" 25.175 640 664 760 800 480 491 493 525
+ # 800x600 @ 56 Hz, 35.15 kHz hsync
+ ModeLine "800x600" 36 800 824 896 1024 600 601 603 625
+ # 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync
+ ModeLine "1024x768" 44.9 1024 1048 1208 1264 768 776 784 817 Interlace
+
+ # 640x400 @ 85 Hz, 37.86 kHz hsync
+ ModeLine "640x400" 31.5 640 672 736 832 400 401 404 445 -HSync +VSync
+ # 640x480 @ 75 Hz, 37.50 kHz hsync
+ ModeLine "640x480" 31.5 640 656 720 840 480 481 484 500 -HSync -VSync
+ # 800x600 @ 60 Hz, 37.8 kHz hsync
+ ModeLine "800x600" 40 800 840 968 1056 600 601 605 628 +hsync +vsync
+
+ # 640x480 @ 85 Hz, 43.27 kHz hsync
+ ModeLine "640x480" 36 640 696 752 832 480 481 484 509 -HSync -VSync
+ # 1152x864 @ 89 Hz interlaced, 44 kHz hsync
+ ModeLine "1152x864" 65 1152 1168 1384 1480 864 865 875 985 Interlace
+
+ # 800x600 @ 72 Hz, 48.0 kHz hsync
+ ModeLine "800x600" 50 800 856 976 1040 600 637 643 666 +hsync +vsync
+ # 1024x768 @ 60 Hz, 48.4 kHz hsync
+ ModeLine "1024x768" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync
+
+ # 640x480 @ 100 Hz, 53.01 kHz hsync
+ ModeLine "640x480" 45.8 640 672 768 864 480 488 494 530 -HSync -VSync
+ # 1152x864 @ 60 Hz, 53.5 kHz hsync
+ ModeLine "1152x864" 89.9 1152 1216 1472 1680 864 868 876 892 -HSync -VSync
+ # 800x600 @ 85 Hz, 55.84 kHz hsync
+ ModeLine "800x600" 60.75 800 864 928 1088 600 616 621 657 -HSync -VSync
+
+ # 1024x768 @ 70 Hz, 56.5 kHz hsync
+ ModeLine "1024x768" 75 1024 1048 1184 1328 768 771 777 806 -hsync -vsync
+ # 1280x1024 @ 87 Hz interlaced, 51 kHz hsync
+ ModeLine "1280x1024" 80 1280 1296 1512 1568 1024 1025 1037 1165 Interlace
+
+ # 800x600 @ 100 Hz, 64.02 kHz hsync
+ ModeLine "800x600" 69.65 800 864 928 1088 600 604 610 640 -HSync -VSync
+ # 1024x768 @ 76 Hz, 62.5 kHz hsync
+ ModeLine "1024x768" 85 1024 1032 1152 1360 768 784 787 823
+ # 1152x864 @ 70 Hz, 62.4 kHz hsync
+ ModeLine "1152x864" 92 1152 1208 1368 1474 864 865 875 895
+ # 1280x1024 @ 61 Hz, 64.2 kHz hsync
+ ModeLine "1280x1024" 110 1280 1328 1512 1712 1024 1025 1028 1054
+ # 1400x1050 @ 60 Hz, 65.5 kHz
+ ModeLine "1400x1050" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +HSync +VSync
+
+ # 1024x768 @ 85 Hz, 70.24 kHz hsync
+ ModeLine "1024x768" 98.9 1024 1056 1216 1408 768 782 788 822 -HSync -VSync
+ # 1152x864 @ 78 Hz, 70.8 kHz hsync
+ ModeLine "1152x864" 110 1152 1240 1324 1552 864 864 876 908
+
+ # 1280x1024 @ 70 Hz, 74.59 kHz hsync
+ ModeLine "1280x1024" 126.5 1280 1312 1472 1696 1024 1032 1040 1068 -HSync -VSync
+ # 1600x1200 @ 60Hz, 75.00 kHz hsync
+ ModeLine "1600x1200" 162 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync
+ # 1152x864 @ 84 Hz, 76.0 kHz hsync
+ ModeLine "1152x864" 135 1152 1464 1592 1776 864 864 876 908
+
+ # 1280x1024 @ 75 Hz, 79.98 kHz hsync
+ ModeLine "1280x1024" 135 1280 1296 1440 1688 1024 1025 1028 1066 +HSync +VSync
+
+ # 1024x768 @ 100Hz, 80.21 kHz hsync
+ ModeLine "1024x768" 115.5 1024 1056 1248 1440 768 771 781 802 -HSync -VSync
+ # 1400x1050 @ 75 Hz, 82.2 kHz hsync
+ ModeLine "1400x1050" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +HSync +VSync
+
+ # 1600x1200 @ 70 Hz, 87.50 kHz hsync
+ ModeLine "1600x1200" 189 1600 1664 1856 2160 1200 1201 1204 1250 -HSync -VSync
+ # 1152x864 @ 100 Hz, 89.62 kHz hsync
+ ModeLine "1152x864" 137.65 1152 1184 1312 1536 864 866 885 902 -HSync -VSync
+ # 1280x1024 @ 85 Hz, 91.15 kHz hsync
+ ModeLine "1280x1024" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +HSync +VSync
+ # 1600x1200 @ 75 Hz, 93.75 kHz hsync
+ ModeLine "1600x1200" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync
+ # 1600x1200 @ 85 Hz, 105.77 kHz hsync
+ ModeLine "1600x1200" 220 1600 1616 1808 2080 1200 1204 1207 1244 +HSync +VSync
+ # 1600x1200 @ 85 Hz, 106.3 kHz hsync
+ ModeLine "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync
+ # 1280x1024 @ 100 Hz, 107.16 kHz hsync
+ ModeLine "1280x1024" 181.75 1280 1312 1440 1696 1024 1031 1046 1072 -HSync -VSync
+
+ # 1800x1440 @ 64Hz, 96.15 kHz hsync
+ ModeLine "1800X1440" 230 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync
+ # 1800x1440 @ 70Hz, 104.52 kHz hsync
+ ModeLine "1800X1440" 250 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync
+
+ # 1920x1440 @ 60 Hz, 90.0 kHz hsync
+ ModeLine "1920x1440" 234.0 1920 2048 2256 2600 1440 1441 1444 1500 -HSync +VSync
+ # 1920x1440 @ 75 Hz, 112.5kHz hsync
+ ModeLine "1920x1440" 297.0 1920 2064 2288 2640 1440 1441 1444 1500 -HSync +VSync
+
+ # 512x384 @ 78 Hz, 31.50 kHz hsync
+ ModeLine "512x384" 20.160 512 528 592 640 384 385 388 404 -HSync -VSync
+ # 512x384 @ 85 Hz, 34.38 kHz hsync
+ ModeLine "512x384" 22 512 528 592 640 384 385 388 404 -HSync -VSync
+
+
+ # Low-res Doublescan modes
+ # If your chipset does not support doublescan, you get a 'squashed'
+ # resolution like 320x400.
+
+ # 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio
+ ModeLine "320x200" 12.588 320 336 384 400 200 204 205 225 Doublescan
+ # 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio
+ ModeLine "320x240" 12.588 320 336 384 400 240 245 246 262 Doublescan
+ # 320x240 @ 72 Hz, 36.5 kHz hsync
+ ModeLine "320x240" 15.750 320 336 384 400 240 244 246 262 Doublescan
+ # 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio
+ ModeLine "400x300" 18 400 416 448 512 300 301 302 312 Doublescan
+ # 400x300 @ 60 Hz, 37.8 kHz hsync
+ ModeLine "400x300" 20 400 416 480 528 300 301 303 314 Doublescan
+ # 400x300 @ 72 Hz, 48.0 kHz hsync
+ ModeLine "400x300" 25 400 424 488 520 300 319 322 333 Doublescan
+ # 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio
+ ModeLine "480x300" 21.656 480 496 536 616 300 301 302 312 Doublescan
+ # 480x300 @ 60 Hz, 37.8 kHz hsync
+ ModeLine "480x300" 23.890 480 496 576 632 300 301 303 314 Doublescan
+ # 480x300 @ 63 Hz, 39.6 kHz hsync
+ ModeLine "480x300" 25 480 496 576 632 300 301 303 314 Doublescan
+ # 480x300 @ 72 Hz, 48.0 kHz hsync
+ ModeLine "480x300" 29.952 480 504 584 624 300 319 322 333 Doublescan
+END
+
1;
diff --git a/perl-install/Xconfig/xfree4.pm b/perl-install/Xconfig/xfree4.pm
index a160da458..c65245b75 100644
--- a/perl-install/Xconfig/xfree4.pm
+++ b/perl-install/Xconfig/xfree4.pm
@@ -3,12 +3,13 @@ package Xconfig::xfree4; # $Id$
use diagnostics;
use strict;
-use MDK::Common;
+use common;
use Xconfig::parse;
use Xconfig::xfree;
our @ISA = 'Xconfig::xfreeX';
+sub name { 'xfree4' }
sub config_file { '/etc/X11/XF86Config-4' }
@@ -23,8 +24,8 @@ sub new_keyboard_section {
my $raw_kbd = { Identifier => { val => 'Keyboard1' }, Driver => { val => 'Keyboard' } };
$raw_X->add_Section('InputDevice', $raw_kbd);
- my $ServerLayout = get_ServerLayout($raw_X);
- push @{$ServerLayout->{InputDevice}}, { val => '"Keyboard1" "CoreKeyboard"' };
+ my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
+ push @$layout, { val => '"Keyboard1" "CoreKeyboard"' };
$raw_kbd;
}
@@ -53,6 +54,85 @@ sub new_mouse_sections {
@l;
}
+sub set_wacoms {
+ my ($raw_X, @wacoms) = @_;
+ $raw_X->remove_InputDevices('wacom');
+
+ my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= [];
+ @$layout = grep { $_->{val} !~ /^"(Stylus|Eraser|Cursor)/ } @$layout;
+
+ @wacoms or return;
+
+ my %Modes = (Stylus => 'Absolute', Erasor => 'Absolute', Cursor => 'Relative');
+
+ each_index {
+ my ($wacom) = @_;
+ foreach (keys %Modes) {
+ my $h = { Identifier => { val => $_ . ($::i + 1) },
+ Driver => { val => 'wacom' },
+ Style => { val => lc $_, Option => 1 },
+ Device => { val => $wacom->{Device}, Option => 1 },
+ Mode => { val => $Modes{$_}, Option => 1 },
+ if_($wacom->{USB}, USB => { Option => 1 })
+ };
+ $raw_X->add_Section('InputDevice', $h);
+ push @$layout, { val => qq("$_$::i" "AlwaysCore") };
+ }
+ } @wacoms;
+}
+
+sub set_monitors {
+ my ($raw_X, @monitors) = @_;
+
+ @monitors = map {
+ my %monitor = %$_;
+ delete @monitor{'HorizSync', 'VertRefresh'} if $monitor{VendorName} eq "Plug'n Play";
+ \%monitor;
+ } @monitors;
+
+ $raw_X->SUPER::set_monitors(@monitors);
+}
+
+sub depths { 8, 15, 16, 24 }
+sub set_resolution {
+ my ($raw_X, $resolution, $Screen) = @_;
+ $Screen ||= $raw_X->get_default_screen or return {};
+
+ $resolution = +{ %$resolution };
+
+ #- use framebuffer if corresponding Device has Driver framebuffer
+ my $Device = $raw_X->get_Section_by_Identifier('Device', val($Screen->{Device})) or internal_error("no device named $Screen->{Device}");
+ $resolution->{fbdev} = 1 if val($Device->{Driver}) eq 'fbdev';
+
+ #- XFree4 doesn't like depth 32, silently replacing it with 24
+ $resolution->{Depth} = 24 if $resolution->{Depth} eq '32';
+ $raw_X->SUPER::set_resolution($resolution, $Screen);
+}
+
+sub get_device_section_fields {
+ qw(VendorName BoardName Driver VideoRam Screen BusID); #-);
+}
+
+sub new_device_sections {
+ my ($raw_X, $nb_new) = @_;
+ my @l = $raw_X->SUPER::new_device_sections($nb_new);
+ $_->{DPMS} = { Option => 1 } foreach @l;
+ @l;
+}
+
+sub new_screen_sections {
+ my ($raw_X, $nb_new) = @_;
+ my @l = $raw_X->SUPER::new_screen_sections($nb_new);
+ each_index { $_->{Identifier} = { val => "screen" . ($::i+1) } } @l;
+
+ get_ServerLayout($raw_X)->{Screen} = [
+ { val => qq("screen1") }, #-)
+ map { { val => sprintf('"screen%d" RightOf "screen%d"', $_-1, $_) } } (2 .. $nb_new)
+ ];
+
+ @l;
+}
+
sub set_Option {
my ($raw_X, $category, $node, @names) = @_;
@@ -68,11 +148,11 @@ sub set_Option {
#-##############################################################################
sub get_InputDevices {
my ($raw_X, $Driver) = @_;
- $raw_X->get_Sections('InputDevice', sub { $_[0]{Driver}{val} eq $Driver });
+ $raw_X->get_Sections('InputDevice', sub { val($_[0]{Driver}) eq $Driver });
}
sub remove_InputDevices {
my ($raw_X, $Driver) = @_;
- $raw_X->remove_Section('InputDevice', sub { $_[0]{Driver}{val} ne $Driver });
+ $raw_X->remove_Section('InputDevice', sub { val($_[0]{Driver}) ne $Driver });
}
sub get_ServerLayout {
@@ -81,4 +161,9 @@ sub get_ServerLayout {
$raw_X->add_Section('ServerLayout', { Identifier => { val => 'layout1' } });
}
+sub val {
+ my ($ref) = @_;
+ $ref && $ref->{val};
+}
+
1;
diff --git a/perl-install/Xconfig/xfreeX.pm b/perl-install/Xconfig/xfreeX.pm
index d782bca1d..f6aa17f78 100644
--- a/perl-install/Xconfig/xfreeX.pm
+++ b/perl-install/Xconfig/xfreeX.pm
@@ -3,8 +3,8 @@ package Xconfig::xfreeX; # $Id$
use diagnostics;
use strict;
-use MDK::Common;
use Xconfig::parse;
+use common;
use log;
@@ -27,11 +27,35 @@ sub write {
}
+my @monitor_fields = qw(VendorName ModelName HorizSync VertRefresh);
+sub get_monitors {
+ my ($raw_X) = @_;
+ my @raw_monitors = $raw_X->get_monitor_sections;
+ map { raw_export_section($_, [ 'Identifier', @monitor_fields ]) } @raw_monitors;
+}
+sub set_monitors {
+ my ($raw_X, @monitors) = @_;
+ my @raw_monitors = $raw_X->new_monitor_sections(int @monitors);
+ mapn {
+ my ($raw_monitor, $monitor) = @_;
+ raw_import_section($raw_monitor, $monitor, \@monitor_fields);
+ } \@raw_monitors, \@monitors;
+}
+sub get_monitor {
+ my ($raw_X) = @_;
+ my @l = $raw_X->get_monitors;
+ if (!@l) {
+ $raw_X->new_monitor_sections(1);
+ @l = $raw_X->get_monitors;
+ }
+ $l[0]
+}
+
my @keyboard_fields = qw(XkbLayout XkbModel XkbDisable);
sub get_keyboard {
my ($raw_X) = @_;
my $raw_kbd = $raw_X->get_keyboard_section;
- raw_export_section($raw_kbd, @keyboard_fields);
+ raw_export_section($raw_kbd, \@keyboard_fields);
}
sub set_keyboard {
my ($raw_X, $kbd) = @_;
@@ -45,7 +69,7 @@ my @mouse_fields = qw(Protocol Device ZAxisMapping Emulate3Buttons Emulate3Timeo
sub get_mice {
my ($raw_X) = @_;
my @raw_mice = $raw_X->get_mouse_sections;
- map { raw_export_section($_, @mouse_fields) } @raw_mice;
+ map { raw_export_section($_, \@mouse_fields) } @raw_mice;
}
sub set_mice {
my ($raw_X, @mice) = @_;
@@ -57,28 +81,177 @@ sub set_mice {
} \@raw_mice, \@mice;
}
+sub get_devices {
+ my ($raw_X) = @_;
+ my @raw_devices = $raw_X->get_device_sections;
+ map {
+ my $raw_device = $_;
+ my $device = raw_export_section($raw_device, [ 'Identifier', $raw_X->get_device_section_fields ]);
+ $device->{Options} = raw_export_section($raw_device, [ grep { (deref_array($raw_device->{$_}))[0]->{Option} } keys %$raw_device ]);
+ $device;
+ } @raw_devices;
+}
+sub set_devices {
+ my ($raw_X, @devices) = @_;
+ my @raw_devices = $raw_X->new_device_sections(int @devices);
+ mapn {
+ my ($raw_device, $device) = @_;
+ my %Options = %{$device->{Options} || {}};
+ add2hash(\%Options, $device->{'Options_' . $raw_X->name});
+ raw_import_section($raw_device, $device, [ $raw_X->get_device_section_fields ]);
+ raw_import_section($raw_device, \%Options);
+ $_->{Option} = 1 foreach map { deref_array($raw_device->{$_}) } keys %Options;
+ $raw_device->{''} = [ { post_comment => $device->{raw_LINES} } ] if $device->{raw_LINES};
+ } \@raw_devices, \@devices;
+}
+
+sub get_device {
+ my ($raw_X) = @_;
+ first(get_devices($raw_X));
+}
+
+sub get_default_screen {
+ my ($raw_X) = @_;
+ my @l = $raw_X->get_Sections('Screen');
+ my @m = grep { $_->{Identifier} && val($_->{Identifier}) eq 'screen1' ||
+ $_->{Driver} && val($_->{Driver}) =~ /svga|accel/ } @l;
+ first(@m ? @m : @l);
+}
+sub set_screens {
+ my ($raw_X, @screens) = @_;
+ my @raw_screens = $raw_X->new_screen_sections(int @screens);
+ mapn {
+ my ($raw_screen, $screen) = @_;
+ raw_import_section($raw_screen, $screen);
+ } \@raw_screens, \@screens;
+}
+
+sub get_modules {
+ my ($raw_X) = @_;
+ my $raw_Module = $raw_X->get_Section('Module') or return;
+ my $Module = raw_export_section($raw_Module, ['Load']);
+ @{$Module->{Load} || []};
+}
+sub add_load_module {
+ my ($raw_X, $module) = @_;
+ my $raw_Module = $raw_X->get_Section('Module') || $raw_X->new_module_section;
+
+ my %load_modules_comment = (
+ dbe => 'Double-Buffering Extension',
+ v4l => 'Video for Linux',
+ dri => 'direct rendering',
+ glx => '3D layer',
+ 'glx-3.so' => '3D layer',
+ );
+ my $comment = $load_modules_comment{$module};
+ push @{$raw_Module->{Load}}, { val => $module,
+ comment_on_line => $comment && " # $comment",
+ } if !member($module, $raw_X->get_modules);
+}
+sub remove_load_module {
+ my ($raw_X, $module) = @_;
+ my $raw_Module = $raw_X->get_Section('Module') or return;
+ if (my @l = grep { $_->{val} ne $module } @{$raw_Module->{Load}}) {
+ $raw_Module->{Load} = \@l;
+ } else {
+ $raw_X->remove_Section('Module');
+ }
+}
+sub set_load_module {
+ my ($raw_X, $module, $bool) = @_;
+ $bool ? add_load_module($raw_X, $module) : remove_load_module($raw_X, $module);
+}
+
+sub get_resolution {
+ my ($raw_X, $Screen) = @_;
+ $Screen ||= $raw_X->get_default_screen or return {};
+
+ my $depth = val($Screen->{DefaultColorDepth});
+ my ($Display) = grep { !$depth || val($_->{l}{Depth}) eq $depth } @{$Screen->{Display} || []} or return {};
+ val($Display->{l}{Modes}) =~ /(\d+)x(\d+)/ or return {};
+ { X => $1, Y => $2, Depth => val($Display->{l}{Depth}) };
+}
+
+sub set_resolution {
+ my ($raw_X, $resolution, $Screen) = @_;
+ $Screen ||= $raw_X->get_default_screen or internal_error('no screen');
+
+ $Screen->{DefaultColorDepth} = { val => $resolution->{Depth} };
+ $Screen->{Display} = [ map {
+ my $modes = do {
+ if ($resolution->{fbdev}) {
+ '"default"';
+ } else {
+ my @Modes = grep { /(\d+)x/ && $1 <= $resolution->{X} } reverse our @resolutions;
+ join(" ", map { qq("$_") } @Modes);
+ }
+ };
+ { l => { Depth => { val => $_ }, Modes => { val => $modes } } };
+ } $raw_X->depths ];
+}
+
#-##############################################################################
-#- helpers
+#- common to xfree3 and xfree4
#-##############################################################################
-sub raw_export_section_name {
- my ($section, $name) = @_;
- my $h = $section->{$name} or return;
+sub default_ModeLine { our $default_ModeLine }
+
+
+sub get_device_sections {
+ my ($raw_X) = @_;
+ $raw_X->get_Sections('Device');
+}
+sub new_device_sections {
+ my ($raw_X, $nb_new) = @_;
+ $raw_X->remove_Section('Device');
+ map { $raw_X->add_Section('Device', { Identifier => { val => "device$_" } }) } (1 .. $nb_new);
+}
+
+sub get_monitor_sections {
+ my ($raw_X) = @_;
+ $raw_X->get_Sections('Monitor');
+}
+sub new_monitor_sections {
+ my ($raw_X, $nb_new) = @_;
+ my $ModeLine = ModeLine_from_string(qq(Section "Monitor"\n) . $raw_X->default_ModeLine . qq(EndSection\n));
+ $raw_X->remove_Section('Monitor');
+ map { $raw_X->add_Section('Monitor', { Identifier => { val => "monitor$_" }, ModeLine => $ModeLine }) } (1 .. $nb_new);
+}
+
+sub new_screen_sections {
+ my ($raw_X, $nb_new) = @_;
+ $raw_X->remove_Section('Screen');
+ map { $raw_X->add_Section('Screen', {}) } (1 .. $nb_new);
+}
- my @l = map { if_(!$_->{commented}, $_->{val}) } deref_array($h) or return;
- $name => (ref($h) eq 'ARRAY' ? \@l : $l[0]);
+sub new_module_section {
+ my ($raw_X) = @_;
+ return $raw_X->add_Section('Module', {});
}
+
+#-##############################################################################
+#- helpers
+#-##############################################################################
sub raw_export_section {
- my ($section, @fields) = @_;
- my %h = map { raw_export_section_name($section, $_) } @fields;
+ my ($section, $fields) = @_;
+
+ my $export_name = sub {
+ my ($name) = @_;
+ my $h = $section->{$name} or return;
+
+ my @l = map { if_(!$_->{commented}, $_->{val}) } deref_array($h) or return;
+ $name => (ref($h) eq 'ARRAY' ? \@l : $l[0]);
+ };
+
+ my %h = map { $export_name->($_) } @$fields;
\%h;
}
sub raw_import_section {
- my ($section, $h) = @_;
- foreach (keys %$h) {
- my @l = map { { val => $_ } } deref_array($h->{$_});
+ my ($section, $h, $fields) = @_;
+ foreach ($fields ? grep { exists $h->{$_} } @$fields : keys %$h) {
+ my @l = map { ref($_) eq 'HASH' ? $_ : { val => $_ } } deref_array($h->{$_});
$section->{$_} = (ref($h->{$_}) eq 'ARRAY' ? \@l : $l[0]);
}
}
@@ -113,9 +286,29 @@ sub get_Section {
@l > 1 and log::l("Xconfig: found more than one Section $Section");
$l[0];
}
+sub get_Section_by_Identifier {
+ my ($raw_X, $Section, $Identifier) = @_;
+ my @l = get_Sections($raw_X, $Section, sub { val($_[0]{Identifier}) eq $Identifier });
+ @l > 1 and die "more than one Section $Section has Identifier $Identifier";
+ $l[0];
+}
+
+sub val {
+ my ($ref) = @_;
+ $ref && $ref->{val};
+}
+
+sub ModeLine_from_string {
+ my ($s) = @_;
+ my $raw_X_for_ModeLine = Xconfig::parse::read_XF86Config_from_string($s);
+ get_Section($raw_X_for_ModeLine, 'Monitor')->{ModeLine};
+}
+
-our $default_header = <<'END';
+our @resolutions = ('640x480', '800x600', '1024x768', (arch() =~ /ppc/ ? '1152x864' : '1152x768'), '1280x1024', '1400x1050', '1600x1200', '1920x1440', '2048x1536');
+
+our $default_header = << 'END';
# File generated by XFdrake.
# **********************************************************************
@@ -137,6 +330,38 @@ Section "ServerFlags"
EndSection
END
+our $default_ModeLine = arch() =~ /ppc/ ? << 'END_PPC' : << 'END';
+ # Apple iMac modes
+ ModeLine "1024x768" 78.525 1024 1049 1145 1312 768 769 772 800 +hsync +vsync
+ ModeLine "800x600" 62.357 800 821 901 1040 600 601 604 632 +hsync +vsync
+ ModeLine "640x480" 49.886 640 661 725 832 480 481 484 514 +hsync +vsync
+ # Apple monitors tend to do 832x624
+ ModeLine "832x624" 57 832 876 940 1152 624 625 628 667 -hsync -vsync
+ # Apple PowerBook G3
+ ModeLine "800x600" 100 800 816 824 840 600 616 624 640 -hsync -vsync
+ # Apple TI Powerbook
+ ModeLine "1152x768" 78.741 1152 1173 1269 1440 768 769 772 800 +vsync +vsync
+ # Pismo Firewire G3
+ ModeLine "1024x768" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync
+ # iBook2
+ ModeLine "1024x768" 65 1024 1048 1184 1344 768 771 777 806 -hsync -vsync
+ # 17" Apple Studio Display
+ ModeLine "1024x768" 112.62 1024 1076 1248 1420 768 768 780 808 +hsync +vsync
+ # HiRes Apple Studio Display
+ ModeLine "1280x1024" 135 1280 1288 1392 1664 1024 1027 1030 1064
+ # Another variation
+ ModeLine "1280x1024" 134.989 1280 1317 1429 1688 1024 1025 1028 1066 +hsync +vsync
+END_PPC
+ # Sony Vaio C1(X,XS,VE,VN)?
+ # 1024x480 @ 85.6 Hz, 48 kHz hsync
+ ModeLine "1024x480" 65.00 1024 1032 1176 1344 480 488 494 563 -hsync -vsync
+
+ # TV fullscreen mode or DVD fullscreen output.
+ # 768x576 @ 79 Hz, 50 kHz hsync
+ ModeLine "768x576" 50.00 768 832 846 1000 576 590 595 630
+ # 768x576 @ 100 Hz, 61.6 kHz hsync
+ ModeLine "768x576" 63.07 768 800 960 1024 576 578 590 616
+END
1;