初级会员
- 积分
- 90
- 金钱
- 90
- 注册时间
- 2019-7-28
- 在线时间
- 33 小时
|
10金钱
按照V4L2逻辑编写ov2640的应用程序
打开摄像头->获取驱动信息->设置图像格式->申请帧缓冲区
申请缓冲区时报错,类似的代码如下,原子哥提供的出厂代码包含一个ov2640_camera,想请教下DMA这部分的逻辑
[ 1042.549695] mx6s-csi 21c4000.csi: dma_alloc_coherent of size 0 failed
struct v4l2_requestbuffers req;
req.count = 4;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
ioctl(fd,VIDIOC_REQBUFS,&req);
struct buffer
{
void *start;
unsigned int length;
}*buffers;
buffers = (struct buffer*)calloc (req.count, sizeof(*buffers));
unsigned int n_buffers = 0;
for(n_buffers = 0; n_buffers < req.count; ++n_buffers)
{
struct v4l2_buffer buf;
memset(&buf,0,sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = n_buffers;
if(ioctl(fd,VIDIOC_QUERYBUF,&buf) == -1)
{
printf("lzj---------_>>>>>>error\n");
close(fd);
exit(-1);
}
buffers[n_buffers].length = buf.length;
buffers[n_buffers].start = mmap(NULL,buf.length,PROT_READ|PROT_WRITE,MAP_SHARED,fd,buf.m.offset);
|
|