i try to capture images from a webcam with video4linux and mmap method. My device is an Aptina MT9M114 camera on a Gentoo Linux (Kernel version 2.6.33.20). The code is based on this sample program: http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
When i want to start captering, i run the following code to prepare my buffers:
enum v4l2_buf_type type;
for (uint8_t i = 0; i < n_buffers; i++) {
struct v4l2_buffer buf;
CLEAR (buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
if (-1 == ioctl(fd, VIDIOC_QBUF, &buf)) {
return false;
}
}
When calling ioctl() here i get a deep layer crash. This is my syslog, i have no further informations:
Mar 2 20:06:30 nao33 klogd: kernel BUG at drivers/media/video/videobuf-core.c:227!
Mar 2 20:06:30 nao33 klogd: invalid opcode: 0000 [#2] PREEMPT
...
Mar 2 20:06:30 nao33 klogd: EIP: 0060:[<f804dad3>] EFLAGS: 00010246 CPU: 0
Mar 2 20:06:30 nao33 klogd: EIP is at videobuf_qbuf+0x23f/0x32d [videobuf_core]
Mar 2 20:06:30 nao33 klogd: EAX: 00000001 EBX: f5bf7e6c ECX: 00000000 EDX: f5bf7e6c
Mar 2 20:06:30 nao33 klogd: ESI: f6bcf61c EDI: f657f140 EBP: f5bf7dc4 ESP: f5bf7db4
Mar 2 20:06:30 nao33 klogd: DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 0068 preempt:00000000
Mar 2 20:06:30 nao33 klogd: Process videoexample (pid: 2979, ti=f5bf6000 task=f5bf00b0 task.ti=f5bf6000)
Mar 2 20:06:30 nao33 klogd: Stack:
Mar 2 20:06:30 nao33 klogd: f5bf7e6c f5bf7e6c 00000000 f8255ca3 f5bf7dcc f8255cb0 f5bf7e48 f8148980
Mar 2 20:06:30 nao33 klogd: <0> 0000ee34 00000001 c14a6e94 c044560f f6bcf600 f5bfb540 f825777c f6b18000
Mar 2 20:06:30 nao33 klogd: <0> c14a6e94 f5bf7e10 c101ee52 00000000 f5bf00b0 f5bf7e20 c100160a f5bf0d80
Mar 2 20:06:30 nao33 klogd: Call Trace:
Mar 2 20:06:30 nao33 klogd: [<f8255ca3>] ? vidioc_qbuf+0x0/0xf [unicorn]
Mar 2 20:06:30 nao33 klogd: [<f8255cb0>] ? vidioc_qbuf+0xd/0xf [unicorn]
Mar 2 20:06:30 nao33 klogd: [<f8148980>] ? __video_do_ioctl+0xe00/0x2d31 [videodev]
Mar 2 20:06:30 nao33 klogd: [<c101ee52>] ? set_next_entity+0xab/0x117
Mar 2 20:06:30 nao33 klogd: [<c100160a>] ? __switch_to+0x12/0x14d
Mar 2 20:06:30 nao33 klogd: [<c112dd83>] ? might_fault+0x14/0x16
Mar 2 20:06:30 nao33 klogd: [<c112dedc>] ? _copy_from_user+0x31/0x115
Mar 2 20:06:30 nao33 klogd: [<f814ab79>] ? video_ioctl2+0x2c8/0x368 [videodev]
Mar 2 20:06:30 nao33 klogd: [<c104635f>] ? T.366+0x27/0x33
Mar 2 20:06:30 nao33 klogd: [<f814a8b1>] ? video_ioctl2+0x0/0x368 [videodev]
Mar 2 20:06:30 nao33 klogd: [<f814711c>] ? v4l2_ioctl+0x33/0x37 [videodev]
Mar 2 20:06:30 nao33 klogd: [<c1085daf>] ? vfs_ioctl+0x69/0x91
Mar 2 20:06:30 nao33 klogd: [<c10862ad>] ? do_vfs_ioctl+0x448/0x486
Mar 2 20:06:30 nao33 klogd: [<c107c9dd>] ? fget_light+0x87/0x91
Mar 2 20:06:30 nao33 klogd: [<c108632c>] ? sys_ioctl+0x41/0x61
Mar 2 20:06:30 nao33 klogd: [<c1002790>] ? sysenter_do_call+0x12/0x26
Mar 2 20:06:30 nao33 klogd: Code: 0f 8e e1 00 00 00 68 ba ec 04 f8 e9 77 fe ff ff 83 3d cc f4 04 f8 00 7e 0b 68 dc ec 04 f8 e8 13 e3 29 c9 5a 8b 4e 48 85 c9 75 04 <0f> 0b eb fe 83 f9 07 75 1d 83 7e 4c 02 75 0b c7 46 4c 03 00 00
Mar 2 20:06:30 nao33 klogd: EIP: [<f804dad3>] videobuf_qbuf+0x23f/0x32d [videobuf_core] SS:ESP 0068:f5bf7db4
Has anybody a hint, what is the problem here? Actually this code should work, since its working on my local PC and its mainly copied from this example. So i have no idea how to find the problem.