[{"id":21666,"web_url":"https://patchwork.libcamera.org/comment/21666/","msgid":"<CAHW6GYK9Ghx_Gh6UW-8wymYpGXzApPT8kMyZ-nTo_rB3VJYeVg@mail.gmail.com>","date":"2021-12-08T11:22:13","subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline: raspberrypi: Restrict\n\tthe advertised maximum ISP output resolution","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for this patch!\n\nOn Wed, 8 Dec 2021 at 09:42, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\n> Limit the advertised ISP output sizes available to the sensor resolution in\n> PipelineHandlerRPi::generateConfiguration(). The user is free to configure a\n> larger resolution than this, and this will work. However, this stops strange\n> behavior in applications that use the V4L2 compatability layer to run, and\n> request the largest possible advertised resolution, which is much larger than\n> the sensor resolution.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 13 +++++++++----\n>  1 file changed, 9 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 4479e732a645..6ee975e85567 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -531,10 +531,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>\n>         unsigned int rawCount = 0;\n>         unsigned int outCount = 0;\n> +       Size sensorSize = data->sensor_->resolution();\n>         for (const StreamRole role : roles) {\n>                 switch (role) {\n>                 case StreamRole::Raw:\n> -                       size = data->sensor_->resolution();\n> +                       size = sensorSize;\n>                         sensorFormat = findBestFormat(data->sensorFormats_, size, defaultRawBitDepth);\n>                         pixelFormat = mbusCodeToPixelFormat(sensorFormat.mbus_code,\n>                                                             BayerFormat::Packing::CSI2);\n> @@ -547,7 +548,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>                         fmts = data->isp_[Isp::Output0].dev()->formats();\n>                         pixelFormat = formats::NV12;\n>                         /* Return the largest sensor resolution. */\n> -                       size = data->sensor_->resolution();\n> +                       size = sensorSize;\n>                         bufferCount = 1;\n>                         outCount++;\n>                         break;\n> @@ -600,11 +601,15 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>                                                 std::forward_as_tuple(format.second.begin(), format.second.end()));\n>                         }\n>                 } else {\n> -                       /* Translate the V4L2PixelFormat to PixelFormat. */\n> +                       /*\n> +                        * Translate the V4L2PixelFormat to PixelFormat. Note that we\n> +                        * limit the recommended largest ISP output size to match the\n> +                        * sensor resolution.\n> +                        */\n>                         for (const auto &format : fmts) {\n>                                 PixelFormat pf = format.first.toPixelFormat();\n>                                 if (pf.isValid())\n> -                                       deviceFormats[pf] = format.second;\n> +                                       deviceFormats[pf].emplace_back(sensorSize);\n>                         }\n>                 }\n>\n> --\n> 2.25.1\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 C3045BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Dec 2021 11:22:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 20B6C6086A;\n\tWed,  8 Dec 2021 12:22:26 +0100 (CET)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C496660225\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Dec 2021 12:22:24 +0100 (CET)","by mail-wm1-x333.google.com with SMTP id\n\tm25-20020a7bcb99000000b0033aa12cdd33so3193040wmi.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Dec 2021 03:22:24 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"QG5I+qyX\"; 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=N9osZz5JNOER0tbdUbstCklRVzOz32j74e+yHp6ZSKk=;\n\tb=QG5I+qyXMMjgiiPIx97Z3cE4U0sqlpv4TbwD/X1i5RVYiNTSrnCkPhIS/GX/lkd6bK\n\tcRZKfKJsOKXI75fZPltqPmUWkeuSLtWUAP0r37iE0UhNfHHF3tcRKV4RNx+PM8+x9Up6\n\tI9uxJHe60dWJdYcrvyPlZs76CoqMGquE/57IeZXHG++IiVo9lQGCqKTKMdKJJWhTtpul\n\ty67RQqMFQcjQjAC9MXSbFrweo6kYDC5yIXzBfNh6TtmqAYfEuSAb8nOkg6iq8vWy46N7\n\tdozMA36DTb0JmVeOINxkLTH900wr0iliUJS2G2PTA7OqorTf6bm00R2MNZin4qKZDE2Y\n\tcLAg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=N9osZz5JNOER0tbdUbstCklRVzOz32j74e+yHp6ZSKk=;\n\tb=1PFD+vRApJdoc6aL65i4DiThEhU8yx9uqrHu433UEHoegHnmoPomlxQCK2CI0IxGdV\n\tKB4VWtdC1NY/IJXI2QUOvqxKyMr/1sl015c+iuYwNFStx/S2dHfq8LYBN5VIoDsIFVA5\n\tIGjVBKh6KI8szKpQ37OVfhaW0nJoufPFGI0Mu08IqWcDHFvTnu4IvGnyotb4l4aFqb3l\n\tdrCd8NSe0X1mMJqJmhe57mofr6DIgmninBo9GhLvNu9/g5D87qlHAcx6K1YPAMYk4834\n\tz+xtDFD/6Ej7f0bPmbeptU0v1Kf8JhqWKOALREfpURKurE5kLAMY5ltC7Vtqq0teeBEL\n\tNbSw==","X-Gm-Message-State":"AOAM532Libhv6LLio2p6Qe7jB/ZqLfPWyXQC82O5V17xjnt5t9BE6k3u\n\t5ND6wrszb58Y9r0sc3/b/CpsrtTQb0Hja8TDhsZRTw==","X-Google-Smtp-Source":"ABdhPJxULxXQeUdmcyn8EbS+KE6vl870jB9xmlzp0sCnnuqA7y0BtMrcLhkkwExSdTdbLJk7dcqdupiCTIw9yUt1ssE=","X-Received":"by 2002:a7b:ca54:: with SMTP id\n\tm20mr15242838wml.21.1638962544282; \n\tWed, 08 Dec 2021 03:22:24 -0800 (PST)","MIME-Version":"1.0","References":"<20211208094211.1251311-1-naush@raspberrypi.com>\n\t<20211208094211.1251311-2-naush@raspberrypi.com>","In-Reply-To":"<20211208094211.1251311-2-naush@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Wed, 8 Dec 2021 11:22:13 +0000","Message-ID":"<CAHW6GYK9Ghx_Gh6UW-8wymYpGXzApPT8kMyZ-nTo_rB3VJYeVg@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline: raspberrypi: Restrict\n\tthe advertised maximum ISP output resolution","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":21671,"web_url":"https://patchwork.libcamera.org/comment/21671/","msgid":"<163896414987.995700.236768589731247728@Monstersaurus>","date":"2021-12-08T11:49:09","subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline: raspberrypi: Restrict\n\tthe advertised maximum ISP output resolution","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck (2021-12-08 09:42:11)\n> Limit the advertised ISP output sizes available to the sensor resolution in\n> PipelineHandlerRPi::generateConfiguration(). The user is free to configure a\n> larger resolution than this, and this will work. However, this stops strange\n> behavior in applications that use the V4L2 compatability layer to run, and\n> request the largest possible advertised resolution, which is much larger than\n> the sensor resolution.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 13 +++++++++----\n>  1 file changed, 9 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 4479e732a645..6ee975e85567 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -531,10 +531,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \n>         unsigned int rawCount = 0;\n>         unsigned int outCount = 0;\n> +       Size sensorSize = data->sensor_->resolution();\n>         for (const StreamRole role : roles) {\n>                 switch (role) {\n>                 case StreamRole::Raw:\n> -                       size = data->sensor_->resolution();\n> +                       size = sensorSize;\n>                         sensorFormat = findBestFormat(data->sensorFormats_, size, defaultRawBitDepth);\n>                         pixelFormat = mbusCodeToPixelFormat(sensorFormat.mbus_code,\n>                                                             BayerFormat::Packing::CSI2);\n> @@ -547,7 +548,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>                         fmts = data->isp_[Isp::Output0].dev()->formats();\n>                         pixelFormat = formats::NV12;\n>                         /* Return the largest sensor resolution. */\n> -                       size = data->sensor_->resolution();\n> +                       size = sensorSize;\n>                         bufferCount = 1;\n>                         outCount++;\n>                         break;\n> @@ -600,11 +601,15 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>                                                 std::forward_as_tuple(format.second.begin(), format.second.end()));\n>                         }\n>                 } else {\n> -                       /* Translate the V4L2PixelFormat to PixelFormat. */\n> +                       /*\n> +                        * Translate the V4L2PixelFormat to PixelFormat. Note that we\n> +                        * limit the recommended largest ISP output size to match the\n> +                        * sensor resolution.\n> +                        */\n>                         for (const auto &format : fmts) {\n>                                 PixelFormat pf = format.first.toPixelFormat();\n>                                 if (pf.isValid())\n> -                                       deviceFormats[pf] = format.second;\n> +                                       deviceFormats[pf].emplace_back(sensorSize);\n\nThis isn't adding to existing entries is it? I think I infer that this\nis using emplace_back() to be able to add the sensorSize as entry to the\nvector. Is it always guaranteed to be empty at this point otherwise?\n\n<edit> Yes deviceFormats is local and only created in this function ;-)\n\nI think it looks fine though.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>                         }\n>                 }\n>  \n> -- \n> 2.25.1\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 0948BBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Dec 2021 11:49:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5BD8D60725;\n\tWed,  8 Dec 2021 12:49:14 +0100 (CET)","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 2C6B360225\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Dec 2021 12:49:13 +0100 (CET)","from pendragon.ideasonboard.com\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 C7B7C8BB;\n\tWed,  8 Dec 2021 12:49:12 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"v1mmYegD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638964152;\n\tbh=Z1CQyW/V6i4vXO+UBKSQgLZXREd5DU3mJNNdeSl4F+s=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=v1mmYegDn5y9noyw+pxXJ5xFWetFuebGkBxGjfoMjJHwj41p8rcMzV/2YqnQGgBLS\n\tDVkZhPeRR0t3FSpwKMttyG9NKNN/faiZa7dZbfbwyoWAn9zcYFrDzz2wujej4HRFL/\n\tArOAvOLNrSFJPaerUhjfZb2oTs5qzk4GvxC9JXbI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211208094211.1251311-2-naush@raspberrypi.com>","References":"<20211208094211.1251311-1-naush@raspberrypi.com>\n\t<20211208094211.1251311-2-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 08 Dec 2021 11:49:09 +0000","Message-ID":"<163896414987.995700.236768589731247728@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH 2/2] pipeline: raspberrypi: Restrict\n\tthe advertised maximum ISP output resolution","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>"}}]