From 9bde70e868596cb1614bde97d01c05ba33b3e1e8 Mon Sep 17 00:00:00 2001 From: "xueman.ruan" Date: Thu, 20 Jul 2023 20:01:41 +0800 Subject: [PATCH] [camera_source]: fix camera reinit failed. Issue: https://github.com/rockchip-linux/mpp/issues/408 Signed-off-by: xueman.ruan Change-Id: Icc0b34ab28c618acdea38914300a3537c604a389 --- utils/camera_source.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/camera_source.c b/utils/camera_source.c index 65b9f349..0b717085 100644 --- a/utils/camera_source.c +++ b/utils/camera_source.c @@ -214,9 +214,6 @@ CamSource *camera_source_init(const char *device, RK_U32 bufcnt, RK_U32 width, R goto FAIL; } - ctx->fbuf[i].start = mmap(NULL, buf.length, - PROT_READ | PROT_WRITE, MAP_SHARED, - ctx->fd, buf.m.offset); if (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE == buf.type) { // tmp_buffers[n_buffers].length = buf.m.planes[0].length; buf_len = buf.m.planes[0].length; @@ -239,6 +236,9 @@ CamSource *camera_source_init(const char *device, RK_U32 bufcnt, RK_U32 width, R mpp_err_f("ERROR: Failed to map device frame buffers\n"); goto FAIL; } + + ctx->fbuf[i].length = buf_len; // record buffer length for unmap + struct v4l2_exportbuffer expbuf = (struct v4l2_exportbuffer) {0} ; // xcam_mem_clear (expbuf); expbuf.type = type; @@ -331,7 +331,7 @@ MPP_RET camera_source_deinit(CamSource *ctx) if (ctx->fbuf[buf.index].buffer) { mpp_buffer_put(ctx->fbuf[buf.index].buffer); } - munmap(ctx->fbuf[buf.index].start, buf.length); + munmap(ctx->fbuf[buf.index].start, ctx->fbuf[buf.index].length); close(ctx->fbuf[i].export_fd); }