[pxc] More generalized form of pxc_load, improved.
M Bianchi
mbianchi@Foveal.com
Sun, 10 Feb 2002 14:55:36 -0500
--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Alessandro made some suggestions to the previous version of framegrabber_load:
there is no support for passing arguments to insmod.
I often use
./pxc_load major=0
or
./pxc_load pll=0,1 buffer=2
or similar stuff.
This version has the following Usage message ...
Usage: framegrabber_load [ options ] { -l | -u } [[sym=value] ...]
Load or unload the kernel modules for the framegrabbers installed on the
system. Creates the device files in /dev for the framegrabbers found.
Must be run as root.
One these flag arguments is required:
-l load (or unload and reload) the framegrabber modules
-u unload the framegrabber modules
options:
-v Verbose; announce successful load or unload.
-i flag Flag option to be set to insmod(1). E.g. -i --verbose
adds the verbose option to the insmod call.
sym=value Additional arguments to insmod(1)
Setup:
This command must be run in the directory where the kernel modules are present.
Kernel modules are named with the recognized device names followed by the
kernel version as reported by the uname -r command. For example for a
PXC200 Imagenation board running on Linux kernel 2.2.12-16, the module file is
named pxc200_2.2.12-16 . The module is listed by lsmod(1) as pxc200 .
If this device_kernel form of module filename does not exist, then <device>.o
is tried. If that does not exist, then either pxc.o (for the PXC200) or
pxdrv.o (for the PX500, PX510 or PX600) is tried.
Recognized Imagenation framegrabbers: PXC200 PX500 PX510 PX600
Note: the PX610A is not supported.
--
Mike Bianchi
Foveal Systems
190 Loantaka Way
Madison NJ 07940-1910
+1 973 822-2085 Voice and Fax
MBianchi@Foveal.com
Create videos of auditorium presentations without a crew?
Yes!
http://www.AutoAuditorium.com
--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=framegrabber_load
Content-Transfer-Encoding: quoted-printable
#! /bin/sh
# Copyright (c) 2000 Foveal Systems
# MBianchi@Foveal.com
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# $Header: /usr/home/mbianchi/src/autoaud/5.0.aa/RCS/framegrabber_load.sh,v=
5.4 2002/02/10 19:48:05 mbianchi Exp $
cmd=3D$( basename $0 )
function Stderr {
echo >&2 "${cmd}: $@"
}
function Verbose {
# prints on stdout!
case $1 in
-f )
file=3D$2
shift 2
echo "$@" >>${file}
esac
if [ ${verbose} ]
then
echo "${cmd}: $@"
fi
}
function Usage {
echo >&2 '=07'
if [ $# -gt 0 ]
then
Stderr "$@"
fi
echo >&2 "Usage: ${cmd} [ options ] { -l | -u } [[sym=3Dvalue] ...]
Load or unload the kernel modules for the framegrabbers installed on the
system. Creates the device files in /dev for the framegrabbers found.
Must be run as root.
One these flag arguments is required:
-l load (or unload and reload) the framegrabber modules
-u unload the framegrabber modules
options:
-v Verbose; announce successful load or unload.
-i flag Flag option to be set to insmod(1). E.g. -i --verbose
adds the verbose option to the insmod call.
sym=3Dvalue Additional arguments to insmod(1)
Setup:
This command must be run in the directory where the kernel modules are pres=
ent.
Kernel modules are named with the recognized device names followed by the
kernel version as reported by the uname -r command. For example for a
PXC200 Imagenation board running on Linux kernel 2.2.12-16, the module file=
is
named pxc200_2.2.12-16 . The module is listed by lsmod(1) as pxc200 .
If this device_kernel form of module filename does not exist, then <device=
>.o
is tried. If that does not exist, then either pxc.o (for the PXC200) or
pxdrv.o (for the PX500, PX510 or PX600) is tried.
Recognized Imagenation framegrabbers: PXC200 PX500 PX510 PX600
Note: the PX610A is not supported.
"
exit 255
}
if [ $# -lt 1 ]
then
Usage
fi
badoption=3D"Need required option: either -l or -u"
insmod_options=3D
load=3D
unload=3D
verbose=3D
while getopts :i:luv option
do
case ${option} in
i )
insmod_options=3D"${insmod_options} ${OPTARG}"
break;
;;
l )
load=3Dload
badoption=3D
;;
u )
unload=3Dunload
badoption=3D
;;
v )
verbose=3Dverbose
;;
'?' )
Usage "invalid option -${OPTARG}"
;;
* )
Usage "oops! unimplimented option -${option}"
esac
done
shift $( expr ${OPTIND} - 1 )
if [ -n "${load}" -a -n "${unload}" ]
then
Usage "Cannot specify both -l and -u options."
elif [ -n "${badoption}" ]
then
Usage "${badoption} $*"
fi
insmod_symbols=3D"$*"
eval $( id | sed 's/(.*//' )
if [ "${uid}" !=3D 0 ]
then
Usage "Must be run as root."
fi
function MakeDevice {
dev_filename=3D$1
major=3D$2
max_minor=3D$3
index=3D$4
for j in \
' MINOR=3D0 TYPE=3D ' \
' MINOR=3D16 TYPE=3Dpgm ' \
' MINOR=3D32 TYPE=3Dctl ' \
' MINOR=3D48 TYPE=3DH ' \
' MINOR=3D64 TYPE=3DHpgm ' \
' MINOR=3D80 TYPE=3Dppm ' \
' MINOR=3D96 TYPE=3Drgb ' \
' MINOR=3D112 TYPE=3Dbgr ' \
' MINOR=3D128 TYPE=3DHppm ' \
' MINOR=3D144 TYPE=3DHrgb '
do
eval ${j}
if [ ${MINOR} -gt ${max_minor} ]
then
return
fi
file=3D${dev_filename}${index}${TYPE}
let MINOR+=3D${index}
rm -f ${file}
mknod ${file} c ${major} ${MINOR} &&
chmod go+w ${file}
done
}
exitcode=3D0
found_device=3D0
# DEVICE the device name found in /proc/devices
# DEV_FILENAME the root of the device filename, starts with /dev/
# BOARDID the string for the board found in lscpi(8)
# MAX_MINOR the maximum minor device number base supported.
# E.g. /dev/px0Hpgm is minor device 64
# /dev/px1Hpgm is minor device 65, etc.
# Maybe someday ...
# DEVICE=3Dpx610A
# DEV_FILENAME=3D/dev/px
# BOARDID=3D"Multimedia controller:.*\<SAA7146\>"
# MAX_MINOR=3D64
for i in \
' DEVICE=3Dpxc200
DEV_FILENAME=3D/dev/pxc
BOARDID=3D"Multimedia video controller:.*\<Bt848\>"
MAX_MINOR=3D144
DEFAULT_DOT_O_FILE=3Dpxc.o
' \
' DEVICE=3Dpx500
DEV_FILENAME=3D/dev/px
BOARDID=3D"Multimedia video controller:.*\<SAA7116\>"
MAX_MINOR=3D64
DEFAULT_DOT_O_FILE=3Dpxdrv.o
'
do
eval ${i}
device_count=3D$( lspci | grep -ic "${BOARDID}" )
if [ ${device_count} -le 0 ]
then
continue
fi
module_file=3D${DEVICE}_$( uname -r )
dot_o_file=3D${DEVICE}.o
rm -f ${DEV_FILENAME}*
if [ ${unload} ]
then
Verbose "/sbin/rmmod ${DEVICE}"
/sbin/rmmod ${DEVICE}
let "exitcode =3D ${exitcode} + $?"
found_device=3D1
continue
fi
/sbin/rmmod ${DEVICE} 2>/dev/null
if [ -s ${module_file} ]
then
:
elif [ -s ${dot_o_file} ]
then
module_file=3D${dot_o_file}
elif [ -s ${DEFAULT_DOT_O_FILE} ]
then
module_file=3D${DEFAULT_DOT_O_FILE}
else
Stderr "$(pwd):
No file ${module_file} , ${dot_o_file} , or ${DEFAULT_DOT_O_FILE}
Need module for \"${BOARDID}\"."
exitcode=3D1
continue
fi
found_device=3D1
insmod_cmd=3D"/sbin/insmod --force --name=3D${DEVICE} ${insmod_options} ${=
module_file} ${insmod_symbols}"
Verbose "${insmod_cmd}"
if ${insmod_cmd}
then
Verbose Loaded module ${module_file} for ${DEVICE}.
major=3D$( grep "${DEVICE}" /proc/devices | awk '{print $1}' )
while [ ${device_count} -gt 0 ]
do
let device_count-=3D1
MakeDevice ${DEV_FILENAME} ${major} ${MAX_MINOR} \
${device_count}
Verbose Created ${DEV_FILENAME}${device_count}
done
else
Verbose "insmod(1) failed:
${insmod_cmd}"
exitcode=3D2
fi
done
if [ ${found_device} =3D 0 ]
then
Verbose No devices found.
fi
exit ${exitcode}
--xHFwDpU9dbj6ez1V--