summaryrefslogtreecommitdiff
path: root/v4l2-mfc-example/mfc.c
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-mfc-example/mfc.c')
-rw-r--r--v4l2-mfc-example/mfc.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/v4l2-mfc-example/mfc.c b/v4l2-mfc-example/mfc.c
index 89aa22d..1f279a1 100644
--- a/v4l2-mfc-example/mfc.c
+++ b/v4l2-mfc-example/mfc.c
@@ -248,6 +248,7 @@ int mfc_dec_setup_capture(struct instance *i, int extra_buf)
struct v4l2_plane planes[MFC_CAP_PLANES];
struct v4l2_control ctrl;
struct v4l2_crop crop;
+ struct v4l2_exportbuffer expbuf;
int ret;
int n;
@@ -325,20 +326,44 @@ int mfc_dec_setup_capture(struct instance *i, int extra_buf)
return -1;
}
- i->mfc.cap_buf_off[n][0] = buf.m.planes[0].m.mem_offset;
- i->mfc.cap_buf_off[n][1] = buf.m.planes[1].m.mem_offset;
-
- i->mfc.cap_buf_addr[n][0] = mmap(NULL, buf.m.planes[0].length,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- i->mfc.fd, buf.m.planes[0].m.mem_offset);
- i->mfc.cap_buf_addr[n][1] = mmap(NULL, buf.m.planes[1].length,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- i->mfc.fd, buf.m.planes[1].m.mem_offset);
-
- if (i->mfc.cap_buf_addr[n][0] == MAP_FAILED ||
- i->mfc.cap_buf_addr[n][1] == MAP_FAILED) {
- err("Failed to MMAP MFC CAPTURE buffer");
- return -1;
+ if (i->fimc.dmabuf) {
+ memset(&expbuf, 0, sizeof(expbuf));
+ expbuf.index = n;
+ expbuf.plane = 0;
+ expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ ret = ioctl(i->mfc.fd, VIDIOC_EXPBUF, &expbuf);
+ if (ret != 0) {
+ err("Failed to export buffer\n");
+ return -1;
+ }
+ i->mfc.dbuf[n][0] = expbuf.fd;
+
+ memset(&expbuf, 0, sizeof(expbuf));
+ expbuf.index = n;
+ expbuf.plane = 1;
+ expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ ret = ioctl(i->mfc.fd, VIDIOC_EXPBUF, &expbuf);
+ if (ret != 0) {
+ err("Failed to export buffer\n");
+ return -1;
+ }
+ i->mfc.dbuf[n][1] = expbuf.fd;
+ } else {
+ i->mfc.cap_buf_off[n][0] = buf.m.planes[0].m.mem_offset;
+ i->mfc.cap_buf_off[n][1] = buf.m.planes[1].m.mem_offset;
+
+ i->mfc.cap_buf_addr[n][0] = mmap(NULL, buf.m.planes[0].length,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ i->mfc.fd, buf.m.planes[0].m.mem_offset);
+ i->mfc.cap_buf_addr[n][1] = mmap(NULL, buf.m.planes[1].length,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ i->mfc.fd, buf.m.planes[1].m.mem_offset);
+
+ if (i->mfc.cap_buf_addr[n][0] == MAP_FAILED ||
+ i->mfc.cap_buf_addr[n][1] == MAP_FAILED) {
+ err("Failed to MMAP MFC CAPTURE buffer");
+ return -1;
+ }
}
}