From patchwork Mon Nov 23 16:43:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10471 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 5E549BE08A for ; Mon, 23 Nov 2020 16:44:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D0822633F4; Mon, 23 Nov 2020 17:44:58 +0100 (CET) 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="iDuoHs8T"; 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 2D4E7631D0 for ; Mon, 23 Nov 2020 17:44:58 +0100 (CET) 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 9C7A171; Mon, 23 Nov 2020 17:44:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149897; bh=AZIPJgI//FwvVMTdAorcRFS6xZjo4BESd/6WAKRgIbY=; h=From:To:Cc:Subject:Date:From; b=iDuoHs8Twj6XtieCGzmNe1KlZf8UIoRiNswt58JosTsdBYGsu2TkOb/de7RZsIW+X Eh7QZq7CRbmpE54/DDNmS2hAPgYArmqi3lkKWF3FMdh1pnXlYZF2uydHlgidbGPaUs m7dmZZjqp79X1PRBv1SZE2cgn89N7pnfE7dh/V1g= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:11 +0000 Message-Id: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 0/8] Configuration files and parsing 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" A preliminary posting of a series which allows me to parse controls on a CameraSensor from a json file which overrides the location and rotation properties. For example, creating a camera_sensor.json file within the libcamera sysconf paths, with the following content can manually set the properties: pi@mercury:~/libcamera $ cat /usr/local/etc/libcamera/camera_sensor.json { "/base/soc/i2c0mux/i2c@1/imx219@10": { "properties": { "Rotation" : 270, "Location" : 0 } } } This implementation exposes the nlohmann json library to libcamera internals rather than wrapping it and re-encoding a generic any-type into another type. The series starts out by cleaning up our meson files to easily obtain and parse the system paths from our config.h and cleans up the IPA meson to re-use those new variables. The Configuration class instance itself is really only about finding and parsing the configuration files, and how the data is parsed is up to the internal code that needs to use the files. Kieran Bingham (8): meson: Simplify pkg_mod.generate src: meson: Re-order subdir layout src: meson: Simplify v4l2 enablement src: meson: Define system paths src: ipa: meson: Re-use existing system paths libcamera: Add configuration interface test: Add configuration parser tests libcamera: camera_sensor: Parse configuration properties README.rst | 2 +- include/libcamera/internal/camera_sensor.h | 1 + include/libcamera/internal/configuration.h | 37 ++++++++ meson.build | 3 +- src/ipa/meson.build | 16 ++-- src/libcamera/camera_sensor.cpp | 50 ++++++++++ src/libcamera/configuration.cpp | 91 ++++++++++++++++++ src/libcamera/meson.build | 1 + src/meson.build | 23 ++++- src/v4l2/meson.build | 4 + test/configuration.cpp | 105 +++++++++++++++++++++ test/data/test_configuration.json | 15 +++ test/data/unparsable.json | 7 ++ test/meson.build | 1 + 14 files changed, 339 insertions(+), 17 deletions(-) create mode 100644 include/libcamera/internal/configuration.h create mode 100644 src/libcamera/configuration.cpp create mode 100644 test/configuration.cpp create mode 100644 test/data/test_configuration.json create mode 100644 test/data/unparsable.json