From patchwork Tue Dec 12 11:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 19306 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 D2A6DBD87C for ; Tue, 12 Dec 2023 11:51:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 881D362B2E; Tue, 12 Dec 2023 12:51:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1702381880; bh=+DHVvdlkAeBB23ioXjBk7DxfCC50ZttBLeVX6IWs+w4=; 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=h5OsJ5x9PJ02HZyOVbS41o1Xtj6Ed7mkdTd3vUKzxJosgtF/ndKKesUmVf5z5lthb ffNg38PdcST7tiYIAhlaeGyDutvj7lijKs5jiizdnh0dnzoFr9thW5eCI8UA6RQGwC ieHOt39I4kbCRA+dM61113hGb/kWcIbub7GbAK2O0vKncYD/zCS+2ZQBkQLIMU3w1O x7zbho0qfPspOueT1dQTly/aUjJmdqtLpeTkulR260coQXygcepp3wP226bXbUyg1D n23tKQ0KufCBMzEkbyh4bagLKjcRWTjRUer8+ruNApTGLijkDswlmKZwizIN/gVaRs ZexloDROffbig== Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E02F6629E1 for ; Tue, 12 Dec 2023 12:51:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rcI/l7CI"; dkim-atps=neutral Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-54c79968ffbso7341146a12.3 for ; Tue, 12 Dec 2023 03:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702381878; x=1702986678; darn=lists.libcamera.org; 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=uIstvMk8lbSTkr39GEaKHG4p3SI0k5/yPhecGjI4+ac=; b=rcI/l7CIqt7LKlj0CbiPb18puU1srndB4JIzeZ+Fyx0CpNBiFMXrHOIJEl+vWzmh1D ziiukPj7kdmSFvgFTI1p4Ova27w5ZcQLBYi9csJsojgR9f7HlJoO5yYTdNZa9noEtl4l oLMUhRoWGTTDc3+Q3eKcLz5ty+gnXqKPjy/m/+7dfH4YhZPbt6W3JeLxAEnm5XTpl7FS GD3o/1NrbNqHPSVYiJlSu4vmCFCzUbpypJXGX26WzJyIi+wnsVO8JWs+BTrAvPBtIE5/ hPsb8G26+/PUaxtZ6Is85WOcCVHyJyR+pf5fbj/SQY5WwAeb0LO1l2orFSBc/GHSUTRX 93rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702381878; x=1702986678; 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=uIstvMk8lbSTkr39GEaKHG4p3SI0k5/yPhecGjI4+ac=; b=SyXKpI/7ZbRvFPhYeE4ulKUXS6XGfjGOalvloVUzMC4+5/e5ikAmzCGEMirbcP0eIA BZbjVfA9+2a5hztIn7YVfKY7ib7K00FV8IM+/zqcWmr71M6ws8HBN6jUjysxJUz7FMMY bPg1Cv4uWG2SnOiWHluuGT9MzyVG/Rusqq5lu3UyoNQsG43zvbHSPb1dkI1rlXnzDujP rG0lss13izG0DYm6FAhM2DyHCmzd7T1Dd4vEA3VTMfKDioy5fOj3ANmZZK+CLWZ/nkW5 JVXhu3Jd8sjfoTemzaLks99JBJqxwf2GpiFLwkuw3huKMNDzGbGziWmISahtMXvug3Vj Iu6w== X-Gm-Message-State: AOJu0YzPbDyyLnaz7qLWCqSqi5S1LvxB7FzTCpoyHgyJx/UDEdHVSDiP SxG3hrP/EQcCD82mcAGs+ohcnfVPgPN8aQtpQjI= X-Google-Smtp-Source: AGHT+IGVqvwTNKFDvnw/9QVhpxsIXLRCjPG7DqRB5s5IXKdwv++pAsPzcsLA2EofB9EOXF/UhS57kQ== X-Received: by 2002:a17:906:3f13:b0:a1e:7683:4da4 with SMTP id c19-20020a1709063f1300b00a1e76834da4mr2495514ejj.11.1702381878410; Tue, 12 Dec 2023 03:51:18 -0800 (PST) Received: from Lat-5310.. ([87.116.161.153]) by smtp.gmail.com with ESMTPSA id tx17-20020a1709078e9100b00a1b75e0e061sm6213188ejc.130.2023.12.12.03.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 03:51:18 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Dec 2023 14:50:40 +0300 Message-Id: <20231212115046.102726-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212115046.102726-1-andrey.konovalov@linaro.org> References: <20231212115046.102726-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/7] libcamera: introduce SoftwareIsp class 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: Andrey Konovalov via libcamera-devel From: Andrey Konovalov Reply-To: Andrey Konovalov Cc: mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com, srinivas.kandagatla@linaro.org, pavel@ucw.cz, bryan.odonoghue@linaro.org, admin@dennisbonke.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Signed-off-by: Andrey Konovalov --- include/libcamera/internal/meson.build | 1 + include/libcamera/internal/software_isp.h | 106 ++++++++++++++++++++++ src/libcamera/meson.build | 1 + src/libcamera/software_isp.cpp | 62 +++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 include/libcamera/internal/software_isp.h create mode 100644 src/libcamera/software_isp.cpp diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 7f1f3440..0f725cfd 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -38,6 +38,7 @@ libcamera_internal_headers = files([ 'process.h', 'pub_key.h', 'request.h', + 'software_isp.h', 'source_paths.h', 'sysfs.h', 'v4l2_device.h', diff --git a/include/libcamera/internal/software_isp.h b/include/libcamera/internal/software_isp.h new file mode 100644 index 00000000..14511017 --- /dev/null +++ b/include/libcamera/internal/software_isp.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Linaro Ltd + * + * software_isp.h - Interface for a software implementation of an ISP + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "libcamera/internal/pipeline_handler.h" + +namespace libcamera { + +class FrameBuffer; +class PixelFormat; +struct StreamConfiguration; + +class SoftwareIsp +{ +public: + SoftwareIsp(PipelineHandler *pipe, const ControlInfoMap &sensorControls); + virtual ~SoftwareIsp(); + + virtual int loadConfiguration(const std::string &filename) = 0; + + virtual bool isValid() const = 0; + + virtual std::vector formats(PixelFormat input) = 0; + virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; + + virtual std::tuple + strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0; + + virtual int configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs) = 0; + virtual int exportBuffers(unsigned int output, unsigned int count, + std::vector> *buffers) = 0; + + virtual int start() = 0; + virtual void stop() = 0; + + virtual int queueBuffers(FrameBuffer *input, + const std::map &outputs) = 0; + + virtual void processStats(const ControlList &sensorControls) = 0; // rather merge with queueBuffers()? + + virtual Signal &getSignalSetSensorControls() = 0; + + Signal inputBufferReady; + Signal outputBufferReady; + + /* The int parameter isn't actually used */ + Signal ispStatsReady; +}; + +class SoftwareIspFactoryBase +{ +public: + SoftwareIspFactoryBase(); + virtual ~SoftwareIspFactoryBase() = default; + + static std::unique_ptr create(PipelineHandler *pipe, + const ControlInfoMap &sensorControls); + static SoftwareIspFactoryBase *&factory(); + +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(SoftwareIspFactoryBase) + + static void registerType(SoftwareIspFactoryBase *factory); + virtual std::unique_ptr createInstance(PipelineHandler *pipe, + const ControlInfoMap &sensorControls) const = 0; +}; + +template +class SoftwareIspFactory : public SoftwareIspFactoryBase +{ +public: + SoftwareIspFactory() + : SoftwareIspFactoryBase() + { + } + + std::unique_ptr createInstance(PipelineHandler *pipe, + const ControlInfoMap &sensorControls) const override + { + return std::make_unique<_SoftwareIsp>(pipe, sensorControls); + } +}; + +#define REGISTER_SOFTWAREISP(softwareIsp) \ + static SoftwareIspFactory global_##softwareIsp##Factory; + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 45f63e93..b3606969 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -40,6 +40,7 @@ libcamera_sources = files([ 'process.cpp', 'pub_key.cpp', 'request.cpp', + 'software_isp.cpp', 'source_paths.cpp', 'stream.cpp', 'sysfs.cpp', diff --git a/src/libcamera/software_isp.cpp b/src/libcamera/software_isp.cpp new file mode 100644 index 00000000..2ff97d70 --- /dev/null +++ b/src/libcamera/software_isp.cpp @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Linaro Ltd + * + * software_isp.cpp - Interface for a software implementation of an ISP + */ + +#include "libcamera/internal/software_isp.h" + +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(SoftwareIsp) + +SoftwareIsp::SoftwareIsp([[maybe_unused]] PipelineHandler *pipe, + [[maybe_unused]] const ControlInfoMap &sensorControls) +{ +} + +SoftwareIsp::~SoftwareIsp() +{ +} + +/* SoftwareIspFactoryBase */ + +SoftwareIspFactoryBase::SoftwareIspFactoryBase() +{ + registerType(this); +} + +void SoftwareIspFactoryBase::registerType(SoftwareIspFactoryBase *factory) +{ + SoftwareIspFactoryBase *®istered = + SoftwareIspFactoryBase::factory(); + + ASSERT(!registered && factory); + registered = factory; +} + +SoftwareIspFactoryBase *&SoftwareIspFactoryBase::factory() +{ + static SoftwareIspFactoryBase *factory; + return factory; +} + +std::unique_ptr +SoftwareIspFactoryBase::create(PipelineHandler *pipe, + const ControlInfoMap &sensorControls) +{ + SoftwareIspFactoryBase *factory = SoftwareIspFactoryBase::factory(); + if (!factory) + return nullptr; + + std::unique_ptr swIsp = factory->createInstance(pipe, sensorControls); + if (swIsp->isValid()) + return swIsp; + + return nullptr; +} + +} /* namespace libcamera */