buffer: add MAPPABLE data flag

Add a MAPPABLE data flag that hints that the fd in the data is mappable
with a simple mmap/munmap. Normally, DmaBuf is not mappable like that
unless explicitly indicated with this flag.

Set the MAPPABLE flag on the DmaBuf from v4l2 and libcamera fd.

When asked, mmap the buffer memory in all cases when the MAPPABLE
flag is set.

This solves the case where v4l2 has exported DmaBuf and is streaming to
node A and then node B links but doesn't get automatically mmaped
memory.

Fixes #3840
This commit is contained in:
Wim Taymans 2024-02-08 18:03:27 +01:00
parent 4715fa1775
commit 858d4e9e1c
6 changed files with 11 additions and 4 deletions

View file

@ -1652,7 +1652,7 @@ again:
d[0].type = SPA_DATA_DmaBuf;
else
d[0].type = SPA_DATA_MemFd;
d[0].flags = SPA_DATA_FLAG_READABLE;
d[0].flags = SPA_DATA_FLAG_READABLE | SPA_DATA_FLAG_MAPPABLE;
d[0].fd = expbuf.fd;
d[0].data = NULL;
SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);