[{"id":22825,"web_url":"https://patchwork.libcamera.org/comment/22825/","msgid":"<165158256578.1217485.3745021751360970623@Monstersaurus>","date":"2022-05-03T12:56:05","subject":"Re: [libcamera-devel] [PATCH v3 2/2] libcamera: raspberrypi: Fetch\n\tcorrect value for SensorSensitivity","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-04-21 16:11:17)\n> From: David Plowman <david.plowman@raspberrypi.com>\n> \n> These changes retrieve the correct value for sensitivity of the mode\n> selected for the sensor. This value is known to the CamHelper which\n> passes it across to the pipeline handler so that it can be set\n> correctly in the camera properties.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  include/libcamera/ipa/raspberrypi.mojom            |  7 ++++++-\n>  src/ipa/raspberrypi/raspberrypi.cpp                |  7 +++++--\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 ++++++++----\n>  3 files changed, 19 insertions(+), 7 deletions(-)\n> \n> diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\n> index 5a228b75cd2f..a60c3bb43d3c 100644\n> --- a/include/libcamera/ipa/raspberrypi.mojom\n> +++ b/include/libcamera/ipa/raspberrypi.mojom\n> @@ -38,6 +38,10 @@ struct IPAConfig {\n>         libcamera.SharedFD lsTableHandle;\n>  };\n>  \n> +struct IPAConfigResult {\n> +       float modeSensitivity;\n> +};\n> +\n>  struct StartConfig {\n>         libcamera.ControlList controls;\n>         int32 dropFrameCount;\n> @@ -58,6 +62,7 @@ interface IPARPiInterface {\n>          * \\param[in] entityControls Controls provided by the pipeline entities\n>          * \\param[in] ipaConfig Pipeline-handler-specific configuration data\n>          * \\param[out] controls Controls to apply by the pipeline entity\n> +        * \\param[out] result Other results that the pipeline handler may require\n>          *\n>          * This function shall be called when the camera is configured to inform\n>          * the IPA of the camera's streams and the sensor settings.\n> @@ -72,7 +77,7 @@ interface IPARPiInterface {\n>                   map<uint32, libcamera.IPAStream> streamConfig,\n>                   map<uint32, libcamera.ControlInfoMap> entityControls,\n>                   IPAConfig ipaConfig)\n> -               => (int32 ret, libcamera.ControlList controls);\n> +               => (int32 ret, libcamera.ControlList controls, IPAConfigResult result);\n>  \n>         /**\n>          * \\fn mapBuffers()\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 5efd051bdd13..fd66cfeee087 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -99,7 +99,7 @@ public:\n>                       const std::map<unsigned int, IPAStream> &streamConfig,\n>                       const std::map<unsigned int, ControlInfoMap> &entityControls,\n>                       const IPAConfig &data,\n> -                     ControlList *controls) override;\n> +                     ControlList *controls, IPAConfigResult *result) override;\n>         void mapBuffers(const std::vector<IPABuffer> &buffers) override;\n>         void unmapBuffers(const std::vector<unsigned int> &ids) override;\n>         void signalStatReady(const uint32_t bufferId) override;\n> @@ -344,7 +344,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n>                       [[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,\n>                       const std::map<unsigned int, ControlInfoMap> &entityControls,\n>                       const IPAConfig &ipaConfig,\n> -                     ControlList *controls)\n> +                     ControlList *controls, IPAConfigResult *result)\n>  {\n>         if (entityControls.size() != 2) {\n>                 LOG(IPARPI, Error) << \"No ISP or sensor controls found.\";\n> @@ -404,6 +404,9 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n>          */\n>         ControlList ctrls(sensorCtrls_);\n>  \n> +       /* The pipeline handler passes out the mode's sensitivity. */\n> +       result->modeSensitivity = mode_.sensitivity;\n> +\n>         if (firstStart_) {\n>                 /* Supply initial values for frame durations. */\n>                 applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration);\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index acc0becaa5c0..b2489005120c 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -200,7 +200,7 @@ public:\n>         void frameStarted(uint32_t sequence);\n>  \n>         int loadIPA(ipa::RPi::SensorConfig *sensorConfig);\n> -       int configureIPA(const CameraConfiguration *config);\n> +       int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result);\n>  \n>         void enumerateVideoDevices(MediaLink *link);\n>  \n> @@ -898,7 +898,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  \n>         data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop);\n>  \n> -       ret = data->configureIPA(config);\n> +       ipa::RPi::IPAConfigResult result;\n> +       ret = data->configureIPA(config, &result);\n>         if (ret)\n>                 LOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n>  \n> @@ -937,6 +938,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>          */\n>         data->properties_.set(properties::ScalerCropMaximum, data->sensorInfo_.analogCrop);\n>  \n> +       /* Store the mode sensitivity for the application. */\n> +       data->properties_.set(properties::SensorSensitivity, result.modeSensitivity);\n> +\n\nI think this is good. I think in the future we might need better ways to\ndetermine what 'would' be the sensitivity when validating a\nconfiguration - but that would involve more rework, and we know we need\nto do a bigger rework on configuration phase - so I think this is a good\nway forwards now.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>         /* Setup the Video Mux/Bridge entities. */\n>         for (auto &[device, link] : data->bridgeDevices_) {\n>                 /*\n> @@ -1528,7 +1532,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig)\n>         return ipa_->init(settings, sensorConfig);\n>  }\n>  \n> -int RPiCameraData::configureIPA(const CameraConfiguration *config)\n> +int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result)\n>  {\n>         std::map<unsigned int, IPAStream> streamConfig;\n>         std::map<unsigned int, ControlInfoMap> entityControls;\n> @@ -1574,7 +1578,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n>         /* Ready the IPA - it must know about the sensor resolution. */\n>         ControlList controls;\n>         ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig,\n> -                             &controls);\n> +                             &controls, result);\n>         if (ret < 0) {\n>                 LOG(RPI, Error) << \"IPA configuration failed!\";\n>                 return -EPIPE;\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 E2AC6C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  3 May 2022 12:56:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 58B4965646;\n\tTue,  3 May 2022 14:56:09 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 269266563D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  3 May 2022 14:56:08 +0200 (CEST)","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 B0F80E5;\n\tTue,  3 May 2022 14:56:07 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1651582569;\n\tbh=bsIc2kvMd1PJL+/FEbD2mRZLhTBzuylfHXZfWKNlpjQ=;\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=SZvK457YymcBvgknZ+qWXcGAdKZ530HUMSbL3CgiRd8flrAPYvrB3oGCN+4SD+Unc\n\tl9ZRdJO9FTD03UsGpSb8BjphawSc0QVqIiMEiEt4XBEjwyRTuUxYamupLJxchmZUyO\n\t28nduWzjDTe+sfHFSgP2I2g4gCNG4r2L7+ws3emo74yOIGqYbpWkEMX2dVzTQMZrJU\n\tON2W8bBIg9lgkIrTLDYkM9/Xy4VXz49evab/5l9BKxJJJFDINx9Hau+ZhVj/fjvj5H\n\tJKe4m+QgYgLoKWed7SGly4gJY/D7E6vuO0mI76BUeRn8TXmL/zwFwal2tITxMtzEuM\n\trMxu5Tmn+RDig==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1651582567;\n\tbh=bsIc2kvMd1PJL+/FEbD2mRZLhTBzuylfHXZfWKNlpjQ=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=uLhEKz06kVH21pILVKX1o3iwIV7Pm1uCo64Y/Xn+uhacyljOuoqqb2Qq4mv9FjVcj\n\tlebhbAe6fyVoEuo/kAui4YcA8n0CVBzWRiu/RZgmdq2xq1FSGR3S3aujD0oK3k+stE\n\tCjpiYlzhwYmWUcU8+bFq6JSH0HDmM2TLYQVzSDUk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"uLhEKz06\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220421151117.703956-3-naush@raspberrypi.com>","References":"<20220421151117.703956-1-naush@raspberrypi.com>\n\t<20220421151117.703956-3-naush@raspberrypi.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 03 May 2022 13:56:05 +0100","Message-ID":"<165158256578.1217485.3745021751360970623@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3 2/2] libcamera: raspberrypi: Fetch\n\tcorrect value for SensorSensitivity","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>"}}]