summaryrefslogtreecommitdiffstats
path: root/perl-install/Xconfig.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-17 13:00:30 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-17 13:00:30 +0000
commit775534f625a05db82b3492a50cd6d67d1f30e122 (patch)
tree48cbf2c7b822bb224c9a44201783d6d97ec17d5a /perl-install/Xconfig.pm
parentc60b796a26ac6510d4089bdfdc3ae92f206ca382 (diff)
downloaddrakx-775534f625a05db82b3492a50cd6d67d1f30e122.tar
drakx-775534f625a05db82b3492a50cd6d67d1f30e122.tar.gz
drakx-775534f625a05db82b3492a50cd6d67d1f30e122.tar.bz2
drakx-775534f625a05db82b3492a50cd6d67d1f30e122.tar.xz
drakx-775534f625a05db82b3492a50cd6d67d1f30e122.zip
Big Xconfigurator.pm cleanup/rework
- use $X instead of $o (to avoid name conflict with DrakX's $o) - {flag}{noclockprobe} unused, dropping it - rename {memory} into "VideoRam" - rename {ramdac} into {Ramdac} - rename {chipset} into {Chipset} - rename {clockchip} into {Clockchip} - rename {keyboard}{xkb_model} into {keyboard}{XkbModel} - rename {keyboard}{xkb_keymap} into {keyboard}{XkbLayout} - drop {mouse}{chordmiddle} (obsolete) - drop {mouse}{cleardtrrts} (obsolete, was not written to XF4 config) - &testConfig is unused, removing it - as a concequence, {clocklines} is never set, dropping it - when UNSUPPORTED remove {driver}, instead of setting {flag}{unsupported} - Cards+ now only provide {Chipset} for cards needing it => {flag}{needChipset} not needed anymore - moved setting needVideoRam in Cards+ (via NEEDVIDEORAM) (hoping it will work: since the regexp was broken, it was never done. (it was applied on the module field of pcitable, instead of the description)) - dropped modelines_text_Trident_TG_96xx case (it has never been used) - rename %xkb_options into %XkbOptions - rename {DRI_glx} into {DRI_GLX}, the value now comes from Cards+ instead of regexp'ing {identifier} - rename {Utah_glx} into {UTAH_GLX}, the value now comes from Cards+ instead of regexp'ing {identifier} - rename {Utah_glx_EXPERIMENTAL} into {UTAH_GLX_EXPERIMENTAL}, the value now comes from Cards+ instead of regexp'ing {identifier} - very_bad_card and bad_card are now the same, the value now comes from Cards+ (BAD_FB_RESTORE & BAD_FB_RESTORE_XF3) - drop unused @accelservers - remove $modelines_text_apple, use $modelines_text_ext instead - don't use a <Section "Modes"> together with <UseModes "Mac Modes">, put directly modelines in Section "Monitor" (why should ppc behave differently than others!?) - replace (conflicting) ModeLines "1280x1024 @ 74 Hz" and "1280x1024 @ 76 Hz" with "1280x1024 @ 75 Hz" (from ddcxinfos) - drop ModeLine "640x480 @ 72 Hz" (it conflicts, and anyway, it has no real use nowadays :) - drop comments about HorizSync, VertRefresh and ModeLine's from XF86Config - drop many unneeded stuff from XF86Config: AutoRepeat, Xqueue, Xleds, NoTrapSignals, XkbTypes, XkbKeycodes, XkbCompat, XkbRules, LeftAlt/RightAlt/ScrollLock/RightCtl - drop section comments from XF86Config - drop XF86_Mono configuration (it doesn't work anyway, seems like it needs a special ModeLine?) - drop 320x200 with XF86_SVGA (who can use this!?) - do not write Screen section "accel" if the server configured is not an accel one - drop the "Generic VGA" Device section for XF4 (this device is unused) - drop {monitor}{vendor}, {monitor}{model}, {card}{vendor}, {card}{model}, {card}{board} (only description strings, not useful for running the server) - use x_res instead of wres for things like 1024 in 1024x768
Diffstat (limited to 'perl-install/Xconfig.pm')
-rw-r--r--perl-install/Xconfig.pm224
1 files changed, 156 insertions, 68 deletions
diff --git a/perl-install/Xconfig.pm b/perl-install/Xconfig.pm
index fb83ec654..e235e5311 100644
--- a/perl-install/Xconfig.pm
+++ b/perl-install/Xconfig.pm
@@ -4,11 +4,12 @@ use diagnostics;
use strict;
use any;
+use log;
use common;
use mouse;
use devices;
use keyboard;
-use Xconfigurator;
+use Xconfigurator_consts;
sub keyboard_from_kmap {
@@ -20,49 +21,72 @@ sub keyboard_from_kmap {
}
+sub info {
+ my ($X) = @_;
+ my $info;
+ my $xf_ver = $X->{card}{use_xf4} ? "4.2.0" : "3.3.6";
+ my $title = ($X->{card}{DRI_GLX} || $X->{UTAH_GLX} ?
+ _("XFree %s with 3D hardware acceleration", $xf_ver) : _("XFree %s", $xf_ver));
+
+ $info .= _("Keyboard layout: %s\n", $X->{keyboard}{XkbLayout});
+ $info .= _("Mouse type: %s\n", $X->{mouse}{XMOUSETYPE});
+ $info .= _("Mouse device: %s\n", $X->{mouse}{device}) if $::expert;
+ $info .= _("Monitor: %s\n", $X->{monitor}{type});
+ $info .= _("Monitor HorizSync: %s\n", $X->{monitor}{hsyncrange}) if $::expert;
+ $info .= _("Monitor VertRefresh: %s\n", $X->{monitor}{vsyncrange}) if $::expert;
+ $info .= _("Graphics card: %s\n", $X->{card}{type});
+ $info .= _("Graphics card identification: %s\n", $X->{card}{identifier}) if $::expert;
+ $info .= _("Graphics memory: %s kB\n", $X->{card}{VideoRam}) if $X->{card}{VideoRam};
+ if ($X->{default_depth} and my $depth = $X->{card}{depth}{$X->{default_depth}}) {
+ $info .= _("Color depth: %s\n", translate($Xconfigurator_consts::depths{$X->{default_depth}}));
+ $info .= _("Resolution: %s\n", join "x", @{$depth->[0]}) if $depth && !is_empty_array_ref($depth->[0]);
+ }
+ $info .= _("XFree86 server: %s\n", $X->{card}{server}) if $X->{card}{server};
+ $info .= _("XFree86 driver: %s\n", $X->{card}{driver}) if $X->{card}{driver};
+ "$title\n\n$info";
+}
+
sub getinfo {
- my $o = shift || {};
- getinfoFromDDC($o);
- getinfoFromSysconfig($o);
+ my $X = shift || {};
+ getinfoFromDDC($X);
+ getinfoFromSysconfig($X);
my ($mouse) = mouse::detect();
- add2hash($o->{mouse}, $mouse) unless $o->{mouse}{XMOUSETYPE};
- add2hash($o->{mouse}{auxmouse}, $mouse->{auxmouse}) unless $o->{mouse}{auxmouse}{XMOUSETYPE};
- $o->{mouse}{auxmouse}{XMOUSETYPE} or delete $o->{mouse}{auxmouse};
+ add2hash($X->{mouse}, $mouse) if !$X->{mouse}{XMOUSETYPE};
+ add2hash($X->{mouse}{auxmouse}, $mouse->{auxmouse}) if !$X->{mouse}{auxmouse}{XMOUSETYPE};
+ $X->{mouse}{auxmouse}{XMOUSETYPE} or delete $X->{mouse}{auxmouse};
- $o->{mouse}{device} ||= "mouse" if -e "/dev/mouse";
- $o;
+ $X->{mouse}{device} ||= "mouse" if -e "/dev/mouse";
+ $X;
}
sub getinfoFromXF86Config {
- my $o = shift || {}; #- original $::o->{X} which must be changed only if sure!
- my $prefix = shift || "";
+ my ($X, $prefix) = @_; #- original $::o->{X} which must be changed only if sure!
+ $X ||= {};
+
my (%keyboard, %mouse, %wacom, %card, %monitor);
my (%c, $depth, $driver);
- local $_;
- local *G; open G, "$prefix/etc/X11/XF86Config-4";
- while (<G>) {
+ foreach (cat_("$prefix/etc/X11/XF86Config-4")) {
if (my $i = /^Section "InputDevice"/ .. /^EndSection/) {
%c = () if $i == 1;
$c{driver} = $1 if /^\s*Driver\s+"(.*?)"/;
$c{id} = $1 if /^\s*Identifier\s+"[^\d"]*(\d*)"/;
- $c{xkb_model} ||= $1 if /^\s*Option\s+"XkbModel"\s+"(.*?)"/;
- $c{xkb_keymap} ||= $1 if /^\s*Option\s+"XkbLayout"\s+"(.*?)"/;
+ $c{XkbModel} ||= $1 if /^\s*Option\s+"XkbModel"\s+"(.*?)"/;
+ $c{XkbLayout} ||= $1 if /^\s*Option\s+"XkbLayout"\s+"(.*?)"/;
$c{XMOUSETYPE} ||= $1 if /^\s*Option\s+"Protocol"\s+"(.*?)"/;
$c{device} ||= $1 if /^\s*Option\s+"Device"\s+"\/dev\/(.*?)"/;
- $c{chordmiddle} ||= $1 if /^\s*Option\s+"ChordMiddle"\s+"\/dev\/(.*?)"/;
$c{nbuttons} = 2 if /^\s*Option\s+"Emulate3Buttons"\s+/;
$c{nbuttons} ||= 5 if /^\s*#\s*Option\s+"ZAxisMapping"\s.*5/;
$c{nbuttons} = 7 if /^\s*#\s*Option\s+"ZAxisMapping"\s.*7/;
if ($i =~ /E0/) {
- @keyboard{qw(xkb_keymap)} = @c{qw(xkb_keymap)}
+ @keyboard{qw(XkbLayout)} = @c{qw(XkbLayout)}
if $c{driver} =~ /keyboard/i;
- @{$mouse{auxmouse}}{qw(XMOUSETYPE device chordmiddle nbuttons)} = @c{qw(XMOUSETYPE device chordmiddle nbuttons)}
+ @{$mouse{auxmouse}}{qw(XMOUSETYPE device nbuttons)} = @c{qw(XMOUSETYPE device nbuttons)}
if $c{driver} =~ /mouse/i && $c{id} > 1;
- @mouse{qw(XMOUSETYPE device chordmiddle nbuttons)} = @c{qw(XMOUSETYPE device chordmiddle nbuttons)}
+ @mouse{qw(XMOUSETYPE device nbuttons)} = @c{qw(XMOUSETYPE device nbuttons)}
if $c{driver} =~ /mouse/i && $c{id} < 1;
$wacom{$c{device}} = undef
if $c{driver} =~ /wacom/i;
@@ -71,9 +95,7 @@ sub getinfoFromXF86Config {
$monitor{type} ||= $1 if /^\s*Identifier\s+"(.*?)"/;
$monitor{hsyncrange} ||= $1 if /^\s*HorizSync\s+(.*)/;
$monitor{vsyncrange} ||= $1 if /^\s*VertRefresh\s+(.*)/;
- $monitor{vendor} ||= $1 if /^\s*VendorName\s+"(.*?)"/;
- $monitor{model} ||= $1 if /^\s*ModelName\s+"(.*?)"/;
- $monitor{modelines_}{"$1_$2"} = $_ if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+/;
+ $monitor{ModeLines} .= $_ if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+/;
} elsif (my $s = /^Section "Screen"/ .. /^EndSection/) {
$card{default_depth} ||= $1 if /^\s*DefaultColorDepth\s+(\d+)/;
if (my $i = /^\s*Subsection\s+"Display"/ .. /^\s*EndSubsection/) {
@@ -87,18 +109,13 @@ sub getinfoFromXF86Config {
}
}
}
- close G;
- local *F; open F, "$prefix/etc/X11/XF86Config";
- while (<F>) {
+ foreach (cat_("$prefix/etc/X11/XF86Config")) {
if (/^Section "Keyboard"/ .. /^EndSection/) {
- $keyboard{xkb_model} ||= $1 if /^\s*XkbModel\s+"(.*?)"/;
- $keyboard{xkb_keymap} ||= $1 if /^\s*XkbLayout\s+"(.*?)"/;
+ $keyboard{XkbModel} ||= $1 if /^\s*XkbModel\s+"(.*?)"/;
+ $keyboard{XkbLayout} ||= $1 if /^\s*XkbLayout\s+"(.*?)"/;
} elsif (/^Section "Pointer"/ .. /^EndSection/) {
$mouse{XMOUSETYPE} ||= $1 if /^\s*Protocol\s+"(.*?)"/;
$mouse{device} ||= $1 if m|^\s*Device\s+"/dev/(.*?)"|;
- $mouse{cleardtrrts} ||= 1 if m/^\s*ClearDTR\s+/;
- $mouse{cleardtrrts} ||= 1 if m/^\s*ClearRTS\s+/;
- $mouse{chordmiddle} ||= 1 if m/^\s*ChordMiddle\s+/;
$mouse{nbuttons} = 2 if m/^\s*Emulate3Buttons\s+/;
$mouse{nbuttons} ||= 5 if m/^\s*ZAxisMapping\s.*5/;
$mouse{nbuttons} = 7 if m/^\s*ZAxisMapping\s.*7/;
@@ -110,26 +127,22 @@ sub getinfoFromXF86Config {
$monitor{type} ||= $1 if /^\s*Identifier\s+"(.*?)"/;
$monitor{hsyncrange} ||= $1 if /^\s*HorizSync\s+(.*)/;
$monitor{vsyncrange} ||= $1 if /^\s*VertRefresh\s+(.*)/;
- $monitor{vendor} ||= $1 if /^\s*VendorName\s+"(.*?)"/;
- $monitor{model} ||= $1 if /^\s*ModelName\s+"(.*?)"/;
- $monitor{modelines_}{"$1_$2"} = $_ if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+/;
+ $monitor{ModeLines_xf3} .= $_ if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+/;
} elsif (my $i = /^Section "Device"/ .. /^EndSection/) {
%c = () if $i == 1;
$c{type} ||= $1 if /^\s*Identifier\s+"(.*?)"/;
- $c{memory} ||= $1 if /VideoRam\s+(\d+)/;
+ $c{VideoRam} ||= $1 if /VideoRam\s+(\d+)/;
$c{flags}{needVideoRam} ||= 1 if /^\s*VideoRam\s+/;
- $c{vendor} ||= $1 if /^\s*VendorName\s+"(.*?)"/;
- $c{board} ||= $1 if /^\s*BoardName\s+"(.*?)"/;
$c{driver} ||= $1 if /^\s*Driver\s+"(.*?)"/;
- $c{options_xf3}{$1} ||= 1 if /^\s*Option\s+"(.*?)"/;
$c{options_xf3}{$1} ||= 0 if /^\s*#\s*Option\s+"(.*?)"/;
+ $c{options_xf3}{$1} ||= 1 if /^\s*Option\s+"(.*?)"/;
add2hash(\%card, \%c) if ($i =~ /E0/ && $c{type} && $c{type} ne "Generic VGA");
} elsif (my $s = /^Section "Screen"/ .. /^EndSection/) {
undef $driver if $s == 1;
$driver = $1 if /^\s*Driver\s+"(.*?)"/;
- if ($driver eq $Xconfigurator::serversdriver{$card{server}}) {
+ if ($driver eq $Xconfigurator_consts::serversdriver{$card{server}}) {
$card{default_depth} ||= $1 if /^\s*DefaultColorDepth\s+(\d+)/;
if (my $i = /^\s*Subsection\s+"Display"/ .. /^\s*EndSubsection/) {
undef $depth if $i == 1;
@@ -143,19 +156,12 @@ sub getinfoFromXF86Config {
}
}
}
- close F;
-
- #- clean up modeline by those automatically given by $modelines_text.
- foreach (split /\n/, $Xconfigurator::modelines_text) {
- delete $monitor{modelines_}{"$1_$2"} if /^\s*Mode[lL]ine\s+(\S+)\s+(\S+)\s+(.*)/;
- }
- $monitor{modelines} .= $_ foreach values %{$monitor{modelines_}}; delete $monitor{modelines_};
#- get the default resolution according the the current file.
#- suggestion to take into account, but that have to be checked.
- $o->{card}{suggest_depth} = $card{default_depth};
+ $X->{card}{suggest_depth} = $card{default_depth};
if (my @depth = keys %{$card{depth}}) {
- $o->{card}{suggest_wres} = ($card{depth}{$o->{card}{suggest_depth} || $depth[0]}[0][0]);
+ $X->{card}{suggest_x_res} = ($card{depth}{$X->{card}{suggest_depth} || $depth[0]}[0][0]);
}
#- final clean-up.
@@ -163,44 +169,46 @@ sub getinfoFromXF86Config {
$mouse{auxmouse}{nbuttons} ||= 3;
mouse::update_type_name(\%mouse); #- allow getting fullname (type|name).
mouse::update_type_name($mouse{auxmouse});
- delete $mouse{auxmouse} unless $mouse{auxmouse}{XMOUSETYPE}; #- only take care of a true mouse.
+ delete $mouse{auxmouse} if !$mouse{auxmouse}{XMOUSETYPE}; #- only take care of a true mouse.
- #- try to merge with $o, the previous has been obtained by ddcxinfos.
- put_in_hash($o->{keyboard} ||= {}, \%keyboard);
- add2hash($o->{mouse} ||= {}, \%mouse);
- @{$o->{wacom} || []} > 0 or $o->{wacom} = [ keys %wacom ];
- add2hash($o->{monitor} ||= {}, \%monitor);
+ #- try to merge with $X, the previous has been obtained by ddcxinfos.
+ put_in_hash($X->{keyboard} ||= {}, \%keyboard);
+ add2hash($X->{mouse} ||= {}, \%mouse);
+ @{$X->{wacom} || []} > 0 or $X->{wacom} = [ keys %wacom ];
+ add2hash($X->{monitor} ||= {}, \%monitor);
- $o;
+ $X;
}
sub getinfoFromSysconfig {
- my $o = shift || {};
+ my $X = shift || {};
my $prefix = shift || "";
- add2hash($o->{mouse} ||= {}, { getVarsFromSh("$prefix/etc/sysconfig/mouse") });
+ add2hash($X->{mouse} ||= {}, { getVarsFromSh("$prefix/etc/sysconfig/mouse") });
if (my %keyboard = getVarsFromSh "$prefix/etc/sysconfig/keyboard") {
- $o->{keyboard}{xkb_keymap} ||= keyboard_from_kmap($keyboard{KEYTABLE}) if $keyboard{KEYTABLE};
+ $X->{keyboard}{XkbLayout} ||= keyboard_from_kmap($keyboard{KEYTABLE}) if $keyboard{KEYTABLE};
}
- $o;
+ $X;
}
sub getinfoFromDDC {
- my $o = shift || {};
- my $O = $o->{monitor} ||= {};
- #- return $o if $O->{hsyncrange} && $O->{vsyncrange} && $O->{modelines};
+ my $X = shift || {};
+ my $O = $X->{monitor} ||= {};
+ #- return $X if $O->{hsyncrange} && $O->{vsyncrange} && $O->{ModeLines};
my ($m, @l) = any::ddcxinfos();
- $? == 0 or return $o;
+ $? == 0 or return $X;
- $o->{card}{memory} ||= to_int($m);
+ $X->{card}{VideoRam} ||= to_int($m);
local $_;
while (($_ = shift @l) ne "\n") {
my ($depth, $x, $y) = split;
$depth = int(log($depth) / log(2));
if ($depth >= 8 && $x >= 640) {
- push @{$o->{card}{depth}{$depth}}, [ $x, $y ] unless scalar grep { $_->[0] == $x && $_->[1] == $y } @{$o->{card}{depth}{$depth}};
- push @{$o->{card}{depth}{32}}, [ $x, $y ] if $depth == 24 && ! scalar grep { $_->[0] == $x && $_->[1] == $y } @{$o->{card}{depth}{32}};
+ push @{$X->{card}{depth}{$depth}}, [ $x, $y ]
+ if ! grep { $_->[0] == $x && $_->[1] == $y } @{$X->{card}{depth}{$depth}};
+ push @{$X->{card}{depth}{32}}, [ $x, $y ]
+ if $depth == 24 && ! grep { $_->[0] == $x && $_->[1] == $y } @{$X->{card}{depth}{32}};
}
}
my ($h, $v, $size, @m) = @l;
@@ -209,8 +217,88 @@ sub getinfoFromDDC {
$O->{vsyncrange} ||= first($v =~ /^(\S*)/);
$O->{size} ||= to_float($size);
$O->{EISA_ID} = lc($1) if $size =~ /EISA ID=(\S*)/;
- $O->{modelines} ||= join '', @m;
- $o;
+ $O->{ModeLines_xf3} ||= join '', @m;
+ $X;
+}
+
+
+sub XF86check_link {
+ my ($prefix, $ext) = @_;
+
+ my $f = "$prefix/etc/X11/XF86Config$ext";
+ touch($f);
+
+ my $l = "$prefix/usr/X11R6/lib/X11/XF86Config$ext";
+
+ if (-e $l && (stat($f))[1] != (stat($l))[1]) { #- compare the inode, must be the sames
+ -e $l and unlink($l) || die "can't remove bad $l";
+ symlinkf "../../../../etc/X11/XF86Config$ext", $l;
+ }
+}
+
+sub add2card {
+ my ($card, $other_card) = @_;
+
+ push @{$card->{lines}}, @{$other_card->{lines} || []};
+ add2hash($card->{flags}, $other_card->{flags});
+ add2hash($card, $other_card);
+}
+
+sub readCardsDB {
+ my ($file) = @_;
+ my ($card, %cards);
+
+ my $F = common::openFileMaybeCompressed($file);
+
+ my ($lineno, $cmd, $val) = 0;
+ my $fs = {
+ NAME => sub {
+ $cards{$card->{type}} = $card if $card;
+ $card = { type => $val };
+ },
+ SEE => sub {
+ my $c = $cards{$val} or die "Error in database, invalid reference $val at line $lineno";
+ add2card($card, $c);
+ },
+ CHIPSET => sub {
+ $card->{Chipset} = $val;
+ $card->{flags}{needVideoRam} = 1 if member($val, qw(mgag10 mgag200 RIVA128 SiS6326));
+ },
+ LINE => sub {
+ push @{$card->{lines}}, $val;
+ },
+ SERVER => sub { $card->{server} = $val },
+ DRIVER => sub { $card->{driver} = $val },
+ DRIVER2 => sub { $card->{driver2} = $val },
+ NEEDVIDEORAM => sub { $card->{flags}{needVideoRam} = 1 },
+ DRI_GLX => sub { $card->{DRI_GLX} = 1 },
+ UTAH_GLX => sub { $card->{UTAH_GLX} = 1 },
+ DRI_GLX_EXPERIMENTAL => sub { $card->{DRI_GLX_EXPERIMENTAL} = 1 },
+ UTAH_GLX_EXPERIMENTAL => sub { $card->{UTAH_GLX_EXPERIMENTAL} = 1 },
+ UNSUPPORTED => sub { delete $card->{driver} },
+
+ #- Obsolete stuff, no existing card still need this
+ RAMDAC => sub { $card->{Ramdac} = $val },
+ DACSPEED => sub { $card->{Dacspeed} = $val },
+ CLOCKCHIP => sub { $card->{Clockchip} = $val },
+
+ COMMENT => sub {},
+ };
+
+ local $_;
+ while (<$F>) { $lineno++;
+ s/\s+$//;
+ /^#/ and next;
+ /^$/ and next;
+ /^END/ and do { $cards{$card->{type}} = $card if $card; last };
+
+ ($cmd, $val) = /(\S+)\s*(.*)/ or next; #log::l("bad line $lineno ($_)"), next;
+
+ my $f = $fs->{$cmd};
+
+ $f ? $f->() : log::l("unknown line $lineno ($_)");
+ }
+ \%cards;
}
1;