1
# -*- coding: utf-8 -*-
2
# (c) 2008 Canonical Ltd.
3
# Authors: Martin Pitt <martin.pitt@ubuntu.com>
4
# Alberto Milone <alberto.milone@canonical.com>
5
# License: GPL v2 or later
7
import logging, os, os.path
10
from jockey.xorg_driver import XorgDriverHandler
11
from NvidiaDetector.alternatives import Alternatives
12
from NvidiaDetector.alternatives import MultiArchUtils
15
# dummy stub for xgettext
18
class CdvDriver(XorgDriverHandler):
19
def __init__(self, backend, package=None):
22
name=_('Intel Cedarview graphics driver')
24
XorgDriverHandler.__init__(self, backend, 'cedarview_gfx',
25
'cedarview-graphics-drivers', None, None, add_modules=['glx'],
26
disable_modules=[], name=name,
27
description=_('3D-accelerated proprietary graphics driver for '
28
'Intel Cedarview cards.'),
29
rationale=_('This driver is required to fully utilise the 3D '
30
'potential of some Intel Cedarview cards, as well as provide '
31
'2D acceleration of newer cards.'))
33
self._alternatives = self._get_alternatives()
34
self.needs_kernel_headers = True
35
self.alternative_name = 'intel-cdv'
37
def _get_alternatives(self):
38
'''Get multi-arch alternatives names'''
39
main_name = 'i386-linux-gnu_egl_conf'
40
return Alternatives(main_name)
43
# we don't offer cdv in a life CD environment, as we will run out of
44
# RAM trying to download and install all the packages in the RAM disk.
45
if os.path.isdir('/rofs'):
46
logging.debug('Disabling cdv driver on live system')
49
logging.debug('cdv.available: falling back to default')
50
return XorgDriverHandler.available(self)
53
XorgDriverHandler.enable(self)
55
# Set the alternative to cdv
56
cdv_alternative = self._alternatives.get_alternative_by_name(
57
self.alternative_name, ignore_pattern='-updates')
58
if not cdv_alternative:
59
logging.error('%s: get_alternative_by_name(%s) returned nothing' % (
60
self.id(), self.package))
62
self._alternatives.set_alternative(cdv_alternative)
63
subprocess.call(['update-initramfs', '-u'])
64
subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]])
67
# See if cdv is the current alternative
68
target_alternative = \
69
self._alternatives.get_alternative_by_name(self.alternative_name)
70
current_alternative = self._alternatives.get_current_alternative()
72
logging.debug('cdv.enabled(%s): target_alt %s current_alt %s',
73
self.module, target_alternative, current_alternative)
75
if current_alternative is None:
76
logging.debug('current alternative of %s is None, not enabled',
79
if current_alternative != target_alternative:
80
logging.debug('%s is not the alternative in use', self.module)
83
return XorgDriverHandler.enabled(self)
86
XorgDriverHandler.disable(self)
87
# make sure that 'cedarview-drm' is removed too
88
self.backend.remove_package('cedarview-drm')
90
# Set the alternative back to open drivers
91
open_drivers = self._alternatives.get_open_drivers_alternative()
92
logging.debug('cdv.disable(%s): open_drivers: %s',
93
self.module, open_drivers)
95
self._alternatives.set_alternative(open_drivers)
97
subprocess.call(['update-initramfs', '-u'])
98
subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]])