From patchwork Tue Mar 14 14:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18394 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 30DE6BD80A for ; Tue, 14 Mar 2023 14:49:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C91B662719; Tue, 14 Mar 2023 15:49:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805398; bh=4WWmNqxEa3En1IFm6A+aBBWoe6pYCuvi8WpsS7o4Y6I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=pJcUSeXZscgNgAJ638bPYSEoqg6WmLHinAfwEmvA98GWj+ZxOFH9oCselg0YZh52o Ab8jFV0Y1M9cJILRBFeuhFrtRy08XH0D9sQy4JATdQfVLWyLPxO466MFG9oE5QYdpz rWLKsdquzRJJ+WzoJB/JFWQTg7uzPdAJGW36QbYkIxSBY6KBc/fcMzUccy7sXuyZQf wTIKqCj4hL8dZkOhuwRc3k+p3Q7NlHBJ+YYrD/N4I5gvSpiu/6yKaEH2fQr5OTWNti hJB0xuSw4k4aqvnMiJJMHG4aDjb/NmtIrUqab7QCw5Kb5tSTHGlnw4cyOCoBb+/nLR eOTRYt3ep5UzA== Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36B2D626D6 for ; Tue, 14 Mar 2023 15:49:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="F7vPqWbk"; dkim-atps=neutral Received: by mail-lj1-x236.google.com with SMTP id z5so16269893ljc.8 for ; Tue, 14 Mar 2023 07:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tf4a27wHPohwI3ltcrQGkT73Z2E4q3f/GsXTtml4cGg=; b=F7vPqWbkbGZsVidBUbxQo9ca8Hvs2k+Ip2vZFsKfmFc4Kbjgpl/gMnzA/gCz9cc+Gk 4zWe6jw2yX10PPPGJcrLahcTfkOZhM1A6Zho6Rx91sglJqk0joQlcOBt+Lw2wqYaFsrC ymtEARmXmjKo2sRsZ7EK79/Zr/yaVWNIfRj5mgnXr2cBS6bZ8H6cfdiqP2xhk2pvrqG/ fPUTq22/DliFnRksxwOf49m193ANP0LC9qd2ROf22DA8+WyhYxXHrzu+mi+tezW65T2I Tw543LwhYZVMfNZ09CglYKjIfbpUBG/FEeUdv9QImBlEcKErCB0GTPYXbM5JA0UJnOuz wmJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tf4a27wHPohwI3ltcrQGkT73Z2E4q3f/GsXTtml4cGg=; b=1ElTtEEfqfdsf0RvGrmIV7Ogm8SC1xE+SSknqzd1dFLKQ37Q0gr2JmnWUV1RJ/NjD4 0ugxD3fgtPpWf976KYQV80ra6rVsr4z72e5pfTe3Hi381bZ44ngfZGZPDcp8m6lYt06X hL5mGO/Im2IWgMpjeyp/Eo7qlO6y4+D/jVl28xzyVvEKYLUs/+xbbk5gMUtzKHQpF/Y/ 3YdPcCGtXUeR7V9MgCHGUAwVNal5ysUse3gKgm5a+BVvVbUPWjuoxRc2rtmyWqQp1qEq AWQlxWBfG9yu8cwYtONAsgo6G0RFMIQRZlc9BAL1Hz9NAZExtXgOl9M0SxGOav8b5Wha uaAg== X-Gm-Message-State: AO0yUKXKxI0MiAP0rspei8TQiOI6KXEyQwrSSCnTV/bnclxEBq52hdjo GyzHmfd/72sGp4v3dkHBE84r7Kx2wJNpFVqI9B4= X-Google-Smtp-Source: AK7set+YJduw8TJ3RBbr8dvOpvu+HO88O2u1ZX2GBbVd/XPCYVTBrzpy0+4eFOwStaZinm8Cbhh6WA== X-Received: by 2002:a2e:be06:0:b0:295:9c2e:7324 with SMTP id z6-20020a2ebe06000000b002959c2e7324mr15562460ljq.4.1678805392437; Tue, 14 Mar 2023 07:49:52 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:27 +0100 Message-Id: <20230314144834.85193-4-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 03/10] ipa: Add base class defining AF algorithm 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: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Define common interface with basic methods that should be supported by the Auto Focus algorithms. Interface methods match the AF controls that can be set in the frame request. Common implementation of controls parsing is provided, so the AF algorithms deriving from this interface should be able to reuse it. Signed-off-by: Daniel Semkowicz --- src/ipa/libipa/algorithms/af.cpp | 155 ++++++++++++++++++++++++++ src/ipa/libipa/algorithms/af.h | 41 +++++++ src/ipa/libipa/algorithms/meson.build | 9 ++ src/ipa/libipa/meson.build | 6 + 4 files changed, 211 insertions(+) create mode 100644 src/ipa/libipa/algorithms/af.cpp create mode 100644 src/ipa/libipa/algorithms/af.h create mode 100644 src/ipa/libipa/algorithms/meson.build diff --git a/src/ipa/libipa/algorithms/af.cpp b/src/ipa/libipa/algorithms/af.cpp new file mode 100644 index 00000000..2052080f --- /dev/null +++ b/src/ipa/libipa/algorithms/af.cpp @@ -0,0 +1,155 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Theobroma Systems + * + * af.cpp - Autofocus control algorithm interface + */ + +#include "af.h" + +/** + * \file af.h + * \brief AF algorithm common interface + */ + +namespace libcamera::ipa::common::algorithms { + +/** + * \class Af + * \brief Common interface for auto-focus algorithms + * + * The Af class defines a standard interface for IPA auto focus algorithms. + */ + +/** + * \brief Provide control values to the algorithm + * \param[in] controls The list of user controls + * + * This method should be called in the libcamera::ipa::Algorithm::queueRequest() + * method of the platform layer. + */ +void Af::queueRequest(const ControlList &controls) +{ + using namespace controls; + + for (auto const &[id, value] : controls) { + switch (id) { + case AF_MODE: { + setMode(static_cast(value.get())); + break; + } + case AF_RANGE: { + setRange(static_cast(value.get())); + break; + } + case AF_SPEED: { + setSpeed(static_cast(value.get())); + break; + } + case AF_METERING: { + setMeteringMode(static_cast(value.get())); + break; + } + case AF_WINDOWS: { + setWindows(value.get>()); + break; + } + case AF_TRIGGER: { + setTrigger(static_cast(value.get())); + break; + } + case AF_PAUSE: { + setPause(static_cast(value.get())); + break; + } + case LENS_POSITION: { + setLensPosition(value.get()); + break; + } + default: + break; + } + } +} + +/** + * \fn Af::setMode() + * \copybrief libcamera::controls::AfMode + * \param[in] mode AF mode + * + * \copydetails libcamera::controls::AfMode + */ + +/** + * \fn Af::setRange() + * \copybrief libcamera::controls::AfRange + * \param[in] range AF range + * + * \copydetails libcamera::controls::AfRange + */ + +/** + * \fn Af::setSpeed() + * \copybrief libcamera::controls::AfSpeed + * \param[in] speed Lens move speed + * +* \copydetails libcamera::controls::AfSpeed + */ + +/** + * \fn Af::setMeteringMode() + * \copybrief libcamera::controls::AfMetering + * \param[in] metering AF metering mode + * + * \copydetails libcamera::controls::AfMetering + */ + +/** + * \fn Af::setWindows() + * \copybrief libcamera::controls::AfWindows + * \param[in] windows AF windows + * + * \copydetails libcamera::controls::AfWindows + */ + +/** + * \fn Af::setTrigger() + * \copybrief libcamera::controls::AfTrigger + * \param[in] trigger Trigger mode + * + * \copydetails libcamera::controls::AfTrigger + */ + +/** + * \fn Af::setPause() + * \copybrief libcamera::controls::AfPause + * \param[in] pause Pause mode + * + * \copydetails libcamera::controls::AfPause + */ + +/** + * \fn Af::setLensPosition() + * \copybrief libcamera::controls::LensPosition + * \param[in] lensPosition Lens position + * + * \copydetails libcamera::controls::LensPosition + */ + +/** + * \fn Af::state() + * \copybrief libcamera::controls::AfState + * \return AF state + * + * \copydetails libcamera::controls::AfState + */ + +/** + * \fn Af::pauseState() + * \copybrief libcamera::controls::AfPauseState + * \return AF pause state + * + * \copydetails libcamera::controls::AfPauseState + */ + +} /* namespace libcamera::ipa::common::algorithms */ diff --git a/src/ipa/libipa/algorithms/af.h b/src/ipa/libipa/algorithms/af.h new file mode 100644 index 00000000..1428902c --- /dev/null +++ b/src/ipa/libipa/algorithms/af.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Theobroma Systems + * + * af.h - Autofocus control algorithm interface + */ +#pragma once + +#include + +namespace libcamera::ipa::common::algorithms { + +class Af +{ +public: + virtual ~Af() = default; + + void queueRequest(const ControlList &controls); + + virtual void setMode(controls::AfModeEnum mode) = 0; + + virtual void setRange(controls::AfRangeEnum range) = 0; + + virtual void setSpeed(controls::AfSpeedEnum speed) = 0; + + virtual void setMeteringMode(controls::AfMeteringEnum metering) = 0; + + virtual void setWindows(Span windows) = 0; + + virtual void setTrigger(controls::AfTriggerEnum trigger) = 0; + + virtual void setPause(controls::AfPauseEnum pause) = 0; + + virtual void setLensPosition(float lensPosition) = 0; + + virtual controls::AfStateEnum state() = 0; + + virtual controls::AfPauseStateEnum pauseState() = 0; +}; + +} /* namespace libcamera::ipa::common::algorithms */ diff --git a/src/ipa/libipa/algorithms/meson.build b/src/ipa/libipa/algorithms/meson.build new file mode 100644 index 00000000..7602976c --- /dev/null +++ b/src/ipa/libipa/algorithms/meson.build @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: CC0-1.0 + +common_ipa_algorithms_headers = files([ + 'af.h', +]) + +common_ipa_algorithms_sources = files([ + 'af.cpp', +]) diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index 016b8e0e..0cfc551a 100644 --- a/src/ipa/libipa/meson.build +++ b/src/ipa/libipa/meson.build @@ -1,5 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 +subdir('algorithms') + libipa_headers = files([ 'algorithm.h', 'camera_sensor_helper.h', @@ -8,6 +10,8 @@ libipa_headers = files([ 'module.h', ]) +libipa_headers += common_ipa_algorithms_headers + libipa_sources = files([ 'algorithm.cpp', 'camera_sensor_helper.cpp', @@ -16,6 +20,8 @@ libipa_sources = files([ 'module.cpp', ]) +libipa_sources += common_ipa_algorithms_sources + libipa_includes = include_directories('..') libipa = static_library('ipa', [libipa_sources, libipa_headers],