[{"id":19391,"web_url":"https://patchwork.libcamera.org/comment/19391/","msgid":"<affa41f0-092f-fd37-fb2b-b2acafab94b0@ideasonboard.com>","date":"2021-09-06T05:34:50","subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> The inode is useful to check if two file descriptors refer to the same\n> file. Add a function to retrieve it.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n> Changes since v1:\n> \n> - Use isValid() instead of open-coding it\n> - Print a message on error\n> ---\n>  include/libcamera/file_descriptor.h |  3 +++\n>  src/libcamera/file_descriptor.cpp   | 26 ++++++++++++++++++++++++++\n>  2 files changed, 29 insertions(+)\n> \n> diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h\n> index d514aac7697b..988f9b7a3d25 100644\n> --- a/include/libcamera/file_descriptor.h\n> +++ b/include/libcamera/file_descriptor.h\n> @@ -8,6 +8,7 @@\n>  #define __LIBCAMERA_FILE_DESCRIPTOR_H__\n>  \n>  #include <memory>\n> +#include <sys/types.h>\n>  \n>  namespace libcamera {\n>  \n> @@ -27,6 +28,8 @@ public:\n>  \tint fd() const { return fd_ ? fd_->fd() : -1; }\n>  \tFileDescriptor dup() const;\n>  \n> +\tino_t inode() const;\n> +\n>  private:\n>  \tclass Descriptor\n>  \t{\n> diff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp\n> index 9f9ebc81f738..0409c3e1758c 100644\n> --- a/src/libcamera/file_descriptor.cpp\n> +++ b/src/libcamera/file_descriptor.cpp\n> @@ -8,6 +8,8 @@\n>  #include <libcamera/file_descriptor.h>\n>  \n>  #include <string.h>\n> +#include <sys/stat.h>\n> +#include <sys/types.h>\n>  #include <unistd.h>\n>  #include <utility>\n>  \n> @@ -221,6 +223,30 @@ FileDescriptor FileDescriptor::dup() const\n>  \treturn FileDescriptor(fd());\n>  }\n>  \n> +/**\n> + * \\brief Retrieve the file descriptor inode\n> + *\n> + * \\todo Should this move to the File class ?\n> + *\n> + * \\return The file descriptor inode on success, or 0 on error\n> + */\n> +ino_t FileDescriptor::inode() const\n> +{\n> +\tif (!isValid())\n> +\t\treturn 0;\n> +\n> +\tstruct stat st;\n> +\tint ret = fstat(fd_->fd(), &st);\n> +\tif (ret < 0) {\n> +\t\tret = -errno;\n> +\t\tLOG(FileDescriptor, Fatal)\n> +\t\t\t<< \"Failed to fstat() fd: \" << strerror(-ret);\n> +\t\treturn 0;\n> +\t}\n> +\n> +\treturn st.st_ino;\n> +}\n> +\n>  FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n>  {\n>  \tif (!duplicate) {\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 97202BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 05:34:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C5976916A;\n\tMon,  6 Sep 2021 07:34:54 +0200 (CEST)","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 EA0096024D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 07:34:52 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A39C1317;\n\tMon,  6 Sep 2021 07:34:52 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PGiHpLbA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630906492;\n\tbh=Nk44h5Llh1NGlAy7DSiay9Ge8URT/UJWFNMCIb8iwS4=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=PGiHpLbA5NuUB92Urky1xOABLTYL0Bi+aKVI2ASsbRYCKSBQCyuSiUvBOLB8VHFMx\n\tizFmPrgI+BGCL9ZSecs4w9/TJ07pXtfm7ZC6FGWKos0NtGAfy2Dp63yJji6b74K+qb\n\tykzepQNrOpu4Q0RHbrnLm2dF3/+640ilPRnSlgo4=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<affa41f0-092f-fd37-fb2b-b2acafab94b0@ideasonboard.com>","Date":"Mon, 6 Sep 2021 07:34:50 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19393,"web_url":"https://patchwork.libcamera.org/comment/19393/","msgid":"<7b23af90-5c75-3b5a-4cc2-b8e7d0db3862@ideasonboard.com>","date":"2021-09-06T05:40:44","subject":"Re: [libcamera-devel] [PATCH v2 04/27] libcamera: Use\n\tV4L2PixelFormat::fromPixelFormat()","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Replace manual looked for V4L2 pixel format in the PixelFormatInfo with\n> the V4L2PixelFormat::fromPixelFormat() helper function. This prepares\n> for multi-planar support that will modify how V4L2 pixel formats are\n> stored in PixelFormatInfo.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/ipu3/cio2.cpp | 4 +---\n>  src/v4l2/v4l2_camera_proxy.cpp       | 9 +++------\n>  2 files changed, 4 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 9cedcb5b2879..dc62ab197acb 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> @@ -203,9 +203,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat)\n>  \tif (itInfo == mbusCodesToPixelFormat.end())\n>  \t\treturn -EINVAL;\n>  \n> -\tconst PixelFormatInfo &info = PixelFormatInfo::info(itInfo->second);\n> -\n> -\toutputFormat->fourcc = info.v4l2Format;\n> +\toutputFormat->fourcc = V4L2PixelFormat::fromPixelFormat(itInfo->second);\n>  \toutputFormat->size = sensorFormat.size;\n>  \toutputFormat->planesCount = 1;\n>  \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 07b1a90aa32f..d926a7b77083 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -164,12 +164,11 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n>  \n>  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n>  {\n> -\tconst PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat);\n>  \tconst Size &size = streamConfig.size;\n>  \n>  \tv4l2PixFormat_.width        = size.width;\n>  \tv4l2PixFormat_.height       = size.height;\n> -\tv4l2PixFormat_.pixelformat  = info.v4l2Format;\n> +\tv4l2PixFormat_.pixelformat  = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat);\n>  \tv4l2PixFormat_.field        = V4L2_FIELD_NONE;\n>  \tv4l2PixFormat_.bytesperline = streamConfig.stride;\n>  \tv4l2PixFormat_.sizeimage    = streamConfig.frameSize;\n> @@ -276,7 +275,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *\n>  \t/* \\todo Add map from format to description. */\n>  \tutils::strlcpy(reinterpret_cast<char *>(arg->description),\n>  \t\t       \"Video Format Description\", sizeof(arg->description));\n> -\targ->pixelformat = PixelFormatInfo::info(format).v4l2Format;\n> +\targ->pixelformat = V4L2PixelFormat::fromPixelFormat(format);\n>  \n>  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n>  \n> @@ -311,11 +310,9 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg)\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> -\tconst PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);\n> -\n>  \targ->fmt.pix.width        = config.size.width;\n>  \targ->fmt.pix.height       = config.size.height;\n> -\targ->fmt.pix.pixelformat  = info.v4l2Format;\n> +\targ->fmt.pix.pixelformat  = V4L2PixelFormat::fromPixelFormat(config.pixelFormat);\n>  \targ->fmt.pix.field        = V4L2_FIELD_NONE;\n>  \targ->fmt.pix.bytesperline = config.stride;\n>  \targ->fmt.pix.sizeimage    = config.frameSize;\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A4716BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 05:40:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6BDDF69168;\n\tMon,  6 Sep 2021 07:40:48 +0200 (CEST)","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 C9D666024D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 07:40:46 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 84429317;\n\tMon,  6 Sep 2021 07:40:46 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QIZxhTqw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630906846;\n\tbh=4zDsVTEjcNal2+i702ZYQWcC6gjMhCzEyYmGTo0CMXM=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=QIZxhTqwMV/J2s3vlhZRxA7mDYYx+tq6qtnQuinPSSvyiBAJc9/GGzxtXZ/g9+Cmv\n\tXTMMYQtk/Tj3pWIXoAy587FOq5b/bxsNpzlCAi2RzUZo5pyK3G6DPpBh60IzbQgul8\n\te2C7aEcMwygv853ctrolYkB8WGYXzGQWWh+OsUJw=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-5-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<7b23af90-5c75-3b5a-4cc2-b8e7d0db3862@ideasonboard.com>","Date":"Mon, 6 Sep 2021 07:40:44 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-5-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 04/27] libcamera: Use\n\tV4L2PixelFormat::fromPixelFormat()","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19396,"web_url":"https://patchwork.libcamera.org/comment/19396/","msgid":"<330d7434-0369-6446-d8c3-b8044cbdd6c7@ideasonboard.com>","date":"2021-09-06T05:50:58","subject":"Re: [libcamera-devel] [PATCH v2 09/27] libcamera: framebuffer: Add\n\ta function to check if planes are contiguous","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Multi-planar frame buffers can store their planes contiguously in\n> memory, or split them in discontiguous memory areas. Add a private\n> function to check in which of these two categories the frame buffer\n> belongs. This will be used to correctly handle the differences between\n> the V4L2 single and multi planar APIs.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n> Changes v1:\n> \n> - Merge both loops in FrameBuffer::FrameBuffer()\n> ---\n>  include/libcamera/internal/framebuffer.h |  2 ++\n>  src/libcamera/framebuffer.cpp            | 45 ++++++++++++++++++++++--\n>  2 files changed, 45 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h\n> index 606aed2b4782..cd33c295466e 100644\n> --- a/include/libcamera/internal/framebuffer.h\n> +++ b/include/libcamera/internal/framebuffer.h\n> @@ -21,9 +21,11 @@ public:\n>  \tPrivate();\n>  \n>  \tvoid setRequest(Request *request) { request_ = request; }\n> +\tbool isContiguous() const { return isContiguous_; }\n>  \n>  private:\n>  \tRequest *request_;\n> +\tbool isContiguous_;\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\n> index ad63a34a83bf..e71c2ffae034 100644\n> --- a/src/libcamera/framebuffer.cpp\n> +++ b/src/libcamera/framebuffer.cpp\n> @@ -106,7 +106,7 @@ LOG_DEFINE_CATEGORY(Buffer)\n>   */\n>  \n>  FrameBuffer::Private::Private()\n> -\t: request_(nullptr)\n> +\t: request_(nullptr), isContiguous_(true)\n>  {\n>  }\n>  \n> @@ -120,6 +120,17 @@ FrameBuffer::Private::Private()\n>   * handlers, it is called by the pipeline handlers themselves.\n>   */\n>  \n> +/**\n> + * \\fn FrameBuffer::Private::isContiguous()\n> + * \\brief Check if the frame buffer stores planes contiguously in memory\n> + *\n> + * Multi-planar frame buffers can store their planes contiguously in memory, or\n> + * split them into discontiguous memory areas. This function checks in which of\n> + * these two categories the frame buffer belongs.\n> + *\n> + * \\return True if the planes are stored contiguously in memory, false otherwise\n> + */\n> +\n>  /**\n>   * \\class FrameBuffer\n>   * \\brief Frame buffer data and its associated dynamic metadata\n> @@ -199,8 +210,38 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n>  \t: Extensible(std::make_unique<Private>()), planes_(planes),\n>  \t  cookie_(cookie)\n>  {\n> -\tfor (const auto &plane : planes_)\n> +\tunsigned int offset = 0;\n> +\tbool isContiguous = true;\n> +\tino_t inode = 0;\n> +\n> +\tfor (const auto &plane : planes_) {\n>  \t\tASSERT(plane.offset != Plane::kInvalidOffset);\n> +\n> +\t\tif (plane.offset != offset) {\n> +\t\t\tisContiguous = false;\n> +\t\t\tbreak;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Two different dmabuf file descriptors may still refer to the\n> +\t\t * same dmabuf instance. Check this using inodes.\n> +\t\t */\n\nHow is that possible ?\n\n> +\t\tif (plane.fd.fd() != planes_[0].fd.fd()) {\n> +\t\t\tif (!inode)\n> +\t\t\t\tinode = planes_[0].fd.inode();\n> +\t\t\tif (plane.fd.inode() != inode) {\n> +\t\t\t\tisContiguous = false;\n> +\t\t\t\tbreak;\n> +\t\t\t}\n> +\t\t}\n> +\n> +\t\toffset += plane.length;\n> +\t}\n> +\n> +\tLOG(Buffer, Debug)\n> +\t\t<< \"Buffer is \" << (isContiguous ? \"not \" : \"\") << \"contiguous\";\n> +\n> +\t_d()->isContiguous_ = isContiguous;\n>  }\n>  \n>  /**\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B1F00BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 05:51:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 011566916A;\n\tMon,  6 Sep 2021 07:51:02 +0200 (CEST)","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 ED15C6024D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 07:51:00 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F103317;\n\tMon,  6 Sep 2021 07:51:00 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KFLG75XP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630907460;\n\tbh=cawfvNYWmaILe2i2BvHSnjGKhDa7NH4pnk/Ryt8gkI0=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=KFLG75XPtCZwz01KJR/BceHtqPoDeJjluKvaTLLqE2T6KJzGMTIuRB1QSkd6HNG2B\n\tuf2NGwI80UNLmK+ynsMoK/1Pof248jvJkgLiXtPjaMTOBbztmjG4++LRQ87oI4weJm\n\tlqCBCqTSwsd0qOCW4fcxOizh+2Wk40O+AJico2mQ=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-10-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<330d7434-0369-6446-d8c3-b8044cbdd6c7@ideasonboard.com>","Date":"Mon, 6 Sep 2021 07:50:58 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-10-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 09/27] libcamera: framebuffer: Add\n\ta function to check if planes are contiguous","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19398,"web_url":"https://patchwork.libcamera.org/comment/19398/","msgid":"<7ceb7baf-814c-1183-d78d-6b265c855937@ideasonboard.com>","date":"2021-09-06T07:13:21","subject":"Re: [libcamera-devel] [PATCH v2 12/27] libcamera: v4l2_videodevice:\n\tTake stride into account to compute offsets","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> When creating FrameBuffer instances, the V4L2VideoDevice computes plane\n> offsets using minimal stride for the format. This doesn't always produce\n> a valid result when the device requires padding at the end of lines. Fix\n> it by computing offsets using the stride reported by V4L2.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 16 +++++++++++++---\n>  1 file changed, 13 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 88535f5a07c7..c6c9263c49e9 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1354,11 +1354,21 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n>  \t\tsize_t offset = 0;\n>  \n>  \t\tfor (size_t i = 0; i < planes.size(); ++i) {\n> +\t\t\t/*\n> +\t\t\t * The stride is reported by V4L2 for the first plane\n> +\t\t\t * only. Compute the stride of the other planes by\n> +\t\t\t * taking the horizontal subsampling factor into\n> +\t\t\t * account, which is equal to the bytesPerGroup ratio of\n> +\t\t\t * the planes.\n> +\t\t\t */\n> +\t\t\tunsigned int stride = format_.planes[0].bpl\n> +\t\t\t\t\t    * formatInfo_->planes[i].bytesPerGroup\n> +\t\t\t\t\t    / formatInfo_->planes[0].bytesPerGroup;\n> +\n>  \t\t\tplanes[i].fd = fd;\n>  \t\t\tplanes[i].offset = offset;\n> -\n> -\t\t\t/* \\todo Take the V4L2 stride into account */\n> -\t\t\tplanes[i].length = formatInfo_->planeSize(format_.size, i);\n> +\t\t\tplanes[i].length = formatInfo_->planeSize(format_.size.height,\n> +\t\t\t\t\t\t\t\t  i, stride);\n>  \t\t\toffset += planes[i].length;\n>  \t\t}\n>  \t}\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BF0E2BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 07:13:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 35CF369168;\n\tMon,  6 Sep 2021 09:13:26 +0200 (CEST)","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 B7E9960503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 09:13:24 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 53F18317;\n\tMon,  6 Sep 2021 09:13:24 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kJiek6F/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630912404;\n\tbh=qWvYNptZuHZ3NDLClIex9lcwBXhs6Hn0DkZmlvFYlUo=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=kJiek6F/xR/z4KgAAofa1KQg5DjwNzTaHpeRB99RgJJAWyIBBLn+CKKuGE5WFoVZ3\n\te4ahhJiMUxMCbn/vuyO9VZgessIAEKZiArqBfJ6FGTqruz/4biOIPSttyaHtfs5b0A\n\txcgjM/utL6NkeTA2Nj+AtsgOaE3yILhpYRfgn1nU=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-13-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<7ceb7baf-814c-1183-d78d-6b265c855937@ideasonboard.com>","Date":"Mon, 6 Sep 2021 09:13:21 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-13-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 12/27] libcamera: v4l2_videodevice:\n\tTake stride into account to compute offsets","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19400,"web_url":"https://patchwork.libcamera.org/comment/19400/","msgid":"<93f27205-49e8-f8a2-06e1-802c12d03c5c@ideasonboard.com>","date":"2021-09-06T07:36:04","subject":"Re: [libcamera-devel] [PATCH v2 16/27] libcamera: framebuffer:\n\tAllocate metadata planes at construction time","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> The metadata planes are allocated by V4L2VideoDevice when dequeuing a\n> buffer. This causes the metadata planes to only be allocated after a\n> buffer gets dequeued, and doesn't provide any strong guarantee that\n> their number matches the number of FrameBuffer planes. The lack of this\n> invariant makes the FrameBuffer class fragile.\n> \n> As a first step towards fixing this, allocate the metadata planes when\n> the FrameBuffer is constructed. The FrameMetadata API should be further\n> improved by preventing a change in the number of planes.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n> Changes since v1:\n> \n> - Return buffer with state set to FrameError on error\n> ---\n>  src/libcamera/framebuffer.cpp      |  2 ++\n>  src/libcamera/v4l2_videodevice.cpp | 10 +++++-----\n>  2 files changed, 7 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\n> index e71c2ffae034..e4f8419a9063 100644\n> --- a/src/libcamera/framebuffer.cpp\n> +++ b/src/libcamera/framebuffer.cpp\n> @@ -210,6 +210,8 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n>  \t: Extensible(std::make_unique<Private>()), planes_(planes),\n>  \t  cookie_(cookie)\n>  {\n> +\tmetadata_.planes.resize(planes_.size());\n> +\n>  \tunsigned int offset = 0;\n>  \tbool isContiguous = true;\n>  \tino_t inode = 0;\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 59aa53c7c27e..e729e608448c 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1670,7 +1670,6 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>  \n>  \tunsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n>  \tFrameMetadata &metadata = buffer->metadata_;\n> -\tmetadata.planes.clear();\n>  \n>  \tif (numV4l2Planes != buffer->planes().size()) {\n>  \t\t/*\n> @@ -1700,8 +1699,9 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>  \t\t\t\treturn buffer;\n>  \t\t\t}\n>  \n> -\t\t\tmetadata.planes.push_back({ std::min(plane.length, bytesused) });\n> -\t\t\tbytesused -= metadata.planes.back().bytesused;\n> +\t\t\tmetadata.planes[i].bytesused =\n> +\t\t\t\tstd::min(plane.length, bytesused);\n> +\t\t\tbytesused -= metadata.planes[i].bytesused;\n>  \t\t}\n>  \t} else if (multiPlanar) {\n>  \t\t/*\n> @@ -1710,9 +1710,9 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n>  \t\t * V4L2 buffer is guaranteed to be equal at this point.\n>  \t\t */\n>  \t\tfor (unsigned int i = 0; i < numV4l2Planes; ++i)\n> -\t\t\tmetadata.planes.push_back({ planes[i].bytesused });\n> +\t\t\tmetadata.planes[i].bytesused = planes[i].bytesused;\n>  \t} else {\n> -\t\tmetadata.planes.push_back({ buf.bytesused });\n> +\t\tmetadata.planes[0].bytesused = buf.bytesused;\n>  \t}\n>  \n>  \treturn buffer;\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 381D3BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 07:36:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8FD056916A;\n\tMon,  6 Sep 2021 09:36:10 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC80E60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 09:36:08 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B503724F;\n\tMon,  6 Sep 2021 09:36:07 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dR9eh3sf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630913767;\n\tbh=ktLK96VlZBDQeRvay9O83TUdPE3Uk+q9RhhOOSMXhrM=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=dR9eh3sf1bSfiv2LGf3X42mr6bLsrnXN57K9Y7vX0hhzAeBpqtSwK3Sr7344c4Wpz\n\teWbQo8CpO0KZQsuFayTdIcbFSgsDATYKDc2DeI0j4nzmWRFSIuMfOuPPHajRvjc8PX\n\tLdDx7sLGPgKlYWzErDyfeqb9yiLP66+LTtilacYo=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-17-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<93f27205-49e8-f8a2-06e1-802c12d03c5c@ideasonboard.com>","Date":"Mon, 6 Sep 2021 09:36:04 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-17-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 16/27] libcamera: framebuffer:\n\tAllocate metadata planes at construction time","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19402,"web_url":"https://patchwork.libcamera.org/comment/19402/","msgid":"<652cf326-0c96-6a7f-a44c-12e1b05cd5af@ideasonboard.com>","date":"2021-09-06T07:38:08","subject":"Re: [libcamera-devel] [PATCH v2 18/27] android: camera_device:\n\tDon't assume all planes use the same fd","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Now that libcamera correctly supports frame buffers with different\n> dmabuf for each plane, remove the assumption that a single dmabuf is\n> used.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/android/camera_device.cpp | 25 ++++++-------------------\n>  1 file changed, 6 insertions(+), 19 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 8ca76719a50f..c64064106ccc 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -749,25 +749,6 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n>  \t\t\t\t\t     libcamera::PixelFormat pixelFormat,\n>  \t\t\t\t\t     const libcamera::Size &size)\n>  {\n> -\tFileDescriptor fd;\n> -\t/*\n> -\t * This assumes all the planes are in the same dmabuf.\n> -\t *\n> -\t * \\todo Verify that this assumption holds, fstat() can be used to check\n> -\t * if two fds refer to the same dmabuf.\n> -\t */\n> -\tfor (int i = 0; i < camera3buffer->numFds; i++) {\n> -\t\tif (camera3buffer->data[i] != -1) {\n> -\t\t\tfd = FileDescriptor(camera3buffer->data[i]);\n> -\t\t\tbreak;\n> -\t\t}\n> -\t}\n> -\n> -\tif (!fd.isValid()) {\n> -\t\tLOG(HAL, Fatal) << \"No valid fd\";\n> -\t\treturn nullptr;\n> -\t}\n> -\n>  \tCameraBuffer buf(camera3buffer, pixelFormat, size, PROT_READ);\n>  \tif (!buf.isValid()) {\n>  \t\tLOG(HAL, Fatal) << \"Failed to create CameraBuffer\";\n> @@ -776,6 +757,12 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n>  \n>  \tstd::vector<FrameBuffer::Plane> planes(buf.numPlanes());\n>  \tfor (size_t i = 0; i < buf.numPlanes(); ++i) {\n> +\t\tFileDescriptor fd{ camera3buffer->data[i] };\n> +\t\tif (!fd.isValid()) {\n> +\t\t\tLOG(HAL, Fatal) << \"No valid fd\";\n> +\t\t\treturn nullptr;\n> +\t\t}\n> +\n>  \t\tplanes[i].fd = fd;\n>  \t\tplanes[i].offset = buf.offset(i);\n>  \t\tplanes[i].length = buf.size(i);\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1BC6CBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 07:38:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D8BA76916A;\n\tMon,  6 Sep 2021 09:38:12 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BD0460503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 09:38:11 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 43F9224F;\n\tMon,  6 Sep 2021 09:38:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"W1dVOreQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630913891;\n\tbh=NqYKB4G4ua6M143bpaOppSpcwdf9M/ux810w1mvT/m0=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=W1dVOreQlC/E46JXz3isMwVGMNLkGGiW9sUsTRwB9dA+Ye3d9XvrqPouBsGXTzoHi\n\t29r6zNSBK647Rt9f4HIW8CYyqCkk+W8pTJmC/WRDQf7bGdhL2AiiRVLaq1DtADKI0K\n\tB0WUo41sneh676DnLJdllTYOBj6Zy9eXXCkCf0YY=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-19-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<652cf326-0c96-6a7f-a44c-12e1b05cd5af@ideasonboard.com>","Date":"Mon, 6 Sep 2021 09:38:08 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-19-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 18/27] android: camera_device:\n\tDon't assume all planes use the same fd","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19405,"web_url":"https://patchwork.libcamera.org/comment/19405/","msgid":"<2279ec9d-de49-6b8c-af28-d96b86811ede@ideasonboard.com>","date":"2021-09-06T08:35:50","subject":"Re: [libcamera-devel] [PATCH v2 19/27] cam: Add Image class","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> The new Image class represents a multi-planar image with direct access\n> to pixel data. It currently duplicates the function of the\n> MappedFrameBuffer class which is internal to libcamera, and will serve\n> as a design playground to improve the API until it is considered ready\n> to be made part of the libcamera public API.\n\nI like the idea, maybe add some documentation already in the class ?\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/cam/image.cpp   | 107 ++++++++++++++++++++++++++++++++++++++++++++\n>  src/cam/image.h     |  52 +++++++++++++++++++++\n>  src/cam/meson.build |   1 +\n>  3 files changed, 160 insertions(+)\n>  create mode 100644 src/cam/image.cpp\n>  create mode 100644 src/cam/image.h\n> \n> diff --git a/src/cam/image.cpp b/src/cam/image.cpp\n> new file mode 100644\n> index 000000000000..7ae5f52dccb4\n> --- /dev/null\n> +++ b/src/cam/image.cpp\n> @@ -0,0 +1,107 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2021, Google Inc.\n> + *\n> + * image.cpp - Multi-planar image with access to pixel data\n> + */\n> +\n> +#include \"image.h\"\n> +\n> +#include <assert.h>\n> +#include <errno.h>\n> +#include <iostream>\n> +#include <map>\n> +#include <string.h>\n> +#include <sys/mman.h>\n> +#include <unistd.h>\n> +\n> +using namespace libcamera;\n> +\n> +std::unique_ptr<Image> Image::fromFrameBuffer(const FrameBuffer *buffer, MapMode mode)\n\nCan you see a use case for Image::toFrameBuffer not implemented yet ?\nWhat would be in this class apart from a conversion from a FrameBuffer\nto a Image ?\n\n> +{\n> +\tstd::unique_ptr<Image> image{ new Image() };\n> +\n> +\tassert(!buffer->planes().empty());\n> +\n> +\tint mmapFlags = 0;\n> +\n> +\tif (mode & MapMode::ReadOnly)\n> +\t\tmmapFlags |= PROT_READ;\n> +\n> +\tif (mode & MapMode::WriteOnly)\n> +\t\tmmapFlags |= PROT_WRITE;\n> +\n> +\tstruct MappedBufferInfo {\n> +\t\tuint8_t *address = nullptr;\n> +\t\tsize_t mapLength = 0;\n> +\t\tsize_t dmabufLength = 0;\n> +\t};\n> +\tstd::map<int, MappedBufferInfo> mappedBuffers;\n> +\n> +\tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> +\t\tconst int fd = plane.fd.fd();\n> +\t\tif (mappedBuffers.find(fd) == mappedBuffers.end()) {\n> +\t\t\tconst size_t length = lseek(fd, 0, SEEK_END);\n> +\t\t\tmappedBuffers[fd] = MappedBufferInfo{ nullptr, 0, length };\n> +\t\t}\n> +\n> +\t\tconst size_t length = mappedBuffers[fd].dmabufLength;\n> +\n> +\t\tif (plane.offset > length ||\n> +\t\t    plane.offset + plane.length > length) {\n> +\t\t\tstd::cerr << \"plane is out of buffer: buffer length=\"\n> +\t\t\t\t  << length << \", plane offset=\" << plane.offset\n> +\t\t\t\t  << \", plane length=\" << plane.length\n> +\t\t\t\t  << std::endl;\n> +\t\t\treturn nullptr;\n> +\t\t}\n> +\t\tsize_t &mapLength = mappedBuffers[fd].mapLength;\n> +\t\tmapLength = std::max(mapLength,\n> +\t\t\t\t     static_cast<size_t>(plane.offset + plane.length));\n> +\t}\n> +\n> +\tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> +\t\tconst int fd = plane.fd.fd();\n> +\t\tauto &info = mappedBuffers[fd];\n> +\t\tif (!info.address) {\n> +\t\t\tvoid *address = mmap(nullptr, info.mapLength, mmapFlags,\n> +\t\t\t\t\t     MAP_SHARED, fd, 0);\n> +\t\t\tif (address == MAP_FAILED) {\n> +\t\t\t\tint error = -errno;\n> +\t\t\t\tstd::cerr << \"Failed to mmap plane: \"\n> +\t\t\t\t\t  << strerror(-error) << std::endl;\n> +\t\t\t\treturn nullptr;\n> +\t\t\t}\n> +\n> +\t\t\tinfo.address = static_cast<uint8_t *>(address);\n> +\t\t\timage->maps_.emplace_back(info.address, info.mapLength);\n> +\t\t}\n> +\n> +\t\timage->planes_.emplace_back(info.address + plane.offset, plane.length);\n> +\t}\n> +\n\nWhy are you using two loops on buffer->planes() ? Is it for code clarity\nor something I did not get ?\n\n> +\treturn image;\n> +}\n> +\n> +Image::Image() = default;\n> +\n> +Image::~Image()\n> +{\n> +\tfor (Span<uint8_t> &map : maps_)\n> +\t\tmunmap(map.data(), map.size());\n> +}\n> +\n> +unsigned int Image::numPlanes() const\n> +{\n> +\treturn planes_.size();\n> +}\n> +\n> +Span<uint8_t> Image::data(unsigned int plane)\n> +{\n> +\treturn planes_[plane];\n> +}\n> +\n> +Span<const uint8_t> Image::data(unsigned int plane) const\n> +{\n> +\treturn planes_[plane];\n> +}\n> diff --git a/src/cam/image.h b/src/cam/image.h\n> new file mode 100644\n> index 000000000000..1ce5f84e5f9e\n> --- /dev/null\n> +++ b/src/cam/image.h\n> @@ -0,0 +1,52 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2021, Google Inc.\n> + *\n> + * image.h - Multi-planar image with access to pixel data\n> + */\n> +#ifndef __CAM_IMAGE_H__\n> +#define __CAM_IMAGE_H__\n> +\n> +#include <memory>\n> +#include <stdint.h>\n> +#include <vector>\n> +\n> +#include <libcamera/base/class.h>\n> +#include <libcamera/base/flags.h>\n> +#include <libcamera/base/span.h>\n> +\n> +#include <libcamera/framebuffer.h>\n> +\n> +class Image\n> +{\n> +public:\n> +\tenum class MapMode {\n> +\t\tReadOnly = 1 << 0,\n> +\t\tWriteOnly = 1 << 1,\n> +\t\tReadWrite = ReadOnly | WriteOnly,\n> +\t};\n> +\n> +\tstatic std::unique_ptr<Image> fromFrameBuffer(const libcamera::FrameBuffer *buffer,\n> +\t\t\t\t\t\t      MapMode mode);\n> +\n> +\t~Image();\n> +\n> +\tunsigned int numPlanes() const;\n> +\n> +\tlibcamera::Span<uint8_t> data(unsigned int plane);\n> +\tlibcamera::Span<const uint8_t> data(unsigned int plane) const;\n> +\n> +private:\n> +\tLIBCAMERA_DISABLE_COPY(Image)\n> +\n> +\tImage();\n> +\n> +\tstd::vector<libcamera::Span<uint8_t>> maps_;\n> +\tstd::vector<libcamera::Span<uint8_t>> planes_;\n> +};\n> +\n> +namespace libcamera {\n> +LIBCAMERA_FLAGS_ENABLE_OPERATORS(Image::MapMode)\n> +}\n> +\n> +#endif /* __CAM_IMAGE_H__ */\n> diff --git a/src/cam/meson.build b/src/cam/meson.build\n> index ea36aaa5c514..e8e2ae57d3f4 100644\n> --- a/src/cam/meson.build\n> +++ b/src/cam/meson.build\n> @@ -14,6 +14,7 @@ cam_sources = files([\n>      'event_loop.cpp',\n>      'file_sink.cpp',\n>      'frame_sink.cpp',\n> +    'image.cpp',\n>      'main.cpp',\n>      'options.cpp',\n>      'stream_options.cpp',\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6A0DCBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 08:35:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DCEBC6916A;\n\tMon,  6 Sep 2021 10:35:54 +0200 (CEST)","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 D4FEF60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 10:35:53 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 63BD124F;\n\tMon,  6 Sep 2021 10:35:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LKRVFZxe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630917353;\n\tbh=oz3slbrrMVmpTUn2i+3DyoLvK4Bb+CODR0LMOScR7mU=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=LKRVFZxe/xQhAfHCUzYUenEG71f48GZAin/4d0v012YF0aTmpOhaxLQkYu6sRmaMm\n\t0tTCKP4pjOrTLkYOdKB+PCGFKOvYQ1t73wMPfa5ohGXtOvJapUER3I9AjolcjSw+dC\n\tmrGaTGvhcvvRLjImOtkqb9Y3StNglF0n0yuQKfBM=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-20-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<2279ec9d-de49-6b8c-af28-d96b86811ede@ideasonboard.com>","Date":"Mon, 6 Sep 2021 10:35:50 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-20-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 19/27] cam: Add Image 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19409,"web_url":"https://patchwork.libcamera.org/comment/19409/","msgid":"<20210906090444.GT968527@pyrite.rasen.tech>","date":"2021-09-06T09:04:44","subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Mon, Sep 06, 2021 at 05:00:35AM +0300, Laurent Pinchart wrote:\n> The inode is useful to check if two file descriptors refer to the same\n> file. Add a function to retrieve it.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n> Changes since v1:\n> \n> - Use isValid() instead of open-coding it\n> - Print a message on error\n> ---\n>  include/libcamera/file_descriptor.h |  3 +++\n>  src/libcamera/file_descriptor.cpp   | 26 ++++++++++++++++++++++++++\n>  2 files changed, 29 insertions(+)\n> \n> diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h\n> index d514aac7697b..988f9b7a3d25 100644\n> --- a/include/libcamera/file_descriptor.h\n> +++ b/include/libcamera/file_descriptor.h\n> @@ -8,6 +8,7 @@\n>  #define __LIBCAMERA_FILE_DESCRIPTOR_H__\n>  \n>  #include <memory>\n> +#include <sys/types.h>\n>  \n>  namespace libcamera {\n>  \n> @@ -27,6 +28,8 @@ public:\n>  \tint fd() const { return fd_ ? fd_->fd() : -1; }\n>  \tFileDescriptor dup() const;\n>  \n> +\tino_t inode() const;\n> +\n>  private:\n>  \tclass Descriptor\n>  \t{\n> diff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp\n> index 9f9ebc81f738..0409c3e1758c 100644\n> --- a/src/libcamera/file_descriptor.cpp\n> +++ b/src/libcamera/file_descriptor.cpp\n> @@ -8,6 +8,8 @@\n>  #include <libcamera/file_descriptor.h>\n>  \n>  #include <string.h>\n> +#include <sys/stat.h>\n> +#include <sys/types.h>\n>  #include <unistd.h>\n>  #include <utility>\n>  \n> @@ -221,6 +223,30 @@ FileDescriptor FileDescriptor::dup() const\n>  \treturn FileDescriptor(fd());\n>  }\n>  \n> +/**\n> + * \\brief Retrieve the file descriptor inode\n> + *\n> + * \\todo Should this move to the File class ?\n> + *\n> + * \\return The file descriptor inode on success, or 0 on error\n> + */\n> +ino_t FileDescriptor::inode() const\n> +{\n> +\tif (!isValid())\n> +\t\treturn 0;\n> +\n> +\tstruct stat st;\n> +\tint ret = fstat(fd_->fd(), &st);\n> +\tif (ret < 0) {\n> +\t\tret = -errno;\n> +\t\tLOG(FileDescriptor, Fatal)\n> +\t\t\t<< \"Failed to fstat() fd: \" << strerror(-ret);\n> +\t\treturn 0;\n> +\t}\n> +\n> +\treturn st.st_ino;\n> +}\n> +\n>  FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n>  {\n>  \tif (!duplicate) {\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 90187BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:04:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4B2CB6916A;\n\tMon,  6 Sep 2021 11:04:53 +0200 (CEST)","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 191CB60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:04:52 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9556317;\n\tMon,  6 Sep 2021 11:04:50 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"h6TDi+o9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630919091;\n\tbh=VZIpjXfsrJnLb5kaa1q5AUnvf9ATo4Vum6QARhRj2VE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=h6TDi+o9yRsYRID6grfFxP4lzDDzqB2j5MJU95Io6LxrL8K9pky8AG7R4ORSgZeQB\n\thsUKkaYuo2pvbmxUCQpSGiCtshLX7atD3AzhFAzwTJrJNjMvnTe24cuLJ/i3XUcQin\n\t5qw80kXNpl936ID3fSOv22lwIGNvuBxTw4X4Cru4=","Date":"Mon, 6 Sep 2021 18:04:44 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210906090444.GT968527@pyrite.rasen.tech>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19410,"web_url":"https://patchwork.libcamera.org/comment/19410/","msgid":"<2974eb39-d5c6-be5e-848a-547678bd023c@ideasonboard.com>","date":"2021-09-06T09:27:06","subject":"Re: [libcamera-devel] [PATCH v2 20/27] cam: file_sink: Use Image\n\tclass to access pixel data","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Replace the manual implementation of frame buffer mapping with the Image\n> class to improve code sharing.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nIt improves reading indeed !\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\n> ---\n>  src/cam/file_sink.cpp | 42 +++++++++++++-----------------------------\n>  src/cam/file_sink.h   |  6 ++++--\n>  2 files changed, 17 insertions(+), 31 deletions(-)\n> \n> diff --git a/src/cam/file_sink.cpp b/src/cam/file_sink.cpp\n> index 0fc7d621f50b..3c2e565b27a2 100644\n> --- a/src/cam/file_sink.cpp\n> +++ b/src/cam/file_sink.cpp\n> @@ -5,17 +5,18 @@\n>   * file_sink.cpp - File Sink\n>   */\n>  \n> +#include <assert.h>\n>  #include <fcntl.h>\n>  #include <iomanip>\n>  #include <iostream>\n>  #include <sstream>\n>  #include <string.h>\n> -#include <sys/mman.h>\n>  #include <unistd.h>\n>  \n>  #include <libcamera/camera.h>\n>  \n>  #include \"file_sink.h\"\n> +#include \"image.h\"\n>  \n>  using namespace libcamera;\n>  \n> @@ -26,12 +27,6 @@ FileSink::FileSink(const std::string &pattern)\n>  \n>  FileSink::~FileSink()\n>  {\n> -\tfor (auto &iter : mappedBuffers_) {\n> -\t\tvoid *memory = iter.second.first;\n> -\t\tunsigned int length = iter.second.second;\n> -\t\tmunmap(memory, length);\n> -\t}\n> -\tmappedBuffers_.clear();\n>  }\n>  \n>  int FileSink::configure(const libcamera::CameraConfiguration &config)\n> @@ -51,23 +46,11 @@ int FileSink::configure(const libcamera::CameraConfiguration &config)\n>  \n>  void FileSink::mapBuffer(FrameBuffer *buffer)\n>  {\n> -\t/* \\todo use MappedFrameBuffer. */\n> -\tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> -\t\tconst int fd = plane.fd.fd();\n> -\t\tif (mappedBuffers_.find(fd) == mappedBuffers_.end()) {\n> -\t\t\t/**\n> -\t\t\t * \\todo Should we try to only map the portions of the\n> -\t\t\t * dmabuf that are used by planes ?\n> -\t\t\t */\n> -\t\t\tsize_t length = lseek(fd, 0, SEEK_END);\n> -\t\t\tvoid *memory = mmap(NULL, plane.length, PROT_READ,\n> -\t\t\t\t\t    MAP_SHARED, fd, 0);\n> -\t\t\tmappedBuffers_[fd] = std::make_pair(memory, length);\n> -\t\t}\n> +\tstd::unique_ptr<Image> image =\n> +\t\tImage::fromFrameBuffer(buffer, Image::MapMode::ReadOnly);\n> +\tassert(image != nullptr);\n>  \n> -\t\tvoid *memory = mappedBuffers_[fd].first;\n> -\t\tplaneData_[&plane] = static_cast<uint8_t *>(memory) + plane.offset;\n> -\t}\n> +\tmappedBuffers_[buffer] = std::move(image);\n>  }\n>  \n>  bool FileSink::processRequest(Request *request)\n> @@ -108,19 +91,20 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer)\n>  \t\treturn;\n>  \t}\n>  \n> +\tImage *image = mappedBuffers_[buffer].get();\n> +\n>  \tfor (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> -\t\tconst FrameBuffer::Plane &plane = buffer->planes()[i];\n>  \t\tconst FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n>  \n> -\t\tuint8_t *data = planeData_[&plane];\n> -\t\tunsigned int length = std::min(meta.bytesused, plane.length);\n> +\t\tSpan<uint8_t> data = image->data(i);\n> +\t\tunsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n>  \n> -\t\tif (meta.bytesused > plane.length)\n> +\t\tif (meta.bytesused > data.size())\n>  \t\t\tstd::cerr << \"payload size \" << meta.bytesused\n> -\t\t\t\t  << \" larger than plane size \" << plane.length\n> +\t\t\t\t  << \" larger than plane size \" << data.size()\n>  \t\t\t\t  << std::endl;\n>  \n> -\t\tret = ::write(fd, data, length);\n> +\t\tret = ::write(fd, data.data(), length);\n>  \t\tif (ret < 0) {\n>  \t\t\tret = -errno;\n>  \t\t\tstd::cerr << \"write error: \" << strerror(-ret)\n> diff --git a/src/cam/file_sink.h b/src/cam/file_sink.h\n> index c12325d955c5..335be93b8732 100644\n> --- a/src/cam/file_sink.h\n> +++ b/src/cam/file_sink.h\n> @@ -8,12 +8,15 @@\n>  #define __CAM_FILE_SINK_H__\n>  \n>  #include <map>\n> +#include <memory>\n>  #include <string>\n>  \n>  #include <libcamera/stream.h>\n>  \n>  #include \"frame_sink.h\"\n>  \n> +class Image;\n> +\n>  class FileSink : public FrameSink\n>  {\n>  public:\n> @@ -32,8 +35,7 @@ private:\n>  \n>  \tstd::map<const libcamera::Stream *, std::string> streamNames_;\n>  \tstd::string pattern_;\n> -\tstd::map<int, std::pair<void *, unsigned int>> mappedBuffers_;\n> -\tstd::map<const libcamera::FrameBuffer::Plane *, uint8_t *> planeData_;\n> +\tstd::map<libcamera::FrameBuffer *, std::unique_ptr<Image>> mappedBuffers_;\n>  };\n>  \n>  #endif /* __CAM_FILE_SINK_H__ */\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F319CBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:27:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F9CD69168;\n\tMon,  6 Sep 2021 11:27:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B3BF60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:27:09 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1A09C8D7;\n\tMon,  6 Sep 2021 11:27:09 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gJD23Cf+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630920429;\n\tbh=MCl5sbIswPA+of8F/mQhsKKXTdheeOH3TUIQ6G/Xvgo=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=gJD23Cf+sxsxnR19r4b0iFb9PAqQ7/dMlMUqzbuyi/o5dW8ISL3TvXwKaGDVF2sRj\n\teHV8tAegdM1Yd5dh6AYfVgHM8GVbdGQALd3Stw5MT8VKKhdtgQbKLGGAWFGWTCQfoW\n\txA3D99R2ZnlXcZtCISo4s6JPEQEOSDwsSIJqZgvc=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-21-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<2974eb39-d5c6-be5e-848a-547678bd023c@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:27:06 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-21-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 20/27] cam: file_sink: Use Image\n\tclass to access pixel data","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19411,"web_url":"https://patchwork.libcamera.org/comment/19411/","msgid":"<7feea922-8eac-b852-27fb-74aaff1ef5fb@ideasonboard.com>","date":"2021-09-06T09:28:31","subject":"Re: [libcamera-devel] [PATCH v2 21/27] cam: drm: Support per-plane\n\tstride values","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> The stride is not always identical for all planes for multi-planar\n> formats. Semi-planar YUV formats without horizontal subsampling often\n> have a chroma stride equal to twice the luma stride, and tri-planar YUV\n> formats with a 1/2 horizontal subsampling often have a chroma stride\n> equal to half the luma stride. This isn't correctly taken into account\n> when creating a DRM frame buffer, as the same stride is set for all\n> planes.\n> \n> libcamera doesn't report per-plane stride values yet, but uses chroma\n> strides that match the above description for all currently supported\n> platforms. Calculation the chrome strides appropriately in the KMSSink\n> class, and pass them to DRM::createFrameBuffer().\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/cam/drm.cpp      |  7 +++----\n>  src/cam/drm.h        |  5 ++++-\n>  src/cam/kms_sink.cpp | 28 +++++++++++++++++++++++++++-\n>  3 files changed, 34 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp\n> index da317e27cb19..ac47b8bd3287 100644\n> --- a/src/cam/drm.cpp\n> +++ b/src/cam/drm.cpp\n> @@ -595,12 +595,12 @@ const Object *Device::object(uint32_t id)\n>  std::unique_ptr<FrameBuffer> Device::createFrameBuffer(\n>  \tconst libcamera::FrameBuffer &buffer,\n>  \tconst libcamera::PixelFormat &format,\n> -\tconst libcamera::Size &size, unsigned int stride)\n> +\tconst libcamera::Size &size,\n> +\tconst std::array<uint32_t, 4> &strides)\n>  {\n>  \tstd::unique_ptr<FrameBuffer> fb{ new FrameBuffer(this) };\n>  \n>  \tuint32_t handles[4] = {};\n> -\tuint32_t pitches[4] = {};\n>  \tuint32_t offsets[4] = {};\n>  \tint ret;\n>  \n> @@ -623,13 +623,12 @@ std::unique_ptr<FrameBuffer> Device::createFrameBuffer(\n>  \t\tfb->planes_.push_back({ handle });\n>  \n>  \t\thandles[i] = handle;\n> -\t\tpitches[i] = stride;\n>  \t\toffsets[i] = 0; /* TODO */\n>  \t\t++i;\n>  \t}\n>  \n>  \tret = drmModeAddFB2(fd_, size.width, size.height, format.fourcc(), handles,\n> -\t\t\t    pitches, offsets, &fb->id_, 0);\n> +\t\t\t    strides.data(), offsets, &fb->id_, 0);\n>  \tif (ret < 0) {\n>  \t\tret = -errno;\n>  \t\tstd::cerr\n> diff --git a/src/cam/drm.h b/src/cam/drm.h\n> index ee2304025208..00f7e798b771 100644\n> --- a/src/cam/drm.h\n> +++ b/src/cam/drm.h\n> @@ -7,9 +7,11 @@\n>  #ifndef __CAM_DRM_H__\n>  #define __CAM_DRM_H__\n>  \n> +#include <array>\n>  #include <list>\n>  #include <map>\n>  #include <memory>\n> +#include <stdint.h>\n>  #include <string>\n>  #include <vector>\n>  \n> @@ -298,7 +300,8 @@ public:\n>  \tstd::unique_ptr<FrameBuffer> createFrameBuffer(\n>  \t\tconst libcamera::FrameBuffer &buffer,\n>  \t\tconst libcamera::PixelFormat &format,\n> -\t\tconst libcamera::Size &size, unsigned int stride);\n> +\t\tconst libcamera::Size &size,\n> +\t\tconst std::array<uint32_t, 4> &strides);\n>  \n>  \tlibcamera::Signal<AtomicRequest *> requestComplete;\n>  \n> diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\n> index 8c0b79c63922..658192efc105 100644\n> --- a/src/cam/kms_sink.cpp\n> +++ b/src/cam/kms_sink.cpp\n> @@ -7,10 +7,12 @@\n>  \n>  #include \"kms_sink.h\"\n>  \n> +#include <array>\n>  #include <algorithm>\n>  #include <assert.h>\n>  #include <iostream>\n>  #include <memory>\n> +#include <stdint.h>\n>  #include <string.h>\n>  \n>  #include <libcamera/camera.h>\n> @@ -65,8 +67,32 @@ KMSSink::KMSSink(const std::string &connectorName)\n>  \n>  void KMSSink::mapBuffer(libcamera::FrameBuffer *buffer)\n>  {\n> +\tstd::array<uint32_t, 4> strides = {};\n> +\n> +\t/* \\todo Should libcamera report per-plane strides ? */\n> +\tunsigned int uvStrideMultiplier;\n> +\n> +\tswitch (format_) {\n> +\tcase libcamera::formats::NV24:\n> +\tcase libcamera::formats::NV42:\n> +\t\tuvStrideMultiplier = 4;\n> +\t\tbreak;\n> +\tcase libcamera::formats::YUV420:\n> +\tcase libcamera::formats::YVU420:\n> +\tcase libcamera::formats::YUV422:\n> +\t\tuvStrideMultiplier = 1;\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tuvStrideMultiplier = 2;\n> +\t\tbreak;\n> +\t}\n> +\n> +\tstrides[0] = stride_;\n> +\tfor (unsigned int i = 1; i < buffer->planes().size(); ++i)\n> +\t\tstrides[i] = stride_ * uvStrideMultiplier / 2;\n> +\n>  \tstd::unique_ptr<DRM::FrameBuffer> drmBuffer =\n> -\t\tdev_.createFrameBuffer(*buffer, format_, size_, stride_);\n> +\t\tdev_.createFrameBuffer(*buffer, format_, size_, strides);\n>  \tif (!drmBuffer)\n>  \t\treturn;\n>  \n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 11310BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:28:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CAF2A6916B;\n\tMon,  6 Sep 2021 11:28:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 83CE360503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:28:33 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C9AC8D7;\n\tMon,  6 Sep 2021 11:28:33 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dhKKDBfr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630920513;\n\tbh=RFQtpUCqr1kxCq74pUxmMXnOQ7ApbeUv2tCBSISL5nU=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=dhKKDBfrfMnyY1vLDTxRVCuVtwXh4UPK/k5gFEWh1gPHwCMln9Wft7y/bj5dNHYCw\n\tXehuwc6TfqGu5ZByF2zuCLLh9PuU+NmrGoWNXv8GO5K7uOXHR7o//6kpDJHPx0zrLr\n\t+GXXJuyAOWcXGay5GgiTFS9wxbggDwNW/FGPD8hg=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-22-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<7feea922-8eac-b852-27fb-74aaff1ef5fb@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:28:31 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-22-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 21/27] cam: drm: Support per-plane\n\tstride values","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19412,"web_url":"https://patchwork.libcamera.org/comment/19412/","msgid":"<187e94f3-b046-dd5b-cd3d-fbd4e91438b2@ideasonboard.com>","date":"2021-09-06T09:28:55","subject":"Re: [libcamera-devel] [PATCH v2 22/27] cam: drm: Set per-plane\n\toffsets when creating DRM frame buffer","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Now that libcamera supports per-plane offsets, pass the values to\n> drmModeAddFB2().\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/cam/drm.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp\n> index ac47b8bd3287..d5a75d039fd8 100644\n> --- a/src/cam/drm.cpp\n> +++ b/src/cam/drm.cpp\n> @@ -623,7 +623,7 @@ std::unique_ptr<FrameBuffer> Device::createFrameBuffer(\n>  \t\tfb->planes_.push_back({ handle });\n>  \n>  \t\thandles[i] = handle;\n> -\t\toffsets[i] = 0; /* TODO */\n> +\t\toffsets[i] = plane.offset;\n>  \t\t++i;\n>  \t}\n>  \n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BC72CBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:28:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D4A36916B;\n\tMon,  6 Sep 2021 11:28:58 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD85560503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:28:57 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6971A8D7;\n\tMon,  6 Sep 2021 11:28:57 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"oGdlbouj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630920537;\n\tbh=Hp9vN4ECdlSetGrzG9m+hpm+OtD3QVxAWAHpy0rfYI8=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=oGdlbouj6LLeSVa9A5wfpuvXd/HmalGfDiDVc1ygT+R4W20itxA2hzgZTXi2NgpZd\n\tP/doJt7o6oE9tCstLbNLRGuCZl9x2Ww74MNaS9kX4NbiJTulEZDUMfGSWGoLJOCnZG\n\tU3VmeAF1bAfN7ednWD2ES5P7kUA3S332GbFh5iDM=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-23-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<187e94f3-b046-dd5b-cd3d-fbd4e91438b2@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:28:55 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-23-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 22/27] cam: drm: Set per-plane\n\toffsets when creating DRM frame buffer","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19413,"web_url":"https://patchwork.libcamera.org/comment/19413/","msgid":"<6c8b6cdc-4a2c-f415-ce6b-5b9f806be8e1@ideasonboard.com>","date":"2021-09-06T09:32:09","subject":"Re: [libcamera-devel] [PATCH v2 23/27] cam: drm: Avoid importing\n\tthe same dmabuf multiple times","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> When creating a DRM frame buffer, the dmabufs for the planes are\n> imported as GEM objects. For multi-planar formats, all planes may use\n> the same dmabuf, which results in multiple imports. This doesn't cause\n> any issue at import time, as DRM detects this situation and returns the\n> same GEM object. However, when destroying the frame buffer, the same GEM\n> object ends up being closed multiple times, which generates an error.\n> \n> Fix this by avoiding multiple imports of the same dmabuf for the same\n> frame buffer. While the issue may theoretically occur with identical\n> dmabufs for different frame buffers, this is quite unlikely and is thus\n> not addressed.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\n>  src/cam/drm.cpp | 29 +++++++++++++++++------------\n>  src/cam/drm.h   |  2 +-\n>  2 files changed, 18 insertions(+), 13 deletions(-)\n> \n> diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp\n> index d5a75d039fd8..f25300913a7f 100644\n> --- a/src/cam/drm.cpp\n> +++ b/src/cam/drm.cpp\n> @@ -283,9 +283,9 @@ FrameBuffer::FrameBuffer(Device *dev)\n>  \n>  FrameBuffer::~FrameBuffer()\n>  {\n> -\tfor (FrameBuffer::Plane &plane : planes_) {\n> +\tfor (const auto &plane : planes_) {\n>  \t\tstruct drm_gem_close gem_close = {\n> -\t\t\t.handle = plane.handle,\n> +\t\t\t.handle = plane.second.handle,\n>  \t\t\t.pad = 0,\n>  \t\t};\n>  \t\tint ret;\n> @@ -605,22 +605,27 @@ std::unique_ptr<FrameBuffer> Device::createFrameBuffer(\n>  \tint ret;\n>  \n>  \tconst std::vector<libcamera::FrameBuffer::Plane> &planes = buffer.planes();\n> -\tfb->planes_.reserve(planes.size());\n>  \n>  \tunsigned int i = 0;\n>  \tfor (const libcamera::FrameBuffer::Plane &plane : planes) {\n> +\t\tint fd = plane.fd.fd();\n>  \t\tuint32_t handle;\n>  \n> -\t\tret = drmPrimeFDToHandle(fd_, plane.fd.fd(), &handle);\n> -\t\tif (ret < 0) {\n> -\t\t\tret = -errno;\n> -\t\t\tstd::cerr\n> -\t\t\t\t<< \"Unable to import framebuffer dmabuf: \"\n> -\t\t\t\t<< strerror(-ret) << std::endl;\n> -\t\t\treturn nullptr;\n> -\t\t}\n> +\t\tauto iter = fb->planes_.find(fd);\n> +\t\tif (iter == fb->planes_.end()) {\n> +\t\t\tret = drmPrimeFDToHandle(fd_, plane.fd.fd(), &handle);\n> +\t\t\tif (ret < 0) {\n> +\t\t\t\tret = -errno;\n> +\t\t\t\tstd::cerr\n> +\t\t\t\t\t<< \"Unable to import framebuffer dmabuf: \"\n> +\t\t\t\t\t<< strerror(-ret) << std::endl;\n> +\t\t\t\treturn nullptr;\n> +\t\t\t}\n>  \n> -\t\tfb->planes_.push_back({ handle });\n> +\t\t\tfb->planes_[fd] = { handle };\n> +\t\t} else {\n> +\t\t\thandle = iter->second.handle;\n> +\t\t}\n>  \n>  \t\thandles[i] = handle;\n>  \t\toffsets[i] = plane.offset;\n> diff --git a/src/cam/drm.h b/src/cam/drm.h\n> index 00f7e798b771..0b88f9a33912 100644\n> --- a/src/cam/drm.h\n> +++ b/src/cam/drm.h\n> @@ -242,7 +242,7 @@ private:\n>  \n>  \tFrameBuffer(Device *dev);\n>  \n> -\tstd::vector<Plane> planes_;\n> +\tstd::map<int, Plane> planes_;\n>  };\n>  \n>  class AtomicRequest\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A8766BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:32:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 208E460503;\n\tMon,  6 Sep 2021 11:32:13 +0200 (CEST)","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 D0EA460503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:32:11 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7D9E38D7;\n\tMon,  6 Sep 2021 11:32:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"qQdNmMZG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630920731;\n\tbh=0cpeVz+VT2Pnk3PqC1wTg8N3InrxxS0u6gnaNjGBr2Q=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=qQdNmMZGNEGAWQmhjc4OdkwEZyBel6Ekt8buBl9w7Zxqn1f/x1CoC/6bBqMFaQIUU\n\tyaF2Zub3HXwydr+baf6qbN9ShhuxSxCifvN9sfMZwpU6ESu9pheHNZA7dbuR3HtGy8\n\tBgsNswrwraJG9Fd88M6iOUWFi01e4jdZ3dMWPJ6Q=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-24-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<6c8b6cdc-4a2c-f415-ce6b-5b9f806be8e1@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:32:09 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-24-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 23/27] cam: drm: Avoid importing\n\tthe same dmabuf multiple times","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19415,"web_url":"https://patchwork.libcamera.org/comment/19415/","msgid":"<49bc88d3-05ed-7c27-cbbc-56180067d48d@ideasonboard.com>","date":"2021-09-06T09:36:10","subject":"Re: [libcamera-devel] [PATCH v2 25/27] qcam: Use Image class to\n\taccess pixel data","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Replace the manual implementation of frame buffer mapping with the Image\n> class to improve code sharing. The ViewFinder API is updated to take an\n> Image pointer in the render() function to prepare for multi-planar\n> buffer support.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/qcam/main_window.cpp   | 31 ++++++++-----------------------\n>  src/qcam/main_window.h     |  4 ++--\n>  src/qcam/meson.build       |  1 +\n>  src/qcam/viewfinder.h      |  6 +++---\n>  src/qcam/viewfinder_gl.cpp |  7 ++++---\n>  src/qcam/viewfinder_gl.h   |  2 +-\n>  src/qcam/viewfinder_qt.cpp |  6 +++---\n>  src/qcam/viewfinder_qt.h   |  2 +-\n>  8 files changed, 23 insertions(+), 36 deletions(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 0a00b1001570..168dd5ce30e3 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -7,10 +7,9 @@\n>  \n>  #include \"main_window.h\"\n>  \n> +#include <assert.h>\n>  #include <iomanip>\n>  #include <string>\n> -#include <sys/mman.h>\n> -#include <unistd.h>\n>  \n>  #include <QComboBox>\n>  #include <QCoreApplication>\n> @@ -29,6 +28,7 @@\n>  #include <libcamera/camera_manager.h>\n>  #include <libcamera/version.h>\n>  \n> +#include \"../cam/image.h\"\n>  #include \"dng_writer.h\"\n>  #ifndef QT_NO_OPENGL\n>  #include \"viewfinder_gl.h\"\n> @@ -473,15 +473,10 @@ int MainWindow::startCapture()\n>  \n>  \t\tfor (const std::unique_ptr<FrameBuffer> &buffer : allocator_->buffers(stream)) {\n>  \t\t\t/* Map memory buffers and cache the mappings. */\n> -\t\t\tconst FrameBuffer::Plane &plane = buffer->planes().front();\n> -\t\t\tsize_t length = lseek(plane.fd.fd(), 0, SEEK_END);\n> -\t\t\tvoid *memory = mmap(NULL, length, PROT_READ, MAP_SHARED,\n> -\t\t\t\t\t    plane.fd.fd(), 0);\n> -\n> -\t\t\tmappedBuffers_[buffer.get()] = { static_cast<uint8_t *>(memory),\n> -\t\t\t\t\t\t\t plane.length };\n> -\t\t\tplaneData_[buffer.get()] = { static_cast<uint8_t *>(memory) + plane.offset,\n> -\t\t\t\t\t\t     plane.length };\n> +\t\t\tstd::unique_ptr<Image> image =\n> +\t\t\t\tImage::fromFrameBuffer(buffer.get(), Image::MapMode::ReadOnly);\n> +\t\t\tassert(image != nullptr);\n> +\t\t\tmappedBuffers_[buffer.get()] = std::move(image);\n>  \n>  \t\t\t/* Store buffers on the free list. */\n>  \t\t\tfreeBuffers_[stream].enqueue(buffer.get());\n> @@ -543,12 +538,7 @@ error_disconnect:\n>  error:\n>  \trequests_.clear();\n>  \n> -\tfor (auto &iter : mappedBuffers_) {\n> -\t\tconst Span<uint8_t> &buffer = iter.second;\n> -\t\tmunmap(buffer.data(), buffer.size());\n> -\t}\n>  \tmappedBuffers_.clear();\n> -\tplaneData_.clear();\n>  \n>  \tfreeBuffers_.clear();\n>  \n> @@ -580,12 +570,7 @@ void MainWindow::stopCapture()\n>  \n>  \tcamera_->requestCompleted.disconnect(this);\n>  \n> -\tfor (auto &iter : mappedBuffers_) {\n> -\t\tconst Span<uint8_t> &buffer = iter.second;\n> -\t\tmunmap(buffer.data(), buffer.size());\n> -\t}\n>  \tmappedBuffers_.clear();\n> -\tplaneData_.clear();\n>  \n>  \trequests_.clear();\n>  \tfreeQueue_.clear();\n> @@ -682,7 +667,7 @@ void MainWindow::processRaw(FrameBuffer *buffer,\n>  \t\t\t\t\t\t\t\"DNG Files (*.dng)\");\n>  \n>  \tif (!filename.isEmpty()) {\n> -\t\tuint8_t *memory = planeData_[buffer].data();\n> +\t\tuint8_t *memory = mappedBuffers_[buffer]->data(0).data();\n>  \t\tDNGWriter::write(filename.toStdString().c_str(), camera_.get(),\n>  \t\t\t\t rawStream_->configuration(), metadata, buffer,\n>  \t\t\t\t memory);\n> @@ -766,7 +751,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)\n>  \t\t<< \"fps:\" << Qt::fixed << qSetRealNumberPrecision(2) << fps;\n>  \n>  \t/* Render the frame on the viewfinder. */\n> -\tviewfinder_->render(buffer, planeData_[buffer]);\n> +\tviewfinder_->render(buffer, mappedBuffers_[buffer].get());\n>  }\n>  \n>  void MainWindow::queueRequest(FrameBuffer *buffer)\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index 28244bca58b2..a16bea09eadc 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -34,6 +34,7 @@ using namespace libcamera;\n>  class QAction;\n>  class QComboBox;\n>  \n> +class Image;\n>  class HotplugEvent;\n>  \n>  enum {\n> @@ -106,8 +107,7 @@ private:\n>  \tFrameBufferAllocator *allocator_;\n>  \n>  \tstd::unique_ptr<CameraConfiguration> config_;\n> -\tstd::map<FrameBuffer *, Span<uint8_t>> mappedBuffers_;\n> -\tstd::map<FrameBuffer *, Span<uint8_t>> planeData_;\n> +\tstd::map<FrameBuffer *, std::unique_ptr<Image>> mappedBuffers_;\n>  \n>  \t/* Capture state, buffers queue and statistics */\n>  \tbool isCapturing_;\n> diff --git a/src/qcam/meson.build b/src/qcam/meson.build\n> index 7d3621c93d41..c46f463130cd 100644\n> --- a/src/qcam/meson.build\n> +++ b/src/qcam/meson.build\n> @@ -15,6 +15,7 @@ endif\n>  qcam_enabled = true\n>  \n>  qcam_sources = files([\n> +    '../cam/image.cpp',\n>      '../cam/options.cpp',\n>      '../cam/stream_options.cpp',\n\nI never realized we were referencing as much \"../cam\" !\n\n>      'format_converter.cpp',\n> diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\n> index 42d40f1f33f0..fb462835fb5f 100644\n> --- a/src/qcam/viewfinder.h\n> +++ b/src/qcam/viewfinder.h\n> @@ -11,11 +11,11 @@\n>  #include <QList>\n>  #include <QSize>\n>  \n> -#include <libcamera/base/span.h>\n> -\n>  #include <libcamera/formats.h>\n>  #include <libcamera/framebuffer.h>\n>  \n> +class Image;\n> +\n>  class ViewFinder\n>  {\n>  public:\n> @@ -24,7 +24,7 @@ public:\n>  \tvirtual const QList<libcamera::PixelFormat> &nativeFormats() const = 0;\n>  \n>  \tvirtual int setFormat(const libcamera::PixelFormat &format, const QSize &size) = 0;\n> -\tvirtual void render(libcamera::FrameBuffer *buffer, libcamera::Span<uint8_t> mem) = 0;\n> +\tvirtual void render(libcamera::FrameBuffer *buffer, Image *image) = 0;\n>  \tvirtual void stop() = 0;\n>  \n>  \tvirtual QImage getCurrentImage() = 0;\n> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> index d2ef036974f4..87e4fe03cb8d 100644\n> --- a/src/qcam/viewfinder_gl.cpp\n> +++ b/src/qcam/viewfinder_gl.cpp\n> @@ -13,6 +13,8 @@\n>  \n>  #include <libcamera/formats.h>\n>  \n> +#include \"../cam/image.h\"\n\nWhere should Image class be in the end, once stable enough ?\n\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> +\n>  static const QList<libcamera::PixelFormat> supportedFormats{\n>  \t/* YUV - packed (single plane) */\n>  \tlibcamera::formats::UYVY,\n> @@ -110,8 +112,7 @@ QImage ViewFinderGL::getCurrentImage()\n>  \treturn grabFramebuffer();\n>  }\n>  \n> -void ViewFinderGL::render(libcamera::FrameBuffer *buffer,\n> -\t\t\t  libcamera::Span<uint8_t> mem)\n> +void ViewFinderGL::render(libcamera::FrameBuffer *buffer, Image *image)\n>  {\n>  \tif (buffer->planes().size() != 1) {\n>  \t\tqWarning() << \"Multi-planar buffers are not supported\";\n> @@ -121,7 +122,7 @@ void ViewFinderGL::render(libcamera::FrameBuffer *buffer,\n>  \tif (buffer_)\n>  \t\trenderComplete(buffer_);\n>  \n> -\tdata_ = mem.data();\n> +\tdata_ = image->data(0).data();\n>  \t/*\n>  \t * \\todo Get the stride from the buffer instead of computing it naively\n>  \t */\n> diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h\n> index 3334549e0be4..7cd8ef3316b9 100644\n> --- a/src/qcam/viewfinder_gl.h\n> +++ b/src/qcam/viewfinder_gl.h\n> @@ -39,7 +39,7 @@ public:\n>  \tconst QList<libcamera::PixelFormat> &nativeFormats() const override;\n>  \n>  \tint setFormat(const libcamera::PixelFormat &format, const QSize &size) override;\n> -\tvoid render(libcamera::FrameBuffer *buffer, libcamera::Span<uint8_t> mem) override;\n> +\tvoid render(libcamera::FrameBuffer *buffer, Image *image) override;\n>  \tvoid stop() override;\n>  \n>  \tQImage getCurrentImage() override;\n> diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp\n> index a0bf99b0b522..fef6d53eef5e 100644\n> --- a/src/qcam/viewfinder_qt.cpp\n> +++ b/src/qcam/viewfinder_qt.cpp\n> @@ -19,6 +19,7 @@\n>  \n>  #include <libcamera/formats.h>\n>  \n> +#include \"../cam/image.h\"\n>  #include \"format_converter.h\"\n>  \n>  static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats\n> @@ -78,15 +79,14 @@ int ViewFinderQt::setFormat(const libcamera::PixelFormat &format,\n>  \treturn 0;\n>  }\n>  \n> -void ViewFinderQt::render(libcamera::FrameBuffer *buffer,\n> -\t\t\t  libcamera::Span<uint8_t> mem)\n> +void ViewFinderQt::render(libcamera::FrameBuffer *buffer, Image *image)\n>  {\n>  \tif (buffer->planes().size() != 1) {\n>  \t\tqWarning() << \"Multi-planar buffers are not supported\";\n>  \t\treturn;\n>  \t}\n>  \n> -\tunsigned char *memory = mem.data();\n> +\tunsigned char *memory = image->data(0).data();\n>  \tsize_t size = buffer->metadata().planes()[0].bytesused;\n>  \n>  \t{\n> diff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h\n> index 1a569b9cee6e..6b48ef48a7d1 100644\n> --- a/src/qcam/viewfinder_qt.h\n> +++ b/src/qcam/viewfinder_qt.h\n> @@ -32,7 +32,7 @@ public:\n>  \tconst QList<libcamera::PixelFormat> &nativeFormats() const override;\n>  \n>  \tint setFormat(const libcamera::PixelFormat &format, const QSize &size) override;\n> -\tvoid render(libcamera::FrameBuffer *buffer, libcamera::Span<uint8_t> mem) override;\n> +\tvoid render(libcamera::FrameBuffer *buffer, Image *image) override;\n>  \tvoid stop() override;\n>  \n>  \tQImage getCurrentImage() override;\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BD551BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:36:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3A4696916A;\n\tMon,  6 Sep 2021 11:36:15 +0200 (CEST)","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 C832C60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:36:13 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4907A8D7;\n\tMon,  6 Sep 2021 11:36:13 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"JN1Px4ab\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630920973;\n\tbh=yf35kZEbQnh877XYo04t1wxLrdwlXThk34PsuxOFh5E=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=JN1Px4abKhc7kTa03oQFE0z4xjQa5tERxMVBYPqis5NmBneAFc9Xkkls9kda2gvY+\n\tNz7eIwRIeKD1I56iH1HfQrV+PBwminUd/hQxbBWdM9yreAXe21+U871vQBwxBOL0Za\n\tSEB0/ASt00VR+9qCXeQNtmrLxD/S04Fbyi3RtXa8=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-26-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<49bc88d3-05ed-7c27-cbbc-56180067d48d@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:36:10 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-26-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 25/27] qcam: Use Image class to\n\taccess pixel data","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19416,"web_url":"https://patchwork.libcamera.org/comment/19416/","msgid":"<0af321a7-1618-f897-2ddf-63359a139260@ideasonboard.com>","date":"2021-09-06T09:37:02","subject":"Re: [libcamera-devel] [PATCH v2 26/27] qcam: viewfinder_gl: Support\n\tmulti-planar buffers","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/09/2021 04:00, Laurent Pinchart wrote:\n> Now that the ViewFinderGL receives an Image, it can trivially support\n> multi-planar buffers.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/qcam/viewfinder_gl.cpp | 38 +++++++++++++++++---------------------\n>  src/qcam/viewfinder_gl.h   |  2 +-\n>  2 files changed, 18 insertions(+), 22 deletions(-)\n> \n> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> index 87e4fe03cb8d..32232faa2ad8 100644\n> --- a/src/qcam/viewfinder_gl.cpp\n> +++ b/src/qcam/viewfinder_gl.cpp\n> @@ -56,7 +56,7 @@ static const QList<libcamera::PixelFormat> supportedFormats{\n>  };\n>  \n>  ViewFinderGL::ViewFinderGL(QWidget *parent)\n> -\t: QOpenGLWidget(parent), buffer_(nullptr), data_(nullptr),\n> +\t: QOpenGLWidget(parent), buffer_(nullptr), image_(nullptr),\n>  \t  vertexBuffer_(QOpenGLBuffer::VertexBuffer)\n>  {\n>  }\n> @@ -102,6 +102,7 @@ void ViewFinderGL::stop()\n>  \tif (buffer_) {\n>  \t\trenderComplete(buffer_);\n>  \t\tbuffer_ = nullptr;\n> +\t\timage_ = nullptr;\n>  \t}\n>  }\n>  \n> @@ -114,15 +115,10 @@ QImage ViewFinderGL::getCurrentImage()\n>  \n>  void ViewFinderGL::render(libcamera::FrameBuffer *buffer, Image *image)\n>  {\n> -\tif (buffer->planes().size() != 1) {\n> -\t\tqWarning() << \"Multi-planar buffers are not supported\";\n> -\t\treturn;\n> -\t}\n> -\n>  \tif (buffer_)\n>  \t\trenderComplete(buffer_);\n>  \n> -\tdata_ = image->data(0).data();\n> +\timage_ = image;\n>  \t/*\n>  \t * \\todo Get the stride from the buffer instead of computing it naively\n>  \t */\n> @@ -489,7 +485,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \n>  \t\t/* Activate texture UV/VU */\n> @@ -503,7 +499,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE_ALPHA,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_ + size_.width() * size_.height());\n> +\t\t\t     image_->data(1).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n>  \t\tbreak;\n>  \n> @@ -519,7 +515,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \n>  \t\t/* Activate texture U */\n> @@ -533,7 +529,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_ + size_.width() * size_.height());\n> +\t\t\t     image_->data(1).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n>  \n>  \t\t/* Activate texture V */\n> @@ -547,7 +543,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_ + size_.width() * size_.height() * 5 / 4);\n> +\t\t\t     image_->data(2).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformV_, 2);\n>  \t\tbreak;\n>  \n> @@ -563,7 +559,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \n>  \t\t/* Activate texture V */\n> @@ -577,7 +573,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_ + size_.width() * size_.height());\n> +\t\t\t     image_->data(1).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformV_, 2);\n>  \n>  \t\t/* Activate texture U */\n> @@ -591,7 +587,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_ + size_.width() * size_.height() * 5 / 4);\n> +\t\t\t     image_->data(2).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n>  \t\tbreak;\n>  \n> @@ -602,7 +598,7 @@ void ViewFinderGL::doRender()\n>  \t\t/*\n>  \t\t * Packed YUV formats are stored in a RGBA texture to match the\n>  \t\t * OpenGL texel size with the 4 bytes repeating pattern in YUV.\n> -\t\t * The texture width is thus half of the image with.\n> +\t\t * The texture width is thus half of the image_ with.\n>  \t\t */\n>  \t\tglActiveTexture(GL_TEXTURE0);\n>  \t\tconfigureTexture(*textures_[0]);\n> @@ -614,7 +610,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_RGBA,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \n>  \t\t/*\n> @@ -642,7 +638,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_RGBA,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \t\tbreak;\n>  \n> @@ -658,7 +654,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_RGB,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \t\tbreak;\n>  \n> @@ -689,7 +685,7 @@ void ViewFinderGL::doRender()\n>  \t\t\t     0,\n>  \t\t\t     GL_LUMINANCE,\n>  \t\t\t     GL_UNSIGNED_BYTE,\n> -\t\t\t     data_);\n> +\t\t\t     image_->data(0).data());\n>  \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n>  \t\tshaderProgram_.setUniformValue(textureUniformBayerFirstRed_,\n>  \t\t\t\t\t       firstRed_);\n> @@ -714,7 +710,7 @@ void ViewFinderGL::paintGL()\n>  \t\t\t\t   << \"create fragment shader failed.\";\n>  \t\t}\n>  \n> -\tif (data_) {\n> +\tif (image_) {\n>  \t\tglClearColor(0.0, 0.0, 0.0, 1.0);\n>  \t\tglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n>  \n> diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h\n> index 7cd8ef3316b9..72a60ecb9159 100644\n> --- a/src/qcam/viewfinder_gl.h\n> +++ b/src/qcam/viewfinder_gl.h\n> @@ -67,7 +67,7 @@ private:\n>  \tlibcamera::PixelFormat format_;\n>  \tQSize size_;\n>  \tunsigned int stride_;\n> -\tunsigned char *data_;\n> +\tImage *image_;\n>  \n>  \t/* Shaders */\n>  \tQOpenGLShaderProgram shaderProgram_;\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DB92DBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 09:37:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A4A6C6916A;\n\tMon,  6 Sep 2021 11:37:06 +0200 (CEST)","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 5E66F60503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 11:37:05 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb18:8e30:9b7:f998])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 19ED68D7;\n\tMon,  6 Sep 2021 11:37:05 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nPVeTluI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630921025;\n\tbh=FIfPpCv37w8SE2ZUjQqC/zQfkSRnR7PhedkZv/OApHQ=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=nPVeTluIq+K2gMSP6UQ3LiYcR0DCZq8D8GvCVJQL47HZ8BKPN2CgyjSBD0U++pUM7\n\t8morHfNhc/2rUJPMG/nDsdDT1Al8qKVR9hd9ZVHv1crDiRIqlhaexZsoP1nNODULqj\n\tpkqRwWmvREZ+DJwUSqxbaYiBPmBVwBczLRcN594s=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-27-laurent.pinchart@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<0af321a7-1618-f897-2ddf-63359a139260@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:37:02 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-27-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 26/27] qcam: viewfinder_gl: Support\n\tmulti-planar buffers","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19418,"web_url":"https://patchwork.libcamera.org/comment/19418/","msgid":"<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>","date":"2021-09-06T10:08:04","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent\n\nOn 9/6/21 7:30 AM, Laurent Pinchart wrote:\n> Hello everybody,\n>\n> This patch series started as an investigation of a qcam failure with\n> IPU3 after the merge of the FrameBuffer offset support. While a hack in\n> qcam would be possible, I decided to instead address the core issue and\n> fix it in V4L2VideoDevice.\n>\n> Compared to v1, the series now includes fixes for cam and qcam in\n> addition to the changes needed in the libcamera core. They have been\n> tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n>\n> The GStreamer element seems to work fine without any change required.\n> The V4L2 compatibility layer is still broken, and I haven't tested the\n> Android HAL yet (any volunteer ?).\n\n\nI am applied this series on top of master and tested on nautilus. \nStreaming seems fine to me, although it was appearing more choppy than \nusual.\n\nNow that I see, entire nautilus seems laggy to respond in general. One \n\"Chrome\" process hogging 50% CPU, seems like a transient issue.\n\nSo, streaming seems fine on multiple runs, with multiple resolutions \nselections (from the camera-app menu), however, requesting MJPEG \n(shutter-click) results in a segfault.\n\nThe stack trace is below:\n\n[0:24:11.415660787] [10635] DEBUG HAL camera_device.cpp:941 \n'\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750235824 with 2 streams\n[0:24:11.415858538] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is \nnot contiguous\n[0:24:11.415905500] [10635] DEBUG HAL camera_device.cpp:980 \n'\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] \n(direct)\n[0:24:11.415943620] [10635] DEBUG HAL camera_device.cpp:966 \n'\\_SB_.PCI0.I2C2.CAM0': 1 - (4160x3104)[0x00000021] -> (4160x3104)[NV12] \n(mapped)\n[0:24:11.416461639] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video0[37:cap]: Queueing buffer 3\n[0:24:11.428903141] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video0[37:cap]: Dequeuing buffer 2\n[0:24:11.429095316] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature \nestimated: 6644\n[0:24:11.429563781] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:237 frame 193 started\n[0:24:11.429627478] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:272 Setting Exposure to 269 at index 193\n[0:24:11.429683048] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video6[25:cap]: Queueing buffer 1\n[0:24:11.436615191] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video5[27:out]: Queueing buffer 2\n[0:24:11.436718629] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video8[28:cap]: Queueing buffer 2\n[0:24:11.436799420] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video4[24:out]: Queueing buffer 2\n[0:24:11.457388821] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video4[24:out]: Dequeuing buffer 1\n[0:24:11.457948159] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video6[25:cap]: Dequeuing buffer 0\n[0:24:11.458257692] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video5[27:out]: Dequeuing buffer 2\n[0:24:11.458525315] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video8[28:cap]: Dequeuing buffer 1\n[0:24:11.458968848] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n[0:24:11.459005634] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n[0:24:11.459082715] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for \nred: 1.16864 and for blue: 1.14863\n[0:24:11.459325998] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:179 Queuing Exposure to 269 at index 194\n[0:24:11.459562485] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 194\n[0:24:11.459815347] [10629] DEBUG Request request.cpp:291 \nRequest(129:C:0/1:140736750229136)\n[0:24:11.460390126] [10629] DEBUG HAL camera_device.cpp:1117 \n'\\_SB_.PCI0.I2C2.CAM0': Request 140736750229136 completed with 1 streams\n[0:24:11.461855854] [10635] DEBUG Request request.cpp:94 Created request \n- cookie: 140736750230064\n[0:24:11.461939858] [10635] DEBUG HAL camera_device.cpp:941 \n'\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750230064 with 1 streams\n[0:24:11.462057435] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is \nnot contiguous\n[0:24:11.462098906] [10635] DEBUG HAL camera_device.cpp:980 \n'\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] \n(direct)\n[0:24:11.463164722] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:237 frame 194 started\n[0:24:11.463730946] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:272 Setting Analogue Gain to 477 at index 193\n[0:24:11.464033686] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:272 Setting Exposure to 269 at index 194\n[0:24:11.464329869] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video0[37:cap]: Queueing buffer 0\n[0:24:11.495739092] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:237 frame 195 started\n[0:24:11.496489311] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:272 Setting Analogue Gain to 477 at index 194\n[0:24:11.496737385] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:285 Queue is empty, auto queue no-op.\n[0:24:11.497044311] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video0[37:cap]: Dequeuing buffer 3\n[0:24:11.497335155] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature \nestimated: 6658\n[0:24:11.497528845] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video6[25:cap]: Queueing buffer 2\n[0:24:11.503589322] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video5[27:out]: Queueing buffer 3\n[0:24:11.504027344] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video8[28:cap]: Queueing buffer 3\n[0:24:11.504287330] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video4[24:out]: Queueing buffer 3\n[0:24:11.504712501] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video4[24:out]: Dequeuing buffer 2\n[0:24:11.505005096] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video6[25:cap]: Dequeuing buffer 1\n[0:24:11.505260331] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video5[27:out]: Dequeuing buffer 3\n[0:24:11.505506837] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video8[28:cap]: Dequeuing buffer 2\n[0:24:11.505940926] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n[0:24:11.505976974] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n[0:24:11.506057427] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for \nred: 1.16797 and for blue: 1.14978\n[0:24:11.506297848] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:179 Queuing Exposure to 269 at index 196\n[0:24:11.506547021] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 196\n[0:24:11.506796456] [10629] DEBUG Request request.cpp:291 \nRequest(130:C:0/1:140736750225984)\n[0:24:11.507374522] [10629] DEBUG HAL camera_device.cpp:1117 \n'\\_SB_.PCI0.I2C2.CAM0': Request 140736750225984 completed with 1 streams\n[0:24:11.509426987] [10635] DEBUG Request request.cpp:94 Created request \n- cookie: 140736750227664\n[0:24:11.509507039] [10635] DEBUG HAL camera_device.cpp:941 \n'\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750227664 with 1 streams\n[0:24:11.509630706] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is \nnot contiguous\n[0:24:11.509675200] [10635] DEBUG HAL camera_device.cpp:980 \n'\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] \n(direct)\n[0:24:11.511309605] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 \n/dev/video0[37:cap]: Queueing buffer 1\n[0:24:11.528984601] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:237 frame 196 started\n[0:24:11.529446048] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:272 Setting Exposure to 269 at index 196\n[0:24:11.548431632] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video4[24:out]: Dequeuing buffer 3\n[0:24:11.548993830] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video6[25:cap]: Dequeuing buffer 2\n[0:24:11.549320802] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 \n/dev/video8[28:cap]: Dequeuing buffer 3\n[0:24:11.549807736] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n[0:24:11.549846777] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n[0:24:11.549927350] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for \nred: 1.16841 and for blue: 1.14912\n[0:24:11.550170924] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:179 Queuing Exposure to 269 at index 197\n[0:24:11.550405629] [10629] DEBUG DelayedControls \ndelayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 197\n[0:24:11.550646460] [10629] DEBUG Request request.cpp:291 \nRequest(131:C:0/1:140736750235824)\n[0:24:11.551245104] [10629] DEBUG HAL camera_device.cpp:1117 \n'\\_SB_.PCI0.I2C2.CAM0': Request 140736750235824 completed with 2 streams\n[0:24:11.562307680] [10629] DEBUG EXIF exif.cpp:522 Created EXIF \ninstance (536 bytes)\n[0:24:11.634800113] [10629] DEBUG JPEG encoder_libjpeg.cpp:220 JPEG \nEncode Starting:4160x3104\n\nThread 6 \"CameraModuleThr\" received signal SIGSEGV, Segmentation fault.\n[Switching to Thread 0x7fffe7fff640 (LWP 10629)]\n0x00007ffff597ead5 in \nEncoderLibJpeg::compressNV(libcamera::Span<unsigned char const, \n18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n(gdb) bt\n#0  0x00007ffff597ead5 in \nEncoderLibJpeg::compressNV(libcamera::Span<unsigned char const, \n18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n#1  0x00007ffff597eda0 in \nEncoderLibJpeg::encode(libcamera::Span<unsigned char const, \n18446744073709551615ul>, libcamera::Span<unsigned char, \n18446744073709551615ul>, libcamera::Span<unsigned char const, \n18446744073709551615ul>, unsigned int) () from \n/usr/lib64/camera_hal/libcamera-hal.so\n#2  0x00007ffff597ec53 in EncoderLibJpeg::encode(libcamera::FrameBuffer \nconst&, libcamera::Span<unsigned char, 18446744073709551615ul>, \nlibcamera::Span<unsigned char const, 18446744073709551615ul>, unsigned \nint) () from /usr/lib64/camera_hal/libcamera-hal.so\n#3  0x00007ffff5981871 in \nPostProcessorJpeg::process(libcamera::FrameBuffer const&, CameraBuffer*, \nCameraMetadata const&, CameraMetadata*) ()\n    from /usr/lib64/camera_hal/libcamera-hal.so\n#4  0x00007ffff597dd8d in CameraStream::process(libcamera::FrameBuffer \nconst&, native_handle const*, CameraMetadata const&, CameraMetadata*) ()\n    from /usr/lib64/camera_hal/libcamera-hal.so\n#5  0x00007ffff59717b9 in \nCameraDevice::requestComplete(libcamera::Request*) () from \n/usr/lib64/camera_hal/libcamera-hal.so\n#6  0x00007ffff5979a7c in libcamera::BoundMethodMember<CameraDevice, \nvoid, libcamera::Request*>::activate(libcamera::Request*, bool) ()\n    from /usr/lib64/camera_hal/libcamera-hal.so\n#7  0x00007ffff58f9051 in libcamera::Signal<libcamera::IPCMessage \nconst&>::emit(libcamera::IPCMessage const&) () from /usr/lib64/libcamera.so\n#8  0x00007ffff58f8fe8 in \nlibcamera::Camera::requestComplete(libcamera::Request*) () from \n/usr/lib64/libcamera.so\n#9  0x00007ffff591f28a in \nlibcamera::PipelineHandler::completeRequest(libcamera::Request*) () from \n/usr/lib64/libcamera.so\n#10 0x00007ffff5935cef in \nlibcamera::IPU3CameraData::queueFrameAction(unsigned int, \nlibcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n#11 0x00007ffff58f0b02 in \nlibcamera::BoundMethodMember<libcamera::ipa::ipu3::IPAProxyIPU3, void, \nunsigned int, libcamera::ipa::ipu3::IPU3Action \nconst&>::activate(unsigned int, libcamera::ipa::ipu3::IPU3Action const&, \nbool) () from /usr/lib64/libcamera.so\n#12 0x00007ffff58edf81 in libcamera::Signal<unsigned int, \nlibcamera::ipa::ipu3::IPU3Action const&>::emit(unsigned int, \nlibcamera::ipa::ipu3::IPU3Action const&) ()\n    from /usr/lib64/libcamera.so\n#13 0x00007ffff58eb5b4 in \nlibcamera::ipa::ipu3::IPAProxyIPU3::queueFrameActionThread(unsigned int, \nlibcamera::ipa::ipu3::IPU3Action const&) ()\n    from /usr/lib64/libcamera.so\n#14 0x00007ffff587caed in \nlibcamera::Object::message(libcamera::Message*) () from \n/usr/lib64/libcamera-base.so\n#15 0x00007ffff587e00b in \nlibcamera::Thread::dispatchMessages(libcamera::Message::Type) () from \n/usr/lib64/libcamera-base.so\n#16 0x00007ffff5876925 in \nlibcamera::EventDispatcherPoll::processEvents() () from \n/usr/lib64/libcamera-base.so\n#17 0x00007ffff587d6e2 in libcamera::Thread::exec() () from \n/usr/lib64/libcamera-base.so\n#18 0x00007ffff58fb582 in libcamera::CameraManager::Private::run() () \nfrom /usr/lib64/libcamera.so\n#19 0x00007ffff587e43c in ?? () from /usr/lib64/libcamera-base.so\n#20 0x0000000000000000 in ?? ()\n\n\n>\n> The most important change is in patches 13/27 and 14/27, which translate\n> between V4L2 buffers and libcamera FrameBuffer to handle the case where\n> a multi-planar frame buffer is used with the V4L2 single-planar API.\n> It's working more or less by chance at the moment (except in qcam where\n> it's broken, and possibly in other places I haven't tested). Patches\n> 01/27 to 12/27 are cleanups and additions to prepare for the work in\n> V4L2VideoDevice, and patch 15/27 is a small cleanup on top. Patches\n> 16/27 and 17/27 then improve the FrameBuffer class API as a cleanup.\n>\n> Patches 18/27 to 27/27 fix the cam and qcam applications, as well as an\n> issue in the Android HAL. Worth being noted is patch 19/27 that\n> introduces an Image class shared by cam and qcam. The class duplicates\n> the MappedFrameBuffer implementation private to libcamera. I've tried to\n> rework MappedFrameBuffer into something I would be happy to see in the\n> public API, but failed to do so in a reasonable amount of time, and I\n> didn't want to delay this important regression fix.\n>\n> This series doesn't break any unit test, as vimc doesn't support NV12.\n> Addition of NV12 support to the vimc kernel driver would be very nice,\n> in order to test multi-planar support in our unit tests. Volunteers are\n> welcome ;-)\n>\n> Laurent Pinchart (27):\n>    libcamera: base: utils: Use size_t for index in utils::enumerate()\n>    libcamera: file_descriptor: Add a function to retrieve the inode\n>    libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()\n>    libcamera: Use V4L2PixelFormat::fromPixelFormat()\n>    libcamera: formats: Move plane info structure to PixelFormatInfo\n>    libcamera: formats: Add planeSize() helpers to PixelFormatInfo\n>    libcamera: formats: Support V4L2 non-contiguous formats\n>    libcamera: framebuffer: Move planes check to constructor\n>    libcamera: framebuffer: Add a function to check if planes are\n>      contiguous\n>    libcamera: v4l2_videodevice: Cache PixelFormatInfo\n>    libcamera: v4l2_videodevice: Document plane handling in createBuffer()\n>    libcamera: v4l2_videodevice: Take stride into account to compute\n>      offsets\n>    libcamera: v4l2_videodevice: Coalesce planes when queuing buffer\n>    libcamera: v4l2_videodevice: Split planes when dequeuing buffer\n>    libcamera: v4l2_videodevice: Use utils::enumerate()\n>    libcamera: framebuffer: Allocate metadata planes at construction time\n>    libcamera: framebuffer: Prevent modifying the number of metadata\n>      planes\n>    android: camera_device: Don't assume all planes use the same fd\n>    cam: Add Image class\n>    cam: file_sink: Use Image class to access pixel data\n>    cam: drm: Support per-plane stride values\n>    cam: drm: Set per-plane offsets when creating DRM frame buffer\n>    cam: drm: Avoid importing the same dmabuf multiple times\n>    qcam: Print bytesused for all planes\n>    qcam: Use Image class to access pixel data\n>    qcam: viewfinder_gl: Support multi-planar buffers\n>    qcam: viewfinder_qt: Support multi-planar buffers\n>\n>   include/libcamera/base/utils.h                |   4 +-\n>   include/libcamera/file_descriptor.h           |   3 +\n>   include/libcamera/framebuffer.h               |  19 +-\n>   include/libcamera/internal/formats.h          |  22 +-\n>   include/libcamera/internal/framebuffer.h      |   2 +\n>   include/libcamera/internal/v4l2_pixelformat.h |   2 +-\n>   include/libcamera/internal/v4l2_videodevice.h |   3 +-\n>   src/android/camera_device.cpp                 |  25 +-\n>   src/android/mm/generic_camera_buffer.cpp      |  11 +-\n>   src/android/yuv/post_processor_yuv.cpp        |  10 +-\n>   src/cam/camera_session.cpp                    |   4 +-\n>   src/cam/drm.cpp                               |  38 +-\n>   src/cam/drm.h                                 |   7 +-\n>   src/cam/file_sink.cpp                         |  44 +--\n>   src/cam/file_sink.h                           |   6 +-\n>   src/cam/image.cpp                             | 107 +++++\n>   src/cam/image.h                               |  52 +++\n>   src/cam/kms_sink.cpp                          |  28 +-\n>   src/cam/meson.build                           |   1 +\n>   src/libcamera/file_descriptor.cpp             |  26 ++\n>   src/libcamera/formats.cpp                     | 373 ++++++++++++++----\n>   src/libcamera/framebuffer.cpp                 |  57 ++-\n>   src/libcamera/pipeline/ipu3/cio2.cpp          |   4 +-\n>   src/libcamera/pipeline/ipu3/imgu.cpp          |   2 +-\n>   .../pipeline/raspberrypi/raspberrypi.cpp      |   8 +-\n>   src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |   6 +-\n>   src/libcamera/pipeline/simple/converter.cpp   |   8 +-\n>   src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n>   src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   6 +-\n>   src/libcamera/pipeline/vimc/vimc.cpp          |   8 +-\n>   src/libcamera/v4l2_pixelformat.cpp            |  11 +-\n>   src/libcamera/v4l2_videodevice.cpp            | 196 ++++++---\n>   src/qcam/format_converter.cpp                 |  18 +-\n>   src/qcam/format_converter.h                   |   9 +-\n>   src/qcam/main_window.cpp                      |  38 +-\n>   src/qcam/main_window.h                        |   4 +-\n>   src/qcam/meson.build                          |   1 +\n>   src/qcam/viewfinder.h                         |   6 +-\n>   src/qcam/viewfinder_gl.cpp                    |  45 +--\n>   src/qcam/viewfinder_gl.h                      |   4 +-\n>   src/qcam/viewfinder_qt.cpp                    |  20 +-\n>   src/qcam/viewfinder_qt.h                      |   2 +-\n>   src/v4l2/v4l2_camera_proxy.cpp                |  11 +-\n>   test/libtest/buffer_source.cpp                |   3 +-\n>   test/utils.cpp                                |  10 +-\n>   45 files changed, 911 insertions(+), 357 deletions(-)\n>   create mode 100644 src/cam/image.cpp\n>   create mode 100644 src/cam/image.h\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 22E0FBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 10:08:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 96B356916A;\n\tMon,  6 Sep 2021 12:08:11 +0200 (CEST)","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 3121A60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 12:08:10 +0200 (CEST)","from [192.168.1.104] (unknown [103.251.226.180])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 09B5E8AD;\n\tMon,  6 Sep 2021 12:08:08 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dSC1QxZv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630922889;\n\tbh=a0QuDhl7uapzlZOrYBC8DSomN9n7Q8O3g7bc+ebT3/s=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=dSC1QxZv3oeZ/f5chcYtmNxj8lsgzzvfoYiuwy+rPHAtxNaEDwxF/c5BXgi3z6v2L\n\tp660OVAzKUgPRiws3JMjV+bRMhs2bDHS0wcr11FnQDivXD7EbNspgj4sXKzyXnBOZE\n\tcMv9yy0WS8Mv7b38zuH4J6UZdP71KB7GstA6CB/4=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>","Date":"Mon, 6 Sep 2021 15:38:04 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"8bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19420,"web_url":"https://patchwork.libcamera.org/comment/19420/","msgid":"<beb5c318-4b54-accf-a34b-f30d96f60bbc@ideasonboard.com>","date":"2021-09-06T10:43:15","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 06/09/2021 11:08, Umang Jain wrote:\n> Hi Laurent\n> \n> On 9/6/21 7:30 AM, Laurent Pinchart wrote:\n>> Hello everybody,\n>>\n>> This patch series started as an investigation of a qcam failure with\n>> IPU3 after the merge of the FrameBuffer offset support. While a hack in\n>> qcam would be possible, I decided to instead address the core issue and\n>> fix it in V4L2VideoDevice.\n>>\n>> Compared to v1, the series now includes fixes for cam and qcam in\n>> addition to the changes needed in the libcamera core. They have been\n>> tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n>>\n>> The GStreamer element seems to work fine without any change required.\n>> The V4L2 compatibility layer is still broken, and I haven't tested the\n>> Android HAL yet (any volunteer ?).\n> \n> \n> I am applied this series on top of master and tested on nautilus.\n> Streaming seems fine to me, although it was appearing more choppy than\n> usual.\n> \n> Now that I see, entire nautilus seems laggy to respond in general. One\n> \"Chrome\" process hogging 50% CPU, seems like a transient issue.\n> \n> So, streaming seems fine on multiple runs, with multiple resolutions\n> selections (from the camera-app menu), however, requesting MJPEG\n> (shutter-click) results in a segfault.\n> \n> The stack trace is below:\n> \n> [0:24:11.415660787] [10635] DEBUG HAL camera_device.cpp:941\n> '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750235824 with 2 streams\n> [0:24:11.415858538] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n> not contiguous\n> [0:24:11.415905500] [10635] DEBUG HAL camera_device.cpp:980\n> '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n> (direct)\n> [0:24:11.415943620] [10635] DEBUG HAL camera_device.cpp:966\n> '\\_SB_.PCI0.I2C2.CAM0': 1 - (4160x3104)[0x00000021] -> (4160x3104)[NV12]\n> (mapped)\n> [0:24:11.416461639] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video0[37:cap]: Queueing buffer 3\n> [0:24:11.428903141] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video0[37:cap]: Dequeuing buffer 2\n> [0:24:11.429095316] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature\n> estimated: 6644\n> [0:24:11.429563781] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:237 frame 193 started\n> [0:24:11.429627478] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:272 Setting Exposure to 269 at index 193\n> [0:24:11.429683048] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video6[25:cap]: Queueing buffer 1\n> [0:24:11.436615191] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video5[27:out]: Queueing buffer 2\n> [0:24:11.436718629] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video8[28:cap]: Queueing buffer 2\n> [0:24:11.436799420] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video4[24:out]: Queueing buffer 2\n> [0:24:11.457388821] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video4[24:out]: Dequeuing buffer 1\n> [0:24:11.457948159] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video6[25:cap]: Dequeuing buffer 0\n> [0:24:11.458257692] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video5[27:out]: Dequeuing buffer 2\n> [0:24:11.458525315] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video8[28:cap]: Dequeuing buffer 1\n> [0:24:11.458968848] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> [0:24:11.459005634] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> [0:24:11.459082715] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n> red: 1.16864 and for blue: 1.14863\n> [0:24:11.459325998] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:179 Queuing Exposure to 269 at index 194\n> [0:24:11.459562485] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 194\n> [0:24:11.459815347] [10629] DEBUG Request request.cpp:291\n> Request(129:C:0/1:140736750229136)\n> [0:24:11.460390126] [10629] DEBUG HAL camera_device.cpp:1117\n> '\\_SB_.PCI0.I2C2.CAM0': Request 140736750229136 completed with 1 streams\n> [0:24:11.461855854] [10635] DEBUG Request request.cpp:94 Created request\n> - cookie: 140736750230064\n> [0:24:11.461939858] [10635] DEBUG HAL camera_device.cpp:941\n> '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750230064 with 1 streams\n> [0:24:11.462057435] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n> not contiguous\n> [0:24:11.462098906] [10635] DEBUG HAL camera_device.cpp:980\n> '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n> (direct)\n> [0:24:11.463164722] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:237 frame 194 started\n> [0:24:11.463730946] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 193\n> [0:24:11.464033686] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:272 Setting Exposure to 269 at index 194\n> [0:24:11.464329869] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video0[37:cap]: Queueing buffer 0\n> [0:24:11.495739092] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:237 frame 195 started\n> [0:24:11.496489311] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 194\n> [0:24:11.496737385] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:285 Queue is empty, auto queue no-op.\n> [0:24:11.497044311] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video0[37:cap]: Dequeuing buffer 3\n> [0:24:11.497335155] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature\n> estimated: 6658\n> [0:24:11.497528845] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video6[25:cap]: Queueing buffer 2\n> [0:24:11.503589322] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video5[27:out]: Queueing buffer 3\n> [0:24:11.504027344] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video8[28:cap]: Queueing buffer 3\n> [0:24:11.504287330] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video4[24:out]: Queueing buffer 3\n> [0:24:11.504712501] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video4[24:out]: Dequeuing buffer 2\n> [0:24:11.505005096] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video6[25:cap]: Dequeuing buffer 1\n> [0:24:11.505260331] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video5[27:out]: Dequeuing buffer 3\n> [0:24:11.505506837] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video8[28:cap]: Dequeuing buffer 2\n> [0:24:11.505940926] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> [0:24:11.505976974] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> [0:24:11.506057427] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n> red: 1.16797 and for blue: 1.14978\n> [0:24:11.506297848] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:179 Queuing Exposure to 269 at index 196\n> [0:24:11.506547021] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 196\n> [0:24:11.506796456] [10629] DEBUG Request request.cpp:291\n> Request(130:C:0/1:140736750225984)\n> [0:24:11.507374522] [10629] DEBUG HAL camera_device.cpp:1117\n> '\\_SB_.PCI0.I2C2.CAM0': Request 140736750225984 completed with 1 streams\n> [0:24:11.509426987] [10635] DEBUG Request request.cpp:94 Created request\n> - cookie: 140736750227664\n> [0:24:11.509507039] [10635] DEBUG HAL camera_device.cpp:941\n> '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750227664 with 1 streams\n> [0:24:11.509630706] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n> not contiguous\n> [0:24:11.509675200] [10635] DEBUG HAL camera_device.cpp:980\n> '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n> (direct)\n> [0:24:11.511309605] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> /dev/video0[37:cap]: Queueing buffer 1\n> [0:24:11.528984601] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:237 frame 196 started\n> [0:24:11.529446048] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:272 Setting Exposure to 269 at index 196\n> [0:24:11.548431632] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video4[24:out]: Dequeuing buffer 3\n> [0:24:11.548993830] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video6[25:cap]: Dequeuing buffer 2\n> [0:24:11.549320802] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> /dev/video8[28:cap]: Dequeuing buffer 3\n> [0:24:11.549807736] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> [0:24:11.549846777] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> [0:24:11.549927350] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n> red: 1.16841 and for blue: 1.14912\n> [0:24:11.550170924] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:179 Queuing Exposure to 269 at index 197\n> [0:24:11.550405629] [10629] DEBUG DelayedControls\n> delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 197\n> [0:24:11.550646460] [10629] DEBUG Request request.cpp:291\n> Request(131:C:0/1:140736750235824)\n> [0:24:11.551245104] [10629] DEBUG HAL camera_device.cpp:1117\n> '\\_SB_.PCI0.I2C2.CAM0': Request 140736750235824 completed with 2 streams\n> [0:24:11.562307680] [10629] DEBUG EXIF exif.cpp:522 Created EXIF\n> instance (536 bytes)\n> [0:24:11.634800113] [10629] DEBUG JPEG encoder_libjpeg.cpp:220 JPEG\n> Encode Starting:4160x3104\n> \n> Thread 6 \"CameraModuleThr\" received signal SIGSEGV, Segmentation fault.\n> [Switching to Thread 0x7fffe7fff640 (LWP 10629)]\n> 0x00007ffff597ead5 in\n> EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const,\n> 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n> (gdb) bt\n> #0  0x00007ffff597ead5 in\n> EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const,\n> 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #1  0x00007ffff597eda0 in\n> EncoderLibJpeg::encode(libcamera::Span<unsigned char const,\n> 18446744073709551615ul>, libcamera::Span<unsigned char,\n> 18446744073709551615ul>, libcamera::Span<unsigned char const,\n> 18446744073709551615ul>, unsigned int) () from\n> /usr/lib64/camera_hal/libcamera-hal.so\n> #2  0x00007ffff597ec53 in EncoderLibJpeg::encode(libcamera::FrameBuffer\n> const&, libcamera::Span<unsigned char, 18446744073709551615ul>,\n\n18446744073709551615ul is -1, so we've certainly missed\ncapturing/preventing an error code from getting assigned to the span at\nsome point, where it then got stored as an unsigned long.\n\n\nDoes this happen repeatably? or only on some specific event?\n--\nKieran","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E9715BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 10:43:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 59A846916A;\n\tMon,  6 Sep 2021 12:43:19 +0200 (CEST)","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 247CB60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 12:43:18 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82CFB8AD;\n\tMon,  6 Sep 2021 12:43:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QKNq0rj8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630924997;\n\tbh=loOqOcRUZHDj2quOigG6JOSZCspiNjQ3Y6FAykMAffc=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=QKNq0rj8DDYZA06cwzhh/Glmrx8q19bIAFtlVFTu3FxI3Akm3Zqy93ls3lSzy5qn0\n\teSffnlmlSdkpiHyLZUTtKRhrTkCnJeyG4rIMbbN8ImyzD2Jr1+9RnLX4EG03kcDMZi\n\tRAZ7uy2JV5A+SvzY4fdNvnFJNvtxgjpgEXEVuRLE=","To":"Umang Jain <umang.jain@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<beb5c318-4b54-accf-a34b-f30d96f60bbc@ideasonboard.com>","Date":"Mon, 6 Sep 2021 11:43:15 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19423,"web_url":"https://patchwork.libcamera.org/comment/19423/","msgid":"<b186c166-cd38-a8ab-38ab-69307a67ee5c@ideasonboard.com>","date":"2021-09-06T11:06:27","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"On 9/6/21 4:13 PM, Kieran Bingham wrote:\n> On 06/09/2021 11:08, Umang Jain wrote:\n>> Hi Laurent\n>>\n>> On 9/6/21 7:30 AM, Laurent Pinchart wrote:\n>>> Hello everybody,\n>>>\n>>> This patch series started as an investigation of a qcam failure with\n>>> IPU3 after the merge of the FrameBuffer offset support. While a hack in\n>>> qcam would be possible, I decided to instead address the core issue and\n>>> fix it in V4L2VideoDevice.\n>>>\n>>> Compared to v1, the series now includes fixes for cam and qcam in\n>>> addition to the changes needed in the libcamera core. They have been\n>>> tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n>>>\n>>> The GStreamer element seems to work fine without any change required.\n>>> The V4L2 compatibility layer is still broken, and I haven't tested the\n>>> Android HAL yet (any volunteer ?).\n>>\n>> I am applied this series on top of master and tested on nautilus.\n>> Streaming seems fine to me, although it was appearing more choppy than\n>> usual.\n>>\n>> Now that I see, entire nautilus seems laggy to respond in general. One\n>> \"Chrome\" process hogging 50% CPU, seems like a transient issue.\n>>\n>> So, streaming seems fine on multiple runs, with multiple resolutions\n>> selections (from the camera-app menu), however, requesting MJPEG\n>> (shutter-click) results in a segfault.\n>>\n>> The stack trace is below:\n>>\n>> [0:24:11.415660787] [10635] DEBUG HAL camera_device.cpp:941\n>> '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750235824 with 2 streams\n>> [0:24:11.415858538] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n>> not contiguous\n>> [0:24:11.415905500] [10635] DEBUG HAL camera_device.cpp:980\n>> '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n>> (direct)\n>> [0:24:11.415943620] [10635] DEBUG HAL camera_device.cpp:966\n>> '\\_SB_.PCI0.I2C2.CAM0': 1 - (4160x3104)[0x00000021] -> (4160x3104)[NV12]\n>> (mapped)\n>> [0:24:11.416461639] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video0[37:cap]: Queueing buffer 3\n>> [0:24:11.428903141] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video0[37:cap]: Dequeuing buffer 2\n>> [0:24:11.429095316] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature\n>> estimated: 6644\n>> [0:24:11.429563781] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:237 frame 193 started\n>> [0:24:11.429627478] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:272 Setting Exposure to 269 at index 193\n>> [0:24:11.429683048] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video6[25:cap]: Queueing buffer 1\n>> [0:24:11.436615191] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video5[27:out]: Queueing buffer 2\n>> [0:24:11.436718629] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video8[28:cap]: Queueing buffer 2\n>> [0:24:11.436799420] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video4[24:out]: Queueing buffer 2\n>> [0:24:11.457388821] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video4[24:out]: Dequeuing buffer 1\n>> [0:24:11.457948159] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video6[25:cap]: Dequeuing buffer 0\n>> [0:24:11.458257692] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video5[27:out]: Dequeuing buffer 2\n>> [0:24:11.458525315] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video8[28:cap]: Dequeuing buffer 1\n>> [0:24:11.458968848] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n>> [0:24:11.459005634] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n>> [0:24:11.459082715] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n>> red: 1.16864 and for blue: 1.14863\n>> [0:24:11.459325998] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:179 Queuing Exposure to 269 at index 194\n>> [0:24:11.459562485] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 194\n>> [0:24:11.459815347] [10629] DEBUG Request request.cpp:291\n>> Request(129:C:0/1:140736750229136)\n>> [0:24:11.460390126] [10629] DEBUG HAL camera_device.cpp:1117\n>> '\\_SB_.PCI0.I2C2.CAM0': Request 140736750229136 completed with 1 streams\n>> [0:24:11.461855854] [10635] DEBUG Request request.cpp:94 Created request\n>> - cookie: 140736750230064\n>> [0:24:11.461939858] [10635] DEBUG HAL camera_device.cpp:941\n>> '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750230064 with 1 streams\n>> [0:24:11.462057435] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n>> not contiguous\n>> [0:24:11.462098906] [10635] DEBUG HAL camera_device.cpp:980\n>> '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n>> (direct)\n>> [0:24:11.463164722] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:237 frame 194 started\n>> [0:24:11.463730946] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 193\n>> [0:24:11.464033686] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:272 Setting Exposure to 269 at index 194\n>> [0:24:11.464329869] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video0[37:cap]: Queueing buffer 0\n>> [0:24:11.495739092] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:237 frame 195 started\n>> [0:24:11.496489311] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 194\n>> [0:24:11.496737385] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:285 Queue is empty, auto queue no-op.\n>> [0:24:11.497044311] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video0[37:cap]: Dequeuing buffer 3\n>> [0:24:11.497335155] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature\n>> estimated: 6658\n>> [0:24:11.497528845] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video6[25:cap]: Queueing buffer 2\n>> [0:24:11.503589322] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video5[27:out]: Queueing buffer 3\n>> [0:24:11.504027344] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video8[28:cap]: Queueing buffer 3\n>> [0:24:11.504287330] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video4[24:out]: Queueing buffer 3\n>> [0:24:11.504712501] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video4[24:out]: Dequeuing buffer 2\n>> [0:24:11.505005096] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video6[25:cap]: Dequeuing buffer 1\n>> [0:24:11.505260331] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video5[27:out]: Dequeuing buffer 3\n>> [0:24:11.505506837] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video8[28:cap]: Dequeuing buffer 2\n>> [0:24:11.505940926] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n>> [0:24:11.505976974] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n>> [0:24:11.506057427] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n>> red: 1.16797 and for blue: 1.14978\n>> [0:24:11.506297848] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:179 Queuing Exposure to 269 at index 196\n>> [0:24:11.506547021] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 196\n>> [0:24:11.506796456] [10629] DEBUG Request request.cpp:291\n>> Request(130:C:0/1:140736750225984)\n>> [0:24:11.507374522] [10629] DEBUG HAL camera_device.cpp:1117\n>> '\\_SB_.PCI0.I2C2.CAM0': Request 140736750225984 completed with 1 streams\n>> [0:24:11.509426987] [10635] DEBUG Request request.cpp:94 Created request\n>> - cookie: 140736750227664\n>> [0:24:11.509507039] [10635] DEBUG HAL camera_device.cpp:941\n>> '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750227664 with 1 streams\n>> [0:24:11.509630706] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n>> not contiguous\n>> [0:24:11.509675200] [10635] DEBUG HAL camera_device.cpp:980\n>> '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n>> (direct)\n>> [0:24:11.511309605] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n>> /dev/video0[37:cap]: Queueing buffer 1\n>> [0:24:11.528984601] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:237 frame 196 started\n>> [0:24:11.529446048] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:272 Setting Exposure to 269 at index 196\n>> [0:24:11.548431632] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video4[24:out]: Dequeuing buffer 3\n>> [0:24:11.548993830] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video6[25:cap]: Dequeuing buffer 2\n>> [0:24:11.549320802] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n>> /dev/video8[28:cap]: Dequeuing buffer 3\n>> [0:24:11.549807736] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n>> [0:24:11.549846777] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n>> [0:24:11.549927350] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n>> red: 1.16841 and for blue: 1.14912\n>> [0:24:11.550170924] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:179 Queuing Exposure to 269 at index 197\n>> [0:24:11.550405629] [10629] DEBUG DelayedControls\n>> delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 197\n>> [0:24:11.550646460] [10629] DEBUG Request request.cpp:291\n>> Request(131:C:0/1:140736750235824)\n>> [0:24:11.551245104] [10629] DEBUG HAL camera_device.cpp:1117\n>> '\\_SB_.PCI0.I2C2.CAM0': Request 140736750235824 completed with 2 streams\n>> [0:24:11.562307680] [10629] DEBUG EXIF exif.cpp:522 Created EXIF\n>> instance (536 bytes)\n>> [0:24:11.634800113] [10629] DEBUG JPEG encoder_libjpeg.cpp:220 JPEG\n>> Encode Starting:4160x3104\n>>\n>> Thread 6 \"CameraModuleThr\" received signal SIGSEGV, Segmentation fault.\n>> [Switching to Thread 0x7fffe7fff640 (LWP 10629)]\n>> 0x00007ffff597ead5 in\n>> EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const,\n>> 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> (gdb) bt\n>> #0  0x00007ffff597ead5 in\n>> EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const,\n>> 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #1  0x00007ffff597eda0 in\n>> EncoderLibJpeg::encode(libcamera::Span<unsigned char const,\n>> 18446744073709551615ul>, libcamera::Span<unsigned char,\n>> 18446744073709551615ul>, libcamera::Span<unsigned char const,\n>> 18446744073709551615ul>, unsigned int) () from\n>> /usr/lib64/camera_hal/libcamera-hal.so\n>> #2  0x00007ffff597ec53 in EncoderLibJpeg::encode(libcamera::FrameBuffer\n>> const&, libcamera::Span<unsigned char, 18446744073709551615ul>,\n> 18446744073709551615ul is -1, so we've certainly missed\n> capturing/preventing an error code from getting assigned to the span at\n> some point, where it then got stored as an unsigned long.\n>\n>\n> Does this happen repeatably? or only on some specific event?\n\n\nIt happens repeatably on every run of camera-service when you try to \ncapture the frame. The service will segfault on shutter-click and you \nneed to re-run it again.\n\n> --\n> Kieran","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4C3A1BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:06:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9943D6916C;\n\tMon,  6 Sep 2021 13:06:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 49FAC60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:06:33 +0200 (CEST)","from [192.168.1.104] (unknown [103.251.226.180])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F0DE8AD;\n\tMon,  6 Sep 2021 13:06:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QkZfJTMK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630926393;\n\tbh=lr3xIFSpg8rhVHR1Qr8qnJSgsdeLjBrwaK98AbVtN1o=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=QkZfJTMKr7+/Co8H0ZRBMfrNWBRaEIiFJM1TgqQTDlVWDuSpx2y0Ly+X41Q/NTE0n\n\tVEPjlvWWRGkENRtiGj+owrNM8LxXr5nNBVRMcu/8qsvVerm78DoEcJOoeicI+eHqoP\n\tfWqy7cO99akIviFCjdk5Rphxi26oM3BfBOuHN+lI=","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>\n\t<beb5c318-4b54-accf-a34b-f30d96f60bbc@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<b186c166-cd38-a8ab-38ab-69307a67ee5c@ideasonboard.com>","Date":"Mon, 6 Sep 2021 16:36:27 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<beb5c318-4b54-accf-a34b-f30d96f60bbc@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"8bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19424,"web_url":"https://patchwork.libcamera.org/comment/19424/","msgid":"<CAHW6GYKkdXzDEax9G9keD=dsFEdtkjrb7t7HXwiaEUFz=RMBTQ@mail.gmail.com>","date":"2021-09-06T11:22:25","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent, everyone\n\nThanks for all the efforts to get this working! I had just a little\nquestion or two...\n\n1. Is it easy to tell if a FrameBuffer is actually single plane or\nmulti plane? If not, could we add a public API function that would\ntell us?\n\n2. Is it easy to get the full size of the buffer for the single plane\ncase (rather than having to add all the bits up)? And again, if the\nanswer is no, could we add such a thing?\n\nI'm thinking of trying to make life easy for applications that might\nwant to pass these buffers to codecs where the driver might only\nsupport single planes. Not thinking of any platform in particular...\n:)\n\nThanks!\nDavid\n\nOn Mon, 6 Sept 2021 at 03:01, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hello everybody,\n>\n> This patch series started as an investigation of a qcam failure with\n> IPU3 after the merge of the FrameBuffer offset support. While a hack in\n> qcam would be possible, I decided to instead address the core issue and\n> fix it in V4L2VideoDevice.\n>\n> Compared to v1, the series now includes fixes for cam and qcam in\n> addition to the changes needed in the libcamera core. They have been\n> tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n>\n> The GStreamer element seems to work fine without any change required.\n> The V4L2 compatibility layer is still broken, and I haven't tested the\n> Android HAL yet (any volunteer ?).\n>\n> The most important change is in patches 13/27 and 14/27, which translate\n> between V4L2 buffers and libcamera FrameBuffer to handle the case where\n> a multi-planar frame buffer is used with the V4L2 single-planar API.\n> It's working more or less by chance at the moment (except in qcam where\n> it's broken, and possibly in other places I haven't tested). Patches\n> 01/27 to 12/27 are cleanups and additions to prepare for the work in\n> V4L2VideoDevice, and patch 15/27 is a small cleanup on top. Patches\n> 16/27 and 17/27 then improve the FrameBuffer class API as a cleanup.\n>\n> Patches 18/27 to 27/27 fix the cam and qcam applications, as well as an\n> issue in the Android HAL. Worth being noted is patch 19/27 that\n> introduces an Image class shared by cam and qcam. The class duplicates\n> the MappedFrameBuffer implementation private to libcamera. I've tried to\n> rework MappedFrameBuffer into something I would be happy to see in the\n> public API, but failed to do so in a reasonable amount of time, and I\n> didn't want to delay this important regression fix.\n>\n> This series doesn't break any unit test, as vimc doesn't support NV12.\n> Addition of NV12 support to the vimc kernel driver would be very nice,\n> in order to test multi-planar support in our unit tests. Volunteers are\n> welcome ;-)\n>\n> Laurent Pinchart (27):\n>   libcamera: base: utils: Use size_t for index in utils::enumerate()\n>   libcamera: file_descriptor: Add a function to retrieve the inode\n>   libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()\n>   libcamera: Use V4L2PixelFormat::fromPixelFormat()\n>   libcamera: formats: Move plane info structure to PixelFormatInfo\n>   libcamera: formats: Add planeSize() helpers to PixelFormatInfo\n>   libcamera: formats: Support V4L2 non-contiguous formats\n>   libcamera: framebuffer: Move planes check to constructor\n>   libcamera: framebuffer: Add a function to check if planes are\n>     contiguous\n>   libcamera: v4l2_videodevice: Cache PixelFormatInfo\n>   libcamera: v4l2_videodevice: Document plane handling in createBuffer()\n>   libcamera: v4l2_videodevice: Take stride into account to compute\n>     offsets\n>   libcamera: v4l2_videodevice: Coalesce planes when queuing buffer\n>   libcamera: v4l2_videodevice: Split planes when dequeuing buffer\n>   libcamera: v4l2_videodevice: Use utils::enumerate()\n>   libcamera: framebuffer: Allocate metadata planes at construction time\n>   libcamera: framebuffer: Prevent modifying the number of metadata\n>     planes\n>   android: camera_device: Don't assume all planes use the same fd\n>   cam: Add Image class\n>   cam: file_sink: Use Image class to access pixel data\n>   cam: drm: Support per-plane stride values\n>   cam: drm: Set per-plane offsets when creating DRM frame buffer\n>   cam: drm: Avoid importing the same dmabuf multiple times\n>   qcam: Print bytesused for all planes\n>   qcam: Use Image class to access pixel data\n>   qcam: viewfinder_gl: Support multi-planar buffers\n>   qcam: viewfinder_qt: Support multi-planar buffers\n>\n>  include/libcamera/base/utils.h                |   4 +-\n>  include/libcamera/file_descriptor.h           |   3 +\n>  include/libcamera/framebuffer.h               |  19 +-\n>  include/libcamera/internal/formats.h          |  22 +-\n>  include/libcamera/internal/framebuffer.h      |   2 +\n>  include/libcamera/internal/v4l2_pixelformat.h |   2 +-\n>  include/libcamera/internal/v4l2_videodevice.h |   3 +-\n>  src/android/camera_device.cpp                 |  25 +-\n>  src/android/mm/generic_camera_buffer.cpp      |  11 +-\n>  src/android/yuv/post_processor_yuv.cpp        |  10 +-\n>  src/cam/camera_session.cpp                    |   4 +-\n>  src/cam/drm.cpp                               |  38 +-\n>  src/cam/drm.h                                 |   7 +-\n>  src/cam/file_sink.cpp                         |  44 +--\n>  src/cam/file_sink.h                           |   6 +-\n>  src/cam/image.cpp                             | 107 +++++\n>  src/cam/image.h                               |  52 +++\n>  src/cam/kms_sink.cpp                          |  28 +-\n>  src/cam/meson.build                           |   1 +\n>  src/libcamera/file_descriptor.cpp             |  26 ++\n>  src/libcamera/formats.cpp                     | 373 ++++++++++++++----\n>  src/libcamera/framebuffer.cpp                 |  57 ++-\n>  src/libcamera/pipeline/ipu3/cio2.cpp          |   4 +-\n>  src/libcamera/pipeline/ipu3/imgu.cpp          |   2 +-\n>  .../pipeline/raspberrypi/raspberrypi.cpp      |   8 +-\n>  src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |   6 +-\n>  src/libcamera/pipeline/simple/converter.cpp   |   8 +-\n>  src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   6 +-\n>  src/libcamera/pipeline/vimc/vimc.cpp          |   8 +-\n>  src/libcamera/v4l2_pixelformat.cpp            |  11 +-\n>  src/libcamera/v4l2_videodevice.cpp            | 196 ++++++---\n>  src/qcam/format_converter.cpp                 |  18 +-\n>  src/qcam/format_converter.h                   |   9 +-\n>  src/qcam/main_window.cpp                      |  38 +-\n>  src/qcam/main_window.h                        |   4 +-\n>  src/qcam/meson.build                          |   1 +\n>  src/qcam/viewfinder.h                         |   6 +-\n>  src/qcam/viewfinder_gl.cpp                    |  45 +--\n>  src/qcam/viewfinder_gl.h                      |   4 +-\n>  src/qcam/viewfinder_qt.cpp                    |  20 +-\n>  src/qcam/viewfinder_qt.h                      |   2 +-\n>  src/v4l2/v4l2_camera_proxy.cpp                |  11 +-\n>  test/libtest/buffer_source.cpp                |   3 +-\n>  test/utils.cpp                                |  10 +-\n>  45 files changed, 911 insertions(+), 357 deletions(-)\n>  create mode 100644 src/cam/image.cpp\n>  create mode 100644 src/cam/image.h\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0C62DBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:22:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DEEA6916A;\n\tMon,  6 Sep 2021 13:22:38 +0200 (CEST)","from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C508D60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:22:36 +0200 (CEST)","by mail-wm1-x32d.google.com with SMTP id\n\tc8-20020a7bc008000000b002e6e462e95fso4719836wmb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 04:22:36 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"rr+g59xd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=VfmdnDHEykHcsZhAZ4hGZAY6kJmT9996pnoIxSvCh2A=;\n\tb=rr+g59xdSzDGDvlNyHBhHMhgPFSQu+cbqOSkECyNrI3lPnC/B01bSPg5aCCvJsu/FZ\n\ttPaNx6uujS266NEG9cI6oM2mwriBlHbvzJXOBY+rKOkGveE+EGCDXZPxu4MlDo5dvF7x\n\tAIs+g/dFDuNVSCMGK0yXxI9MeOzZn04xUl7vu5dbHvZD4XW2xn+j3Ly6S2nzdH/la3Jv\n\tI2/z1qTRXkb8HsDsFDsuRljMZIQ1w9S76a7KxFLIiTNRVsCpe28HyaUS/P+45EuPj/8X\n\tzddbq1pMAPDAA+SSfT7F+BDXaVcoKMWwvutC+qdNNRRjkL0zDpY3R7PE7bDh5MaX7kTe\n\tcedA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=VfmdnDHEykHcsZhAZ4hGZAY6kJmT9996pnoIxSvCh2A=;\n\tb=BocVunI9MeJEfdwbfJVjq7b87bOXoxoc+TCKetI6zO0j8/KIYckuf6E3oemEQzfMNX\n\tSr/bOICs1OIR1Az1x9+5Bvbiz2fbHYFzDA/Nesf7E0Hp8HgtOL6aPPEuGV7wMPU4oW8e\n\tHNJPsypTjU7gFtQm1Ad1NMeRlMGYfqgKvLY9Ck0BDgDPSqHcNJ9roRYoUu04W6gxPGyH\n\tfE6aLYz0R+v6aI2e3Ro+hXzCQQ8mqXdYbukhXmurWLlpjo1W9NEuqqDHRxRY7oovEXGJ\n\tpJCMViloZtstSwcLr18SwI3RC7Ws20Zvj7RNAp1kzZBPLb1v2ueVYTV7L9Y1WKWKYX8X\n\tnr+w==","X-Gm-Message-State":"AOAM530TqCaisUCQ07jvG4ljKzNftWdj8Cx2RP88XurSV9q7oo6/+tTt\n\tXDeDBCs84r5g6ZPMU1LbViUAcBPZ+BL18JLvMMaRZ5T3eLlF8Q==","X-Google-Smtp-Source":"ABdhPJxvq/kCMS1qcZzncJdB5aLbiPSZp4xoahnLm1p9r2cywh53tCHnLQKY8khhyJYoahY1FaTTTbxmbfYS1VysgzE=","X-Received":"by 2002:a05:600c:3795:: with SMTP id\n\to21mr10768265wmr.130.1630927356337; \n\tMon, 06 Sep 2021 04:22:36 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 6 Sep 2021 12:22:25 +0100","Message-ID":"<CAHW6GYKkdXzDEax9G9keD=dsFEdtkjrb7t7HXwiaEUFz=RMBTQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19426,"web_url":"https://patchwork.libcamera.org/comment/19426/","msgid":"<CAO5uPHPsr+mvrd2ABo2hwTtt92FyVndF0XPSZR2KtAyZqjzBDg@mail.gmail.com>","date":"2021-09-06T11:37:26","subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent,\n\nOn Mon, Sep 6, 2021 at 6:04 PM <paul.elder@ideasonboard.com> wrote:\n>\n> Hi Laurent,\n>\n> On Mon, Sep 06, 2021 at 05:00:35AM +0300, Laurent Pinchart wrote:\n> > The inode is useful to check if two file descriptors refer to the same\n> > file. Add a function to retrieve it.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n>\n> > ---\n> > Changes since v1:\n> >\n> > - Use isValid() instead of open-coding it\n> > - Print a message on error\n> > ---\n> >  include/libcamera/file_descriptor.h |  3 +++\n> >  src/libcamera/file_descriptor.cpp   | 26 ++++++++++++++++++++++++++\n> >  2 files changed, 29 insertions(+)\n> >\n> > diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h\n> > index d514aac7697b..988f9b7a3d25 100644\n> > --- a/include/libcamera/file_descriptor.h\n> > +++ b/include/libcamera/file_descriptor.h\n> > @@ -8,6 +8,7 @@\n> >  #define __LIBCAMERA_FILE_DESCRIPTOR_H__\n> >\n> >  #include <memory>\n> > +#include <sys/types.h>\n> >\n> >  namespace libcamera {\n> >\n> > @@ -27,6 +28,8 @@ public:\n> >       int fd() const { return fd_ ? fd_->fd() : -1; }\n> >       FileDescriptor dup() const;\n> >\n> > +     ino_t inode() const;\n> > +\n> >  private:\n> >       class Descriptor\n> >       {\n> > diff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp\n> > index 9f9ebc81f738..0409c3e1758c 100644\n> > --- a/src/libcamera/file_descriptor.cpp\n> > +++ b/src/libcamera/file_descriptor.cpp\n> > @@ -8,6 +8,8 @@\n> >  #include <libcamera/file_descriptor.h>\n> >\n> >  #include <string.h>\n> > +#include <sys/stat.h>\n> > +#include <sys/types.h>\n> >  #include <unistd.h>\n> >  #include <utility>\n> >\n> > @@ -221,6 +223,30 @@ FileDescriptor FileDescriptor::dup() const\n> >       return FileDescriptor(fd());\n> >  }\n> >\n> > +/**\n> > + * \\brief Retrieve the file descriptor inode\n> > + *\n> > + * \\todo Should this move to the File class ?\n> > + *\n> > + * \\return The file descriptor inode on success, or 0 on error\n> > + */\n> > +ino_t FileDescriptor::inode() const\n> > +{\n> > +     if (!isValid())\n> > +             return 0;\n> > +\n> > +     struct stat st;\n> > +     int ret = fstat(fd_->fd(), &st);\n> > +     if (ret < 0) {\n> > +             ret = -errno;\n> > +             LOG(FileDescriptor, Fatal)\n> > +                     << \"Failed to fstat() fd: \" << strerror(-ret);\n\nSetting errno to ret is unnecessary?\n\nif (ret < 0) {\n   LOG(FileDescriptor, Fatal) << \"Failed to fstat() fd: \" << stderr(errno);\n  return 0;\n}\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\n> > +             return 0;\n> > +     }\n> > +\n> > +     return st.st_ino;\n> > +}\n> > +\n> >  FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n> >  {\n> >       if (!duplicate) {\n> > --\n> > Regards,\n> >\n> > Laurent Pinchart\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 27D9FBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:37:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8BEE669167;\n\tMon,  6 Sep 2021 13:37:39 +0200 (CEST)","from mail-ed1-x532.google.com (mail-ed1-x532.google.com\n\t[IPv6:2a00:1450:4864:20::532])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EAEB460137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:37:37 +0200 (CEST)","by mail-ed1-x532.google.com with SMTP id z19so9106129edi.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 04:37:37 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Zk9d/UQM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=h+ARaJvQI8cV09lc1Z4VC2ncwQsGyqZjM81vo/Mdpjs=;\n\tb=Zk9d/UQMtJU74cBzt6LgWNYNYHw43KQrAqbkQPDLux4eN8txccmzietsS1BYqU1zdI\n\t4aE53c6XS4ttrGm/wLR85yvOAu/T0VrbV5p/XVIE5gfETGMerZJrX/m/sf2ypU2jBghM\n\taaHwBfe1dANGO3nc5jicMI4Zp8ce9PHS4UzwU=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=h+ARaJvQI8cV09lc1Z4VC2ncwQsGyqZjM81vo/Mdpjs=;\n\tb=sN6gXk9YJ2SqzoyS4b6npe29v+w2y8P7tG7DkkMSbYNq4zWmoi20pOBQFCXR4CDveL\n\tH9BvTiEGVi4sJ9h0calygdSNEl3Cr/KKodFXG0Xi3MT8/r4Lt0ybQiannH3Quqv8NpDk\n\t0eSi6g2Pbb9q1wgCXHXB6gfD1XAp2Bx57SuHnpOTLzXX3TGNpxzmw5P2uc+08FhfEG4y\n\tmA1cIjV8A81HKJg1CMHV2CaCEhGBfmWv6u6PPQgTs0RWMlsfQg4yeI9zWXdIFD2KPnjH\n\t2f8bePi1EvZleYE2q5iMjmb0ZW4KMA6FOo2M2tSFx2/uLEWb1OEBBaT/H9b44Zh41aFW\n\tOpgA==","X-Gm-Message-State":"AOAM530Dqm4dM7eBAGHIc1C1D6HWXNYXvrf8wgRgEnqSWm9cm2/qSY0Y\n\tKs1iEhPkARpCMQ5sj3ScIbt87AqpjMDemnqVcX6ibw==","X-Google-Smtp-Source":"ABdhPJxAJX7TZ7VZWLByl9lqqTbDcJUwbDBVsT/dMwJQQHi/TD4zZF3rWQlI20nivAFQzHR/dXsxNf76yOGwLr5FJrU=","X-Received":"by 2002:a05:6402:28b1:: with SMTP id\n\teg49mr11378847edb.291.1630928257499; \n\tMon, 06 Sep 2021 04:37:37 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>\n\t<20210906090444.GT968527@pyrite.rasen.tech>","In-Reply-To":"<20210906090444.GT968527@pyrite.rasen.tech>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 6 Sep 2021 20:37:26 +0900","Message-ID":"<CAO5uPHPsr+mvrd2ABo2hwTtt92FyVndF0XPSZR2KtAyZqjzBDg@mail.gmail.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19427,"web_url":"https://patchwork.libcamera.org/comment/19427/","msgid":"<YTX+b/Xrr75gJy2C@pendragon.ideasonboard.com>","date":"2021-09-06T11:41:35","subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nOn Mon, Sep 06, 2021 at 08:37:26PM +0900, Hirokazu Honda wrote:\n> On Mon, Sep 6, 2021 at 6:04 PM <paul.elder@ideasonboard.com> wrote:\n> > On Mon, Sep 06, 2021 at 05:00:35AM +0300, Laurent Pinchart wrote:\n> > > The inode is useful to check if two file descriptors refer to the same\n> > > file. Add a function to retrieve it.\n> > >\n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >\n> > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> >\n> > > ---\n> > > Changes since v1:\n> > >\n> > > - Use isValid() instead of open-coding it\n> > > - Print a message on error\n> > > ---\n> > >  include/libcamera/file_descriptor.h |  3 +++\n> > >  src/libcamera/file_descriptor.cpp   | 26 ++++++++++++++++++++++++++\n> > >  2 files changed, 29 insertions(+)\n> > >\n> > > diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h\n> > > index d514aac7697b..988f9b7a3d25 100644\n> > > --- a/include/libcamera/file_descriptor.h\n> > > +++ b/include/libcamera/file_descriptor.h\n> > > @@ -8,6 +8,7 @@\n> > >  #define __LIBCAMERA_FILE_DESCRIPTOR_H__\n> > >\n> > >  #include <memory>\n> > > +#include <sys/types.h>\n> > >\n> > >  namespace libcamera {\n> > >\n> > > @@ -27,6 +28,8 @@ public:\n> > >       int fd() const { return fd_ ? fd_->fd() : -1; }\n> > >       FileDescriptor dup() const;\n> > >\n> > > +     ino_t inode() const;\n> > > +\n> > >  private:\n> > >       class Descriptor\n> > >       {\n> > > diff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp\n> > > index 9f9ebc81f738..0409c3e1758c 100644\n> > > --- a/src/libcamera/file_descriptor.cpp\n> > > +++ b/src/libcamera/file_descriptor.cpp\n> > > @@ -8,6 +8,8 @@\n> > >  #include <libcamera/file_descriptor.h>\n> > >\n> > >  #include <string.h>\n> > > +#include <sys/stat.h>\n> > > +#include <sys/types.h>\n> > >  #include <unistd.h>\n> > >  #include <utility>\n> > >\n> > > @@ -221,6 +223,30 @@ FileDescriptor FileDescriptor::dup() const\n> > >       return FileDescriptor(fd());\n> > >  }\n> > >\n> > > +/**\n> > > + * \\brief Retrieve the file descriptor inode\n> > > + *\n> > > + * \\todo Should this move to the File class ?\n> > > + *\n> > > + * \\return The file descriptor inode on success, or 0 on error\n> > > + */\n> > > +ino_t FileDescriptor::inode() const\n> > > +{\n> > > +     if (!isValid())\n> > > +             return 0;\n> > > +\n> > > +     struct stat st;\n> > > +     int ret = fstat(fd_->fd(), &st);\n> > > +     if (ret < 0) {\n> > > +             ret = -errno;\n> > > +             LOG(FileDescriptor, Fatal)\n> > > +                     << \"Failed to fstat() fd: \" << strerror(-ret);\n> \n> Setting errno to ret is unnecessary?\n> \n> if (ret < 0) {\n>    LOG(FileDescriptor, Fatal) << \"Failed to fstat() fd: \" << stderr(errno);\n>   return 0;\n> }\n\nThe LOG() macros constructs a LogMessage object, and it may change errno\nbefore strerror() is called. The same is possibly true of the\noperator<<() calls, or other function calls in the log line. Maybe it\ncan't happen in this specific case, but we always assign ret = -errno to\nbe safe.\n\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> \n> > > +             return 0;\n> > > +     }\n> > > +\n> > > +     return st.st_ino;\n> > > +}\n> > > +\n> > >  FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n> > >  {\n> > >       if (!duplicate) {","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 26315BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:41:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D3C76916A;\n\tMon,  6 Sep 2021 13:41:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DB6D60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:41:55 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D54F68AD;\n\tMon,  6 Sep 2021 13:41:54 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"NI+iWS7G\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630928515;\n\tbh=24/eRt/TT5+lcnZHwFN7kgnC7m/L+Q1uBCow8qhRDyg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=NI+iWS7GOTaUJF5/SOSA/XAkas8+ylSqsq9oSyippLtfMQD/gdFZcn9CDMNS3z83x\n\tNL3Ql9P9W0+aI+An8A5F/5CfewUtMLyMD4CbUg9xX/dt4y8XK5YeFZ8JxREG2I8w7R\n\tPAxkb9tjlRJQvkrnIEKL3a+ijVOqltihkfq7iMnc=","Date":"Mon, 6 Sep 2021 14:41:35 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YTX+b/Xrr75gJy2C@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>\n\t<20210906090444.GT968527@pyrite.rasen.tech>\n\t<CAO5uPHPsr+mvrd2ABo2hwTtt92FyVndF0XPSZR2KtAyZqjzBDg@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAO5uPHPsr+mvrd2ABo2hwTtt92FyVndF0XPSZR2KtAyZqjzBDg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19428,"web_url":"https://patchwork.libcamera.org/comment/19428/","msgid":"<YTX/X4MnE4sqUsuL@pendragon.ideasonboard.com>","date":"2021-09-06T11:45:35","subject":"Re: [libcamera-devel] [PATCH v2 25/27] qcam: Use Image class to\n\taccess pixel data","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nOn Mon, Sep 06, 2021 at 11:36:10AM +0200, Jean-Michel Hautbois wrote:\n> On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > Replace the manual implementation of frame buffer mapping with the Image\n> > class to improve code sharing. The ViewFinder API is updated to take an\n> > Image pointer in the render() function to prepare for multi-planar\n> > buffer support.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/qcam/main_window.cpp   | 31 ++++++++-----------------------\n> >  src/qcam/main_window.h     |  4 ++--\n> >  src/qcam/meson.build       |  1 +\n> >  src/qcam/viewfinder.h      |  6 +++---\n> >  src/qcam/viewfinder_gl.cpp |  7 ++++---\n> >  src/qcam/viewfinder_gl.h   |  2 +-\n> >  src/qcam/viewfinder_qt.cpp |  6 +++---\n> >  src/qcam/viewfinder_qt.h   |  2 +-\n> >  8 files changed, 23 insertions(+), 36 deletions(-)\n> > \n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 0a00b1001570..168dd5ce30e3 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -7,10 +7,9 @@\n> >  \n> >  #include \"main_window.h\"\n> >  \n> > +#include <assert.h>\n> >  #include <iomanip>\n> >  #include <string>\n> > -#include <sys/mman.h>\n> > -#include <unistd.h>\n> >  \n> >  #include <QComboBox>\n> >  #include <QCoreApplication>\n> > @@ -29,6 +28,7 @@\n> >  #include <libcamera/camera_manager.h>\n> >  #include <libcamera/version.h>\n> >  \n> > +#include \"../cam/image.h\"\n> >  #include \"dng_writer.h\"\n> >  #ifndef QT_NO_OPENGL\n> >  #include \"viewfinder_gl.h\"\n> > @@ -473,15 +473,10 @@ int MainWindow::startCapture()\n> >  \n> >  \t\tfor (const std::unique_ptr<FrameBuffer> &buffer : allocator_->buffers(stream)) {\n> >  \t\t\t/* Map memory buffers and cache the mappings. */\n> > -\t\t\tconst FrameBuffer::Plane &plane = buffer->planes().front();\n> > -\t\t\tsize_t length = lseek(plane.fd.fd(), 0, SEEK_END);\n> > -\t\t\tvoid *memory = mmap(NULL, length, PROT_READ, MAP_SHARED,\n> > -\t\t\t\t\t    plane.fd.fd(), 0);\n> > -\n> > -\t\t\tmappedBuffers_[buffer.get()] = { static_cast<uint8_t *>(memory),\n> > -\t\t\t\t\t\t\t plane.length };\n> > -\t\t\tplaneData_[buffer.get()] = { static_cast<uint8_t *>(memory) + plane.offset,\n> > -\t\t\t\t\t\t     plane.length };\n> > +\t\t\tstd::unique_ptr<Image> image =\n> > +\t\t\t\tImage::fromFrameBuffer(buffer.get(), Image::MapMode::ReadOnly);\n> > +\t\t\tassert(image != nullptr);\n> > +\t\t\tmappedBuffers_[buffer.get()] = std::move(image);\n> >  \n> >  \t\t\t/* Store buffers on the free list. */\n> >  \t\t\tfreeBuffers_[stream].enqueue(buffer.get());\n> > @@ -543,12 +538,7 @@ error_disconnect:\n> >  error:\n> >  \trequests_.clear();\n> >  \n> > -\tfor (auto &iter : mappedBuffers_) {\n> > -\t\tconst Span<uint8_t> &buffer = iter.second;\n> > -\t\tmunmap(buffer.data(), buffer.size());\n> > -\t}\n> >  \tmappedBuffers_.clear();\n> > -\tplaneData_.clear();\n> >  \n> >  \tfreeBuffers_.clear();\n> >  \n> > @@ -580,12 +570,7 @@ void MainWindow::stopCapture()\n> >  \n> >  \tcamera_->requestCompleted.disconnect(this);\n> >  \n> > -\tfor (auto &iter : mappedBuffers_) {\n> > -\t\tconst Span<uint8_t> &buffer = iter.second;\n> > -\t\tmunmap(buffer.data(), buffer.size());\n> > -\t}\n> >  \tmappedBuffers_.clear();\n> > -\tplaneData_.clear();\n> >  \n> >  \trequests_.clear();\n> >  \tfreeQueue_.clear();\n> > @@ -682,7 +667,7 @@ void MainWindow::processRaw(FrameBuffer *buffer,\n> >  \t\t\t\t\t\t\t\"DNG Files (*.dng)\");\n> >  \n> >  \tif (!filename.isEmpty()) {\n> > -\t\tuint8_t *memory = planeData_[buffer].data();\n> > +\t\tuint8_t *memory = mappedBuffers_[buffer]->data(0).data();\n> >  \t\tDNGWriter::write(filename.toStdString().c_str(), camera_.get(),\n> >  \t\t\t\t rawStream_->configuration(), metadata, buffer,\n> >  \t\t\t\t memory);\n> > @@ -766,7 +751,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)\n> >  \t\t<< \"fps:\" << Qt::fixed << qSetRealNumberPrecision(2) << fps;\n> >  \n> >  \t/* Render the frame on the viewfinder. */\n> > -\tviewfinder_->render(buffer, planeData_[buffer]);\n> > +\tviewfinder_->render(buffer, mappedBuffers_[buffer].get());\n> >  }\n> >  \n> >  void MainWindow::queueRequest(FrameBuffer *buffer)\n> > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> > index 28244bca58b2..a16bea09eadc 100644\n> > --- a/src/qcam/main_window.h\n> > +++ b/src/qcam/main_window.h\n> > @@ -34,6 +34,7 @@ using namespace libcamera;\n> >  class QAction;\n> >  class QComboBox;\n> >  \n> > +class Image;\n> >  class HotplugEvent;\n> >  \n> >  enum {\n> > @@ -106,8 +107,7 @@ private:\n> >  \tFrameBufferAllocator *allocator_;\n> >  \n> >  \tstd::unique_ptr<CameraConfiguration> config_;\n> > -\tstd::map<FrameBuffer *, Span<uint8_t>> mappedBuffers_;\n> > -\tstd::map<FrameBuffer *, Span<uint8_t>> planeData_;\n> > +\tstd::map<FrameBuffer *, std::unique_ptr<Image>> mappedBuffers_;\n> >  \n> >  \t/* Capture state, buffers queue and statistics */\n> >  \tbool isCapturing_;\n> > diff --git a/src/qcam/meson.build b/src/qcam/meson.build\n> > index 7d3621c93d41..c46f463130cd 100644\n> > --- a/src/qcam/meson.build\n> > +++ b/src/qcam/meson.build\n> > @@ -15,6 +15,7 @@ endif\n> >  qcam_enabled = true\n> >  \n> >  qcam_sources = files([\n> > +    '../cam/image.cpp',\n> >      '../cam/options.cpp',\n> >      '../cam/stream_options.cpp',\n> \n> I never realized we were referencing as much \"../cam\" !\n> \n> >      'format_converter.cpp',\n> > diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\n> > index 42d40f1f33f0..fb462835fb5f 100644\n> > --- a/src/qcam/viewfinder.h\n> > +++ b/src/qcam/viewfinder.h\n> > @@ -11,11 +11,11 @@\n> >  #include <QList>\n> >  #include <QSize>\n> >  \n> > -#include <libcamera/base/span.h>\n> > -\n> >  #include <libcamera/formats.h>\n> >  #include <libcamera/framebuffer.h>\n> >  \n> > +class Image;\n> > +\n> >  class ViewFinder\n> >  {\n> >  public:\n> > @@ -24,7 +24,7 @@ public:\n> >  \tvirtual const QList<libcamera::PixelFormat> &nativeFormats() const = 0;\n> >  \n> >  \tvirtual int setFormat(const libcamera::PixelFormat &format, const QSize &size) = 0;\n> > -\tvirtual void render(libcamera::FrameBuffer *buffer, libcamera::Span<uint8_t> mem) = 0;\n> > +\tvirtual void render(libcamera::FrameBuffer *buffer, Image *image) = 0;\n> >  \tvirtual void stop() = 0;\n> >  \n> >  \tvirtual QImage getCurrentImage() = 0;\n> > diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> > index d2ef036974f4..87e4fe03cb8d 100644\n> > --- a/src/qcam/viewfinder_gl.cpp\n> > +++ b/src/qcam/viewfinder_gl.cpp\n> > @@ -13,6 +13,8 @@\n> >  \n> >  #include <libcamera/formats.h>\n> >  \n> > +#include \"../cam/image.h\"\n> \n> Where should Image class be in the end, once stable enough ?\n\nI expect it to move to include/libcamera/ then.\n\n> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n>\n> > +\n> >  static const QList<libcamera::PixelFormat> supportedFormats{\n> >  \t/* YUV - packed (single plane) */\n> >  \tlibcamera::formats::UYVY,\n> > @@ -110,8 +112,7 @@ QImage ViewFinderGL::getCurrentImage()\n> >  \treturn grabFramebuffer();\n> >  }\n> >  \n> > -void ViewFinderGL::render(libcamera::FrameBuffer *buffer,\n> > -\t\t\t  libcamera::Span<uint8_t> mem)\n> > +void ViewFinderGL::render(libcamera::FrameBuffer *buffer, Image *image)\n> >  {\n> >  \tif (buffer->planes().size() != 1) {\n> >  \t\tqWarning() << \"Multi-planar buffers are not supported\";\n> > @@ -121,7 +122,7 @@ void ViewFinderGL::render(libcamera::FrameBuffer *buffer,\n> >  \tif (buffer_)\n> >  \t\trenderComplete(buffer_);\n> >  \n> > -\tdata_ = mem.data();\n> > +\tdata_ = image->data(0).data();\n> >  \t/*\n> >  \t * \\todo Get the stride from the buffer instead of computing it naively\n> >  \t */\n> > diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h\n> > index 3334549e0be4..7cd8ef3316b9 100644\n> > --- a/src/qcam/viewfinder_gl.h\n> > +++ b/src/qcam/viewfinder_gl.h\n> > @@ -39,7 +39,7 @@ public:\n> >  \tconst QList<libcamera::PixelFormat> &nativeFormats() const override;\n> >  \n> >  \tint setFormat(const libcamera::PixelFormat &format, const QSize &size) override;\n> > -\tvoid render(libcamera::FrameBuffer *buffer, libcamera::Span<uint8_t> mem) override;\n> > +\tvoid render(libcamera::FrameBuffer *buffer, Image *image) override;\n> >  \tvoid stop() override;\n> >  \n> >  \tQImage getCurrentImage() override;\n> > diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp\n> > index a0bf99b0b522..fef6d53eef5e 100644\n> > --- a/src/qcam/viewfinder_qt.cpp\n> > +++ b/src/qcam/viewfinder_qt.cpp\n> > @@ -19,6 +19,7 @@\n> >  \n> >  #include <libcamera/formats.h>\n> >  \n> > +#include \"../cam/image.h\"\n> >  #include \"format_converter.h\"\n> >  \n> >  static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats\n> > @@ -78,15 +79,14 @@ int ViewFinderQt::setFormat(const libcamera::PixelFormat &format,\n> >  \treturn 0;\n> >  }\n> >  \n> > -void ViewFinderQt::render(libcamera::FrameBuffer *buffer,\n> > -\t\t\t  libcamera::Span<uint8_t> mem)\n> > +void ViewFinderQt::render(libcamera::FrameBuffer *buffer, Image *image)\n> >  {\n> >  \tif (buffer->planes().size() != 1) {\n> >  \t\tqWarning() << \"Multi-planar buffers are not supported\";\n> >  \t\treturn;\n> >  \t}\n> >  \n> > -\tunsigned char *memory = mem.data();\n> > +\tunsigned char *memory = image->data(0).data();\n> >  \tsize_t size = buffer->metadata().planes()[0].bytesused;\n> >  \n> >  \t{\n> > diff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h\n> > index 1a569b9cee6e..6b48ef48a7d1 100644\n> > --- a/src/qcam/viewfinder_qt.h\n> > +++ b/src/qcam/viewfinder_qt.h\n> > @@ -32,7 +32,7 @@ public:\n> >  \tconst QList<libcamera::PixelFormat> &nativeFormats() const override;\n> >  \n> >  \tint setFormat(const libcamera::PixelFormat &format, const QSize &size) override;\n> > -\tvoid render(libcamera::FrameBuffer *buffer, libcamera::Span<uint8_t> mem) override;\n> > +\tvoid render(libcamera::FrameBuffer *buffer, Image *image) override;\n> >  \tvoid stop() override;\n> >  \n> >  \tQImage getCurrentImage() override;\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 05229BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:45:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5B34069168;\n\tMon,  6 Sep 2021 13:45:57 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 14E6160137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:45:55 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 911228AD;\n\tMon,  6 Sep 2021 13:45:54 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gTmbpY0F\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630928754;\n\tbh=4J1J/ieSaWAq6hIGRBmoSdzCKE3U8c1FxvlSmEUQXHg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gTmbpY0FlZyrwr05d8uZFCWWg2Y/aVo/Fqa/wboeeG2KacjYtn55gfJuAAYkuP0LA\n\tHizE40fxfHjyukzRxGbhw7XzZzdd/v5QT5296Oc1/iSwkh5UjNthdPzGsk+NAIc/G3\n\tB7lzOR+tEChVUtIy8nJSrovUfLoSehbZ9tL6/5O8=","Date":"Mon, 6 Sep 2021 14:45:35 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YTX/X4MnE4sqUsuL@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-26-laurent.pinchart@ideasonboard.com>\n\t<49bc88d3-05ed-7c27-cbbc-56180067d48d@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<49bc88d3-05ed-7c27-cbbc-56180067d48d@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 25/27] qcam: Use Image class to\n\taccess pixel data","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19429,"web_url":"https://patchwork.libcamera.org/comment/19429/","msgid":"<YTYBtkzBZWdbd5VN@pendragon.ideasonboard.com>","date":"2021-09-06T11:55:34","subject":"Re: [libcamera-devel] [PATCH v2 19/27] cam: Add Image class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nOn Mon, Sep 06, 2021 at 10:35:50AM +0200, Jean-Michel Hautbois wrote:\n> On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > The new Image class represents a multi-planar image with direct access\n> > to pixel data. It currently duplicates the function of the\n> > MappedFrameBuffer class which is internal to libcamera, and will serve\n> > as a design playground to improve the API until it is considered ready\n> > to be made part of the libcamera public API.\n> \n> I like the idea, maybe add some documentation already in the class ?\n\nThat's a good idea, but in the specific case I'd like to get this series\nmerged ASAP to fix the breakage in the master branch, so I'd prefer\nadding the documentation on top.\n\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/cam/image.cpp   | 107 ++++++++++++++++++++++++++++++++++++++++++++\n> >  src/cam/image.h     |  52 +++++++++++++++++++++\n> >  src/cam/meson.build |   1 +\n> >  3 files changed, 160 insertions(+)\n> >  create mode 100644 src/cam/image.cpp\n> >  create mode 100644 src/cam/image.h\n> > \n> > diff --git a/src/cam/image.cpp b/src/cam/image.cpp\n> > new file mode 100644\n> > index 000000000000..7ae5f52dccb4\n> > --- /dev/null\n> > +++ b/src/cam/image.cpp\n> > @@ -0,0 +1,107 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2021, Google Inc.\n> > + *\n> > + * image.cpp - Multi-planar image with access to pixel data\n> > + */\n> > +\n> > +#include \"image.h\"\n> > +\n> > +#include <assert.h>\n> > +#include <errno.h>\n> > +#include <iostream>\n> > +#include <map>\n> > +#include <string.h>\n> > +#include <sys/mman.h>\n> > +#include <unistd.h>\n> > +\n> > +using namespace libcamera;\n> > +\n> > +std::unique_ptr<Image> Image::fromFrameBuffer(const FrameBuffer *buffer, MapMode mode)\n> \n> Can you see a use case for Image::toFrameBuffer not implemented yet ?\n> What would be in this class apart from a conversion from a FrameBuffer\n> to a Image ?\n\nI don't think so. The Image class is an interface to provide access to\npixel data. In its current form it's constructed from a FrameBuffer, but\nI'd like the ability to construct it from a byte array as well. This is\nrelated to the MappedVectorBuffer class that Hiro has proposed, it would\nallow the JPEG compression in the Android HAL to use an Image as the\nsource, regardless of whether the compresses the still capture (coming\nfrom libcamera in a FrameBuffer) or the thumbnail (downscaled in\nsoftware and stored in a std::vector<uint8_t>).\n\nWhat I still haven't determined is whether the Image class should be an\ninterface with pure virtual functions only, implemented by subclasses\nsuch as FrameBufferImage or Memory Image, or if it should contain the\ndata as well, populated by the different constructors.\n\nI've also started to think about how to perform the mapping. For\nFrameBuffer objects constructed from Android buffers, the mapping should\nbe delegated to gralloc on Android and to the CameraBufferManager on\nChrome OS. For FrameBuffer objects constructed internally by the\nV4L2VideoDevice (and in particular the ones exposes to applications with\nFrameBufferAllocator), the code below should be correct. For other types\nof FrameBuffer objects supplied by applications, another method of\nmapping may be needed. I'm not sure yet how to best handle that, and if\nwe'll need a FrameBufferMapper object that FrameBuffer instances will\nreference.\n\n> > +{\n> > +\tstd::unique_ptr<Image> image{ new Image() };\n> > +\n> > +\tassert(!buffer->planes().empty());\n> > +\n> > +\tint mmapFlags = 0;\n> > +\n> > +\tif (mode & MapMode::ReadOnly)\n> > +\t\tmmapFlags |= PROT_READ;\n> > +\n> > +\tif (mode & MapMode::WriteOnly)\n> > +\t\tmmapFlags |= PROT_WRITE;\n> > +\n> > +\tstruct MappedBufferInfo {\n> > +\t\tuint8_t *address = nullptr;\n> > +\t\tsize_t mapLength = 0;\n> > +\t\tsize_t dmabufLength = 0;\n> > +\t};\n> > +\tstd::map<int, MappedBufferInfo> mappedBuffers;\n> > +\n> > +\tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> > +\t\tconst int fd = plane.fd.fd();\n> > +\t\tif (mappedBuffers.find(fd) == mappedBuffers.end()) {\n> > +\t\t\tconst size_t length = lseek(fd, 0, SEEK_END);\n> > +\t\t\tmappedBuffers[fd] = MappedBufferInfo{ nullptr, 0, length };\n> > +\t\t}\n> > +\n> > +\t\tconst size_t length = mappedBuffers[fd].dmabufLength;\n> > +\n> > +\t\tif (plane.offset > length ||\n> > +\t\t    plane.offset + plane.length > length) {\n> > +\t\t\tstd::cerr << \"plane is out of buffer: buffer length=\"\n> > +\t\t\t\t  << length << \", plane offset=\" << plane.offset\n> > +\t\t\t\t  << \", plane length=\" << plane.length\n> > +\t\t\t\t  << std::endl;\n> > +\t\t\treturn nullptr;\n> > +\t\t}\n> > +\t\tsize_t &mapLength = mappedBuffers[fd].mapLength;\n> > +\t\tmapLength = std::max(mapLength,\n> > +\t\t\t\t     static_cast<size_t>(plane.offset + plane.length));\n> > +\t}\n> > +\n> > +\tfor (const FrameBuffer::Plane &plane : buffer->planes()) {\n> > +\t\tconst int fd = plane.fd.fd();\n> > +\t\tauto &info = mappedBuffers[fd];\n> > +\t\tif (!info.address) {\n> > +\t\t\tvoid *address = mmap(nullptr, info.mapLength, mmapFlags,\n> > +\t\t\t\t\t     MAP_SHARED, fd, 0);\n> > +\t\t\tif (address == MAP_FAILED) {\n> > +\t\t\t\tint error = -errno;\n> > +\t\t\t\tstd::cerr << \"Failed to mmap plane: \"\n> > +\t\t\t\t\t  << strerror(-error) << std::endl;\n> > +\t\t\t\treturn nullptr;\n> > +\t\t\t}\n> > +\n> > +\t\t\tinfo.address = static_cast<uint8_t *>(address);\n> > +\t\t\timage->maps_.emplace_back(info.address, info.mapLength);\n> > +\t\t}\n> > +\n> > +\t\timage->planes_.emplace_back(info.address + plane.offset, plane.length);\n> > +\t}\n> > +\n> \n> Why are you using two loops on buffer->planes() ? Is it for code clarity\n> or something I did not get ?\n\nBecause we may have multiple planes using the same dmabuf fd. The first\nlook gathers the dmabuf fds along with their length, the second loop\nthen maps them. We need to compute the length to be mapped by looking at\nall planes first, before doing any mapping.\n\n> > +\treturn image;\n> > +}\n> > +\n> > +Image::Image() = default;\n> > +\n> > +Image::~Image()\n> > +{\n> > +\tfor (Span<uint8_t> &map : maps_)\n> > +\t\tmunmap(map.data(), map.size());\n> > +}\n> > +\n> > +unsigned int Image::numPlanes() const\n> > +{\n> > +\treturn planes_.size();\n> > +}\n> > +\n> > +Span<uint8_t> Image::data(unsigned int plane)\n> > +{\n> > +\treturn planes_[plane];\n> > +}\n> > +\n> > +Span<const uint8_t> Image::data(unsigned int plane) const\n> > +{\n> > +\treturn planes_[plane];\n> > +}\n> > diff --git a/src/cam/image.h b/src/cam/image.h\n> > new file mode 100644\n> > index 000000000000..1ce5f84e5f9e\n> > --- /dev/null\n> > +++ b/src/cam/image.h\n> > @@ -0,0 +1,52 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2021, Google Inc.\n> > + *\n> > + * image.h - Multi-planar image with access to pixel data\n> > + */\n> > +#ifndef __CAM_IMAGE_H__\n> > +#define __CAM_IMAGE_H__\n> > +\n> > +#include <memory>\n> > +#include <stdint.h>\n> > +#include <vector>\n> > +\n> > +#include <libcamera/base/class.h>\n> > +#include <libcamera/base/flags.h>\n> > +#include <libcamera/base/span.h>\n> > +\n> > +#include <libcamera/framebuffer.h>\n> > +\n> > +class Image\n> > +{\n> > +public:\n> > +\tenum class MapMode {\n> > +\t\tReadOnly = 1 << 0,\n> > +\t\tWriteOnly = 1 << 1,\n> > +\t\tReadWrite = ReadOnly | WriteOnly,\n> > +\t};\n> > +\n> > +\tstatic std::unique_ptr<Image> fromFrameBuffer(const libcamera::FrameBuffer *buffer,\n> > +\t\t\t\t\t\t      MapMode mode);\n> > +\n> > +\t~Image();\n> > +\n> > +\tunsigned int numPlanes() const;\n> > +\n> > +\tlibcamera::Span<uint8_t> data(unsigned int plane);\n> > +\tlibcamera::Span<const uint8_t> data(unsigned int plane) const;\n> > +\n> > +private:\n> > +\tLIBCAMERA_DISABLE_COPY(Image)\n> > +\n> > +\tImage();\n> > +\n> > +\tstd::vector<libcamera::Span<uint8_t>> maps_;\n> > +\tstd::vector<libcamera::Span<uint8_t>> planes_;\n> > +};\n> > +\n> > +namespace libcamera {\n> > +LIBCAMERA_FLAGS_ENABLE_OPERATORS(Image::MapMode)\n> > +}\n> > +\n> > +#endif /* __CAM_IMAGE_H__ */\n> > diff --git a/src/cam/meson.build b/src/cam/meson.build\n> > index ea36aaa5c514..e8e2ae57d3f4 100644\n> > --- a/src/cam/meson.build\n> > +++ b/src/cam/meson.build\n> > @@ -14,6 +14,7 @@ cam_sources = files([\n> >      'event_loop.cpp',\n> >      'file_sink.cpp',\n> >      'frame_sink.cpp',\n> > +    'image.cpp',\n> >      'main.cpp',\n> >      'options.cpp',\n> >      'stream_options.cpp',\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AFE73BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:55:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EAAE76916A;\n\tMon,  6 Sep 2021 13:55:55 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D27560137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:55:54 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B44C8AD;\n\tMon,  6 Sep 2021 13:55:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"lwY6WOLg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630929353;\n\tbh=NGnfKa2+aODibq5Q1vnMvm6Wq+CWnM7mptyEDnQ/Ums=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lwY6WOLg6necvgAOr5EMJUpe6G3B4ZoXcgYtLKOpxcxI/nU9T5LWAoQyILTZBvfDq\n\t2OK04ytYsrrwZ3O/maCAhHAxNPVD0fL5yQuwrl8iuMU2rnW+7xu8ltNLpCLOFP4oAV\n\tJwTLuM1N1J8bXIBEEz8yWqk19e8lNitRQQo8utNw=","Date":"Mon, 6 Sep 2021 14:55:34 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YTYBtkzBZWdbd5VN@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-20-laurent.pinchart@ideasonboard.com>\n\t<2279ec9d-de49-6b8c-af28-d96b86811ede@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<2279ec9d-de49-6b8c-af28-d96b86811ede@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 19/27] cam: Add Image 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19430,"web_url":"https://patchwork.libcamera.org/comment/19430/","msgid":"<YTYCGYn0J7etjp3w@pendragon.ideasonboard.com>","date":"2021-09-06T11:57:13","subject":"Re: [libcamera-devel] [PATCH v2 09/27] libcamera: framebuffer: Add\n\ta function to check if planes are contiguous","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nOn Mon, Sep 06, 2021 at 07:50:58AM +0200, Jean-Michel Hautbois wrote:\n> On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > Multi-planar frame buffers can store their planes contiguously in\n> > memory, or split them in discontiguous memory areas. Add a private\n> > function to check in which of these two categories the frame buffer\n> > belongs. This will be used to correctly handle the differences between\n> > the V4L2 single and multi planar APIs.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> > ---\n> > Changes v1:\n> > \n> > - Merge both loops in FrameBuffer::FrameBuffer()\n> > ---\n> >  include/libcamera/internal/framebuffer.h |  2 ++\n> >  src/libcamera/framebuffer.cpp            | 45 ++++++++++++++++++++++--\n> >  2 files changed, 45 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h\n> > index 606aed2b4782..cd33c295466e 100644\n> > --- a/include/libcamera/internal/framebuffer.h\n> > +++ b/include/libcamera/internal/framebuffer.h\n> > @@ -21,9 +21,11 @@ public:\n> >  \tPrivate();\n> >  \n> >  \tvoid setRequest(Request *request) { request_ = request; }\n> > +\tbool isContiguous() const { return isContiguous_; }\n> >  \n> >  private:\n> >  \tRequest *request_;\n> > +\tbool isContiguous_;\n> >  };\n> >  \n> >  } /* namespace libcamera */\n> > diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\n> > index ad63a34a83bf..e71c2ffae034 100644\n> > --- a/src/libcamera/framebuffer.cpp\n> > +++ b/src/libcamera/framebuffer.cpp\n> > @@ -106,7 +106,7 @@ LOG_DEFINE_CATEGORY(Buffer)\n> >   */\n> >  \n> >  FrameBuffer::Private::Private()\n> > -\t: request_(nullptr)\n> > +\t: request_(nullptr), isContiguous_(true)\n> >  {\n> >  }\n> >  \n> > @@ -120,6 +120,17 @@ FrameBuffer::Private::Private()\n> >   * handlers, it is called by the pipeline handlers themselves.\n> >   */\n> >  \n> > +/**\n> > + * \\fn FrameBuffer::Private::isContiguous()\n> > + * \\brief Check if the frame buffer stores planes contiguously in memory\n> > + *\n> > + * Multi-planar frame buffers can store their planes contiguously in memory, or\n> > + * split them into discontiguous memory areas. This function checks in which of\n> > + * these two categories the frame buffer belongs.\n> > + *\n> > + * \\return True if the planes are stored contiguously in memory, false otherwise\n> > + */\n> > +\n> >  /**\n> >   * \\class FrameBuffer\n> >   * \\brief Frame buffer data and its associated dynamic metadata\n> > @@ -199,8 +210,38 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n> >  \t: Extensible(std::make_unique<Private>()), planes_(planes),\n> >  \t  cookie_(cookie)\n> >  {\n> > -\tfor (const auto &plane : planes_)\n> > +\tunsigned int offset = 0;\n> > +\tbool isContiguous = true;\n> > +\tino_t inode = 0;\n> > +\n> > +\tfor (const auto &plane : planes_) {\n> >  \t\tASSERT(plane.offset != Plane::kInvalidOffset);\n> > +\n> > +\t\tif (plane.offset != offset) {\n> > +\t\t\tisContiguous = false;\n> > +\t\t\tbreak;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Two different dmabuf file descriptors may still refer to the\n> > +\t\t * same dmabuf instance. Check this using inodes.\n> > +\t\t */\n> \n> How is that possible ?\n\ndup(), or IPC. Depending on the IPC mechanism, if you send the same fd\ntwice (once for each plane in an NV12 buffer for instance), you may get\ntwo different fds on the receiving side.\n\n> > +\t\tif (plane.fd.fd() != planes_[0].fd.fd()) {\n> > +\t\t\tif (!inode)\n> > +\t\t\t\tinode = planes_[0].fd.inode();\n> > +\t\t\tif (plane.fd.inode() != inode) {\n> > +\t\t\t\tisContiguous = false;\n> > +\t\t\t\tbreak;\n> > +\t\t\t}\n> > +\t\t}\n> > +\n> > +\t\toffset += plane.length;\n> > +\t}\n> > +\n> > +\tLOG(Buffer, Debug)\n> > +\t\t<< \"Buffer is \" << (isContiguous ? \"not \" : \"\") << \"contiguous\";\n> > +\n> > +\t_d()->isContiguous_ = isContiguous;\n> >  }\n> >  \n> >  /**","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E5A36BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 11:57:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A845960137;\n\tMon,  6 Sep 2021 13:57:33 +0200 (CEST)","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 2330760137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 13:57:32 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 991F68AD;\n\tMon,  6 Sep 2021 13:57:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"seX7ZPSL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630929451;\n\tbh=DVGVKasiego2YqzkWqct8mUvd2GgSAXV+V36jz4jwJ0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=seX7ZPSL21D2y/+CU7JIDRbQOeFhg4sTIPbv2xJTeS0a7G44Rip+802tuxp52onbj\n\tfjwC+ZLE8yKlphJ0sLN4a6ojZnN47GPB+7f1gsaTJlFXP3Myp/CK8YDShato1En6lf\n\to5JerVCuwNtUbMPuw6kfsagAe4FDUIvrQGvMyN6Q=","Date":"Mon, 6 Sep 2021 14:57:13 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YTYCGYn0J7etjp3w@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-10-laurent.pinchart@ideasonboard.com>\n\t<330d7434-0369-6446-d8c3-b8044cbdd6c7@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<330d7434-0369-6446-d8c3-b8044cbdd6c7@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 09/27] libcamera: framebuffer: Add\n\ta function to check if planes are contiguous","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19433,"web_url":"https://patchwork.libcamera.org/comment/19433/","msgid":"<YTYGEXss6sHJ2bW8@pendragon.ideasonboard.com>","date":"2021-09-06T12:14:09","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Mon, Sep 06, 2021 at 12:22:25PM +0100, David Plowman wrote:\n> Hi Laurent, everyone\n> \n> Thanks for all the efforts to get this working! I had just a little\n> question or two...\n> \n> 1. Is it easy to tell if a FrameBuffer is actually single plane or\n> multi plane? If not, could we add a public API function that would\n> tell us?\n\nYou can use FrameBuffer::planes().size() to get the number of planes. Or\ndid you mean checking if the different planes in a multi-planar frame\nbuffer are stored contiguously in the same dmabuf ? There's a private\nhelper for that (FrameBuffer::Private::isContiguous()), I haven't made\nit public yet as I wanted to evaluate the use cases first.\n\n> 2. Is it easy to get the full size of the buffer for the single plane\n> case (rather than having to add all the bits up)? And again, if the\n> answer is no, could we add such a thing?\n> \n> I'm thinking of trying to make life easy for applications that might\n> want to pass these buffers to codecs where the driver might only\n> support single planes. Not thinking of any platform in particular...\n> :)\n\nIt again depends what you mean :-) If the FrameBuffer has a single\nplane, FrameBuffer::planes()[0].length (and\nFrameMetaData::planes()[0].bytesused) will give you what you need. I\nsuspect you're however consider the case of a multi-planar FrameBuffer\nwith planes stored contiguously in memory, using the single-planar V4L2\nformats (e.g. V4L2_PIX_FMT_NV12, as opposed to V4L2_PIX_FMT_NV12M). I'm\na bit worried that a helper function in that case would be used by\napplications to ignore that the buffer can be truly multi-planar.\n\n> On Mon, 6 Sept 2021 at 03:01, Laurent Pinchart wrote:\n> >\n> > Hello everybody,\n> >\n> > This patch series started as an investigation of a qcam failure with\n> > IPU3 after the merge of the FrameBuffer offset support. While a hack in\n> > qcam would be possible, I decided to instead address the core issue and\n> > fix it in V4L2VideoDevice.\n> >\n> > Compared to v1, the series now includes fixes for cam and qcam in\n> > addition to the changes needed in the libcamera core. They have been\n> > tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n> >\n> > The GStreamer element seems to work fine without any change required.\n> > The V4L2 compatibility layer is still broken, and I haven't tested the\n> > Android HAL yet (any volunteer ?).\n> >\n> > The most important change is in patches 13/27 and 14/27, which translate\n> > between V4L2 buffers and libcamera FrameBuffer to handle the case where\n> > a multi-planar frame buffer is used with the V4L2 single-planar API.\n> > It's working more or less by chance at the moment (except in qcam where\n> > it's broken, and possibly in other places I haven't tested). Patches\n> > 01/27 to 12/27 are cleanups and additions to prepare for the work in\n> > V4L2VideoDevice, and patch 15/27 is a small cleanup on top. Patches\n> > 16/27 and 17/27 then improve the FrameBuffer class API as a cleanup.\n> >\n> > Patches 18/27 to 27/27 fix the cam and qcam applications, as well as an\n> > issue in the Android HAL. Worth being noted is patch 19/27 that\n> > introduces an Image class shared by cam and qcam. The class duplicates\n> > the MappedFrameBuffer implementation private to libcamera. I've tried to\n> > rework MappedFrameBuffer into something I would be happy to see in the\n> > public API, but failed to do so in a reasonable amount of time, and I\n> > didn't want to delay this important regression fix.\n> >\n> > This series doesn't break any unit test, as vimc doesn't support NV12.\n> > Addition of NV12 support to the vimc kernel driver would be very nice,\n> > in order to test multi-planar support in our unit tests. Volunteers are\n> > welcome ;-)\n> >\n> > Laurent Pinchart (27):\n> >   libcamera: base: utils: Use size_t for index in utils::enumerate()\n> >   libcamera: file_descriptor: Add a function to retrieve the inode\n> >   libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()\n> >   libcamera: Use V4L2PixelFormat::fromPixelFormat()\n> >   libcamera: formats: Move plane info structure to PixelFormatInfo\n> >   libcamera: formats: Add planeSize() helpers to PixelFormatInfo\n> >   libcamera: formats: Support V4L2 non-contiguous formats\n> >   libcamera: framebuffer: Move planes check to constructor\n> >   libcamera: framebuffer: Add a function to check if planes are\n> >     contiguous\n> >   libcamera: v4l2_videodevice: Cache PixelFormatInfo\n> >   libcamera: v4l2_videodevice: Document plane handling in createBuffer()\n> >   libcamera: v4l2_videodevice: Take stride into account to compute\n> >     offsets\n> >   libcamera: v4l2_videodevice: Coalesce planes when queuing buffer\n> >   libcamera: v4l2_videodevice: Split planes when dequeuing buffer\n> >   libcamera: v4l2_videodevice: Use utils::enumerate()\n> >   libcamera: framebuffer: Allocate metadata planes at construction time\n> >   libcamera: framebuffer: Prevent modifying the number of metadata\n> >     planes\n> >   android: camera_device: Don't assume all planes use the same fd\n> >   cam: Add Image class\n> >   cam: file_sink: Use Image class to access pixel data\n> >   cam: drm: Support per-plane stride values\n> >   cam: drm: Set per-plane offsets when creating DRM frame buffer\n> >   cam: drm: Avoid importing the same dmabuf multiple times\n> >   qcam: Print bytesused for all planes\n> >   qcam: Use Image class to access pixel data\n> >   qcam: viewfinder_gl: Support multi-planar buffers\n> >   qcam: viewfinder_qt: Support multi-planar buffers\n> >\n> >  include/libcamera/base/utils.h                |   4 +-\n> >  include/libcamera/file_descriptor.h           |   3 +\n> >  include/libcamera/framebuffer.h               |  19 +-\n> >  include/libcamera/internal/formats.h          |  22 +-\n> >  include/libcamera/internal/framebuffer.h      |   2 +\n> >  include/libcamera/internal/v4l2_pixelformat.h |   2 +-\n> >  include/libcamera/internal/v4l2_videodevice.h |   3 +-\n> >  src/android/camera_device.cpp                 |  25 +-\n> >  src/android/mm/generic_camera_buffer.cpp      |  11 +-\n> >  src/android/yuv/post_processor_yuv.cpp        |  10 +-\n> >  src/cam/camera_session.cpp                    |   4 +-\n> >  src/cam/drm.cpp                               |  38 +-\n> >  src/cam/drm.h                                 |   7 +-\n> >  src/cam/file_sink.cpp                         |  44 +--\n> >  src/cam/file_sink.h                           |   6 +-\n> >  src/cam/image.cpp                             | 107 +++++\n> >  src/cam/image.h                               |  52 +++\n> >  src/cam/kms_sink.cpp                          |  28 +-\n> >  src/cam/meson.build                           |   1 +\n> >  src/libcamera/file_descriptor.cpp             |  26 ++\n> >  src/libcamera/formats.cpp                     | 373 ++++++++++++++----\n> >  src/libcamera/framebuffer.cpp                 |  57 ++-\n> >  src/libcamera/pipeline/ipu3/cio2.cpp          |   4 +-\n> >  src/libcamera/pipeline/ipu3/imgu.cpp          |   2 +-\n> >  .../pipeline/raspberrypi/raspberrypi.cpp      |   8 +-\n> >  src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |   6 +-\n> >  src/libcamera/pipeline/simple/converter.cpp   |   8 +-\n> >  src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n> >  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   6 +-\n> >  src/libcamera/pipeline/vimc/vimc.cpp          |   8 +-\n> >  src/libcamera/v4l2_pixelformat.cpp            |  11 +-\n> >  src/libcamera/v4l2_videodevice.cpp            | 196 ++++++---\n> >  src/qcam/format_converter.cpp                 |  18 +-\n> >  src/qcam/format_converter.h                   |   9 +-\n> >  src/qcam/main_window.cpp                      |  38 +-\n> >  src/qcam/main_window.h                        |   4 +-\n> >  src/qcam/meson.build                          |   1 +\n> >  src/qcam/viewfinder.h                         |   6 +-\n> >  src/qcam/viewfinder_gl.cpp                    |  45 +--\n> >  src/qcam/viewfinder_gl.h                      |   4 +-\n> >  src/qcam/viewfinder_qt.cpp                    |  20 +-\n> >  src/qcam/viewfinder_qt.h                      |   2 +-\n> >  src/v4l2/v4l2_camera_proxy.cpp                |  11 +-\n> >  test/libtest/buffer_source.cpp                |   3 +-\n> >  test/utils.cpp                                |  10 +-\n> >  45 files changed, 911 insertions(+), 357 deletions(-)\n> >  create mode 100644 src/cam/image.cpp\n> >  create mode 100644 src/cam/image.h","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C184BBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 12:14:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 366F96916C;\n\tMon,  6 Sep 2021 14:14:29 +0200 (CEST)","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 73B0C60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 14:14:28 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F231C8AD;\n\tMon,  6 Sep 2021 14:14:27 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SEO+NEUY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630930468;\n\tbh=UBLpIpzI6BwgeFznYDOG94BnSb0DpRh8mVtq4nCR/wA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SEO+NEUY6+jKzV+FHBCEe2qHIICYn67rrh4EBHChSZ25jCbiKqw0xxbbI3Ise5qty\n\t/UyRgGMLGo/f2dCAF0fIJDYoPCeqqV0KYUIplQ5vG/OPc+bV4BNSMH5Zxj0bNvauhR\n\tMTHWRZChlW8bRq10j9K0C+wHgzyROoauINTgZmdk=","Date":"Mon, 6 Sep 2021 15:14:09 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YTYGEXss6sHJ2bW8@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<CAHW6GYKkdXzDEax9G9keD=dsFEdtkjrb7t7HXwiaEUFz=RMBTQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAHW6GYKkdXzDEax9G9keD=dsFEdtkjrb7t7HXwiaEUFz=RMBTQ@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19434,"web_url":"https://patchwork.libcamera.org/comment/19434/","msgid":"<YTYGi+K4/uCUgR0H@pendragon.ideasonboard.com>","date":"2021-09-06T12:16:11","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Mon, Sep 06, 2021 at 11:43:15AM +0100, Kieran Bingham wrote:\n> On 06/09/2021 11:08, Umang Jain wrote:\n> > On 9/6/21 7:30 AM, Laurent Pinchart wrote:\n> >> Hello everybody,\n> >>\n> >> This patch series started as an investigation of a qcam failure with\n> >> IPU3 after the merge of the FrameBuffer offset support. While a hack in\n> >> qcam would be possible, I decided to instead address the core issue and\n> >> fix it in V4L2VideoDevice.\n> >>\n> >> Compared to v1, the series now includes fixes for cam and qcam in\n> >> addition to the changes needed in the libcamera core. They have been\n> >> tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n> >>\n> >> The GStreamer element seems to work fine without any change required.\n> >> The V4L2 compatibility layer is still broken, and I haven't tested the\n> >> Android HAL yet (any volunteer ?).\n> > \n> > I am applied this series on top of master and tested on nautilus.\n> > Streaming seems fine to me, although it was appearing more choppy than\n> > usual.\n> > \n> > Now that I see, entire nautilus seems laggy to respond in general. One\n> > \"Chrome\" process hogging 50% CPU, seems like a transient issue.\n> > \n> > So, streaming seems fine on multiple runs, with multiple resolutions\n> > selections (from the camera-app menu), however, requesting MJPEG\n> > (shutter-click) results in a segfault.\n> > \n> > The stack trace is below:\n> > \n> > [0:24:11.415660787] [10635] DEBUG HAL camera_device.cpp:941\n> > '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750235824 with 2 streams\n> > [0:24:11.415858538] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n> > not contiguous\n> > [0:24:11.415905500] [10635] DEBUG HAL camera_device.cpp:980\n> > '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n> > (direct)\n> > [0:24:11.415943620] [10635] DEBUG HAL camera_device.cpp:966\n> > '\\_SB_.PCI0.I2C2.CAM0': 1 - (4160x3104)[0x00000021] -> (4160x3104)[NV12]\n> > (mapped)\n> > [0:24:11.416461639] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video0[37:cap]: Queueing buffer 3\n> > [0:24:11.428903141] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video0[37:cap]: Dequeuing buffer 2\n> > [0:24:11.429095316] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature\n> > estimated: 6644\n> > [0:24:11.429563781] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:237 frame 193 started\n> > [0:24:11.429627478] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:272 Setting Exposure to 269 at index 193\n> > [0:24:11.429683048] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video6[25:cap]: Queueing buffer 1\n> > [0:24:11.436615191] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video5[27:out]: Queueing buffer 2\n> > [0:24:11.436718629] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video8[28:cap]: Queueing buffer 2\n> > [0:24:11.436799420] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video4[24:out]: Queueing buffer 2\n> > [0:24:11.457388821] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video4[24:out]: Dequeuing buffer 1\n> > [0:24:11.457948159] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video6[25:cap]: Dequeuing buffer 0\n> > [0:24:11.458257692] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video5[27:out]: Dequeuing buffer 2\n> > [0:24:11.458525315] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video8[28:cap]: Dequeuing buffer 1\n> > [0:24:11.458968848] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> > [0:24:11.459005634] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> > [0:24:11.459082715] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n> > red: 1.16864 and for blue: 1.14863\n> > [0:24:11.459325998] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:179 Queuing Exposure to 269 at index 194\n> > [0:24:11.459562485] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 194\n> > [0:24:11.459815347] [10629] DEBUG Request request.cpp:291\n> > Request(129:C:0/1:140736750229136)\n> > [0:24:11.460390126] [10629] DEBUG HAL camera_device.cpp:1117\n> > '\\_SB_.PCI0.I2C2.CAM0': Request 140736750229136 completed with 1 streams\n> > [0:24:11.461855854] [10635] DEBUG Request request.cpp:94 Created request\n> > - cookie: 140736750230064\n> > [0:24:11.461939858] [10635] DEBUG HAL camera_device.cpp:941\n> > '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750230064 with 1 streams\n> > [0:24:11.462057435] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n> > not contiguous\n> > [0:24:11.462098906] [10635] DEBUG HAL camera_device.cpp:980\n> > '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n> > (direct)\n> > [0:24:11.463164722] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:237 frame 194 started\n> > [0:24:11.463730946] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 193\n> > [0:24:11.464033686] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:272 Setting Exposure to 269 at index 194\n> > [0:24:11.464329869] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video0[37:cap]: Queueing buffer 0\n> > [0:24:11.495739092] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:237 frame 195 started\n> > [0:24:11.496489311] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 194\n> > [0:24:11.496737385] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:285 Queue is empty, auto queue no-op.\n> > [0:24:11.497044311] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video0[37:cap]: Dequeuing buffer 3\n> > [0:24:11.497335155] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature\n> > estimated: 6658\n> > [0:24:11.497528845] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video6[25:cap]: Queueing buffer 2\n> > [0:24:11.503589322] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video5[27:out]: Queueing buffer 3\n> > [0:24:11.504027344] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video8[28:cap]: Queueing buffer 3\n> > [0:24:11.504287330] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video4[24:out]: Queueing buffer 3\n> > [0:24:11.504712501] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video4[24:out]: Dequeuing buffer 2\n> > [0:24:11.505005096] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video6[25:cap]: Dequeuing buffer 1\n> > [0:24:11.505260331] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video5[27:out]: Dequeuing buffer 3\n> > [0:24:11.505506837] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video8[28:cap]: Dequeuing buffer 2\n> > [0:24:11.505940926] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> > [0:24:11.505976974] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> > [0:24:11.506057427] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n> > red: 1.16797 and for blue: 1.14978\n> > [0:24:11.506297848] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:179 Queuing Exposure to 269 at index 196\n> > [0:24:11.506547021] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 196\n> > [0:24:11.506796456] [10629] DEBUG Request request.cpp:291\n> > Request(130:C:0/1:140736750225984)\n> > [0:24:11.507374522] [10629] DEBUG HAL camera_device.cpp:1117\n> > '\\_SB_.PCI0.I2C2.CAM0': Request 140736750225984 completed with 1 streams\n> > [0:24:11.509426987] [10635] DEBUG Request request.cpp:94 Created request\n> > - cookie: 140736750227664\n> > [0:24:11.509507039] [10635] DEBUG HAL camera_device.cpp:941\n> > '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750227664 with 1 streams\n> > [0:24:11.509630706] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is\n> > not contiguous\n> > [0:24:11.509675200] [10635] DEBUG HAL camera_device.cpp:980\n> > '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]\n> > (direct)\n> > [0:24:11.511309605] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582\n> > /dev/video0[37:cap]: Queueing buffer 1\n> > [0:24:11.528984601] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:237 frame 196 started\n> > [0:24:11.529446048] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:272 Setting Exposure to 269 at index 196\n> > [0:24:11.548431632] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video4[24:out]: Dequeuing buffer 3\n> > [0:24:11.548993830] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video6[25:cap]: Dequeuing buffer 2\n> > [0:24:11.549320802] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650\n> > /dev/video8[28:cap]: Dequeuing buffer 3\n> > [0:24:11.549807736] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> > [0:24:11.549846777] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> > [0:24:11.549927350] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for\n> > red: 1.16841 and for blue: 1.14912\n> > [0:24:11.550170924] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:179 Queuing Exposure to 269 at index 197\n> > [0:24:11.550405629] [10629] DEBUG DelayedControls\n> > delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 197\n> > [0:24:11.550646460] [10629] DEBUG Request request.cpp:291\n> > Request(131:C:0/1:140736750235824)\n> > [0:24:11.551245104] [10629] DEBUG HAL camera_device.cpp:1117\n> > '\\_SB_.PCI0.I2C2.CAM0': Request 140736750235824 completed with 2 streams\n> > [0:24:11.562307680] [10629] DEBUG EXIF exif.cpp:522 Created EXIF\n> > instance (536 bytes)\n> > [0:24:11.634800113] [10629] DEBUG JPEG encoder_libjpeg.cpp:220 JPEG\n> > Encode Starting:4160x3104\n> > \n> > Thread 6 \"CameraModuleThr\" received signal SIGSEGV, Segmentation fault.\n> > [Switching to Thread 0x7fffe7fff640 (LWP 10629)]\n> > 0x00007ffff597ead5 in\n> > EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const,\n> > 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n> > (gdb) bt\n> > #0  0x00007ffff597ead5 in\n> > EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const,\n> > 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n> > #1  0x00007ffff597eda0 in\n> > EncoderLibJpeg::encode(libcamera::Span<unsigned char const,\n> > 18446744073709551615ul>, libcamera::Span<unsigned char,\n> > 18446744073709551615ul>, libcamera::Span<unsigned char const,\n> > 18446744073709551615ul>, unsigned int) () from\n> > /usr/lib64/camera_hal/libcamera-hal.so\n> > #2  0x00007ffff597ec53 in EncoderLibJpeg::encode(libcamera::FrameBuffer\n> > const&, libcamera::Span<unsigned char, 18446744073709551615ul>,\n> \n> 18446744073709551615ul is -1, so we've certainly missed\n> capturing/preventing an error code from getting assigned to the span at\n> some point, where it then got stored as an unsigned long.\n\nThis it the template argument, and -1 indicates a dynamic extent, as\nopposed to Span<> instances that have a static extent.\n\n> Does this happen repeatably? or only on some specific event?","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EB49BBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 12:16:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 61D3760137;\n\tMon,  6 Sep 2021 14:16:32 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C57D060137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 14:16:30 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E55C8AD;\n\tMon,  6 Sep 2021 14:16:30 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"DHSeK/+N\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630930590;\n\tbh=RDKkvRxq2ZLOHlfVh6c+lv/+Oa4PPJzo7N/jLJH4khk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=DHSeK/+NLfaWuR2P/bjqoQMm/rO+eLn50Lb23RF1Y6IVkMRrgAQVD5S4zNA0NxTLH\n\tdzBtstbxg3FvFMeBoV3gD6ixF7URCiKOuRurMDHV/W+c7AHfAQO9bwAuNTj0uDkzVs\n\t8+l5JaD1nBti86ynfG6zLpN/iRrxi0+F2YilQK5Y=","Date":"Mon, 6 Sep 2021 15:16:11 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YTYGi+K4/uCUgR0H@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>\n\t<beb5c318-4b54-accf-a34b-f30d96f60bbc@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<beb5c318-4b54-accf-a34b-f30d96f60bbc@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19435,"web_url":"https://patchwork.libcamera.org/comment/19435/","msgid":"<YTYIkHs8wPCf0oZf@pendragon.ideasonboard.com>","date":"2021-09-06T12:24:48","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nOn Mon, Sep 06, 2021 at 03:38:04PM +0530, Umang Jain wrote:\n> On 9/6/21 7:30 AM, Laurent Pinchart wrote:\n> > Hello everybody,\n> >\n> > This patch series started as an investigation of a qcam failure with\n> > IPU3 after the merge of the FrameBuffer offset support. While a hack in\n> > qcam would be possible, I decided to instead address the core issue and\n> > fix it in V4L2VideoDevice.\n> >\n> > Compared to v1, the series now includes fixes for cam and qcam in\n> > addition to the changes needed in the libcamera core. They have been\n> > tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n> >\n> > The GStreamer element seems to work fine without any change required.\n> > The V4L2 compatibility layer is still broken, and I haven't tested the\n> > Android HAL yet (any volunteer ?).\n> \n> I am applied this series on top of master and tested on nautilus. \n> Streaming seems fine to me, although it was appearing more choppy than \n> usual.\n> \n> Now that I see, entire nautilus seems laggy to respond in general. One \n> \"Chrome\" process hogging 50% CPU, seems like a transient issue.\n> \n> So, streaming seems fine on multiple runs, with multiple resolutions \n> selections (from the camera-app menu), however, requesting MJPEG \n> (shutter-click) results in a segfault.\n\nThanks for testing !\n\n> The stack trace is below:\n> \n> [0:24:11.415660787] [10635] DEBUG HAL camera_device.cpp:941 '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750235824 with 2 streams\n> [0:24:11.415858538] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is not contiguous\n> [0:24:11.415905500] [10635] DEBUG HAL camera_device.cpp:980 '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] (direct)\n> [0:24:11.415943620] [10635] DEBUG HAL camera_device.cpp:966 '\\_SB_.PCI0.I2C2.CAM0': 1 - (4160x3104)[0x00000021] -> (4160x3104)[NV12] (mapped)\n> [0:24:11.416461639] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 /dev/video0[37:cap]: Queueing buffer 3\n> [0:24:11.428903141] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 /dev/video0[37:cap]: Dequeuing buffer 2\n> [0:24:11.429095316] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature estimated: 6644\n> [0:24:11.429563781] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 193 started\n> [0:24:11.429627478] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Exposure to 269 at index 193\n> [0:24:11.429683048] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video6[25:cap]: Queueing buffer 1\n> [0:24:11.436615191] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video5[27:out]: Queueing buffer 2\n> [0:24:11.436718629] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video8[28:cap]: Queueing buffer 2\n> [0:24:11.436799420] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video4[24:out]: Queueing buffer 2\n> [0:24:11.457388821] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video4[24:out]: Dequeuing buffer 1\n> [0:24:11.457948159] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video6[25:cap]: Dequeuing buffer 0\n> [0:24:11.458257692] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video5[27:out]: Dequeuing buffer 2\n> [0:24:11.458525315] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video8[28:cap]: Dequeuing buffer 1\n> [0:24:11.458968848] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> [0:24:11.459005634] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> [0:24:11.459082715] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for  red: 1.16864 and for blue: 1.14863\n> [0:24:11.459325998] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Exposure to 269 at index 194\n> [0:24:11.459562485] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 194\n> [0:24:11.459815347] [10629] DEBUG Request request.cpp:291  Request(129:C:0/1:140736750229136)\n> [0:24:11.460390126] [10629] DEBUG HAL camera_device.cpp:1117  '\\_SB_.PCI0.I2C2.CAM0': Request 140736750229136 completed with 1 streams\n> [0:24:11.461855854] [10635] DEBUG Request request.cpp:94 Created request  - cookie: 140736750230064\n> [0:24:11.461939858] [10635] DEBUG HAL camera_device.cpp:941  '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750230064 with 1 streams\n> [0:24:11.462057435] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is  not contiguous\n> [0:24:11.462098906] [10635] DEBUG HAL camera_device.cpp:980  '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]  (direct)\n> [0:24:11.463164722] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 194 started\n> [0:24:11.463730946] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 193\n> [0:24:11.464033686] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Exposure to 269 at index 194\n> [0:24:11.464329869] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video0[37:cap]: Queueing buffer 0\n> [0:24:11.495739092] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 195 started\n> [0:24:11.496489311] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 194\n> [0:24:11.496737385] [10629] DEBUG DelayedControls  delayed_controls.cpp:285 Queue is empty, auto queue no-op.\n> [0:24:11.497044311] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video0[37:cap]: Dequeuing buffer 3\n> [0:24:11.497335155] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature  estimated: 6658\n> [0:24:11.497528845] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video6[25:cap]: Queueing buffer 2\n> [0:24:11.503589322] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video5[27:out]: Queueing buffer 3\n> [0:24:11.504027344] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video8[28:cap]: Queueing buffer 3\n> [0:24:11.504287330] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video4[24:out]: Queueing buffer 3\n> [0:24:11.504712501] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video4[24:out]: Dequeuing buffer 2\n> [0:24:11.505005096] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video6[25:cap]: Dequeuing buffer 1\n> [0:24:11.505260331] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video5[27:out]: Dequeuing buffer 3\n> [0:24:11.505506837] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video8[28:cap]: Dequeuing buffer 2\n> [0:24:11.505940926] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> [0:24:11.505976974] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> [0:24:11.506057427] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for  red: 1.16797 and for blue: 1.14978\n> [0:24:11.506297848] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Exposure to 269 at index 196\n> [0:24:11.506547021] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 196\n> [0:24:11.506796456] [10629] DEBUG Request request.cpp:291  Request(130:C:0/1:140736750225984)\n> [0:24:11.507374522] [10629] DEBUG HAL camera_device.cpp:1117  '\\_SB_.PCI0.I2C2.CAM0': Request 140736750225984 completed with 1 streams\n> [0:24:11.509426987] [10635] DEBUG Request request.cpp:94 Created request  - cookie: 140736750227664\n> [0:24:11.509507039] [10635] DEBUG HAL camera_device.cpp:941  '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750227664 with 1 streams\n> [0:24:11.509630706] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is  not contiguous\n> [0:24:11.509675200] [10635] DEBUG HAL camera_device.cpp:980  '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]  (direct)\n> [0:24:11.511309605] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video0[37:cap]: Queueing buffer 1\n> [0:24:11.528984601] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 196 started\n> [0:24:11.529446048] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Exposure to 269 at index 196\n> [0:24:11.548431632] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video4[24:out]: Dequeuing buffer 3\n> [0:24:11.548993830] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video6[25:cap]: Dequeuing buffer 2\n> [0:24:11.549320802] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video8[28:cap]: Dequeuing buffer 3\n> [0:24:11.549807736] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n> [0:24:11.549846777] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n> [0:24:11.549927350] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for  red: 1.16841 and for blue: 1.14912\n> [0:24:11.550170924] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Exposure to 269 at index 197\n> [0:24:11.550405629] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 197\n> [0:24:11.550646460] [10629] DEBUG Request request.cpp:291  Request(131:C:0/1:140736750235824)\n> [0:24:11.551245104] [10629] DEBUG HAL camera_device.cpp:1117  '\\_SB_.PCI0.I2C2.CAM0': Request 140736750235824 completed with 2 streams\n> [0:24:11.562307680] [10629] DEBUG EXIF exif.cpp:522 Created EXIF  instance (536 bytes)\n> [0:24:11.634800113] [10629] DEBUG JPEG encoder_libjpeg.cpp:220 JPEG  Encode Starting:4160x3104\n> \n> Thread 6 \"CameraModuleThr\" received signal SIGSEGV, Segmentation fault.\n> [Switching to Thread 0x7fffe7fff640 (LWP 10629)]\n> 0x00007ffff597ead5 in EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const, 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n\nNot nice :-S Could you please print frame.size() here ?\n\n> (gdb) bt\n> #0  0x00007ffff597ead5 in EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const, 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #1  0x00007ffff597eda0 in EncoderLibJpeg::encode(libcamera::Span<unsigned char const, 18446744073709551615ul>, libcamera::Span<unsigned char, 18446744073709551615ul>, libcamera::Span<unsigned char const, 18446744073709551615ul>, unsigned int) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #2  0x00007ffff597ec53 in EncoderLibJpeg::encode(libcamera::FrameBuffer const&, libcamera::Span<unsigned char, 18446744073709551615ul>, libcamera::Span<unsigned char const, 18446744073709551615ul>, unsigned int) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #3  0x00007ffff5981871 in PostProcessorJpeg::process(libcamera::FrameBuffer const&, CameraBuffer*, CameraMetadata const&, CameraMetadata*) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #4  0x00007ffff597dd8d in CameraStream::process(libcamera::FrameBuffer const&, native_handle const*, CameraMetadata const&, CameraMetadata*) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #5  0x00007ffff59717b9 in CameraDevice::requestComplete(libcamera::Request*) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #6  0x00007ffff5979a7c in libcamera::BoundMethodMember<CameraDevice, void, libcamera::Request*>::activate(libcamera::Request*, bool) () from /usr/lib64/camera_hal/libcamera-hal.so\n> #7  0x00007ffff58f9051 in libcamera::Signal<libcamera::IPCMessage const&>::emit(libcamera::IPCMessage const&) () from /usr/lib64/libcamera.so\n> #8  0x00007ffff58f8fe8 in libcamera::Camera::requestComplete(libcamera::Request*) () from /usr/lib64/libcamera.so\n> #9  0x00007ffff591f28a in libcamera::PipelineHandler::completeRequest(libcamera::Request*) () from /usr/lib64/libcamera.so\n> #10 0x00007ffff5935cef in libcamera::IPU3CameraData::queueFrameAction(unsigned int, libcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n> #11 0x00007ffff58f0b02 in libcamera::BoundMethodMember<libcamera::ipa::ipu3::IPAProxyIPU3, void, unsigned int, libcamera::ipa::ipu3::IPU3Action const&>::activate(unsigned int, libcamera::ipa::ipu3::IPU3Action const&, bool) () from /usr/lib64/libcamera.so\n> #12 0x00007ffff58edf81 in libcamera::Signal<unsigned int, libcamera::ipa::ipu3::IPU3Action const&>::emit(unsigned int, libcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n> #13 0x00007ffff58eb5b4 in libcamera::ipa::ipu3::IPAProxyIPU3::queueFrameActionThread(unsigned int, libcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n> #14 0x00007ffff587caed in libcamera::Object::message(libcamera::Message*) () from /usr/lib64/libcamera-base.so\n> #15 0x00007ffff587e00b in libcamera::Thread::dispatchMessages(libcamera::Message::Type) () from /usr/lib64/libcamera-base.so\n> #16 0x00007ffff5876925 in libcamera::EventDispatcherPoll::processEvents() () from /usr/lib64/libcamera-base.so\n> #17 0x00007ffff587d6e2 in libcamera::Thread::exec() () from /usr/lib64/libcamera-base.so\n> #18 0x00007ffff58fb582 in libcamera::CameraManager::Private::run() () from /usr/lib64/libcamera.so\n> #19 0x00007ffff587e43c in ?? () from /usr/lib64/libcamera-base.so\n> #20 0x0000000000000000 in ?? ()\n> \n> > The most important change is in patches 13/27 and 14/27, which translate\n> > between V4L2 buffers and libcamera FrameBuffer to handle the case where\n> > a multi-planar frame buffer is used with the V4L2 single-planar API.\n> > It's working more or less by chance at the moment (except in qcam where\n> > it's broken, and possibly in other places I haven't tested). Patches\n> > 01/27 to 12/27 are cleanups and additions to prepare for the work in\n> > V4L2VideoDevice, and patch 15/27 is a small cleanup on top. Patches\n> > 16/27 and 17/27 then improve the FrameBuffer class API as a cleanup.\n> >\n> > Patches 18/27 to 27/27 fix the cam and qcam applications, as well as an\n> > issue in the Android HAL. Worth being noted is patch 19/27 that\n> > introduces an Image class shared by cam and qcam. The class duplicates\n> > the MappedFrameBuffer implementation private to libcamera. I've tried to\n> > rework MappedFrameBuffer into something I would be happy to see in the\n> > public API, but failed to do so in a reasonable amount of time, and I\n> > didn't want to delay this important regression fix.\n> >\n> > This series doesn't break any unit test, as vimc doesn't support NV12.\n> > Addition of NV12 support to the vimc kernel driver would be very nice,\n> > in order to test multi-planar support in our unit tests. Volunteers are\n> > welcome ;-)\n> >\n> > Laurent Pinchart (27):\n> >    libcamera: base: utils: Use size_t for index in utils::enumerate()\n> >    libcamera: file_descriptor: Add a function to retrieve the inode\n> >    libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()\n> >    libcamera: Use V4L2PixelFormat::fromPixelFormat()\n> >    libcamera: formats: Move plane info structure to PixelFormatInfo\n> >    libcamera: formats: Add planeSize() helpers to PixelFormatInfo\n> >    libcamera: formats: Support V4L2 non-contiguous formats\n> >    libcamera: framebuffer: Move planes check to constructor\n> >    libcamera: framebuffer: Add a function to check if planes are\n> >      contiguous\n> >    libcamera: v4l2_videodevice: Cache PixelFormatInfo\n> >    libcamera: v4l2_videodevice: Document plane handling in createBuffer()\n> >    libcamera: v4l2_videodevice: Take stride into account to compute\n> >      offsets\n> >    libcamera: v4l2_videodevice: Coalesce planes when queuing buffer\n> >    libcamera: v4l2_videodevice: Split planes when dequeuing buffer\n> >    libcamera: v4l2_videodevice: Use utils::enumerate()\n> >    libcamera: framebuffer: Allocate metadata planes at construction time\n> >    libcamera: framebuffer: Prevent modifying the number of metadata\n> >      planes\n> >    android: camera_device: Don't assume all planes use the same fd\n> >    cam: Add Image class\n> >    cam: file_sink: Use Image class to access pixel data\n> >    cam: drm: Support per-plane stride values\n> >    cam: drm: Set per-plane offsets when creating DRM frame buffer\n> >    cam: drm: Avoid importing the same dmabuf multiple times\n> >    qcam: Print bytesused for all planes\n> >    qcam: Use Image class to access pixel data\n> >    qcam: viewfinder_gl: Support multi-planar buffers\n> >    qcam: viewfinder_qt: Support multi-planar buffers\n> >\n> >   include/libcamera/base/utils.h                |   4 +-\n> >   include/libcamera/file_descriptor.h           |   3 +\n> >   include/libcamera/framebuffer.h               |  19 +-\n> >   include/libcamera/internal/formats.h          |  22 +-\n> >   include/libcamera/internal/framebuffer.h      |   2 +\n> >   include/libcamera/internal/v4l2_pixelformat.h |   2 +-\n> >   include/libcamera/internal/v4l2_videodevice.h |   3 +-\n> >   src/android/camera_device.cpp                 |  25 +-\n> >   src/android/mm/generic_camera_buffer.cpp      |  11 +-\n> >   src/android/yuv/post_processor_yuv.cpp        |  10 +-\n> >   src/cam/camera_session.cpp                    |   4 +-\n> >   src/cam/drm.cpp                               |  38 +-\n> >   src/cam/drm.h                                 |   7 +-\n> >   src/cam/file_sink.cpp                         |  44 +--\n> >   src/cam/file_sink.h                           |   6 +-\n> >   src/cam/image.cpp                             | 107 +++++\n> >   src/cam/image.h                               |  52 +++\n> >   src/cam/kms_sink.cpp                          |  28 +-\n> >   src/cam/meson.build                           |   1 +\n> >   src/libcamera/file_descriptor.cpp             |  26 ++\n> >   src/libcamera/formats.cpp                     | 373 ++++++++++++++----\n> >   src/libcamera/framebuffer.cpp                 |  57 ++-\n> >   src/libcamera/pipeline/ipu3/cio2.cpp          |   4 +-\n> >   src/libcamera/pipeline/ipu3/imgu.cpp          |   2 +-\n> >   .../pipeline/raspberrypi/raspberrypi.cpp      |   8 +-\n> >   src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |   6 +-\n> >   src/libcamera/pipeline/simple/converter.cpp   |   8 +-\n> >   src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n> >   src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   6 +-\n> >   src/libcamera/pipeline/vimc/vimc.cpp          |   8 +-\n> >   src/libcamera/v4l2_pixelformat.cpp            |  11 +-\n> >   src/libcamera/v4l2_videodevice.cpp            | 196 ++++++---\n> >   src/qcam/format_converter.cpp                 |  18 +-\n> >   src/qcam/format_converter.h                   |   9 +-\n> >   src/qcam/main_window.cpp                      |  38 +-\n> >   src/qcam/main_window.h                        |   4 +-\n> >   src/qcam/meson.build                          |   1 +\n> >   src/qcam/viewfinder.h                         |   6 +-\n> >   src/qcam/viewfinder_gl.cpp                    |  45 +--\n> >   src/qcam/viewfinder_gl.h                      |   4 +-\n> >   src/qcam/viewfinder_qt.cpp                    |  20 +-\n> >   src/qcam/viewfinder_qt.h                      |   2 +-\n> >   src/v4l2/v4l2_camera_proxy.cpp                |  11 +-\n> >   test/libtest/buffer_source.cpp                |   3 +-\n> >   test/utils.cpp                                |  10 +-\n> >   45 files changed, 911 insertions(+), 357 deletions(-)\n> >   create mode 100644 src/cam/image.cpp\n> >   create mode 100644 src/cam/image.h","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 13AEBBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 12:25:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 711536916A;\n\tMon,  6 Sep 2021 14:25:09 +0200 (CEST)","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 9BE3E60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 14:25:07 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 16A618AD;\n\tMon,  6 Sep 2021 14:25:07 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Afjb5ISZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630931107;\n\tbh=ZcX3XJGLtWixiNfn5fsqPv31/mjCsuy2u+ap5jDdAYs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Afjb5ISZDnRLYULO4dplNIgMtgIeDTZethIT2fRaWLUlvHujj8upzpTljExvPWmS1\n\t1ZZVVjvJk03LaBu+qplLJiZVOHkOLxNMcC+Aiqp6FMcDMhrCiQasqcZVzyAr7+V2BO\n\tbR9pALkhi7pNiipiDbFgrSweUYopWt/Yum7ztvRY=","Date":"Mon, 6 Sep 2021 15:24:48 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YTYIkHs8wPCf0oZf@pendragon.ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19437,"web_url":"https://patchwork.libcamera.org/comment/19437/","msgid":"<CAO5uPHMtDXbxamoNm=XGpFzmqZP7FOEqQLD=BKKJxjEk5Kxw3A@mail.gmail.com>","date":"2021-09-06T12:38:10","subject":"Re: [libcamera-devel] [PATCH v2 04/27] libcamera: Use\n\tV4L2PixelFormat::fromPixelFormat()","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent, thank you for the patch.\n\nOn Mon, Sep 6, 2021 at 2:40 PM Jean-Michel Hautbois\n<jeanmichel.hautbois@ideasonboard.com> wrote:\n>\n> Hi Laurent,\n>\n> On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > Replace manual looked for V4L2 pixel format in the PixelFormatInfo with\n> > the V4L2PixelFormat::fromPixelFormat() helper function. This prepares\n> > for multi-planar support that will modify how V4L2 pixel formats are\n> > stored in PixelFormatInfo.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\n> > ---\n> >  src/libcamera/pipeline/ipu3/cio2.cpp | 4 +---\n> >  src/v4l2/v4l2_camera_proxy.cpp       | 9 +++------\n> >  2 files changed, 4 insertions(+), 9 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > index 9cedcb5b2879..dc62ab197acb 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > @@ -203,9 +203,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat)\n> >       if (itInfo == mbusCodesToPixelFormat.end())\n> >               return -EINVAL;\n> >\n> > -     const PixelFormatInfo &info = PixelFormatInfo::info(itInfo->second);\n> > -\n> > -     outputFormat->fourcc = info.v4l2Format;\n> > +     outputFormat->fourcc = V4L2PixelFormat::fromPixelFormat(itInfo->second);\n> >       outputFormat->size = sensorFormat.size;\n> >       outputFormat->planesCount = 1;\n> >\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index 07b1a90aa32f..d926a7b77083 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -164,12 +164,11 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n> >\n> >  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n> >  {\n> > -     const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat);\n> >       const Size &size = streamConfig.size;\n> >\n> >       v4l2PixFormat_.width        = size.width;\n> >       v4l2PixFormat_.height       = size.height;\n> > -     v4l2PixFormat_.pixelformat  = info.v4l2Format;\n> > +     v4l2PixFormat_.pixelformat  = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat);\n> >       v4l2PixFormat_.field        = V4L2_FIELD_NONE;\n> >       v4l2PixFormat_.bytesperline = streamConfig.stride;\n> >       v4l2PixFormat_.sizeimage    = streamConfig.frameSize;\n> > @@ -276,7 +275,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *\n> >       /* \\todo Add map from format to description. */\n> >       utils::strlcpy(reinterpret_cast<char *>(arg->description),\n> >                      \"Video Format Description\", sizeof(arg->description));\n> > -     arg->pixelformat = PixelFormatInfo::info(format).v4l2Format;\n> > +     arg->pixelformat = V4L2PixelFormat::fromPixelFormat(format);\n> >\n> >       memset(arg->reserved, 0, sizeof(arg->reserved));\n> >\n> > @@ -311,11 +310,9 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg)\n> >               return -EINVAL;\n> >       }\n> >\n> > -     const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);\n> > -\n> >       arg->fmt.pix.width        = config.size.width;\n> >       arg->fmt.pix.height       = config.size.height;\n> > -     arg->fmt.pix.pixelformat  = info.v4l2Format;\n> > +     arg->fmt.pix.pixelformat  = V4L2PixelFormat::fromPixelFormat(config.pixelFormat);\n> >       arg->fmt.pix.field        = V4L2_FIELD_NONE;\n> >       arg->fmt.pix.bytesperline = config.stride;\n> >       arg->fmt.pix.sizeimage    = config.frameSize;\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 876F1BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 12:38:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E48AA60137;\n\tMon,  6 Sep 2021 14:38:23 +0200 (CEST)","from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com\n\t[IPv6:2a00:1450:4864:20::62a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F48F60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 14:38:22 +0200 (CEST)","by mail-ej1-x62a.google.com with SMTP id x11so13335436ejv.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 05:38:22 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"lgYibNhA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=kS3vIhQKifp7j2spgKcM9WN1KEg5zHB8TB94UcR7UlE=;\n\tb=lgYibNhAHqjADgJmn84UR9saeTgX3lDWcp1mXTHwlf19Qbex5+soH0JSG3x4NeGBPs\n\tz4RWAGZaepJYIq8jmaUKCbjtAeNuCOTj/vpM+6EUrtVIcfPLCrwfuaG6ce4g+sqA4meI\n\tHbQkCkm7dSYXJ0R7XtY83/mbBv/fulBGcHWUk=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=kS3vIhQKifp7j2spgKcM9WN1KEg5zHB8TB94UcR7UlE=;\n\tb=FqJGhh8IyPUuNd0wwb8uB8623VtWHDkXS1mr+0kPBVk1nby0xdSchVsIG9sTUt+BxF\n\t+DtrbsyIo7BHHctBxHLZFNb2X2/UrSS83XIVYHC1+jWSf8R5xxq1rRznVqwbfUcF+wQ5\n\tKYX6TtrhpAC1puEKY9WZzWrG1Nc48mU3OEcXRPk9gYqQ7DMJwO60w2vbJddIFZJ4iTRx\n\tKf4YvchEWi4EDqY0is7DF6UVChm/JtXJQN85y/ONmNcfc/fOqZFfZ7P5RJrLU6OUn/oV\n\tIaIiM2gttCa5jxCYuP1oFxFkkFJ9FuHqqjt8aXaH8Q4te4qgLeBdtE7+oKw7Ni2TDkLf\n\tvF/A==","X-Gm-Message-State":"AOAM531URHa6KOmklXqkLPZBNDD5hC7iBGrwHhvKuAk+kbujQHMuFDVc\n\tEMyjqrZAajOb7Ra7Cepg/95Spwob0Qbv9gHSwWlqLA==","X-Google-Smtp-Source":"ABdhPJzDeY8i2vTEssEwiSdMIhZIVvT6FBCQ3KpHO+thJ9jnQ7izNenqFBKZirrM421j12Wqrt0oB7uY7b48aRt44yU=","X-Received":"by 2002:a17:906:f289:: with SMTP id\n\tgu9mr13139554ejb.559.1630931901761; \n\tMon, 06 Sep 2021 05:38:21 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-5-laurent.pinchart@ideasonboard.com>\n\t<7b23af90-5c75-3b5a-4cc2-b8e7d0db3862@ideasonboard.com>","In-Reply-To":"<7b23af90-5c75-3b5a-4cc2-b8e7d0db3862@ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 6 Sep 2021 21:38:10 +0900","Message-ID":"<CAO5uPHMtDXbxamoNm=XGpFzmqZP7FOEqQLD=BKKJxjEk5Kxw3A@mail.gmail.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 04/27] libcamera: Use\n\tV4L2PixelFormat::fromPixelFormat()","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19439,"web_url":"https://patchwork.libcamera.org/comment/19439/","msgid":"<CAO5uPHPiMJpY-tm+Gx4u=yJWt4LMRvrFW6aaHuKnGLGKJ2--Xw@mail.gmail.com>","date":"2021-09-06T12:40:32","subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent,\n\nOn Mon, Sep 6, 2021 at 8:41 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Hiro,\n>\n> On Mon, Sep 06, 2021 at 08:37:26PM +0900, Hirokazu Honda wrote:\n> > On Mon, Sep 6, 2021 at 6:04 PM <paul.elder@ideasonboard.com> wrote:\n> > > On Mon, Sep 06, 2021 at 05:00:35AM +0300, Laurent Pinchart wrote:\n> > > > The inode is useful to check if two file descriptors refer to the same\n> > > > file. Add a function to retrieve it.\n> > > >\n> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > >\n> > > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> > >\n> > > > ---\n> > > > Changes since v1:\n> > > >\n> > > > - Use isValid() instead of open-coding it\n> > > > - Print a message on error\n> > > > ---\n> > > >  include/libcamera/file_descriptor.h |  3 +++\n> > > >  src/libcamera/file_descriptor.cpp   | 26 ++++++++++++++++++++++++++\n> > > >  2 files changed, 29 insertions(+)\n> > > >\n> > > > diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h\n> > > > index d514aac7697b..988f9b7a3d25 100644\n> > > > --- a/include/libcamera/file_descriptor.h\n> > > > +++ b/include/libcamera/file_descriptor.h\n> > > > @@ -8,6 +8,7 @@\n> > > >  #define __LIBCAMERA_FILE_DESCRIPTOR_H__\n> > > >\n> > > >  #include <memory>\n> > > > +#include <sys/types.h>\n> > > >\n> > > >  namespace libcamera {\n> > > >\n> > > > @@ -27,6 +28,8 @@ public:\n> > > >       int fd() const { return fd_ ? fd_->fd() : -1; }\n> > > >       FileDescriptor dup() const;\n> > > >\n> > > > +     ino_t inode() const;\n> > > > +\n> > > >  private:\n> > > >       class Descriptor\n> > > >       {\n> > > > diff --git a/src/libcamera/file_descriptor.cpp b/src/libcamera/file_descriptor.cpp\n> > > > index 9f9ebc81f738..0409c3e1758c 100644\n> > > > --- a/src/libcamera/file_descriptor.cpp\n> > > > +++ b/src/libcamera/file_descriptor.cpp\n> > > > @@ -8,6 +8,8 @@\n> > > >  #include <libcamera/file_descriptor.h>\n> > > >\n> > > >  #include <string.h>\n> > > > +#include <sys/stat.h>\n> > > > +#include <sys/types.h>\n> > > >  #include <unistd.h>\n> > > >  #include <utility>\n> > > >\n> > > > @@ -221,6 +223,30 @@ FileDescriptor FileDescriptor::dup() const\n> > > >       return FileDescriptor(fd());\n> > > >  }\n> > > >\n> > > > +/**\n> > > > + * \\brief Retrieve the file descriptor inode\n> > > > + *\n> > > > + * \\todo Should this move to the File class ?\n> > > > + *\n> > > > + * \\return The file descriptor inode on success, or 0 on error\n> > > > + */\n> > > > +ino_t FileDescriptor::inode() const\n> > > > +{\n> > > > +     if (!isValid())\n> > > > +             return 0;\n> > > > +\n> > > > +     struct stat st;\n> > > > +     int ret = fstat(fd_->fd(), &st);\n> > > > +     if (ret < 0) {\n> > > > +             ret = -errno;\n> > > > +             LOG(FileDescriptor, Fatal)\n> > > > +                     << \"Failed to fstat() fd: \" << strerror(-ret);\n> >\n> > Setting errno to ret is unnecessary?\n> >\n> > if (ret < 0) {\n> >    LOG(FileDescriptor, Fatal) << \"Failed to fstat() fd: \" << stderr(errno);\n> >   return 0;\n> > }\n>\n> The LOG() macros constructs a LogMessage object, and it may change errno\n> before strerror() is called. The same is possibly true of the\n> operator<<() calls, or other function calls in the log line. Maybe it\n> can't happen in this specific case, but we always assign ret = -errno to\n> be safe.\n>\n\nAh, I didn't notice it. Thanks for explaining.\n\n-Hiro\n\n> > Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> >\n> > > > +             return 0;\n> > > > +     }\n> > > > +\n> > > > +     return st.st_ino;\n> > > > +}\n> > > > +\n> > > >  FileDescriptor::Descriptor::Descriptor(int fd, bool duplicate)\n> > > >  {\n> > > >       if (!duplicate) {\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8D5CABDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 12:40:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 464F269167;\n\tMon,  6 Sep 2021 14:40:46 +0200 (CEST)","from mail-ed1-x534.google.com (mail-ed1-x534.google.com\n\t[IPv6:2a00:1450:4864:20::534])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6EBED60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 14:40:44 +0200 (CEST)","by mail-ed1-x534.google.com with SMTP id i6so9397288edu.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 05:40:44 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"b9DdmUrO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=gqY/4bHNeRJkSonVjqCrVpCyewaZU6lhzvOp7F8f8VU=;\n\tb=b9DdmUrOCEFpiUV0LSbhTkUeZA9cIRr8a+xFiT2YzMWFpvuGj+WbaQA7fj9ibB1J9w\n\tmnu3ZARyvmxKvmBJ8CG9G+Hcb+pByZu1REF60tK2Pl5x2ep1Q6X/3C7cVwTDEXingsTf\n\t9xPA5OXK5v4luSprviMb0eqINFk/e+UIHWTJ8=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=gqY/4bHNeRJkSonVjqCrVpCyewaZU6lhzvOp7F8f8VU=;\n\tb=iYw26eySuIpf8E5zo1xXorV2JX82+hIoge6R2631H/X00cmRMGgLUB887VX52T+BtD\n\tMrJMwU7FhLwf3y6KuFprrr8XZDyr16vpMbcL7yIs4fExPWBzpiKMiofEE3iEkNYQmqts\n\t4Jf7NQZA6y7ogk4i5Y2pU73TzXag/R9jdMukdUykRI4mgbXjLtN4qFjuqJx6pmJb3w4k\n\txrRsw7Jasv9D8uIeYmL1IlSpdnvfpCm/zzXVKvs0Pa5U2qORz1MtPP4zzxdcPEpFNJwQ\n\tAqIJbjcRc3XqNHRRAHAaVimc9bJB0X1VfE7L6v/ljDjRFTkjEjmosRTC9h7Y8EKHo/Z3\n\tisiQ==","X-Gm-Message-State":"AOAM530Pj6Uno7KbS1Im8I4LlwH/nZXvbD2k6mqJcMgQ+RDa1vrCqry/\n\tYXb+1trF5jz52oZgBQPyv8Vr+kHuhtlkFw4flybNVuVNFO4=","X-Google-Smtp-Source":"ABdhPJzzTdgboBpeDDkshhKznjLBjPJTb91vqUPxdZIxdASg4SeTqN5r+eBIWkzlL/hBvdZm7M2Vn2I1H1pQj+dvzGk=","X-Received":"by 2002:a05:6402:1385:: with SMTP id\n\tb5mr12840537edv.276.1630932044103; \n\tMon, 06 Sep 2021 05:40:44 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-3-laurent.pinchart@ideasonboard.com>\n\t<20210906090444.GT968527@pyrite.rasen.tech>\n\t<CAO5uPHPsr+mvrd2ABo2hwTtt92FyVndF0XPSZR2KtAyZqjzBDg@mail.gmail.com>\n\t<YTX+b/Xrr75gJy2C@pendragon.ideasonboard.com>","In-Reply-To":"<YTX+b/Xrr75gJy2C@pendragon.ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 6 Sep 2021 21:40:32 +0900","Message-ID":"<CAO5uPHPiMJpY-tm+Gx4u=yJWt4LMRvrFW6aaHuKnGLGKJ2--Xw@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 02/27] libcamera: file_descriptor:\n\tAdd a function to retrieve the inode","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19442,"web_url":"https://patchwork.libcamera.org/comment/19442/","msgid":"<9349cf7a-30d4-48d9-f842-5a246ec0befe@ideasonboard.com>","date":"2021-09-06T12:54:21","subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 9/6/21 5:54 PM, Laurent Pinchart wrote:\n> Hi Umang,\n>\n> On Mon, Sep 06, 2021 at 03:38:04PM +0530, Umang Jain wrote:\n>> On 9/6/21 7:30 AM, Laurent Pinchart wrote:\n>>> Hello everybody,\n>>>\n>>> This patch series started as an investigation of a qcam failure with\n>>> IPU3 after the merge of the FrameBuffer offset support. While a hack in\n>>> qcam would be possible, I decided to instead address the core issue and\n>>> fix it in V4L2VideoDevice.\n>>>\n>>> Compared to v1, the series now includes fixes for cam and qcam in\n>>> addition to the changes needed in the libcamera core. They have been\n>>> tested with the Raspberry Pi, IPU3, VIMC and UVC pipeline handlers.\n>>>\n>>> The GStreamer element seems to work fine without any change required.\n>>> The V4L2 compatibility layer is still broken, and I haven't tested the\n>>> Android HAL yet (any volunteer ?).\n>> I am applied this series on top of master and tested on nautilus.\n>> Streaming seems fine to me, although it was appearing more choppy than\n>> usual.\n>>\n>> Now that I see, entire nautilus seems laggy to respond in general. One\n>> \"Chrome\" process hogging 50% CPU, seems like a transient issue.\n>>\n>> So, streaming seems fine on multiple runs, with multiple resolutions\n>> selections (from the camera-app menu), however, requesting MJPEG\n>> (shutter-click) results in a segfault.\n> Thanks for testing !\n>\n>> The stack trace is below:\n>>\n>> [0:24:11.415660787] [10635] DEBUG HAL camera_device.cpp:941 '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750235824 with 2 streams\n>> [0:24:11.415858538] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is not contiguous\n>> [0:24:11.415905500] [10635] DEBUG HAL camera_device.cpp:980 '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] (direct)\n>> [0:24:11.415943620] [10635] DEBUG HAL camera_device.cpp:966 '\\_SB_.PCI0.I2C2.CAM0': 1 - (4160x3104)[0x00000021] -> (4160x3104)[NV12] (mapped)\n>> [0:24:11.416461639] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582 /dev/video0[37:cap]: Queueing buffer 3\n>> [0:24:11.428903141] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650 /dev/video0[37:cap]: Dequeuing buffer 2\n>> [0:24:11.429095316] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature estimated: 6644\n>> [0:24:11.429563781] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 193 started\n>> [0:24:11.429627478] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Exposure to 269 at index 193\n>> [0:24:11.429683048] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video6[25:cap]: Queueing buffer 1\n>> [0:24:11.436615191] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video5[27:out]: Queueing buffer 2\n>> [0:24:11.436718629] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video8[28:cap]: Queueing buffer 2\n>> [0:24:11.436799420] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video4[24:out]: Queueing buffer 2\n>> [0:24:11.457388821] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video4[24:out]: Dequeuing buffer 1\n>> [0:24:11.457948159] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video6[25:cap]: Dequeuing buffer 0\n>> [0:24:11.458257692] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video5[27:out]: Dequeuing buffer 2\n>> [0:24:11.458525315] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video8[28:cap]: Dequeuing buffer 1\n>> [0:24:11.458968848] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n>> [0:24:11.459005634] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n>> [0:24:11.459082715] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for  red: 1.16864 and for blue: 1.14863\n>> [0:24:11.459325998] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Exposure to 269 at index 194\n>> [0:24:11.459562485] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 194\n>> [0:24:11.459815347] [10629] DEBUG Request request.cpp:291  Request(129:C:0/1:140736750229136)\n>> [0:24:11.460390126] [10629] DEBUG HAL camera_device.cpp:1117  '\\_SB_.PCI0.I2C2.CAM0': Request 140736750229136 completed with 1 streams\n>> [0:24:11.461855854] [10635] DEBUG Request request.cpp:94 Created request  - cookie: 140736750230064\n>> [0:24:11.461939858] [10635] DEBUG HAL camera_device.cpp:941  '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750230064 with 1 streams\n>> [0:24:11.462057435] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is  not contiguous\n>> [0:24:11.462098906] [10635] DEBUG HAL camera_device.cpp:980  '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]  (direct)\n>> [0:24:11.463164722] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 194 started\n>> [0:24:11.463730946] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 193\n>> [0:24:11.464033686] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Exposure to 269 at index 194\n>> [0:24:11.464329869] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video0[37:cap]: Queueing buffer 0\n>> [0:24:11.495739092] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 195 started\n>> [0:24:11.496489311] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Analogue Gain to 477 at index 194\n>> [0:24:11.496737385] [10629] DEBUG DelayedControls  delayed_controls.cpp:285 Queue is empty, auto queue no-op.\n>> [0:24:11.497044311] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video0[37:cap]: Dequeuing buffer 3\n>> [0:24:11.497335155] [10643] DEBUG IPU3Awb awb.cpp:331 Color temperature  estimated: 6658\n>> [0:24:11.497528845] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video6[25:cap]: Queueing buffer 2\n>> [0:24:11.503589322] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video5[27:out]: Queueing buffer 3\n>> [0:24:11.504027344] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video8[28:cap]: Queueing buffer 3\n>> [0:24:11.504287330] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video4[24:out]: Queueing buffer 3\n>> [0:24:11.504712501] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video4[24:out]: Dequeuing buffer 2\n>> [0:24:11.505005096] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video6[25:cap]: Dequeuing buffer 1\n>> [0:24:11.505260331] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video5[27:out]: Dequeuing buffer 3\n>> [0:24:11.505506837] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video8[28:cap]: Dequeuing buffer 2\n>> [0:24:11.505940926] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n>> [0:24:11.505976974] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n>> [0:24:11.506057427] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for  red: 1.16797 and for blue: 1.14978\n>> [0:24:11.506297848] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Exposure to 269 at index 196\n>> [0:24:11.506547021] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 196\n>> [0:24:11.506796456] [10629] DEBUG Request request.cpp:291  Request(130:C:0/1:140736750225984)\n>> [0:24:11.507374522] [10629] DEBUG HAL camera_device.cpp:1117  '\\_SB_.PCI0.I2C2.CAM0': Request 140736750225984 completed with 1 streams\n>> [0:24:11.509426987] [10635] DEBUG Request request.cpp:94 Created request  - cookie: 140736750227664\n>> [0:24:11.509507039] [10635] DEBUG HAL camera_device.cpp:941  '\\_SB_.PCI0.I2C2.CAM0': Queueing request 140736750227664 with 1 streams\n>> [0:24:11.509630706] [10635] DEBUG Buffer framebuffer.cpp:249 Buffer is  not contiguous\n>> [0:24:11.509675200] [10635] DEBUG HAL camera_device.cpp:980  '\\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12]  (direct)\n>> [0:24:11.511309605] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1582  /dev/video0[37:cap]: Queueing buffer 1\n>> [0:24:11.528984601] [10629] DEBUG DelayedControls  delayed_controls.cpp:237 frame 196 started\n>> [0:24:11.529446048] [10629] DEBUG DelayedControls  delayed_controls.cpp:272 Setting Exposure to 269 at index 196\n>> [0:24:11.548431632] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video4[24:out]: Dequeuing buffer 3\n>> [0:24:11.548993830] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video6[25:cap]: Dequeuing buffer 2\n>> [0:24:11.549320802] [10629] DEBUG V4L2 v4l2_videodevice.cpp:1650  /dev/video8[28:cap]: Dequeuing buffer 3\n>> [0:24:11.549807736] [10643] DEBUG IPU3Awb awb.cpp:270 Valid zones: 186\n>> [0:24:11.549846777] [10643] DEBUG IPU3Awb awb.cpp:224 Grey world AWB\n>> [0:24:11.549927350] [10643] DEBUG IPU3Awb awb.cpp:273 Gain found for  red: 1.16841 and for blue: 1.14912\n>> [0:24:11.550170924] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Exposure to 269 at index 197\n>> [0:24:11.550405629] [10629] DEBUG DelayedControls  delayed_controls.cpp:179 Queuing Analogue Gain to 477 at index 197\n>> [0:24:11.550646460] [10629] DEBUG Request request.cpp:291  Request(131:C:0/1:140736750235824)\n>> [0:24:11.551245104] [10629] DEBUG HAL camera_device.cpp:1117  '\\_SB_.PCI0.I2C2.CAM0': Request 140736750235824 completed with 2 streams\n>> [0:24:11.562307680] [10629] DEBUG EXIF exif.cpp:522 Created EXIF  instance (536 bytes)\n>> [0:24:11.634800113] [10629] DEBUG JPEG encoder_libjpeg.cpp:220 JPEG  Encode Starting:4160x3104\n>>\n>> Thread 6 \"CameraModuleThr\" received signal SIGSEGV, Segmentation fault.\n>> [Switching to Thread 0x7fffe7fff640 (LWP 10629)]\n>> 0x00007ffff597ead5 in EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const, 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n> Not nice :-S Could you please print frame.size() here ?\n\n\n[3:11:40.303057525] [25328] DEBUG EXIF exif.cpp:522 Created EXIF \ninstance (536 bytes)\n[3:11:40.368109082] [25328] DEBUG JPEG encoder_libjpeg.cpp:222 JPEG \nEncode Starting:4160x3104\n[3:11:40.368158138] [25328] DEBUG JPEG encoder_libjpeg.cpp:128 Frame \nsize : 12912640\nSegmentation fault (core dumped)\n\n>\n>> (gdb) bt\n>> #0  0x00007ffff597ead5 in EncoderLibJpeg::compressNV(libcamera::Span<unsigned char const, 18446744073709551615ul>) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #1  0x00007ffff597eda0 in EncoderLibJpeg::encode(libcamera::Span<unsigned char const, 18446744073709551615ul>, libcamera::Span<unsigned char, 18446744073709551615ul>, libcamera::Span<unsigned char const, 18446744073709551615ul>, unsigned int) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #2  0x00007ffff597ec53 in EncoderLibJpeg::encode(libcamera::FrameBuffer const&, libcamera::Span<unsigned char, 18446744073709551615ul>, libcamera::Span<unsigned char const, 18446744073709551615ul>, unsigned int) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #3  0x00007ffff5981871 in PostProcessorJpeg::process(libcamera::FrameBuffer const&, CameraBuffer*, CameraMetadata const&, CameraMetadata*) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #4  0x00007ffff597dd8d in CameraStream::process(libcamera::FrameBuffer const&, native_handle const*, CameraMetadata const&, CameraMetadata*) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #5  0x00007ffff59717b9 in CameraDevice::requestComplete(libcamera::Request*) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #6  0x00007ffff5979a7c in libcamera::BoundMethodMember<CameraDevice, void, libcamera::Request*>::activate(libcamera::Request*, bool) () from /usr/lib64/camera_hal/libcamera-hal.so\n>> #7  0x00007ffff58f9051 in libcamera::Signal<libcamera::IPCMessage const&>::emit(libcamera::IPCMessage const&) () from /usr/lib64/libcamera.so\n>> #8  0x00007ffff58f8fe8 in libcamera::Camera::requestComplete(libcamera::Request*) () from /usr/lib64/libcamera.so\n>> #9  0x00007ffff591f28a in libcamera::PipelineHandler::completeRequest(libcamera::Request*) () from /usr/lib64/libcamera.so\n>> #10 0x00007ffff5935cef in libcamera::IPU3CameraData::queueFrameAction(unsigned int, libcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n>> #11 0x00007ffff58f0b02 in libcamera::BoundMethodMember<libcamera::ipa::ipu3::IPAProxyIPU3, void, unsigned int, libcamera::ipa::ipu3::IPU3Action const&>::activate(unsigned int, libcamera::ipa::ipu3::IPU3Action const&, bool) () from /usr/lib64/libcamera.so\n>> #12 0x00007ffff58edf81 in libcamera::Signal<unsigned int, libcamera::ipa::ipu3::IPU3Action const&>::emit(unsigned int, libcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n>> #13 0x00007ffff58eb5b4 in libcamera::ipa::ipu3::IPAProxyIPU3::queueFrameActionThread(unsigned int, libcamera::ipa::ipu3::IPU3Action const&) () from /usr/lib64/libcamera.so\n>> #14 0x00007ffff587caed in libcamera::Object::message(libcamera::Message*) () from /usr/lib64/libcamera-base.so\n>> #15 0x00007ffff587e00b in libcamera::Thread::dispatchMessages(libcamera::Message::Type) () from /usr/lib64/libcamera-base.so\n>> #16 0x00007ffff5876925 in libcamera::EventDispatcherPoll::processEvents() () from /usr/lib64/libcamera-base.so\n>> #17 0x00007ffff587d6e2 in libcamera::Thread::exec() () from /usr/lib64/libcamera-base.so\n>> #18 0x00007ffff58fb582 in libcamera::CameraManager::Private::run() () from /usr/lib64/libcamera.so\n>> #19 0x00007ffff587e43c in ?? () from /usr/lib64/libcamera-base.so\n>> #20 0x0000000000000000 in ?? ()\n>>\n>>> The most important change is in patches 13/27 and 14/27, which translate\n>>> between V4L2 buffers and libcamera FrameBuffer to handle the case where\n>>> a multi-planar frame buffer is used with the V4L2 single-planar API.\n>>> It's working more or less by chance at the moment (except in qcam where\n>>> it's broken, and possibly in other places I haven't tested). Patches\n>>> 01/27 to 12/27 are cleanups and additions to prepare for the work in\n>>> V4L2VideoDevice, and patch 15/27 is a small cleanup on top. Patches\n>>> 16/27 and 17/27 then improve the FrameBuffer class API as a cleanup.\n>>>\n>>> Patches 18/27 to 27/27 fix the cam and qcam applications, as well as an\n>>> issue in the Android HAL. Worth being noted is patch 19/27 that\n>>> introduces an Image class shared by cam and qcam. The class duplicates\n>>> the MappedFrameBuffer implementation private to libcamera. I've tried to\n>>> rework MappedFrameBuffer into something I would be happy to see in the\n>>> public API, but failed to do so in a reasonable amount of time, and I\n>>> didn't want to delay this important regression fix.\n>>>\n>>> This series doesn't break any unit test, as vimc doesn't support NV12.\n>>> Addition of NV12 support to the vimc kernel driver would be very nice,\n>>> in order to test multi-planar support in our unit tests. Volunteers are\n>>> welcome ;-)\n>>>\n>>> Laurent Pinchart (27):\n>>>     libcamera: base: utils: Use size_t for index in utils::enumerate()\n>>>     libcamera: file_descriptor: Add a function to retrieve the inode\n>>>     libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()\n>>>     libcamera: Use V4L2PixelFormat::fromPixelFormat()\n>>>     libcamera: formats: Move plane info structure to PixelFormatInfo\n>>>     libcamera: formats: Add planeSize() helpers to PixelFormatInfo\n>>>     libcamera: formats: Support V4L2 non-contiguous formats\n>>>     libcamera: framebuffer: Move planes check to constructor\n>>>     libcamera: framebuffer: Add a function to check if planes are\n>>>       contiguous\n>>>     libcamera: v4l2_videodevice: Cache PixelFormatInfo\n>>>     libcamera: v4l2_videodevice: Document plane handling in createBuffer()\n>>>     libcamera: v4l2_videodevice: Take stride into account to compute\n>>>       offsets\n>>>     libcamera: v4l2_videodevice: Coalesce planes when queuing buffer\n>>>     libcamera: v4l2_videodevice: Split planes when dequeuing buffer\n>>>     libcamera: v4l2_videodevice: Use utils::enumerate()\n>>>     libcamera: framebuffer: Allocate metadata planes at construction time\n>>>     libcamera: framebuffer: Prevent modifying the number of metadata\n>>>       planes\n>>>     android: camera_device: Don't assume all planes use the same fd\n>>>     cam: Add Image class\n>>>     cam: file_sink: Use Image class to access pixel data\n>>>     cam: drm: Support per-plane stride values\n>>>     cam: drm: Set per-plane offsets when creating DRM frame buffer\n>>>     cam: drm: Avoid importing the same dmabuf multiple times\n>>>     qcam: Print bytesused for all planes\n>>>     qcam: Use Image class to access pixel data\n>>>     qcam: viewfinder_gl: Support multi-planar buffers\n>>>     qcam: viewfinder_qt: Support multi-planar buffers\n>>>\n>>>    include/libcamera/base/utils.h                |   4 +-\n>>>    include/libcamera/file_descriptor.h           |   3 +\n>>>    include/libcamera/framebuffer.h               |  19 +-\n>>>    include/libcamera/internal/formats.h          |  22 +-\n>>>    include/libcamera/internal/framebuffer.h      |   2 +\n>>>    include/libcamera/internal/v4l2_pixelformat.h |   2 +-\n>>>    include/libcamera/internal/v4l2_videodevice.h |   3 +-\n>>>    src/android/camera_device.cpp                 |  25 +-\n>>>    src/android/mm/generic_camera_buffer.cpp      |  11 +-\n>>>    src/android/yuv/post_processor_yuv.cpp        |  10 +-\n>>>    src/cam/camera_session.cpp                    |   4 +-\n>>>    src/cam/drm.cpp                               |  38 +-\n>>>    src/cam/drm.h                                 |   7 +-\n>>>    src/cam/file_sink.cpp                         |  44 +--\n>>>    src/cam/file_sink.h                           |   6 +-\n>>>    src/cam/image.cpp                             | 107 +++++\n>>>    src/cam/image.h                               |  52 +++\n>>>    src/cam/kms_sink.cpp                          |  28 +-\n>>>    src/cam/meson.build                           |   1 +\n>>>    src/libcamera/file_descriptor.cpp             |  26 ++\n>>>    src/libcamera/formats.cpp                     | 373 ++++++++++++++----\n>>>    src/libcamera/framebuffer.cpp                 |  57 ++-\n>>>    src/libcamera/pipeline/ipu3/cio2.cpp          |   4 +-\n>>>    src/libcamera/pipeline/ipu3/imgu.cpp          |   2 +-\n>>>    .../pipeline/raspberrypi/raspberrypi.cpp      |   8 +-\n>>>    src/libcamera/pipeline/rkisp1/rkisp1_path.cpp |   6 +-\n>>>    src/libcamera/pipeline/simple/converter.cpp   |   8 +-\n>>>    src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n>>>    src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   6 +-\n>>>    src/libcamera/pipeline/vimc/vimc.cpp          |   8 +-\n>>>    src/libcamera/v4l2_pixelformat.cpp            |  11 +-\n>>>    src/libcamera/v4l2_videodevice.cpp            | 196 ++++++---\n>>>    src/qcam/format_converter.cpp                 |  18 +-\n>>>    src/qcam/format_converter.h                   |   9 +-\n>>>    src/qcam/main_window.cpp                      |  38 +-\n>>>    src/qcam/main_window.h                        |   4 +-\n>>>    src/qcam/meson.build                          |   1 +\n>>>    src/qcam/viewfinder.h                         |   6 +-\n>>>    src/qcam/viewfinder_gl.cpp                    |  45 +--\n>>>    src/qcam/viewfinder_gl.h                      |   4 +-\n>>>    src/qcam/viewfinder_qt.cpp                    |  20 +-\n>>>    src/qcam/viewfinder_qt.h                      |   2 +-\n>>>    src/v4l2/v4l2_camera_proxy.cpp                |  11 +-\n>>>    test/libtest/buffer_source.cpp                |   3 +-\n>>>    test/utils.cpp                                |  10 +-\n>>>    45 files changed, 911 insertions(+), 357 deletions(-)\n>>>    create mode 100644 src/cam/image.cpp\n>>>    create mode 100644 src/cam/image.h","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B78F8BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 12:54:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6EDB16916A;\n\tMon,  6 Sep 2021 14:54:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00FFA60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 14:54:27 +0200 (CEST)","from [192.168.1.104] (unknown [103.251.226.180])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 034448AD;\n\tMon,  6 Sep 2021 14:54:25 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"mCCR9kEy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630932866;\n\tbh=XuPZ25CgRwLx1WISpbYllv3yDNuEFw8jA4K6wcpRGzc=;\n\th=Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=mCCR9kEyV6frXcq8zdBvjalPTCaWz3V+n5wdfSaypK/miJxgm+cqe5hu2zndcuOar\n\tWYyx+Ky2SYIE/Wxa0XDYN69XQsX286oUidO9Je1WB6ZRIFFRO1l68ScDZ4FEkkwERr\n\tCi+LuevuYOJFZwXTiqCnA9eaKUnH1REKCqekPGlo=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<551da75d-1e5e-590d-a29e-54112cb3dc0e@ideasonboard.com>\n\t<YTYIkHs8wPCf0oZf@pendragon.ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<9349cf7a-30d4-48d9-f842-5a246ec0befe@ideasonboard.com>","Date":"Mon, 6 Sep 2021 18:24:21 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<YTYIkHs8wPCf0oZf@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"8bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v2 00/27] libcamera: Handle fallout of\n\tFrameBuffer offset support","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19443,"web_url":"https://patchwork.libcamera.org/comment/19443/","msgid":"<CAO5uPHNCNKtLT+5Y83+9UtpqZjO64453HFedpdW=zFzz95A3_w@mail.gmail.com>","date":"2021-09-06T13:01:00","subject":"Re: [libcamera-devel] [PATCH v2 12/27] libcamera: v4l2_videodevice:\n\tTake stride into account to compute offsets","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent, thank you for the patch.\n\nOn Mon, Sep 6, 2021 at 4:13 PM Jean-Michel Hautbois\n<jeanmichel.hautbois@ideasonboard.com> wrote:\n>\n> Hi Laurent,\n>\n> On 06/09/2021 04:00, Laurent Pinchart wrote:\n> > When creating FrameBuffer instances, the V4L2VideoDevice computes plane\n> > offsets using minimal stride for the format. This doesn't always produce\n> > a valid result when the device requires padding at the end of lines. Fix\n> > it by computing offsets using the stride reported by V4L2.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> > ---\n> >  src/libcamera/v4l2_videodevice.cpp | 16 +++++++++++++---\n> >  1 file changed, 13 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index 88535f5a07c7..c6c9263c49e9 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -1354,11 +1354,21 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n> >               size_t offset = 0;\n> >\n> >               for (size_t i = 0; i < planes.size(); ++i) {\n> > +                     /*\n> > +                      * The stride is reported by V4L2 for the first plane\n> > +                      * only. Compute the stride of the other planes by\n> > +                      * taking the horizontal subsampling factor into\n> > +                      * account, which is equal to the bytesPerGroup ratio of\n> > +                      * the planes.\n> > +                      */\n> > +                     unsigned int stride = format_.planes[0].bpl\n> > +                                         * formatInfo_->planes[i].bytesPerGroup\n> > +                                         / formatInfo_->planes[0].bytesPerGroup;\n> > +\n> >                       planes[i].fd = fd;\n> >                       planes[i].offset = offset;\n> > -\n> > -                     /* \\todo Take the V4L2 stride into account */\n> > -                     planes[i].length = formatInfo_->planeSize(format_.size, i);\n> > +                     planes[i].length = formatInfo_->planeSize(format_.size.height,\n> > +                                                               i, stride);\n> >                       offset += planes[i].length;\n> >               }\n> >       }\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 57A15BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 13:01:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AAB0E6916A;\n\tMon,  6 Sep 2021 15:01:13 +0200 (CEST)","from mail-ej1-x636.google.com (mail-ej1-x636.google.com\n\t[IPv6:2a00:1450:4864:20::636])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF71E60137\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Sep 2021 15:01:11 +0200 (CEST)","by mail-ej1-x636.google.com with SMTP id jg16so13403597ejc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Sep 2021 06:01:11 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"nwVAS23h\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=CZA6IplzEHT+/RZznD0uDA8L3VMzPED8f3hKbua3zSc=;\n\tb=nwVAS23hT1ceyOWG2JlwwlJcnmhNJ5TkxPAPfNWsfhLQPQDu9PrKzE9yxpPsq1rDTG\n\t5LmH9Sz6YK4UoW9scV8vh1JyVc8I5oKIo080CpWAZT6TCzZQgpgfn+/9GPN0Trp1MKOB\n\t9vIOTxlusdddpZvgFIklsEtLNheQTPw2/s1Tk=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=CZA6IplzEHT+/RZznD0uDA8L3VMzPED8f3hKbua3zSc=;\n\tb=btDCHFzbQUo8R5Y30X7Prp0fdPRmZZ5ID6BH5f4fIpAaPqrlvxugpl47flXW1VcuVN\n\tPZBnQhBCMYSLQ5Jr3kqUxc8A4TusVJV64swoiW3PLfHFOOcQosAIcKHbFdcKLDBHbPHY\n\tFHYU+x1R78uXzwu2D4eU2qQmtY/QbAyEN1tv9G/7FJgEH86rjtUWsK91rA/grbZkhpKh\n\tYOE/BB70pLs+eyowbUvMy7lngre+yfJaP4RJbxrORhZkOhpcRQVprOJL/Ao7GiGhVHN1\n\tFEg2uwftR8+Y31VOODDyFTfQgdjgrOmTv68uoUsyapITy2ExLh4Aa0udDMf0TnCVfE0D\n\tnDCg==","X-Gm-Message-State":"AOAM530X2i57XFBKjAoPkY8QpbfP8xs/cSgT7RrtKTNmI8g/JTa/QstK\n\tnDyPwAMwCg7LDHg4sejxMA5s0vwlAnnpibmmY+hnog==","X-Google-Smtp-Source":"ABdhPJyVB+3ZHsJ4ph3Ptzx/seX4llJJEnTXblLcs4dRSVnzOhS7aAYoLXHiGgYviNfRmId5NhStZijoMHi5ki1O96k=","X-Received":"by 2002:a17:906:3589:: with SMTP id\n\to9mr13946056ejb.150.1630933271392; \n\tMon, 06 Sep 2021 06:01:11 -0700 (PDT)","MIME-Version":"1.0","References":"<20210906020100.14430-1-laurent.pinchart@ideasonboard.com>\n\t<20210906020100.14430-13-laurent.pinchart@ideasonboard.com>\n\t<7ceb7baf-814c-1183-d78d-6b265c855937@ideasonboard.com>","In-Reply-To":"<7ceb7baf-814c-1183-d78d-6b265c855937@ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 6 Sep 2021 22:01:00 +0900","Message-ID":"<CAO5uPHNCNKtLT+5Y83+9UtpqZjO64453HFedpdW=zFzz95A3_w@mail.gmail.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 12/27] libcamera: v4l2_videodevice:\n\tTake stride into account to compute offsets","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]