[{"id":5417,"web_url":"https://patchwork.libcamera.org/comment/5417/","msgid":"<20200625090028.GC5865@pendragon.ideasonboard.com>","date":"2020-06-25T09:00:28","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: pipeline: raspberrypi:\n\tAdd StreamFormats to StreamConfiguration","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Thu, Jun 25, 2020 at 08:28:44AM +0100, Naushir Patuck wrote:\n> In generateConfiguration(), add the device node specific formats to the\n> StreamConfiguration for each StreamRole requested.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nand about to push, after tests complete.\n\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 52 +++++++++++++------\n>  1 file changed, 36 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 60985b71..dcd737a1 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -518,41 +518,45 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \tRPiCameraData *data = cameraData(camera);\n>  \tCameraConfiguration *config = new RPiCameraConfiguration(data);\n>  \tV4L2DeviceFormat sensorFormat;\n> +\tunsigned int bufferCount;\n> +\tPixelFormat pixelFormat;\n>  \tV4L2PixFmtMap fmts;\n> +\tSize size;\n>  \n>  \tif (roles.empty())\n>  \t\treturn config;\n>  \n>  \tfor (const StreamRole role : roles) {\n> -\t\tStreamConfiguration cfg{};\n> -\n>  \t\tswitch (role) {\n>  \t\tcase StreamRole::StillCaptureRaw:\n> -\t\t\tcfg.size = data->sensor_->resolution();\n> +\t\t\tsize = data->sensor_->resolution();\n>  \t\t\tfmts = data->unicam_[Unicam::Image].dev()->formats();\n> -\t\t\tsensorFormat = findBestMode(fmts, cfg.size);\n> -\t\t\tcfg.pixelFormat = sensorFormat.fourcc.toPixelFormat();\n> -\t\t\tASSERT(cfg.pixelFormat.isValid());\n> -\t\t\tcfg.bufferCount = 1;\n> +\t\t\tsensorFormat = findBestMode(fmts, size);\n> +\t\t\tpixelFormat = sensorFormat.fourcc.toPixelFormat();\n> +\t\t\tASSERT(pixelFormat.isValid());\n> +\t\t\tbufferCount = 1;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::StillCapture:\n> -\t\t\tcfg.pixelFormat = formats::NV12;\n> +\t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n> +\t\t\tpixelFormat = formats::NV12;\n>  \t\t\t/* Return the largest sensor resolution. */\n> -\t\t\tcfg.size = data->sensor_->resolution();\n> -\t\t\tcfg.bufferCount = 1;\n> +\t\t\tsize = data->sensor_->resolution();\n> +\t\t\tbufferCount = 1;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::VideoRecording:\n> -\t\t\tcfg.pixelFormat = formats::NV12;\n> -\t\t\tcfg.size = { 1920, 1080 };\n> -\t\t\tcfg.bufferCount = 4;\n> +\t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n> +\t\t\tpixelFormat = formats::NV12;\n> +\t\t\tsize = { 1920, 1080 };\n> +\t\t\tbufferCount = 4;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::Viewfinder:\n> -\t\t\tcfg.pixelFormat = formats::ARGB8888;\n> -\t\t\tcfg.size = { 800, 600 };\n> -\t\t\tcfg.bufferCount = 4;\n> +\t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n> +\t\t\tpixelFormat = formats::ARGB8888;\n> +\t\t\tsize = { 800, 600 };\n> +\t\t\tbufferCount = 4;\n>  \t\t\tbreak;\n>  \n>  \t\tdefault:\n> @@ -561,6 +565,22 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tbreak;\n>  \t\t}\n>  \n> +\t\t/* Translate the V4L2PixelFormat to PixelFormat. */\n> +\t\tstd::map<PixelFormat, std::vector<SizeRange>> deviceFormats;\n> +\t\tstd::transform(fmts.begin(), fmts.end(), std::inserter(deviceFormats, deviceFormats.end()),\n> +\t\t\t       [&](const decltype(fmts)::value_type &format) {\n> +\t\t\t\t\treturn decltype(deviceFormats)::value_type{\n> +\t\t\t\t\t\tformat.first.toPixelFormat(),\n> +\t\t\t\t\t\tformat.second\n> +\t\t\t\t\t};\n> +\t\t\t       });\n> +\n> +\t\t/* Add the stream format based on the device node used for the use case. */\n> +\t\tStreamFormats formats(deviceFormats);\n> +\t\tStreamConfiguration cfg(formats);\n> +\t\tcfg.size = size;\n> +\t\tcfg.pixelFormat = pixelFormat;\n> +\t\tcfg.bufferCount = bufferCount;\n>  \t\tconfig->addConfiguration(cfg);\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 4CD7FC0101\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Jun 2020 09:00:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BEA36609C5;\n\tThu, 25 Jun 2020 11:00:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3821609A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Jun 2020 11:00:29 +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 67C32521;\n\tThu, 25 Jun 2020 11:00:29 +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=\"NY8rrqp8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593075629;\n\tbh=/TgYLidRji9VS1ZZ1gb0M29bjYQLLkpfTBPyZjpwTOE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=NY8rrqp8Q0TQc5uv4q/6vG0iOJhIzecxoOBG1lv8YSA+hngF0GV6JjVEHk+T0lG5w\n\tsJ/wskbEpORit4PdNC0zZdwuUWerXCMAXhWdljCtkGZVlBIzG51wfo+cfgiXbU8JA+\n\tzAkBddMYi5oBj5aPkBHxxrBuFlwzch/wPkn2jJGo=","Date":"Thu, 25 Jun 2020 12:00:28 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20200625090028.GC5865@pendragon.ideasonboard.com>","References":"<20200625072844.1146902-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200625072844.1146902-1-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: pipeline: raspberrypi:\n\tAdd StreamFormats to StreamConfiguration","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>"}}]