summaryrefslogtreecommitdiff
path: root/v4l/scripts/hwdata.pl
blob: ca583d69d6def8f954ab1b8d923a10973bd288e6 (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
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
#!/usr/bin/perl -w

# This script is used to generate hwdata pci info. We are going to 
# submit this data periodically to linux PCI ID's Project http://pciids.sf.net

my %map = (
	   "PCI_ANY_ID"            => "0",
	   "PCI_VENDOR_ID_PHILIPS" => "1131",
	   "PCI_VENDOR_ID_ASUSTEK" => "1043",
	   "PCI_VENDOR_ID_MATROX"  => "102B",
	   "PCI_VENDOR_ID_ATI"     => "1002",
);

sub fix_id($) {
	my $id = shift;
	$id = $map{$id} if defined($map{$id});
	$id =~ s/^0x//;
	return $id;
}

open ($input, "../saa7134-cards.c");

print ("\n");
print ("1131  Philips Semiconductors\n");

my %data;

while (<$input>) {

	if (/\[(SAA7134_BOARD_\w+)\]/) {
		$id = $1;
		$data{$id}->{id} = $id;
		$data{$id}->{subvendor} = "0";
	};
	next unless defined($id);
	
	if (!defined($data{$id}) || !defined($data{$id}->{name})) {
		$data{$id}->{name} = $1 if (/\.name\s*=\s*\"([^\"]+)\"/);
	}
	
	# saa7134_pci_tbl
	$device = $1 if (/\.device\s*=\s*(\w+),/);
	$subvendor = fix_id($1) if (/\.subvendor\s*=\s*(\w+),/);
	$subdevice = fix_id($1) if (/\.subdevice\s*=\s*(\w+),/);
	if (/.driver_data\s*=\s*(\w+),/) {
		if (defined($data{$1})  &&
		    defined($subvendor) && $subvendor ne "0" &&
		    defined($subdevice) && $subdevice ne "0" &&
		    defined($device)) {
			$data{$1}->{device} = $device;
			$data{$1}->{subvendor} = $subvendor;
			$data{$1}->{subdevice} = $subdevice;
			undef $device;
			undef $subvendor;
			undef $subdevice;
		}
	}
}

sub print_cards ($) {
    my $filter = shift;
    foreach my $item (sort {$data{$a}->{subvendor} cmp $data{$b}->{subvendor}} keys (%data)) 
    {
	if (defined ($data{$item}->{device}) && ($data{$item}->{device} eq $filter)) {
	    	printf("\t\t");
		printf("%s %s  %s", $data{$item}->{subvendor}, $data{$item}->{subdevice}, $data{$item}->{name});
		print "\n";
	}
    }
}

print ("\t7130  SAA7130 Video Broadcast Decoder\n");
print_cards ("PCI_DEVICE_ID_PHILIPS_SAA7130");
print ("\t7133  SAA7133/SAA7135 Video Broadcast Decoder\n");
print_cards ("PCI_DEVICE_ID_PHILIPS_SAA7133");
print ("\t7134  SAA7134 Video Broadcast Decoder\n");
print_cards ("PCI_DEVICE_ID_PHILIPS_SAA7134");

open ($input, "../cx88-cards.c");

%data=();

while (<$input>) {
	if (/\[(CX88_BOARD_\w+)\]/) {
		$id = $1;
		$data{$id}->{id} = $id;
		$data{$id}->{subvendor} = "0";
	};
	next unless defined($id);
	
	if (!defined($data{$id}) || !defined($data{$id}->{name})) {
		$data{$id}->{name} = $1 if (/\.name\s*=\s*\"([^\"]+)\"/);
	}

	$subvendor = fix_id($1) if (/\.subvendor\s*=\s*(\w+),/);
	$subdevice = fix_id($1) if (/\.subdevice\s*=\s*(\w+),/);
	if (/.card\s*=\s*(\w+),/) {
		if (defined($data{$1})  &&
		    defined($subvendor) && $subvendor ne "0" &&
		    defined($subdevice) && $subdevice ne "0") {
			$data{$1}->{subvendor} = $subvendor;
			$data{$1}->{subdevice} = $subdevice;
			undef $subvendor;
			undef $subdevice;
		}
	}
}

print ("14f1  Conexant\n");
print ("\t8800  CX23880/1/2/3 PCI Video and Audio Decoder\n");

foreach my $item (sort {$data{$a}->{subvendor} cmp $data{$b}->{subvendor}} keys (%data)) 
{
	if (defined ($data{$item}->{subdevice}) && ($data{$item}->{subvendor} ne "0")) {
		printf("\t\t");
    		printf("%s %s  %s", $data{$item}->{subvendor}, $data{$item}->{subdevice}, $data{$item}->{name});
		print "\n";
	}
}

print ("109e  Brooktree Corporation\n");
print ("\t032e  Bt878 Video Capture\n");
%data=();

open ($input, "../bttv-cards.c");
while (<$input>) {
    if (/\{\s*0x(\w{4})(\w{4}),.*\"([^\"]+)\"\s\},/)
	{
		printf ("\t\t%s %s  %s\n", $2, $1, $3);
	}
}

printf ("\n");