[{"id":11171,"web_url":"https://patchwork.libcamera.org/comment/11171/","msgid":"<20200704184556.GE6018@pendragon.ideasonboard.com>","date":"2020-07-04T18:45:56","subject":"Re: [libcamera-devel] [PATCH v3 07/22] v4l2: v4l2_camera: Add\n\tvalidateConfiguration","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Sat, Jul 04, 2020 at 10:31:25PM +0900, Paul Elder wrote:\n> In V4L2CameraProxy, we need a way to validate formats and sizes, to\n> implement try_fmt. Instead of manually checking it against the cached\n> list of formats and sizes, add V4L2Camera::validateConfiguration that we\n> can use to implement try_fmt.\n\nI'd squash this with patch 10/22, as it's more difficult to review the\nfunction without seeing how it's used. If the function and/or the user\nwhere large it may make sense to split them in separate patches, but\nhere a single patch is manageable.\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> New in v3\n> ---\n>  src/v4l2/v4l2_camera.cpp | 29 +++++++++++++++++++++++++++++\n>  src/v4l2/v4l2_camera.h   |  3 +++\n>  2 files changed, 32 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\n> index ffc1230..326e1c2 100644\n> --- a/src/v4l2/v4l2_camera.cpp\n> +++ b/src/v4l2/v4l2_camera.cpp\n> @@ -138,6 +138,35 @@ int V4L2Camera::configure(StreamConfiguration *streamConfigOut,\n>  \treturn 0;\n>  }\n>  \n> +int V4L2Camera::validateConfiguration(StreamConfiguration *streamConfigOut,\n> +\t\t\t\t      const Size &size,\n> +\t\t\t\t      const PixelFormat &pixelFormat)\n\nWe usually put output parameters last, and pixel format before size\n(probably because we consider that the size qualifies the pixel format).\n\n> +{\n> +\tif (!streamConfigOut)\n> +\t\treturn -EINVAL;\n\nThat can't happen, it's a private function, and the caller always passed\na non-null pointer.\n\n> +\n> +\tstd::unique_ptr<CameraConfiguration> config =\n> +\t\tcamera_->generateConfiguration({ StreamRole::Viewfinder });\n> +\tStreamConfiguration &cfg = config->at(0);\n> +\tcfg.size.width = size.width;\n> +\tcfg.size.height = size.height;\n\n\tcfg.size = size;\n\n> +\tcfg.pixelFormat = pixelFormat;\n> +\tcfg.bufferCount = 1;\n> +\n> +\tCameraConfiguration::Status validation = config->validate();\n> +\tif (validation == CameraConfiguration::Invalid)\n> +\t\treturn -EINVAL;\n> +\n> +\tstreamConfigOut->pixelFormat = cfg.pixelFormat;\n> +\tstreamConfigOut->size.width  = cfg.size.width;\n> +\tstreamConfigOut->size.height = cfg.size.height;\n\n\tstreamConfigOut->size = cfg.size;\n\n> +\tstreamConfigOut->bufferCount = cfg.bufferCount;\n> +\tstreamConfigOut->stride      = cfg.stride;\n> +\tstreamConfigOut->frameSize   = cfg.frameSize;\n\nOr just\n\n\t*streamConfigOut = cfg;\n\n?\n\n> +\n> +\treturn 0;\n> +}\n> +\n>  int V4L2Camera::allocBuffers(unsigned int count)\n>  {\n>  \tStream *stream = *camera_->streams().begin();\n> diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\n> index 515e906..15a9363 100644\n> --- a/src/v4l2/v4l2_camera.h\n> +++ b/src/v4l2/v4l2_camera.h\n> @@ -47,6 +47,9 @@ public:\n>  \tint configure(StreamConfiguration *streamConfigOut,\n>  \t\t      const Size &size, const PixelFormat &pixelformat,\n>  \t\t      unsigned int bufferCount);\n> +\tint validateConfiguration(StreamConfiguration *streamConfigOut,\n> +\t\t\t\t  const Size &size,\n> +\t\t\t\t  const PixelFormat &pixelformat);\n>  \n>  \tint allocBuffers(unsigned int count);\n>  \tvoid freeBuffers();","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 D2BF3BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Jul 2020 18:46:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 668E460C50;\n\tSat,  4 Jul 2020 20:46:03 +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 4562E609C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jul 2020 20:46:01 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ACB15296;\n\tSat,  4 Jul 2020 20:46:00 +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=\"G5/BE3SF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593888360;\n\tbh=g2uSYQyJNJEYm19vunkAJIVjlnI4x8Q2Pj5EikHh5Y8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=G5/BE3SFb2jgI/iCwKfosfwKXdfLasIwjEUNjBIXhWdxnx/QldrWQ7Fz6ceD6tGDz\n\t31+m9AE9rgvXEAj2mpHZ0W0FFr+q36i9Ui0jSrAdnNXbgy4mwABLBgGekoPXb2xM8O\n\ts0h7m0WWk88/rDywAa2QbqsReudSGF9zcJotT2XM=","Date":"Sat, 4 Jul 2020 21:45:56 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<20200704184556.GE6018@pendragon.ideasonboard.com>","References":"<20200704133140.1738660-1-paul.elder@ideasonboard.com>\n\t<20200704133140.1738660-8-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200704133140.1738660-8-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 07/22] v4l2: v4l2_camera: Add\n\tvalidateConfiguration","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]