[{"id":10938,"web_url":"https://patchwork.libcamera.org/comment/10938/","msgid":"<20200628182956.GN1105424@oden.dyn.berto.se>","date":"2020-06-28T18:29:56","subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: raspberrypi: Refuse\n\tinvalid roles configuration","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2020-06-28 18:17:21 +0200, Jacopo Mondi wrote:\n> The generateConfiguration() implementation does not check if the\n> requested list of roles can actually be satisfied. The camera API\n> documentation prescribes the function shall fail in that case, instead\n> of silently adjust the returned confiuguration.\n> \n> Fix this by implementing the same logic as the validate() function\n> implements, as the pipeline handler supports one raw stream and up to\n> two output streams.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 11 +++++++++++\n>  1 file changed, 11 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index dcd737a1d1a0..d1338b640e3c 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -526,6 +526,8 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \tif (roles.empty())\n>  \t\treturn config;\n>  \n> +\tunsigned int rawCount = 0;\n> +\tunsigned int outCount = 0;\n>  \tfor (const StreamRole role : roles) {\n>  \t\tswitch (role) {\n>  \t\tcase StreamRole::StillCaptureRaw:\n> @@ -535,6 +537,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tpixelFormat = sensorFormat.fourcc.toPixelFormat();\n>  \t\t\tASSERT(pixelFormat.isValid());\n>  \t\t\tbufferCount = 1;\n> +\t\t\trawCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::StillCapture:\n> @@ -543,6 +546,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\t/* Return the largest sensor resolution. */\n>  \t\t\tsize = data->sensor_->resolution();\n>  \t\t\tbufferCount = 1;\n> +\t\t\toutCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::VideoRecording:\n> @@ -550,6 +554,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tpixelFormat = formats::NV12;\n>  \t\t\tsize = { 1920, 1080 };\n>  \t\t\tbufferCount = 4;\n> +\t\t\toutCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::Viewfinder:\n> @@ -557,6 +562,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tpixelFormat = formats::ARGB8888;\n>  \t\t\tsize = { 800, 600 };\n>  \t\t\tbufferCount = 4;\n> +\t\t\toutCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tdefault:\n> @@ -565,6 +571,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tbreak;\n>  \t\t}\n>  \n> +\t\tif (rawCount > 1 || outCount > 2) {\n> +\t\t\tdelete config;\n> +\t\t\treturn nullptr;\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> -- \n> 2.27.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 DC8EAC2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Jun 2020 18:29:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69916609C9;\n\tSun, 28 Jun 2020 20:29:59 +0200 (CEST)","from mail-lf1-x144.google.com (mail-lf1-x144.google.com\n\t[IPv6:2a00:1450:4864:20::144])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F088603B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Jun 2020 20:29:58 +0200 (CEST)","by mail-lf1-x144.google.com with SMTP id m26so7847814lfo.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Jun 2020 11:29:58 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\t11sm8570672lfz.78.2020.06.28.11.29.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 28 Jun 2020 11:29:56 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"isQYjCIb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=XJvRg1DRhPcv/Bo+8uaVXWYovMBmlSyBbIhkbek3FnA=;\n\tb=isQYjCIbugljA0kav4dsY/WmrU+tCMuUe86jUcajeAjWmhevjMup/yev02yrXjvx8M\n\tzSuqF2qh4AF0tn5NHPVvRSo0KORF1VYLJkyVJzX4YQJGq408vac4PB0Td2XGTOmaa5JV\n\tpqBMJT6Hj3wJ0x+tnPl6834V5d2urOXy1SulsTpmwrYNg3+KgLWzVo7TxlQOYFZgFzCo\n\tSzD/HgyPYIqgIC1KJ+ns8LuUySpyuAn3pBnZBr+jeMcBJNbGUVVJ17hWS06v6WUEzyZ0\n\t/ho8sLJI1+xFtQv7UvMsE8yzJm6tyNscXRX/vGSp61DG5tGhnyvTmS/UlIqTSVEd4ySA\n\t1DAw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=XJvRg1DRhPcv/Bo+8uaVXWYovMBmlSyBbIhkbek3FnA=;\n\tb=kskYZNXdEiHytjvp6sWPUOi3Ru6zVLGhYb/VwDKm2IMdd06Gnr1ZtIC9WrUt6SQ0CI\n\tq5pO7NCK5uY/MRvWWqButYnX51ydqsz4IxS9kByGcExDJZ1XoXMmStKOq4IsIFHDrS6B\n\tag3zRtzuxgO2de3gtL8sTFk9zn7RAI0LhRVnlp5Jj9iCip+IRnRVdJESX/248x5Jc+qw\n\tjEPxKnvmtKWIXOEJWR5e7uDennQ1pkUmZVXSex1pJ3XznUVmLHvCMkLybVHEtTOPajCP\n\tKqjDBm/9bHEbRzkowUMR53ZKU2gQditovqyy0IGTySs9+MxCDINBDakiWxwhE+2eJIuF\n\tdZBA==","X-Gm-Message-State":"AOAM533NLyHjYd2frLpd6cYQBs75d3dkOgGqMyrObkiJo/xmISOGN61O\n\trw8XQmoxiIZAoi7kzrZeZ/sh0xaTZbs=","X-Google-Smtp-Source":"ABdhPJwevZdNUu4ea1tS6pDEXdkOZIZ9cRZf1Gmz8zwg6ocGusUyR7WFIWlpnktIl0w50TRcxnjrtA==","X-Received":"by 2002:a19:8b8a:: with SMTP id\n\tn132mr7242902lfd.45.1593368997470; \n\tSun, 28 Jun 2020 11:29:57 -0700 (PDT)","Date":"Sun, 28 Jun 2020 20:29:56 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200628182956.GN1105424@oden.dyn.berto.se>","References":"<20200628161723.30625-1-jacopo@jmondi.org>\n\t<20200628161723.30625-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200628161723.30625-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: raspberrypi: Refuse\n\tinvalid roles configuration","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=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":10946,"web_url":"https://patchwork.libcamera.org/comment/10946/","msgid":"<20200628220628.GB6954@pendragon.ideasonboard.com>","date":"2020-06-28T22:06:28","subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: raspberrypi: Refuse\n\tinvalid roles configuration","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Sun, Jun 28, 2020 at 06:17:21PM +0200, Jacopo Mondi wrote:\n> The generateConfiguration() implementation does not check if the\n> requested list of roles can actually be satisfied. The camera API\n> documentation prescribes the function shall fail in that case, instead\n> of silently adjust the returned confiuguration.\n\ns/confiuguration/configuration/\n\n> Fix this by implementing the same logic as the validate() function\n> implements, as the pipeline handler supports one raw stream and up to\n> two output streams.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 11 +++++++++++\n>  1 file changed, 11 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index dcd737a1d1a0..d1338b640e3c 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -526,6 +526,8 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \tif (roles.empty())\n>  \t\treturn config;\n>  \n> +\tunsigned int rawCount = 0;\n> +\tunsigned int outCount = 0;\n>  \tfor (const StreamRole role : roles) {\n>  \t\tswitch (role) {\n>  \t\tcase StreamRole::StillCaptureRaw:\n> @@ -535,6 +537,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tpixelFormat = sensorFormat.fourcc.toPixelFormat();\n>  \t\t\tASSERT(pixelFormat.isValid());\n>  \t\t\tbufferCount = 1;\n> +\t\t\trawCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::StillCapture:\n> @@ -543,6 +546,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\t/* Return the largest sensor resolution. */\n>  \t\t\tsize = data->sensor_->resolution();\n>  \t\t\tbufferCount = 1;\n> +\t\t\toutCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::VideoRecording:\n> @@ -550,6 +554,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tpixelFormat = formats::NV12;\n>  \t\t\tsize = { 1920, 1080 };\n>  \t\t\tbufferCount = 4;\n> +\t\t\toutCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tcase StreamRole::Viewfinder:\n> @@ -557,6 +562,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tpixelFormat = formats::ARGB8888;\n>  \t\t\tsize = { 800, 600 };\n>  \t\t\tbufferCount = 4;\n> +\t\t\toutCount++;\n>  \t\t\tbreak;\n>  \n>  \t\tdefault:\n> @@ -565,6 +571,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t\tbreak;\n>  \t\t}\n>  \n> +\t\tif (rawCount > 1 || outCount > 2) {\n\nWould an error message be a good idea ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\tdelete config;\n> +\t\t\treturn nullptr;\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()),","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 93763C2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Jun 2020 22:06:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 09F5F609DB;\n\tMon, 29 Jun 2020 00:06:34 +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 5195A603B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2020 00:06:32 +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 6BB7E4FB;\n\tMon, 29 Jun 2020 00:06:31 +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=\"eGuG4YnA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593381991;\n\tbh=8ENX8Hg3QN7t4IPEbyFOr3l/876sNCKCqAY51EM9zPc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eGuG4YnABR35fQIJuDTcUXQgRx60bVMQ6ygQMoG7USIpDGo6GRNbV5AAPqE0fgs1Q\n\tz9s1BJnsr6rsdqENMqsSF5BPo6u8NZihoLWjls1oJ/CUuEfdVxpdPeOVkKkITOSJwC\n\t8/ME02WtDeO9D1s8e9m/kASFNniGPKF0IPPGdQnQ=","Date":"Mon, 29 Jun 2020 01:06:28 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200628220628.GB6954@pendragon.ideasonboard.com>","References":"<20200628161723.30625-1-jacopo@jmondi.org>\n\t<20200628161723.30625-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200628161723.30625-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: raspberrypi: Refuse\n\tinvalid roles configuration","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>"}}]