我试图在Samsung Galaxy S3上运行视频捕获示例代码here。
起初我在许多VIDIOC
操作中遇到了一些错误(例如S_FMT
或STREAMON
),我可以通过以下方式解决这些错误:
现在我来到这里..所有ioctls都成功完成,但我得到0数据.. v4l2_buffer->bytesused
总是0。
我绝望了所以我在 fimc_v4l2.c 和 fimc_capture.c (FIMC是三星的V4L2驱动程序)的每个功能中添加了printk日志,这是我在使用相机应用时看到的所有内容:(我只是在从STREAMON
返回后粘贴了该部分)
@@@ fimc_dqbuf#bytesused = 0 length = 0
### fimc_dqbuf_capture start#bytesused = 0 length = 0
### fimc_dqbuf_capture #list empty
fimc_irq_cap [0],fimc0,cnt [0]
fimc_irq_cap [0] SKIPPED
fimc_irq_cap [1],fimc0, cnt [1]
@@@@ fimc_dqbuf#bytesused = 0 length = 65545
### fimc_dqbuf_capture start#bytesused = 0 length = 65545
### fimc_dqbuf_capture #list not empty
### fimc_dqbuf_capture #length = 65545
### fimc_dqbuf_capture end #length = 65545,bytesused = 0
@@@ fimc_qbuf#bytesused = 0 length = 0
### fimc_qbuf_capture start
### fimc_qbuf_capture#buf state ok
### fimc_qbuf_capture #index = 0
### fimc_qbuf_capture结束
@@@ fimc_dqbuf# bytesused = 3225703951 length = 0
### fimc_dqbuf_capture start#bytesused = 3225703951 length = 0
### fimc_dqbuf_capture #list empty
fimc_irq_cap [2],fimc0,cnt [2]
@@@ fimc_dqbuf#bytesused = 3225703951 length = 65545
### fimc_dqbuf_capture start#bytesused = 3225703951 length = 65545
### fimc_dqbuf_capture #list not empty
### fimc_dqbuf_capture #length = 65545
### fimc_dqbuf_capture end #length = 65545,bytesused = 3225703951
@@@ fimc_qbuf#bytesused = 0 length = 0
### fimc_qbuf_capture start
### fimc_qbuf_capture#buf state ok
### fimc_qbuf_capture #index = 1
### fimc_qbuf_capture结束
... ...
我将日志分成块:它基本上是DQBUF(empty) -> IRQ -> DQBUF -> QBUF
循环。我用粗体标记b->lenght
和b->bytesused
首先获得非零值。
我修改了 v4l2示例代码来模拟这个确切的流程。
但是你可以看到b->lenght
和b->bytesused
只有0:
@@@ fimc_dqbuf#bytesused = 0 length = 0
### fimc_dqbuf_capture start#bytesused = 0 length = 0
### fimc_dqbuf_capture #list 空的
fimc_irq_cap [0],fimc0,cnt [0]
fimc_irq_cap [0] SKIPPED
fimc_irq_cap [1],fimc0,cnt [1]
@@@@ fimc_dqbuf# bytesused = 0 length = 0
### fimc_dqbuf_capture start# bytesused = 0 length = 0
### fimc_dqbuf_capture #list not empty
### fimc_dqbuf_capture #length = 0
### fimc_dqbuf_capture end# length = 0,bytesused = 0
@@@ fimc_qbuf#bytesused = 0 length = 0
### fimc_qbuf_capture start
### fimc_qbuf_capture# buf state ok
### fimc_qbuf_capture #index = 0
### fimc_qbuf_capture结束
@@@ fimc_dqbuf# bytesused = 0 length = 0
### fimc_dqbuf_capture start#bytesused = 0 length = 0
### fimc_dqbuf_capture #list empty
fimc_irq_cap [2],fimc0, cnt [2]
@@@ fimc_dqbuf#bytesused = 0 length = 0
### fimc_dqbuf_capture start#bytesused = 0 length = 0
### fimc_dqbuf_capture #list not empty
### fimc_dqbuf_capture# length = 0
### fimc_dqbuf_capture end #length = 0,bytesused = 0
@@@ fimc_qbuf#bytesused = 0 length = 0
### fimc_qbuf_capture start
### fimc_qbuf_capture#buf state ok
### fimc_qbuf_capture #index = 1
### fimc_qbuf_capture end
...
我已尝试在内核驱动程序源代码中使用 grep 来查找何时可以bytesused
分配但无法找到正确的位置。
有人有想法吗?我非常感激
当我在strlen()
ped缓冲区的指针上使用mmap
时,它实际上返回一个合理的值。返回的尺寸会根据我指向相机的位置而变化(当我用手遮住镜头时,它会变得非常小,当它用来遮住镜头时,它会变得非常小;当它变得明亮时它会变化大约1万;它还会保持不变当我移动相机时改变)。我猜测这表明我实际上得到了帧。
但我仍然无法弄清楚为什么bytesused
始终为0。