-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgpu-configuration
685 lines (586 loc) · 24.6 KB
/
gpu-configuration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import errno
import subprocess
try:
from subprocess import getoutput
except ImportError:
from commands import getoutput
import shutil
from sys import exit as goto, argv
lspci = '/usr/sbin/lspci'
nvidia_settings = "/usr/share/applications/nvidia-settings.desktop"
modprobe_blacklist = '/etc/modprobe.d/blacklist.conf'
# Taken from here:
# http://www.nvidia.com/object/IO_32667.html
nvidia_390xx_supported = [
'0083', '0106', '0177', '0180', '0190', '0192', '01c0', '0224',
'054d', '054e', '0554', '0557', '0562', '0565', '0568', '0590',
'0592', '0594', '0595', '05a2', '05b1', '05b3', '05da', '05de',
'05e0', '05e8', '05f4', '0600', '0606', '060f', '0625', '062f',
'064a', '064c', '064e', '0652', '0653', '0655', '065e', '0662',
'067a', '0680', '0686', '0689', '068b', '068d', '068e', '0691',
'0692', '0694', '06ad', '06ae', '06af', '06b0', '06c0', '06c1',
'06c4', '06ca', '06cd', '06d1', '06d2', '06d8', '06d9', '06da',
'06dc', '06dd', '06de', '06df', '0702', '0719', '0725', '0728',
'072b', '072e', '0732', '0753', '0754', '0763', '0771', '0772',
'0773', '0774', '0776', '077a', '077b', '077c', '077d', '077e',
'077f', '0781', '0798', '0799', '079b', '079c', '0807', '0821',
'0823', '082f', '0830', '0833', '0837', '083e', '0840', '0841',
'0842', '0846', '0853', '0854', '0855', '0856', '0857', '0858',
'0863', '0866', '0868', '0869', '0873', '0878', '087b', '087f',
'0881', '0885', '088a', '088e', '088f', '0891', '089b', '0907',
'0911', '0914', '091e', '0921', '0926', '092e', '092f', '0932',
'093a', '093c', '093f', '0941', '0945', '0952', '0953', '0954',
'0965', '0974', '0982', '0983', '098d', '0dac', '0dad', '0dc0',
'0dc4', '0dc5', '0dc6', '0dcd', '0dce', '0dd1', '0dd2', '0dd3',
'0dd6', '0dd8', '0dda', '0de0', '0de1', '0de2', '0de3', '0de4',
'0de5', '0de7', '0de8', '0de9', '0dea', '0deb', '0dec', '0ded',
'0dee', '0def', '0df0', '0df1', '0df2', '0df3', '0df4', '0df5',
'0df6', '0df7', '0df8', '0df9', '0dfa', '0dfc', '0e22', '0e23',
'0e24', '0e30', '0e31', '0e3a', '0e3b', '0ef3', '0f00', '0f01',
'0f02', '0f03', '1005', '1012', '1013', '1019', '1025', '1028',
'1030', '103c', '1040', '1042', '1043', '1048', '1049', '104a',
'104b', '104c', '1050', '1051', '1052', '1054', '1055', '1056',
'1057', '1058', '1059', '105a', '105b', '1067', '107c', '107d',
'1080', '1081', '1082', '1084', '1086', '1087', '1088', '1089',
'108b', '1091', '1092', '1094', '1096', '109a', '109b', '10b8',
'10cc', '10cf', '10dd', '10de', '10e9', '10ed', '1116', '1140',
'1179', '11fd', '1200', '1201', '1203', '1205', '1206', '1207',
'1208', '1210', '1211', '1212', '1213', '1241', '1243', '1244',
'1245', '1246', '1247', '1248', '1249', '124b', '124d', '1251',
'126d', '131d', '13fd', '144d', '1462', '14c0', '14c7', '1507',
'152d', '15ad', '15ed', '160d', '163d', '165d', '166d', '16cd',
'16dd', '170d', '174b', '176d', '178d', '179d', '17aa', '17f5',
'1854', '18ef', '18f9', '18fb', '18fd', '18ff', '1b0a', '1b50',
'1b6c', '1bab', '1d05', '20dd', '20df', '210e', '212a', '212b',
'212c', '2132', '2136', '218a', '21ba', '21bb', '21bc', '21fa',
'2200', '2202', '220a', '220e', '2210', '2212', '2213', '2214',
'2218', '221a', '2220', '223a', '224a', '225b', '225d', '226d',
'226f', '227a', '228a', '22d2', '22d9', '22fa', '232a', '2335',
'2337', '233a', '235a', '236a', '238a', '2aef', '2af1', '2af9',
'2afb', '309c', '30b1', '30b4', '30b7', '30e4', '30f3', '361b',
'361c', '361d', '3656', '365a', '365b', '365e', '3660', '3661',
'366c', '3682', '3685', '3686', '3687', '3692', '3695', '3696',
'369b', '369c', '369d', '369e', '36a1', '36a6', '36a7', '36a8',
'36a9', '36ac', '36ad', '36af', '36b0', '36b6', '3800', '3801',
'3802', '3803', '3804', '3806', '3808', '380d', '380e', '380f',
'3811', '3812', '3813', '3816', '3817', '3818', '381a', '381c',
'381d', '3901', '3902', '3903', '3904', '3905', '3907', '3910',
'3912', '3913', '3915', '3977', '3983', '5001', '5003', '5005',
'500d', '5014', '5017', '5019', '501a', '501f', '5025', '5027',
'502a', '502b', '502d', '502e', '502f', '5030', '5031', '5032',
'5033', '503e', '503f', '5040', '5530', '705a', '844c', '846b',
'8595', '85ea', '85eb', '85ec', '85ee', '85f3', '860e', '861a',
'861b', '8628', '8643', '864c', '8652', '8660', '8661', '90d7',
'90dd', '999f', 'a625', 'aa33', 'aaa2', 'aaa3', 'acb2', 'acc1',
'ae61', 'ae65', 'ae6a', 'ae71', 'b092', 'b590', 'c0d5', 'c0d7',
'c0e2', 'c0e3', 'c0e4', 'c10d', 'c652', 'c709', 'c711', 'c736',
'c737', 'c745', 'c750', 'fa01', 'fa02', 'fa03', 'fa05', 'fa11',
'fa13', 'fa18', 'fa19', 'fa21', 'fa23', 'fa2a', 'fa32', 'fa33',
'fa36', 'fa38', 'fa42', 'fa43', 'fa45', 'fa47', 'fa49', 'fa58',
'fa59', 'fa88', 'fa89'
]
class SabayonGpuConfigurator:
def __init__(self):
# cmdlines
self.options = None
self.dryrun = False
self.no_proprietary = False
self.nvidia_disablelegacy = False
self.legacy = False
self.livecd = False
self.steps = []
self.forced_xdriver = ''
self.current_arch = os.uname()[4]
self.nomodeset = False
self.noefi = False
self.efivars_loaded = False
self.xorgfile = None
self.device_id_prefix = "SabayonVga"
self.nvidia_option_prefix = "--nvidia-opt--"
self.screen_layout_sections = []
self.device_sections = []
self.screen_sections = []
self.bb_enabled = False
self.debug = False
self.xorg_conf_structure = """
Section "Module"
SubSection "extmod"
Option "omit xfree86-dga"
EndSubSection
Load "i2c"
Load "ddc"
Load "vbe"
Load "dri"
Load "glx"
Load "synaptics"
EndSection
Section "ServerFlags"
Option "AllowMouseOpenFail" "true"
EndSection
Section "Monitor"
Identifier "Generic Monitor"
VertRefresh 43 - 60
HorizSync 28 - 80
EndSection
__device_section__
__screen_section__
Section "DRI"
Mode 0666
EndSection
Section "ServerLayout"
Identifier "Main Layout"
__screen_layout_section__
EndSection
Section "Extensions"
#Option "Composite" "Enable"
EndSection
"""
self.screen_section = """
Section "Screen"
Identifier "Screen __screen_id__"
Device "%s__screen_id__"
Monitor "Generic Monitor"
%sOption "AddARGBGLXVisuals" "true"
%sOption "RegistryDwords" "EnableBrightnessControl=1"
DefaultDepth 24
SubSection "Display"
Depth 8
ViewPort 0 0
#Modes "1024x768" "800x600" "640x480"
EndSubsection
SubSection "Display"
Depth 16
ViewPort 0 0
#Modes "1024x768" "800x600" "640x480"
EndSubsection
SubSection "Display"
Depth 24
ViewPort 0 0
#Modes "1024x768" "800x600" "640x480"
EndSubsection
EndSection
""" % (self.device_id_prefix, self.nvidia_option_prefix,
self.nvidia_option_prefix,)
def get_vesa_driver(self):
"""
Return either "vesa" or "fbdev" as the fallback
vesa-like X driver.
"""
if self.is_efi():
# vesa does not work
return "fbdev"
return "vesa"
def set_xorg_device(self, xdriver, cardnum, total_cards, bus_id):
opt_logopath = 'Option "LogoPath" "/usr/share/backgrounds/sabayonlinux-nvidia.png"'
if xdriver not in ("nvidia") and \
(not self.check_if_driver_is_available(xdriver)):
xdriver = self.get_vesa_driver() # fallback to vesa
bus_id_mark = "#"
if total_cards > 1:
bus_id_mark = ""
my_screen_section = self.screen_section.replace("__screen_id__", str(cardnum))
# setup Option AddARGBVisuals
# especially needed for legacy nvidia drivers, but works
# on all of them
if xdriver == "nvidia":
my_screen_section = my_screen_section.replace(self.nvidia_option_prefix, "")
else:
my_screen_section = my_screen_section.replace(self.nvidia_option_prefix, "#")
opt_logopath = ''
self.device_sections.append("""
Section "Device"
Identifier "%s%s"
Driver "%s"
%sBusID "%s"
#Option "RenderAccel" "on"
#Option "XAANoOffscreenPixmaps"
#Option "BusType" "PCI"
#Option "ColorTiling" "on"
#Option "EnablePageFlip" "on"
# UseEvents is causing segmentation faults with
# NVIDIA 6xxx, 7xxx and >=275.xx.xx drivers
#Option "UseEvents" "True"
%s
EndSection
""" % (self.device_id_prefix, cardnum, xdriver, bus_id_mark, bus_id,
opt_logopath))
self.screen_sections.append(my_screen_section)
self.screen_layout_sections.append('Screen %s "Screen %s"' % (
cardnum, cardnum,))
@staticmethod
def openrc_running():
return os.path.isfile("/run/openrc/softlevel")
@staticmethod
def systemd_running():
return os.path.isdir("/run/systemd/system")
def remove_proprietary_opengl(self):
if not self.dryrun:
os.system("""
mount -t tmpfs none /usr/lib64/opengl/nvidia &> /dev/null
sed -i '/LIBGL_DRIVERS_PATH/ s/.*//' /etc/profile.env
""")
else:
print("I was about to remove proprietary OpenGL libraries")
@staticmethod
def get_kernel_version():
try:
return int(os.uname()[2].replace(".", "")[:3])
except (ValueError, TypeError) as err:
print("get_kernel_version: ouch: %s" % (err,))
return None
@staticmethod
def check_if_driver_is_available(xdriver):
drv_path = "/usr/lib64/xorg/modules/drivers/" + xdriver + "_drv.so"
if os.path.isfile(drv_path):
print("check_if_driver_is_available for " + xdriver + ": available")
return True
print("check_if_driver_is_available for " + xdriver + ": not available")
return False
@staticmethod
def check_if_proprietary_driver_system_is_healthy(kernelmod):
rc = subprocess.call(["modprobe", kernelmod])
if rc == 0 and kernelmod == "nvidia":
if os.path.exists("/usr/lib64/opengl/nvidia/lib"):
print("check_if_proprietary_driver_system_is_healthy:"
" nvidia healthy")
return True
print("check_if_proprietary_driver_system_is_healthy:"
" nvidia NOT healthy")
return False
def deploy_nvidia_xxxxxx_drivers(self, ver):
if self.dryrun:
print("I was about to run deploy_nvidia_xxxxxx_drivers"
", ver: %s" % (ver,))
return False
drivers_dir = "/install-data/drivers"
# are they available ? we're on livecd...
if not os.path.isdir(drivers_dir):
print("drivers_dir not available")
return False
packages = os.listdir(drivers_dir)
_packages = []
for pkg in packages:
if not pkg.endswith(".tbz2"):
continue
if pkg.startswith("x11-drivers:nvidia-drivers-" + ver):
_packages.append(pkg)
elif pkg.startswith("x11-drivers:nvidia-userspace-" + ver):
_packages.append(pkg)
packages = [os.path.join(drivers_dir, x) for x in _packages]
if not packages:
return False
rc = subprocess.call(["/usr/bin/equo", "install", "--nodeps"] + packages)
if rc:
return False
# try to check driver status now
return self.check_if_proprietary_driver_system_is_healthy("nvidia")
def is_efi(self):
"""
Return whether the system boots from EFI
"""
if self.noefi:
return False
if not self.efivars_loaded:
subprocess.call(["modprobe", "efivars"])
self.efivars_loaded = True
return os.path.exists("/sys/firmware/efi")
@staticmethod
def copy_nvidia_settings_on_desktop():
homes = []
if os.path.isfile(nvidia_settings):
homes += [x for x in os.listdir("/home")
if os.path.isdir("/home/" + x + "/Desktop")]
for home in homes:
try:
full_home = os.path.join("/home", home)
st = os.stat(full_home)
dest_path = "/home/" + home + "/Desktop/" + \
os.path.basename(nvidia_settings)
shutil.copy2(nvidia_settings, dest_path)
os.chmod(dest_path, 0o755)
os.chown(dest_path, st.st_uid, st.st_gid)
if os.path.isdir("/etc/skel/Desktop"):
dest_path = os.path.join(
"/etc/skel/Desktop",
os.path.basename(nvidia_settings))
shutil.copy2(nvidia_settings, dest_path)
os.chmod(dest_path, 0o755)
except Exception:
pass
def setup_nvidia_drivers(self, card_id):
drv_string = ''
done_legacy = False
legacy_def_version = '390'
drivers_map = (
("390", nvidia_390xx_supported,),
)
if not self.nvidia_disablelegacy:
for ver, lst in drivers_map:
if card_id not in lst:
continue
print("NVIDIA %s driver selected" % (ver,))
drv_string = ver
if self.livecd:
rc = self.deploy_nvidia_xxxxxx_drivers(ver)
if rc:
print("NVIDIA %s deployed correctly" % (ver,))
done_legacy = True
break
if not done_legacy:
if self.legacy and not self.nvidia_disablelegacy:
drv_string = legacy_def_version
if self.livecd:
print('Trying to use legacy nvidia driver %s' % (
legacy_def_version
))
rc = self.deploy_nvidia_xxxxxx_drivers(legacy_def_version)
if rc:
print("NVIDIA %s deployed correctly" % (
legacy_def_version)
)
else:
drv_string = '[latest]'
print("latest and greatest NVIDIA driver selected or unsupported")
healthy = self.check_if_proprietary_driver_system_is_healthy("nvidia")
if healthy:
print("NVIDIA proprietary driver %s is loaded" % (drv_string,))
if done_legacy:
try:
os.makedirs("/lib/nvidia/legacy")
except OSError as err:
if err.errno != errno.EEXIST:
raise
with open("/lib/nvidia/legacy/running", "w") as f:
f.write("%s" % (drv_string,))
return done_legacy, healthy
def generate_nvidia_steps(self, videocard, cardnumber, total_cards, bus_id):
comp_id, card_id = self.extract_pci_ids(videocard)
done_legacy, healthy = self.setup_nvidia_drivers(card_id)
if healthy:
if done_legacy:
# then activate nvidia opengl subsystem after resetting it
self.steps.append(('set_xorg_device', "nvidia",
cardnumber, total_cards, bus_id,))
self.steps.append(('copy_nvidia_settings_on_desktop',))
else:
self.steps.append(('copy_nvidia_settings_on_desktop',))
self.steps.append(('set_xorg_device', "nvidia",
cardnumber, total_cards, bus_id,))
else:
print(
"NVIDIA drivers couldn't be loaded, switchting to nouveau driver"
)
self.steps.append(('set_xorg_device', 'nouveau',
cardnumber, total_cards, bus_id,))
def generate_generic_steps(self):
self.steps.append(('remove_proprietary_opengl', self.bb_enabled))
@staticmethod
def drop_kernel_mod(kmod):
return subprocess.call(["modprobe", "-r", kmod])
@staticmethod
def extract_pci_ids(videocard_str):
videocard_split = [x.strip() for x in videocard_str.strip().split('"')
if x.strip()]
try:
card_id = videocard_split[3].split()[-1].lower().strip("[]")
except IndexError:
card_id = None
try:
company_id = videocard_split[2].split()[-1].lower().strip("[]")
except IndexError:
company_id = None
return company_id, card_id
@staticmethod
def extract_vga_cards(lspci_list):
cards = []
for item in lspci_list:
try:
class_type = item.split()[1].strip('"')
if class_type == "0300":
cards.append(item)
except IndexError:
continue
return cards
def modify_modprobe_blacklist(self, kmod):
blist_nouveau_present = False
blist_nvidia_present = False
blist_nvidia_drm_present = False
if self.dryrun:
old_file = '/tmp/%s%s' % (
os.path.basename(modprobe_blacklist), '.old'
)
# Use /tmp for create debug files
shutil.copy(modprobe_blacklist, old_file)
dst = open('/tmp/%s' % os.path.basename(modprobe_blacklist), 'w')
else:
old_file = '%s%s' % (modprobe_blacklist, '.old')
# Rename previous file
shutil.move(modprobe_blacklist, old_file)
dst = open(modprobe_blacklist, 'w')
src = open(old_file, 'r')
data = src.readlines()
src.close()
for row in data:
if row.startswith('blacklist nvidia_drm'):
if kmod == 'nvidia':
dst.write('%s%s' % ('#', row))
else:
dst.write(row)
blist_nvidia_drm_present = True
elif row.startswith('blacklist nvidia'):
if kmod == 'nvidia':
dst.write('%s%s' % ('#', row))
else:
dst.write(row)
blist_nvidia_present = True
elif row.startswith('blacklist nouveau'):
if kmod == 'nvidia':
dst.write(row)
else:
dst.write('%s%s' % ('#', row))
blist_nouveau_present = True
if kmod == 'nvidia' and not blist_nouveau_present:
dst.write('blacklist nouveau')
if kmod == 'nouveau' and not blist_nvidia_present:
dst.write('blacklist nvidia')
if kmod == 'nouveau' and not blist_nvidia_drm_present:
dst.write('blacklist nvidia_drm')
dst.close()
def main(self, cmd_argv):
self.options = cmd_argv[1:]
self.xorgfile = os.getenv('SABAYON_XORG_CONF', "/etc/X11/xorg.conf")
lspci_output = ''
for option in self.options:
if option == "--dry-run":
self.dryrun = True
elif option == '--legacy':
self.legacy = True
elif option == '--debug':
self.debug = True
elif option.startswith('--with-lspci=') and \
len(option.split("=")) >= 2:
option = option.split("=")[1:]
option = "=".join(option)
if option.startswith('"'):
option = option[1:]
if option.startswith("'"):
option = option[1:]
if option.endswith("'"):
option = option[:len(option)-1]
if option.endswith('"'):
option = option[:len(option)-1]
lspci_output = option
elif option.startswith('--forced-xdriver=') and \
len(option.split("=")) == 2:
self.forced_xdriver = option.split("=")[1]
if not lspci_output:
lspci_output = getoutput(lspci+' -mm -n')
# parse cmdline
with open("/proc/cmdline", "r") as f:
cmdline = f.readline().split()
for cmd in cmdline:
if cmd == "noproprietary":
self.no_proprietary = True
elif cmd == "nomodeset":
self.nomodeset = True
elif cmd == "nvidia=disablelegacy":
self.nvidia_disablelegacy = True
elif cmd == "legacy":
self.legacy = True
elif cmd == "cdroot":
self.livecd = True
elif cmd == "noefi":
self.noefi = True
elif cmd.startswith("xdriver=") and (len(cmd.split("=")) == 2):
if not self.forced_xdriver:
self.forced_xdriver = cmd.split("=")[1] # --forced-xdriver= owns
# Create videocards list
lspci_out_split = lspci_output.split("\n")
videocards = self.extract_vga_cards(lspci_out_split)
# Run the program
cardnumber = -1
total_cards = len(videocards)
forced_monitor_modes = False
write_config = False
update_modprobe_blist = False
for videocard in videocards:
# setup card number
cardnumber += 1
print("Card Number: " + str(cardnumber))
try:
bus_id = "PCI:%s" % (
videocard.split()[0].split(".", 1)[0]
)
except (IndexError, ValueError, TypeError,):
bus_id = None
if self.forced_xdriver:
print("You have chosen to force the X driver: " + self.forced_xdriver)
if self.forced_xdriver == "nvidia" and (not self.no_proprietary):
self.generate_nvidia_steps(videocard, cardnumber, total_cards, bus_id)
elif self.forced_xdriver == "vesa":
forced_monitor_modes = True
else:
if self.forced_xdriver == 'nouveau':
self.modify_modprobe_blacklist('nouveau')
self.generate_generic_steps()
self.steps.append(('set_xorg_device', self.forced_xdriver,
cardnumber, total_cards, bus_id,))
write_config = True
else:
company_id, card_id = self.extract_pci_ids(videocard)
print("[%s] company_id: %s | card_id: %s" % (
cardnumber, company_id, card_id,))
if company_id == "10de": # NVIDIA
if self.no_proprietary:
if not update_modprobe_blist:
self.modify_modprobe_blacklist('nouveau')
update_modprobe_blist = True
self.steps.append(('set_xorg_device', "nouveau",
cardnumber, total_cards, bus_id,))
else:
if not update_modprobe_blist:
self.modify_modprobe_blacklist('nvidia')
update_modprobe_blist = True
self.generate_nvidia_steps(
videocard, cardnumber, total_cards, bus_id)
print("NVIDIA!")
write_config = True
else:
self.generate_generic_steps()
print("GPU will be automatically detected by X.Org and udevd")
# now create the file
for args in self.steps:
func, args = args[0], args[1:]
method = getattr(self, func)
method(*args)
if write_config:
config = self.xorg_conf_structure.replace(
'__device_section__',
'\n\n'.join(self.device_sections))
config = config.replace(
'__screen_section__',
'\n\n'.join(self.screen_sections))
config = config.replace(
'__screen_layout_section__',
'\n '.join(self.screen_layout_sections))
if forced_monitor_modes:
config = config.replace('#Modes', 'Modes')
if not self.dryrun or self.debug:
with open(self.xorgfile, "w") as f:
f.write(config)
f.flush()
else:
try:
os.remove(self.xorgfile)
except (OSError, IOError):
pass
return 0
def main():
configurator = SabayonGpuConfigurator()
the_exit = configurator.main(argv)
goto(the_exit)
if __name__ == '__main__':
main()