From patchwork Thu Oct 6 23:07:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17556 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 3B182BD16B for ; Thu, 6 Oct 2022 23:07:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F232862D08; Fri, 7 Oct 2022 01:07:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665097677; bh=q6SCLqt0jmn10adSE30c75HoqERoAggP/7dZnuz2fCo=; 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=d4e9dZLt9C7TjmxycuP2AmqUQqvJtPcWbrb7uc7kSW2nlCD+duV6NV0jqY95s9Ip0 9s/hgE43wEBuo06Bc2mPbRhPuGhGsXd6avbdl8CE+tJ8U1IbOxQ6lIlA1yjzpHCtSN HR3f9yyUylR6rBs+ENf6E2w+g+x3A69ITUlr1l+Cid9VywnN2cTlfpNByxl4jkQohH ci99pFb0S0DhquK/zVs62QvTB5cg4KA0j47CerLPDd1oYOWuiQ5UWAZThLlzeyZAfz xRYOKCfO3YQ9qjQRULAipJ1A4bCJmR28IO+Ia45mes7hN5HyYQMdftVksZOdnAQrC/ +t7nAK4zVp5qg== 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 4314B603D7 for ; Fri, 7 Oct 2022 01:07:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MdVzHwP/"; 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 BE7A86D6; Fri, 7 Oct 2022 01:07:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665097675; bh=q6SCLqt0jmn10adSE30c75HoqERoAggP/7dZnuz2fCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MdVzHwP/mEP0pWJNwHTbuOQbSqfXGvj+Y7m5HoBBhhDt0gCG0A/Wn6OVEozOCEOj7 p9vgNYQYlWg6r/r0EU8LHT7dfy4Q8HabpdFGKuXKaZgZXhFUxbVuyhShvE4Z3+f457 vBNcFMAINaaXGZfhi6Cl+bScWGCxsJc2KlL8OAgc= To: libcamera-devel@lists.libcamera.org Date: Fri, 7 Oct 2022 02:07:44 +0300 Message-Id: <20221006230747.11688-2-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 1/4] utils: gen-controls: Factor out YAML data handling in classes 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" The gen-controls.py script handles the data structure produced by the YAML parser manually through the whole code base. Clean this up by encapsulating it in Control and ControlEnum classes to model a control and its enum values respectively, to decouple YAML data handling from generation. No functional change intended. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- Changes since v1: - Use self.__enum_values to check if Control is an enum - Fix typos --- utils/gen-controls.py | 156 ++++++++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 50 deletions(-) diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 46ba439439ec..d6b4e30001b2 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -14,6 +14,90 @@ import sys import yaml +class ControlEnum(object): + def __init__(self, data): + self.__data = data + + @property + def description(self): + """The enum description""" + return self.__data.get('description') + + @property + def name(self): + """The enum name""" + return self.__data.get('name') + + @property + def value(self): + """The enum value""" + return self.__data.get('value') + + +class Control(object): + def __init__(self, name, data): + self.__name = name + self.__data = data + self.__enum_values = None + + enum_values = data.get('enum') + if enum_values is not None: + self.__enum_values = [ControlEnum(enum) for enum in enum_values] + + @property + def description(self): + """The control description""" + return self.__data.get('description') + + @property + def enum_values(self): + """The enum values, if the control is an enumeration""" + if self.__enum_values is None: + return + for enum in self.__enum_values: + yield enum + + @property + def is_enum(self): + """Is the control an enumeration""" + return self.__enum_values is not None + + @property + def is_draft(self): + """Is the control a draft control""" + return self.__data.get('draft') is not None + + @property + def name(self): + """The control name (CamelCase)""" + return self.__name + + @property + def q_name(self): + """The control name, qualified with a namespace""" + ns = 'draft::' if self.is_draft else '' + return ns + self.__name + + @property + def type(self): + typ = self.__data.get('type') + size = self.__data.get('size') + + if typ == 'string': + return 'std::string' + + if size is None: + return typ + + if len(size) > 0: + # fixed-sized Span + span_size = reduce(operator.mul, size) + return f"Span" + else: + # variable-sized Span + return f"Span" + + def snake_case(s): return ''.join([c.isupper() and ('_' + c) or c for c in s]).strip('_') @@ -24,24 +108,6 @@ def format_description(description): return '\n'.join([(line and ' * ' or ' *') + line for line in description]) -def get_ctrl_type(ctrl): - ctrl_type = ctrl['type'] - ctrl_size_arr = ctrl.get('size') - - if ctrl_type == 'string': - return 'std::string' - elif ctrl_size_arr is not None: - if len(ctrl_size_arr) > 0: - # fixed-sized Span - ctrl_span_size = reduce(operator.mul, ctrl_size_arr) - return f"Span" - else: - # variable-sized Span - return f"Span" - else: - return ctrl_type - - def generate_cpp(controls): enum_doc_start_template = string.Template('''/** * \\enum ${name}Enum @@ -67,35 +133,31 @@ ${description} ctrls_map = [] for ctrl in controls: - name, ctrl = ctrl.popitem() - id_name = snake_case(name).upper() - - ctrl_type = get_ctrl_type(ctrl) + id_name = snake_case(ctrl.name).upper() info = { - 'name': name, - 'type': ctrl_type, - 'description': format_description(ctrl['description']), + 'name': ctrl.name, + 'type': ctrl.type, + 'description': format_description(ctrl.description), 'id_name': id_name, } target_doc = ctrls_doc target_def = ctrls_def - if ctrl.get('draft'): + if ctrl.is_draft: target_doc = draft_ctrls_doc target_def = draft_ctrls_def - enum = ctrl.get('enum') - if enum: + if ctrl.is_enum: enum_doc = [] enum_doc.append(enum_doc_start_template.substitute(info)) num_entries = 0 - for entry in enum: + for enum in ctrl.enum_values: value_info = { - 'name': name, - 'value': entry['name'], - 'description': format_description(entry['description']), + 'name': ctrl.name, + 'value': enum.name, + 'description': format_description(enum.description), } enum_doc.append(enum_doc_value_template.substitute(value_info)) num_entries += 1 @@ -110,9 +172,9 @@ ${description} } target_doc.append(enum_values_doc.substitute(values_info)) target_def.append(enum_values_start.substitute(values_info)) - for entry in enum: + for enum in ctrl.enum_values: value_info = { - 'name': entry['name'] + 'name': enum.name } target_def.append(enum_values_values.substitute(value_info)) target_def.append("};") @@ -120,10 +182,7 @@ ${description} target_doc.append(doc_template.substitute(info)) target_def.append(def_template.substitute(info)) - if ctrl.get('draft'): - name = 'draft::' + name - - ctrls_map.append('\t{ ' + id_name + ', &' + name + ' },') + ctrls_map.append('\t{ ' + id_name + ', &' + ctrl.q_name + ' },') return { 'controls_doc': '\n\n'.join(ctrls_doc), @@ -146,31 +205,27 @@ def generate_h(controls): id_value = 1 for ctrl in controls: - name, ctrl = ctrl.popitem() - id_name = snake_case(name).upper() + id_name = snake_case(ctrl.name).upper() ids.append('\t' + id_name + ' = ' + str(id_value) + ',') - ctrl_type = get_ctrl_type(ctrl) - info = { - 'name': name, - 'type': ctrl_type, + 'name': ctrl.name, + 'type': ctrl.type, } target_ctrls = ctrls - if ctrl.get('draft'): + if ctrl.is_draft: target_ctrls = draft_ctrls - enum = ctrl.get('enum') - if enum: + if ctrl.is_enum: target_ctrls.append(enum_template_start.substitute(info)) num_entries = 0 - for entry in enum: + for enum in ctrl.enum_values: value_info = { - 'name': entry['name'], - 'value': entry['value'], + 'name': enum.name, + 'value': enum.value, } target_ctrls.append(enum_value_template.substitute(value_info)) num_entries += 1 @@ -214,6 +269,7 @@ def main(argv): data = open(args.input, 'rb').read() controls = yaml.safe_load(data)['controls'] + controls = [Control(*ctrl.popitem()) for ctrl in controls] if args.template.endswith('.cpp.in'): data = generate_cpp(controls) 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" From patchwork Thu Oct 6 23:07:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17558 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 72FD7BD16B for ; Thu, 6 Oct 2022 23:08:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2913262D07; Fri, 7 Oct 2022 01:08:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665097681; bh=5RD1PXUGvhzpLRYGfkbmlyL16KVADQxTMpFINfHZAxg=; 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=1AAIcKCXjmFB+RcraLJ94GmG61nxMlZkfuA9hhwSLVaUuAyFlbzPXy2PKSp06j0kB llPcwJGPeiy6DWdbDviuR8o7orSyO0xI8RfpoxsV1izpWCbm1LXnNqiU+yLYMfWqFF q/YnkVWkWRJiRVPOKoaQIQVhwkuqADecZYl6c/CzaucOfIms8DFVxoZbxQ5iXLfmLo gUpoj+S+KAdVP8QWaIK/cycZTijVrKAMecyN3BFw/+A1IcapzKVdXmT3z0EyrjBS5+ Ven85p01WoLXKRGn5racEDeIVsXc2qeWfEPxXSFeNW0JgbXTLGZJGC6GjEzulWpD15 AtsZlUfrtUCSA== 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 3AC2962D07 for ; Fri, 7 Oct 2022 01:07:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qaIHJQyI"; 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 B39906D6; Fri, 7 Oct 2022 01:07:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665097679; bh=5RD1PXUGvhzpLRYGfkbmlyL16KVADQxTMpFINfHZAxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qaIHJQyIBIiq+SPCXnN/fMHwRjCvQ4to7Pwfm5CJtn4VJoOMVRE0zgfYx12ldaJoK WmQg0S5zC4KCaoIejl3ogrVpqhPd3gB8wDI7goVQJlfsgRdgz6DVXb7/3jilUvjHPP sp6iyzuxepc+PxhL2nFHHzka2wW60Dnr/lekMHqM= To: libcamera-devel@lists.libcamera.org Date: Fri, 7 Oct 2022 02:07:46 +0300 Message-Id: <20221006230747.11688-4-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 3/4] libcamera: controls: Construct Span with size for 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" The ControlList::set() function overload used for array controls constructs a Span from an initializer list. It doesn't specify the Span size explicitly, which results in a dynamic extent Span being constructed. That causes a compilation failure for fixed-size array controls, as they are defined as Control with T being a fixed-extent Span, and conversion from a dynamic-extent to fixed-extent Span when calling ControlValue::set() can't be implicit. Fix this by constructing the Span using the size of the control, which resolves to a fixed-extent and dynamic-extent Span for fixed-size and dynamic-size array controls respectively. The ControlList::set() function that takes an initializer list can then be used for fixed-size array controls. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/controls.h | 6 +++--- src/libcamera/controls.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 38d0a3e8360a..cf94205577a5 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -393,14 +393,14 @@ public: val->set(value); } - template - void set(const Control &ctrl, const std::initializer_list &value) + template + void set(const Control> &ctrl, const std::initializer_list &value) { ControlValue *val = find(ctrl.id()); if (!val) return; - val->set(Span>{ value.begin(), value.size() }); + val->set(Span, Size>{ value.begin(), value.size() }); } const ControlValue &get(unsigned int id) const; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index bc3db4f69388..6dbf9b348709 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -970,7 +970,7 @@ bool ControlList::contains(unsigned int id) const */ /** - * \fn ControlList::set(const Control &ctrl, const std::initializer_list &value) + * \fn ControlList::set(const Control> &ctrl, const std::initializer_list &value) * \copydoc ControlList::set(const Control &ctrl, const V &value) */ From patchwork Thu Oct 6 23:07:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17559 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 0278CBD16B for ; Thu, 6 Oct 2022 23:08:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A7A9C62D15; Fri, 7 Oct 2022 01:08:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665097682; bh=wPRX9qYEUtVsq1h35g13Cuk4X6YvkP3ZOA1nlRHv5sI=; 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=N75PBoz24Ox6x/oXaBaAIblDOMpssRhXxM8POhbic8hsBjmrM0Dlb9W7aOQ24x3np QwdIqOXcqytHKTx74dO803jf7H4CBe4yXEYFzU2dQeDyWpIA/2JArNlNFwsy506/Kw QMpvXCeBThMh56e9gVszKkSylIP2sxIpbQeQPdzAtnC5SW2YUU4sdk1R8zGHvKD6IY vgKiCh1Kdbcxz11qdSFqXaJDU0nYNIhjJo7qmGwjm4hhet5jbn97sSyqvRjG88CH7y qMlZB4grO9YXZtLPAECo2cmWNGd5Z+zbmWKbAkd8sGV0VVTFQeuoOQvFhnKpMpyD23 DLCYSw0BNclrg== 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 2AE2562D12 for ; Fri, 7 Oct 2022 01:08:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BbvTtrnv"; 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 A51B16D6; Fri, 7 Oct 2022 01:08:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665097680; bh=wPRX9qYEUtVsq1h35g13Cuk4X6YvkP3ZOA1nlRHv5sI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BbvTtrnvkvtpvJy5D6TUbnTTkAdc3ICL8HQT8nRhQIf/CAMAcsrYrVwnL/xFW3JvD u26BwyLUhOo9eLQI0/SgZ/9aiMo/Y5U6dh/kbEUOJ8FuFXhzoE9nmbxlHD4EMbOeNg R5Fp0OIM2OrVlUOPkmAWlQ/dOaDTIgAkadq3hIa0= To: libcamera-devel@lists.libcamera.org Date: Fri, 7 Oct 2022 02:07:47 +0300 Message-Id: <20221006230747.11688-5-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 4/4] ipa: raspberrypi: Remove unneeded Span casts 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" Commit 09c1b081baa2 ("libcamera: controls: Generate and use fixed-sized Span types") added explicit Span casts for fixed extent spans that were required due to the ControlList::set() function that takes an std::initializer_list not being able to infer a control size from template arguments. This has now been fixed, so the casts are not needed anymore. Drop them. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Christian Rauch Reviewed-by: Umang Jain --- src/ipa/raspberrypi/raspberrypi.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 8d731435764e..14b06a4feae6 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -566,19 +566,18 @@ void IPARPi::reportMetadata() AwbStatus *awbStatus = rpiMetadata_.getLocked("awb.status"); if (awbStatus) { - libcameraMetadata_.set(controls::ColourGains, - Span({ static_cast(awbStatus->gainR), - static_cast(awbStatus->gainB) })); + libcameraMetadata_.set(controls::ColourGains, { static_cast(awbStatus->gainR), + static_cast(awbStatus->gainB) }); libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperatureK); } BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked("black_level.status"); if (blackLevelStatus) libcameraMetadata_.set(controls::SensorBlackLevels, - Span({ static_cast(blackLevelStatus->blackLevelR), - static_cast(blackLevelStatus->blackLevelG), - static_cast(blackLevelStatus->blackLevelG), - static_cast(blackLevelStatus->blackLevelB) })); + { static_cast(blackLevelStatus->blackLevelR), + static_cast(blackLevelStatus->blackLevelG), + static_cast(blackLevelStatus->blackLevelG), + static_cast(blackLevelStatus->blackLevelB) }); FocusStatus *focusStatus = rpiMetadata_.getLocked("focus.status"); if (focusStatus && focusStatus->num == 12) { @@ -883,7 +882,7 @@ void IPARPi::queueRequest(const ControlList &controls) if (gains[0] != 0.0f && gains[1] != 0.0f) /* A gain of 0.0f will switch back to auto mode. */ libcameraMetadata_.set(controls::ColourGains, - Span({ gains[0], gains[1] })); + { gains[0], gains[1] }); break; } @@ -1167,8 +1166,8 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur /* Return the validated limits via metadata. */ libcameraMetadata_.set(controls::FrameDurationLimits, - Span({ static_cast(minFrameDuration_.get()), - static_cast(maxFrameDuration_.get()) })); + { static_cast(minFrameDuration_.get()), + static_cast(maxFrameDuration_.get()) }); /* * Calculate the maximum exposure time possible for the AGC to use.