From patchwork Fri Sep 24 17:25:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13934 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 C5473BDC71 for ; Fri, 24 Sep 2021 17:24:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 63E8369196; Fri, 24 Sep 2021 19:24:50 +0200 (CEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B83BC69188 for ; Fri, 24 Sep 2021 19:24:45 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id A6A751BF208; Fri, 24 Sep 2021 17:24:44 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Sep 2021 19:25:24 +0200 Message-Id: <20210924172525.160482-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210924172525.160482-1-jacopo@jmondi.org> References: <20210924172525.160482-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/5] libcamera: control_serializer: Serialize info::def() 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 ControlInfo class was originally designed to only transport the control's minimum and maximum values which represent the control's valid limits. Later the default value of the control has been added to the ControlInfo class, but the control serializer implementation has not been updated accordingly. This causes issues in IPA modules making use of ControlInfo::def() as, when running in isolation, they would receive 0. Fix that by serializing and deserializing the additional ControlValue and update the protocol description accordingly. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/libcamera/control_serializer.cpp | 6 ++++-- src/libcamera/ipa_controls.cpp | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index d42840cddecb..f1245ea620ab 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -105,7 +105,7 @@ size_t ControlSerializer::binarySize(const ControlValue &value) size_t ControlSerializer::binarySize(const ControlInfo &info) { - return binarySize(info.min()) + binarySize(info.max()); + return binarySize(info.min()) + binarySize(info.max()) + binarySize(info.def()); } /** @@ -158,6 +158,7 @@ void ControlSerializer::store(const ControlInfo &info, ByteStreamBuffer &buffer) { store(info.min(), buffer); store(info.max(), buffer); + store(info.def(), buffer); } /** @@ -346,8 +347,9 @@ ControlInfo ControlSerializer::loadControlInfo(ControlType type, ControlValue min = loadControlValue(type, b); ControlValue max = loadControlValue(type, b); + ControlValue def = loadControlValue(type, b); - return ControlInfo(min, max); + return ControlInfo(min, max, def); } /** diff --git a/src/libcamera/ipa_controls.cpp b/src/libcamera/ipa_controls.cpp index fb98cda30ede..c3489bbff646 100644 --- a/src/libcamera/ipa_controls.cpp +++ b/src/libcamera/ipa_controls.cpp @@ -108,17 +108,19 @@ * +-------------------------+ . * / | ... | | entry[n].offset * | +-------------------------+ <-----ยด - * Data | | minimum value (#n) | \ - * section | +-------------------------+ | Entry #n - * | | maximum value (#n) | / + * | | minimum value (#n) | \ + * Data | +-------------------------+ | + * section | | maximum value (#n) | | Entry #n + * | +-------------------------+ | + * | | default value (#n) | / * | +-------------------------+ * \ | ... | * +-------------------------+ * ~~~~ * - * The minimum and maximum value are stored in the platform's native data - * format. The ipa_control_info_entry::offset field stores the offset from the - * beginning of the data section to the info data. + * The minimum, maximum and default values are stored in the platform's native + * data format. The ipa_control_info_entry::offset field stores the offset from + * the beginning of the data section to the info data. * * Info data in the data section shall be stored in the same order as the * entries array, shall be aligned to a multiple of 8 bytes, and shall be