[{"id":26044,"web_url":"https://patchwork.libcamera.org/comment/26044/","msgid":"<20221212095340.gsv6pavmnhnllc2v@uno.localdomain>","date":"2022-12-12T09:53:40","subject":"Re: [libcamera-devel] [PATCH v2 2/2] libcamera:camera_sensor,\n\tipa: raspberrypi: Test readOnly() for HBLANK control","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"On Fri, Dec 02, 2022 at 12:40:05PM +0000, Naushir Patuck via libcamera-devel wrote:\n> Use ControlInfo::readOnly() to test if the camera sensor accepts V4L2_CID_HBLANK\n> control changes. This replaces the current workaround where we test if the\n> V4L2_CID_HBLANK min and max values are the same to determine if a control is\n> read-only.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/raspberrypi.cpp | 12 +-----------\n>  src/libcamera/camera_sensor.cpp     | 14 ++------------\n>  2 files changed, 3 insertions(+), 23 deletions(-)\n>\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index bead436def3c..57f01496fc44 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -1239,17 +1239,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n>  \tctrls.set(V4L2_CID_EXPOSURE, exposureLines);\n>  \tctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode);\n>\n> -\t/*\n> -\t * At present, there is no way of knowing if a control is read-only.\n> -\t * As a workaround, assume that if the minimum and maximum values of\n> -\t * the V4L2_CID_HBLANK control are the same, it implies the control\n> -\t * is read-only. This seems to be the case for all the cameras our IPA\n> -\t * works with.\n> -\t *\n> -\t * \\todo The control API ought to have a flag to specify if a control\n> -\t * is read-only which could be used below.\n> -\t */\n> -\tif (mode_.minLineLength != mode_.maxLineLength)\n> +\tif (!sensorCtrls_.at(V4L2_CID_HBLANK).readOnly())\n>  \t\tctrls.set(V4L2_CID_HBLANK, static_cast<int32_t>(hblank));\n>  }\n>\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index ae3127d6b693..3785b6441b90 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -185,20 +185,10 @@ int CameraSensor::init()\n>  \t * Set HBLANK to the minimum to start with a well-defined line length,\n>  \t * allowing IPA modules that do not modify HBLANK to use the sensor\n>  \t * minimum line length in their calculations.\n> -\t *\n> -\t * At present, there is no way of knowing if a control is read-only.\n> -\t * As a workaround, assume that if the minimum and maximum values of\n> -\t * the V4L2_CID_HBLANK control are the same, it implies the control\n> -\t * is read-only.\n> -\t *\n> -\t * \\todo The control API ought to have a flag to specify if a control\n> -\t * is read-only which could be used below.\n\nI guess this fixes the todo\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n>  \t */\n>  \tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n> -\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n> -\tconst int32_t hblankMax = hblank.max().get<int32_t>();\n> -\n> -\tif (hblankMin != hblankMax) {\n> +\tif (!hblank.readOnly()) {\n> +\t\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n>  \t\tControlList ctrl(subdev_->controls());\n>\n>  \t\tctrl.set(V4L2_CID_HBLANK, hblankMin);\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 B1E59BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Dec 2022 09:53:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 04C7263362;\n\tMon, 12 Dec 2022 10:53:44 +0100 (CET)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B46BE61F23\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Dec 2022 10:53:42 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 1EF841BF208;\n\tMon, 12 Dec 2022 09:53:41 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670838824;\n\tbh=sinQ94GVYmeOUlT8cLrWkpJce/WNNQhSPyQBi+bRAbI=;\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=pqHX35vGYLNCN7MtEyP4giZOgdAXrPeYvznbpbcKws97yDjFBHtkgBjo9ymryVXi4\n\tSfaBzzB/oJZkjj7evSLfIDvmkVM0x0AV17PYodHFMTL25FCwDhXmPUJx4vO7wgf8Q9\n\taxrYLU7r8sWl7ynCKbUrBzI0LcGFoUJeJPxhszVI/VU8jDTqvN3l801grDPfbcc0MC\n\t1pXjCRpy0RTssaMpcoGwVaSTauVDU1sEPmHJvC5iyazY6EbogO+21HjlVALyfa88UM\n\tXnkSNC+TXaW+9r8NmleNPUjwVlIZt+twjNrjonUCcjL8XTW6y6hcyeiyKF+L5lG947\n\t7ov2TRIn6eXhQ==","Date":"Mon, 12 Dec 2022 10:53:40 +0100","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20221212095340.gsv6pavmnhnllc2v@uno.localdomain>","References":"<20221202124005.3643-1-naush@raspberrypi.com>\n\t<20221202124005.3643-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221202124005.3643-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/2] libcamera:camera_sensor,\n\tipa: raspberrypi: Test readOnly() for HBLANK control","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@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26374,"web_url":"https://patchwork.libcamera.org/comment/26374/","msgid":"<167508575001.42371.18269696083479146386@Monstersaurus>","date":"2023-01-30T13:35:50","subject":"Re: [libcamera-devel] [PATCH v2 2/2] libcamera:camera_sensor,\n\tipa: raspberrypi: Test readOnly() for HBLANK control","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck via libcamera-devel (2022-12-02 12:40:05)\n> Use ControlInfo::readOnly() to test if the camera sensor accepts V4L2_CID_HBLANK\n> control changes. This replaces the current workaround where we test if the\n> V4L2_CID_HBLANK min and max values are the same to determine if a control is\n> read-only.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/raspberrypi.cpp | 12 +-----------\n>  src/libcamera/camera_sensor.cpp     | 14 ++------------\n>  2 files changed, 3 insertions(+), 23 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index bead436def3c..57f01496fc44 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -1239,17 +1239,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n>         ctrls.set(V4L2_CID_EXPOSURE, exposureLines);\n>         ctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode);\n>  \n> -       /*\n> -        * At present, there is no way of knowing if a control is read-only.\n> -        * As a workaround, assume that if the minimum and maximum values of\n> -        * the V4L2_CID_HBLANK control are the same, it implies the control\n> -        * is read-only. This seems to be the case for all the cameras our IPA\n> -        * works with.\n> -        *\n> -        * \\todo The control API ought to have a flag to specify if a control\n> -        * is read-only which could be used below.\n> -        */\n> -       if (mode_.minLineLength != mode_.maxLineLength)\n> +       if (!sensorCtrls_.at(V4L2_CID_HBLANK).readOnly())\n>                 ctrls.set(V4L2_CID_HBLANK, static_cast<int32_t>(hblank));\n\nWell, certainly once there's a .readOnly()...\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>  }\n>  \n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index ae3127d6b693..3785b6441b90 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -185,20 +185,10 @@ int CameraSensor::init()\n>          * Set HBLANK to the minimum to start with a well-defined line length,\n>          * allowing IPA modules that do not modify HBLANK to use the sensor\n>          * minimum line length in their calculations.\n> -        *\n> -        * At present, there is no way of knowing if a control is read-only.\n> -        * As a workaround, assume that if the minimum and maximum values of\n> -        * the V4L2_CID_HBLANK control are the same, it implies the control\n> -        * is read-only.\n> -        *\n> -        * \\todo The control API ought to have a flag to specify if a control\n> -        * is read-only which could be used below.\n>          */\n>         const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n> -       const int32_t hblankMin = hblank.min().get<int32_t>();\n> -       const int32_t hblankMax = hblank.max().get<int32_t>();\n> -\n> -       if (hblankMin != hblankMax) {\n> +       if (!hblank.readOnly()) {\n> +               const int32_t hblankMin = hblank.min().get<int32_t>();\n>                 ControlList ctrl(subdev_->controls());\n>  \n>                 ctrl.set(V4L2_CID_HBLANK, hblankMin);\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 95844BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Jan 2023 13:35:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07D4260482;\n\tMon, 30 Jan 2023 14:35:55 +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 63A0360482\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Jan 2023 14:35:53 +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 E61018B8;\n\tMon, 30 Jan 2023 14:35:52 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675085755;\n\tbh=jaAJEzP870ntVpP/WEKrW2fT/UxH2GVXidWhsvref3s=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=mi4YFGRCg4rceLMtmCKUjb2VXmXGG1RPPlA17X0Ww9zwmdNNzBXTxwACoYJLIG0SF\n\ttxy8gO7B1PqiHj0q6s9A0jEn1Edw/y9iS2DW4e6WjYUWLf5tw+X5tY+5u7csrK4d5z\n\tpqN0lU0uG55pu/6lIn45Qf44f0At1StICwRHWOBhR1VGwSazCmSGCWh2IjvPaxbtzL\n\tMP1G9RdNR8PP57c0/1h2ZhLUIbe2MpTy818Y5yCS7UsnsLvi1PaEcDdwD98YUTfqQy\n\thyXnQIaPKWxTdJTJcZ65BU06y/YyT53mXJAKWG6SyaTZArRyKX0QTKm75Lt+zb2uuR\n\tQEhBQS5M27tdg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1675085753;\n\tbh=jaAJEzP870ntVpP/WEKrW2fT/UxH2GVXidWhsvref3s=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=keHWsXemSnIyH8HwSJP2HIwNNH9dCeQhuM+GZV/1zgWPGgSGqz5emqh5/XycnKw04\n\tpkmM7eZS3YRJNG/Z6x1+efPkyYViKVkmop3cN8lHoosmRHkFqCJXlpbpcPlRFJAjAe\n\tOH27ehpPDidSjRz3d4GG0sMN5d8ZMW6SdHbqq3vk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"keHWsXem\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20221202124005.3643-3-naush@raspberrypi.com>","References":"<20221202124005.3643-1-naush@raspberrypi.com>\n\t<20221202124005.3643-3-naush@raspberrypi.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 30 Jan 2023 13:35:50 +0000","Message-ID":"<167508575001.42371.18269696083479146386@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v2 2/2] libcamera:camera_sensor,\n\tipa: raspberrypi: Test readOnly() for HBLANK control","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]