summaryrefslogtreecommitdiffstats
path: root/utils/trimpciids
blob: 2d177acc73036fc3d74a0bf577374d4402c3cb04 (plain)
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
#!/usr/bin/python

import sys
import os
import string

vendors = []
devices = []

f = open(sys.argv[1])
if f:
	pcitable = f.readlines()
	f.close()
	for line in pcitable:
	    if not line.startswith("alias pci:"):
		continue
	    vend = "0x%s" % (line[15:19],)
	    dev = "0x%s" % (line[24:28],)
	    if vend not in vendors:
		vendors.append(vend)
	    if (vend, dev) not in devices:
		devices.append( (vend, dev) )

f = open(sys.argv[2])
if f:
	pcitable = f.readlines()
	f.close()
	for line in pcitable:
	    if not line.startswith("alias pcivideo:"):
		continue
	    vend = "0x%s" % (line[20:24],)
	    dev = "0x%s" % (line[29:33],)
	    if vend not in vendors:
		vendors.append(vend)
	    if (vend, dev) not in devices:
		devices.append( (vend, dev) )

pciids = sys.stdin.readlines()
current_vend = 0
for line in pciids:
    if line.startswith("#") or line == "\n":
	continue
    if line.startswith("\t\t"):
	continue
    if not line.startswith("\t"):
	current_vend = "0x%s" % line.split()[0]
	if current_vend in vendors:
	    print line,
	continue
    dev = "0x%s" % line.split()[0]
    if (current_vend, dev) in devices:
	print line,