From patchwork Thu Oct 6 23:07:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17557 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 D721BBD16B for ; Thu, 6 Oct 2022 23:07:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8375862D0E; Fri, 7 Oct 2022 01:07:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665097678; bh=6IrpVGQne4DhF/cufG8P66+LI9YMJNAkfFU83KhVHRM=; 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=Do4ZiE5INMD1o+u5yrVof0Ot3yFo02FkTLXWq8V8RzWfEzN+hSGob1swc5tQTCKYo A6AGGQ/42YmSrlWkeyHUVJwEZErQpDtUoor4N4R+iQ0p4kyoPpJ7ZUusPrF/3W9QFJ A1i7QZBbINspHnC3Bz32kZKfM3hcXv9SYEbMfXH07EbTBlPADWpha0oeSylXudSWa2 GhGjUAFWB+hS9YKZZ2tpz9pii+vV0XRxKmeha3oVtJITCkNa4Nw59WxcfPjuFCJJUJ U0MWc2+XkZzDHQQAgXE/hH5gFnviXu5/dHBEquNdLoUT5rY8S+123rBbgzyqdYY6Ax Xhb8spQkEJ5EQ== 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 3FE6C62D0A for ; Fri, 7 Oct 2022 01:07:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jtO8B/0a"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9F5006D6; Fri, 7 Oct 2022 01:07:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665097676; bh=6IrpVGQne4DhF/cufG8P66+LI9YMJNAkfFU83KhVHRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtO8B/0aZ2EIg9Pbn17l9FG52YxKa3ZneS++KeR+8+mZMfSbFFMmAQx+1wlZLuoFs 3o86PMYE69rEivWWUyqmMMXPH1efPtk6yx9oDUkt9A+LK5uTNHuKYLZblSMRQNmg3d EXIw4eIIq2iwC8t0Q8l560nraROIi0VeKyPmjHsk= To: libcamera-devel@lists.libcamera.org Date: Fri, 7 Oct 2022 02:07:45 +0300 Message-Id: <20221006230747.11688-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221006230747.11688-1-laurent.pinchart@ideasonboard.com> References: <20221006230747.11688-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve YAML notation for variable-size array controls 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Array controls specify the array size through the YAML 'size' element, which stores a list of values, one per dimension. Variable-size arrays currently use an empty 'size' list, which prevents describing the number of dimensions of the array. Improve this by using the same notation for fixed-size and variable-size array controls. Dimensions that are not fixed are described as a string instead of an integer, such as [n], [n,3] or [w,h]. The strings have currently no special meaning, this may change in the future. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/libcamera/control_ids.yaml | 2 +- src/libcamera/property_ids.yaml | 4 ++-- utils/gen-controls.py | 31 +++++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index c93f362463dd..a456e6c0358f 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -525,7 +525,7 @@ controls: the window where the focal distance for the objects shown in that part of the image are closest to the camera. - size: [] + size: [n] - AfTrigger: type: int32_t diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 960e254495b7..cb55e0ed2283 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -497,7 +497,7 @@ controls: - PixelArrayOpticalBlackRectangles: type: Rectangle - size: [] + size: [n] description: | The pixel array region(s) which contain optical black pixels considered valid for calibration purposes. @@ -592,7 +592,7 @@ controls: - PixelArrayActiveAreas: type: Rectangle - size: [] + size: [n] description: | The PixelArrayActiveAreas property defines the (possibly multiple and overlapping) portions of the camera sensor readable pixel matrix diff --git a/utils/gen-controls.py b/utils/gen-controls.py index d6b4e30001b2..45b7081e6b1d 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -39,11 +39,33 @@ class Control(object): self.__name = name self.__data = data self.__enum_values = None + self.__size = None enum_values = data.get('enum') if enum_values is not None: self.__enum_values = [ControlEnum(enum) for enum in enum_values] + size = self.__data.get('size') + if size is not None: + if len(size) == 0: + raise RuntimeError(f'Control `{self.__name}` size must have at least one dimension') + + # Compute the total number of elemens in the array. If any of the + # array dimension is a string, the array is variable-sized. + num_elems = 1 + for dim in size: + if type(dim) is str: + num_elems = 0 + break + + dim = int(dim) + if dim <= 0: + raise RuntimeError(f'Control `{self.__name}` size must have positive values only') + + num_elems *= dim + + self.__size = num_elems + @property def description(self): """The control description""" @@ -86,15 +108,12 @@ class Control(object): if typ == 'string': return 'std::string' - if size is None: + if self.__size is None: return typ - if len(size) > 0: - # fixed-sized Span - span_size = reduce(operator.mul, size) - return f"Span" + if self.__size: + return f"Span" else: - # variable-sized Span return f"Span"