diff --git a/rhpxl/videocard.py b/rhpxl/videocard.py index c649de9..3c8278b 100644 --- a/rhpxl/videocard.py +++ b/rhpxl/videocard.py @@ -118,6 +118,11 @@ class VideoCardInfo: return retstr def __init__ (self, forceDriver = None): + # just use first video card we recognize + # store as a list of class VideoCard + self.videocards = [] + self.primary = None + aliases = alias.Alias() aliases.addAliasDir("/usr/share/hwdata/videoaliases", "*.xinf") @@ -130,64 +135,61 @@ class VideoCardInfo: devs = hal.GetAllDevices() devs = [bus.get_object('org.freedesktop.Hal', x) for x in devs] devs = [dbus.Interface(x, 'org.freedesktop.Hal.Device') for x in devs] + pdevs = [x for x in devs if x.PropertyExists('pci.device_class')] pdevs = [x for x in pdevs if x.GetPropertyInteger('pci.device_class') == 3] - # XXX append fbdev junk here - vdevs = pdevs - - # just use first video card we recognize - # store as a list of class VideoCard - self.videocards = [] - self.primary = None - - index = 0 - prependedOne = False - for dev in vdevs: + for dev in pdevs: driver = None vc = VideoCard() + vc.setDescription(dev.GetPropertyString('info.vendor') + " " + dev.GetPropertyString('info.product')) - - if dev.PropertyExists('pci.linux.sysfs_path'): - path = dev.GetPropertyString('pci.linux.sysfs_path') - # last path component is bus address; tupleize it - path = os.path.basename(path).replace('.', ':').split(':') - # vc.setPCIDom(path[0]) - vc.setPCIBus(path[1]) - vc.setPCIDev(path[2]) - vc.setPCIFn(path[3]) - - # bit of a hack to skip secondary devices. thanks redmond. - if path[3] != '0': - continue - # elif dev.IsFbdev(): - # vc.setDevice(foo) + path = dev.GetPropertyString('pci.linux.sysfs_path') + # last path component is bus address; tupleize it + path = os.path.basename(path).replace('.', ':').split(':') + # vc.setPCIDom(path[0]) + vc.setPCIBus(path[1]) + vc.setPCIDev(path[2]) + vc.setPCIFn(path[3]) + + # bit of a hack to skip secondary devices. thanks redmond. + if path[3] != '0': + continue if forceDriver: driver = forceDriver - elif dev.PropertyExists('pci.linux.sysfs_path'): + else: v = dev.GetPropertyInteger('pci.vendor_id') d = dev.GetPropertyInteger('pci.product_id') sv = dev.GetPropertyInteger('pci.subsys_vendor_id') sd = dev.GetPropertyInteger('pci.subsys_product_id') # XXX bc, sc, i. except these never matter driver = aliases.matchDevice(v, d, sv, sd) - else: - driver = 'fbdev' + if (driver == None): + driver = 'vesa' - if (driver == None): - driver = 'vesa' - vc.setDriver(driver) + self.videocards.append(vc) + + # if we didn't find anything native, hunt for fbdev. this is _not_ + # a good search if you have more than one fbdev device, since there's + # basically no way to map from sysfs entry to dev entry. serves you + # right for using fbdev. + if len(self.videocards) == 0: + fdevs = [x for x in devs if x.PropertyExists('info.linux.driver')] + # omg + fdevs = [x for x in devs if x.GetPropertyString('info.linux.driver').endswith('fb')] + for i in xrange(len(fdevs)): + device = '/dev/fb' % i + if not os.access(device, os.F_OK): + continue + vc = VideoCard() + vc.setDescription('Framebuffer %d' % i) + vc.setDevice(device) + vc.setDriver('fbdev') + self.videocards.append(vc) - # 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) - if len(self.videocards) > 0: self.primary = 0