From patchwork Thu May 19 10:33:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15983 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 E69D7C3256 for ; Thu, 19 May 2022 10:34:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 463C265665; Thu, 19 May 2022 12:34:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652956450; bh=dIiYL3KTgx4EUsgCx3rVpJoYWdQ920dbKt/mp9HKuyE=; 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=f2ONrpb+9wfPKbfmkfoj/whBdb2BS9JYADhW84sifP6QTRdCSpIRH9pAz2flzw/+e p/XiHsZANi0KnOF5C64UTCM0I+2kYmcF6xZqs3ra+JgP1BSvfjt+70sZ5HGJDMeLNM L5BH73RhfBTm42sugXzlFuq213PWmKwZlKDsIcqSpry8Yy+zdQkV6z+s+tSAokIXnd DXhrr+MQnYqbNSCf7VWIuzLQptVmVI9HRx6hElJvt6X3bgZqezcATxdoMSXlb+SDLM zRXYeMjNPjR3vJu2HS3Dad1nd9qOBC34ayuQ1sz8gJ4DM/N6bbZiICHzQ19B1Smpqb bTuD9YH5IkbLg== 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 3499265661 for ; Thu, 19 May 2022 12:34:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P5/vTQJi"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6D748E50; Thu, 19 May 2022 12:34:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652956446; bh=dIiYL3KTgx4EUsgCx3rVpJoYWdQ920dbKt/mp9HKuyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5/vTQJitR550KxqXSm0noFUBth1gzNiOrmrCFy1gFU6VxsuPA0UHydidX2ch/BWD x5aECsoG66p5QxhJxZtP/LzxpMuNIf+1YNXDxvyE2gE5wM1cNO8ukrGuPsmf3CapKd TWQrDJym7JalxoWPG9eEUlmjdOqkzt6hOY1R651c= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 19 May 2022 13:33:43 +0300 Message-Id: <20220519103347.33295-2-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> References: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] py: Generate pixel formats list 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Generate a list of pixel formats under 'libcamera.formats'. The 'formats' is a "dummy" container class, the only purpose of which is to contain the read-only pixel format properties. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- src/py/libcamera/gen-py-formats.py | 56 ++++++++++++++++++++ src/py/libcamera/meson.build | 12 +++++ src/py/libcamera/py_formats_generated.cpp.in | 23 ++++++++ src/py/libcamera/py_main.cpp | 3 ++ 4 files changed, 94 insertions(+) create mode 100755 src/py/libcamera/gen-py-formats.py create mode 100644 src/py/libcamera/py_formats_generated.cpp.in diff --git a/src/py/libcamera/gen-py-formats.py b/src/py/libcamera/gen-py-formats.py new file mode 100755 index 00000000..0ff1d12a --- /dev/null +++ b/src/py/libcamera/gen-py-formats.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Generate Python format definitions from YAML + +import argparse +import string +import sys +import yaml + + +def generate(formats): + fmts = [] + + for format in formats: + name, format = format.popitem() + fmts.append(f'\t\t.def_readonly_static("{name}", &libcamera::formats::{name})') + + return {'formats': '\n'.join(fmts)} + + +def fill_template(template, data): + with open(template, encoding='utf-8') as f: + template = f.read() + + template = string.Template(template) + return template.substitute(data) + + +def main(argv): + parser = argparse.ArgumentParser() + parser.add_argument('-o', dest='output', metavar='file', type=str, + help='Output file name. Defaults to standard output if not specified.') + parser.add_argument('input', type=str, + help='Input file name.') + parser.add_argument('template', type=str, + help='Template file name.') + args = parser.parse_args(argv[1:]) + + with open(args.input, encoding='utf-8') as f: + formats = yaml.safe_load(f)['formats'] + + data = generate(formats) + data = fill_template(args.template, data) + + if args.output: + with open(args.output, 'w', encoding='utf-8') as f: + f.write(data) + else: + sys.stdout.write(data) + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build index a3388c63..0a7b65f3 100644 --- a/src/py/libcamera/meson.build +++ b/src/py/libcamera/meson.build @@ -30,6 +30,18 @@ pycamera_sources += custom_target('py_gen_controls', output : ['py_control_enums_generated.cpp'], command : [gen_py_control_enums, '-o', '@OUTPUT@', '@INPUT@']) +gen_py_formats_input_files = files([ + '../../libcamera/formats.yaml', + 'py_formats_generated.cpp.in', +]) + +gen_py_formats = files('gen-py-formats.py') + +pycamera_sources += custom_target('py_gen_formats', + input : gen_py_formats_input_files, + output : ['py_formats_generated.cpp'], + command : [gen_py_formats, '-o', '@OUTPUT@', '@INPUT@']) + pycamera_deps = [ libcamera_public, py3_dep, diff --git a/src/py/libcamera/py_formats_generated.cpp.in b/src/py/libcamera/py_formats_generated.cpp.in new file mode 100644 index 00000000..5824966f --- /dev/null +++ b/src/py/libcamera/py_formats_generated.cpp.in @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Tomi Valkeinen + * + * Python bindings - Auto-generated formats + * + * This file is auto-generated. Do not edit. + */ + +#include + +#include + +namespace py = pybind11; + +class PyFormats {}; + +void init_py_formats_generated(py::module& m) +{ + py::class_(m, "formats") +${formats} + ; +} diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 1d941160..e7066841 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -132,6 +132,7 @@ static void handleRequestCompleted(Request *req) void init_py_enums(py::module &m); void init_py_control_enums_generated(py::module &m); +void init_py_formats_generated(py::module &m); void init_py_geometry(py::module &m); PYBIND11_MODULE(_libcamera, m) @@ -171,6 +172,8 @@ PYBIND11_MODULE(_libcamera, m) auto pyColorSpaceRange = py::enum_(pyColorSpace, "Range"); auto pyPixelFormat = py::class_(m, "PixelFormat"); + init_py_formats_generated(m); + /* Global functions */ m.def("log_set_level", &logSetLevel); From patchwork Thu May 19 10:33:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15984 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 424AAC3256 for ; Thu, 19 May 2022 10:34:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BE44F65666; Thu, 19 May 2022 12:34:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652956450; bh=u2tqjxRj2OwecQxi/1sS9LWYVbQZr9S9oBztjV3FNyo=; 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=vbXGESsmRvka4LQ7pQmUA+cb/79elwwcEOo/jhDUItlbhr6MpNdXyQw11kbcrE+uZ bEq3yt2drjPJAxgrfQIsP8OnlAeGFDxOWqmuzEFt/gTBh8VocvYN8PyEtR6XcSy1Cl usKb/uk785QAzWljqxL8w7FPENaTZR2STI3YkZetTyfCAMnP/9KIWb+xM+hKGk2/N7 L3/A0u1jkN4SoXtgAiI3NHacR1SguoJT7lSGKCHFLweYBOYZy2161TSXf7qX2EYCbI t3NRaySAG9ZuqGBPNYhG4w6fDD8carh9yxLNprBfgl4zLKc2wD+3YZNLj0sfnxxSXY Qe+QUqGR06Veg== 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 732CB60420 for ; Thu, 19 May 2022 12:34:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FxU9Nlhy"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E6FCCE52; Thu, 19 May 2022 12:34:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652956447; bh=u2tqjxRj2OwecQxi/1sS9LWYVbQZr9S9oBztjV3FNyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxU9Nlhyif6fScc2VuT34ri5rf1fbE1OFrN16M8ipSbWBNxoHeYWN1PVn4GF1WVoN UfZv4vfqA0aV0J7Qgxtt4rw4V9d9RHic38ibUta8Mgw4NHFedeukTGyZbheHKw4VT5 r7WX8pAraW4oIJLKmXBuX/Bj34ux2TY04VRw0kFI= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 19 May 2022 13:33:44 +0300 Message-Id: <20220519103347.33295-3-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> References: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] py: cam_qt: Use libcamera.formats 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the new libcamera.formats in cam_qt.py. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/py/cam/cam_qt.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py index 91be2a08..0a25a823 100644 --- a/src/py/cam/cam_qt.py +++ b/src/py/cam/cam_qt.py @@ -8,6 +8,7 @@ from numpy.lib.stride_tricks import as_strided from PIL import Image from PIL.ImageQt import ImageQt from PyQt5 import QtCore, QtGui, QtWidgets +import libcamera as libcam import numpy as np import sys @@ -87,9 +88,7 @@ def to_rgb(fmt, size, data): w = size.width h = size.height - fmt = str(fmt) - - if fmt == 'YUYV': + if fmt == libcam.formats.YUYV: # YUV422 yuyv = data.reshape((h, w // 2 * 4)) @@ -111,20 +110,21 @@ def to_rgb(fmt, size, data): rgb[:, :, 2] -= 226.8183044444304 rgb = rgb.astype(np.uint8) - elif fmt == 'RGB888': + elif fmt == libcam.formats.RGB888: rgb = data.reshape((h, w, 3)) rgb[:, :, [0, 1, 2]] = rgb[:, :, [2, 1, 0]] - elif fmt == 'BGR888': + elif fmt == libcam.formats.BGR888: rgb = data.reshape((h, w, 3)) - elif fmt in ['ARGB8888', 'XRGB8888']: + elif fmt in [libcam.formats.ARGB8888, libcam.formats.XRGB8888]: rgb = data.reshape((h, w, 4)) rgb = np.flip(rgb, axis=2) # drop alpha component rgb = np.delete(rgb, np.s_[0::4], axis=2) - elif fmt.startswith('S'): + elif str(fmt).startswith('S'): + fmt = str(fmt) bayer_pattern = fmt[1:5] bitspp = int(fmt[5:]) @@ -296,7 +296,7 @@ class MainWindow(QtWidgets.QWidget): h = cfg.size.height pitch = cfg.stride - if str(cfg.pixel_format) == 'MJPEG': + if cfg.pixel_format == libcam.formats.MJPEG: img = Image.open(BytesIO(mfb.planes[0])) qim = ImageQt(img).copy() pix = QtGui.QPixmap.fromImage(qim) From patchwork Thu May 19 10:33:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15985 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 A5421C326C for ; Thu, 19 May 2022 10:34:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1C64E65667; Thu, 19 May 2022 12:34:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652956451; bh=K0Zv9bI44iCQj0lfB8y7MwuuVF7GVni5p82HCXe4F9I=; 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=yudXtiWLSxVvWfs0yZDNJuKnyl2PFihBZ7erPXUZ8AXPUuKa5XiSwGb/ex3JK5ZQB 21tiW7RHY4dofzLI6n7uEnJdQSU9xYJUz8ampx42vwzw1DcQUVfVNH2Nmgsxw6REbb vxXcMAEtzOnvNif6KvbLFgEY2C7vh2sUkf7AZ43bQzR1evw40nRa9KN2vC2OgbNbEj QLJHQixar8gV4XotdWUAhAwo61qWvDDdV6YFYJgVRiAyLxvOV8bfLRBQ3FdWNpkQ9u vjwP4kQiNMfkdX+6CfJB654fdXpdWyDnOQf321VUyu9Fp0dDSn2fn5DBmglojgXm27 0LPelGq94ranQ== 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 F40EC60420 for ; Thu, 19 May 2022 12:34:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gm79lZly"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6E64CE53; Thu, 19 May 2022 12:34:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652956447; bh=K0Zv9bI44iCQj0lfB8y7MwuuVF7GVni5p82HCXe4F9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gm79lZly/UAqe/C+fhBIH1QLanc5777Sa8biqyD0S0/H1PQu8yXOyi8QFRyCb6rAu PjDtJpeS3ElfJNybb/jcNSizVKMhogcw1jsA2KS1bfBcSsXbmV5rDZzfEDFIl/9oK9 FX1ERP9cNOIOAM4IngFJDw+o+Mr7y0dgS2Bt4+oQ= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 19 May 2022 13:33:45 +0300 Message-Id: <20220519103347.33295-4-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> References: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] py: cam: Cleanups 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" No functional changes. Drop unused variables, reduce typechecker warnings. Signed-off-by: Tomi Valkeinen --- src/py/cam/cam.py | 2 +- src/py/cam/cam_qt.py | 13 ++----------- src/py/cam/cam_qtgl.py | 9 ++------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index 2f0690b5..e2bc78da 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -304,7 +304,7 @@ def event_handler(state): running = any(ctx['reqs-completed'] < ctx['opt-capture'] for ctx in contexts) return running - except Exception as e: + except Exception: traceback.print_exc() return False diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py index 0a25a823..8dc6f92e 100644 --- a/src/py/cam/cam_qt.py +++ b/src/py/cam/cam_qt.py @@ -184,14 +184,8 @@ class QtRenderer: windows = [] for ctx in self.contexts: - camera = ctx['camera'] - for stream in ctx['streams']: - fmt = stream.configuration.pixel_format - size = stream.configuration.size - window = MainWindow(ctx, stream) - window.setAttribute(QtCore.Qt.WA_ShowWithoutActivating) window.show() windows.append(window) @@ -199,10 +193,10 @@ class QtRenderer: def run(self): camnotif = QtCore.QSocketNotifier(self.cm.efd, QtCore.QSocketNotifier.Read) - camnotif.activated.connect(lambda x: self.readcam()) + camnotif.activated.connect(lambda _: self.readcam()) keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read) - keynotif.activated.connect(lambda x: self.readkey()) + keynotif.activated.connect(lambda _: self.readkey()) print('Capturing...') @@ -292,9 +286,6 @@ class MainWindow(QtWidgets.QWidget): def buf_to_qpixmap(self, stream, fb): with fb.mmap() as mfb: cfg = stream.configuration - w = cfg.size.width - h = cfg.size.height - pitch = cfg.stride if cfg.pixel_format == libcam.formats.MJPEG: img = Image.open(BytesIO(mfb.planes[0])) diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py index 4bbcda6c..3fb7dde3 100644 --- a/src/py/cam/cam_qtgl.py +++ b/src/py/cam/cam_qtgl.py @@ -5,16 +5,11 @@ from PyQt5 import QtCore, QtWidgets from PyQt5.QtCore import Qt import math -import numpy as np import os import sys os.environ['PYOPENGL_PLATFORM'] = 'egl' -import OpenGL -# OpenGL.FULL_LOGGING = True - -from OpenGL import GL as gl from OpenGL.EGL.EXT.image_dma_buf_import import * from OpenGL.EGL.KHR.image import * from OpenGL.EGL.VERSION.EGL_1_0 import * @@ -149,10 +144,10 @@ class QtRenderer: def run(self): camnotif = QtCore.QSocketNotifier(self.state['cm'].efd, QtCore.QSocketNotifier.Read) - camnotif.activated.connect(lambda x: self.readcam()) + camnotif.activated.connect(lambda _: self.readcam()) keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read) - keynotif.activated.connect(lambda x: self.readkey()) + keynotif.activated.connect(lambda _: self.readkey()) print('Capturing...') From patchwork Thu May 19 10:33:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15986 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 24C09C326D for ; Thu, 19 May 2022 10:34:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19DFB6566B; Thu, 19 May 2022 12:34:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652956452; bh=S/RVNlIlL/i+4loRKEAVUW+1XNEtUENfvOvlbekWDYg=; 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=Gsp2mVygVGiKtnI3FneVrQMRYGkR15WIj9GekcK/z0yaqMnoEPN9F2sXwK5X4NIws zyBqPrhfa2EV0tX4P/YJ9CkUEn3Rn30Di6sLiq9ZGTfPeI6sYI7z+CEbvbaqsrt9C+ qEkwHIjw86pJbl3DlN0Dw0H+8huw4KD4ABgVnpf0n/dT9fqUeAhdUwK904eC0peVqg IhFm2NDZtj4uf8QGWu9KPcLIlsG6gZbzT69Ubw/xjckP3/lngF3DM1vOEdOgftCTs2 6X0aa7N/m5ydjUh6pz+pv/lOxTkT4mJ7ff9yQO8sf62vZ9KfFTS+SwS19lDBxmf921 Z0hv+3yB4XZLA== 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 7612D60420 for ; Thu, 19 May 2022 12:34:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P4x+HBgr"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E975410CC; Thu, 19 May 2022 12:34:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652956448; bh=S/RVNlIlL/i+4loRKEAVUW+1XNEtUENfvOvlbekWDYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4x+HBgrXdSLHQgcv1nHegEnmJRFksVeIYjrFYdzFtJI/g2LaxpBOXVbT2GCx5C+O aSrRj3F3/DOXVNQvvTqhqLK124+RrRGYj+qZhnkjHz+BX2+pYpfoL/NiDzK+G13YeT 2AGTUBY3Qlrr+CxZyFEbV6G2Fed72HuIBRfyeMrg= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 19 May 2022 13:33:46 +0300 Message-Id: <20220519103347.33295-5-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> References: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] py: Fix SceneFlicker enum values 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Stripping 'SceneFlicker' prefix from the enum value names leads to '50Hz' and '60Hz', which are not valid names. So add another heuristics to keep the prefix for SceneFlicker. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- src/py/libcamera/gen-py-control-enums.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/py/libcamera/gen-py-control-enums.py b/src/py/libcamera/gen-py-control-enums.py index dcc28b1a..6b2b5362 100755 --- a/src/py/libcamera/gen-py-control-enums.py +++ b/src/py/libcamera/gen-py-control-enums.py @@ -42,6 +42,9 @@ def generate_py(controls): if name == 'LensShadingMapMode': prefix = 'LensShadingMapMode' + elif name == 'SceneFlicker': + # If we strip the prefix, we would get '50Hz', which is illegal name + prefix = '' else: prefix = find_common_prefix([e['name'] for e in enum]) From patchwork Thu May 19 10:33:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15987 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 9A341C326E for ; Thu, 19 May 2022 10:34:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14BD765672; Thu, 19 May 2022 12:34:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652956454; bh=A/SKTe1eyVCsX8wYDwzaM1C1mySX39BKFloflu1ogp0=; 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=Z4uPmDtT5fTWqaKU3b8PUxoZYF62BNsUjsapmsb+i/hSlmlKoHnQ8cQi9bmFWl40O l+QZ840QowgchOE8BjN13SC5aeW/eGkRPO8rBV5iK2xtiynTNh37GO0+wRIoU1/5H4 KTTI4OSCIENPaQgnBdcFA51LAJ/gE/QTshLn+wOGeyyjBc1Qh0CTisZwOC07vOIttK WVUIX8gTAZvT3sZBCpTAC3mg2cIZ/g7YaX6m9Gma1xed1q2pV2BMbIXfxNfBVbtotQ U4cBudRtGmU/RI4ZOKKmdiQuAoMh9rYSsDIaZWwWDh53OnuP2OlXd3gy7kGNhkriCo H8PVyk1xco61g== 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 12B4E60420 for ; Thu, 19 May 2022 12:34:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="No8c5qhm"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7299C119F; Thu, 19 May 2022 12:34:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652956448; bh=A/SKTe1eyVCsX8wYDwzaM1C1mySX39BKFloflu1ogp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=No8c5qhmjzujd2sPCYXHrfm0KruPA9F6o9oarhY4VJMvekr47ckuRbrd4qZbwkY1W A7JoVWeI8jO/fW6KbJB1GjKKbWfoYZNcbS43r4+YRoITZfnsCQPHY7/4bQAs5uHCbe jwFxk5Yg+GItXifP3GxvE7JISkvn9LL8XVhDCSec= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Thu, 19 May 2022 13:33:47 +0300 Message-Id: <20220519103347.33295-6-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> References: <20220519103347.33295-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] py: Fix None value in ControlType enum 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" "None" is not a valid name for an enum value, so change it to "Null". Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- src/py/libcamera/py_enums.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/libcamera/py_enums.cpp b/src/py/libcamera/py_enums.cpp index e55318f1..96d4beef 100644 --- a/src/py/libcamera/py_enums.cpp +++ b/src/py/libcamera/py_enums.cpp @@ -22,7 +22,7 @@ void init_py_enums(py::module &m) .value("Viewfinder", StreamRole::Viewfinder); py::enum_(m, "ControlType") - .value("None", ControlType::ControlTypeNone) + .value("Null", ControlType::ControlTypeNone) .value("Bool", ControlType::ControlTypeBool) .value("Byte", ControlType::ControlTypeByte) .value("Integer32", ControlType::ControlTypeInteger32)