First approach to fix the problem to compile motion if v4l2 is not supported

This commit is contained in:
AngelCarpintero
2007-01-11 00:51:43 +00:00
parent efe789b089
commit 6daec25e7c
4 changed files with 162 additions and 4 deletions

120
configure vendored
View File

@@ -4779,6 +4779,120 @@ fi
done
have_v4l2=false
{ echo "$as_me:$LINENO: checking for struct v4l2_buffer" >&5
echo $ECHO_N "checking for struct v4l2_buffer... $ECHO_C" >&6; }
if test "${ac_cv_type_struct_v4l2_buffer+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/time.h>
#include <linux/videodev.h>
typedef struct v4l2_buffer ac__type_new_;
int
main ()
{
if ((ac__type_new_ *) 0)
return 0;
if (sizeof (ac__type_new_))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_struct_v4l2_buffer=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_struct_v4l2_buffer=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_struct_v4l2_buffer" >&5
echo "${ECHO_T}$ac_cv_type_struct_v4l2_buffer" >&6; }
if test $ac_cv_type_struct_v4l2_buffer = yes; then
have_v4l2=true
else
have_v4l2=false
fi
if test x$have_v4l2 = xfalse; then
KERNEL_VERSION=`uname -r`
as_ac_File=`echo "ac_cv_file_/lib/modules/$KERNEL_VERSION/build/include/linux/videodev2.h" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for /lib/modules/$KERNEL_VERSION/build/include/linux/videodev2.h" >&5
echo $ECHO_N "checking for /lib/modules/$KERNEL_VERSION/build/include/linux/videodev2.h... $ECHO_C" >&6; }
if { as_var=$as_ac_File; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
test "$cross_compiling" = yes &&
{ { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
{ (exit 1); exit 1; }; }
if test -r "/lib/modules/$KERNEL_VERSION/build/include/linux/videodev2.h"; then
eval "$as_ac_File=yes"
else
eval "$as_ac_File=no"
fi
fi
ac_res=`eval echo '${'$as_ac_File'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
if test `eval echo '${'$as_ac_File'}'` = yes; then
have_v4l2=true
have_v4l2=false
fi
fi
if test x$have_v4l2 = xtrue; then
TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_V4L2"
fi
{ echo "$as_me:$LINENO: checking for short int" >&5
echo $ECHO_N "checking for short int... $ECHO_C" >&6; }
if test "${ac_cv_type_short_int+set}" = set; then
@@ -7782,6 +7896,12 @@ else
else
echo "V4L included: No"
fi
if test x$have_v4l2 = xtrue; then
echo "V4L2 supported: Yes"
else
echo "V4L2 supported: No"
fi
fi
if test "${FFMPEG_OK}" = "found"; then

View File

@@ -541,6 +541,27 @@ dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(stdio.h unistd.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h sys/param.h)
dnl check if v4l2 is available
have_v4l2=false
AC_CHECK_TYPE([struct v4l2_buffer],
[have_v4l2=true],
[have_v4l2=false],
[#include <sys/time.h>
#include <linux/videodev.h>])
if test x$have_v4l2 = xfalse; then
KERNEL_VERSION=`uname -r`
AC_CHECK_FILE(/lib/modules/$KERNEL_VERSION/build/include/linux/videodev2.h,
[have_v4l2=true]
[have_v4l2=false])
fi
if test x$have_v4l2 = xtrue; then
TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_V4L2"
fi
dnl Check sizes of integer types
AC_CHECK_SIZEOF(short int)
if test "$ac_cv_sizeof_short_int" = "4"; then
@@ -877,6 +898,12 @@ else
else
echo "V4L included: No"
fi
if test x$have_v4l2 = xtrue; then
echo "V4L2 supported: Yes"
else
echo "V4L2 supported: No"
fi
fi
if test "${FFMPEG_OK}" = "found"; then

View File

@@ -41,6 +41,10 @@
*/
#ifndef WITHOUT_V4L
#ifdef HAVE_V4L2
# warning **************************************************
# warning Using experimental V4L2 support
# warning **************************************************
#include <math.h>
#include <sys/utsname.h>
@@ -685,3 +689,4 @@ void v4l2_cleanup(struct video_dev *viddev)
}
#endif
#endif

View File

@@ -245,9 +245,11 @@ void vid_cleanup(void)
int i = -1;
if (viddevs) {
while (viddevs[++i]) {
#ifdef HAVE_V4L2
if (viddevs[i]->v4l2)
v4l2_cleanup(viddevs[i]);
else
#endif
munmap(viddevs[i]->v4l_buffers[0], viddevs[i]->size_map);
free(viddevs[i]);
}
@@ -392,19 +394,21 @@ static int vid_v4lx_start(struct context *cnt)
viddevs[i]->hue = 0;
viddevs[i]->owner = -1;
viddevs[i]->v4l_fmt = VIDEO_PALETTE_YUV420P;
#ifdef HAVE_V4L2
/* First lets try V4L2 and if it's not supported V4L1 */
viddevs[i]->v4l2 = 1;
if (!v4l2_start(cnt, viddevs[i], width, height, input, norm, frequency, tuner_number)) {
#endif
if (!v4l_start(cnt, viddevs[i], width, height, input, norm, frequency, tuner_number)) {
pthread_mutex_unlock(&vid_mutex);
return -1;
}
#ifdef HAVE_V4L2
viddevs[i]->v4l2 =0;
}
#endif
if (viddevs[i]->v4l2 == 0){
motion_log(-1, 0, "Using V4L1");
}else{
@@ -509,18 +513,20 @@ int vid_next(struct context *cnt, unsigned char *map)
viddevs[i]->frames = conf->roundrobin_frames;
cnt->switched = 1;
}
#ifdef HAVE_V4L2
if (viddevs[i]->v4l2) {
v4l2_set_input(cnt, viddevs[i], map, width, height, conf);
ret = v4l2_next(cnt, viddevs[i], map, width, height);
} else {
#endif
v4l_set_input(cnt, viddevs[i], map, width, height, conf->input, conf->norm,
conf->roundrobin_skip, conf->frequency, conf->tuner_number);
ret = v4l_next(viddevs[i], map, width, height);
#ifdef HAVE_V4L2
}
#endif
if (--viddevs[i]->frames <= 0) {
viddevs[i]->owner = -1;
pthread_mutex_unlock(&viddevs[i]->mutex);