~rbirnie-deactivatedaccount/jockey/jockey-kde4

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
# (c) 2008 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
# License: GPL v2 or later

import logging

from jockey.handlers import KernelModuleHandler, ModulePackageHandler
from jockey.xorg_driver import XorgDriverHandler
from jockey.oslib import OSLib

class NvidiaDriver(XorgDriverHandler):
    def __init__(self, ui, kernel_module = 'nvidia', driver_package='nvidia-glx', 
            extra_conf_options = {'NoLogo': 'True'}, 
            extra_screen_options={'AddARGBGLXVisuals': 'True'}):
        XorgDriverHandler.__init__(self, ui, kernel_module, driver_package,
            'nvidia', 'nv', extra_conf_options, 
            add_modules=['glx'], remove_modules=['dri', 'GLcore'],
            name=ui._('NVIDIA accelerated graphics driver'),
            description=ui._('3D-accelerated proprietary graphics driver for '
                'NVIDIA cards.'),
            rationale=ui._('This driver is required to fully utilise '
                'the 3D potential of NVIDIA graphics cards, as well as provide '
                '2D acceleration of newer cards.\n\n'
                'If you wish to enable desktop effects, this driver is '
                'required.\n\n'
                'If this driver is not enabled, you will not be able to '
                'enable desktop effects and will not be able to run software '
                'that requires 3D acceleration, such as some games.'))
        self.extra_screen_options=extra_screen_options

    def used(self):
        # if you modprobe nvidia_{new,legacy} they will still appear as
        # 'nvidia' in /proc/modules for some weird reason, so we need to
        # account for that
        return KernelModuleHandler.module_loaded('nvidia') and \
            OSLib.inst.package_installed(self.package)

    def enable_config_hook(self):
        # X.org does not work otherwise
        if len(self.xorg_conf.getSections('Screen')) == 0:
            self.xorg_conf.append(self.xorg_conf.makeSection(None, 
                ['Section', 'Screen']))
        s = self.xorg_conf.getSections('Screen')[0]
        s.defaultdepth = 24

        for k, v in self.extra_screen_options.iteritems():
            s.append(s.makeLine(None, ['Option', k, v]))

    def enabled(self):
        devices = self.xorg_conf.getSections('device') 
        if len(devices) == 0 or devices[0].driver != 'nvidia':
            return False
        return ModulePackageHandler.enabled(self)

    def enables_composite(self):
        '''Return whether this driver supports the composite extension.'''

        # When using an upstream installation, or -new/-legacy etc., we already
        # have composite
        if KernelModuleHandler.module_loaded('nvidia'):
            logging.debug('enables_composite(): already using nvidia driver from nondefault package')
            return False

        # neither vesa nor nv support composite, so safe to say yes here
        return True

class LegacyNvidiaDriver(NvidiaDriver):
    def __init__(self, ui):
        NvidiaDriver.__init__(self, ui, 'nvidia_legacy', 'nvidia-glx-legacy', 
            {'AllowGLXWithComposite': 'True', 'UseEdidFreqs': 'True',
                'NoLogo': 'True'}, {})

    def name(self):
        return self.ui._('NVIDIA accelerated graphics driver (legacy cards)')

class NewNvidiaDriver(NvidiaDriver):
    def __init__(self, ui):
        NvidiaDriver.__init__(self, ui, 'nvidia_new', 'nvidia-glx-new', 
            {'NoLogo': 'True'}, {})

    def name(self):
        return self.ui._('NVIDIA accelerated graphics driver (latest cards)')