Viewing file: videocard.py (4.45 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# # videocard.py - Install data and probing for video cards # # Matt Wilson <msw@redhat.com> # Brent Fox <bfox@redhat.com> # Mike Fulbright <msf@redhat.com> # Bill Nottingham <notting@redhat.com> # # Copyright 2001-2006 Red Hat, Inc. # # This software may be freely redistributed under the terms of the GNU # library public license. # # You should have received a copy of the GNU Library Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
import kudzu import string import os
from rhpl.executil import execWithCapture from rhpl.translate import _ import rhpl.translate as translate import rhpl
translate.textdomain('rhpxl')
class VideoCard: # # This class represents the base data about a videocard. These are # the internal members - PLEASE use methods to access values! # # device - if framebuffer running on card this is entry in /dev (string) # descr - human readable description (string) # driver - X driver # vidRam - amount of video ram (in kB) (string) # pcibus - PCI bus number of the card # pcidev - PCI device number of the card # pcifn - PCI fn number of the card # # These values will be None if undefined or not applicable. #
def __str__ (self): return "device: %s\ndriver : %s\ndescr : %s\nvidRam: %s\n" % (self.device, self.driver, self.descr, self.vidRam)
def __init__ (self): self.device = None self.driver = None self.descr = None self.vidRam = None self.pcibus = None self.pcidev = None self.pcifn = None def setDevice(self, device): self.device = device
def setDescription(self, descr): self.descr = descr
def setDriver(self, card): self.driver = card
def setVideoRam(self, vidRam): self.vidRam = vidRam
def setPCIBus(self, num): self.pcibus = num
def setPCIDev(self, num): self.pcidev = num
def setPCIFn(self, num): self.pcifn = num def getDriver(self): return self.driver def getVideoRam(self): return self.vidRam
def getDescription(self): return self.descr
def getDevice(self): return self.device
def getPCIBus(self): return self.pcibus
def getPCIDev(self): return self.pcidev
def getPCIFn(self): return self.pcifn
class VideoCardInfo:
# # This class represents the video cards on the system. # # Currently we only care about the primary card on the system. # This can be found by using the VideoCardInfo::primaryCard() function. # # NOTE - X configuration is not represented here. This class is # intended only to reprsent the available hardware on the system # def primaryCard(self): if self.videocards and self.primary < len(self.videocards): return self.videocards[self.primary] else: return None
def __str__(self): retstr = "primary: %s\nvidCards: %s\n" % (self.primary, self.videocards) if self.primaryCard(): retstr = retstr + ("Primary Video Card Info:\n%s" % (str(self.primaryCard()))) return retstr
def __init__ (self, forceDriver = None):
cards = kudzu.probe (kudzu.CLASS_VIDEO, kudzu.BUS_UNSPEC, kudzu.PROBE_ALL) # just use first video card we recognize # store as a list of class VideoCard self.videocards = [] self.primary = None
index = 0 prependedOne = False for card in cards: vc = VideoCard() vc.setDevice(card.device) vc.setDescription(card.desc) if card.bus == kudzu.BUS_PCI: vc.setPCIBus(card.pcibus) vc.setPCIDev(card.pcidev) vc.setPCIFn(card.pcifn)
if forceDriver: vc.setDriver(forceDriver) self.videocards.append(vc) elif card.xdriver: vc.setDriver(card.xdriver)
# Only prepend one card that has a driver, rather than all. if not prependedOne: self.videocards = [vc] + self.videocards prependedOne = True else: self.videocards.append(vc) else: # insert a best guess at a card if os.uname()[4].count("ppc") > 0: vc.setDriver('fbdev') else: vc.setDriver('vesa') self.videocards.append(vc) if len(self.videocards) > 0: self.primary = 0
|