1 |
package Xconfig::card; # $Id: card.pm 266355 2010-02-22 20:51:38Z pzanoni $ |
2 |
|
3 |
use diagnostics; |
4 |
use strict; |
5 |
|
6 |
use lib '/usr/lib/libDrakX'; |
7 |
use detect_devices; |
8 |
use Xconfig::xfree; |
9 |
use modules; |
10 |
use common; |
11 |
use interactive; |
12 |
use log; |
13 |
use run_program; |
14 |
|
15 |
my $lib = arch() =~ /x86_64/ ? "lib64" : "lib"; |
16 |
|
17 |
sub modules_dir() { "/usr/$lib/xorg/modules" } |
18 |
|
19 |
my %VideoRams = ( |
20 |
256 => N_("256 kB"), |
21 |
512 => N_("512 kB"), |
22 |
1024 => N_("1 MB"), |
23 |
2048 => N_("2 MB"), |
24 |
4096 => N_("4 MB"), |
25 |
8192 => N_("8 MB"), |
26 |
16384 => N_("16 MB"), |
27 |
32768 => N_("32 MB"), |
28 |
65536 => N_("64 MB or more"), |
29 |
); |
30 |
|
31 |
my @xfree4_Drivers = ((arch() =~ /^sparc/ ? qw(sunbw2 suncg14 suncg3 suncg6 sunffb sunleo suntcx) : |
32 |
qw(apm ark ast chips cirrus i128 i740 intel mga |
33 |
neomagic newport nouveau nv openchrome psb qxl |
34 |
rendition s3 s3virge savage siliconmotion sis sisusb |
35 |
tdfx tga trident tseng vesa vmware xgi xgixp)), |
36 |
if_(arch() =~ /i.86/, qw(geode)), |
37 |
qw(ati glint fbdev)); |
38 |
|
39 |
sub from_raw_X { |
40 |
my ($raw_X) = @_; |
41 |
|
42 |
my ($device, @cards) = $raw_X->get_devices or die "no card configured"; |
43 |
|
44 |
my $card = { |
45 |
use_DRI_GLX => eval { any { /dri/ } $raw_X->get_modules }, |
46 |
DRI_GLX_SPECIAL => $device->{Driver} eq 'nvidia' && eval { any { $_ eq 'glx' } $raw_X->get_modules }, |
47 |
%$device, |
48 |
if_($device->{Driver} eq 'nvidia', |
49 |
DriverVersion => |
50 |
readlink("$::prefix/etc/alternatives/gl_conf") =~ m!nvidia(.*)/! ? $1 : '97xx'), |
51 |
if_(@cards, cards => \@cards), |
52 |
}; |
53 |
add_to_card__using_Cards($card, $card->{BoardName}); |
54 |
$card; |
55 |
} |
56 |
|
57 |
sub to_raw_X { |
58 |
my ($card, $raw_X) = @_; |
59 |
|
60 |
my @cards = ($card, @{$card->{cards} || []}); |
61 |
|
62 |
foreach (@cards) { |
63 |
if (arch() =~ /ppc/ && ($_->{Driver} eq 'r128' || $_->{Driver} eq 'radeon')) { |
64 |
$_->{UseFBDev} = 1; |
65 |
} |
66 |
} |
67 |
|
68 |
$raw_X->set_devices(@cards); |
69 |
|
70 |
$raw_X->get_ServerLayout->{Xinerama} = { commented => !$card->{Xinerama}, Option => 1 } |
71 |
if defined $card->{Xinerama}; |
72 |
|
73 |
# cleanup deprecated previous special nvidia explicit libglx |
74 |
$raw_X->remove_load_module(modules_dir() . "$_/libglx.so") foreach '/extensions/nvidia', '/extensions/nvidia_legacy', '/extensions'; |
75 |
|
76 |
# remove ModulePath that we added |
77 |
$raw_X->remove_ModulePath(modules_dir() . "/extensions/$_") foreach 'nvidia97xx', 'nvidia96xx', 'nvidia71xx', 'nvidia-current'; |
78 |
$raw_X->remove_ModulePath(modules_dir()); |
79 |
#- if we have some special ModulePath, ensure the last one is the standard ModulePath |
80 |
$raw_X->add_ModulePath(modules_dir()) if $raw_X->get_ModulePaths; |
81 |
|
82 |
#- un-disable modules that we previously disabled |
83 |
$raw_X->remove_disable_module('glx'); |
84 |
$raw_X->remove_disable_module('dri'); |
85 |
|
86 |
$raw_X->remove_Section('DRI'); |
87 |
|
88 |
$raw_X->remove_load_module('v4l') if $card->{use_DRI_GLX} && $card->{Driver} eq 'r128'; |
89 |
} |
90 |
|
91 |
sub probe() { |
92 |
#-for Pixel tests |
93 |
#- my @c = { driver => 'Card:Matrox Millennium G400 DualHead', description => 'Matrox|Millennium G400 Dual HeadCard' }; |
94 |
my @c = detect_devices::matching_driver__regexp('^(Card|Server|Driver):'); |
95 |
|
96 |
my @cards = map { |
97 |
my @l = $_->{description} =~ /(.*?)\|(.*)/; |
98 |
my $card = { |
99 |
description => $_->{description}, |
100 |
VendorName => $l[0], BoardName => $l[1], |
101 |
BusID => "PCI:$_->{pci_bus}:$_->{pci_device}:$_->{pci_function}", |
102 |
}; |
103 |
if (my ($card_name) = $_->{driver} =~ /Card:(.*)/) { |
104 |
$card->{BoardName} = $card_name; |
105 |
add_to_card__using_Cards($card, $card_name); |
106 |
} elsif ($_->{driver} =~ /Driver:(.*)/) { |
107 |
$card->{Driver} = $1; |
108 |
} else { |
109 |
internal_error(); |
110 |
} |
111 |
#dual head ATI card have a dummy DISPLAY_OTHER pci device because it |
112 |
#was needed by Win2000, filter those out because we don't want to |
113 |
#behave as if there were 2 video cards in the system in such cases |
114 |
($_->{media_type} eq 'DISPLAY_VGA') ? $card : (); |
115 |
} @c; |
116 |
|
117 |
if (@cards >= 2 && $cards[0]{card_name} eq $cards[1]{card_name} && $cards[0]{card_name} eq 'Intel 830 - 965') { |
118 |
shift @cards; |
119 |
} |
120 |
#- take a default on sparc if nothing has been found. |
121 |
if (arch() =~ /^sparc/ && !@cards) { |
122 |
log::l("Using probe with /proc/fb as nothing has been found!"); |
123 |
my $s = cat_("/proc/fb"); |
124 |
@cards = { server => $s =~ /Mach64/ ? "Mach64" : $s =~ /Permedia2/ ? "3DLabs" : "Sun24" }; |
125 |
} |
126 |
|
127 |
#- disabling MULTI_HEAD when not available |
128 |
foreach (@cards) { |
129 |
$_->{MULTI_HEAD} && $_->{card_name} =~ /G[24]00/ or next; |
130 |
if ($ENV{MATROX_HAL}) { |
131 |
$_->{need_MATROX_HAL} = 1; |
132 |
} else { |
133 |
delete $_->{MULTI_HEAD}; |
134 |
} |
135 |
} |
136 |
|
137 |
#- in case of only one cards, remove all BusID reference, this will avoid |
138 |
#- need of change of it if the card is moved. |
139 |
#- on many PPC machines, card is on-board, BusID is important, leave? |
140 |
if (@cards == 1 && !$cards[0]{MULTI_HEAD} && arch() !~ /ppc/) { |
141 |
delete $cards[0]{BusID}; |
142 |
} |
143 |
|
144 |
@cards; |
145 |
} |
146 |
|
147 |
sub card_config__not_listed { |
148 |
my ($in, $card, $options) = @_; |
149 |
|
150 |
my $vendors_regexp = join '|', map { quotemeta } ( |
151 |
'3Dlabs', |
152 |
'AOpen', 'ASUS', 'ATI', 'Ark Logic', 'Avance Logic', |
153 |
'Cardex', 'Chaintech', 'Chips & Technologies', 'Cirrus Logic', 'Compaq', 'Creative Labs', |
154 |
'Dell', 'Diamond', 'Digital', |
155 |
'ET', 'Elsa', |
156 |
'Genoa', 'Guillemot', 'Hercules', 'Intel', 'Leadtek', |
157 |
'Matrox', 'Miro', 'NVIDIA', 'NeoMagic', 'Number Nine', |
158 |
'Oak', 'Orchid', |
159 |
'RIVA', 'Rendition Verite', |
160 |
'S3', 'Silicon Motion', 'STB', 'SiS', 'Sun', |
161 |
'Toshiba', 'Trident', |
162 |
'VideoLogic', |
163 |
); |
164 |
my $cards = readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+"); |
165 |
|
166 |
my @xf4 = grep { $options->{allowFB} || $::isStandalone || $_ ne 'fbdev' } |
167 |
uniq(@xfree4_Drivers, map { $_->{Driver} } values %$cards); |
168 |
my @list = ( |
169 |
(map { 'Vendor|' . $_ } keys %$cards), |
170 |
(map { 'Xorg|' . $_ } @xf4), |
171 |
); |
172 |
|
173 |
my $r = exists $cards->{$card->{BoardName}} ? "Vendor|$card->{BoardName}" : 'Xorg|vesa'; |
174 |
$in->ask_from_({ title => N("X server"), |
175 |
messages => N("Choose an X server"), |
176 |
interactive_help_id => 'configureX_card_list', |
177 |
}, |
178 |
[ { val => \$r, separator => '|', list => \@list, sort => 1, |
179 |
format => sub { $_[0] =~ /^Vendor\|($vendors_regexp)\s*-?(.*)/ ? "Vendor|$1|$2" : |
180 |
$_[0] =~ /^Vendor\|(.*)/ ? "Vendor|Other|$1" : $_[0] } } ]) or return; |
181 |
|
182 |
log::explanations("Xconfig::card: $r manually chosen"); |
183 |
|
184 |
$r eq "Vendor|$card->{BoardName}" and return 1; #- it is unchanged, do not modify $card |
185 |
|
186 |
my ($kind, $s) = $r =~ /(.*?)\|(.*)/; |
187 |
|
188 |
%$card = (); |
189 |
if ($kind eq 'Vendor') { |
190 |
add_to_card__using_Cards($card, $s); |
191 |
} else { |
192 |
$card->{Driver} = $s; |
193 |
$card->{DRI_GLX} = 0; |
194 |
} |
195 |
$card->{manually_chosen} = 1; |
196 |
1; |
197 |
} |
198 |
|
199 |
sub multi_head_choose { |
200 |
my ($in, $_auto, @cards) = @_; |
201 |
|
202 |
my @choices = multi_head_choices('', @cards); |
203 |
|
204 |
my $tc = $choices[0]; |
205 |
if (@choices > 1) { |
206 |
$tc = $in->ask_from_listf(N("Multi-head configuration"), |
207 |
N("Your system supports multiple head configuration. |
208 |
What do you want to do?"), sub { $_[0]{text} }, \@choices) or return; |
209 |
} |
210 |
$tc->{code} or die internal_error(); |
211 |
return $tc->{code}(); |
212 |
} |
213 |
|
214 |
sub configure_auto_install { |
215 |
my ($raw_X, $do_pkgs, $old_X, $options) = @_; |
216 |
|
217 |
my $card = $old_X->{card} || {}; |
218 |
|
219 |
if ($card->{card_name}) { |
220 |
#- try to get info from given card_name |
221 |
add_to_card__using_Cards($card, $card->{card_name}); |
222 |
if (!$card->{Driver}) { |
223 |
log::l("bad card_name $card->{card_name}, using probe"); |
224 |
undef $card->{card_name}; |
225 |
} |
226 |
} |
227 |
|
228 |
my ($boot_xdriver) = cat_("/proc/cmdline") =~ /.*\bxdriver=(\S+)/; |
229 |
|
230 |
$options->{freedriver} = 1 if $boot_xdriver eq 'free'; |
231 |
|
232 |
if (!$card->{Driver} && $boot_xdriver && !member($boot_xdriver, 'auto', 'free')) { |
233 |
log::explanations("using driver $boot_xdriver from kernel command line"); |
234 |
$card = { |
235 |
Driver => $boot_xdriver, |
236 |
description => "Set by boot parameter", |
237 |
VendorName => "Custom", |
238 |
BoardName => "Set by boot parameter", |
239 |
}; |
240 |
if ($boot_xdriver =~ /^(nvidia.|fglrx)/) { |
241 |
$card->{Driver} = "vesa"; |
242 |
$card->{Driver2} = $boot_xdriver; |
243 |
} |
244 |
} |
245 |
|
246 |
if (!$card->{Driver}) { |
247 |
my @cards = probe(); |
248 |
my ($choice) = multi_head_choices($old_X->{Xinerama}, @cards); |
249 |
$card = $choice ? $choice->{code}() : do { |
250 |
log::explanations('no graphic card probed, try providing one using $o->{card}{Driver} or $o->{card}{card_name}. Defaulting...'); |
251 |
{ Driver => $options->{allowFB} ? 'fbdev' : 'vesa' }; |
252 |
}; |
253 |
} |
254 |
|
255 |
install_server($card, $options, $do_pkgs, undef) or return; |
256 |
$card = configure_Driver2($card, undef); |
257 |
|
258 |
Xconfig::various::various_auto_install($raw_X, $card, $old_X); |
259 |
set_glx_restrictions($card); |
260 |
|
261 |
if ($card->{needVideoRam} && !$card->{VideoRam}) { |
262 |
$card->{VideoRam} = $options->{VideoRam_probed} || 4096; |
263 |
log::explanations("argh, I need to know VideoRam! Taking " . ($options->{probed_VideoRam} ? "the probed" : "a default") . " value: VideoRam = $card->{VideoRam}"); |
264 |
} |
265 |
to_raw_X($card, $raw_X); |
266 |
$card; |
267 |
} |
268 |
|
269 |
sub configure { |
270 |
my ($in, $raw_X, $do_pkgs, $auto, $options) = @_; |
271 |
|
272 |
my @cards = probe(); |
273 |
@cards or @cards = {}; |
274 |
|
275 |
if (!$cards[0]{Driver}) { |
276 |
if ($options->{allowFB}) { |
277 |
$cards[0]{Driver} = 'fbdev'; |
278 |
} |
279 |
} |
280 |
if (!$auto || !$cards[0]{Driver}) { |
281 |
card_config__not_listed: |
282 |
card_config__not_listed($in, $cards[0], $options) or return; |
283 |
} |
284 |
|
285 |
my $card = multi_head_choose($in, $auto, @cards) or return; |
286 |
|
287 |
install_server($card, $options, $do_pkgs, $in) or goto card_config__not_listed; |
288 |
|
289 |
$card = configure_Driver2($card, $in); |
290 |
|
291 |
Xconfig::various::various($in, $raw_X, $card, $options, $auto); |
292 |
set_glx_restrictions($card); |
293 |
|
294 |
if ($card->{needVideoRam} && !$card->{VideoRam}) { |
295 |
$card->{VideoRam} = (find { $_ <= $options->{VideoRam_probed} } reverse ikeys %VideoRams) || 4096; |
296 |
$in->ask_from('', N("Select the memory size of your graphics card"), |
297 |
[ { val => \$card->{VideoRam}, |
298 |
type => 'list', |
299 |
list => [ ikeys %VideoRams ], |
300 |
format => sub { translate($VideoRams{$_[0]}) }, |
301 |
not_edit => 0 } ]) or return; |
302 |
} |
303 |
|
304 |
to_raw_X($card, $raw_X); |
305 |
$card; |
306 |
} |
307 |
|
308 |
sub install_server { |
309 |
my ($card, $options, $do_pkgs, $o_in) = @_; |
310 |
|
311 |
my @packages; |
312 |
my @must_have = "x11-driver-video-$card->{Driver}"; |
313 |
|
314 |
if ($options->{freedriver}) { |
315 |
delete $card->{Driver2}; |
316 |
} |
317 |
|
318 |
if ($card->{Driver2}) { |
319 |
require Xconfig::proprietary; |
320 |
Xconfig::proprietary::handle_DRIVER2_NO_SSE($card); |
321 |
my @pkgs = Xconfig::proprietary::pkgs_for_Driver2($card->{Driver2}, $do_pkgs); |
322 |
if (@pkgs && (!$o_in || $o_in->ask_yesorno('', formatAlaTeX(N("There is a proprietary driver available for your video card which may support additional features. |
323 |
Do you wish to use it?")), 1))) { |
324 |
push @packages, @pkgs; |
325 |
} else { |
326 |
delete $card->{Driver2}; |
327 |
} |
328 |
} |
329 |
|
330 |
$do_pkgs->ensure_are_installed([ @must_have, @packages ], 1) or |
331 |
@must_have == listlength($do_pkgs->are_installed(@must_have)) |
332 |
or return; |
333 |
|
334 |
if ($card->{need_MATROX_HAL}) { |
335 |
require Xconfig::proprietary; |
336 |
Xconfig::proprietary::install_matrox_hal($::prefix); |
337 |
} |
338 |
1; |
339 |
} |
340 |
|
341 |
sub configure_Driver2 { |
342 |
my ($card, $o_in) = @_; |
343 |
|
344 |
if ($card->{Driver2}) { |
345 |
require Xconfig::proprietary; |
346 |
if (my $card2 = Xconfig::proprietary::may_use_Driver2($card)) { |
347 |
$card = $card2; |
348 |
} else { |
349 |
$o_in and $o_in->ask_warn('', formatAlaTeX(N("The proprietary driver was not properly installed, defaulting to free software driver."))); |
350 |
log::l("defaulting to free software driver"); |
351 |
} |
352 |
} |
353 |
|
354 |
libgl_config_and_more($card); |
355 |
$card; |
356 |
} |
357 |
|
358 |
#- configures which libGL.so.1 to use, using update-alternatives |
359 |
#- it also configures nvidia_drv.so (using a slave alternative, cf "update-alternatives --display gl_conf") |
360 |
sub libgl_config_and_more { |
361 |
my ($card) = @_; |
362 |
|
363 |
if ($card->{Driver} eq 'nvidia') { |
364 |
$card->{DriverVersion} or internal_error("DriverVersion should be set for driver nvidia!"); |
365 |
} |
366 |
|
367 |
#- ensure old deprecated conf files are not there anymore |
368 |
unlink("/etc/ld.so.conf.d/$_.conf") foreach 'nvidia', 'nvidia_legacy', 'ati'; |
369 |
|
370 |
my %files = ( |
371 |
fglrx => "/etc/ld.so.conf.d/GL/ati$card->{DriverVersion}.conf", |
372 |
nvidia => "/etc/nvidia$card->{DriverVersion}/ld.so.conf", |
373 |
psb => "/etc/ld.so.conf.d/GL/libdrm-psb.conf", |
374 |
); |
375 |
my $wanted = $files{$card->{Driver}} || '/etc/ld.so.conf.d/GL/standard.conf'; |
376 |
my $link = "$::prefix/etc/alternatives/gl_conf"; |
377 |
my $need_run_ldconfig = readlink($link) ne $wanted; |
378 |
-e "$::prefix$wanted" or log::l("ERROR: $wanted does not exist, linking $link to it anyway"); |
379 |
common::symlinkf_update_alternatives('gl_conf', $wanted); |
380 |
if ($need_run_ldconfig) { |
381 |
log::explanations("ldconfig will be run because the GL library was switched to $wanted"); |
382 |
run_program::rooted($::prefix, 'ldconfig', '-X'); |
383 |
} |
384 |
|
385 |
if (member($card->{Driver}, 'fglrx', 'nvidia')) { |
386 |
log::l("workaround buggy fglrx/nvidia driver: make dm restart xserver (#29550, #38297)"); |
387 |
eval { common::update_gnomekderc_no_create("$::prefix/etc/kde/kdm/kdmrc", 'X-:0-Core' => ( |
388 |
TerminateServer => "true", |
389 |
)) }; |
390 |
eval { update_gnomekderc("$::prefix/etc/X11/gdm/custom.conf", daemon => ( |
391 |
AlwaysRestartServer => "true", |
392 |
)) }; |
393 |
} |
394 |
} |
395 |
|
396 |
sub multi_head_choices { |
397 |
my ($want_Xinerama, @cards) = @_; |
398 |
my @choices; |
399 |
|
400 |
my $has_multi_head = @cards > 1 || @cards && $cards[0]{MULTI_HEAD} > 1; |
401 |
my $disable_multi_head = any { |
402 |
$_->{Driver} or log::explanations("found card $_->{description} not supported by XF4, disabling multi-head support"); |
403 |
!$_->{Driver}; |
404 |
} @cards; |
405 |
|
406 |
if ($has_multi_head && !$disable_multi_head) { |
407 |
my $configure_multi_head = sub { |
408 |
|
409 |
#- special case for multi head card using only one BusID. |
410 |
@cards = map { |
411 |
map_index { { Screen => $::i, %$_ } } ($_) x ($_->{MULTI_HEAD} || 1); |
412 |
} @cards; |
413 |
|
414 |
my $card = shift @cards; #- assume good default. |
415 |
$card->{cards} = \@cards; |
416 |
$card->{Xinerama} = $_[0]; |
417 |
$card; |
418 |
}; |
419 |
my $independent = { text => N("Configure all heads independently"), code => sub { $configure_multi_head->('') } }; |
420 |
my $xinerama = { text => N("Use Xinerama extension"), code => sub { $configure_multi_head->(1) } }; |
421 |
push @choices, $want_Xinerama ? ($xinerama, $independent) : ($independent, $xinerama); |
422 |
} |
423 |
|
424 |
foreach my $c (@cards) { |
425 |
push @choices, { text => N("Configure only card \"%s\"%s", $c->{description}, $c->{BusID} && " ($c->{BusID})"), |
426 |
code => sub { $c } }; |
427 |
} |
428 |
@choices; |
429 |
} |
430 |
|
431 |
sub set_glx_restrictions { |
432 |
my ($card) = @_; |
433 |
|
434 |
#- 3D acceleration configuration for XFree 4 using DRI, this is enabled by default |
435 |
#- but for some there is a need to specify VideoRam (else it will not run). |
436 |
if ($card->{use_DRI_GLX}) { |
437 |
$card->{needVideoRam} = 1 if $card->{description} =~ /Matrox.* G[245][05]0/; |
438 |
($card->{needVideoRam}, $card->{VideoRam}) = (1, 16384) |
439 |
if $card->{card_name} eq 'Intel 810 / 815'; |
440 |
|
441 |
#- hack for ATI Rage 128 card using a bttv or peripheral with PCI bus mastering exchange |
442 |
#- AND using DRI at the same time. |
443 |
if ($card->{card_name} eq 'ATI Rage 128 TV-out') { |
444 |
$card->{Options}{UseCCEFor2D} = bool2text(detect_devices::probe_category('multimedia/tv')); |
445 |
} |
446 |
} |
447 |
} |
448 |
|
449 |
sub add_to_card__using_Cards { |
450 |
my ($card, $name) = @_; |
451 |
my $cards = readCardsDB("$ENV{SHARE_PATH}/ldetect-lst/Cards+"); |
452 |
add2hash($card, $cards->{$name}); |
453 |
$card->{BoardName} = $card->{card_name}; |
454 |
|
455 |
$card; |
456 |
} |
457 |
|
458 |
#- needed for bad cards not restoring cleanly framebuffer, according to which version of Xorg are used. |
459 |
sub check_bad_card { |
460 |
my ($card) = @_; |
461 |
my $bad_card = $card->{BAD_FB_RESTORE}; |
462 |
$bad_card ||= $card->{Driver} eq 'intel' || $card->{Driver} eq 'fbdev'; |
463 |
$bad_card ||= member($card->{Driver}, 'nvidia', 'vmware') if !$::isStandalone; #- avoid testing during install at any price. |
464 |
|
465 |
log::explanations("the graphics card does not like X in framebuffer") if $bad_card; |
466 |
|
467 |
!$bad_card; |
468 |
} |
469 |
|
470 |
sub readCardsDB { |
471 |
my ($file) = @_; |
472 |
my ($card, %cards); |
473 |
|
474 |
my $F = openFileMaybeCompressed($file); |
475 |
|
476 |
my $lineno = 0; |
477 |
my ($cmd, $val); |
478 |
my $fs = { |
479 |
NAME => sub { |
480 |
$cards{$card->{card_name}} = $card if $card; |
481 |
$card = { card_name => $val }; |
482 |
}, |
483 |
SEE => sub { |
484 |
my $c = $cards{$val} or die "Error in database, invalid reference $val at line $lineno"; |
485 |
add2hash($card, $c); |
486 |
}, |
487 |
LINE => sub { $val =~ s/^\s*//; $card->{raw_LINES} .= "$val\n" }, |
488 |
CHIPSET => sub { $card->{Chipset} = $val }, |
489 |
DRIVER => sub { $card->{Driver} = $val }, |
490 |
DRIVER2 => sub { $card->{Driver2} = $val }, |
491 |
DRIVER2_NO_SSE => sub { $card->{DRIVER2_NO_SSE} = $val }, |
492 |
NEEDVIDEORAM => sub { $card->{needVideoRam} = 1 }, |
493 |
DRI_GLX => sub { $card->{DRI_GLX} = 1 if $card->{Driver} }, |
494 |
DRI_GLX_EXPERIMENTAL => sub { $card->{DRI_GLX_EXPERIMENTAL} = 1 if $card->{Driver} }, |
495 |
MULTI_HEAD => sub { $card->{MULTI_HEAD} = $val if $card->{Driver} }, |
496 |
BAD_FB_RESTORE => sub { $card->{BAD_FB_RESTORE} = 1 }, |
497 |
FB_TVOUT => sub { $card->{FB_TVOUT} = 1 }, |
498 |
UNSUPPORTED => sub { delete $card->{Driver} }, |
499 |
COMMENT => sub {}, |
500 |
}; |
501 |
|
502 |
local $_; |
503 |
while (<$F>) { $lineno++; |
504 |
s/\s+$//; |
505 |
/^#/ and next; |
506 |
/^$/ and next; |
507 |
/^END/ and do { $cards{$card->{card_name}} = $card if $card; last }; |
508 |
|
509 |
($cmd, $val) = /(\S+)\s*(.*)/ or next; |
510 |
|
511 |
my $f = $fs->{$cmd}; |
512 |
|
513 |
$f ? $f->() : log::l("unknown line $lineno ($_)"); |
514 |
} |
515 |
\%cards; |
516 |
} |
517 |
|
518 |
1; |
519 |
|