diff options
author | Mystery Man <unknown@mandriva.org> | 2002-08-29 08:27:03 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2002-08-29 08:27:03 +0000 |
commit | e3000d1c3652d63caebb334ab96251875e875b5c (patch) | |
tree | f1011fca62406be25bdce4ba865d3c0cf9d933e1 /perl-install/Xconfig | |
parent | 71180d5532cd2fe1853cc32d8826a04644e2ec08 (diff) | |
download | drakx-backup-do-not-use-1_1_9_25mdk.tar drakx-backup-do-not-use-1_1_9_25mdk.tar.gz drakx-backup-do-not-use-1_1_9_25mdk.tar.bz2 drakx-backup-do-not-use-1_1_9_25mdk.tar.xz drakx-backup-do-not-use-1_1_9_25mdk.zip |
This commit was manufactured by cvs2svn to create tag 'V1_1_9_25mdk'.V1_1_9_25mdk
Diffstat (limited to 'perl-install/Xconfig')
-rw-r--r-- | perl-install/Xconfig/FILES | 8 | ||||
-rw-r--r-- | perl-install/Xconfig/card.pm | 580 | ||||
-rw-r--r-- | perl-install/Xconfig/default.pm | 57 | ||||
-rw-r--r-- | perl-install/Xconfig/main.pm | 194 | ||||
-rw-r--r-- | perl-install/Xconfig/monitor.pm | 200 | ||||
-rw-r--r-- | perl-install/Xconfig/parse.pm | 200 | ||||
-rw-r--r-- | perl-install/Xconfig/proprietary.pm | 35 | ||||
-rw-r--r-- | perl-install/Xconfig/resolution_and_depth.pm | 308 | ||||
-rw-r--r-- | perl-install/Xconfig/screen.pm | 42 | ||||
-rw-r--r-- | perl-install/Xconfig/test.pm | 146 | ||||
-rw-r--r-- | perl-install/Xconfig/various.pm | 138 | ||||
-rw-r--r-- | perl-install/Xconfig/xfree.pm | 111 | ||||
-rw-r--r-- | perl-install/Xconfig/xfree3.pm | 257 | ||||
-rw-r--r-- | perl-install/Xconfig/xfree4.pm | 158 | ||||
-rw-r--r-- | perl-install/Xconfig/xfreeX.pm | 378 |
15 files changed, 0 insertions, 2812 deletions
diff --git a/perl-install/Xconfig/FILES b/perl-install/Xconfig/FILES deleted file mode 100644 index deefdedec..000000000 --- a/perl-install/Xconfig/FILES +++ /dev/null @@ -1,8 +0,0 @@ - - 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 deleted file mode 100644 index 3bd55bcfd..000000000 --- a/perl-install/Xconfig/card.pm +++ /dev/null @@ -1,580 +0,0 @@ -package Xconfig::card; # $Id$ - -use diagnostics; -use strict; - -use detect_devices; -use modules; -use common; -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 ($xfree3_server) = readlink("$::prefix/etc/X11/X") =~ /XF86_(.*)/; - - my $card = { - use_UTAH_GLX => int(grep { /glx/ } $raw_X->{xfree3}->get_modules), - use_DRI_GLX => int(grep { /dri/ } $raw_X->{xfree4}->get_modules), - server => $xfree3_server, - prefer_xf3 => $xfree3_server && !$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('glx', !$card->{DRI_GLX_SPECIAL}); #- glx for everyone, except proprietary nvidia - $raw_X->{xfree4}->set_load_module('dri', $card->{use_DRI_GLX} && !$card->{DRI_GLX_SPECIAL}); - - # 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} = undef 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, - exists $cards->{$card->{BoardName}} ? "Vendor|$card->{BoardName}" : 'XFree 4|vesa') or return; - - $r eq "Vendor|$card->{BoardName}" and return 1; #- it is unchanged, don't modify $card - - 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} = $options->{VideoRam_probed} || 4096; - log::l("argh, I need to know VideoRam! Taking " . ($options->{probed_VideoRam} ? "the probed" : "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(); - @cards or @cards = ({}); - - if (!$cards[0]{server} && !$cards[0]{Driver} || !$auto) { - card_config__not_listed($in, $cards[0], $options) or return; - } - my $card = multi_head_choose($in, @cards) or return; - - $card->{Driver} = 'fbdev' if $options->{allowFB} && !$card->{server} && !$card->{Driver}; - - xfree_and_glx_choose($in, $card, $auto) or return; - - $card->{prog} = install_server($card, $options, $do_pkgs); - - $in->ask_from('', _("Select the memory size of your graphics card"), - [ { val => \ ($card->{VideoRam} = $options->{VideoRam_probed} || 4096), - 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); - 1; -} - -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 $xf3 = if_($card->{server}, { text => _("XFree %s", $xf3_ver), code => sub { $card->{prefer_xf3} = 1 } }); - my $xf4 = if_($card->{Driver}, { text => _("XFree %s", $xf4_ver), code => sub { $card->{prefer_xf3} = 0 } }); - - #- no XFree3 with multi-head - my @choices = grep {$_} ($card->{cards} ? $xf4 : $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}) { - my $e = { 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)), - }; - $card->{prefer_xf3} ? unshift(@choices, $e) : push(@choices, $e); - } - - #- 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} = undef if $card->{use_UTAH_GLX}; - $card->{Options_xfree3}{no_pixmap_cache} = undef if $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} = undef if $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 TVout', '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}); - $card->{BoardName} = $card->{card_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->{server}; - - $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 }, - FB_TVOUT => sub { $card->{FB_TVOUT} = 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 deleted file mode 100644 index e9e4abd35..000000000 --- a/perl-install/Xconfig/default.pm +++ /dev/null @@ -1,57 +0,0 @@ -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(); - $mouse ||= do { - my $mouse = mouse::read(); - add2hash($mouse, mouse::detect()) if !$::noauto; - $mouse; - }; - - - 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); -} - -sub config_keyboard { - my ($raw_X, $keyboard) = @_; - - my $XkbLayout = keyboard::keyboard2xkb($keyboard); - - my $XkbModel = - arch() =~ /sparc/ ? 'sun' : - $XkbLayout eq 'jp' ? 'jp106' : - $XkbLayout eq 'br' ? 'abnt2' : 'pc105'; - - my $xkb = { $XkbLayout ? ( - XkbLayout => $XkbLayout, - XkbModel => $XkbModel, - if_($keyboard->{GRP_TOGGLE}, XkbOptions => "grp:$keyboard->{GRP_TOGGLE}"), - ) : (XkbDisable => undef) }; - $raw_X->set_keyboard($xkb); -} - -1; - diff --git a/perl-install/Xconfig/main.pm b/perl-install/Xconfig/main.pm deleted file mode 100644 index 661f1d5f5..000000000 --- a/perl-install/Xconfig/main.pm +++ /dev/null @@ -1,194 +0,0 @@ -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 $X = {}; - $X->{monitor} = Xconfig::monitor::configure_auto_install($raw_X, $old_X) or return; - $options->{VideoRam_probed} = $X->{monitor}{VideoRam_probed}; - $X->{card} = Xconfig::card::configure_auto_install($raw_X, $do_pkgs, $old_X, $options) or return; - Xconfig::screen::configure($raw_X, $X->{card}) or return; - $X->{resolution} = Xconfig::resolution_and_depth::configure_auto_install($raw_X, $X->{card}, $X->{monitor}, $old_X); - - &write($raw_X, $X); - - any::runlevel($::prefix, exists $old_X->{xdm} && !$old_X->{xdm} ? 3 : 5); -} - -sub configure_everything { - my ($in, $raw_X, $do_pkgs, $auto, $options) = @_; - my $X = {}; - my $ok = 1; - $ok &&= $X->{monitor} = Xconfig::monitor::configure($in, $raw_X, $auto); - $options->{VideoRam_probed} = $X->{monitor}{VideoRam_probed}; - $ok &&= $X->{card} = Xconfig::card::configure($in, $raw_X, $do_pkgs, $auto, $options); - $ok &&= Xconfig::screen::configure($raw_X, $X->{card}); - $ok &&= $X->{resolution} = Xconfig::resolution_and_depth::configure($in, $raw_X, $X->{card}, $X->{monitor}, $auto); - $ok &&= Xconfig::test::test($in, $raw_X, $X->{card}, $auto, 'skip_badcard'); - - if (!$ok) { - ($ok) = configure_chooser_raw($in, $raw_X, $do_pkgs, $options, $X, 1); - } else { - Xconfig::various::various($in, $X->{card}, $options, $auto); - } - $ok = may_write($in, $raw_X, $X, $ok); - - $ok && 'config_changed'; -} - -sub configure_chooser_raw { - my ($in, $raw_X, $do_pkgs, $options, $X, $modified) = @_; - - my %texts; - - my $update_texts = sub { - $texts{card} = $X->{card} && $X->{card}{BoardName} || _("Custom"); - $texts{monitor} = $X->{monitor} && $X->{monitor}{ModelName} || _("Custom"); - $texts{resolution} = Xconfig::resolution_and_depth::to_string($X->{resolution}); - - $texts{$_} =~ s/(.{20}).*/$1.../ foreach keys %texts; #- ensure not too long - }; - $update_texts->(); - - my $may_set = sub { - my ($field, $val) = @_; - if ($val) { - $X->{$field} = $val; - $X->{"modified_$field"} = 1; - $modified = 1; - $update_texts->(); - - if (member($field, 'card', 'monitor')) { - Xconfig::screen::configure($raw_X, $X->{card}); - $raw_X->set_resolution($X->{resolution}) if $X->{resolution}; - } - } - }; - - my $ok; - $in->ask_from_({ ok => '' }, - [ - { label => _("Graphic Card"), val => \$texts{card}, icon => "eth_card_mini", clicked => sub { - $may_set->('card', Xconfig::card::configure($in, $raw_X, $do_pkgs, 0, $options)); - } }, - { label => _("Monitor"), val => \$texts{monitor}, icon => "ic82-systemeplus-40", clicked => sub { - $may_set->('monitor', Xconfig::monitor::configure($in, $raw_X)); - } }, - { label => _("Resolution"), val => \$texts{resolution}, icon => "X", disabled => sub { !$X->{card} || !$X->{monitor} }, - clicked => sub { - $may_set->('resolution', Xconfig::resolution_and_depth::configure($in, $raw_X, $X->{card}, $X->{monitor})); - } }, - if_(Xconfig::card::check_bad_card($X->{card}) || $::isStandalone, - { val => _("Test"), icon => "warning", disabled => sub { !$X->{card} || !$X->{monitor} }, - clicked => sub { - $ok = Xconfig::test::test($in, $raw_X, $X->{card}, 'auto', 0); - } }, - ), - { val => _("Options"), icon => "ic82-tape-40", clicked => sub { - Xconfig::various::various($in, $X->{card}, $options); - } }, - { val => $::isInstall ? _("Ok") : _("Quit"), icon => "exit", clicked_may_quit => sub { 1 } }, - ]); - $ok, $modified; -} - -sub configure_chooser { - my ($in, $raw_X, $do_pkgs, $options) = @_; - - my $X = { - card => scalar eval { Xconfig::card::from_raw_X($raw_X) }, - monitor => $raw_X->get_monitors && Xconfig::monitor::from_raw_X($raw_X), - resolution => scalar eval { $raw_X->get_resolution }, - }; - my ($ok, $modified) = configure_chooser_raw($in, $raw_X, $do_pkgs, $options, $X); - - $modified and may_write($in, $raw_X, $X, $ok) or return; - - 'config_changed'; -} - -sub may_write { - my ($in, $raw_X, $X, $ok) = @_; - - $ok ||= $in->ask_yesorno('', _("Keep the changes? -The current configuration is: - -%s", Xconfig::various::info($raw_X, $X->{card})), 1); - - &write($raw_X, $X) if $ok; - $ok; -} - -sub write { - my ($raw_X, $X) = @_; - export_to_install_X($X); - $raw_X->write; - Xconfig::various::check_XF86Config_symlink(); - symlinkf "../..$X->{card}{prog}", "$::prefix/etc/X11/X" if $X->{card}{server} !~ /Xpmac/; -} - - -sub export_to_install_X { - my ($X) = @_; - - $::isInstall or return; - - $::o->{X}{resolution_wanted} = $X->{resolution}{X}; - $::o->{X}{default_depth} = $X->{resolution}{Depth}; - $::o->{X}{bios_vga_mode} = $X->{resolution}{bios}; - $::o->{X}{monitor} = $X->{monitor} if $X->{monitor}{manually_chosen} && $X->{monitor}{vendor} ne "Plug'n Play"; - $::o->{X}{card} = $X->{monitor} if $X->{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 deleted file mode 100644 index 9b3eea507..000000000 --- a/perl-install/Xconfig/monitor.pm +++ /dev/null @@ -1,200 +0,0 @@ -package Xconfig::monitor; #- $Id$ - -use diagnostics; -use strict; - -use detect_devices; -use common; -use any; -use log; - - -sub good_default_monitor { - arch() =~ /ppc/ ? - (detect_devices::get_mac_model =~ /^iBook/ ? 'Apple|iBook 800x600' : 'Apple|iMac/PowerBook 1024x768') : - (detect_devices::isLaptop() ? 'Generic|Flat Panel 1024x768' : 'Generic|1024x768 @ 70 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, { HorizSync => '31.5-35.1', VertRefresh => '50-61' }); - $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 %h_monitors = map { ; "$_->{VendorName}|$_->{ModelName}" => $_ } @$monitors; - - ask_monitor: - my $merged_name = do { - if ($monitor->{VendorName} eq "Plug'n Play") { - $monitor->{VendorName}; - } else { - my $merged_name = $monitor->{VendorName} . '|' . $monitor->{ModelName}; - - if (!exists $h_monitors{$merged_name}) { - $merged_name = $monitor->{HorizSync} ? 'Custom' : good_default_monitor(); - } else { - $merged_name; - } - } - }; - - $in->ask_from(_("Monitor"), _("Choose a monitor"), - [ { val => \$merged_name, separator => '|', - list => ['Custom', "Plug'n Play", sort keys %h_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()); - if (configure_automatic($monitor, $monitors)) { - $monitor->{VendorName} = "Plug'n Play"; - } else { - delete $monitor->{VendorName}; - $in->ask_warn('', _("Plug'n Play probing failed. Please choose a precise monitor")); - goto ask_monitor; - } - } 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, $h_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} } @$monitors) { - add2hash($monitor, $mon); - log::l("EISA_ID corresponds to: $monitor->{ModelName}"); - } elsif (!$monitor->{HorizSync} || !$monitor->{VertRefresh}) { - log::l("unknown EISA_ID and partial DDC probe, so unknown monitor"); - delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'}; - } - } else { - if (my ($mon) = grep { $_->{VendorName} eq $monitor->{VendorName} && $_->{ModelName} eq $monitor->{ModelName} } @$monitors) { - put_in_hash($monitor, $mon); - } - } - - 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_probed => to_int($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; - 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; @l{@fields} = split /\s*;\s*/; - push @monitors, \%l; - } - \@monitors; -} - - -1; - diff --git a/perl-install/Xconfig/parse.pm b/perl-install/Xconfig/parse.pm deleted file mode 100644 index 9f4b40bd5..000000000 --- a/perl-install/Xconfig/parse.pm +++ /dev/null @@ -1,200 +0,0 @@ -package Xconfig::parse; # $Id$ - -use diagnostics; -use strict; - -use common; - - -sub read_XF86Config { - my ($file) = @_; - my $raw_X = raw_from_file($file); - from_raw(@$raw_X); - $raw_X; -} - -sub write_XF86Config { - my ($raw_X, $file) = @_; - my @blocks = map { raw_to_string(before_to_string({ %$_ }, 0)) } @$raw_X; - @blocks ? output($file, @blocks) : unlink $file; -} - -sub read_XF86Config_from_string { - my ($s) = @_; - my $raw_X = raw_from_file('-', [ split "\n", $s ]); - from_raw(@$raw_X); - $raw_X; -} - -#-############################################################################### -#- raw reading/saving -#-############################################################################### -sub raw_from_file { #- internal - my ($file, $lines) = @_; - my $raw_X = []; - - $lines ||= [ cat_($file) ]; - my $line; - my $weird = sub { warn "$file:$line: strange $_[0]" }; - - my ($comment, $obj, @objs); - - my $attach_comment = sub { - $obj || @objs or warn "$file:$line: can't attach comment\n"; - if ($comment) { - $comment =~ s/\n+$/\n/; - ($obj || $objs[0])->{$_[0] . '_comment'} = $comment; - $comment = ''; - } - }; - - foreach (@$lines) { - $line++; - s/^\s*//; s/\s*$//; - - if (/^$/) { - $comment .= "\n" if $comment; - next; - } elsif (/^#\W/ || /^#$/) { - s/^#\s+/# /; - $comment .= "$_\n"; - next; - } - - if (/^Section\s+"(.*)"/i) { - die "$file:$line: missing EndSection\n" if @objs; - my $e = { name => $1, l => [], kind => 'Section' }; - push @$raw_X, $e; - unshift @objs, $e; $obj = ''; - $attach_comment->('pre'); - } elsif (/^Subsection\s+"(.*)"/i) { - die "$file:$line: missing EndSubsection\n" if @objs && $objs[0]{kind} eq 'Subsection'; - die "$file:$line: not in Section\n" if !@objs || $objs[0]{kind} ne 'Section'; - my $e = { name => $1, l => [], kind => 'Subsection' }; - push @{$objs[0]{l}}, $e; - unshift @objs, $e; $obj = ''; - $attach_comment->('pre'); - } elsif (/^EndSection/i) { - die "$file:$line: not in Section\n" if !@objs || $objs[0]{kind} ne 'Section'; - $attach_comment->('post'); - shift @objs; $obj = ''; - } elsif (/^EndSubsection/i) { - die "$file:$line: not in Subsection\n" if !@objs || $objs[0]{kind} ne 'Subsection'; - $attach_comment->('post'); - my $e = shift @objs; $obj = ''; - } else { - die "$file:$line: not in Section\n" if !@objs; - - my $commented = s/^#//; - - my $comment_on_line; - s/(\s*#.*)/$comment_on_line = $1; ''/e; - - if (/^$/) { - die "$file:$line: weird"; - } - - (my $name, my $Option, $_) = - /^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); - $comment = ''; - $obj = { name => $name, val => $val }; - $e{$_} and $obj->{$_} = $e{$_} foreach keys %e; - - push @{$objs[0]{l}}, $obj; - } - } - $raw_X; -} - -sub raw_to_string { - my ($e, $want_spacing) = @_; - my $s = do { - if ($e->{l}) { - my $inside = join('', map_index { raw_to_string($_, $::i) } @{$e->{l}}); - $inside =~ s/^/ /mg; - qq(\n$e->{kind} "$e->{name}"\n) . $inside . "End$e->{kind}"; - } else { - ($e->{commented} ? '#' : '') . - ($e->{Option} ? qq(Option "$e->{name}") : $e->{name}) . - (defined $e->{val} ? ($e->{Option} && $e->{val} !~ /^"/ ? qq( "$e->{val}") : qq( $e->{val})) : ''); - } - }; - ($e->{pre_comment} ? ($want_spacing ? "\n" : '') . $e->{pre_comment} : '') . $s . ($e->{comment_on_line} || '') . "\n" . ($e->{post_comment} || ''); -} - -#-############################################################################### -#- refine the data structure for easier use -#-############################################################################### -my %kind_names = ( - Pointer => [ qw(Protocol Device Emulate3Buttons Emulate3Timeout) ], - 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 DPMS power_saver) ], - Display => [ qw(Depth Modes) ], # Subsection in Device - Screen => [ qw(Identifier Driver Device Monitor DefaultColorDepth) ], - InputDevice => [ qw(Identifier Driver Protocol Device Type Mode XkbModel XkbLayout XkbDisable Emulate3Buttons Emulate3Timeout) ], - WacomCursor => [ qw(Port) ], #-\ - WacomStylus => [ qw(Port) ], #--> Port must be first - WacomEraser => [ qw(Port) ], #-/ - ServerLayout => [ qw(Identifier) ], -); -my @want_string = qw(Identifier DeviceName VendorName ModelName BoardName Driver Device Chipset Monitor Protocol XkbModel XkbLayout XkbOptions Load BusID); - -%kind_names = map_each { lc $::a => [ map { lc } @$::b ] } %kind_names; -@want_string = map { lc } @want_string; - -sub from_raw { - foreach my $e (@_) { - ($e->{l}, my $l) = ({}, $e->{l}); - from_raw__rec($e, $_) foreach @$l; - - delete $e->{kind}; - } - - sub from_raw__rec { - my ($current, $e) = @_; - if ($e->{l}) { - from_raw($e); - push @{$current->{l}{$e->{name}}}, $e; - } else { - if (member(lc $e->{name}, @want_string)) { - $e->{val} =~ s/^"(.*)"$/$1/ or warn "$e->{name} $e->{val} has no quote\n"; - } - - if (member(lc $e->{name}, @{$kind_names{lc $current->{name}} || []})) { - if ($current->{l}{$e->{name}} && !$current->{l}{$e->{name}}{commented}) { - warn "skipping conflicting line for $e->{name} in $current->{name}\n" if !$e->{commented}; - } else { - $current->{l}{$e->{name}} = $e; - } - } else { - push @{$current->{l}{$e->{name}}}, $e; - } - } - delete $e->{name}; - } -} - -sub before_to_string { - my ($e, $depth) = @_; - - if ($e->{l}) { - $e->{kind} = $depth ? 'Subsection' : 'Section'; - - my %rated = map_index { $_ => $::i + 1 } @{$kind_names{lc $e->{name}} || []}; - my @sorted = sort { ($rated{lc $a} || 99) <=> ($rated{lc $b} || 99) } keys %{$e->{l}}; - $e->{l} = [ map { - my $name = $_; - map { - before_to_string({ name => $name, %$_ }, $depth+1); - } deref_array($e->{l}{$name}); - } @sorted ]; - } elsif (member(lc $e->{name}, @want_string)) { - $e->{val} = qq("$e->{val}"); - } - $e; -} diff --git a/perl-install/Xconfig/proprietary.pm b/perl-install/Xconfig/proprietary.pm deleted file mode 100644 index bb04bd892..000000000 --- a/perl-install/Xconfig/proprietary.pm +++ /dev/null @@ -1,35 +0,0 @@ -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" || $::testing; - - 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"); -} - -1; - diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm deleted file mode 100644 index 1127fa1f2..000000000 --- a/perl-install/Xconfig/resolution_and_depth.pm +++ /dev/null @@ -1,308 +0,0 @@ -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 to_string { - my ($resolution) = @_; - $resolution or return; - - sprintf("%sx%s %dbpp", @$resolution{'X', 'Y', 'Depth'}); -} - -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) = @_; - - my $resolution = $default_resolution || {}; - $in->ask_from(_("Resolutions"), "", - [ { - val => \$resolution, type => 'list', sort => 0, - list => [ sort { $a->{X} <=> $b->{X} } @resolutions ], - format => sub { "$_[0]{X}x$_[0]{Y} $_[0]{Depth}bpp" }, - } ]) - and $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} || ($monitor->{Model} =~ /^Flat Panel (\d+x\d+)$/ ? $1 : size2default_resolution($monitor->{size} || 14)); - 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_resolutions = sort { $b->{Y} <=> $a->{Y} } grep { $_->{Depth} eq $Depth } @matching; - my $default_resolution = first(grep { $resolution_wanted->{Y} eq $_->{Y} } @default_resolutions) || $default_resolutions[0]; - - $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); - - if ($in->isa('interactive::gtk')) { - $default_resolution = choose_gtk($card, $default_resolution, @resolutions) or return; - } else { - $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, $resolution_wanted, $card, $monitor); - $default_resolution or die "you selected an unusable depth"; - - $raw_X->set_resolution($default_resolution); - - $default_resolution; -} - -sub choose_gtk { - my ($card, $default_resolution, @resolutions) = @_; - - my ($chosen_x_res, $chosen_y_res, $chosen_Depth) = @$default_resolution{'X', 'Y', 'Depth'}; - $chosen_x_res ||= 640; - - my %x_res2depth; push @{$x_res2depth{$_->{X}}}, $_->{Depth} foreach @resolutions; - my %depth2x_res; push @{$depth2x_res{$_->{Depth}}}, $_->{X} foreach @resolutions; - - require my_gtk; - my_gtk->import(qw(:helpers :wrappers)); - my $W = my_gtk->new(_("Resolution")); - - my %monitor_images_x_res = do { - my @l = qw(640 800 1024 1152 1280 1400 1600 1920 2048); - my %h = map { $_ => [ gtkcreate_png("monitor-$_.png") ] } @l; - - #- for the other, use the biggest smaller - foreach my $x_res (uniq map { $_->{X} } @resolutions) { - my $x_res_ = max(grep { $_ <= $x_res } @l); - $h{$x_res} ||= $h{$x_res_}; - } - %h; - }; - - my ($depth_combo, $x_res_combo); - - my $pix_colors = gtkpng("colors"); - my $set_chosen_Depth_image = sub { - $pix_colors->set(gtkcreate_png( - $chosen_Depth >= 24 ? "colors.png" : - $chosen_Depth >= 15 ? "colors16.png" : "colors8.png")); - }; - - my $set_chosen_Depth = sub { - $chosen_Depth = $_[0]; - $depth_combo->entry->set_text(translate($depth2text{$chosen_Depth})); - $set_chosen_Depth_image->(); - }; - - my $pixmap_mo; - my $set_chosen_x_res = sub { - $chosen_x_res = $_[0]; - if ($_[1]) { - $chosen_y_res = $_[1]; - } else { - #- take one - my ($one) = grep { $_->{X} eq $chosen_x_res } @resolutions; - $chosen_y_res = $one->{Y}; - } - my $image = $monitor_images_x_res{$chosen_x_res} or internal_error("no image for resolution $chosen_x_res"); - $pixmap_mo ? $pixmap_mo->set($image->[0], $image->[1]) : ($pixmap_mo = new Gtk::Pixmap($image->[0], $image->[1])); - }; - $set_chosen_x_res->($chosen_x_res, $chosen_y_res); - - gtkadd($W->{window}, - gtkpack_($W->create_box_with_title(_("Choose the resolution and the color depth"), - if_($card->{BoardName}, "(" . _("Graphics card: %s", $card->{BoardName}) . ")"), - ), - 1, gtkpack2(new Gtk::VBox(0,0), - gtkpack2__(new Gtk::VBox(0, 15), - $pixmap_mo, - gtkpack2(new Gtk::HBox(0,0), - create_packtable({ col_spacings => 5, row_spacings => 5 }, - [ $x_res_combo = new Gtk::Combo, new Gtk::Label("")], - [ $depth_combo = new Gtk::Combo, gtkadd(gtkset_shadow_type(new Gtk::Frame, 'etched_out'), $pix_colors) ], - ), - ), - ), - ), - 0, gtkadd($W->create_okcancel(_("Ok"), _("Cancel"))), - )); - $depth_combo->disable_activate; - $depth_combo->set_use_arrows_always(1); - $depth_combo->entry->set_editable(0); - $depth_combo->set_popdown_strings(map { translate($depth2text{$_}) } ikeys %depth2x_res); - $depth_combo->entry->set_usize(220, 0); - $depth_combo->entry->signal_connect(changed => sub { - my %txt2depth = reverse %depth2text; - my $s = $depth_combo->entry->get_text; - $chosen_Depth = $txt2depth{untranslate($s, keys %txt2depth)}; - $set_chosen_Depth_image->(); - - if (!member($chosen_x_res, @{$depth2x_res{$chosen_Depth}})) { - $set_chosen_x_res->(max(@{$depth2x_res{$chosen_Depth}})); - } - }); - $x_res_combo->disable_activate; - $x_res_combo->set_use_arrows_always(1); - $x_res_combo->entry->set_editable(0); - $x_res_combo->set_popdown_strings(uniq map { "$_->{X}x$_->{Y}" } sort { $a->{X} <=> $b->{X} } @resolutions); - $x_res_combo->entry->signal_connect(changed => sub { - $x_res_combo->entry->get_text =~ /(\d+)x(\d+)/; - $set_chosen_x_res->($1, $2); - - if (!member($chosen_Depth, @{$x_res2depth{$chosen_x_res}})) { - $set_chosen_Depth->(max(@{$x_res2depth{$chosen_x_res}})); - } - }); - $set_chosen_Depth->($chosen_Depth); - $W->{ok}->grab_focus; - - $x_res_combo->entry->set_text($chosen_x_res . "x" . $chosen_y_res); - $W->main or return; - - first(grep { $_->{X} == $chosen_x_res && - $_->{Y} == $chosen_y_res && - $_->{Depth} == $chosen_Depth } @resolutions); -} - -1; diff --git a/perl-install/Xconfig/screen.pm b/perl-install/Xconfig/screen.pm deleted file mode 100644 index 761c5defd..000000000 --- a/perl-install/Xconfig/screen.pm +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index 0648a28b1..000000000 --- a/perl-install/Xconfig/test.pm +++ /dev/null @@ -1,146 +0,0 @@ -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, $skip_badcard) = @_; - - my $bad_card = !Xconfig::card::check_bad_card($card); - return 1 if $skip_badcard && $bad_card; - - if ($bad_card || !$auto) { - my $msg = - $in->ask_yesorno(_("Test of the configuration"), - _("Do you want to test the configuration?") . ($bad_card ? "\n" . _("Warning: testing this graphic card may freeze your computer") : ''), - !$bad_card) or return 1; - } - - 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 do { run_program::rooted($::prefix, "/etc/rc.d/init.d/xfs", $_) foreach 'stop', '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 = 12; - Gtk->timeout_add(1000, sub { - $text->set(_("Leaving in %d seconds", $time)); - $time-- or Gtk->main_quit; - 1; - }); - - my $background = "/usr/share/mdk/xfdrake/xfdrake-test-card.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 deleted file mode 100644 index 646edf8be..000000000 --- a/perl-install/Xconfig/various.pm +++ /dev/null @@ -1,138 +0,0 @@ -package Xconfig::various; # $Id$ - -use diagnostics; -use strict; - -use Xconfig::card; -use Xconfig::default; -use Xconfig::resolution_and_depth; -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::resolution_and_depth::depth2text{$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 various { - my ($in, $card, $options, $auto) = @_; - - tvout($in, $card, $options); - choose_xdm($in, $auto); -} - -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); -} - -sub tvout { - my ($in, $card, $options) = @_; - - $card->{FB_TVOUT} && Xconfig::card::using_xf4($card) && $options->{allowFB} or return; - - $in->ask_yesorno('', _("Your graphic card seems to have a TV-OUT connector. -It can be configured to work using frame-buffer. - -For this you have to plug your graphic card to your TV before booting your computer. -Then choose the \"TVout\" entry in the bootloader - -Do you have this feature?")) or return; - - #- rough default value (rationale: http://download.nvidia.com/XFree86_40/1.0-2960/README.txt) - require timezone; - my $norm = timezone::read()->{timezone} =~ /America/ ? 'NTSC' : 'PAL'; - - $norm = $in->ask_from_list('', _("What norm is your TV using?"), [ 'NTSC', 'PAL' ], $norm) or return; - - configure_FB_TVOUT({ norm => $norm }); -} - -sub configure_FB_TVOUT { - my ($use_FB_TVOUT) = @_; - - my $raw_X = Xconfig::default::configure(); - my $xfree4 = $raw_X->{xfree4}; - - $xfree4->set_monitors({ HorizSync => '30-50', VertRefresh => ($use_FB_TVOUT->{norm} eq 'NTSC' ? 60 : 50) }); - first($xfree4->get_monitor_sections)->{ModeLine} = [ - { val => '"640x480" 29.50 640 675 678 944 480 530 535 625', pre_comment => "# PAL\n" }, - { val => '"800x600" 36.00 800 818 820 960 600 653 655 750' }, - { val => '"640x480" 28.195793 640 656 658 784 480 520 525 600', pre_comment => "# NTSC\n" }, - { val => '"800x600" 38.769241 800 812 814 880 600 646 649 735' }, - ]; - $xfree4->set_devices({ Driver => 'fbdev' }); - - my ($device) = $xfree4->get_devices; - my ($monitor) = $xfree4->get_monitors; - $xfree4->set_screens({ Device => $device->{Identifier}, Monitor => $monitor->{Identifier} }); - - my $Screen = $xfree4->get_default_screen; - $Screen->{Display} = [ map { { l => { Depth => { val => $_ } } } } 8, 16 ]; - - $xfree4->write("$::prefix/etc/X11/XF86Config-4.tvout"); - - check_XF86Config_symlink(); - - { - require bootloader; - require fsedit; - require detect_devices; - my ($bootloader, $all_hds) = - $::isInstall ? ($::o->{bootloader}, $::o->{all_hds}) : - (bootloader::read(), fsedit::get_hds()); - - if (my $tvout = bootloader::duplicate_kernel_entry($bootloader, 'TVout')) { - $tvout->{append} .= " XFree=tvout"; - bootloader::install($bootloader, [ fsedit::get_all_fstab($all_hds) ], $all_hds->{hds}); - } - } -} - -sub check_XF86Config_symlink { - my $f = "$::prefix/etc/X11/XF86Config-4"; - if (!-l $f && -e "$f.tvout") { - rename $f, "$f.standard"; - symlink "XF86Config-4.standard", $f; - } -} - -1; diff --git a/perl-install/Xconfig/xfree.pm b/perl-install/Xconfig/xfree.pm deleted file mode 100644 index 583229f4b..000000000 --- a/perl-install/Xconfig/xfree.pm +++ /dev/null @@ -1,111 +0,0 @@ -package Xconfig::xfree; # $Id$ - -use diagnostics; -use strict; - -use common; -use Xconfig::parse; -use Xconfig::xfree3; -use Xconfig::xfree4; -use log; - - -#- files are optional -sub read { - 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, $xfree3_file, $xfree4_file) = @_; - $both->{xfree3} ? $both->{xfree3}->write($xfree3_file) : unlink($xfree3_file); - $both->{xfree4} ? $both->{xfree4}->write($xfree4_file) : unlink($xfree4_file); -} - -sub empty_config { - my ($class) = @_; - bless { xfree3 => Xconfig::xfree3->empty_config, - xfree4 => Xconfig::xfree4->empty_config }, $class; -} - -sub get_keyboard { get_both('get_keyboard', @_) } -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 -#-############################################################################## -sub get_both { - my ($getter, $both) = @_; - - if ($both->{xfree3}) { - $both->{xfree4}->$getter; - } elsif ($both->{xfree4}) { - $both->{xfree3}->$getter; - } else { - my @l3 = $both->{xfree3}->$getter; - my @l4 = $both->{xfree4}->$getter; - merge_values(\@l3, \@l4); - } -} -sub set_both { - my ($setter, $both, @l) = @_; - - $both->{xfree3}->$setter(@l) if $both->{xfree3}; - $both->{xfree4}->$setter(@l) if $both->{xfree4}; -} - -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{$_}) { - if (ref($h{$_}) eq 'HASH' && ref($h3->{$_}) eq 'HASH') { - #- needed for "Options" of Devices - $h{$_} = +{ %{$h3->{$_}}, %{$h{$_}} }; - } else { - 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; - } - - my @r = mapn(\&merge_values__hashes, $l3, $l4); - - @r == 1 ? $r[0] : @r; -} - -1; diff --git a/perl-install/Xconfig/xfree3.pm b/perl-install/Xconfig/xfree3.pm deleted file mode 100644 index 9b69b3cb6..000000000 --- a/perl-install/Xconfig/xfree3.pm +++ /dev/null @@ -1,257 +0,0 @@ -package Xconfig::xfree3; # $Id$ - -use diagnostics; -use strict; - -use common; -use Xconfig::parse; -use Xconfig::xfreeX; - -our @ISA = 'Xconfig::xfreeX'; - -sub name { 'xfree3' } -sub config_file { '/etc/X11/XF86Config' } - - -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' } }); -} - -sub get_mouse_sections { - my ($raw_X) = @_; - my $main = $raw_X->get_Section('Pointer') or die "no mouse section"; - my $XInput = $raw_X->get_Section('XInput'); - $main, if_($XInput, map { $_->{l} } @{$XInput->{Mouse} || []}); -} - -sub new_mouse_sections { - my ($raw_X, $nb_new) = @_; - - $raw_X->remove_Section('Pointer'); - my $XInput = $raw_X->get_Section('XInput'); - delete $XInput->{Mouse} if $XInput; - $raw_X->remove_Section('XInput') if $nb_new <= 1 && $XInput && !%$XInput; - - $nb_new or return; - - my $main = $raw_X->add_Section('Pointer', {}); - - if ($nb_new == 1) { - $main; - } else { - my @l = map { { AlwaysCore => {} } } (2 .. $nb_new); - $XInput ||= $raw_X->add_Section('XInput', {}); - $XInput->{Mouse} = [ map { { l => $_ } } @l ]; - $main, @l; - } -} - -sub set_mice { - my ($raw_X, @mice) = @_; - @mice = map { - my %h = %$_; - put_in_hash(\%h, { Protocol => 'IMPS/2', ZAxisMapping => '4 5' }) if $h{Protocol} eq 'ExplorerPS/2'; - \%h; - } @mice; - $raw_X->SUPER::set_mice(@mice); -} - -sub set_wacoms { - my ($raw_X, @wacoms) = @_; - - my %Modes = (Stylus => 'Absolute', Eraser => '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) = @_; - - $resolution = +{ %$resolution }; - if (my $Screen_ = $Screen || $raw_X->get_default_screen) { - #- 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 deleted file mode 100644 index 542226000..000000000 --- a/perl-install/Xconfig/xfree4.pm +++ /dev/null @@ -1,158 +0,0 @@ -package Xconfig::xfree4; # $Id$ - -use diagnostics; -use strict; - -use common; -use Xconfig::parse; -use Xconfig::xfree; - -our @ISA = 'Xconfig::xfreeX'; - -sub name { 'xfree4' } -sub config_file { '/etc/X11/XF86Config-4' } - - -sub get_keyboard_section { - my ($raw_X) = @_; - my ($raw_kbd) = get_InputDevices($raw_X, 'Keyboard') or die "no keyboard section"; - $raw_kbd; -} - -sub new_keyboard_section { - my ($raw_X) = @_; - my $raw_kbd = { Identifier => { val => 'Keyboard1' }, Driver => { val => 'Keyboard' } }; - $raw_X->add_Section('InputDevice', $raw_kbd); - - my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= []; - push @$layout, { val => '"Keyboard1" "CoreKeyboard"' }; - - $raw_kbd; -} - -sub get_mouse_sections { - my ($raw_X) = @_; - get_InputDevices($raw_X, 'mouse'); -} -sub new_mouse_sections { - my ($raw_X, $nb_new) = @_; - $raw_X->remove_InputDevices('mouse'); - - my $layout = get_ServerLayout($raw_X)->{InputDevice} ||= []; - @$layout = grep { $_->{val} !~ /^"Mouse/ } @$layout; - - $nb_new or return; - - my @l = map { - my $h = { Identifier => { val => "Mouse$_" }, Driver => { val => 'mouse' } }; - $raw_X->add_Section('InputDevice', $h); - } (1 .. $nb_new); - - push @$layout, { val => qq("Mouse1" "CorePointer") }; - push @$layout, { val => qq("Mouse$_" "SendCoreEvents") } foreach (2 .. $nb_new); - - @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', Eraser => 'Absolute', Cursor => 'Relative'); - - each_index { - my $wacom = $_; - foreach (keys %Modes) { - my $identifier = $_ . ($::i + 1); - my $h = { Identifier => { val => $identifier }, - Driver => { val => 'wacom' }, - Type => { 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("$identifier" "AlwaysCore") }; - } - } @wacoms; -} - -sub depths { 8, 15, 16, 24 } -sub set_resolution { - my ($raw_X, $resolution, $Screen) = @_; - - $resolution = +{ %$resolution }; - if (my $Screen_ = $Screen || $raw_X->get_default_screen) { - #- 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) = @_; - - if (member($category, 'keyboard', 'mouse')) { - #- everything we export is an Option - $_->{Option} = 1 foreach map { deref_array($node->{$_}) } @names; - } -} - - -#-############################################################################## -#- helpers -#-############################################################################## -sub get_InputDevices { - my ($raw_X, $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 { val($_[0]{Driver}) ne $Driver }); -} - -sub get_ServerLayout { - my ($raw_X) = @_; - $raw_X->get_Section('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 deleted file mode 100644 index 9b8744a4c..000000000 --- a/perl-install/Xconfig/xfreeX.pm +++ /dev/null @@ -1,378 +0,0 @@ -package Xconfig::xfreeX; # $Id$ - -use diagnostics; -use strict; - -use Xconfig::parse; -use common; -use log; - - -sub empty_config { - my ($class) = @_; - my $raw_X = Xconfig::parse::read_XF86Config_from_string(our $default_header); - bless $raw_X, $class; -} - -sub read { - my ($class, $file) = @_; - $file ||= ($::prefix || '') . (bless {}, $class)->config_file; - my $raw_X = Xconfig::parse::read_XF86Config($file); - bless $raw_X, $class; -} -sub write { - my ($raw_X, $file) = @_; - $file ||= ($::prefix || '') . $raw_X->config_file; - rename $file, "$file.old"; - Xconfig::parse::write_XF86Config($raw_X, $file); -} - - -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 XkbOptions); -sub get_keyboard { - my ($raw_X) = @_; - my $raw_kbd = $raw_X->get_keyboard_section; - raw_export_section($raw_kbd, \@keyboard_fields); -} -sub set_keyboard { - my ($raw_X, $kbd) = @_; - my $raw_kbd = eval { $raw_X->get_keyboard_section } || $raw_X->new_keyboard_section; - raw_import_section($raw_kbd, $kbd); - $raw_X->set_Option('keyboard', $raw_kbd, keys %$kbd); -} - -#- example: { Protocol => 'IMPS/2', Device => '/dev/psaux', Emulate3Buttons => undef, Emulate3Timeout => 50, ZAxisMapping => [ '4 5', '6 7' ] } -my @mouse_fields = qw(Protocol Device ZAxisMapping Emulate3Buttons Emulate3Timeout); #-); -sub get_mice { - my ($raw_X) = @_; - my @raw_mice = $raw_X->get_mouse_sections; - map { raw_export_section($_, \@mouse_fields) } @raw_mice; -} -sub set_mice { - my ($raw_X, @mice) = @_; - my @raw_mice = $raw_X->new_mouse_sections(int @mice); - mapn { - my ($raw_mouse, $mouse) = @_; - raw_import_section($raw_mouse, $mouse); - $raw_X->set_Option('mouse', $raw_mouse, keys %$mouse); - } \@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_screens { - my ($raw_X) = @_; - $raw_X->get_Sections('Screen'); -} -sub get_default_screen { - my ($raw_X) = @_; - my @l = get_screens($raw_X); - 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_) = @_; - - foreach my $Screen ($Screen_ ? $Screen_ : $raw_X->get_screens) { - $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(\d+)/; - $1 <= $resolution->{X} && (!$resolution->{Y} || $2 <= $resolution->{Y}); - } reverse our @resolutions; - join(" ", map { qq("$_") } @Modes); - } - }; - { l => { Depth => { val => $_ }, Modes => { val => $modes } } }; - } $raw_X->depths ]; - } -} - - -#-############################################################################## -#- common to xfree3 and xfree4 -#-############################################################################## -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); -} - -sub new_module_section { - my ($raw_X) = @_; - return $raw_X->add_Section('Module', {}); -} - - -#-############################################################################## -#- helpers -#-############################################################################## -sub raw_export_section { - 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, $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]); - } -} - -sub add_Section { - my ($raw_X, $Section, $h) = @_; - my @suggested_ordering = qw(Files ServerFlags Module DRI Keyboard Pointer XInput InputDevice Monitor Device Screen ServerLayout); - my %order = map_index { { lc($_) => $::i } } @suggested_ordering; - my $e = { name => $Section, l => $h }; - my $added; - @$raw_X = map { - if ($order{lc $_->{name}} > $order{lc $Section} && !$added) { - $added = 1; - ($e, $_); - } else { $_ } - } @$raw_X; - push @$raw_X, $e if !$added; - $h; -} -sub remove_Section { - my ($raw_X, $Section, $when) = @_; - @$raw_X = grep { $_->{name} ne $Section || ($when && $when->($_->{l})) } @$raw_X; - $raw_X; -} -sub get_Sections { - my ($raw_X, $Section, $when) = @_; - map { if_($_->{name} eq $Section && (!$when || $when->($_->{l})), $_->{l}) } @$raw_X; -} -sub get_Section { - my ($raw_X, $Section, $when) = @_; - my @l = get_Sections($raw_X, $Section, $when); - @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 @resolutions = ('640x480', '800x600', '1024x768', if_(arch() =~ /ppc/, '1152x768'), '1152x864', '1280x960', '1280x1024', '1400x1050', '1600x1200', '1920x1440', '2048x1536'); - -our $default_header = << 'END'; -# File generated by XFdrake. - -# ********************************************************************** -# Refer to the XF86Config man page for details about the format of -# this file. -# ********************************************************************** - -Section "Files" - # Multiple FontPath entries are allowed (they are concatenated together) - # By default, Mandrake 6.0 and later now use a font server independent of - # the X server to render fonts. - FontPath "unix/:-1" -EndSection - -Section "ServerFlags" - #DontZap # disable <Crtl><Alt><BS> (server abort) - #DontZoom # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching) - AllowMouseOpenFail # allows the server to start up even if the mouse doesn't work -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; - |