AnsweredAssumed Answered

select/poll is not working in block mode for camera capture

Question asked by Titus Stalin on Mar 7, 2017
Latest reply on Mar 17, 2017 by Titus Stalin

Hello,

I've attached the v4l2 camera capture example code and am not getting any timeout when I use this example in poll/select method while using non-blocking method.

 

While opening the v4l2 device node in non-blocking mode, it should timeout if didn't receive any frames in given timeout.

But its not working as expected, but its working with UVC camera (USB webcam).

 

Application output log:

root@sabre:/#
root@sabre:/# ./poll /dev/video3 640 480 1
main
before open
after open fd : 3
get standard
set standard
query cap
capabilitioes
set format
get format
/dev/video3: 640x480 UYVY 30.00fps
request buffers
allocate buffers
buffers[n_buffers].start= 0x76dc1000     buffers[n_buffers].length=614400
buffers[n_buffers].start= 0x76d2b000     buffers[n_buffers].length=614400
buffers[n_buffers].start= 0x76c95000     buffers[n_buffers].length=614400
buffers[n_buffers].start= 0x76bff000     buffers[n_buffers].length=614400
queue buffers
start capture
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
Waiting at 'poll()'
 before process image
Processing Frame: 640x480 UYVY
[   0,   0] YUYV:0x0bfb0afc RGB:0x0313ffffffff
[ 250,   0] YUYV:0x16fd17ff RGB:0x131e10
red pixel count=0
 after process image
 before save frame
save frame
Wrote 614400 of 614400 bytes to frame1.raw
 before save frame

root@sabre:/#

 

Attached the dmesg (kernel log)

There you can see lot of DQBUF calls, but it should be.

 

Here is the log when I tried with USB webcam.

 

root@sabre:/#
root@sabre:/#
root@sabre:/# ./poll /dev/video4 640 480 1
main
before open
after open fd : 3
get standard
VIDIOC_G_STD: Inappropriate ioctl for device
set standard
VIDIOC_S_STD: Inappropriate ioctl for device
found NTSC TV decoder
found SECAM TV decoder
found PAL TV decoder
query cap
capabilitioes
VIDIOC_S_INPUT: Invalid argument
set format
get format
/dev/video4: 640x480 YUYV 5.00fps
request buffers
allocate buffers
buffers[n_buffers].start= 0x76dd1000     buffers[n_buffers].length=614400
buffers[n_buffers].start= 0x76d3b000     buffers[n_buffers].length=614400
buffers[n_buffers].start= 0x76ca5000     buffers[n_buffers].length=614400
buffers[n_buffers].start= 0x76c0f000     buffers[n_buffers].length=614400
queue buffers
start capture
Waiting at 'poll()'
Waiting at 'poll()'
 before process image
Processing Frame: 640x480 YUYV
[   0,   0] YUYV:0x7df87df8 RGB:0x71886e
[ 250,   0] YUYV:0x790e7d0f RGB:0x907295
red pixel count=0
 after process image
 before save frame
save frame
Wrote 614400 of 614400 bytes to frame1.raw
 before save frame

 

root@sabre:/#
root@sabre:/#
root@sabre:/#
root@sabre:/# dmesg
usb 1-1.1: reset high-speed USB device number 3 using ci_hdrc
UVC case VIDIOC_REQBUFS
vb2: Allocated 4 buffers, 1 plane(s) each
UVC case VIDIOC_QUERYBUF
UVC case VIDIOC_QUERYBUF
UVC case VIDIOC_QUERYBUF
UVC case VIDIOC_QUERYBUF
UVC case VIDIOC_QBUF
vb2: vb2_internal_qbuf() of buffer 0 succeeded
UVC case VIDIOC_QBUF
vb2: vb2_internal_qbuf() of buffer 1 succeeded
UVC case VIDIOC_QBUF
vb2: vb2_internal_qbuf() of buffer 2 succeeded
UVC case VIDIOC_QBUF
vb2: vb2_internal_qbuf() of buffer 3 succeeded
UVC case VIDIOC_STREAMON
UVC case VIDIOC_DQBUF
vb2: dqbuf of buffer 0, with state 0
UVC case VIDIOC_QBUF
vb2: vb2_internal_qbuf() of buffer 0 succeeded
UVC case VIDIOC_DQBUF
vb2: dqbuf of buffer 1, with state 0
UVC case VIDIOC_QBUF
vb2: vb2_internal_qbuf() of buffer 1 succeeded
UVC case VIDIOC_STREAMOFF
root@sabre:/#
root@sabre:/#

 

 

 

As you can see, kernel has limited DQBUF calls.

The same issue am getting if I try "select" method, you can check the attached code.

FYI: I'm using default kernel and OV5640 MIPI camera.

 

Can you please help me on this issue ?

Any insight/pointers pls ?

 

Thanks for your help.

 

Regards,

Titus S.

Original Attachment has been moved to: dmesg_log.txt.zip

Original Attachment has been moved to: application_camera.c.zip

Outcomes