131816462f
git-svn-id: http://svn.sabayonlinux.org/overlay@2854 d7aec97c-591d-0410-af39-a8856400b30a
653 lines
21 KiB
Python
Executable File
653 lines
21 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
import os
|
|
import string
|
|
import commands
|
|
import shutil
|
|
import sys
|
|
|
|
# Variables
|
|
xorgfile = "/etc/X11/xorg.conf"
|
|
xorgfile_backup = "/etc/X11/xorg.conf.sabayon"
|
|
lspci = '/usr/sbin/lspci'
|
|
nvidia_settings = "/usr/share/applications/nvidia-settings.desktop"
|
|
|
|
device_id_prefix = "SabayonVga"
|
|
screen_layout_sections = []
|
|
device_sections = []
|
|
xorg_conf_structure = """
|
|
Section "Module"
|
|
SubSection "extmod"
|
|
Option "omit xfree86-dga"
|
|
EndSubSection
|
|
Load "i2c"
|
|
Load "ddc"
|
|
Load "vbe"
|
|
Load "dri"
|
|
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
|
|
"""
|
|
|
|
screen_sections = []
|
|
screen_section = """
|
|
Section "Screen"
|
|
|
|
Identifier "Screen __screen_id__"
|
|
Device "%s__screen_id__"
|
|
Monitor "Generic Monitor"
|
|
#Option "AddARGBGLXVisuals" "true"
|
|
|
|
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
|
|
""" % (device_id_prefix,)
|
|
|
|
# cmdlines
|
|
options = sys.argv[1:]
|
|
dryrun = False
|
|
noproprietary = False
|
|
nvidia_forcefail = False
|
|
nvidia_disablelegacy = False
|
|
legacy = False
|
|
noopengl = False
|
|
noexa = False
|
|
livecd = False
|
|
steps = []
|
|
forced_xdriver = ''
|
|
current_arch = os.uname()[4]
|
|
if current_arch == "x86_64":
|
|
ld_arch = "elf_x86_64"
|
|
else:
|
|
ld_arch = "elf_i386"
|
|
lspci_output = ''
|
|
for option in options:
|
|
if option == "--dry-run":
|
|
dryrun = True
|
|
elif option.startswith('--with-lspci=') and len(option.split("=")) >= 2:
|
|
option = option.split("=")[1:]
|
|
option = string.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:
|
|
forced_xdriver = option.split("=")[1]
|
|
elif option == "--noopengl":
|
|
noopengl = True
|
|
elif option == "--noexa":
|
|
noexa = True
|
|
|
|
if (not lspci_output):
|
|
lspci_output = commands.getoutput(lspci+' -nn | grep VGA')
|
|
else:
|
|
lspci_output = commands.getoutput('echo '+lspci_output+' | grep VGA')
|
|
|
|
# parse cmdline
|
|
# FIXME: add support for no-dri?
|
|
f = open("/proc/cmdline","r")
|
|
cmdline = f.readline().split()
|
|
f.close()
|
|
for cmd in cmdline:
|
|
if cmd == "noproprietary":
|
|
noproprietary = True
|
|
elif cmd == "nvidia=forcefail":
|
|
nvidia_forcefail = True
|
|
elif cmd == "nvidia=disablelegacy":
|
|
nvidia_disablelegacy = True
|
|
elif cmd == "legacy":
|
|
legacy = True
|
|
elif cmd == "noopengl":
|
|
noopengl = True
|
|
elif cmd == "cdroot":
|
|
livecd = True
|
|
elif cmd == "noexa":
|
|
noexa = True
|
|
elif cmd.startswith("xdriver=") and (len(cmd.split("=")) == 2):
|
|
if (not forced_xdriver): forced_xdriver = cmd.split("=")[1] # --forced-xdriver= owns
|
|
|
|
|
|
# Functions
|
|
def remove_proprietary_opengl():
|
|
if (not dryrun):
|
|
os.system('''
|
|
mount -t tmpfs none /usr/lib/opengl/ati &> /dev/null
|
|
mount -t tmpfs none /usr/lib/opengl/nvidia &> /dev/null
|
|
sed -i '/LIBGL_DRIVERS_PATH/ s/.*//' /etc/profile.env
|
|
''')
|
|
fix_possible_opengl_misconfiguration('xorg-x11')
|
|
else:
|
|
print "I was about to remove proprietary OpenGL libraries"
|
|
|
|
def check_if_driver_is_available(xdriver):
|
|
if os.path.isfile('/usr/lib/xorg/modules/drivers/'+xdriver+'_drv.so'):
|
|
print "check_if_driver_is_available for "+xdriver+": available"
|
|
return True
|
|
print "check_if_driver_is_available for "+xdriver+": not available"
|
|
return False
|
|
|
|
def check_if_proprietary_driver_system_is_healthy(kernelmod): #FIXME attenzione a dove usi questa
|
|
rc = os.system('modprobe '+kernelmod+' &> /dev/null')
|
|
if (rc == 0):
|
|
if kernelmod == "nvidia":
|
|
if os.path.exists('/usr/lib/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
|
|
if kernelmod == "fglrx":
|
|
if os.path.exists('/usr/lib/opengl/ati/lib'):
|
|
print "check_if_proprietary_driver_system_is_healthy: ati healthy"
|
|
return True
|
|
print "check_if_proprietary_driver_system_is_healthy: ati NOT healthy"
|
|
return False
|
|
else:
|
|
return False
|
|
|
|
def deploy_nvidia_xxxxxx_drivers(ver): # reduce os.system usage
|
|
if (not dryrun):
|
|
from entropy import EquoInterface
|
|
Equo = EquoInterface()
|
|
# are they available ? we're on livecd...
|
|
if not os.path.isdir("/install-data/drivers"):
|
|
print "No /install-data/drivers available"
|
|
return False
|
|
|
|
packages = os.listdir("/install-data/drivers")
|
|
packages = [x for x in packages if x.startswith("x11-drivers:nvidia-drivers-"+ver) and x.endswith(".tbz2")]
|
|
if not packages:
|
|
return False
|
|
package_file = "/install-data/drivers/"+packages[0]
|
|
if not os.path.isfile(package_file):
|
|
print package_file+" does not exist???"
|
|
return False
|
|
|
|
# prepare system
|
|
idpackage, result = Equo.clientDbconn.atomMatch('x11-drivers/nvidia-drivers')
|
|
if idpackage != -1:
|
|
content = Equo.clientDbconn.retrieveContent(idpackage)
|
|
for myfile in content:
|
|
if os.path.isfile(myfile) and os.access(myfile,os.W_OK):
|
|
try:
|
|
os.remove(myfile)
|
|
except OSError:
|
|
pass
|
|
del content
|
|
|
|
# remove old garbage - copy over - create module
|
|
os.system("tar xjf %s -C / &> /dev/null" % (package_file,))
|
|
|
|
# try to check driver status now
|
|
rc = check_if_proprietary_driver_system_is_healthy("nvidia")
|
|
return rc
|
|
else:
|
|
print "I was about to run deploy_nvidia_xxxxxx_drivers, ver: %s" % (ver,)
|
|
return False
|
|
|
|
def set_xorg_device(xdriver, cardnum, total_cards, bus_id):
|
|
bus_id_mark = '#'
|
|
if total_cards > 1:
|
|
bus_id_mark = ''
|
|
|
|
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"
|
|
Option "UseEvents" "True"
|
|
|
|
EndSection
|
|
""" % (device_id_prefix,cardnum,xdriver,bus_id_mark,bus_id,)
|
|
)
|
|
|
|
my_screen_section = screen_section.replace('__screen_id__',str(cardnum))
|
|
screen_sections.append(my_screen_section)
|
|
screen_layout_sections.append('Screen %s "Screen %s"' % (cardnum,cardnum,))
|
|
|
|
|
|
def opengl_activate(profile):
|
|
if (not dryrun):
|
|
if (livecd):
|
|
os.system("opengl-activator "+profile+" &> /dev/null")
|
|
else:
|
|
os.system("eselect opengl set "+profile+" &> /dev/null")
|
|
else:
|
|
print "I was about to set opengl subsystem to: "+profile
|
|
|
|
def opengl_show():
|
|
if (livecd):
|
|
profile = commands.getoutput("opengl-activator show").split("\n")[0].strip()
|
|
else:
|
|
profile = commands.getoutput("eselect opengl show").split("\n")[0].strip()
|
|
return profile
|
|
|
|
def fix_possible_opengl_misconfiguration(profile):
|
|
# get current subsystem
|
|
current = opengl_show()
|
|
if (not dryrun):
|
|
if (profile in ("ati","nvidia","xorg-x11")) and (profile != current):
|
|
if profile == "ati" or profile == "nvidia":
|
|
os.system("""
|
|
umount /usr/lib/opengl/"""+profile+""" &> /dev/null
|
|
umount /usr/lib/opengl/"""+profile+""" &> /dev/null
|
|
""")
|
|
opengl_activate(profile)
|
|
else:
|
|
print "I was about to fix OpenGL subsystem to: "+profile+" while the current implementation is: "+current
|
|
|
|
def copy_nvidia_settings_on_desktop():
|
|
if os.path.isfile(nvidia_settings):
|
|
homes = os.listdir("/home")
|
|
homes = [x for x in homes if os.path.isdir("/home/"+x+"/Desktop")]
|
|
for home in homes:
|
|
try:
|
|
user = home
|
|
group = "users"
|
|
shutil.copy2(nvidia_settings,"/home/"+home+"/Desktop/"+os.path.basename(nvidia_settings))
|
|
shutil.copystat(nvidia_settings,"/home/"+home+"/Desktop/"+os.path.basename(nvidia_settings))
|
|
os.chown("/home/"+home+"/Desktop/"+os.path.basename(nvidia_settings),user,group)
|
|
except:
|
|
pass
|
|
if os.path.isdir("/etc/skel/Desktop"):
|
|
shutil.copy2(nvidia_settings,"/etc/skel/Desktop/"+os.path.basename(nvidia_settings))
|
|
|
|
def copy_ati_settings_on_desktop():
|
|
desktop_files = commands.getoutput('equo query files ati-drivers --quiet | grep ".desktop"').split("\n")
|
|
desktop_files = [x for x in desktop_files if os.path.isfile(x)]
|
|
print "copy_ati_settings_on_desktop: found files: "+str(desktop_files)
|
|
for ati_settings in desktop_files:
|
|
homes = os.listdir("/home")
|
|
homes = [x for x in homes if os.path.isdir("/home/"+x+"/Desktop")]
|
|
for home in homes:
|
|
try:
|
|
user = home
|
|
group = "users"
|
|
shutil.copy2(ati_settings,"/home/"+home+"/Desktop/"+os.path.basename(ati_settings))
|
|
shutil.copystat(ati_settings,"/home/"+home+"/Desktop/"+os.path.basename(ati_settings))
|
|
os.chown("/home/"+home+"/Desktop/"+os.path.basename(ati_settings),user,group)
|
|
except:
|
|
pass
|
|
if os.path.isdir("/etc/skel/Desktop"):
|
|
shutil.copy2(ati_settings,"/etc/skel/Desktop/"+os.path.basename(ati_settings))
|
|
|
|
|
|
def generate_nvidia_steps(cardnumber, total_cards, bus_id):
|
|
if check_if_proprietary_driver_system_is_healthy("nvidia"):
|
|
if (not noopengl):
|
|
steps.append(('fix_possible_opengl_misconfiguration','nvidia'))
|
|
steps.append(('copy_nvidia_settings_on_desktop',))
|
|
steps.append(('opengl_activate','nvidia'))
|
|
steps.append(('set_xorg_device','nvidia',cardnumber,total_cards,bus_id,))
|
|
else:
|
|
if (livecd):
|
|
print "latest NVIDIA drivers couldn't be loaded, trying 173.xx.xx/9x.xx.xx/7x.xx.xx drivers"
|
|
rc = deploy_nvidia_xxxxxx_drivers("17")
|
|
drv_string = "17x.xx.xx"
|
|
if not rc:
|
|
rc = deploy_nvidia_xxxxxx_drivers("9")
|
|
drv_string = "9x.xx.xx"
|
|
if not rc:
|
|
drv_string = "7x.xx.xx"
|
|
rc = deploy_nvidia_xxxxxx_drivers("7")
|
|
if rc:
|
|
# then activate nvidia opengl subsystem after resetting it
|
|
steps.append(('opengl_activate','xorg-x11'))
|
|
steps.append(('opengl_activate','nvidia'))
|
|
os.makedirs("/lib/nvidia/legacy")
|
|
|
|
f = open("/lib/nvidia/legacy/running","w")
|
|
f.write("NVIDIA %s\n" % (drv_string,))
|
|
f.flush()
|
|
f.close()
|
|
|
|
steps.append(('set_xorg_device','nvidia',cardnumber,total_cards,bus_id,))
|
|
steps.append(('fix_possible_opengl_misconfiguration','nvidia'))
|
|
steps.append(('copy_nvidia_settings_on_desktop',))
|
|
else:
|
|
# it's a no-go!
|
|
print "NVIDIA drivers %s failed to load too... sorry, switching to nv driver" % (drv_string,)
|
|
if (not noopengl):
|
|
steps.append(('opengl_activate','xorg-x11'))
|
|
steps.append(('set_xorg_device','nv',cardnumber,total_cards,bus_id,))
|
|
else:
|
|
print "latest NVIDIA drivers couldn't be loaded, switchting to nv driver"
|
|
if (not noopengl):
|
|
steps.append(('opengl_activate','xorg-x11'))
|
|
steps.append(('set_xorg_device','nv',cardnumber,total_cards,bus_id,))
|
|
|
|
def generate_generic_steps():
|
|
if noopengl:
|
|
return
|
|
steps.append(('remove_proprietary_opengl',))
|
|
steps.append(('opengl_activate','xorg-x11',))
|
|
|
|
|
|
### APPLICATION
|
|
|
|
# Create videocards list
|
|
videocards = lspci_output.split("\n")
|
|
|
|
# Run the program
|
|
cardnumber = -1
|
|
|
|
import re
|
|
# Intel
|
|
i740 = re.compile('.*intel.*74[0-9].*')
|
|
i810 = re.compile('.*Intel.*Corp.*')
|
|
# misc
|
|
silicon_motion = re.compile('.*silicon.*motion.*')
|
|
s3virge = re.compile('.*S3.*Virge.*')
|
|
# VIA
|
|
via = re.compile('.*VIA.*Tech.*')
|
|
unichrome = re.compile('.*via.*tech.*chrome.*')
|
|
# nVidia
|
|
nvidia = re.compile('.*nvidia corporation.*')
|
|
# ATi
|
|
ati = re.compile('.*ati.*technologies.*')
|
|
radeon_1x0 = re.compile('.*ati.*technologies.*r(v)?(s)?1[0-9][0-9].*')
|
|
radeon_2x0 = re.compile('.*ati.*technologies.*r(v)?(s)?2[0-9][0-9].*')
|
|
radeon_3x0 = re.compile('.*ati.*technologies.*r(v)?(s)?3[0-9][0-9].*')
|
|
radeon_4x0 = re.compile('.*ati.*technologies.*r(v)?(s)?4[0-9][0-9].*')
|
|
radeon_5x0 = re.compile('.*ati.*technologies.*r(v)?(s)?5[0-9][0-9].*')
|
|
radeon_6x0 = re.compile('.*ati.*technologies.*r(v)?(s)?6[0-9][0-9].*')
|
|
radeon_7xx0 = re.compile('.*ati.*technologies.*radeon.*7[0-9][0-9]0.*')
|
|
radeon_8xx0 = re.compile('.*ati.*technologies.*radeon.*8[0-9][0-9]0.*')
|
|
radeon_9xx0_free = re.compile('.*ati.*technologies.*radeon.*9[0-2][0-9]0.*')
|
|
radeon_9xx0_closed = re.compile('.*ati.*technologies.*radeon.*9[5-9][0-9]0.*')
|
|
radeon_Xxx0_closed = re.compile('.*ati.*technologies.*radeon.*x[0-9][0-9]0.*')
|
|
radeon_Xxxx0_closed = re.compile('.*ati.*technologies.*radeon.*x[0-9][0-9][0-9]0.*')
|
|
radeon_m_XX_closed = re.compile('.*ati.*technologies.*m[0-9][0-9].*mobility.*')
|
|
radeon_hd = re.compile('.*ati.*technologies.*radeon.* hd .*')
|
|
ati_firegl = re.compile('.*ati.*technologies.*firegl.*')
|
|
|
|
|
|
total_cards = len(videocards)
|
|
forced_monitor_modes = 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
|
|
|
|
steps = []
|
|
|
|
if forced_xdriver:
|
|
print "You have chosen to force X driver: "+forced_xdriver
|
|
if forced_xdriver == "fglrx":
|
|
if noopengl or check_if_proprietary_driver_system_is_healthy("fglrx"):
|
|
steps.append(('opengl_activate','xorg-x11'))
|
|
forced_xdriver = "radeon"
|
|
else:
|
|
steps.append(('fix_possible_opengl_misconfiguration','ati'))
|
|
steps.append(('copy_ati_settings_on_desktop',))
|
|
steps.append(('opengl_activate','ati'))
|
|
|
|
elif forced_xdriver == "nvidia":
|
|
generate_nvidia_steps(cardnumber,total_cards,bus_id)
|
|
elif forced_xdriver == "vesa":
|
|
forced_monitor_modes = True
|
|
elif forced_xdriver == "sisusb":
|
|
steps.append(('remove_proprietary_opengl',))
|
|
else:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device',forced_xdriver,cardnumber,total_cards,bus_id,))
|
|
else:
|
|
|
|
if os.path.isfile('/sys/module/sisusbvga'):
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','sisusb',cardnumber,total_cards,bus_id,))
|
|
print "SiS USB!"
|
|
|
|
elif videocard.lower().find('neomagic') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','neomagic',cardnumber,total_cards,bus_id,))
|
|
print "Neomagic!"
|
|
|
|
elif videocard.lower().find('mach64') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','ati',cardnumber,total_cards,bus_id,))
|
|
print "Mach64!"
|
|
|
|
elif videocard.lower().find('savage') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','savage',cardnumber,total_cards,bus_id,))
|
|
print "Savage!"
|
|
|
|
elif videocard.lower().find('virge') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','s3virge',cardnumber,total_cards,bus_id,))
|
|
print "Virge!"
|
|
|
|
elif videocard.lower().find('cyrix') != -1:
|
|
generate_generic_steps()
|
|
print "Cyrix!"
|
|
|
|
elif videocard.lower().find('i128') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','i128',cardnumber,total_cards,bus_id,))
|
|
print "i128!"
|
|
|
|
elif videocard.lower().find('rendition') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','rendition',cardnumber,total_cards,bus_id,))
|
|
print "Rendition!"
|
|
|
|
elif videocard.lower().find('tseng') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','tseng',cardnumber,total_cards,bus_id,))
|
|
print "Tseng!"
|
|
|
|
elif videocard.lower().find('3dfx interactive') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','tdfx',cardnumber,total_cards,bus_id,))
|
|
print "3Dfx!"
|
|
|
|
elif videocard.lower().find('trident') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','trident',cardnumber,total_cards,bus_id,))
|
|
print "Trident!"
|
|
|
|
elif videocard.lower().find('rage 128') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','r128',cardnumber,total_cards,bus_id,))
|
|
print "Rage128!"
|
|
|
|
elif videocard.find('Matrox') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','mga',cardnumber,total_cards,bus_id,))
|
|
print "Matrox!"
|
|
|
|
elif videocard.find('Cirrus') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','cirrus',cardnumber,total_cards,bus_id,))
|
|
print "Cirrus!"
|
|
|
|
elif videocard.find(' SiS ') != -1 or videocard.find('Silicon Integrated Systems') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','sis',cardnumber,total_cards,bus_id,))
|
|
print "SiS!"
|
|
|
|
elif videocard.lower().find('xgi') != -1 and videocard.find('Volari') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','sis',cardnumber,total_cards,bus_id,))
|
|
print "XGI Volari!"
|
|
|
|
elif videocard.find('VMWare') != -1 or videocard.find('VMware') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','vmware',cardnumber,total_cards,bus_id,))
|
|
print "VMware!"
|
|
|
|
elif videocard.find('VirtualBox') != -1 or videocard.find('InnoTek') != -1:
|
|
generate_generic_steps()
|
|
if check_if_driver_is_available('vboxvideo'):
|
|
steps.append(('set_xorg_device','vboxvideo',cardnumber,total_cards,bus_id,))
|
|
print "VirtualBox!"
|
|
|
|
elif i740.match(videocard.lower()):
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','i740',cardnumber,total_cards,bus_id,))
|
|
print "i740!"
|
|
|
|
elif s3virge.match(videocard):
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','s3virge',cardnumber,total_cards,bus_id,))
|
|
print "S3Virge!"
|
|
|
|
elif via.match(videocard):
|
|
generate_generic_steps()
|
|
if unichrome.match(videocard.lower()):
|
|
if check_if_driver_is_available('openchrome'):
|
|
steps.append(('set_xorg_device','openchrome',cardnumber,total_cards,bus_id,))
|
|
else:
|
|
steps.append(('set_xorg_device','via',cardnumber,total_cards,bus_id,))
|
|
print "UniChrome!"
|
|
else:
|
|
steps.append(('set_xorg_device','via',cardnumber,total_cards,bus_id,))
|
|
print "VIA Tech!"
|
|
|
|
elif silicon_motion.match(videocard.lower()):
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','siliconmotion',cardnumber,total_cards,bus_id,))
|
|
print "Silicon Motion!"
|
|
|
|
elif i810.match(videocard): # non lower
|
|
generate_generic_steps()
|
|
if check_if_driver_is_available('intel'):
|
|
steps.append(('set_xorg_device','intel',cardnumber,total_cards,bus_id,))
|
|
elif check_if_driver_is_available('i810'):
|
|
steps.append(('set_xorg_device','i810',cardnumber,total_cards,bus_id,))
|
|
else:
|
|
print "WARNING: i810 and intel drivers not found !! This could be a real problem"
|
|
print "Intel >= 810!"
|
|
|
|
elif videocard.lower().find('riva tnt') != -1:
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','nv',cardnumber,total_cards,bus_id,))
|
|
print "Riva TNT!"
|
|
|
|
elif nvidia.match(videocard.lower()):
|
|
generate_nvidia_steps(cardnumber,total_cards,bus_id)
|
|
print "NVIDIA!"
|
|
|
|
elif ati.match(videocard.lower()):
|
|
print "ATI Technologies"
|
|
if radeon_1x0.match(videocard.lower()) or \
|
|
radeon_2x0.match(videocard.lower()) or \
|
|
radeon_7xx0.match(videocard.lower()) or \
|
|
radeon_8xx0.match(videocard.lower()) or \
|
|
radeon_9xx0_free.match(videocard.lower()):
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','radeon',cardnumber,total_cards,bus_id,))
|
|
elif radeon_3x0.match(videocard.lower()) or \
|
|
radeon_4x0.match(videocard.lower()) or \
|
|
radeon_5x0.match(videocard.lower()) or \
|
|
radeon_6x0.match(videocard.lower()) or \
|
|
radeon_9xx0_closed.match(videocard.lower()) or \
|
|
radeon_Xxx0_closed.match(videocard.lower()) or \
|
|
radeon_Xxxx0_closed.match(videocard.lower()) or \
|
|
ati_firegl.match(videocard.lower()) or \
|
|
radeon_m_XX_closed.match(videocard.lower()) or \
|
|
radeon_hd.match(videocard.lower()):
|
|
if (not noopengl):
|
|
steps.append(('fix_possible_opengl_misconfiguration','ati'))
|
|
steps.append(('copy_ati_settings_on_desktop',))
|
|
steps.append(('opengl_activate','ati'))
|
|
steps.append(('set_xorg_device','fglrx',cardnumber,total_cards,bus_id,))
|
|
else:
|
|
print "ATTENTION !!!"
|
|
print "ATTENTION !!!"
|
|
print "ATTENTION !!!"
|
|
print "--> ATI Card undetected: "+videocard
|
|
print "SETTING OPEN SOURCE DRIVERS"
|
|
generate_generic_steps()
|
|
steps.append(('set_xorg_device','radeon',cardnumber,total_cards,bus_id,))
|
|
else:
|
|
steps.append(('set_xorg_device','vesa',cardnumber,total_cards,bus_id,))
|
|
print "ATTENTION !!!"
|
|
print "ATTENTION !!!"
|
|
print "ATTENTION !!!"
|
|
print "--> Video Card undetected: "+videocard
|
|
print "SETTING TO VESA"
|
|
print "Please report this output to Sabayon Linux developers or mail to LXNAY <at> SABAYON <dot> ORG"
|
|
|
|
# now create the file
|
|
for step in steps:
|
|
if len(step) == 1:
|
|
eval(step[0])()
|
|
else:
|
|
param = step[1:]
|
|
eval(step[0])(*param)
|
|
|
|
|
|
# Generate xorg.conf
|
|
xorg_conf_structure = xorg_conf_structure.replace('__device_section__','\n\n'.join(device_sections))
|
|
xorg_conf_structure = xorg_conf_structure.replace('__screen_section__','\n\n'.join(screen_sections))
|
|
xorg_conf_structure = xorg_conf_structure.replace('__screen_layout_section__','\n '.join(screen_layout_sections))
|
|
if forced_monitor_modes:
|
|
xorg_conf_structure = xorg_conf_structure.replace('#Modes','Modes')
|
|
if dryrun:
|
|
print xorg_conf_structure
|
|
else:
|
|
f = open(xorgfile,"w")
|
|
g = open(xorgfile_backup,"w")
|
|
f.write(xorg_conf_structure)
|
|
f.flush()
|
|
f.close()
|
|
g.flush()
|
|
g.close()
|