[{"id":3340,"web_url":"https://patchwork.libcamera.org/comment/3340/","msgid":"<20200107105520.okchy4m6wtrdmznr@uno.localdomain>","date":"2020-01-07T10:55:20","subject":"Re: [libcamera-devel] [PATCH v2 05/25] libcamera: buffers: Remove\n\tPlane class","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Mon, Dec 30, 2019 at 01:04:50PM +0100, Niklas Söderlund wrote:\n> There are no users left of the Plane class, drop it.\n>\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/buffer.h |  21 ------\n>  src/libcamera/buffer.cpp   | 149 -------------------------------------\n\nThe patch changelog I like most\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n>  2 files changed, 170 deletions(-)\n>\n> diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\n> index 71633492e4752efb..2d8885e9f3a1234f 100644\n> --- a/include/libcamera/buffer.h\n> +++ b/include/libcamera/buffer.h\n> @@ -65,27 +65,6 @@ private:\n>  \tunsigned int cookie_;\n>  };\n>\n> -class Plane final\n> -{\n> -public:\n> -\tPlane();\n> -\t~Plane();\n> -\n> -\tint dmabuf() const { return fd_; }\n> -\tint setDmabuf(int fd, unsigned int length);\n> -\n> -\tvoid *mem();\n> -\tunsigned int length() const { return length_; }\n> -\n> -private:\n> -\tint mmap();\n> -\tint munmap();\n> -\n> -\tint fd_;\n> -\tunsigned int length_;\n> -\tvoid *mem_;\n> -};\n> -\n>  class BufferMemory final\n>  {\n>  public:\n> diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\n> index fde0b33511c64c9e..3ea982306843b116 100644\n> --- a/src/libcamera/buffer.cpp\n> +++ b/src/libcamera/buffer.cpp\n> @@ -85,155 +85,6 @@ LOG_DEFINE_CATEGORY(Buffer)\n>   * \\brief Array holding plane specific metadata\n>   */\n>\n> -/**\n> - * \\class Plane\n> - * \\brief A memory region to store a single plane of a frame\n> - *\n> - * Planar pixel formats use multiple memory regions to store planes\n> - * corresponding to the different colour components of a frame. The Plane class\n> - * tracks the specific details of a memory region used to store a single plane\n> - * for a given frame and provides the means to access the memory, both for the\n> - * application and for DMA. A Buffer then contains one or multiple planes\n> - * depending on its pixel format.\n> - *\n> - * To support DMA access, planes are associated with dmabuf objects represented\n> - * by file handles. Each plane carries a dmabuf file handle and an offset within\n> - * the buffer. Those file handles may refer to the same dmabuf object, depending\n> - * on whether the devices accessing the memory regions composing the image\n> - * support non-contiguous DMA to planes ore require DMA-contiguous memory.\n> - *\n> - * To support CPU access, planes carry the CPU address of their backing memory.\n> - * Similarly to the dmabuf file handles, the CPU addresses for planes composing\n> - * an image may or may not be contiguous.\n> - */\n> -\n> -Plane::Plane()\n> -\t: fd_(-1), length_(0), mem_(0)\n> -{\n> -}\n> -\n> -Plane::~Plane()\n> -{\n> -\tmunmap();\n> -\n> -\tif (fd_ != -1)\n> -\t\tclose(fd_);\n> -}\n> -\n> -/**\n> - * \\fn Plane::dmabuf()\n> - * \\brief Get the dmabuf file handle backing the buffer\n> - */\n> -\n> -/**\n> - * \\brief Set the dmabuf file handle backing the buffer\n> - * \\param[in] fd The dmabuf file handle\n> - * \\param[in] length The size of the memory region\n> - *\n> - * The \\a fd dmabuf file handle is duplicated and stored. The caller may close\n> - * the original file handle.\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int Plane::setDmabuf(int fd, unsigned int length)\n> -{\n> -\tif (fd < 0) {\n> -\t\tLOG(Buffer, Error) << \"Invalid dmabuf fd provided\";\n> -\t\treturn -EINVAL;\n> -\t}\n> -\n> -\tif (fd_ != -1) {\n> -\t\tclose(fd_);\n> -\t\tfd_ = -1;\n> -\t}\n> -\n> -\tfd_ = dup(fd);\n> -\tif (fd_ == -1) {\n> -\t\tint ret = -errno;\n> -\t\tLOG(Buffer, Error)\n> -\t\t\t<< \"Failed to duplicate dmabuf: \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\tlength_ = length;\n> -\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\brief Map the plane memory data to a CPU accessible address\n> - *\n> - * The file descriptor to map the memory from must be set by a call to\n> - * setDmaBuf() before calling this function.\n> - *\n> - * \\sa setDmaBuf()\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int Plane::mmap()\n> -{\n> -\tvoid *map;\n> -\n> -\tif (mem_)\n> -\t\treturn 0;\n> -\n> -\tmap = ::mmap(NULL, length_, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0);\n> -\tif (map == MAP_FAILED) {\n> -\t\tint ret = -errno;\n> -\t\tLOG(Buffer, Error)\n> -\t\t\t<< \"Failed to mmap plane: \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\tmem_ = map;\n> -\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\brief Unmap any existing CPU accessible mapping\n> - *\n> - * Unmap the memory mapped by an earlier call to mmap().\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int Plane::munmap()\n> -{\n> -\tint ret = 0;\n> -\n> -\tif (mem_)\n> -\t\tret = ::munmap(mem_, length_);\n> -\n> -\tif (ret) {\n> -\t\tret = -errno;\n> -\t\tLOG(Buffer, Warning)\n> -\t\t\t<< \"Failed to unmap plane: \" << strerror(-ret);\n> -\t} else {\n> -\t\tmem_ = 0;\n> -\t}\n> -\n> -\treturn ret;\n> -}\n> -\n> -/**\n> - * \\fn Plane::mem()\n> - * \\brief Retrieve the CPU accessible memory address of the Plane\n> - * \\return The CPU accessible memory address on success or nullptr otherwise.\n> - */\n> -void *Plane::mem()\n> -{\n> -\tif (!mem_)\n> -\t\tmmap();\n> -\n> -\treturn mem_;\n> -}\n> -\n> -/**\n> - * \\fn Plane::length() const\n> - * \\brief Retrieve the length of the memory region\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> 2.24.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D16B60460\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jan 2020 11:52:56 +0100 (CET)","from uno.localdomain (93-34-114-233.ip49.fastwebnet.it\n\t[93.34.114.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 9B701240013;\n\tTue,  7 Jan 2020 10:52:55 +0000 (UTC)"],"X-Originating-IP":"93.34.114.233","Date":"Tue, 7 Jan 2020 11:55:20 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200107105520.okchy4m6wtrdmznr@uno.localdomain>","References":"<20191230120510.938333-1-niklas.soderlund@ragnatech.se>\n\t<20191230120510.938333-6-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"3vdx2sofzxbblc3f\"","Content-Disposition":"inline","In-Reply-To":"<20191230120510.938333-6-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v2 05/25] libcamera: buffers: Remove\n\tPlane class","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, 07 Jan 2020 10:52:56 -0000"}},{"id":3343,"web_url":"https://patchwork.libcamera.org/comment/3343/","msgid":"<20200107155312.GB4871@pendragon.ideasonboard.com>","date":"2020-01-07T15:53:12","subject":"Re: [libcamera-devel] [PATCH v2 05/25] libcamera: buffers: Remove\n\tPlane class","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 Mon, Dec 30, 2019 at 01:04:50PM +0100, Niklas Söderlund wrote:\n> There are no users left of the Plane class, drop it.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/buffer.h |  21 ------\n>  src/libcamera/buffer.cpp   | 149 -------------------------------------\n>  2 files changed, 170 deletions(-)\n> \n> diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\n> index 71633492e4752efb..2d8885e9f3a1234f 100644\n> --- a/include/libcamera/buffer.h\n> +++ b/include/libcamera/buffer.h\n> @@ -65,27 +65,6 @@ private:\n>  \tunsigned int cookie_;\n>  };\n>  \n> -class Plane final\n> -{\n> -public:\n> -\tPlane();\n> -\t~Plane();\n> -\n> -\tint dmabuf() const { return fd_; }\n> -\tint setDmabuf(int fd, unsigned int length);\n> -\n> -\tvoid *mem();\n> -\tunsigned int length() const { return length_; }\n> -\n> -private:\n> -\tint mmap();\n> -\tint munmap();\n> -\n> -\tint fd_;\n> -\tunsigned int length_;\n> -\tvoid *mem_;\n> -};\n> -\n>  class BufferMemory final\n>  {\n>  public:\n> diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\n> index fde0b33511c64c9e..3ea982306843b116 100644\n> --- a/src/libcamera/buffer.cpp\n> +++ b/src/libcamera/buffer.cpp\n> @@ -85,155 +85,6 @@ LOG_DEFINE_CATEGORY(Buffer)\n>   * \\brief Array holding plane specific metadata\n>   */\n>  \n> -/**\n> - * \\class Plane\n> - * \\brief A memory region to store a single plane of a frame\n> - *\n> - * Planar pixel formats use multiple memory regions to store planes\n> - * corresponding to the different colour components of a frame. The Plane class\n> - * tracks the specific details of a memory region used to store a single plane\n> - * for a given frame and provides the means to access the memory, both for the\n> - * application and for DMA. A Buffer then contains one or multiple planes\n> - * depending on its pixel format.\n> - *\n> - * To support DMA access, planes are associated with dmabuf objects represented\n> - * by file handles. Each plane carries a dmabuf file handle and an offset within\n> - * the buffer. Those file handles may refer to the same dmabuf object, depending\n> - * on whether the devices accessing the memory regions composing the image\n> - * support non-contiguous DMA to planes ore require DMA-contiguous memory.\n\nThis seems useful information that we should somehow keep in the new\nFrameBuffer::Plane class. I propose\n\n/**\n * \\struct FrameBuffer::Plane\n * \\brief A memory region to store a single plane of a frame\n *\n * Planar pixel formats use multiple memory regions to store the different\n * colour components of a frame. The Plane structure describes such a memory\n * region by a dmabuf file descriptor and a length. A FrameBuffer then\n * contains one or multiple planes, depending on the pixel format of the\n * frames it is meant to store.\n *\n * To support DMA access, planes are associated with dmabuf objects represented\n * by FileDescriptor handles. The Plane class doesn't handle mapping of the\n * memory to the CPU, but applications and IPAs may use the dmabuf file\n * descriptors to map the plane memory with mmap() and access its contents.\n *\n * \\todo Once we have a Kernel API which can express offsets within a plane\n * this structure shall be extended to contain this information. See commit\n * 83148ce8be55e for initial documentation of this feature.\n */\n\nFor this patch itself,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> - *\n> - * To support CPU access, planes carry the CPU address of their backing memory.\n> - * Similarly to the dmabuf file handles, the CPU addresses for planes composing\n> - * an image may or may not be contiguous.\n> - */\n> -\n> -Plane::Plane()\n> -\t: fd_(-1), length_(0), mem_(0)\n> -{\n> -}\n> -\n> -Plane::~Plane()\n> -{\n> -\tmunmap();\n> -\n> -\tif (fd_ != -1)\n> -\t\tclose(fd_);\n> -}\n> -\n> -/**\n> - * \\fn Plane::dmabuf()\n> - * \\brief Get the dmabuf file handle backing the buffer\n> - */\n> -\n> -/**\n> - * \\brief Set the dmabuf file handle backing the buffer\n> - * \\param[in] fd The dmabuf file handle\n> - * \\param[in] length The size of the memory region\n> - *\n> - * The \\a fd dmabuf file handle is duplicated and stored. The caller may close\n> - * the original file handle.\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int Plane::setDmabuf(int fd, unsigned int length)\n> -{\n> -\tif (fd < 0) {\n> -\t\tLOG(Buffer, Error) << \"Invalid dmabuf fd provided\";\n> -\t\treturn -EINVAL;\n> -\t}\n> -\n> -\tif (fd_ != -1) {\n> -\t\tclose(fd_);\n> -\t\tfd_ = -1;\n> -\t}\n> -\n> -\tfd_ = dup(fd);\n> -\tif (fd_ == -1) {\n> -\t\tint ret = -errno;\n> -\t\tLOG(Buffer, Error)\n> -\t\t\t<< \"Failed to duplicate dmabuf: \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\tlength_ = length;\n> -\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\brief Map the plane memory data to a CPU accessible address\n> - *\n> - * The file descriptor to map the memory from must be set by a call to\n> - * setDmaBuf() before calling this function.\n> - *\n> - * \\sa setDmaBuf()\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int Plane::mmap()\n> -{\n> -\tvoid *map;\n> -\n> -\tif (mem_)\n> -\t\treturn 0;\n> -\n> -\tmap = ::mmap(NULL, length_, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0);\n> -\tif (map == MAP_FAILED) {\n> -\t\tint ret = -errno;\n> -\t\tLOG(Buffer, Error)\n> -\t\t\t<< \"Failed to mmap plane: \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\tmem_ = map;\n> -\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\brief Unmap any existing CPU accessible mapping\n> - *\n> - * Unmap the memory mapped by an earlier call to mmap().\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - */\n> -int Plane::munmap()\n> -{\n> -\tint ret = 0;\n> -\n> -\tif (mem_)\n> -\t\tret = ::munmap(mem_, length_);\n> -\n> -\tif (ret) {\n> -\t\tret = -errno;\n> -\t\tLOG(Buffer, Warning)\n> -\t\t\t<< \"Failed to unmap plane: \" << strerror(-ret);\n> -\t} else {\n> -\t\tmem_ = 0;\n> -\t}\n> -\n> -\treturn ret;\n> -}\n> -\n> -/**\n> - * \\fn Plane::mem()\n> - * \\brief Retrieve the CPU accessible memory address of the Plane\n> - * \\return The CPU accessible memory address on success or nullptr otherwise.\n> - */\n> -void *Plane::mem()\n> -{\n> -\tif (!mem_)\n> -\t\tmmap();\n> -\n> -\treturn mem_;\n> -}\n> -\n> -/**\n> - * \\fn Plane::length() const\n> - * \\brief Retrieve the length of the memory region\n> - * \\return The length of the memory region\n> - */\n> -\n>  /**\n>   * \\class BufferMemory\n>   * \\brief A memory buffer to store an image","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 88AD060464\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jan 2020 16:53:24 +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 A225C52F;\n\tTue,  7 Jan 2020 16:53:23 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1578412404;\n\tbh=WubbxIyPJUnzm/7qS6bC+IiOSyNzP7jBC5/19AkZyLM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gOT5x9X03aXu1L+ue3K4gLpkL2bgR8VFUMkjMWOMfmoagH95FHtLoyBfbn9Tg+LIc\n\tzg8pD41pLNXqFxXknBRtKL/3dCXcrJXZSMSBsce8xPBG6yoVS+HB+mqSPAc0nZRw91\n\tzbeeWIFRt/fzscALQy55a0DHZ75klfeIyf30rKHg=","Date":"Tue, 7 Jan 2020 17:53:12 +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":"<20200107155312.GB4871@pendragon.ideasonboard.com>","References":"<20191230120510.938333-1-niklas.soderlund@ragnatech.se>\n\t<20191230120510.938333-6-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":"<20191230120510.938333-6-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 05/25] libcamera: buffers: Remove\n\tPlane class","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, 07 Jan 2020 15:53:24 -0000"}}]