Patch Detail
Show a patch.
GET /api/patches/2356/?format=api
{ "id": 2356, "url": "https://patchwork.libcamera.org/api/patches/2356/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2356/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20191126233620.1695316-9-niklas.soderlund@ragnatech.se>", "date": "2019-11-26T23:35:58", "name": "[libcamera-devel,08/30] libcamera: buffer: Switch from Plane to Dmabuf", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "cb85f4def680223af4723363a0d28c46cd504f7d", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2356/mbox/", "series": [ { "id": 579, "url": "https://patchwork.libcamera.org/api/series/579/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=579", "date": "2019-11-26T23:35:50", "name": "libcamera: Rework buffer API", "version": 1, "mbox": "https://patchwork.libcamera.org/series/579/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2356/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2356/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5128A61C62\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Nov 2019 00:39:31 +0100 (CET)", "from bismarck.berto.se (p54ac5865.dip0.t-ipconnect.de\n\t[84.172.88.101]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid fd52620a-10a5-11ea-a0b9-005056917f90;\n\tWed, 27 Nov 2019 00:39:29 +0100 (CET)" ], "X-Halon-ID": "fd52620a-10a5-11ea-a0b9-005056917f90", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 27 Nov 2019 00:35:58 +0100", "Message-Id": "<20191126233620.1695316-9-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.24.0", "In-Reply-To": "<20191126233620.1695316-1-niklas.soderlund@ragnatech.se>", "References": "<20191126233620.1695316-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 08/30] libcamera: buffer: Switch from\n\tPlane to Dmabuf", "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": "Tue, 26 Nov 2019 23:39:31 -0000" }, "content": "Dmabug and Plane serves similar functions in the two buffer interfaces\nBuffer and FrameBuffer and share many function signatures. Replace all\nusages of Plane with Dmabuf to prepare for dropping the Buffer\ninterface.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/buffer.h | 6 +++---\n src/cam/buffer_writer.cpp | 6 +++---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++--\n src/libcamera/stream.cpp | 3 +--\n src/libcamera/v4l2_videodevice.cpp | 14 ++++++--------\n src/qcam/main_window.cpp | 4 ++--\n test/camera/buffer_import.cpp | 2 +-\n 7 files changed, 18 insertions(+), 21 deletions(-)", "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex fe5195327b540f5c..2dd5bcf3b49c4ee8 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -101,11 +101,11 @@ private:\n class BufferMemory final\n {\n public:\n-\tconst std::vector<Plane> &planes() const { return planes_; }\n-\tstd::vector<Plane> &planes() { return planes_; }\n+\tconst std::vector<Dmabuf> &planes() const { return planes_; }\n+\tstd::vector<Dmabuf> &planes() { return planes_; }\n \n private:\n-\tstd::vector<Plane> planes_;\n+\tstd::vector<Dmabuf> planes_;\n };\n \n class BufferPool final\ndiff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp\nindex c33e99c5f8173db8..5967efca07254666 100644\n--- a/src/cam/buffer_writer.cpp\n+++ b/src/cam/buffer_writer.cpp\n@@ -43,9 +43,9 @@ int BufferWriter::write(Buffer *buffer, const std::string &streamName)\n \t\treturn -errno;\n \n \tBufferMemory *mem = buffer->mem();\n-\tfor (Plane &plane : mem->planes()) {\n-\t\tvoid *data = plane.mem();\n-\t\tunsigned int length = plane.length();\n+\tfor (Dmabuf &dmabuf : mem->planes()) {\n+\t\tvoid *data = dmabuf.mem();\n+\t\tunsigned int length = dmabuf.length();\n \n \t\tret = ::write(fd, data, length);\n \t\tif (ret < 0) {\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 00fa4d4f19cb4aa4..e8b6a278e97b0ba0 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -689,7 +689,7 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,\n \tfor (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) {\n \t\tstd::vector<FrameBuffer::Plane> planes;\n \t\tplanes.push_back({\n-\t\t\t.fd = paramPool_.buffers()[i].planes()[0].dmabuf(),\n+\t\t\t.fd = paramPool_.buffers()[i].planes()[0].fd(),\n \t\t\t.length = paramPool_.buffers()[i].planes()[0].length(),\n \t\t});\n \n@@ -701,7 +701,7 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,\n \tfor (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) {\n \t\tstd::vector<FrameBuffer::Plane> planes;\n \t\tplanes.push_back({\n-\t\t\t.fd = statPool_.buffers()[i].planes()[0].dmabuf(),\n+\t\t\t.fd = statPool_.buffers()[i].planes()[0].fd(),\n \t\t\t.length = statPool_.buffers()[i].planes()[0].length(),\n \t\t});\n \ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex 45f31ae1e2daeb53..e70a1e307ecaa5ba 100644\n--- a/src/libcamera/stream.cpp\n+++ b/src/libcamera/stream.cpp\n@@ -577,8 +577,7 @@ int Stream::mapBuffer(const Buffer *buffer)\n \t\tif (dmabufs[i] == -1)\n \t\t\tbreak;\n \n-\t\tmem->planes().emplace_back();\n-\t\tmem->planes().back().setDmabuf(dmabufs[i], 0);\n+\t\tmem->planes().emplace_back(dmabufs[i], 0);\n \t}\n \n \t/* Remove the buffer from the cache and return its index. */\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex dbb5c3982334e243..166b0abc1b101f88 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -921,9 +921,7 @@ int V4L2VideoDevice::createPlane(BufferMemory *buffer, unsigned int index,\n \t\treturn ret;\n \t}\n \n-\tbuffer->planes().emplace_back();\n-\tPlane &plane = buffer->planes().back();\n-\tplane.setDmabuf(expbuf.fd, length);\n+\tbuffer->planes().emplace_back(expbuf.fd, length);\n \t::close(expbuf.fd);\n \n \treturn 0;\n@@ -986,19 +984,19 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer)\n \n \tbool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type);\n \tBufferMemory *mem = &bufferPool_->buffers()[buf.index];\n-\tconst std::vector<Plane> &planes = mem->planes();\n+\tconst std::vector<Dmabuf> &dmabufs = mem->planes();\n \n \tif (buf.memory == V4L2_MEMORY_DMABUF) {\n \t\tif (multiPlanar) {\n-\t\t\tfor (unsigned int p = 0; p < planes.size(); ++p)\n-\t\t\t\tv4l2Planes[p].m.fd = planes[p].dmabuf();\n+\t\t\tfor (unsigned int p = 0; p < dmabufs.size(); ++p)\n+\t\t\t\tv4l2Planes[p].m.fd = dmabufs[p].fd();\n \t\t} else {\n-\t\t\tbuf.m.fd = planes[0].dmabuf();\n+\t\t\tbuf.m.fd = dmabufs[0].fd();\n \t\t}\n \t}\n \n \tif (multiPlanar) {\n-\t\tbuf.length = planes.size();\n+\t\tbuf.length = dmabufs.size();\n \t\tbuf.m.planes = v4l2Planes;\n \t}\n \ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 0c7ca61ac12ec41c..a828a176cbbf4854 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -300,8 +300,8 @@ int MainWindow::display(Buffer *buffer)\n \tif (mem->planes().size() != 1)\n \t\treturn -EINVAL;\n \n-\tPlane &plane = mem->planes().front();\n-\tunsigned char *raw = static_cast<unsigned char *>(plane.mem());\n+\tDmabuf &dmabuf = mem->planes().front();\n+\tunsigned char *raw = static_cast<unsigned char *>(dmabuf.mem());\n \tviewfinder_->display(raw, buffer->bytesused());\n \n \treturn 0;\ndiff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex 3efe02704c02f691..8b0d1c167bd2bbe8 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -178,7 +178,7 @@ private:\n \n \t\tuint64_t cookie = index;\n \t\tBufferMemory &mem = pool_.buffers()[index];\n-\t\tint dmabuf = mem.planes()[0].dmabuf();\n+\t\tint dmabuf = mem.planes()[0].fd();\n \n \t\trequestReady.emit(cookie, dmabuf);\n \n", "prefixes": [ "libcamera-devel", "08/30" ] }