examples/camera: Call VIDIOC_S_FMT before VIDIOC_REQBUFS
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
ca855f3f23
commit
02f608b64d
@ -131,20 +131,6 @@ static int camera_prepare(int fd, enum v4l2_buf_type type,
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
/* VIDIOC_REQBUFS initiate user pointer I/O */
|
|
||||||
|
|
||||||
req.type = type;
|
|
||||||
req.memory = V4L2_MEMORY_USERPTR;
|
|
||||||
req.count = buffernum;
|
|
||||||
req.mode = buf_mode;
|
|
||||||
|
|
||||||
ret = ioctl(fd, VIDIOC_REQBUFS, (unsigned long)&req);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
printf("Failed to VIDIOC_REQBUFS: errno = %d\n", errno);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* VIDIOC_S_FMT set format */
|
/* VIDIOC_S_FMT set format */
|
||||||
|
|
||||||
fmt.type = type;
|
fmt.type = type;
|
||||||
@ -160,6 +146,20 @@ static int camera_prepare(int fd, enum v4l2_buf_type type,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* VIDIOC_REQBUFS initiate user pointer I/O */
|
||||||
|
|
||||||
|
req.type = type;
|
||||||
|
req.memory = V4L2_MEMORY_USERPTR;
|
||||||
|
req.count = buffernum;
|
||||||
|
req.mode = buf_mode;
|
||||||
|
|
||||||
|
ret = ioctl(fd, VIDIOC_REQBUFS, (unsigned long)&req);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
printf("Failed to VIDIOC_REQBUFS: errno = %d\n", errno);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Prepare video memory to store images */
|
/* Prepare video memory to store images */
|
||||||
|
|
||||||
*vbuf = malloc(sizeof(v_buffer_t) * buffernum);
|
*vbuf = malloc(sizeof(v_buffer_t) * buffernum);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user