diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-08 11:48:28 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-08 11:48:28 -0300 |
commit | 195a360c69962832e547fed5fd88bc25c8f79d84 (patch) | |
tree | 6b37805c9c219dc589dea0bb79f29634e8902d09 /v4l | |
parent | 0f150356bedfcbfe38b12f5f70c01c3daff98ed0 (diff) | |
download | mediapointer-dvb-s2-195a360c69962832e547fed5fd88bc25c8f79d84.tar.gz mediapointer-dvb-s2-195a360c69962832e547fed5fd88bc25c8f79d84.tar.bz2 |
Add a tool to identify if the frontend selects are fine
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Priority: normal
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l')
-rwxr-xr-x | v4l/scripts/fix_dvb_customise.pl | 257 |
1 files changed, 257 insertions, 0 deletions
diff --git a/v4l/scripts/fix_dvb_customise.pl b/v4l/scripts/fix_dvb_customise.pl new file mode 100755 index 000000000..c4c9c14bd --- /dev/null +++ b/v4l/scripts/fix_dvb_customise.pl @@ -0,0 +1,257 @@ +#!/usr/bin/perl +use strict; +use warnings; +use File::Find; +use Fcntl ':mode'; + +my $debug = 0; + +my $SRC = "../linux"; +my $fname = "$SRC/drivers/media/dvb/frontends/Makefile"; + +#################### +# Get Makefile rules +# +sub get_makefile($) +{ + my $file = shift; + my %rules; + my %composite; + + open IN, $file or die "Can't find $file\n"; + while (<IN>) { + # Handle line continuations + if (/\\\n$/) { + $_ .= <IN>; + redo; + } + # Eat line continuations in string we will parse + s/\s*\\\n\s*/ /g; + + if (m/(^\s*[[\da-zA-Z-_]+)-objs\s*[\:\+]*\=\s*(.*)\n/) { + my $dep=$1; + my $file = $2; + $file =~ s/\.o / /g; + $file =~ s/\.o$//; + + if ($file eq "") { + die "broken dep on file $file for $dep\n"; + } + + $composite{$dep} = $file; + printf "MULTI: $dep = $file\n" if ($debug > 1); + } + + if (m/^\s*obj\-\$\(CONFIG_([^\)]+)\)\s*[\:\+]*\=\s*(.*)\n/) { + my $rule = $1; + my $file = $2; + + $file =~ s/\.o / /g; + $file =~ s/\.o$//; + + $rules{$rule} = $file; + printf "RULE: $rule = $file\n" if ($debug > 1); + } + } + close IN; + + return (\%rules, \%composite); +} + +########################### +# Seeks header dependencies +# +my %header_deps; + +# For a more complete check, use: +# my $hfiles = "*.c"; +my $hfiles = "av7110_av.c av7110.c av7110_ca.c av7110_hw.c av7110_ipack.c av7110_ir.c av7110_v4l.c budget-patch.c dvb_ringbuffer.c nova-t-usb2.c umt-010.c"; + +sub get_header_deps() +{ + my $file = shift; + my %rules; + my %composite; + + open IN, "gcc -I ../linux/include -I . -DCONFIG_PCI -D__LITTLE_ENDIAN -D_COMPAT_H -DKERNEL_VERSION\\(a,b,c\\) -MM $hfiles|"; + while (<IN>) { + # Handle line continuations + if (/\\\n$/) { + $_ .= <IN>; + redo; + } + # Eat line continuations in string we will parse + s/\s*\\\n\s*/ /g; + + if (m/^([^\:]+)\s*\:\s*(.*)/) { + my $dep = $1; + my $file = $2; + + $dep =~ s|.*/||; + $dep =~ s/\.o$//; + + my @files = split(/\s/, $file); + foreach my $f (@files) { + $f =~ s|.*/||; + + if (!defined($header_deps{$f})) { + $header_deps{$f} = $dep; + } else { + $header_deps{$f} .= " " . $dep; + } + + } + } + } + close IN; + + if ($debug > 1) { + print "Header deps for: "; + print "$_ " foreach %header_deps; + print "\n"; + } + +print "Header deps for av7110.h: "; +print "$_ " foreach $header_deps{"av7110.h"}; +print "\n"; +} + + +########################### +# Seeks files for Makefiles +# + +my %driver_config; + +sub parse_makefiles() +{ + my $fname = $File::Find::name; + + return if !($fname =~ m|/Makefile$|); + return if ($fname =~ m|drivers/media/dvb/frontends/|); + + + my ($refs, $mult) = get_makefile($fname); + + foreach my $ref (keys %$refs) { + my $file=$$refs{$ref}; + + my @files = split(/\s/, $file); + foreach my $f (@files) { + if (defined($$mult{$f})) { + $file .= " " . $$mult{$f}; + } + } + + $file =~ s|/||g; + + @files = split(/\s/, $file); + foreach my $f (@files) { + $driver_config{$f} = $ref; + } + if ($debug > 1) { + print "$ref = "; + print "$_ " foreach @files; + print "\n"; + } + } +} + + +######################## +# Seeks files for header +# +sub found_ref($$) +{ + my $file = shift; + my $header = shift; + my $found = 0; + my $name = $file; + $name =~ s|.*/||; + + $name =~ s/flexcop-fe-tuner.c/b2c2-flexcop/; + $name =~ s/av7110.c/av7110/; + + if (defined ($header_deps{$name})) { + $name = $header_deps{$name}; + } else { + $name =~ s/\.[ch]$//; + } + + my @files = split(/\s/, $name); + foreach my $n (@files) { + if (defined($driver_config{$n})) { + my $ref = $driver_config{$n}; + printf "$ref needs %s\n", $header; + $found = 1; + } + } + + if (!$found) { + printf "$file needs %s\n", $header; + } +} + +######################## +# Seeks files for header +# + +my %header; + +sub parse_headers() +{ + my $file = $File::Find::name; + + return if !($file =~ m/\.[ch]$/); + return if ($file =~ m|drivers/media/dvb/frontends/|); + + open IN, $file or die "Can't open $file\n"; + while (<IN>) { + if (m/^\s*\#include\s+\"([^\"]+)\"/) { + if (defined($header{$1})) { + my $head = $header{$1}; + found_ref ($file, $head); + } + } + } + close IN; +} + +##### +#main + +get_header_deps(); + +my ($FEs, $mult) = get_makefile($fname); + +foreach my $fe (keys %$FEs) { + my $file=$$FEs{$fe}; + my $found = 0; + + # Special cases + $file =~ s/tda10021/tda1002x/; + $file =~ s/tda10023/tda1002x/; + $file =~ s/dib3000mb/dib3000/; + + if (defined($$mult{$file})) { + $file .= " ".$$mult{$file}; + } + + my @files = split(/\s/, $file); + foreach my $f (@files) { + if (stat("$f.h")) { + printf "$fe = $f.h\n" if ($debug); + $found = 1; + $header {"$f.h"} = $fe; + last; + } + } + + if (!$found) { + printf "$file.h ($fe) not found in $file\n"; + exit -1; + } +} + +find({wanted => \&parse_makefiles, no_chdir => 1}, $SRC); +find({wanted => \&parse_headers, no_chdir => 1}, $SRC); |