From patchwork Wed Jun 7 10:00:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18717 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 95DF9C31E9 for ; Wed, 7 Jun 2023 10:01:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4A7B0628A0; Wed, 7 Jun 2023 12:01:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686132070; bh=tu4bRmcEaQqNlcxtWPbaL9tphuQr8mmI66go/+RstpY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xWkYSvxTu3xG4/6aIsXkYDdaBkKDRZhnxcremSEytEPvNxs9q7g5sIX5pgpQ0GLBd EqgxAjZQ7mX68ZZaygx3SpY49tKtqv5JQFCefxy80DYBjxHNCh3rbhKNQ5imzsKh+E 4OwJDisujyK3LrmaxJ7EQZpqIKYVSA3Ultfi4CLCqXv9gyRdraSPpEr11JZPCMUK+z ScGi7gZqpg1a1NLdJNPG7vcRxTbkix95gAN0VV6quDrCG6Y0fo2tQe7rqYpQCniKj+ 9HhZZ3S3s2aHqZTngmQg8SXSTKX4rvJOsRuvQCOyNYgL1lTwWcj+UwRpzRkA5VAoid 8QHRMvNdva9pg== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2374562899 for ; Wed, 7 Jun 2023 12:01:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="QoQM82zy"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f735bfcbbbso31572725e9.2 for ; Wed, 07 Jun 2023 03:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1686132066; x=1688724066; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fdSQojxheQYTuQ2xidXZl7R5UCmxPlHXljHGiv5RCeY=; b=QoQM82zyHkok+d0UzA9QhxSLkIinN8ILmRbne1nOFe8AWimVl5bSNpBqbAMa601bNL N/V7qTnOL/kycDQfo+tCcVwEcF4CXwLOjjqyFVftvE0X/P7cDSeMldrDVjqYKhV3vu9a +dkdrlY/sGrgGweq7u813d6zNmgJ0tMLzOPQ1+t0CNrhx28Wi9mktDuuNXBgq0H1H7m8 OU4BhLr8z1kPGqFpkGKOnmzsg51OwecMLem4JpEzSa9tqDB95KK82sRvzNyw8e+gHx4Q vJnu1O6N5tiQqfBkRt6rSnwFcm1yoL4H8o1yRx00yajUZc99D1o55yD4xwXoxNcsWvrO zD6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686132066; x=1688724066; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fdSQojxheQYTuQ2xidXZl7R5UCmxPlHXljHGiv5RCeY=; b=l+xxvfNMKNLilIWWKq4qPU5Ygqq+t3xDXC9eAvtuGMSDx/9sBcvP70ZcAZfMhZlMbh LqbeO6OG5u1tqBtpJqu23JyxLZCZVb1dzLTT/8Sx9KDyi8lhc7d29us76H0lPqh81PSh tp/N44MRILcz3t7Hx93u62gULps7i+vnLoaUnneLI2u03uG28EfiYUqJTyCmnNtNa4gW qdQHvMyifRN7nAukwRMoI2Zp7XHnuHzPjLXapeR8DO9ul2LTbh1n0Y3nc4WlD0TjcxcH KxM0crA/thzMAtm6vES0hshvLROm5mMBQGEODJXn7cYS+LxAQcB+cil/WdD+HKql5VG6 MCwA== X-Gm-Message-State: AC+VfDzw5FrJTmbqc8NK9wuEl9Bk6R36Azl5Cya1YWnEXvx/7F9G3WdP X3fr6/dT9SZZG+E35dOqqiwBHnDWUFDEyeUN7MaDrQ== X-Google-Smtp-Source: ACHHUZ67CqYgA93SCMdYrFfjcYqW/HhxFRjfefAYtvpb0+WCZ5MOR3op5tP7OMdacJw1+WFY4T/k5g== X-Received: by 2002:a05:600c:2257:b0:3f6:f152:1183 with SMTP id a23-20020a05600c225700b003f6f1521183mr4197229wmm.37.1686132066444; Wed, 07 Jun 2023 03:01:06 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id t7-20020a1c7707000000b003f6cf9afc25sm1556889wmi.40.2023.06.07.03.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 03:01:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jun 2023 11:00:53 +0100 Message-Id: <20230607100054.4576-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607100054.4576-1-naush@raspberrypi.com> References: <20230607100054.4576-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/3] ipa: rpi: agc: Use std::string instead of char arrays 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace the char array strings in struct AgcStatus with std::string objects. This simplifies the string handling in the source code. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/rpi/controller/agc_status.h | 8 +++++--- src/ipa/rpi/controller/rpi/agc.cpp | 23 +++++++---------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/ipa/rpi/controller/agc_status.h b/src/ipa/rpi/controller/agc_status.h index 6abf09d9df57..6c112e76aa12 100644 --- a/src/ipa/rpi/controller/agc_status.h +++ b/src/ipa/rpi/controller/agc_status.h @@ -6,6 +6,8 @@ */ #pragma once +#include + #include /* @@ -24,9 +26,9 @@ struct AgcStatus { libcamera::utils::Duration targetExposureValue; /* (unfiltered) target total exposure AGC is aiming for */ libcamera::utils::Duration shutterTime; double analogueGain; - char exposureMode[32]; - char constraintMode[32]; - char meteringMode[32]; + std::string exposureMode; + std::string constraintMode; + std::string meteringMode; double ev; libcamera::utils::Duration flickerPeriod; int floatingRegionEnable; diff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp index e79c82e2e65b..b611157af1f0 100644 --- a/src/ipa/rpi/controller/rpi/agc.cpp +++ b/src/ipa/rpi/controller/rpi/agc.cpp @@ -226,7 +226,7 @@ Agc::Agc(Controller *controller) * Setting status_.totalExposureValue_ to zero initially tells us * it's not been calculated yet (i.e. Process hasn't yet run). */ - memset(&status_, 0, sizeof(status_)); + status_ = {}; status_.ev = ev_; } @@ -524,12 +524,6 @@ void Agc::updateLockStatus(DeviceStatus const &deviceStatus) status_.locked = lockCount_ == maxLockCount; } -static void copyString(std::string const &s, char *d, size_t size) -{ - size_t length = s.copy(d, size - 1); - d[length] = '\0'; -} - void Agc::housekeepConfig() { /* First fetch all the up-to-date settings, so no one else has to do it. */ @@ -544,30 +538,27 @@ void Agc::housekeepConfig() * Make sure the "mode" pointers point to the up-to-date things, if * they've changed. */ - if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) { + if (meteringModeName_ != status_.meteringMode) { auto it = config_.meteringModes.find(meteringModeName_); if (it == config_.meteringModes.end()) LOG(RPiAgc, Fatal) << "No metering mode " << meteringModeName_; meteringMode_ = &it->second; - copyString(meteringModeName_, status_.meteringMode, - sizeof(status_.meteringMode)); + status_.meteringMode = meteringModeName_; } - if (strcmp(exposureModeName_.c_str(), status_.exposureMode)) { + if (exposureModeName_ != status_.exposureMode) { auto it = config_.exposureModes.find(exposureModeName_); if (it == config_.exposureModes.end()) LOG(RPiAgc, Fatal) << "No exposure profile " << exposureModeName_; exposureMode_ = &it->second; - copyString(exposureModeName_, status_.exposureMode, - sizeof(status_.exposureMode)); + status_.exposureMode = exposureModeName_; } - if (strcmp(constraintModeName_.c_str(), status_.constraintMode)) { + if (constraintModeName_ != status_.constraintMode) { auto it = config_.constraintModes.find(constraintModeName_); if (it == config_.constraintModes.end()) LOG(RPiAgc, Fatal) << "No constraint list " << constraintModeName_; constraintMode_ = &it->second; - copyString(constraintModeName_, status_.constraintMode, - sizeof(status_.constraintMode)); + status_.constraintMode = constraintModeName_; } LOG(RPiAgc, Debug) << "exposureMode " << exposureModeName_ << " constraintMode "