[{"id":36785,"web_url":"https://patchwork.libcamera.org/comment/36785/","msgid":"<f2e819e8e8025cb1f0f01c7dea6ce050@igalia.com>","date":"2025-11-12T10:29:45","subject":"Re: [PATCH v2] treewide: Use proper enum types for\n\tcontrols/properties","submitter":{"id":232,"url":"https://patchwork.libcamera.org/api/people/232/","name":"Umang Jain","email":"uajain@igalia.com"},"content":"On 2025-11-12 14:39, Barnabás Pőcze wrote:\n> The enumerated controls/properties use `int32_t` as their backing type.\n> In multiple cases, when parsing such an enum value from a source, an\n> integer type is used. Replace the integer type with the proper enum\n> type where it is trivially doable.\n> \n> This change also brings `CameraSensorLegacy::initProperties()` in line\n> with `CameraSensorRaw::initProperties()`, by defaulting the color\n> filter arrangement to `MONO`.\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Umang Jain <uajain@igalia.com>\n\n> ---\n> changes in v2:\n>   * don't use `auto`\n> \n> v1: https://patchwork.libcamera.org/patch/24954/\n> ---\n>  src/ipa/libipa/agc_mean_luminance.cpp         | 2 +-\n>  src/ipa/rpi/common/ipa_base.cpp               | 4 +++-\n>  src/libcamera/sensor/camera_sensor_legacy.cpp | 5 +++--\n>  src/libcamera/sensor/camera_sensor_raw.cpp    | 5 ++---\n>  4 files changed, 9 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n> index 64f36bd75d..4df1201892 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.cpp\n> +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n> @@ -297,7 +297,7 @@ int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData)\n>  \t * possible before touching gain.\n>  \t */\n>  \tif (availableExposureModes.empty()) {\n> -\t\tint32_t exposureModeId = controls::ExposureNormal;\n> +\t\tcontrols::AeExposureModeEnum exposureModeId = controls::ExposureNormal;\n>  \t\tstd::vector<std::pair<utils::Duration, double>> stages = { };\n> \n>  \t\tstd::shared_ptr<ExposureModeHelper> helper =\n> diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> index 8dfe35cc32..865035e578 100644\n> --- a/src/ipa/rpi/common/ipa_base.cpp\n> +++ b/src/ipa/rpi/common/ipa_base.cpp\n> @@ -1584,7 +1584,9 @@ void IpaBase::reportMetadata(unsigned int ipaContext)\n> \n>  \tconst AfStatus *afStatus = rpiMetadata.getLocked<AfStatus>(\"af.status\");\n>  \tif (afStatus) {\n> -\t\tint32_t s, p;\n> +\t\tcontrols::AfStateEnum s;\n> +\t\tcontrols::AfPauseStateEnum p;\n> +\n>  \t\tswitch (afStatus->state) {\n>  \t\tcase AfState::Scanning:\n>  \t\t\ts = controls::AfStateScanning;\n> diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp\n> index f9e685a9ac..8f45ec9e15 100644\n> --- a/src/libcamera/sensor/camera_sensor_legacy.cpp\n> +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp\n> @@ -571,7 +571,7 @@ int CameraSensorLegacy::initProperties()\n>  \tconst auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION);\n>  \tif (orientation != controls.end()) {\n>  \t\tint32_t v4l2Orientation = orientation->second.def().get<int32_t>();\n> -\t\tint32_t propertyValue;\n> +\t\tproperties::LocationEnum propertyValue;\n> \n>  \t\tswitch (v4l2Orientation) {\n>  \t\tdefault:\n> @@ -624,7 +624,8 @@ int CameraSensorLegacy::initProperties()\n> \n>  \t/* Color filter array pattern, register only for RAW sensors. */\n>  \tif (bayerFormat_) {\n> -\t\tint32_t cfa;\n> +\t\tproperties::draft::ColorFilterArrangementEnum cfa = properties::draft::MONO;\n> +\n>  \t\tswitch (bayerFormat_->order) {\n>  \t\tcase BayerFormat::BGGR:\n>  \t\t\tcfa = properties::draft::BGGR;\n> diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp\n> index 8ea4423698..1aabc0485b 100644\n> --- a/src/libcamera/sensor/camera_sensor_raw.cpp\n> +++ b/src/libcamera/sensor/camera_sensor_raw.cpp\n> @@ -576,7 +576,7 @@ int CameraSensorRaw::initProperties()\n>  \tconst auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION);\n>  \tif (orientation != controls.end()) {\n>  \t\tint32_t v4l2Orientation = orientation->second.def().get<int32_t>();\n> -\t\tint32_t propertyValue;\n> +\t\tproperties::LocationEnum propertyValue;\n> \n>  \t\tswitch (v4l2Orientation) {\n>  \t\tdefault:\n> @@ -628,7 +628,7 @@ int CameraSensorRaw::initProperties()\n>  \tproperties_.set(properties::PixelArrayActiveAreas, { activeArea_ });\n> \n>  \t/* Color filter array pattern. */\n> -\tuint32_t cfa;\n> +\tproperties::draft::ColorFilterArrangementEnum cfa = properties::draft::MONO;\n> \n>  \tswitch (cfaPattern_) {\n>  \tcase BayerFormat::BGGR:\n> @@ -644,7 +644,6 @@ int CameraSensorRaw::initProperties()\n>  \t\tcfa = properties::draft::RGGB;\n>  \t\tbreak;\n>  \tcase BayerFormat::MONO:\n> -\tdefault:\n>  \t\tcfa = properties::draft::MONO;\n>  \t\tbreak;\n>  \t}\n> --\n> 2.51.2","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 9D664C3263\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 12 Nov 2025 10:29:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C7F2F60A80;\n\tWed, 12 Nov 2025 11:29:50 +0100 (CET)","from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C71AE606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Nov 2025 11:29:48 +0100 (CET)","from maestria.local.igalia.com ([192.168.10.14]\n\thelo=mail.igalia.com) by fanzine2.igalia.com with esmtps \n\t(Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)\n\t(Exim) id 1vJ86m-005VgE-33; Wed, 12 Nov 2025 11:29:48 +0100","from webmail.service.igalia.com ([192.168.21.45])\n\tby mail.igalia.com with esmtp (Exim)\n\tid 1vJ86j-00Fxjb-MR; Wed, 12 Nov 2025 11:29:47 +0100","from localhost ([127.0.0.1] helo=webmail.igalia.com)\n\tby webmail with esmtp (Exim 4.96) (envelope-from <uajain@igalia.com>)\n\tid 1vJ86j-004JvN-0P; Wed, 12 Nov 2025 11:29:45 +0100"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=igalia.com header.i=@igalia.com\n\theader.b=\"ie2Fuirv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n\ts=20170329;\n\th=Content-Transfer-Encoding:Content-Type:Message-ID:References:\n\tIn-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender:Reply-To:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=h6sWZtzxlL7Rqq6X1PUIUVvRKaV/Nt9XPRHTuOazulg=;\n\tb=ie2Fuirv5jm8qKrlzBF6cj4nfs\n\tZFTxxMIj5DwNZrAWD/DowDUVksrEtrJqHp6wIPp5U1mhWLW8EUMb+AbkFKYA4mSkD5S3dK9fhHNF8\n\tk9lRqvQwzJcnB3SFytIE58FNhGumDM13U22NLtvveMdONnwvjNvuDFaxbAAWkPpYF0psyrQrzsuk0\n\t1KNVyeHmO2KCiJDN4MR/h7C6RwYZucYNKafdjjgidNMUHhKa4owRzZPdNnKes+B3oWLB+8OqRTBBe\n\tK0W2T2NXjUzDQvUTDej+OHXa2fsQcDRxdzIsw/R7jc7xCjgBLfa2BxgaFDpx63y/VP4X2IgpsQfa9\n\tHbSdt4Hw==;","MIME-Version":"1.0","Date":"Wed, 12 Nov 2025 15:59:45 +0530","From":"Umang Jain <uajain@igalia.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v2] treewide: Use proper enum types for\n\tcontrols/properties","In-Reply-To":"<20251112090941.2626202-1-barnabas.pocze@ideasonboard.com>","References":"<20251112090941.2626202-1-barnabas.pocze@ideasonboard.com>","Message-ID":"<f2e819e8e8025cb1f0f01c7dea6ce050@igalia.com>","X-Sender":"uajain@igalia.com","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-Spam-Report":"NO, Score=-2.2, Tests=ALL_TRUSTED=-3, AWL=0.001, BAYES_50=0.8,\n\tURIBL_BLOCKED=0.001","X-Spam-Score":"-21","X-Spam-Bar":"--","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>"}}]