From patchwork Mon Nov 3 14:49:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 24954 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3AE9CBDE4C for ; Mon, 3 Nov 2025 14:49:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DF74760A80; Mon, 3 Nov 2025 15:49:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A+vY/Ut7"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F9C0606A0 for ; Mon, 3 Nov 2025 15:49:21 +0100 (CET) Received: from pb-laptop.local (185.221.140.239.nat.pool.zt.hu [185.221.140.239]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 457FD7CE for ; Mon, 3 Nov 2025 15:47:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762181248; bh=u4nzrQgCtW+z35fq/frBap6W/i9M+xf1v1XaT0GanA4=; h=From:To:Subject:Date:From; b=A+vY/Ut7uy2Ht0yUHYSg/xHNTLCqHmpOylNasNKMmWOKAA9DBIs8/159X57E6YRVq afmFaRs9+H6RdDzL/4l7o8Vo5Pb7XqhqNfeI+uddYDJ8XwMpjOhw2V8PIZGqK0OqLz 0yDiQZ0Fq7zJuHO44BjDU9oCL3jPaVLCLKHVLzcE= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] treewide: Use proper enum types for controls/properties Date: Mon, 3 Nov 2025 15:49:17 +0100 Message-ID: <20251103144917.439212-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.51.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The enumerated controls/properties use `int32_t` as their backing type. In multiple cases, when parsing such an enum value from a source, an integer type is used. Replace the integer type with the proper enum type where it is trivially doable. This change also brings `CameraSensorLegacy::initProperties()` in line with `CameraSensorRaw::initProperties()`, by defaulting the color filter arrangement to `MONO`. Signed-off-by: Barnabás Pőcze --- src/ipa/libipa/agc_mean_luminance.cpp | 2 +- src/ipa/rpi/common/ipa_base.cpp | 4 +++- src/libcamera/sensor/camera_sensor_legacy.cpp | 5 +++-- src/libcamera/sensor/camera_sensor_raw.cpp | 5 ++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 64f36bd75d..0c46329c09 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -297,7 +297,7 @@ int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData) * possible before touching gain. */ if (availableExposureModes.empty()) { - int32_t exposureModeId = controls::ExposureNormal; + auto exposureModeId = controls::ExposureNormal; std::vector> stages = { }; std::shared_ptr helper = diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 8dfe35cc32..865035e578 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -1584,7 +1584,9 @@ void IpaBase::reportMetadata(unsigned int ipaContext) const AfStatus *afStatus = rpiMetadata.getLocked("af.status"); if (afStatus) { - int32_t s, p; + controls::AfStateEnum s; + controls::AfPauseStateEnum p; + switch (afStatus->state) { case AfState::Scanning: s = controls::AfStateScanning; diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index f9e685a9ac..8b6df10ee6 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -571,7 +571,7 @@ int CameraSensorLegacy::initProperties() const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION); if (orientation != controls.end()) { int32_t v4l2Orientation = orientation->second.def().get(); - int32_t propertyValue; + properties::LocationEnum propertyValue; switch (v4l2Orientation) { default: @@ -624,7 +624,8 @@ int CameraSensorLegacy::initProperties() /* Color filter array pattern, register only for RAW sensors. */ if (bayerFormat_) { - int32_t cfa; + auto cfa = properties::draft::MONO; + switch (bayerFormat_->order) { case BayerFormat::BGGR: cfa = properties::draft::BGGR; diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 8ea4423698..cabaa21635 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -576,7 +576,7 @@ int CameraSensorRaw::initProperties() const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION); if (orientation != controls.end()) { int32_t v4l2Orientation = orientation->second.def().get(); - int32_t propertyValue; + properties::LocationEnum propertyValue; switch (v4l2Orientation) { default: @@ -628,7 +628,7 @@ int CameraSensorRaw::initProperties() properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); /* Color filter array pattern. */ - uint32_t cfa; + auto cfa = properties::draft::MONO; switch (cfaPattern_) { case BayerFormat::BGGR: @@ -644,7 +644,6 @@ int CameraSensorRaw::initProperties() cfa = properties::draft::RGGB; break; case BayerFormat::MONO: - default: cfa = properties::draft::MONO; break; }