summaryrefslogtreecommitdiff
path: root/v4l/scripts/modules.sh
blob: 8bbc62253918879591e30a3c34beb85e648b3e61 (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
#!/bin/sh

function xrmmod() {
	local module regex
	module="$1"
	regex=`echo $module | sed -e 's/[-_]/[-_]/g'`
	grep -qe "$regex" /proc/modules || return 0
	echo "unload $module"
	if test "$UID" = "0"; then
		/sbin/rmmod $module
	else
		sudo /sbin/rmmod $module
	fi
}

function xinsmod() {
	local module regex file args
	module="$1"
	shift
	args="$*"
	regex=`echo $module | sed -e 's/[-_]/[-_]/g'`
	grep -qe "$regex" /proc/modules && return
	file=""
	test -f "$module.o"	&& file="$module.o"
	test -f "$module.ko"	&& file="$module.ko"
	if test "$file" != ""; then
		echo "load $file $args"
		if test "$UID" = "0"; then
			/sbin/insmod $file $args
		else
			sudo /sbin/insmod $file $args
		fi
	else
		echo "load $module $args"
		if test "$UID" = "0"; then
			/sbin/modprobe $module $args
		else
			sudo /sbin/modprobe $module $args
		fi
	fi
}

function v4l2basic() {
	for module in	i2c-core i2c-algo-bit			\
			videodev v4l2-common v4l1-compat	\
			video-buf				\
			soundcore
	do
		xinsmod $module
	done
}