From patchwork Sat Apr 25 20:56:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3542 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A49C603FC for ; Sat, 25 Apr 2020 22:56:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d+WXQzFJ"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CFCCB4F7; Sat, 25 Apr 2020 22:56:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1587848219; bh=eNgmipggjKuVhGaJWNTiywO3WhssVqjOJ8X2DB4yxlY=; h=From:To:Cc:Subject:Date:From; b=d+WXQzFJCgmt1Xr4fvYVhq6Doo9SXBojwJlkD4NU0SwEJuXc35Eag1pYbTLm39oE5 7Ag/dnH0UvZ6aaUqn4owhKCKA/OhNs2gjt+/WvaUQyIhomUAkpiV8p3U1ZxDgyNxBf YRMJ/I/mNSTNuCjcKrQBj45m+a1Ns4r+eNfTdkq0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 25 Apr 2020 23:56:38 +0300 Message-Id: <20200425205639.30566-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: controls: Add rectangle and size control types 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-List-Received-Date: Sat, 25 Apr 2020 20:56:59 -0000 Add two control types to store rectangles and sizes. These will be useful for the properties related to the pixel array. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/controls.h | 13 +++++++++++++ src/libcamera/controls.cpp | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 4b2e7e9cdd6c..80944efc133a 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -13,6 +13,7 @@ #include #include +#include #include namespace libcamera { @@ -27,6 +28,8 @@ enum ControlType { ControlTypeInteger64, ControlTypeFloat, ControlTypeString, + ControlTypeRectangle, + ControlTypeSize, }; namespace details { @@ -70,6 +73,16 @@ struct control_type { static constexpr ControlType value = ControlTypeString; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeRectangle; +}; + +template<> +struct control_type { + static constexpr ControlType value = ControlTypeSize; +}; + template struct control_type> : public control_type> { }; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 540cc026417a..08df7f29e938 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -58,6 +58,8 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeInteger64] = sizeof(int64_t), [ControlTypeFloat] = sizeof(float), [ControlTypeString] = sizeof(char), + [ControlTypeRectangle] = sizeof(Rectangle), + [ControlTypeSize] = sizeof(Size), }; } /* namespace */ @@ -242,6 +244,16 @@ std::string ControlValue::toString() const str += std::to_string(*value); break; } + case ControlTypeRectangle: { + const Rectangle *value = reinterpret_cast(data); + str += value->toString(); + break; + } + case ControlTypeSize: { + const Size *value = reinterpret_cast(data); + str += value->toString(); + break; + } case ControlTypeNone: case ControlTypeString: break;