Discuss DMABUF implementation #1
stephematician
started this conversation in
Ideas
Replies: 2 comments
-
A bare-bones attempt at the VIDIOC_EXPBUF looks like: static int vidioc_expbuf(struct file *file, void *fh,
struct v4l2_exportbuffer *exp_buf)
{
struct v4l2_loopback_device *dev;
struct v4l2_loopback_opener *opener;
struct v4l2l_buffer *b;
MARK();
dev = v4l2loopback_getdevice(file);
opener = fh_to_opener(fh);
/* insert check on exp_buf arguments */
b = &dev->buffers[exp_buf->index];
if (b->buffer.memory != V4L2_MEMORY_MMAP)
return -EINVAL;
if (b->buffer.flags & V4L2_BUF_FLAG_MAPPED) {
dprintk("cannot export mapped buffer[%d]\n",
exp_buf->index);
return -EINVAL;
}
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
exp_info.ops = 0; // &v4l2l_dmabuf_ops;
exp_info.size = dev->buffer_size;
exp_info.flags = O_RDWR; // FIXME: non-block, too?
exp_info.priv = b;
struct dma_buf *dma_buf = dma_buf_export(&exp_info);
if (IS_ERR(dma_buf))
return PTR_ERR(dma_buf);
int result = dma_buf_fd(dma_buf, exp_buf->flags);
if (result < 0)
return result;
exp_buf->fd = result;
return 0;
} The harder part is defining the |
Beta Was this translation helpful? Give feedback.
0 replies
-
There are some differences in how v4l2loopback handles |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
👋 Welcome!
We'll use this Discussion - and this discussion only - to collaborate on supporting DMABUF in v4l2loopback 💪. The feature was requested here umlaeute#501; an earlier effort seems to have gone stale, and involved a number of changes that made it difficult to merge.
The branch for work in progress is here: https://github.com/stephematician/v4l2loopback/tree/expbuf_experiment
The first step is to be able to export the (memory-mapped mode) buffers as DMA buffers via ioctl VIDIOC_EXPBUF.
The plan is to follow the pattern for DMA export outlined here. An example of how to follow this pattern is provided in the kernel as
udmabuf
.Once the first step is complete; we can refactor REQBUF and the other parts of v4l2loopback required to manage DMABUF.
Applications to consider:
probe_expbuf()
andmmap_init()
in v4l2-utils.c.gst_v4l2_allocator_alloc_dmabuf()
in gstv4l2allocator.c.Beta Was this translation helpful? Give feedback.
All reactions