From patchwork Wed Feb 9 07:19:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 15345 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 0A6FDC3257 for ; Wed, 9 Feb 2022 07:19:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA611610EA; Wed, 9 Feb 2022 08:19:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="OrBOP5Sq"; dkim-atps=neutral Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1406860E66 for ; Wed, 9 Feb 2022 08:19:28 +0100 (CET) Received: by mail-pl1-x62a.google.com with SMTP id 10so1489625plj.1 for ; Tue, 08 Feb 2022 23:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WAjeWglpTXXvm2qM30sZOk2hyFk1CLMYUo2yD83YX/c=; b=OrBOP5SqAhVlAq4j9ezYn1F5bNOWjYqmAUH8QwFHOjqrgJOV3QfEe08xLLeCjAWJla C7CTQi5vRQiQWoKTig6/FdVg7ZFPZmWxMER6HY3ef/fMttW4Ef+Vjk5tZAQG9Eyhbfej KYLIN00ZQ0UhD19FkjBgtP55TZjuJoAuJ4Whw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WAjeWglpTXXvm2qM30sZOk2hyFk1CLMYUo2yD83YX/c=; b=uREzoUyWnJH1maZR71PxlLIr/2uc+k7PzK/ghN5TEhkhlfhUNCajqzy1/tBdpOsrNF nhOViCbxcm3+St/t8WRHdRzUakWqd+q+A1dMyqxZ/6Y0Rib6+44OkR0wG10D0Qt+0DUY AuTXnJ//CxMjmJdasgMKmahFML1q7y5wMbAhur1BEGsAOF7SF6lOl0rFp6BaV8a+v7eo a0XbtrSuSgCoMNMjsAZX3qpuH4M+M1XT0laQ/76ukWVrGjIpIKwmKH9BO2QMNtFJuNJ3 PoaMI3Sevj83b9bX1mLc+6mO5tCwdSMdGwzUZmWRgraaUiAr5Z+qH3Sssitsg+fIvKZL EutQ== X-Gm-Message-State: AOAM530Owy3Qo5EHOMtYGXHlXqV+5sAb5so5+caFYFdv3BQsc6KPwXpu OexHNiYNnCLJSfLpY4SchsWeomQJ3y9D/A== X-Google-Smtp-Source: ABdhPJw4ntJsUnKrbj1nAHG1nMO9enanzBKo5sV+qQCW02aN9txXeHOX1HmfFZ3gqFyQp0/X9ZBLOA== X-Received: by 2002:a17:90a:7e15:: with SMTP id i21mr1980775pjl.74.1644391166337; Tue, 08 Feb 2022 23:19:26 -0800 (PST) Received: from localhost ([2401:fa00:1:10:a5cf:9a43:1c6d:824]) by smtp.gmail.com with UTF8SMTPSA id a5sm1900138pfh.101.2022.02.08.23.19.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Feb 2022 23:19:26 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Wed, 9 Feb 2022 15:19:09 +0800 Message-Id: <20220209071917.559993-2-hanlinchen@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220209071917.559993-1-hanlinchen@chromium.org> References: <20220209071917.559993-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/9] libcamera: Introduce option to customize behavior for a camera module 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" Introduce option to customize behavior for a camera module, which might alter the camera characteristic and should be set before inspecting it. Re-use the Control generation infrastructure to generate options and define the first 'PipelineConfigFile' option, which allows user to specify preference for pipeline configuration. Signed-off-by: Han-Lin Chen --- include/libcamera/ipa/ipa_controls.h | 1 + include/libcamera/meson.build | 3 +- include/libcamera/option_ids.h.in | 36 +++++++++++++++++ src/libcamera/control_serializer.cpp | 12 ++++++ src/libcamera/option_ids.cpp.in | 58 ++++++++++++++++++++++++++++ src/libcamera/option_ids.yaml | 16 ++++++++ 6 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 include/libcamera/option_ids.h.in create mode 100644 src/libcamera/option_ids.cpp.in create mode 100644 src/libcamera/option_ids.yaml diff --git a/include/libcamera/ipa/ipa_controls.h b/include/libcamera/ipa/ipa_controls.h index da1a7596..8173a2e5 100644 --- a/include/libcamera/ipa/ipa_controls.h +++ b/include/libcamera/ipa/ipa_controls.h @@ -18,6 +18,7 @@ extern "C" { enum ipa_controls_id_map_type { IPA_CONTROL_ID_MAP_CONTROLS, IPA_CONTROL_ID_MAP_PROPERTIES, + IPA_CONTROL_ID_MAP_OPTIONS, IPA_CONTROL_ID_MAP_V4L2, }; diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 408b7acf..a9b71bc3 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -31,10 +31,11 @@ install_headers(libcamera_public_headers, libcamera_headers_install_dir = get_option('includedir') / libcamera_include_dir -# control_ids.h and property_ids.h +# control_ids.h, property_ids.h, and option_ids.h control_source_files = [ 'control_ids', 'property_ids', + 'option_ids', ] control_headers = [] diff --git a/include/libcamera/option_ids.h.in b/include/libcamera/option_ids.h.in new file mode 100644 index 00000000..53058a4b --- /dev/null +++ b/include/libcamera/option_ids.h.in @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * option_ids.h - Option ID list + * + * This file is auto-generated. Do not edit. + */ + +#pragma once + +#include + +#include + +namespace libcamera { + +namespace options { + +enum { +${ids} +}; + +${controls} + +namespace draft { + +${draft_controls} + +} /* namespace draft */ + +extern const ControlIdMap options; + +} /* namespace options */ + +} /* namespace libcamera */ diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index e87d2362..dc8d2906 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -239,6 +240,8 @@ int ControlSerializer::serialize(const ControlInfoMap &infoMap, enum ipa_controls_id_map_type idMapType; if (idmap == &controls::controls) idMapType = IPA_CONTROL_ID_MAP_CONTROLS; + else if (idmap == &options::options) + idMapType = IPA_CONTROL_ID_MAP_OPTIONS; else if (idmap == &properties::properties) idMapType = IPA_CONTROL_ID_MAP_PROPERTIES; else @@ -333,6 +336,8 @@ int ControlSerializer::serialize(const ControlList &list, enum ipa_controls_id_map_type idMapType; if (idmap == &controls::controls) idMapType = IPA_CONTROL_ID_MAP_CONTROLS; + else if (idmap == &options::options) + idMapType = IPA_CONTROL_ID_MAP_OPTIONS; else if (idmap == &properties::properties) idMapType = IPA_CONTROL_ID_MAP_PROPERTIES; else @@ -458,6 +463,9 @@ ControlInfoMap ControlSerializer::deserialize(ByteStreamBuffer & case IPA_CONTROL_ID_MAP_CONTROLS: idMap = &controls::controls; break; + case IPA_CONTROL_ID_MAP_OPTIONS: + idMap = &options::options; + break; case IPA_CONTROL_ID_MAP_PROPERTIES: idMap = &properties::properties; break; @@ -589,6 +597,10 @@ ControlList ControlSerializer::deserialize(ByteStreamBuffer &buffer idMap = &controls::controls; break; + case IPA_CONTROL_ID_MAP_OPTIONS: + idMap = &options::options; + break; + case IPA_CONTROL_ID_MAP_PROPERTIES: idMap = &properties::properties; break; diff --git a/src/libcamera/option_ids.cpp.in b/src/libcamera/option_ids.cpp.in new file mode 100644 index 00000000..adfd0633 --- /dev/null +++ b/src/libcamera/option_ids.cpp.in @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * option_ids.cpp : Option ID list + * + * This file is auto-generated. Do not edit. + */ + +#include + +/** + * \file option_ids.h + * \brief Camera option identifiers + */ + +namespace libcamera { + +/** + * \brief Namespace for libcamera options + */ +namespace options { + +${controls_doc} + +/** + * \brief Namespace for libcamera draft options + */ +namespace draft { + +${draft_controls_doc} + +} /* namespace draft */ + +#ifndef __DOXYGEN__ +/* + * Keep the options definitions hidden from doxygen as it incorrectly parses + * them as functions. + */ +${controls_def} + +namespace draft { + +${draft_controls_def} + +} /* namespace draft */ +#endif + +/** + * \brief List of all supported libcamera options + */ +extern const ControlIdMap options { +${controls_map} +}; + +} /* namespace options */ + +} /* namespace libcamera */ diff --git a/src/libcamera/option_ids.yaml b/src/libcamera/option_ids.yaml new file mode 100644 index 00000000..3f9304be --- /dev/null +++ b/src/libcamera/option_ids.yaml @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2022, Google Inc. +# +%YAML 1.2 +--- +controls: + - PipelineConfigFile: + type: string + description: | + Some platform supports customizing pipeline configuration preference + for a camera module. The structure and contents of the configuration + file is specific to each platform in YAML format. The PipelineConfigFile + option can be used to specify the path to load the configuration file. + +...