Query: Reqbufs returning without calling queue_setup.
Hi
There is a check in __reqbufs in videobuf2-core.c in which if the count is same then the function returns immediately. __reqbufs also calls queue_setup callback into driver which updates the plane counts and sizes of vb2 queue. The count and size can be affected/changed by S_FMT and G_FMT ioctl calls. This causes an issue with following call flow:
1. reqbufs.count = 8;
ioctl(fd, VIDIOC_REQBUFS, &reqbufs);
2. ioctl(fd, VIDIOC_S_FMT, &format) --> update format with differen height/width etc which effect the sizeofimage
3. reqbufs.count = 8;
ioctl(fd, VIDIOC_REQBUFS, &reqbufs); to update the vb2_queue num planes
and size of each plane. But this call never goes to the driver since the count is same.
Shouldn't we query the driver for any change in plane count/size before deciding to return from reqbufs? Following is the code. This is just a temporary patch to point the issue.
(quoted diff) +0 -0
b/drivers/media/v4l2-core/videobuf2-core.c
index e42eb0d..57e18c2 100644
drivers/media/v4l2-core/videobuf2-core.c +0 -0
@@ -590,13 +590,6 @@ static int __reqbufs(struct vb2_queue *q, struct
v4l2_requestbuffers *req)
return -EBUSY;
}- /*
- * If the same number of buffers and memory access method is
requested
- * then return immediately.
- */
- if (q->memory == req->memory && req->count == q->num_buffers)
- return 0;
-
if (req->count == 0 || q->num_buffers != 0 || q->memory !=
req->memory) {
/*
* We already have buffers allocated, so first check if they
Thanks
Vinay
Quoted 34 lines · On 03/13/2014 09:13 PM, [email protected] wrote:
Hi
There is a check in
__reqbufsinvideobuf2-core.cin which if the count is same then the function returns immediately.__reqbufsalso callsqueue_setupcallback into driver which updates the plane counts and sizes of vb2 queue. The count and size can be affected/changed byS_FMTandG_FMTioctl calls. This causes an issue with following call flow:1. reqbufs.count = 8; ioctl(fd, VIDIOC_REQBUFS, &reqbufs);2.
ioctl(fd, VIDIOC_S_FMT, &format)--> update format with differen height/width etc which effect the sizeofimage
3. reqbufs.count = 8;
ioctl(fd, VIDIOC_REQBUFS, &reqbufs); to update thevb2_queuenum planes
and size of each plane. But this call never goes to the driver since the count is same.Shouldn't we query the driver for any change in plane count/size before deciding to return from reqbufs? Following is the code. This is just a temporary patch to point the issue.
drivers/media/v4l2-core/videobuf2-core.c +0
-2@@ -590,13 +590,6 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)return -EBUSY ; } -/* -* If the same number of buffers and memory access method is requested
drivers/media/v4l2-core/videobuf2-core.c
Quoted 5 lines
drivers/media/v4l2-core/videobuf2-core.c +0
-5-* then return immediately. -*/ -if (q->memory == req->memory && req->count == q->num_buffers) -return 0 ; -
What strange kernel version are you using? This obviously wrong code was part of the first videobuf2 appearance in kernel 2.6.39 and was fixed in 3.0. Furthermore, in 2.6.39 videobuf2-core.c was in the video directory, not v4l2-core, and the __reqbufs function didn't exist yet.
It seems someone made a Frankenstein version of videobuf2-core.c for whatever kernel you are using. A Qualcomm kernel perhaps?
Regards,
Hans
Quoted 13 lines
if (req->count == 0 || q->num_buffers != 0 || q->memory !=
req->memory) {
/*
* We already have buffers allocated, so first check if theyThanks
Vinay--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html