From patchwork Wed Oct 7 18:57:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10018 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 4590CBEEDF for ; Wed, 7 Oct 2020 18:57:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AB09E605C6; Wed, 7 Oct 2020 20:57:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rr3jHWcC"; dkim-atps=neutral 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 DD18B605A8 for ; Wed, 7 Oct 2020 20:57:25 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 66EC19E7; Wed, 7 Oct 2020 20:57:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1602097045; bh=u2fU2HC4YTkKFi6T2l4TRCZzc/yognLx/0Z4c7D8SGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rr3jHWcCrhEf29ZPzZfAkJmumRBYhX4deGISVpuPGxPGyrZtMFB+aEgfT6Twy3NoM pg2XpSS42cm0b44fKREVNVsDpPBaO/iBxmKDIUhDL+/YPXgFD6Nn31Txg2OQWYQlC2 c77x2A0kXXJoY25pYghIXZ1Y2q0de3ju8GpvSq+4= From: Kieran Bingham To: libcamera devel Date: Wed, 7 Oct 2020 19:57:18 +0100 Message-Id: <20201007185719.3208272-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201007185719.3208272-1-kieran.bingham@ideasonboard.com> References: <20200911162039.61933-1-jacopo@jmondi.org> <20201007185719.3208272-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] properties: Support draft controls and properties 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" Extend the control and property framework to support exposing draft controls and properties in a scoped namespace. The controls/properties themselves will retain the same ordering in the relevant enum/id maps - but the access to any draft control will require explicitly referencing through its' draft:: namespace prefix. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- include/libcamera/control_ids.h.in | 6 +++++ include/libcamera/property_ids.h.in | 6 +++++ src/libcamera/property_ids.cpp.in | 13 +++++++++++ utils/gen-controls.py | 36 ++++++++++++++++++++++------- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in index 95a7a7f1e260..baadca83b103 100644 --- a/include/libcamera/control_ids.h.in +++ b/include/libcamera/control_ids.h.in @@ -26,6 +26,12 @@ ${controls} extern const ControlIdMap controls; +namespace draft { + +${draft_controls} + +} /* namespace draft */ + } /* namespace controls */ } /* namespace libcamera */ diff --git a/include/libcamera/property_ids.h.in b/include/libcamera/property_ids.h.in index e4dea335cd3b..52646c1f78ae 100644 --- a/include/libcamera/property_ids.h.in +++ b/include/libcamera/property_ids.h.in @@ -24,6 +24,12 @@ ${ids} ${controls} +namespace draft { + +${draft_controls} + +} /* namespace draft */ + extern const ControlIdMap properties; } /* namespace properties */ diff --git a/src/libcamera/property_ids.cpp.in b/src/libcamera/property_ids.cpp.in index bfdd823f63b0..275c1caff3ec 100644 --- a/src/libcamera/property_ids.cpp.in +++ b/src/libcamera/property_ids.cpp.in @@ -23,12 +23,25 @@ namespace properties { ${controls_doc} +namespace draft { + +${draft_controls_doc} + +} /* namespace draft */ + #ifndef __DOXYGEN__ /* * Keep the properties definitions hidden from doxygen as it incorrectly parses * them as functions. */ ${controls_def} + +namespace draft { + +${draft_controls_def} + +} /* namespace draft */ + #endif /** diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 87c3d52ada6d..f28db27ba19f 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -36,6 +36,8 @@ ${description} ctrls_doc = [] ctrls_def = [] + draft_ctrls_doc = [] + draft_ctrls_def = [] ctrls_map = [] for ctrl in controls: @@ -55,6 +57,12 @@ ${description} 'id_name': id_name, } + target_doc = ctrls_doc + target_def = ctrls_def + if ctrl.get('draft'): + target_doc = draft_ctrls_doc + target_def = draft_ctrls_def + enum = ctrl.get('enum') if enum: enum_doc = [] @@ -70,15 +78,21 @@ ${description} enum_doc = '\n *\n'.join(enum_doc) enum_doc += '\n */' - ctrls_doc.append(enum_doc) + target_doc.append(enum_doc) + + target_doc.append(doc_template.substitute(info)) + target_def.append(def_template.substitute(info)) + + if ctrl.get('draft'): + name = 'draft::' + name - ctrls_doc.append(doc_template.substitute(info)) - ctrls_def.append(def_template.substitute(info)) ctrls_map.append('\t{ ' + id_name + ', &' + name + ' },') return { 'controls_doc': '\n\n'.join(ctrls_doc), 'controls_def': '\n'.join(ctrls_def), + 'draft_controls_doc': '\n\n'.join(draft_ctrls_doc), + 'draft_controls_def': '\n\n'.join(draft_ctrls_def), 'controls_map': '\n'.join(ctrls_map), } @@ -89,6 +103,7 @@ def generate_h(controls): template = string.Template('''extern const Control<${type}> ${name};''') ctrls = [] + draft_ctrls = [] ids = [] id_value = 1 @@ -109,22 +124,27 @@ def generate_h(controls): 'type': ctrl_type, } + target_ctrls = ctrls + if ctrl.get('draft'): + target_ctrls = draft_ctrls + enum = ctrl.get('enum') if enum: - ctrls.append(enum_template_start.substitute(info)) + target_ctrls.append(enum_template_start.substitute(info)) for entry in enum: value_info = { 'name': entry['name'], 'value': entry['value'], } - ctrls.append(enum_value_template.substitute(value_info)) - ctrls.append("};") + target_ctrls.append(enum_value_template.substitute(value_info)) + target_ctrls.append("};") - ctrls.append(template.substitute(info)) + target_ctrls.append(template.substitute(info)) id_value += 1 - return {'ids': '\n'.join(ids), 'controls': '\n'.join(ctrls)} + return {'ids': '\n'.join(ids), 'controls': '\n'.join(ctrls), + 'draft_controls': '\n'.join(draft_ctrls)} def fill_template(template, data): From patchwork Wed Oct 7 18:57:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10019 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 30F2BBEEDF for ; Wed, 7 Oct 2020 18:57:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F00B3605AF; Wed, 7 Oct 2020 20:57:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XskCyXrR"; dkim-atps=neutral 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 40E9A605A8 for ; Wed, 7 Oct 2020 20:57:26 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C506FA08; Wed, 7 Oct 2020 20:57:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1602097046; bh=uaMmk/7AafdplmO8uRLp0DAPjFzTNL2BkU25iHwc/hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XskCyXrR18pMGzRXOhniOa2ycE9i4grluNumQEIlyIN8KVx2L+hoEnwfKr2cUfdZI NRPginqtICWORBafZNNZ5STef9jR3tWyvgs2+6ZHiD8UGbFlsuDFYqlBDGMRDPevcw oxVbo2drEaqYDswd7fG5f7eI0Do6Yz8HfZFZt/lY= From: Kieran Bingham To: libcamera devel Date: Wed, 7 Oct 2020 19:57:19 +0100 Message-Id: <20201007185719.3208272-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201007185719.3208272-1-kieran.bingham@ideasonboard.com> References: <20200911162039.61933-1-jacopo@jmondi.org> <20201007185719.3208272-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] DNI: How to use a draft control 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" This just shows how the draft state can be used on a control or property. Expressing a draft key on the property_ids or control_ids yaml descriptions will automatically move the entrys to the draft namespace. --- src/libcamera/camera_sensor.cpp | 2 +- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/property_ids.yaml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 78c7ceec7c44..4e899d180d95 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -249,7 +249,7 @@ int CameraSensor::init() propertyValue = rotationControl->second.def().get(); else propertyValue = 0; - properties_.set(properties::Rotation, propertyValue); + properties_.set(properties::draft::Rotation, propertyValue); /* Enumerate, sort and cache media bus codes and sizes. */ formats_ = subdev_->formats(pad_); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 26dbd2573e04..c1468178f163 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -270,7 +270,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * error means the platform can never run. Let's just print a warning * and continue regardless; the rotation is effectively set to zero. */ - int32_t rotation = data_->sensor_->properties().get(properties::Rotation); + int32_t rotation = data_->sensor_->properties().get(properties::draft::Rotation); bool success; Transform rotationTransform = transformFromRotation(rotation, &success); if (!success) diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 7261263a9ba3..e3400cc9d469 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -28,6 +28,7 @@ controls: - Rotation: type: int32_t + draft: true description: | The camera rotation is expressed as the angular difference in degrees between two reference systems, one relative to the camera module, and