Skip to content

Commit c895b66

Browse files
committed
Initial support for MMAL camera on raspberry pi
Originally by dozencrows on github; mostly this commit: dozencrows/motion@6d1ed5b Changes to merge back into motion upstream made by Joseph Heenan (with help from lowflyerUK on github, see dozencrows/motion#1 ): - changed back to using autoconf etc as per the main project - submitted the one change we need to the raspicam files back upstream ( raspberrypi/userland#332 ) - imported latest versions of files in raspicam, now exactly match upstream - added README.txt to raspicam directory with brief explanation - replaced some tabs with spaces - removed dependency on checkout of raspberrypi userland repo; now we use the headers provided by libraspberrypi-dev - merged in a couple of the trivial later bugfix commits - merged in mmalcam_control_params commit to allow config of camera options - fixed many merge conflicts rebased on top of latest upstream motion
1 parent 8f9786f commit c895b66

File tree

14 files changed

+2548
-4
lines changed

14 files changed

+2548
-4
lines changed

Makefile.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ examplesdir = $(datadir)/@PACKAGE_NAME@/examples
3131
# These variables contain compiler flags, object files to build and files to #
3232
# install. #
3333
################################################################################
34-
CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@
34+
CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@ @MMAL_CFLAGS@
3535
LDFLAGS = @LDFLAGS@
36-
LIBS = @LIBS@ @FFMPEG_LIBS@
36+
LIBS = @LIBS@ @MMAL_LIBS@ @FFMPEG_LIBS@
3737
VIDEO_OBJ = @VIDEO@
3838
OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \
3939
netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \
4040
alg.o event.o picture.o rotate.o webhttpd.o \
41-
stream.o md5.o netcam_rtsp.o @FFMPEG_OBJ@ @SDL_OBJ@
41+
stream.o md5.o netcam_rtsp.o \
42+
@FFMPEG_OBJ@ @MMAL_OBJ@ @SDL_OBJ@
4243
SRC = $(OBJ:.o=.c)
4344
DOC = CHANGELOG COPYING CREDITS README motion_guide.html mask1.png normal.jpg outputmotion1.jpg outputnormal1.jpg
4445
EXAMPLES = *.conf

conf.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ struct config conf_template = {
148148
netcam_proxy: NULL,
149149
netcam_tolerant_check: 0,
150150
rtsp_uses_tcp: 1,
151+
#ifdef HAVE_MMAL
152+
mmalcam_name: NULL,
153+
mmalcam_control_params: NULL,
154+
#endif
151155
text_changes: 0,
152156
text_left: NULL,
153157
text_right: DEF_TIMESTAMP,
@@ -421,6 +425,27 @@ config_param config_params[] = {
421425
copy_bool,
422426
print_bool
423427
},
428+
#ifdef HAVE_MMAL
429+
{
430+
"mmalcam_name",
431+
"# Name of camera to use if you are using a camera accessed through OpenMax/MMAL\n"
432+
"# For the raspberry pi official camera, use vc.ril.camera"
433+
"# Default: Not defined",
434+
0,
435+
CONF_OFFSET(mmalcam_name),
436+
copy_string,
437+
print_string
438+
},
439+
{
440+
"mmalcam_control_params",
441+
"# Camera control parameters (see raspivid/raspistill tool documentation)\n"
442+
"# Default: Not defined",
443+
0,
444+
CONF_OFFSET(mmalcam_control_params),
445+
copy_string,
446+
print_string
447+
},
448+
#endif
424449
{
425450
"auto_brightness",
426451
"# Let motion regulate the brightness of a video device (default: off).\n"

conf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ struct config {
127127
const char *netcam_proxy;
128128
unsigned int netcam_tolerant_check;
129129
unsigned int rtsp_uses_tcp;
130+
#ifdef HAVE_MMAL
131+
const char *mmalcam_name;
132+
const char *mmalcam_control_params;
133+
#endif
130134
int text_changes;
131135
const char *text_left;
132136
const char *text_right;

configure.ac

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,24 @@ AC_CHECK_PROG([PKGCONFIG],[pkg-config],[yes],[no])
376376
AM_CONDITIONAL([FOUND_PKGCONFIG], [test "x$PKGCONFIG" = xyes])
377377
AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not found, please check motion_guide.html and install necessary dependencies.])])
378378

379+
# Check for raspberry pi mmal interface
380+
#
381+
HAVE_MMAL=""
382+
LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal"
383+
384+
if test -d ${LIBRASPBERRYPIDEVPATH}; then
385+
HAVE_MMAL="yes"
386+
fi
387+
388+
AS_IF([test "${HAVE_MMAL}" = "yes" ], [
389+
AC_SUBST(MMAL_CFLAGS)
390+
AC_SUBST(MMAL_OBJ)
391+
AC_SUBST(MMAL_LIBS)
392+
MMAL_OBJ="mmalcam.o raspicam/RaspiCamControl.o raspicam/RaspiCLI.o"
393+
MMAL_CFLAGS="-std=gnu99 -DHAVE_MMAL -Irasppicam -I/opt/vc/include"
394+
MMAL_LIBS="-L/opt/vc/lib -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lvchostif -lvchiq_arm"
395+
AC_DEFINE([HAVE_MMAL], 1, [Define to 1 if we want MMAL])
396+
])
379397

380398
#
381399
# Check for libavcodec and libavformat from ffmpeg
@@ -1112,7 +1130,6 @@ else
11121130
fi
11131131
fi
11141132

1115-
11161133
AC_SUBST(BIN_PATH)
11171134

11181135
AC_CONFIG_FILES([
@@ -1201,6 +1218,16 @@ else
12011218
echo "SDL support: No"
12021219
fi
12031220

1221+
if test "${HAVE_MMAL}" = "yes"; then
1222+
echo "MMAL support: Yes"
1223+
echo " ... MMAL_CFLAGS: $MMAL_CFLAGS"
1224+
echo " ... MMAL_OBJ: $MMAL_OBJ"
1225+
echo " ... MMAL_LIBS: $MMAL_LIBS"
1226+
else
1227+
echo "MMAL support: No"
1228+
echo " ... libraspberrypi-dev package not installed"
1229+
fi
1230+
12041231
if test "${HAVE_FFMPEG}" = "yes"; then
12051232
echo "FFmpeg support: Yes"
12061233
echo " ... FFMPEG_CFLAGS: $FFMPEG_CFLAGS"

0 commit comments

Comments
 (0)