[{"id":26766,"web_url":"https://patchwork.libcamera.org/comment/26766/","msgid":"<CAHW6GYLHNJFSY9bEcyje3khOofGYTUZEOd62zJ3ZJ-Hewhp7HQ@mail.gmail.com>","date":"2023-03-27T13:18:33","subject":"Re: [libcamera-devel] [PATCH v2 1/4] ipa: raspberrypi: Add sensor\n\tmode limits to CameraMode","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 the patch.\n\nOn Mon, 27 Mar 2023 at 10:34, Naushir Patuck via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Add fields in the CameraMode structure to capture the mode specific\n> limits for analogue gain and shutter speed. For convenience, also add\n> fields for minimum and maximum frame durations.\n>\n> Populate these new fields when setting up the CameraMode structure.\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/ipa/raspberrypi/controller/camera_mode.h | 10 +++++++++-\n>  src/ipa/raspberrypi/raspberrypi.cpp          | 16 ++++++++++++++++\n>  2 files changed, 25 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h\n> index 94c51ddf1686..63b1177852d0 100644\n> --- a/src/ipa/raspberrypi/controller/camera_mode.h\n> +++ b/src/ipa/raspberrypi/controller/camera_mode.h\n> @@ -36,9 +36,11 @@ struct CameraMode {\n>         double scaleY;\n>         /* scaling of the noise compared to the native sensor mode */\n>         double noiseFactor;\n> -       /* minimum and maximum line time */\n> +       /* minimum and maximum line time and frame durations */\n>         libcamera::utils::Duration minLineLength;\n>         libcamera::utils::Duration maxLineLength;\n> +       libcamera::utils::Duration minFrameDuration;\n> +       libcamera::utils::Duration maxFrameDuration;\n>         /* any camera transform *not* reflected already in the camera tuning */\n>         libcamera::Transform transform;\n>         /* minimum and maximum frame lengths in units of lines */\n> @@ -48,4 +50,10 @@ struct CameraMode {\n>         double sensitivity;\n>         /* pixel clock rate */\n>         uint64_t pixelRate;\n> +       /* Mode specific shutter speed limits */\n> +       libcamera::utils::Duration minShutter;\n> +       libcamera::utils::Duration maxShutter;\n> +       /* Mode specific analogue gain limits */\n> +       double minAnalogueGain;\n> +       double maxAnalogueGain;\n>  };\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 1375795568e2..3f1afb846420 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -407,11 +407,27 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo)\n>         mode_.minFrameLength = sensorInfo.minFrameLength;\n>         mode_.maxFrameLength = sensorInfo.maxFrameLength;\n>\n> +       /* Store these for convenience. */\n> +       mode_.minFrameDuration = mode_.minFrameLength * mode_.minLineLength;\n> +       mode_.maxFrameDuration = mode_.maxFrameLength * mode_.maxLineLength;\n> +\n>         /*\n>          * Some sensors may have different sensitivities in different modes;\n>          * the CamHelper will know the correct value.\n>          */\n>         mode_.sensitivity = helper_->getModeSensitivity(mode_);\n> +\n> +       const ControlInfo &gainCtrl = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN);\n> +       const ControlInfo &shutterCtrl = sensorCtrls_.at(V4L2_CID_EXPOSURE);\n> +\n> +       mode_.minAnalogueGain = helper_->gain(gainCtrl.min().get<int32_t>());\n> +       mode_.maxAnalogueGain = helper_->gain(gainCtrl.max().get<int32_t>());\n> +\n> +       /* Shutter speed is calculated based on the limits of the frame durations. */\n> +       mode_.minShutter = helper_->exposure(shutterCtrl.min().get<int32_t>(), mode_.minLineLength);\n> +       mode_.maxShutter = Duration::max();\n> +       helper_->getBlanking(mode_.maxShutter,\n> +                            mode_.minFrameDuration, mode_.maxFrameDuration);\n>  }\n>\n>  int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ipaConfig,\n> --\n> 2.34.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 3E722BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Mar 2023 13:18:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7FB0962722;\n\tMon, 27 Mar 2023 15:18:48 +0200 (CEST)","from mail-oi1-x231.google.com (mail-oi1-x231.google.com\n\t[IPv6:2607:f8b0:4864:20::231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E454A626D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Mar 2023 15:18:46 +0200 (CEST)","by mail-oi1-x231.google.com with SMTP id bk5so6298278oib.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Mar 2023 06:18:46 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679923128;\n\tbh=LEg9IXLWlTYI3/j4Ohlraxm1eCpXiievyN7fQbHKEyY=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=zaql4rV1ur36pVBCAwHRpRt5gJ1ETAz4KetrkodCekPbZ9Hf7ZUlCU1LBbq3q77W7\n\t8lMqcdVyy+2qCqpMbUtTQqqmTC5lr3rSDoYmldwNp7aJC8w0+Xlaz8A7Ouyl+41IlF\n\t9ifK18m54yHp3UTjtF5Sa6A71blBrTzur9C9y7DLSivILazNQn0jP1XeP3fZBxiI+8\n\t8VvU5KahCIv66wJFFN1Vj1N63Dehc31IUNgSWVG/AvY2SmsRzJDEGK1Iy2AsDfIJt7\n\t3mKwZRRKHB84g1ulRfFyl1mpkpkkBEHH8Yyg1S40Dlq8AlMeU/XWpIf6FmMiK46ZaS\n\tcOxdAWhQ+kjDg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1679923125;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=1/PK3vpsSv3uZdGQThBBe0Ngx1phtqdOB7J/q8T5yVg=;\n\tb=tBK27924iuaxUkmAMaZWBVGHr/TLmaO/CtbUgNpk4ZY0KwBwL7jgROAPXPSSq3qg5o\n\ttopPrnihicZ53AscRDJJWBrLrVjHlWIh4+rxWn/NEsVztFlubf/D7K6j4jCWsZWj35wE\n\thh/63z90Vei422XqAmhk3bS26u+8hfcpJL9c64czFdUFDYKqk63e5LKp3/ebNlmhAqAd\n\t3eEf340TN1xtSP052lB9/3ZoSRMD5dfQBKe5pUMG9GnCIdK4iYmI5rmRgAjjhB7DWxfG\n\t/ablsge0imf+pljakx19AEBpwT2IqGFw/viuSO2zrp8Lo9ItFLAAzxDrWzbi0sjU1J81\n\tqNRw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"tBK27924\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1679923125;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=1/PK3vpsSv3uZdGQThBBe0Ngx1phtqdOB7J/q8T5yVg=;\n\tb=qQvgraKLlX/jTHrRwduN9VwCwM8si7Tqbhum+pNDOTb76R7799qPZyMdHUE+BnJun+\n\tpSIpgDu4oPrLt0sY54dnh5vinA1MwZR8aSrl7G71f6NuypxbhUJ249Psldc/HjgRpRbH\n\t9dHYSvcywLSJuM6z8gSHwW7aKn7pVw1rRbqxm6v5tqQ6m6MJTmcH9uWVCW5Ij9IH2u/J\n\tEjbED+rNz85FWkKxqKD/6XRTvxpohQZioyLdUSRLIkTqOR3SDB3zrUAjswISAiw4QXVp\n\tGrksbmbQHKTo4nT1iS8W2/65UmqXQzCeSgVpJCFF6hrNRl5GJiocZ3lRlD8EH6GLl+yd\n\tW1QA==","X-Gm-Message-State":"AO0yUKWRgKXuIY9ObiJcIQ0hPHPe3f4aG5jHoX3LbPfdCUgOX0qWWADL\n\t9MzK2YOx+ZLyFfGVz9H52zlPdBaE2PtFtDq0zTC42A==","X-Google-Smtp-Source":"AK7set/CxWfDIJXuYhOGYTZL7lGMl17n4vwVr5fzXKZ4Xza1/KMKa8IclAUql+5KPKsnNcSClSr2aVSwwGYisihTObM=","X-Received":"by 2002:a05:6808:a83:b0:386:a5cf:c1d with SMTP id\n\tq3-20020a0568080a8300b00386a5cf0c1dmr6985500oij.2.1679923124076;\n\tMon, 27 Mar 2023 06:18:44 -0700 (PDT)","MIME-Version":"1.0","References":"<20230327093439.24670-1-naush@raspberrypi.com>\n\t<20230327093439.24670-2-naush@raspberrypi.com>","In-Reply-To":"<20230327093439.24670-2-naush@raspberrypi.com>","Date":"Mon, 27 Mar 2023 14:18:33 +0100","Message-ID":"<CAHW6GYLHNJFSY9bEcyje3khOofGYTUZEOd62zJ3ZJ-Hewhp7HQ@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] ipa: raspberrypi: Add sensor\n\tmode limits to CameraMode","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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26774,"web_url":"https://patchwork.libcamera.org/comment/26774/","msgid":"<20230327134945.kimlq4qnf3prrnxl@uno.localdomain>","date":"2023-03-27T13:49:45","subject":"Re: [libcamera-devel] [PATCH v2 1/4] ipa: raspberrypi: Add sensor\n\tmode limits to CameraMode","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Mon, Mar 27, 2023 at 10:34:36AM +0100, Naushir Patuck via libcamera-devel wrote:\n> Add fields in the CameraMode structure to capture the mode specific\n> limits for analogue gain and shutter speed. For convenience, also add\n> fields for minimum and maximum frame durations.\n>\n> Populate these new fields when setting up the CameraMode structure.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n> ---\n>  src/ipa/raspberrypi/controller/camera_mode.h | 10 +++++++++-\n>  src/ipa/raspberrypi/raspberrypi.cpp          | 16 ++++++++++++++++\n>  2 files changed, 25 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h\n> index 94c51ddf1686..63b1177852d0 100644\n> --- a/src/ipa/raspberrypi/controller/camera_mode.h\n> +++ b/src/ipa/raspberrypi/controller/camera_mode.h\n> @@ -36,9 +36,11 @@ struct CameraMode {\n>  \tdouble scaleY;\n>  \t/* scaling of the noise compared to the native sensor mode */\n>  \tdouble noiseFactor;\n> -\t/* minimum and maximum line time */\n> +\t/* minimum and maximum line time and frame durations */\n>  \tlibcamera::utils::Duration minLineLength;\n>  \tlibcamera::utils::Duration maxLineLength;\n> +\tlibcamera::utils::Duration minFrameDuration;\n> +\tlibcamera::utils::Duration maxFrameDuration;\n>  \t/* any camera transform *not* reflected already in the camera tuning */\n>  \tlibcamera::Transform transform;\n>  \t/* minimum and maximum frame lengths in units of lines */\n> @@ -48,4 +50,10 @@ struct CameraMode {\n>  \tdouble sensitivity;\n>  \t/* pixel clock rate */\n>  \tuint64_t pixelRate;\n> +\t/* Mode specific shutter speed limits */\n> +\tlibcamera::utils::Duration minShutter;\n> +\tlibcamera::utils::Duration maxShutter;\n> +\t/* Mode specific analogue gain limits */\n> +\tdouble minAnalogueGain;\n> +\tdouble maxAnalogueGain;\n>  };\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 1375795568e2..3f1afb846420 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -407,11 +407,27 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo)\n>  \tmode_.minFrameLength = sensorInfo.minFrameLength;\n>  \tmode_.maxFrameLength = sensorInfo.maxFrameLength;\n>\n> +\t/* Store these for convenience. */\n> +\tmode_.minFrameDuration = mode_.minFrameLength * mode_.minLineLength;\n> +\tmode_.maxFrameDuration = mode_.maxFrameLength * mode_.maxLineLength;\n> +\n>  \t/*\n>  \t * Some sensors may have different sensitivities in different modes;\n>  \t * the CamHelper will know the correct value.\n>  \t */\n>  \tmode_.sensitivity = helper_->getModeSensitivity(mode_);\n> +\n> +\tconst ControlInfo &gainCtrl = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN);\n> +\tconst ControlInfo &shutterCtrl = sensorCtrls_.at(V4L2_CID_EXPOSURE);\n> +\n> +\tmode_.minAnalogueGain = helper_->gain(gainCtrl.min().get<int32_t>());\n> +\tmode_.maxAnalogueGain = helper_->gain(gainCtrl.max().get<int32_t>());\n> +\n> +\t/* Shutter speed is calculated based on the limits of the frame durations. */\n> +\tmode_.minShutter = helper_->exposure(shutterCtrl.min().get<int32_t>(), mode_.minLineLength);\n> +\tmode_.maxShutter = Duration::max();\n> +\thelper_->getBlanking(mode_.maxShutter,\n> +\t\t\t     mode_.minFrameDuration, mode_.maxFrameDuration);\n>  }\n>\n>  int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ipaConfig,\n> --\n> 2.34.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 9F269BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Mar 2023 13:49:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0FBB062724;\n\tMon, 27 Mar 2023 15:49:50 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A9C44626D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Mar 2023 15:49:48 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 402027FA;\n\tMon, 27 Mar 2023 15:49:48 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679924990;\n\tbh=y66CEjxaU6E0cOhGmpQr6qVumaCxuk230UAP/s+ljP8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=kcHwsel53YtXI9YBSpMJUIXWV3A/vWwqbfIeqDcVxnEdqgurf+zyq5n02x/SVKGSe\n\tWjcjJPz3iWceTLqhPMwsTQgbmVBuucMGYBebGHk7KGUHE0HlqvIwNSsemNf3aMQspw\n\tWvJCJ5yZJkmJa4TQM1/MntKg7FH9wrdgtyfjcY8fsd2W73IsPpGgPHkkPTKUqRHeCC\n\t6Z7eaWJVgyEBnqZ1WB9XX/6dWix/1MZn3GrFwWytea2eK1Z4p1k1zJ2ERlPBG4aqYN\n\tpdXiCnHT+zjJdqhzBdpOPzcn6nD+aJWlStQSJa42uFJ4IwZh9CmXjMzrD/kzQhrDy0\n\tZmC4LprHMk5Jg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1679924988;\n\tbh=y66CEjxaU6E0cOhGmpQr6qVumaCxuk230UAP/s+ljP8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uIbfqB9DWStJvJtQdfdRGIo+nKnVGv1tQAuNuVd+74k792jVYeHslUrUWZVN0B3ob\n\t1pNQOjdmt43A4Gwxs6/Jjm2G2JhL46WL9Etg5H3WjUDkyXhOXqGGCGbxgjrazomT1s\n\tW/fu+vIcuKjzBjl8rizGDDdtuGyrC3gGvGAkajv8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"uIbfqB9D\"; dkim-atps=neutral","Date":"Mon, 27 Mar 2023 15:49:45 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20230327134945.kimlq4qnf3prrnxl@uno.localdomain>","References":"<20230327093439.24670-1-naush@raspberrypi.com>\n\t<20230327093439.24670-2-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230327093439.24670-2-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/4] ipa: raspberrypi: Add sensor\n\tmode limits to CameraMode","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]