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

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

my $H = shift;
my $C = shift;

open IN, "<$H";
while (<IN>) {
	# defines in header file
	if (/#define\s+(TUNER_\w+)\s+(\d+)/) {
		$data{$1}->{nr} = $2;
		next;
	}
}
close IN;

open IN, "<$C";
while (<IN>) {
	# tuners
	if (/\[(TUNER_\w+)\]/) {
		$id = $1;
		if ($id =~ m/TUNER_MAX/) {
			next;
		}
		$data{$id}->{id} = $id;
	};
	next unless defined($id);

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

foreach my $item (sort { $data{$a}->{nr} <=> $data{$b}->{nr} } keys %data) {
	printf("tuner=%d - %s", $data{$item}->{nr}, $data{$item}->{name});
	print "\n";
}