summaryrefslogtreecommitdiff
path: root/v4l/scripts/usbvision.pl
blob: 3976e8bd19301acad075a2a05315836376f917a0 (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
#!/usr/bin/perl -w
use strict;

my $new_entry = -1;
my $nr = 0;
my ($id,$subvendor,$subdevice);
my %data;

while (<>) {
	# defines in header file
	if (/#define\s*(\w+)\s*(\d+)/) {
		$data{$1}->{nr} = $2;
		next;
	}
	# boards
	if (/^\s*\[([\w\d_]+)\]\s*=\s*{/) {
		$id = $1;
		$data{$id}->{id} = $id;
	};

	next unless defined($id);

	if (/USB_DEVICE.*0x([0-9a-fA-F]*).*0x([0-9a-fA-F]*).*driver_info\s*=\s*([\w\d_]+)/)
{
		$subvendor=$1;
		$subdevice=$2;
		push @{$data{$3}->{subid}}, "$subvendor:$subdevice";
	}

	if (!defined($data{$id}) || !defined($data{$id}->{name})) {
		$data{$id}->{name} = $1 if (/\.ModelString\s*=\s*\"([^\"]+)\"/);
	}
}

foreach my $item (sort { $data{$a}->{nr} <=> $data{$b}->{nr} } keys %data) {
	printf("%3d -> %-56s", $data{$item}->{nr}, $data{$item}->{name});
	printf(" [%s]",join(",",@{$data{$item}->{subid}}))
	  if defined($data{$item}->{subid});
	print "\n";
}