"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "video_v4l2.c" between
motion-release-4.2.2.tar.gz and motion-Release-4.3.0.tar.gz

About: Motion monitors the video signal from one or more cameras and is able to detect motion.

video_v4l2.c  (motion-release-4.2.2):video_v4l2.c  (motion-Release-4.3.0)
skipping to change at line 28 skipping to change at line 28
* *
*/ */
#include "translate.h" #include "translate.h"
#include "rotate.h" /* Already includes motion.h */ #include "rotate.h" /* Already includes motion.h */
#include "video_common.h" #include "video_common.h"
#include "video_v4l2.h" #include "video_v4l2.h"
#include <sys/mman.h> #include <sys/mman.h>
#ifdef HAVE_V4L2 #ifdef HAVE_V4L2
#if defined(HAVE_LINUX_VIDEODEV2_H)
#include <linux/videodev2.h> #include <linux/videodev2.h>
#else
#include <sys/videoio.h>
#endif
#define u8 unsigned char #define u8 unsigned char
#define u16 unsigned short #define u16 unsigned short
#define u32 unsigned int #define u32 unsigned int
#define s32 signed int #define s32 signed int
#define MMAP_BUFFERS 4 #define MMAP_BUFFERS 4
#define MIN_MMAP_BUFFERS 2 #define MIN_MMAP_BUFFERS 2
#define V4L2_PALETTE_COUNT_MAX 21 #define V4L2_PALETTE_COUNT_MAX 21
skipping to change at line 115 skipping to change at line 119
for (indx=0; indx <=V4L2_PALETTE_COUNT_MAX; indx++ ){ for (indx=0; indx <=V4L2_PALETTE_COUNT_MAX; indx++ ){
sprintf(palette_array[indx].fourcc ,"%c%c%c%c" sprintf(palette_array[indx].fourcc ,"%c%c%c%c"
,palette_array[indx].v4l2id >> 0 ,palette_array[indx].v4l2id >> 0
,palette_array[indx].v4l2id >> 8 ,palette_array[indx].v4l2id >> 8
,palette_array[indx].v4l2id >> 16 ,palette_array[indx].v4l2id >> 16
,palette_array[indx].v4l2id >> 24); ,palette_array[indx].v4l2id >> 24);
} }
} }
#if defined (__OpenBSD__) || defined (__FreeBSD__) #if defined (BSD)
static int xioctl(src_v4l2_t *vid_source, unsigned long request, void *arg) static int xioctl(src_v4l2_t *vid_source, unsigned long request, void *arg)
#else #else
static int xioctl(src_v4l2_t *vid_source, int request, void *arg) static int xioctl(src_v4l2_t *vid_source, int request, void *arg)
#endif #endif
{ {
int ret; int ret;
do do
ret = ioctl(vid_source->fd_device, request, arg); ret = ioctl(vid_source->fd_device, request, arg);
while (-1 == ret && EINTR == errno && !vid_source->finish); while (-1 == ret && EINTR == errno && !vid_source->finish);
skipping to change at line 1335 skipping to change at line 1339
MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "- TIMEPERFRAME"); MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "- TIMEPERFRAME");
if (!(vid_source->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { if (!(vid_source->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, _("Device does not support capturi ng.")); MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, _("Device does not support capturi ng."));
return -1; return -1;
} }
return 0; return 0;
} }
static int v4l2_fps_set(struct context *cnt, struct video_dev *curdev) {
src_v4l2_t *vid_source = (src_v4l2_t *) curdev->v4l2_private;
struct v4l2_streamparm setfps;
int retcd;
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = 1;
setfps.parm.capture.timeperframe.denominator = cnt->conf.framerate;
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO
, _("Trying to set fps to %d")
, setfps.parm.capture.timeperframe.denominator);
retcd = xioctl(vid_source, VIDIOC_S_PARM, &setfps);
if (retcd != 0) {
MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO
,_("Error setting fps. Return code %d"), retcd);
}
MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO
, _("Device set fps to %d")
, setfps.parm.capture.timeperframe.denominator);
return 0;
}
#endif /* HAVE_V4L2 */ #endif /* HAVE_V4L2 */
void v4l2_mutex_init(void) { void v4l2_mutex_init(void) {
#ifdef HAVE_V4L2 #ifdef HAVE_V4L2
pthread_mutex_init(&v4l2_mutex, NULL); pthread_mutex_init(&v4l2_mutex, NULL);
#else #else
MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, _("V4L2 is not enabled")); MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, _("V4L2 is not enabled"));
#endif // HAVE_V4L2 #endif // HAVE_V4L2
} }
skipping to change at line 1390 skipping to change at line 1421
curdev->starting = TRUE; curdev->starting = TRUE;
retcd = v4l2_device_init(cnt, curdev); retcd = v4l2_device_init(cnt, curdev);
if (retcd == 0) retcd = v4l2_vdev_init(cnt); if (retcd == 0) retcd = v4l2_vdev_init(cnt);
if (retcd == 0) retcd = v4l2_device_open(cnt, curdev); if (retcd == 0) retcd = v4l2_device_open(cnt, curdev);
if (retcd == 0) retcd = v4l2_device_capability(curdev); if (retcd == 0) retcd = v4l2_device_capability(curdev);
if (retcd == 0) retcd = v4l2_input_select(cnt, curdev); if (retcd == 0) retcd = v4l2_input_select(cnt, curdev);
if (retcd == 0) retcd = v4l2_norm_select(cnt, curdev); if (retcd == 0) retcd = v4l2_norm_select(cnt, curdev);
if (retcd == 0) retcd = v4l2_frequency_select(cnt, curdev); if (retcd == 0) retcd = v4l2_frequency_select(cnt, curdev);
if (retcd == 0) retcd = v4l2_pixfmt_select(cnt, curdev); if (retcd == 0) retcd = v4l2_pixfmt_select(cnt, curdev);
if (retcd == 0) retcd = v4l2_fps_set(cnt, curdev);
if (retcd == 0) retcd = v4l2_ctrls_count(curdev); if (retcd == 0) retcd = v4l2_ctrls_count(curdev);
if (retcd == 0) retcd = v4l2_ctrls_list(curdev); if (retcd == 0) retcd = v4l2_ctrls_list(curdev);
if (retcd == 0) retcd = vid_parms_parse(cnt); if (retcd == 0) retcd = vid_parms_parse(cnt);
if (retcd == 0) retcd = v4l2_parms_set(cnt, curdev); if (retcd == 0) retcd = v4l2_parms_set(cnt, curdev);
if (retcd == 0) retcd = v4l2_ctrls_set(curdev); if (retcd == 0) retcd = v4l2_ctrls_set(curdev);
if (retcd == 0) retcd = v4l2_mmap_set(curdev); if (retcd == 0) retcd = v4l2_mmap_set(curdev);
if (retcd == 0) retcd = v4l2_imgs_set(cnt, curdev); if (retcd == 0) retcd = v4l2_imgs_set(cnt, curdev);
if (retcd < 0){ if (retcd < 0){
/* These may need more work to consider all the fail scenarios*/ /* These may need more work to consider all the fail scenarios*/
if (curdev->v4l2_private != NULL){ if (curdev->v4l2_private != NULL){
 End of changes. 5 change blocks. 
1 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)