Commit 241199ff authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

v4l2: map buffers before queueing them

Not sure if this is a driver bug or a limitation.
parent c3cba318
...@@ -587,8 +587,8 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n) ...@@ -587,8 +587,8 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
if (unlikely(bufv == NULL)) if (unlikely(bufv == NULL))
return NULL; return NULL;
uint32_t bufc; uint32_t bufc = 0;
for (bufc = 0; bufc < req.count; bufc++) while (bufc < req.count)
{ {
struct v4l2_buffer buf = { struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
...@@ -601,11 +601,6 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n) ...@@ -601,11 +601,6 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
msg_Err (obj, "cannot query buffer %"PRIu32": %m", bufc); msg_Err (obj, "cannot query buffer %"PRIu32": %m", bufc);
goto error; goto error;
} }
if (v4l2_ioctl (fd, VIDIOC_QBUF, &buf) < 0)
{
msg_Err (obj, "cannot queue buffer %"PRIu32": %m", bufc);
goto error;
}
bufv[bufc].start = v4l2_mmap (NULL, buf.length, PROT_READ | PROT_WRITE, bufv[bufc].start = v4l2_mmap (NULL, buf.length, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, buf.m.offset); MAP_SHARED, fd, buf.m.offset);
...@@ -615,6 +610,14 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n) ...@@ -615,6 +610,14 @@ struct buffer_t *StartMmap (vlc_object_t *obj, int fd, uint32_t *restrict n)
goto error; goto error;
} }
bufv[bufc].length = buf.length; bufv[bufc].length = buf.length;
bufc++;
/* Some drivers refuse to queue buffers before they are mapped. Bug? */
if (v4l2_ioctl (fd, VIDIOC_QBUF, &buf) < 0)
{
msg_Err (obj, "cannot queue buffer %"PRIu32": %m", bufc);
goto error;
}
} }
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment