[{"id":3256,"web_url":"https://patchwork.libcamera.org/comment/3256/","msgid":"<20191215093526.GC4889@pendragon.ideasonboard.com>","date":"2019-12-15T09:35:26","subject":"Re: [libcamera-devel] [PATCH 28/30] libcamera: Remove dead code\n\tafter switch to FrameBuffer","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Wed, Nov 27, 2019 at 12:36:18AM +0100, Niklas Söderlund wrote:\n> Delete all dead code after switching to the FrameBuffer interface.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  include/libcamera/buffer.h               |  59 ------\n>  include/libcamera/stream.h               |  23 ---\n>  src/android/camera_device.cpp            |   1 -\n>  src/libcamera/buffer.cpp                 | 183 -----------------\n>  src/libcamera/include/v4l2_videodevice.h |   7 -\n>  src/libcamera/stream.cpp                 | 247 +----------------------\n>  src/libcamera/v4l2_videodevice.cpp       | 110 +---------\n>  7 files changed, 3 insertions(+), 627 deletions(-)\n> \n> diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\n> index acc876eec7d93873..6be26a6400e91546 100644\n> --- a/include/libcamera/buffer.h\n> +++ b/include/libcamera/buffer.h\n\nYou can also remove the inclusion of <array> and the forward declaration\nof class Stream at the beginning of this file.\n\nWith this fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> @@ -77,65 +77,6 @@ private:\n>  \tvoid *mem_;\n>  };\n>  \n> -class BufferMemory final\n> -{\n> -public:\n> -\tconst std::vector<Dmabuf> &planes() const { return planes_; }\n> -\tstd::vector<Dmabuf> &planes() { return planes_; }\n> -\n> -private:\n> -\tstd::vector<Dmabuf> 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:\n> -\tBuffer(unsigned int index = -1, const Buffer *metadata = nullptr);\n> -\tBuffer(const Buffer &) = delete;\n> -\tBuffer &operator=(const Buffer &) = delete;\n> -\n> -\tunsigned int index() const { return index_; }\n> -\tconst std::array<int, 3> &dmabufs() const { return dmabuf_; }\n> -\tBufferMemory *mem() { return mem_; }\n> -\n> -\tconst BufferInfo &info() const { return info_; };\n> -\n> -\tRequest *request() const { return request_; }\n> -\tStream *stream() const { return stream_; }\n> -\n> -private:\n> -\tfriend class Camera;\n> -\tfriend class Request;\n> -\tfriend class Stream;\n> -\tfriend class V4L2VideoDevice;\n> -\n> -\tvoid cancel();\n> -\n> -\tunsigned int index_;\n> -\tstd::array<int, 3> dmabuf_;\n> -\tBufferMemory *mem_;\n> -\n> -\tBufferInfo info_;\n> -\n> -\tRequest *request_;\n> -\tStream *stream_;\n> -};\n> -\n>  class FrameBuffer final\n>  {\n>  public:\n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 8e653408fd54cf74..a4a8b4d3105add4c 100644\n> --- a/include/libcamera/stream.h\n> +++ b/include/libcamera/stream.h\n> @@ -36,11 +36,6 @@ private:\n>  \tstd::map<PixelFormat, std::vector<SizeRange>> formats_;\n>  };\n>  \n> -enum MemoryType {\n> -\tInternalMemory,\n> -\tExternalMemory,\n> -};\n> -\n>  struct StreamConfiguration {\n>  \tStreamConfiguration();\n>  \tStreamConfiguration(const StreamFormats &formats);\n> @@ -48,7 +43,6 @@ struct StreamConfiguration {\n>  \tPixelFormat pixelFormat;\n>  \tSize size;\n>  \n> -\tMemoryType memoryType;\n>  \tunsigned int bufferCount;\n>  \n>  \tStream *stream() const { return stream_; }\n> @@ -76,13 +70,7 @@ 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; /* To allocate and release buffers. */\n> @@ -94,18 +82,7 @@ protected:\n>  \tvirtual int start() = 0;\n>  \tvirtual void stop() = 0;\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> -\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 */\n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 708cf95b0c3c25c2..a6da658bec277933 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -641,7 +641,6 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n>  \tStreamConfiguration *streamConfiguration = &config_->at(0);\n>  \tstreamConfiguration->size.width = camera3Stream->width;\n>  \tstreamConfiguration->size.height = camera3Stream->height;\n> -\tstreamConfiguration->memoryType = ExternalMemory;\n>  \n>  \t/*\n>  \t * \\todo We'll need to translate from Android defined pixel format codes\n> diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\n> index ab28e0d76b8c40f7..5abb8589ea58e9c0 100644\n> --- a/src/libcamera/buffer.cpp\n> +++ b/src/libcamera/buffer.cpp\n> @@ -268,189 +268,6 @@ int Dmabuf::munmap()\n>  \treturn ret;\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() const\n> - * \\brief Retrieve the planes within the buffer\n> - * \\return A const reference to a vector holding all Planes within the buffer\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> -/**\n> - * \\class Buffer\n> - * \\brief A buffer handle and dynamic metadata\n> - *\n> - * The Buffer class references a buffer memory and associates dynamic metadata\n> - * related to the frame contained in the buffer. It allows referencing buffer\n> - * memory through a single interface regardless of whether the memory is\n> - * allocated internally in libcamera or provided externally through dmabuf.\n> - *\n> - * Buffer instances are allocated dynamically for a stream through\n> - * Stream::createBuffer(), added to a request with Request::addBuffer() and\n> - * deleted automatically after the request complete handler returns.\n> - */\n> -\n> -/**\n> - * \\brief Construct a buffer not associated with any stream\n> - *\n> - * This method constructs an orphaned buffer not associated with any stream. It\n> - * is not meant to be called by applications, they should instead create buffers\n> - * for a stream with Stream::createBuffer().\n> - */\n> -Buffer::Buffer(unsigned int index, const Buffer *metadata)\n> -\t: index_(index), dmabuf_({ -1, -1, -1 }), request_(nullptr),\n> -\t  stream_(nullptr)\n> -{\n> -\tunsigned int sequence;\n> -\tuint64_t timestamp;\n> -\tunsigned int bytesused;\n> -\n> -\tif (metadata) {\n> -\t\tbytesused = metadata->info().planes()[0].bytesused;\n> -\t\tsequence = metadata->info().sequence();\n> -\t\ttimestamp = metadata->info().timestamp();\n> -\t} else {\n> -\t\tbytesused = 0;\n> -\t\tsequence = 0;\n> -\t\ttimestamp = 0;\n> -\t}\n> -\n> -\tinfo_.update(BufferInfo::BufferSuccess, sequence, timestamp,\n> -\t\t     { { bytesused } });\n> -}\n> -\n> -/**\n> - * \\fn Buffer::index()\n> - * \\brief Retrieve the Buffer index\n> - * \\return The buffer index\n> - */\n> -\n> -/**\n> - * \\fn Buffer::dmabufs()\n> - * \\brief Retrieve the dmabuf file descriptors for all buffer planes\n> - *\n> - * The dmabufs array contains one dmabuf file descriptor per plane. Unused\n> - * entries are set to -1.\n> - *\n> - * \\return The dmabuf file descriptors\n> - */\n> -\n> -/**\n> - * \\fn Buffer::mem()\n> - * \\brief Retrieve the BufferMemory this buffer is associated with\n> - *\n> - * The association between the buffer and a BufferMemory instance is valid from\n> - * the time the request containing this buffer is queued to a camera to the end\n> - * of that request's completion handler.\n> - *\n> - * \\return The BufferMemory this buffer is associated with\n> - */\n> -\n> -/**\n> - * \\fn Buffer::info()\n> - * \\brief Retrieve the buffer metadata information\n> - *\n> - * The buffer metadata information is update every time the buffer contained\n> - * are changed, for example when it is dequeued from hardware.\n> - *\n> - * \\return Metadata of the buffer\n> - */\n> -\n> -/**\n> - * \\fn Buffer::request()\n> - * \\brief Retrieve the request this buffer belongs to\n> - *\n> - * The intended callers of this method are buffer completion handlers that\n> - * need to associate a buffer to the request it belongs to.\n> - *\n> - * A Buffer is associated to a request by Request::prepare() and the\n> - * association is valid until the buffer completes. The returned request\n> - * pointer is valid only during that interval.\n> - *\n> - * \\return The Request the Buffer belongs to, or nullptr if the buffer is\n> - * either completed or not associated with a request\n> - */\n> -\n> -/**\n> - * \\fn Buffer::stream()\n> - * \\brief Retrieve the stream this buffer is associated with\n> - *\n> - * A Buffer is associated to the stream that created it with\n> - * Stream::createBuffer() and the association is valid until the buffer is\n> - * destroyed. Buffer instances that are created directly are not associated\n> - * with any stream.\n> - *\n> - * \\return The Stream the Buffer is associated with, or nullptr if the buffer\n> - * is not associated with a stream\n> - */\n> -\n> -/**\n> - * \\brief Mark a buffer as cancel by setting its status to BufferCancelled\n> - */\n> -void Buffer::cancel()\n> -{\n> -\tinfo_.update(BufferInfo::BufferCancelled, 0, 0, { {} });\n> -}\n> -\n>  /**\n>   * \\class FrameBuffer\n>   * \\brief A buffer handle and dynamic metadata\n> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> index ced3cb229c509ad2..1c299d988515298e 100644\n> --- a/src/libcamera/include/v4l2_videodevice.h\n> +++ b/src/libcamera/include/v4l2_videodevice.h\n> @@ -24,8 +24,6 @@\n>  \n>  namespace libcamera {\n>  \n> -class BufferMemory;\n> -class BufferPool;\n>  class EventNotifier;\n>  class MediaDevice;\n>  class MediaEntity;\n> @@ -161,8 +159,6 @@ public:\n>  \tint setFormat(V4L2DeviceFormat *format);\n>  \tImageFormats formats();\n>  \n> -\tint exportBuffers(BufferPool *pool);\n> -\tint importBuffers(BufferPool *pool);\n>  \tint allocateBuffers(unsigned int count, std::vector<FrameBuffer *> *buffers);\n>  \tint externalBuffers(unsigned int count);\n>  \tint releaseBuffers();\n> @@ -197,8 +193,6 @@ private:\n>  \tstd::vector<SizeRange> enumSizes(unsigned int pixelFormat);\n>  \n>  \tint requestBuffers(unsigned int count);\n> -\tint createPlane(BufferMemory *buffer, unsigned int index,\n> -\t\t\tunsigned int plane, unsigned int length);\n>  \tFrameBuffer *createBuffer(struct v4l2_buffer buf);\n>  \tint exportDmaBuffer(unsigned int index, unsigned int plane);\n>  \n> @@ -210,7 +204,6 @@ private:\n>  \tenum v4l2_buf_type bufferType_;\n>  \tenum v4l2_memory memoryType_;\n>  \n> -\tBufferPool *bufferPool_;\n>  \tV4L2BufferCache *cache_;\n>  \tstd::map<unsigned int, FrameBuffer *> queuedBuffers_;\n>  \n> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> index ba3f571b08cb0c41..c5a4cca658527ef8 100644\n> --- a/src/libcamera/stream.cpp\n> +++ b/src/libcamera/stream.cpp\n> @@ -266,17 +266,6 @@ SizeRange StreamFormats::range(PixelFormat pixelformat) const\n>  \treturn range;\n>  }\n>  \n> -/**\n> - * \\enum MemoryType\n> - * \\brief Define the memory type used by a Stream\n> - * \\var MemoryType::InternalMemory\n> - * The Stream uses memory allocated internally by the library and exported to\n> - * applications.\n> - * \\var MemoryType::ExternalMemory\n> - * The Stream uses memory allocated externally by application and imported in\n> - * the library.\n> - */\n> -\n>  /**\n>   * \\struct StreamConfiguration\n>   * \\brief Configuration parameters for a stream\n> @@ -290,7 +279,7 @@ SizeRange StreamFormats::range(PixelFormat pixelformat) const\n>   * handlers provied StreamFormats.\n>   */\n>  StreamConfiguration::StreamConfiguration()\n> -\t: pixelFormat(0), memoryType(InternalMemory), stream_(nullptr)\n> +\t: pixelFormat(0), stream_(nullptr)\n>  {\n>  }\n>  \n> @@ -298,8 +287,7 @@ StreamConfiguration::StreamConfiguration()\n>   * \\brief Construct a configuration with stream formats\n>   */\n>  StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n> -\t: pixelFormat(0), memoryType(InternalMemory), stream_(nullptr),\n> -\t  formats_(formats)\n> +\t: pixelFormat(0), stream_(nullptr), formats_(formats)\n>  {\n>  }\n>  \n> @@ -313,11 +301,6 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)\n>   * \\brief Stream pixel format\n>   */\n>  \n> -/**\n> - * \\var StreamConfiguration::memoryType\n> - * \\brief The memory type the stream shall use\n> - */\n> -\n>  /**\n>   * \\var StreamConfiguration::bufferCount\n>   * \\brief Requested number of buffers to allocate for the stream\n> @@ -420,106 +403,12 @@ 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>   * \\fn Stream::allocateBuffers()\n>   * \\brief Allocate buffers from the stream\n> @@ -575,133 +464,6 @@ std::unique_ptr<Buffer> Stream::createBuffer(const std::array<int, 3> &fds)\n>   * implemeted by all subclasses of 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(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> @@ -711,9 +473,4 @@ void Stream::destroyBuffers()\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> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index a29ed697468a7f59..787cf8c0477b808c 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -377,8 +377,7 @@ const std::string V4L2DeviceFormat::toString() const\n>   * \\param[in] deviceNode The file-system path to the video device node\n>   */\n>  V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)\n> -\t: V4L2Device(deviceNode), bufferPool_(nullptr), cache_(nullptr),\n> -\t  fdEvent_(nullptr)\n> +\t: V4L2Device(deviceNode), cache_(nullptr), fdEvent_(nullptr)\n>  {\n>  \t/*\n>  \t * We default to an MMAP based CAPTURE video device, however this will\n> @@ -937,112 +936,6 @@ int V4L2VideoDevice::requestBuffers(unsigned int count)\n>  \treturn 0;\n>  }\n>  \n> -/**\n> - * \\brief Request buffers to be allocated from the video device and stored in\n> - * the buffer pool provided.\n> - * \\param[out] pool BufferPool to populate with buffers\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int V4L2VideoDevice::exportBuffers(BufferPool *pool)\n> -{\n> -\tunsigned int i;\n> -\tint ret;\n> -\n> -\tmemoryType_ = V4L2_MEMORY_MMAP;\n> -\n> -\tret = requestBuffers(pool->count());\n> -\tif (ret)\n> -\t\treturn ret;\n> -\n> -\t/* Map the buffers. */\n> -\tfor (i = 0; i < pool->count(); ++i) {\n> -\t\tstruct v4l2_plane planes[VIDEO_MAX_PLANES] = {};\n> -\t\tstruct v4l2_buffer buf = {};\n> -\t\tBufferMemory &buffer = pool->buffers()[i];\n> -\n> -\t\tbuf.index = i;\n> -\t\tbuf.type = bufferType_;\n> -\t\tbuf.memory = memoryType_;\n> -\t\tbuf.length = VIDEO_MAX_PLANES;\n> -\t\tbuf.m.planes = planes;\n> -\n> -\t\tret = ioctl(VIDIOC_QUERYBUF, &buf);\n> -\t\tif (ret < 0) {\n> -\t\t\tLOG(V4L2, Error)\n> -\t\t\t\t<< \"Unable to query buffer \" << i << \": \"\n> -\t\t\t\t<< strerror(-ret);\n> -\t\t\tbreak;\n> -\t\t}\n> -\n> -\t\tif (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) {\n> -\t\t\tfor (unsigned int p = 0; p < buf.length; ++p) {\n> -\t\t\t\tret = createPlane(&buffer, i, p,\n> -\t\t\t\t\t\t  buf.m.planes[p].length);\n> -\t\t\t\tif (ret)\n> -\t\t\t\t\tbreak;\n> -\t\t\t}\n> -\t\t} else {\n> -\t\t\tret = createPlane(&buffer, i, 0, buf.length);\n> -\t\t}\n> -\n> -\t\tif (ret) {\n> -\t\t\tLOG(V4L2, Error) << \"Failed to create plane\";\n> -\t\t\tbreak;\n> -\t\t}\n> -\t}\n> -\n> -\tif (ret) {\n> -\t\trequestBuffers(0);\n> -\t\tpool->destroyBuffers();\n> -\t\treturn ret;\n> -\t}\n> -\n> -\tbufferPool_ = pool;\n> -\n> -\treturn 0;\n> -}\n> -\n> -int V4L2VideoDevice::createPlane(BufferMemory *buffer, unsigned int index,\n> -\t\t\t\t unsigned int planeIndex, unsigned int length)\n> -{\n> -\tint fd;\n> -\n> -\tLOG(V4L2, Debug)\n> -\t\t<< \"Buffer \" << index\n> -\t\t<< \" plane \" << planeIndex\n> -\t\t<< \": length=\" << length;\n> -\n> -\tfd = exportDmaBuffer(index, planeIndex);\n> -\tif (fd < 0)\n> -\t\treturn fd;\n> -\n> -\tbuffer->planes().emplace_back(fd, length);\n> -\t::close(fd);\n> -\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\brief Import the externally allocated \\a pool of buffers\n> - * \\param[in] pool BufferPool of buffers to import\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int V4L2VideoDevice::importBuffers(BufferPool *pool)\n> -{\n> -\tint ret;\n> -\n> -\tmemoryType_ = V4L2_MEMORY_DMABUF;\n> -\n> -\tret = requestBuffers(pool->count());\n> -\tif (ret)\n> -\t\treturn ret;\n> -\n> -\tLOG(V4L2, Debug) << \"provided pool of \" << pool->count() << \" buffers\";\n> -\tbufferPool_ = pool;\n> -\n> -\treturn 0;\n> -}\n> -\n>  /**\n>   * \\brief Operate using buffers allocated from local video device\n>   * \\param[in] count Number of buffers to allocate\n> @@ -1193,7 +1086,6 @@ int V4L2VideoDevice::releaseBuffers()\n>  {\n>  \tLOG(V4L2, Debug) << \"Releasing buffers\";\n>  \n> -\tbufferPool_ = nullptr;\n>  \tdelete cache_;\n>  \tcache_ = nullptr;\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DAC24601E4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 15 Dec 2019 10:35:35 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3B2582D1;\n\tSun, 15 Dec 2019 10:35:35 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1576402535;\n\tbh=cVmzFpMGTkPLCxVPdLu7XPbzixgyeVYfZS7x+et7Wec=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=R7Yz0IRUwx8Q9hQ16tE68THMBvkoyub1qUJBWMrGaI70KJqzcvj1QhbcKZb/uz22z\n\tG0us8DTX5fRJzaE1+cvsCFuDlf7y0r7ve+mODp0rL4jFZnoylDfDPuS9ixc8vDM7Eb\n\tRYtI1KCh4lXAUnCII2KdDGUWm+9hEpqsmLu4CnfQ=","Date":"Sun, 15 Dec 2019 11:35:26 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191215093526.GC4889@pendragon.ideasonboard.com>","References":"<20191126233620.1695316-1-niklas.soderlund@ragnatech.se>\n\t<20191126233620.1695316-29-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20191126233620.1695316-29-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 28/30] libcamera: Remove dead code\n\tafter switch to FrameBuffer","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":"Sun, 15 Dec 2019 09:35:36 -0000"}}]