{"id":3096,"url":"https://patchwork.libcamera.org/api/1.1/patches/3096/?format=json","web_url":"https://patchwork.libcamera.org/patch/3096/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200314235728.15495-4-laurent.pinchart@ideasonboard.com>","date":"2020-03-14T23:57:22","name":"[libcamera-devel,3/9] libcamera: v4l2_videodevice: Pass memory type to reqbufs()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b2b53df73072166816f1854cbe72348e1d00ef25","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3096/mbox/","series":[{"id":719,"url":"https://patchwork.libcamera.org/api/1.1/series/719/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=719","date":"2020-03-14T23:57:19","name":"Simplify buffer management with V4L2 buffer orphaning","version":1,"mbox":"https://patchwork.libcamera.org/series/719/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3096/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3096/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C8CD628BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 15 Mar 2020 00:57:41 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EF7351163\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 15 Mar 2020 00:57:40 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584230261;\n\tbh=e6xscaDEWFpZBhVwPrGz6mQnBSH4JfkxTy8WU1akbNA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=mCoW6YFT8CtZ2VkZ5eEj0ai6iCE6g/kjjhds/53uI9J4wa40jC8ogFA5Cu582MPTW\n\tnJNaqnJidY5Drw6uzUnDmvV5NucMoUd/RNHhCYS92IDL1H+IbkS8u91UXcAkgzVgJ1\n\t2c0tVOrCnTy6A9PWQ0L8Alj6PqxDSk428h+X9ou4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 15 Mar 2020 01:57:22 +0200","Message-Id":"<20200314235728.15495-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200314235728.15495-1-laurent.pinchart@ideasonboard.com>","References":"<20200314235728.15495-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/9] libcamera: v4l2_videodevice: Pass\n\tmemory type to reqbufs()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 14 Mar 2020 23:57:41 -0000"},"content":"To prepare for the rework of buffer export, pass the memory type\nexplicitly to the V4L2VideoDevice::reqbufs() function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_videodevice.h |  2 +-\n src/libcamera/v4l2_videodevice.cpp       | 15 ++++++++-------\n 2 files changed, 9 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex 893d28c7db88..26f5e5917716 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -227,7 +227,7 @@ private:\n \n \tint setSelection(unsigned int target, Rectangle *rect);\n \n-\tint requestBuffers(unsigned int count);\n+\tint requestBuffers(unsigned int count, enum v4l2_memory memoryType);\n \tstd::unique_ptr<FrameBuffer> createBuffer(const struct v4l2_buffer &buf);\n \tFileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);\n \ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex aea7a4ea3a23..6911ab024fd7 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1013,14 +1013,15 @@ int V4L2VideoDevice::setSelection(unsigned int target, Rectangle *rect)\n \treturn 0;\n }\n \n-int V4L2VideoDevice::requestBuffers(unsigned int count)\n+int V4L2VideoDevice::requestBuffers(unsigned int count,\n+\t\t\t\t    enum v4l2_memory memoryType)\n {\n \tstruct v4l2_requestbuffers rb = {};\n \tint ret;\n \n \trb.count = count;\n \trb.type = bufferType_;\n-\trb.memory = memoryType_;\n+\trb.memory = memoryType;\n \n \tret = ioctl(VIDIOC_REQBUFS, &rb);\n \tif (ret < 0) {\n@@ -1033,7 +1034,7 @@ int V4L2VideoDevice::requestBuffers(unsigned int count)\n \tif (rb.count < count) {\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Not enough buffers provided by V4L2VideoDevice\";\n-\t\trequestBuffers(0);\n+\t\trequestBuffers(0, memoryType);\n \t\treturn -ENOMEM;\n \t}\n \n@@ -1059,7 +1060,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,\n \n \tmemoryType_ = V4L2_MEMORY_MMAP;\n \n-\tint ret = requestBuffers(count);\n+\tint ret = requestBuffers(count, V4L2_MEMORY_MMAP);\n \tif (ret < 0)\n \t\treturn ret;\n \n@@ -1096,7 +1097,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,\n \treturn count;\n \n err_buf:\n-\trequestBuffers(0);\n+\trequestBuffers(0, V4L2_MEMORY_MMAP);\n \n \tbuffers->clear();\n \n@@ -1166,7 +1167,7 @@ int V4L2VideoDevice::importBuffers(unsigned int count)\n \n \tmemoryType_ = V4L2_MEMORY_DMABUF;\n \n-\tint ret = requestBuffers(count);\n+\tint ret = requestBuffers(count, V4L2_MEMORY_DMABUF);\n \tif (ret)\n \t\treturn ret;\n \n@@ -1187,7 +1188,7 @@ int V4L2VideoDevice::releaseBuffers()\n \tdelete cache_;\n \tcache_ = nullptr;\n \n-\treturn requestBuffers(0);\n+\treturn requestBuffers(0, memoryType_);\n }\n \n /**\n","prefixes":["libcamera-devel","3/9"]}