From patchwork Mon Nov 23 16:43:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10472 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 8D19CBE08A for ; Mon, 23 Nov 2020 16:45:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 37C9B633F1; Mon, 23 Nov 2020 17:45:01 +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="rwdZZcdC"; 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 630D7633F0 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 E8F085A6; 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=1606149898; bh=eGOD0ERkSrh+rYDXGtunSC0Hk4IjYH8e1eCj+Keasd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rwdZZcdCSciVnptjnaLtqP1z2+PF5zW6K+PYdUDnVQ/w7sZ3DHcRNNcAR91d+tFHc LAqnsOGFfZI9qbBSnJ3eLO2L/V9U2IfpO6uRnSZs97Owf9qAGkvECTX4aHNg92LuHD AI4zUogeh1wUbQg88iAVArYZTDlZPHl6ucZwJVIM= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:12 +0000 Message-Id: <20201123164319.152742-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/8] meson: Simplify pkg_mod.generate 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" Later versions of meson allow for the first positional argument to specificy the defaults. Specify the libcamera library as the first argument, and remove the filebase. Signed-off-by: Kieran Bingham --- meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 55cf36e15f57..ced4afa7d726 100644 --- a/meson.build +++ b/meson.build @@ -146,10 +146,9 @@ run_command('ln', '-fsT', meson.source_root(), configure_file(output : 'config.h', configuration : config_h) pkg_mod = import('pkgconfig') -pkg_mod.generate(libraries : libcamera, +pkg_mod.generate(libcamera, version : '1.0', name : 'libcamera', - filebase : 'camera', description : 'Complex Camera Support Library', subdirs : 'libcamera') From patchwork Mon Nov 23 16:43:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10473 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 71328BE08A for ; Mon, 23 Nov 2020 16:45:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C6003631D0; Mon, 23 Nov 2020 17:45:01 +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="Dj0E4oie"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DEAD633F1 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 3DE45102C; Mon, 23 Nov 2020 17:44:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149898; bh=pvAcf31Nt7MYCaAl85Z3ZX8dBpKXHlfdLGUf4gf/gCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dj0E4oie0rqpHQfZINp33TCdtV0pneR+g1i+DqzGG+00iS0ng9Ti8cVRWmxYEW/kK 3JR5pjFeE8kKpZgqe1BGZPteraXtHTVdudw0Kh8vN+OMJcmXFvVD3yM8BX3a91/wPp Q7jX2Um1KGCEipvkAdqZ5Q5Erxe9jM5dU5Cb0T5M= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:13 +0000 Message-Id: <20201123164319.152742-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 2/8] src: meson: Re-order subdir layout 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" Move the android subdir below the configuration options to keep all subdirs together. Add a comment explaining why android must come first, and some padding to group the libcamera and ipa components, applications, and remaining adaptation layers. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/meson.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/meson.build b/src/meson.build index b9c7e7599d61..27f70544f1f6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,7 +1,5 @@ # SPDX-License-Identifier: CC0-1.0 -subdir('android') - openssl = find_program('openssl', required : true) if openssl.found() ipa_priv_key = custom_target('ipa-priv-key', @@ -13,8 +11,12 @@ else ipa_sign_module = false endif +# The Android HAL must be built before, and is included in libcamera. +subdir('android') + subdir('libcamera') subdir('ipa') + subdir('cam') subdir('qcam') From patchwork Mon Nov 23 16:43:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10474 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 7658ABE08A for ; Mon, 23 Nov 2020 16:45:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43FCD633FB; Mon, 23 Nov 2020 17:45:03 +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="Q5v1YVDJ"; 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 F0FD0633F6 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 8427871; Mon, 23 Nov 2020 17:44:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149898; bh=aBox++raUvo2sW/mFpOTME+Qelppss6T2peHGVCvfT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5v1YVDJFcRvngap79AqmXdyREGXdLqeb51hu8x6kBE4nYlXl2MwCQY6lg/lqzZcy AuoLCIMTN7Rp96VP6+gAkHKZ/9wRXewt6/LJa+IWZvu5m+RvsdQ05N/Z9lpfD7Km7B wUYOxaLJ6PrFiplbguDUJzrE6oYPudZUKrprF/30= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:14 +0000 Message-Id: <20201123164319.152742-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/8] src: meson: Simplify v4l2 enablement 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" Simplify the src level meson file by moving the declaration of the v4l2 subdir to match the other invocations, making use of 'subdir_done()' to break out if the adaptation layer is not enabled. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/meson.build | 5 +---- src/v4l2/meson.build | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/meson.build b/src/meson.build index 27f70544f1f6..8c7449f9b8a0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -20,8 +20,5 @@ subdir('ipa') subdir('cam') subdir('qcam') -if get_option('v4l2') - subdir('v4l2') -endif - +subdir('v4l2') subdir('gstreamer') diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index e3838f0b07cc..dbe6a424b10e 100644 --- a/src/v4l2/meson.build +++ b/src/v4l2/meson.build @@ -1,5 +1,9 @@ # SPDX-License-Identifier: CC0-1.0 +if not get_option('v4l2') + subdir_done() +endif + v4l2_compat_sources = files([ 'v4l2_camera.cpp', 'v4l2_camera_file.cpp', From patchwork Mon Nov 23 16:43:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10475 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 CBA44BE177 for ; Mon, 23 Nov 2020 16:45:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9BD8563409; Mon, 23 Nov 2020 17:45:03 +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="nZvn1xHV"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E3C0633F1 for ; Mon, 23 Nov 2020 17:44:59 +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 CF2AC5A6; Mon, 23 Nov 2020 17:44:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149899; bh=ZOHjDoQU60vDqYuL/6JJ6hTGM1m3nafvymWqGJnICjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZvn1xHVtVAbWROxVQk1m5qrxEhfBErfBDorfHjCCjGtFUdM0bU0BPx1UFIZDy7Yk G6g0BzhQlGgeDfLUMov1DudGGMuPF255jMmlclttmOoEzBwkkfpHYp/7I0GTYyoUAD IGtgAkDIBmcSpfAghOmUpgGzU00WJ4Yv044SEGeU= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:15 +0000 Message-Id: <20201123164319.152742-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/8] src: meson: Define system paths 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" Define libcamera specific system paths for use within the library code base. These can be used to identify system configuration files and shared data. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/meson.build | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/meson.build b/src/meson.build index 8c7449f9b8a0..b1b3514f6ed7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,17 @@ # SPDX-License-Identifier: CC0-1.0 +# Handle system paths +datadir = get_option('datadir') +prefix = get_option('prefix') +sysconfdir = get_option('sysconfdir') + +libcamera_datadir = datadir / 'libcamera' +libcamera_sysconfdir = sysconfdir / 'libcamera' + +config_h.set('LIBCAMERA_SYSCONF_DIR', '"' + prefix / libcamera_sysconfdir + '"') +config_h.set('LIBCAMERA_DATA_DIR', '"' + prefix / libcamera_datadir + '"') + +# Module Signing openssl = find_program('openssl', required : true) if openssl.found() ipa_priv_key = custom_target('ipa-priv-key', From patchwork Mon Nov 23 16:43:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10476 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 53EC9BE08A for ; Mon, 23 Nov 2020 16:45:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 136BA6340C; Mon, 23 Nov 2020 17:45:04 +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="gumwg+zy"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7872C633F2 for ; Mon, 23 Nov 2020 17:44:59 +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 21DFE71; Mon, 23 Nov 2020 17:44:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149899; bh=Ohi7DMLd0Tf9EdGfdkQfO12SvSLQ1dK/ovx3NnXDAiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gumwg+zyvy2pnConvB6wObTDeZ1K/83CBu6/64cAAOWEACxfYnCKXT9qUUza1d3+Z RQUGWfwn39hNpT+IfR4XJTwWWF+/CIqVSVcpm/hR7/rW1XoHzQr/YmDntLZKeaE9ND LukIVoteZlzUWb+BZr5SAtCaz1vnsfwKwucZ5drM= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:16 +0000 Message-Id: <20201123164319.152742-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 5/8] src: ipa: meson: Re-use existing system paths 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" Make use of the new system path variables and map the ipa paths upon the libcamera system paths. While we're at it, make use of the new shorter syntax for join_paths(). Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/ipa/meson.build | 16 +++++++--------- src/meson.build | 2 ++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ipa/meson.build b/src/ipa/meson.build index 5a5de267c147..c1dc1ce6fa90 100644 --- a/src/ipa/meson.build +++ b/src/ipa/meson.build @@ -1,19 +1,17 @@ # SPDX-License-Identifier: CC0-1.0 -ipa_install_dir = join_paths(get_option('libdir'), 'libcamera') -ipa_data_dir = join_paths(get_option('datadir'), 'libcamera', 'ipa') -ipa_sysconf_dir = join_paths(get_option('sysconfdir'), 'libcamera', 'ipa') - ipa_includes = [ libcamera_includes, ] -config_h.set('IPA_CONFIG_DIR', - '"' + join_paths(get_option('prefix'), ipa_sysconf_dir) + - ':' + join_paths(get_option('prefix'), ipa_data_dir) + '"') +ipa_install_dir = libcamera_libdir +ipa_data_dir = libcamera_datadir / 'ipa' +ipa_sysconf_dir = libcamera_sysconfdir / 'ipa' + +config_h.set('IPA_CONFIG_DIR', '"' + prefix / ipa_sysconf_dir + + ':' + prefix / ipa_data_dir + '"') -config_h.set('IPA_MODULE_DIR', - '"' + join_paths(get_option('prefix'), ipa_install_dir) + '"') +config_h.set('IPA_MODULE_DIR', '"' + prefix / ipa_install_dir + '"') subdir('libipa') diff --git a/src/meson.build b/src/meson.build index b1b3514f6ed7..c7430805fd86 100644 --- a/src/meson.build +++ b/src/meson.build @@ -2,10 +2,12 @@ # Handle system paths datadir = get_option('datadir') +libdir = get_option('libdir') prefix = get_option('prefix') sysconfdir = get_option('sysconfdir') libcamera_datadir = datadir / 'libcamera' +libcamera_libdir = libdir / 'libcamera' libcamera_sysconfdir = sysconfdir / 'libcamera' config_h.set('LIBCAMERA_SYSCONF_DIR', '"' + prefix / libcamera_sysconfdir + '"') From patchwork Mon Nov 23 16:43:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10477 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 CF015BE08A for ; Mon, 23 Nov 2020 16:45:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8AA10633F4; Mon, 23 Nov 2020 17:45:04 +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="OjY/+GI3"; 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 C79C1631D0 for ; Mon, 23 Nov 2020 17:44:59 +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 69307102C; Mon, 23 Nov 2020 17:44:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149899; bh=gdpRi3a4dLxQGyoi6/FJH+ps2csVaqVib9LiQfa6Hj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OjY/+GI3MC4hoDmL9p68kRfLSKnUk6QRR67zBALWwt+kREHLMjL4r5SgprqKDo+55 uZ7fs3HNnYWIDW7VNeUBUgan2NxxoZzXPmTO9iWXGmgdQJ2kbAeBshY14mP5TA9FVO yqP3U70pPd0kkqPUb1ebhevJ6cmfOGhU6A9WwVVU= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:17 +0000 Message-Id: <20201123164319.152742-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 6/8] libcamera: Add configuration interface 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" Provide an interface to support reading configuration files. Initial support is included for JSON formatted files, but extending this with other configuration file formats is not excluded. Signed-off-by: Kieran Bingham --- README.rst | 2 +- include/libcamera/internal/configuration.h | 37 +++++++++ src/libcamera/configuration.cpp | 91 ++++++++++++++++++++++ src/libcamera/meson.build | 1 + 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 include/libcamera/internal/configuration.h create mode 100644 src/libcamera/configuration.cpp diff --git a/README.rst b/README.rst index 251291b77c62..c09e262fcc43 100644 --- a/README.rst +++ b/README.rst @@ -58,7 +58,7 @@ Meson Build system: [required] pip3 install --user --upgrade meson for the libcamera core: [required] - python3-yaml python3-ply python3-jinja2 + python3-yaml python3-ply python3-jinja2 nlohmann-json3-dev for IPA module signing: [required] libgnutls28-dev openssl diff --git a/include/libcamera/internal/configuration.h b/include/libcamera/internal/configuration.h new file mode 100644 index 000000000000..a89732f0210f --- /dev/null +++ b/include/libcamera/internal/configuration.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * configuration.h - Parsing configuration files + */ +#ifndef __LIBCAMERA_INTERNAL_CONFIGURATION_H__ +#define __LIBCAMERA_INTERNAL_CONFIGURATION_H__ + +#include +#include + +/* https://nlohmann.github.io/json/home/exceptions/#switch-off-exceptions */ +#define JSON_NOEXCEPTION 1 +#include + +using json = nlohmann::json; + +namespace libcamera { + +class Configuration +{ +public: + int open(std::string filename); + + json &data() { return json_; } + +private: + std::string findFile(std::string filename); + + json json_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_INTERNAL_CONFIGURATION_H__ */ + diff --git a/src/libcamera/configuration.cpp b/src/libcamera/configuration.cpp new file mode 100644 index 000000000000..f849088bbc45 --- /dev/null +++ b/src/libcamera/configuration.cpp @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * configuration.cpp - Parsing configuration files + */ +#include "libcamera/internal/configuration.h" + +#include "libcamera/internal/file.h" +#include "libcamera/internal/log.h" +#include "libcamera/internal/utils.h" + +#include +#include + +/** + * \file configuration.h + * \brief Read interface for configuration files + */ + +namespace libcamera { + +LOG_DEFINE_CATEGORY(Configuration) + +/* + * Configuration files can be stored in system paths, which are identified + * through the build configuration. + * + * However, when running uninstalled - the source location takes precedence. + */ +std::string Configuration::findFile(std::string filename) +{ + static std::array searchPaths = { + LIBCAMERA_SYSCONF_DIR, + LIBCAMERA_DATA_DIR, + }; + + std::string root = utils::libcameraSourcePath(); + if (!root.empty()) { + std::string configurationPath = root + "data/" + filename; + + if (File::exists(configurationPath)) + return configurationPath; + } + + for (std::string &path : searchPaths) { + std::string configurationPath = path + "/" + filename; + if (File::exists(configurationPath)) + return configurationPath; + } + + return ""; +} + +/** + * \brief Open and parse a configuration file. + * + * The filename will be searched for on the libcamera configuration and paths, + * and then parsed. + * + * Successfully parsed files will present the data contained therein through the + * json object exposed from data(); + */ +int Configuration::open(std::string filename) +{ + std::string data = findFile(filename); + if (data.empty()) { + LOG(Configuration, Warning) + << "file: \"" << filename + << "\" was not found."; + return -ENOENT; + } + + LOG(Configuration, Debug) << "Reading configuration from " << data; + + /* Parse with no error callbacks and exceptions disabled. */ + std::ifstream input(data); + json j = json::parse(input, nullptr, false); + if (j.is_discarded()) { + LOG(Configuration, Error) + << "file: \"" << data + << "\" was not parsable."; + return -EINVAL; + } + + json_ = std::move(j); + + return 0; +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 387d5d88ecae..5d655c87a7a0 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -9,6 +9,7 @@ libcamera_sources = files([ 'camera_controls.cpp', 'camera_manager.cpp', 'camera_sensor.cpp', + 'configuration.cpp', 'controls.cpp', 'control_serializer.cpp', 'control_validator.cpp', From patchwork Mon Nov 23 16:43: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: 10478 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 4FE17BE08A for ; Mon, 23 Nov 2020 16:45:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15E61633F6; Mon, 23 Nov 2020 17:45:05 +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="Fc2CrJSM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E407633F9 for ; Mon, 23 Nov 2020 17:45:00 +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 AFF9171; Mon, 23 Nov 2020 17:44:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149899; bh=AWhmdsy7jYmfQVRscIK7cYnS6iEbSVhlB6iSzv6l2RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fc2CrJSMFXH8cpRvLAVd6QyRwgipzhGxaZs3I4yos4NufH7ZOH8yRNIV2gZJ6Cq/s 90PI8JiH2oMd/JiETM920dL93RPRW3L9N+FC6zC0/4bRWbcRuBXJEyDZrESQhJjmKX okQYqzKjEh7wJvqU2xMwx9IHgvf7qOdOYm6JMY1c= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:18 +0000 Message-Id: <20201123164319.152742-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 7/8] test: Add configuration parser tests 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" Signed-off-by: Kieran Bingham --- test/configuration.cpp | 105 ++++++++++++++++++++++++++++++ test/data/test_configuration.json | 15 +++++ test/data/unparsable.json | 7 ++ test/meson.build | 1 + 4 files changed, 128 insertions(+) create mode 100644 test/configuration.cpp create mode 100644 test/data/test_configuration.json create mode 100644 test/data/unparsable.json diff --git a/test/configuration.cpp b/test/configuration.cpp new file mode 100644 index 000000000000..bed70b1b1218 --- /dev/null +++ b/test/configuration.cpp @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * configuration.cpp - Configuration parser tests + */ + +#include "libcamera/internal/configuration.h" + +#include "test.h" + +#include + +using namespace std; +using namespace libcamera; + +class ConfigurationTest : public Test +{ +protected: + int init() + { + return TestPass; + } + + int run() + { + Configuration c; + + /* Check access of json data before parsing */ + if (!c.data().is_null()) { + std::cerr << "Empty json was not discarded" + << std::endl; + return TestFail; + } + + /* Failure tests */ + int ret = c.open("CantFindMe.json"); + if (ret != -ENOENT) { + std::cerr << "Found an invalid file" << std::endl; + return TestFail; + } + + /* + * When run from source, Configuration looks in data/ + * Find our test data relative to that. + */ + ret = c.open("../test/data/unparsable.json"); + if (ret != -EINVAL) { + std::cerr << "Unparsable file parsed" << std::endl; + return TestFail; + } + + /* We expect to find this in the data/ folder of the sources. */ + ret = c.open("../test/data/test_configuration.json"); + if (ret != 0) { + std::cerr << "Failed to open configuration data" + << std::endl; + return TestFail; + } + + /* Parse sample data */ + json j = c.data(); + + for (auto &array : j) { + std::cout << array << std::endl; + } + + for (auto &[key, value] : c.data().items()) { + std::cout << key << " : " << value << "\n"; + } + + std::string cameraName = "Not Found"; + + auto it = j.find("device"); + if (it == j.end()) { + std::cerr << "Failed to find device key" << std::endl; + return TestFail; + } + + std::cout << "Device: " << j["device"] << std::endl; + if (j["device"].contains("cameraName")) + cameraName = j["device"]["cameraName"]; + + for (auto &[key, value] : j["device"].items()) { + std::cout << key << " : " << value << "\n"; + } + + if (cameraName != "Test Camera Name") { + std::cerr << "Failed to find expected string" << std::endl; + return TestFail; + } + + return TestPass; + } + + void cleanup() + { + } + +private: + std::string fileName_; +}; + +TEST_REGISTER(ConfigurationTest) + diff --git a/test/data/test_configuration.json b/test/data/test_configuration.json new file mode 100644 index 000000000000..926a14c23f17 --- /dev/null +++ b/test/data/test_configuration.json @@ -0,0 +1,15 @@ +{ + "device": { + "cameraName": "Test Camera Name", + "manufacturer": "Test Manufacturer" + }, + + "/base/soc/i2c0mux/i2c@1/imx219@10": { + "properties": { + "Rotation" : 0, + "Location" : 1 + } + }, + + "dummy_key": "Sample test string" +} diff --git a/test/data/unparsable.json b/test/data/unparsable.json new file mode 100644 index 000000000000..5cf969511242 --- /dev/null +++ b/test/data/unparsable.json @@ -0,0 +1,7 @@ +{ + "\_SB_.PCI0.XHC_.RHUB.HS05-5:1.0-0408:5251": { + "properties": { + "The ID above is invalidly escaped" : 0, + "This will not parse": 1 + } +}, diff --git a/test/meson.build b/test/meson.build index 0a1d434e3996..6b2105295ddf 100644 --- a/test/meson.build +++ b/test/meson.build @@ -25,6 +25,7 @@ public_tests = [ internal_tests = [ ['byte-stream-buffer', 'byte-stream-buffer.cpp'], ['camera-sensor', 'camera-sensor.cpp'], + ['configuration', 'configuration.cpp'], ['event', 'event.cpp'], ['event-dispatcher', 'event-dispatcher.cpp'], ['event-thread', 'event-thread.cpp'], From patchwork Mon Nov 23 16:43: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: 10479 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 B3CC1BE08A for ; Mon, 23 Nov 2020 16:45:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7F9E8633FF; Mon, 23 Nov 2020 17:45:05 +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="qgs43ZrY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5510A633FA for ; Mon, 23 Nov 2020 17:45:00 +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 0115A102C; Mon, 23 Nov 2020 17:44:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1606149900; bh=YvzN9h1fhb+XlVT8Bx6Fp1ABG07k7SDvCkVDUIkrufg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qgs43ZrYUmJuVK6t+q6CuW9TycqGZa5ZAzNODChy13yw7uA3QfAjd1tVTgxi2nBhg 20WTFhosDzQmrej5XX4AswQAqid5lPJoPl/yJKt9MVeCQdapJzkH6VJq5z+4rEPppI Yw0laY5EBJ67kVpcZcR4Qiy4dTDxxa2XI4loSXBo= From: Kieran Bingham To: libcamera devel Date: Mon, 23 Nov 2020 16:43:19 +0000 Message-Id: <20201123164319.152742-9-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> References: <20201123164319.152742-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 8/8] libcamera: camera_sensor: Parse configuration 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" Search for a camera_sensor.json configuration file specific to libcamera and parse it to see if any properties specific to this CameraSensor are applicable. Signed-off-by: Kieran Bingham --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 50 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index b9eba89f00fb..646f24a966bd 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -69,6 +69,7 @@ protected: private: int generateId(); + int parseConfigurationFile(); const MediaEntity *entity_; std::unique_ptr subdev_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 935de528c496..5a1bda483b9d 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -17,6 +17,7 @@ #include +#include "libcamera/internal/configuration.h" #include "libcamera/internal/formats.h" #include "libcamera/internal/sysfs.h" #include "libcamera/internal/utils.h" @@ -251,6 +252,12 @@ int CameraSensor::init() propertyValue = 0; properties_.set(properties::Rotation, propertyValue); + /* + * Properties are pulled from a configuration file on a best effort. + * If the file doesn't exist, or has no properties there is no failure. + */ + parseConfigurationFile(); + /* Enumerate, sort and cache media bus codes and sizes. */ formats_ = subdev_->formats(pad_); if (formats_.empty()) { @@ -584,4 +591,47 @@ int CameraSensor::generateId() return -EINVAL; } +int CameraSensor::parseConfigurationFile() +{ + Configuration c; + + int ret = c.open("camera_sensor.json"); + if (ret) { + LOG(CameraSensor, Debug) << "No configuration file available"; + return -ENODATA; + } + + /* Find properties based on the Camera model_ */ + /* Todo: Spilt parsing out for multiple paths. */ + + /* Find properties based around the Camera Sensor ID */ + json::iterator it = c.data().find(id_); + if (it == c.data().end()) + return -ENOENT; + + json j = *it; + it = j.find("properties"); + if (it == j.end()) + return -ENOENT; + + json deviceProperties = *it; + + for (auto &[key, value] : deviceProperties.items()) { + LOG(CameraSensor, Debug) << "Key: " << key << " Value: " << value; + + if (!value.is_number()) { + LOG(CameraSensor, Debug) << "Not a number: " << value; + continue; + } + + if (key == "Rotation") + properties_.set(properties::Rotation, value); + + if (key == "Location") + properties_.set(properties::Location, value); + } + + return 0; +} + } /* namespace libcamera */