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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
import copy
import string
import kudzu
import iutil
import isys
from log import log
Video_cardslist = {}
def Video_cardsDBLookup(thecard):
card = Video_cardslist[thecard]
origcard = copy.copy(card)
count = 0
while count < 16 and card.has_key ("SEE"):
card = Video_cardslist[card["SEE"]]
count = count + 1
if count >= 16:
raise RunTimeError, "Could not find card ",origcard
return card
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)
# server - X server to use (string)
# probedcard - value returned for kudzu containing 'Card:........'
# cardManf - name of manufacturer (string)
# vidRam - amount of video ram (in kB) (string)
# cardData - record from X card database, contains a dictionary of
# key/values.
# devID - ID from ddcprobe (string)
# fbmodes - if framebuffer running, video mode in use (string)
# fbbpp - if framebuffer running, pixel depth in use (string)
#
# These values will be None if undefined or not applicable.
#
def __str__ (self):
return "device: %s\ndescr : %s\nserver: %s\ncardManf: %s\nvidRam: %s\ncarddata: %s\ndevID: %s\nfbmodes: %s\nfbbpp: %s\n" % (self.device, self.descr, self.server, self.cardManf, self.vidRam, self.cardData, self.devID, self.fbmodes, self.fbbpp)
def __init__ (self):
self.device = None
self.probedcard = None
self.descr = None
self.server = None
self.cardManf = None
self.vidRam = None
self.cardData = None
self.devID = None
self.fbmodes = None
self.fbbpp = None
def setDevice(self, device):
self.device = device
def setDescription(self, descr):
self.descr = descr
def setProbedCard(self, card):
self.probedcard = card
def setXServer(self, server):
self.server = server
def setVideoRam(self, vidRam):
self.vidRam = vidRam
def setCardData(self, card):
self.cardData = card
def setDevID(self, devid):
self.devID = devid
def setCardManf(self, manf):
self.cardManf = manf
def setFBModes(self, fbmodes):
self.fbmodes = fbmodes
def setFBBpp(self, bpp):
self.fbbpp = bpp
def getProbedCard(self):
return self.probedcard
def getVideoRam(self):
return self.vidRam
def getDescription(self):
return self.descr
def getDevice(self):
return self.device
def getDevID(self):
return self.devID
def getXServer(self):
return self.server
def getFBBpp(self):
return self.fbbpp
def shortDescription(self):
if self.devID and self.devID != "":
return self.devID
else:
return _("Unable to probe")
# dontResolve = 1 tells us to not follow 'SEE' records to find
# true card definition
def getCardData(self, dontResolve = 0):
if dontResolve:
return self.cardData
else:
return Video_cardsDBLookup(self.cardData["NAME"])
def canTestSafely(self):
cardData = self.getCardData()
if cardData.has_key("DRIVER"):
curdriver = cardData["DRIVER"]
noprobedriverList = ("i810", "tdfx")
for adriver in noprobedriverList:
if curdriver == adriver:
return 0
return 1
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, useProbed = 0):
if useProbed:
if self.orig_videocards and self.orig_primary < len(self.orig_videocards):
return self.orig_videocards[self.orig_primary]
else:
return None
else:
if self.videocards and self.primary < len(self.videocards):
return self.videocards[self.primary]
else:
return None
def possible_ram_sizes(self):
#--Valid video ram sizes--
return [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]
def possible_depths(self):
#--Valid bit depths--
return ["8", "16", "24", "32"]
def manufacturerDB(self):
return ["3DLabs",
"ABit", "AOpen", "ASUS", "ATI", "Actix", "Ark Logic", "Avance Logic",
"Compaq", "Canopus", "Cardex", "Chaintech",
"Chips & Technologies", "Cirrus", "Creative Labs",
"DFI", "DSV", "DataExpert", "Dell", "Diamond", "Digital",
"ELSA", "EONtronics", "Epson", "ExpertColor",
"Gainward", "Genoa", "Guillemot",
"Hercules",
"Intel",
"Jaton",
"LeadTek",
"MELCO", "MachSpeed", "Matrox", "Miro",
"NVIDIA", "NeoMagic", "Number Nine",
"Oak", "Octek", "Orchid",
"Paradise", "PixelView",
"Quantum",
"RIVA", "Real3D", "Rendition",
"S3", "Sharp", "SNI", "SPEA", "STB", "SiS",
"Sierra", "Sigma", "Silicon Motion", "Soyo", "Spider", "Sun",
"TechWorks", "Toshiba", "Trident",
"VideoLogic", "ViewTop", "Voodoo",
"WD", "Weitek", "WinFast"]
def readCardsDB (self):
# all the straight servers
for server in [ "3DLabs", "8514", "FBDev", "I128",
"Mach8", "Mach32", "Mach64", "Mono",
"P9000", "S3", "S3V", "SVGA", "W32", "VGA16" ]:
Video_cardslist["Generic " + server] = { "SERVER" : server,
"NAME" : "Generic " + server }
db = open ('/usr/X11R6/lib/X11/Cards')
lines = db.readlines ()
db.close ()
card = {}
name = None
for line in lines:
line = string.strip (line)
if not line and name:
Video_cardslist[name] = card
card = {}
name = None
continue
if line and line[0] == '#':
continue
if len (line) > 4 and line[0:4] == 'NAME':
name = line[5:]
info = string.splitfields (line, ' ')
if card.has_key (info[0]):
card[info[0]] = card[info[0]] + '\n' + (string.joinfields (info[1:], ' '))
else:
card[info[0]] = string.joinfields (info[1:], ' ')
return
def cardsDB(self):
return Video_cardslist
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 reset(self):
self.videocards = copy.deepcopy(self.orig_videocards)
self.primary = self.orig_primary
def __init__ (self, skipDDCProbe = 0):
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
self.readCardsDB()
for card in cards:
(device, server, descr) = card
if len (server) > 9 and server[0:10] == "Server:Sun" and descr[0:4] == "Sun|":
server = "Card:Sun " + descr[4:]
if len (server) > 5 and server[0:5] == "Card:":
# info = self.cardsDBLookup (server[5:])
info = Video_cardslist [server[5:]]
if len (server) > 7 and server[0:7] == "Server:":
info = { "NAME" : "Generic " + server[7:],
"SERVER" : server[7:] }
if info:
vc = VideoCard()
vc.setProbedCard(server)
vc.setDevice(device)
vc.setDescription(descr)
vc.setCardData (info)
vc.setDevID (info["NAME"])
if (vc.getCardData().has_key("DRIVER") and
not vc.getCardData().has_key("UNSUPPORTED")):
server = "XFree86"
else:
server = "XF86_" + vc.getCardData()["SERVER"]
vc.setXServer(server)
self.videocards.append(vc)
if len(self.videocards) == 0:
return
# default primary card to be the first card found
self.primary = 0
# VESA probe for videoram, etc.
# for now assume fb corresponds to primary video card
if not skipDDCProbe:
try:
probe = string.split (iutil.execWithCapture ("/usr/sbin/ddcprobe", ['ddcprobe']), '\n')
for line in probe:
if line and line[:9] == "OEM Name:":
cardManf = string.strip (line[10:])
self.primaryCard().setCardManf(cardManf)
self.primaryCard().getCardData()["VENDOR"] = cardManf
if line and line[:16] == "Memory installed":
memory = string.split (line, '=')
self.primaryCard().setVideoRam(string.strip (memory[2][:-2]))
except:
log("ddcprobe failed")
pass
# try to get frame buffer information if we don't know video ram
if not self.primaryCard().getVideoRam() and self.primaryCard().getDevice():
try:
(vidram, depth, mode, monitor) = isys.fbconProbe("/dev/" + self.primaryCard().getDevice())
if vidram:
self.primaryCard().setVideoRam("%d" % vidram)
if depth:
self.primaryCard().setFBModes({ "%d" % depth : [ mode ] })
self.primaryCard().setFBBpp( "%d" % depth )
except:
pass
try:
if isys.fbinfo() != None:
x, y, depth = isys.fbinfo()
self.primaryCard().setFBBpp(depth)
except:
pass
# kludge to handle i810 displays which require at least 16 Meg
if (self.primaryCard().getCardData()).has_key("DRIVER"):
cardData = self.primaryCard().getCardData()
if cardData["DRIVER"] == "i810":
self.primaryCard().setVideoRam("16384")
# save so we can reset
self.orig_videocards = copy.deepcopy(self.videocards)
self.orig_primary = self.primary
#
# XXX needed for kickstart only (via installclass.py::configureX())
# some useful routines for setting videocard in various ways
# needs to be ported to new VideoCard object
# pass videocard object for desired card; this sets card to be
# primary card
def setVidcard (self, videocard):
self.primary = self.videocards.index(videocard)
# find the appropriate videocard object for the requested card name
# this will only find the first instance of any card
def locateVidcardByName (self, card):
for vc in self.videocards:
print vc.getDescription()
if (vc.getDescription() == card):
return vc
raise RuntimeError, "Could not find valid video card driver"
# find the appropriate videocard object for the requested server name
# this will only find the first instance of any card
def locateVidcardByServer (self, server):
for vc in self.videocards:
if (vc.getXServer() == server):
return vc
raise RuntimeError, "Could not find valid video card driver."
|