diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-08 15:07:18 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-08 15:07:18 -0300 |
commit | 6b9db488d186cc23b3ab9a64fc2ad687c07407bf (patch) | |
tree | 1e6945c234507f460949bc619e116a0c4bbbf46b /v4l | |
parent | ea9723bc221278765e75d0362ce36881285ee241 (diff) | |
download | mediapointer-dvb-s2-6b9db488d186cc23b3ab9a64fc2ad687c07407bf.tar.gz mediapointer-dvb-s2-6b9db488d186cc23b3ab9a64fc2ad687c07407bf.tar.bz2 |
insmod.sh were replaced by a perl script (rmmod.pl)
From: Mauro Carvalho Chehab <mchehab@infradead.org>
insmod.sh were a hack, were somebody should check all dependencies
for each module. Several dependencies were mising, and, to keep it
updated for 178 modules is really hard.
rmmod.pl is a "smart" script: it does:
1) Check, for each found module on v4l, the correct order for each
module;
2) Check any dependencies for out-of-tree modules;
3) rmmod/insmod at the correct order;
4) It have a table with the suggested debug parameter for each module.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l')
-rw-r--r-- | v4l/Makefile | 13 | ||||
-rwxr-xr-x | v4l/scripts/insmod.sh | 307 | ||||
-rw-r--r-- | v4l/scripts/rmmod.pl | 193 |
3 files changed, 201 insertions, 312 deletions
diff --git a/v4l/Makefile b/v4l/Makefile index 6f86925a6..87fdc5270 100644 --- a/v4l/Makefile +++ b/v4l/Makefile @@ -232,14 +232,17 @@ distclean:: clean ################################################# # Kernel module insert/removal rules -insmod load:: - scripts/insmod.sh load +start insmod load:: + scripts/rmmod.pl load -rmmod unload:: - scripts/insmod.sh unload +stop rmmod unload:: + scripts/rmmod.pl unload reload:: - scripts/insmod.sh reload + scripts/rmmod.pl reload + +debug:: + scripts/rmmod.pl debug ################################################# # Configuration rules diff --git a/v4l/scripts/insmod.sh b/v4l/scripts/insmod.sh deleted file mode 100755 index 91b4558e3..000000000 --- a/v4l/scripts/insmod.sh +++ /dev/null @@ -1,307 +0,0 @@ -#!/bin/sh -# insmod modules from current directory without having to install them first - -sync - -case "$1" in - load) - echo "Inserting V4L/DVB modules into kernel" - modprobe i2c-core - modprobe crc32 - modprobe firmware_class - # make sure input stuff is there for IR remote controls - modprobe evdev - # video4linux - insmod ./compat_ioctl32.ko - insmod ./videodev.ko - insmod ./v4l1-compat.ko - insmod ./v4l2-common.ko - insmod ./video-buf.ko - insmod ./ir-common.ko - insmod ./ir-kbd-i2c.ko - insmod ./tuner.ko - insmod ./tda9887.ko - insmod ./tvaudio.ko - insmod ./tveeprom.ko - insmod ./tvmixer.ko - insmod ./cs53l32a.ko - insmod ./wm8775.ko - insmod ./cx25840.ko - insmod ./saa7115.ko - insmod ./btcx-risc.ko - insmod ./saa7127.ko - insmod ./msp3400.ko - insmod ./tvp5150.ko - insmod ./tda7432.ko - insmod ./tda9840.ko - insmod ./tda9875.ko - insmod ./tea6415c.ko - insmod ./tea6420.ko - # DVB core - insmod ./dvb-core.ko # dvb_net_debug=1 - # for hybrid cx88 and saa7134 cards - insmod ./video-buf-dvb.ko - # frontend drivers - insmod ./dvb-pll.ko - insmod ./ves1x93.ko - insmod ./sp8870.ko - insmod ./cx22700.ko - insmod ./stv0299.ko - insmod ./ves1820.ko - insmod ./tda1004x.ko - insmod ./tda10021.ko - insmod ./dib3000-common.ko - insmod ./dib3000mb.ko - insmod ./dib3000mc.ko - insmod ./l64781.ko - insmod ./tda8083.ko - insmod ./cx24110.ko - insmod ./cx24123.ko - insmod ./cx22702.ko - insmod ./mt312.ko - insmod ./mt352.ko - insmod ./stv0297.ko - insmod ./nxt200x.ko - insmod ./lgdt330x.ko - insmod ./nxt6000.ko - insmod ./bcm3510.ko - insmod ./s5h1420.ko - insmod ./sp887x.ko - insmod ./or51211.ko - insmod ./or51132.ko - insmod ./zl10353.ko - insmod ./ttusbdecfe.ko - - # saa7146 based siemens/technotrend/hauppauge cards - insmod ./saa7146.ko - insmod ./saa7146_vv.ko - insmod ./ttpci-eeprom.ko - insmod ./dvb-ttpci.ko - insmod ./budget-core.ko - insmod ./budget.ko - insmod ./budget-ci.ko - insmod ./budget-av.ko - insmod ./mxb.ko - insmod ./hexium_gemini.ko - insmod ./hexium_orion.ko - # technotrend/hauppauge USB things - insmod ./dvb-ttusb-budget.ko - insmod ./ttusb_dec.ko - - # technisat skystar2 - insmod ./stv0297_cs2.ko - insmod ./b2c2-flexcop.ko - insmod ./b2c2-flexcop-usb.ko - insmod ./b2c2-flexcop-pci.ko - # terratec CinergyT2 - insmod ./cinergyT2.ko - - insmod ./dvb-usb.ko - insmod ./dvb-usb-gp8psk.ko - insmod ./dvb-usb-vp7045.ko - insmod ./dvb-usb-dtt200u.ko - - insmod ./dvb-usb-dibusb-common.ko - insmod ./dvb-usb-dibusb-mb.ko - insmod ./dvb-usb-dibusb-mc.ko - insmod ./dvb-usb-a800.ko - insmod ./dvb-usb-nova-t-usb2.ko - insmod ./dvb-usb-umt-010.ko - insmod ./dvb-usb-digitv.ko - insmod ./dvb-usb-cxusb.ko - # bt8xx - insmod ./bt832.ko - insmod ./bttv.ko - insmod ./bt878.ko - insmod ./dst.ko - insmod ./dst_ca.ko - insmod ./dvb-bt8xx.ko - insmod ./saa6588.ko - # conexant cx2388x - insmod ./cx88xx.ko - insmod ./cx8800.ko - insmod ./cx8802.ko - insmod ./cx88-vp3054-i2c.ko - insmod ./cx88-dvb.ko - insmod ./cx88-blackbird.ko - insmod ./cx88-alsa.ko - # phillips saa713x - insmod ./saa7134.ko - insmod ./saa7134-alsa.ko -# insmod ./saa7134-oss.ko - insmod ./saa7134-dvb.ko - insmod ./saa7134-empress.ko - insmod ./saa6752hs.ko - - insmod ./em28xx.ko - insmod ./pvrusb2.ko - insmod ./cpia2.ko - insmod ./vivi.ko - - echo - ;; - debug) - echo "Inserting V4L/DVB modules (debug) into kernel" - modprobe i2c-core - modprobe crc32 - modprobe firmware_class - modprobe evdev - insmod ./compat_ioctl32.ko - insmod ./videodev.ko - insmod ./v4l1-compat.ko - insmod ./v4l2-common.ko - insmod ./video-buf.ko - insmod ./ir-common.ko - insmod ./ir-kbd-i2c.ko - insmod ./tuner.ko tuner_debug=1 - insmod ./tda9887.ko - insmod ./tvaudio.ko - insmod ./tveeprom.ko - insmod ./tvmixer.ko - insmod ./cs53l32a.ko - insmod ./wm8775.ko - insmod ./cx25840.ko - insmod ./saa7115.ko - insmod ./btcx-risc.ko - insmod ./saa7127.ko - insmod ./msp3400.ko - insmod ./tvp5150.ko - insmod ./tda7432.ko - insmod ./tda9840.ko - insmod ./tda9875.ko - insmod ./tea6415c.ko - insmod ./tea6420.ko - insmod ./dvb-core.ko cam_debug=1 - insmod ./video-buf-dvb.ko - insmod ./dvb-pll.ko - insmod ./ves1x93.ko - insmod ./sp8870.ko - insmod ./cx22700.ko - insmod ./stv0299.ko - insmod ./ves1820.ko - insmod ./tda1004x.ko - insmod ./tda10021.ko - insmod ./dib3000-common.ko - insmod ./dib3000mb.ko - insmod ./dib3000mc.ko - insmod ./l64781.ko - insmod ./stv0297.ko - insmod ./tda8083.ko - insmod ./cx24110.ko - insmod ./cx24123.ko - insmod ./mt312.ko - insmod ./mt352.ko - insmod ./cx22702.ko - insmod ./nxt200x.ko - insmod ./lgdt330x.ko - insmod ./nxt6000.ko - insmod ./bcm3510.ko - insmod ./s5h1420.ko - insmod ./sp887x.ko - insmod ./or51211.ko - insmod ./or51132.ko - insmod ./zl10353.ko - insmod ./ttusbdecfe.ko - insmod ./saa7146.ko - insmod ./saa7146_vv.ko - insmod ./ttpci-eeprom.ko - insmod ./dvb-ttpci.ko debug=247 - insmod ./budget-core.ko - insmod ./budget.ko - insmod ./budget-ci.ko - insmod ./budget-av.ko - insmod ./mxb.ko - insmod ./hexium_gemini.ko - insmod ./hexium_orion.ko - insmod ./dvb-ttusb-budget.ko - insmod ./stv0297_cs2.ko - insmod ./b2c2-flexcop.ko debug=0x01 - insmod ./b2c2-flexcop-usb.ko debug=0x01 - insmod ./b2c2-flexcop-pci.ko debug=0x01 - insmod ./ttusb_dec.ko - insmod ./cinergyT2.ko - - insmod ./dvb-usb.ko debug=0x33 - insmod ./dvb-usb-gp8psk.ko debug=0x03 - insmod ./dvb-usb-vp7045.ko debug=0x03 - insmod ./dvb-usb-dtt200u.ko debug=0x03 - - insmod ./dvb-usb-dibusb-common.ko debug=0x03 - insmod ./dvb-usb-dibusb-mb.ko - insmod ./dvb-usb-dibusb-mc.ko - insmod ./dvb-usb-a800.ko - insmod ./dvb-usb-nova-t-usb2.ko - insmod ./dvb-usb-umt-010.ko - insmod ./dvb-usb-digitv.ko - insmod ./dvb-usb-cxusb.ko - - insmod ./bt832.ko - insmod ./bttv.ko - insmod ./bt878.ko - insmod ./dst.ko - insmod ./dst_ca.ko - insmod ./dvb-bt8xx.ko - insmod ./saa6588.ko - - insmod ./cx88xx.ko - insmod ./cx8800.ko - insmod ./cx8802.ko - insmod ./cx88-vp3054-i2c.ko - insmod ./cx88-dvb.ko - insmod ./cx88-blackbird.ko - insmod ./cx88-alsa.ko - - insmod ./saa7134.ko - insmod ./saa7134-alsa.ko - insmod ./saa7134-oss.ko - insmod ./saa7134-dvb.ko - insmod ./saa7134-empress.ko - insmod ./saa6752hs.ko - - insmod ./em28xx.ko - insmod ./pvrusb2.ko - insmod ./cpia2.ko - insmod ./vivi.ko - echo - ;; - unload) - echo "Removing V4L/DVB modules from kernel" - rmmod b2c2-flexcop-usb b2c2-flexcop-pci b2c2-flexcop dvb-ttpci budget \ - budget-av budget-ci budget-core ttusb_dec dvb-ttusb-budget \ - ttpci-eeprom dvb-usb-nova-t-usb2.ko dvb-usb-a800.ko \ - dvb-usb-umt-010.ko dvb-usb-dibusb-mc.ko dvb-usb-dibusb-mb.ko\ - dvb-usb-dibusb-common.ko dvb-usb-gp8psk.ko dvb-usb-vp7045.ko \ - dvb-usb-dtt200u.ko dvb-usb-digitv.ko dvb-usb-cxusb.ko \ - dvb-usb.ko -# video4linux cards - rmmod cx88-alsa cx88-blackbird cx88-dvb cx88-vp3054-i2c cx8802 cx8800 \ - cx88xx saa7134-oss saa7134-alsa saa7134-empress saa7134-dvb \ - saa7134 dvb-bt8xx dst_ca dst bt878 bttv bt832 mxb \ - hexium_gemini hexium_orion em28xx pvrusb2 cpia2 vivi - -# frontends - rmmod dib3000mb zl10353 dib3000mc dib3000_common nxt200x ves1x93 \ - sp8870 cx22700 stv0299 ves1820 cinergyT2 ttusbdecfe \ - tda1004x l64781 tda8083 cx24110 cx22702 stv0297 \ - tda10021 mt352 mt312 bcm3510 s5h1420 nxt6000 \ - stv0297_cs2 lgdt330x cx24123 sp887x or51211 or51132 \ - dvb-pll - -# chips and helpers - rmmod saa7127 msp3400 tvp5150 tda7432 tda9840 tda9875 tea6415c tea6420 \ - saa6752hs saa6588 btcx-risc tveeprom tvaudio tda9887 tuner \ - ir-kbd-i2c ir-common cx25840 tvmixer cs53l32a wm8775 saa7115 \ - saa7146_vv saa7146 video-buf-dvb video-buf \ - v4l2-common v4l1-compat dvb-core videodev compat_ioctl32 - - echo - ;; - reload) - $0 unload && $0 load - ;; - *) - echo "Usage$0 {load|unload|debug|reload}" - exit 1 -esac - -sync diff --git a/v4l/scripts/rmmod.pl b/v4l/scripts/rmmod.pl new file mode 100644 index 000000000..6cb690217 --- /dev/null +++ b/v4l/scripts/rmmod.pl @@ -0,0 +1,193 @@ +#!/usr/bin/perl +use strict; +use File::Find; + +my %depend = (); +my %depend2 = (); +my %rmlist = (); +my @nodep; +my @modlist; +my @allmodules; +my %reqmodules; +my %loaded = (); +my $i=0; + +# Device debug parameters +# Module name Debug option +my %debug = ( "tuner" => "tuner_debug=1", + "dvb-core" => "cam_debug=1", + "dvb-ttpci" => "debug=247", + "b2c2-flexcop" => "debug=0x01", + "b2c2-flexcop-usb" => "debug=0x01", + "b2c2-flexcop-pci" => "debug=0x01", + "dvb-usb" => "debug=0x33", + "dvb-usb-gp8psk" => "debug=0x03", + "dvb-usb-vp7045" => "debug=0x03", + "dvb-usb-dtt200u" => "debug=0x03", + "dvb-usb-dibusb-common" => "debug=0x03", + ); + + +sub parse_dir { + my $file = $File::Find::name; + + if (!($file =~ /[.]ko$/)) { + return; + } + + my $module = $file; + $module =~ s|^[./]*(.*)[.]ko|\1|; + + open IN, "modinfo $file|grep depends|cut -b 17-|"; + while (<IN>) { + my $deps = $_; + $deps =~ s/\n//; + $deps =~ s/[,]/ /g; + $deps = " $deps "; + $depend{$module} = $deps; + push @allmodules, $module; + $i++; + } + close IN; +} + +sub parse_loaded { + open IN, "/proc/modules"; + while (<IN>) { + m/^([\w\d_-]+)/; + $loaded{$1}=1; + } + close IN; +} + +sub cleandep() +{ + my $dep; + + while ( my ($k, $v) = each(%depend) ) { + my $arg=$v; + my $arg2=" "; + while (!($arg =~ m/^\s*$/)) { + if ($arg =~ m/^ ([^ ]+) /) { + my $val=$1; + if (exists($depend{$val})) { + $arg2="$arg2 $val "; + } else { + $reqmodules{$val}=1; + } + } + $arg =~ s/^ [^ ]+//; + $arg2 =~ s/\s\s+/ /; + } + $depend2 { $k } = $arg2; + } + +} + +sub rmdep() +{ + my $dep; + + while ($dep=pop @nodep) { + while ( my ($k, $v) = each(%depend2) ) { + if ($v =~ m/\s($dep)\s/) { + $v =~ s/\s${dep}\s/ /; + $v =~ s/\s${dep}\s/ /; + $v =~ s/\s${dep}\s/ /; + $depend2 {$k} = $v; + } + } + } +} + +sub orderdep () +{ + my $old; + do { + $old=$i; + while ( my ($key, $value) = each(%depend2) ) { + if ($value =~ m/^\s*$/) { + push @nodep, $key; + push @modlist, $key; + $i=$i-1; + delete $depend2 {$key}; + } + } + rmdep(); + } until ($old==$i); + while ( my ($key, $value) = each(%depend2) ) { + printf "ERROR: bad dependencies - $key ($value)\n"; + } +} + +sub insmod ($) +{ + my $debug=shift; + + while ( my ($key, $value) = each(%reqmodules) ) { + printf ("modprobe $key\n"); + system ("modprobe $key"); + } + + foreach my $key (@modlist) { + if ($debug) { + my $dbg=$debug{$key}; + + printf "insmod ./$key.ko $dbg\n"; + system "insmod ./$key.ko $dbg\n"; + } else { + printf "insmod ./$key.ko\n"; + system "insmod ./$key.ko\n"; + } + } +} + +sub rmmod () +{ + my $cmd="rmmod"; + while (my $key=pop @modlist) { + my $dep=$key; + $dep=~s/[\-]/_/g; + if (exists ($loaded{$dep})) { + printf "$cmd ./$key.ko\n"; + system "$cmd ./$key.ko\n"; + } + } +} + +sub prepare_cmd() +{ + find(\&parse_dir, "."); + printf "found $i modules\n"; + + cleandep(); + orderdep(); +} + +# main +my $mode=shift; +if ($mode eq "load") { + prepare_cmd; + insmod(0); +} else { + if ($mode eq "unload") { + prepare_cmd; + parse_loaded; + rmmod; + } else { + if ($mode eq "reload") { + prepare_cmd; + parse_loaded; + rmmod; + insmod(0); + } else { + if ($mode eq "debug") { + prepare_cmd; + parse_loaded; + insmod(1); + } else { + printf "Usage: $0 [load|unload|reload]\n"; + } + } + } +} |