Patch Detail
Show a patch.
GET /api/1.1/patches/2272/?format=api
{ "id": 2272, "url": "https://patchwork.libcamera.org/api/1.1/patches/2272/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2272/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20191028022525.796995-13-niklas.soderlund@ragnatech.se>", "date": "2019-10-28T02:25:25", "name": "[libcamera-devel,RFC,12/12] libcamera: buffer: Clean up after buffer API switch", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ec6bb33fbe8fc46c8e74ec016302faca6b7e4c5a", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2272/mbox/", "series": [ { "id": 561, "url": "https://patchwork.libcamera.org/api/1.1/series/561/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=561", "date": "2019-10-28T02:25:13", "name": "libcamera: Rework buffer API", "version": 1, "mbox": "https://patchwork.libcamera.org/series/561/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2272/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2272/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BF286017F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 03:26:04 +0100 (CET)", "from localhost.localdomain (unknown [93.2.121.143])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 4732cd8d-f92a-11e9-903a-005056917f90;\n\tMon, 28 Oct 2019 03:26:00 +0100 (CET)" ], "X-Halon-ID": "4732cd8d-f92a-11e9-903a-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": "Mon, 28 Oct 2019 03:25:25 +0100", "Message-Id": "<20191028022525.796995-13-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20191028022525.796995-1-niklas.soderlund@ragnatech.se>", "References": "<20191028022525.796995-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 12/12] libcamera: buffer: Clean up after\n\tbuffer API switch", "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": "Mon, 28 Oct 2019 02:26:04 -0000" }, "content": "Remove dead code after the switch to the new buffer API.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/buffer.h | 24 ----\n include/libcamera/stream.h | 22 +---\n src/libcamera/buffer.cpp | 61 ----------\n src/libcamera/stream.cpp | 241 -------------------------------------\n 4 files changed, 2 insertions(+), 346 deletions(-)", "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex 3568c2e0cdf8d95b..c9887fc6a9aeeb9f 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -39,30 +39,6 @@ private:\n \tvoid *mem_;\n };\n \n-class BufferMemory final\n-{\n-public:\n-\tstd::vector<Plane> &planes() { return planes_; }\n-\n-private:\n-\tstd::vector<Plane> planes_;\n-};\n-\n-class BufferPool final\n-{\n-public:\n-\t~BufferPool();\n-\n-\tvoid createBuffers(unsigned int count);\n-\tvoid destroyBuffers();\n-\n-\tunsigned int count() const { return buffers_.size(); }\n-\tstd::vector<BufferMemory> &buffers() { return buffers_; }\n-\n-private:\n-\tstd::vector<BufferMemory> buffers_;\n-};\n-\n class Buffer final\n {\n public:\ndiff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\nindex b051341511a7ab7c..5ba1306176fcaeb0 100644\n--- a/include/libcamera/stream.h\n+++ b/include/libcamera/stream.h\n@@ -48,7 +48,6 @@ struct StreamConfiguration {\n \tSize size;\n \n \tMemoryType memoryType;\n-\tunsigned int bufferCount;\n \n \tStream *stream() const { return stream_; }\n \tvoid setStream(Stream *stream) { stream_ = stream; }\n@@ -75,33 +74,16 @@ public:\n \tStream();\n \tvirtual ~Stream(){};\n \n-\tstd::unique_ptr<Buffer> createBuffer(unsigned int index);\n-\tstd::unique_ptr<Buffer> createBuffer(const std::array<int, 3> &fds);\n-\n-\tBufferPool &bufferPool() { return bufferPool_; }\n-\tstd::vector<BufferMemory> &buffers() { return bufferPool_.buffers(); }\n \tconst StreamConfiguration &configuration() const { return configuration_; }\n-\tMemoryType memoryType() const { return memoryType_; }\n \n protected:\n \tfriend class BufferAllocator;\n \tfriend class Camera;\n \n-\tvirtual int allocateBuffers(std::vector<Buffer *> *buffers) { return -EINVAL; }\n-\tvirtual int importBuffers(bool enable) { return -EINVAL; }\n-\n-\tint mapBuffer(const Buffer *buffer);\n-\tvoid unmapBuffer(const Buffer *buffer);\n-\n-\tvoid createBuffers(MemoryType memory, unsigned int count);\n-\tvoid destroyBuffers();\n+\tvirtual int allocateBuffers(std::vector<Buffer *> *buffers) = 0;\n+\tvirtual int importBuffers(bool enable) = 0;\n \n-\tBufferPool bufferPool_;\n \tStreamConfiguration configuration_;\n-\tMemoryType memoryType_;\n-\n-private:\n-\tstd::vector<std::pair<std::array<int, 3>, unsigned int>> bufferCache_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex d00849520bc2b51c..0d14e1d19d7abce5 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -143,67 +143,6 @@ void *Plane::mem()\n * \\return The length of the memory region\n */\n \n-/**\n- * \\class BufferMemory\n- * \\brief A memory buffer to store an image\n- *\n- * The BufferMemory class represents the memory buffers used to store full frame\n- * images, which may contain multiple separate memory Plane objects if the\n- * image format is multi-planar.\n- */\n-\n-/**\n- * \\fn BufferMemory::planes()\n- * \\brief Retrieve the planes within the buffer\n- * \\return A reference to a vector holding all Planes within the buffer\n- */\n-\n-/**\n- * \\class BufferPool\n- * \\brief A pool of buffers\n- *\n- * The BufferPool class groups together a collection of Buffers to store frames.\n- * The buffers must be exported by a device before they can be imported into\n- * another device for further use.\n- */\n-\n-BufferPool::~BufferPool()\n-{\n-\tdestroyBuffers();\n-}\n-\n-/**\n- * \\brief Create buffers in the Pool\n- * \\param[in] count The number of buffers to create\n- */\n-void BufferPool::createBuffers(unsigned int count)\n-{\n-\tbuffers_.resize(count);\n-}\n-\n-/**\n- * \\brief Release all buffers from pool\n- *\n- * If no buffers have been created or if buffers have already been released no\n- * operation is performed.\n- */\n-void BufferPool::destroyBuffers()\n-{\n-\tbuffers_.resize(0);\n-}\n-\n-/**\n- * \\fn BufferPool::count()\n- * \\brief Retrieve the number of buffers contained within the pool\n- * \\return The number of buffers contained in the pool\n- */\n-\n-/**\n- * \\fn BufferPool::buffers()\n- * \\brief Retrieve all the buffers in the pool\n- * \\return A vector containing all the buffers in the pool.\n- */\n-\n Buffer::Buffer(std::vector<std::pair<int, unsigned int>> planes)\n {\n \tfor (std::pair<int, unsigned int> plane : planes)\ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex b8e7209c10477f16..66d124beada0af0b 100644\n--- a/src/libcamera/stream.cpp\n+++ b/src/libcamera/stream.cpp\n@@ -423,246 +423,5 @@ Stream::Stream()\n {\n }\n \n-/**\n- * \\brief Create a Buffer instance referencing the memory buffer \\a index\n- * \\param[in] index The desired buffer index\n- *\n- * This method creates a Buffer instance that references a BufferMemory from\n- * the stream's buffers pool by its \\a index. The index shall be lower than the\n- * number of buffers in the pool.\n- *\n- * This method is only valid for streams that use the InternalMemory type. It\n- * will return a null pointer when called on streams using the ExternalMemory\n- * type.\n- *\n- * \\return A newly created Buffer on success or nullptr otherwise\n- */\n-std::unique_ptr<Buffer> Stream::createBuffer(unsigned int index)\n-{\n-\tif (memoryType_ != InternalMemory) {\n-\t\tLOG(Stream, Error) << \"Invalid stream memory type\";\n-\t\treturn nullptr;\n-\t}\n-\n-\tif (index >= bufferPool_.count()) {\n-\t\tLOG(Stream, Error) << \"Invalid buffer index \" << index;\n-\t\treturn nullptr;\n-\t}\n-\n-\tBuffer *buffer = new Buffer();\n-\tbuffer->index_ = index;\n-\tbuffer->stream_ = this;\n-\n-\treturn std::unique_ptr<Buffer>(buffer);\n-}\n-\n-/**\n- * \\brief Create a Buffer instance that represents a memory area identified by\n- * dmabuf file descriptors\n- * \\param[in] fds The dmabuf file descriptors for each plane\n- *\n- * This method creates a Buffer instance that references buffer memory\n- * allocated outside of libcamera through dmabuf file descriptors. The \\a\n- * dmabuf array shall contain a file descriptor for each plane in the buffer,\n- * and unused entries shall be set to -1.\n- *\n- * The buffer is created without a valid index, as it does not yet map to any of\n- * the stream's BufferMemory instances. An index will be assigned at the time\n- * the buffer is queued to the camera in a request. Applications may thus\n- * create any number of Buffer instances, providing that no more than the\n- * number of buffers allocated for the stream are queued at any given time.\n- *\n- * This method is only valid for streams that use the ExternalMemory type. It\n- * will return a null pointer when called on streams using the InternalMemory\n- * type.\n- *\n- * \\sa Stream::mapBuffer()\n- *\n- * \\return A newly created Buffer on success or nullptr otherwise\n- */\n-std::unique_ptr<Buffer> Stream::createBuffer(const std::array<int, 3> &fds)\n-{\n-\tif (memoryType_ != ExternalMemory) {\n-\t\tLOG(Stream, Error) << \"Invalid stream memory type\";\n-\t\treturn nullptr;\n-\t}\n-\n-\tBuffer *buffer = new Buffer();\n-\tbuffer->dmabuf_ = fds;\n-\tbuffer->stream_ = this;\n-\n-\treturn std::unique_ptr<Buffer>(buffer);\n-}\n-\n-/**\n- * \\fn Stream::bufferPool()\n- * \\brief Retrieve the buffer pool for the stream\n- *\n- * The buffer pool handles the memory buffers used to store frames for the\n- * stream. It is initially created empty and shall be populated with\n- * buffers before being used.\n- *\n- * \\return A reference to the buffer pool\n- */\n-\n-/**\n- * \\fn Stream::buffers()\n- * \\brief Retrieve the memory buffers in the Stream's buffer pool\n- * \\return The list of stream's memory buffers\n- */\n-\n-/**\n- * \\fn Stream::configuration()\n- * \\brief Retrieve the active configuration of the stream\n- * \\return The active configuration of the stream\n- */\n-\n-/**\n- * \\fn Stream::memoryType()\n- * \\brief Retrieve the stream memory type\n- * \\return The memory type used by the stream\n- */\n-\n-/**\n- * \\brief Map a Buffer to a buffer memory index\n- * \\param[in] buffer The buffer to map to a buffer memory index\n- *\n- * Streams configured to use externally allocated memory need to maintain a\n- * best-effort association between the memory area the \\a buffer represents\n- * and the associated buffer memory in the Stream's pool.\n- *\n- * The buffer memory to use, once the \\a buffer reaches the video device,\n- * is selected using the index assigned to the \\a buffer and to minimize\n- * relocations in the V4L2 back-end, this operation provides a best-effort\n- * caching mechanism that associates to the dmabuf file descriptors contained\n- * in the \\a buffer the index of the buffer memory that was lastly queued with\n- * those file descriptors set.\n- *\n- * If the Stream uses internally allocated memory, the index of the memory\n- * buffer to use will match the one request at Stream::createBuffer(unsigned int)\n- * time, and no mapping is thus required.\n- *\n- * \\return The buffer memory index for the buffer on success, or a negative\n- * error code otherwise\n- * \\retval -ENOMEM No buffer memory was available to map the buffer\n- */\n-int Stream::mapBuffer(const Buffer *buffer)\n-{\n-\tASSERT(memoryType_ == ExternalMemory);\n-\n-\tif (bufferCache_.empty())\n-\t\treturn -ENOMEM;\n-\n-\tconst std::array<int, 3> &dmabufs = buffer->dmabufs();\n-\n-\t/*\n-\t * Try to find a previously mapped buffer in the cache. If we miss, use\n-\t * the oldest entry in the cache.\n-\t */\n-\tauto map = std::find_if(bufferCache_.begin(), bufferCache_.end(),\n-\t\t\t\t[&](std::pair<std::array<int, 3>, unsigned int> &entry) {\n-\t\t\t\t\treturn entry.first == dmabufs;\n-\t\t\t\t});\n-\tif (map == bufferCache_.end())\n-\t\tmap = bufferCache_.begin();\n-\n-\t/*\n-\t * Update the dmabuf file descriptors of the entry. We can't assume that\n-\t * identical file descriptor numbers refer to the same dmabuf object as\n-\t * it may have been closed and its file descriptor reused. We thus need\n-\t * to update the plane's internally cached mmap()ed memory.\n-\t */\n-\tunsigned int index = map->second;\n-\tBufferMemory *mem = &bufferPool_.buffers()[index];\n-\tmem->planes().clear();\n-\n-\tfor (unsigned int i = 0; i < dmabufs.size(); ++i) {\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}\n-\n-\t/* Remove the buffer from the cache and return its index. */\n-\tbufferCache_.erase(map);\n-\treturn index;\n-}\n-\n-/**\n- * \\brief Unmap a Buffer from its buffer memory\n- * \\param[in] buffer The buffer to unmap\n- *\n- * This method releases the buffer memory entry that was mapped by mapBuffer(),\n- * making it available for new mappings.\n- */\n-void Stream::unmapBuffer(const Buffer *buffer)\n-{\n-\tASSERT(memoryType_ == ExternalMemory);\n-\n-\tbufferCache_.emplace_back(buffer->dmabufs(), buffer->index());\n-}\n-\n-/**\n- * \\brief Create buffers for the stream\n- * \\param[in] count The number of buffers to create\n- * \\param[in] memory The stream memory type\n- *\n- * Create \\a count empty buffers in the Stream's buffer pool.\n- */\n-void Stream::createBuffers(MemoryType memory, unsigned int count)\n-{\n-\tdestroyBuffers();\n-\tif (count == 0)\n-\t\treturn;\n-\n-\tmemoryType_ = memory;\n-\tbufferPool_.createBuffers(count);\n-\n-\t/* Streams with internal memory usage do not need buffer mapping. */\n-\tif (memoryType_ == InternalMemory)\n-\t\treturn;\n-\n-\t/*\n-\t * Prepare for buffer mapping by adding all buffer memory entries to the\n-\t * cache.\n-\t */\n-\tbufferCache_.clear();\n-\tfor (unsigned int i = 0; i < bufferPool_.count(); ++i)\n-\t\tbufferCache_.emplace_back(std::array<int, 3>{ -1, -1, -1 }, i);\n-}\n-\n-/**\n- * \\brief Destroy buffers in the stream\n- *\n- * If no buffers have been created or if buffers have already been destroyed no\n- * operation is performed.\n- */\n-void Stream::destroyBuffers()\n-{\n-\tbufferPool_.destroyBuffers();\n-}\n-\n-/**\n- * \\var Stream::bufferPool_\n- * \\brief The pool of buffers associated with the stream\n- *\n- * The stream buffer pool is populated by the Camera class after a successful\n- * stream configuration.\n- */\n-\n-/**\n- * \\var Stream::configuration_\n- * \\brief The stream configuration\n- *\n- * The configuration for the stream is set by any successful call to\n- * Camera::configure() that includes the stream, and remains valid until the\n- * next call to Camera::configure() regardless of if it includes the stream.\n- */\n-\n-/**\n- * \\var Stream::memoryType_\n- * \\brief The stream memory type\n- */\n \n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "RFC", "12/12" ] }