From patchwork Thu Dec 14 12:13:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 19316 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 F2C2DBD87C for ; Thu, 14 Dec 2023 12:13:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ADA5C62B3E; Thu, 14 Dec 2023 13:13:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1702556039; bh=9lAdjEGb84KrawF6VpzD8e4nEnFR/pZ0hxGDAoDEsKc=; 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=yd63Nl3NoBRn7xIF3U14KxCoKZ2hiSQ2LgmNG3pUcMBp8SwJUuFcul4hBrlrXDxdQ uS7sN6oDZgZHXmN2bMs6FxOQo0zk0hcbMIGyesG7sVIOcwOgY0yDFGYA1yjMwpQuuw 17bMVd/EFOp/eWE8JB9HFDBITJ7iSIzOKV8YqEOhvHkhDH9Mo7uEgqxpLdmbHpQm6Q PKnUDJ4XIXuMU1+odwPFepzjEcWPAkZWrc04k7aWVuLacqwe6UtFoRVJyS+X6sntfu 16LVGTY9hHUXWcqPhy6cK9jR+tvigT5OBhAiigQQUG9fB6eHCiWOw5jl+Un+iQezNx 9RUpkWywn4dpw== Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C5B261D97 for ; Thu, 14 Dec 2023 13:13:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="cuQGl5T7"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702556037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W1QTcMYwG8Wi8q3OEBBjijsdZNeRjmeL4rPymXzB/3A=; b=cuQGl5T7nklwwqEL+Cc47TD+3IQ3QX000S5OkxVxD1VR3U6+rfSNXW+QdSpPWrU27o5CHb E75WIFGD4PgX/QKRX86RyV+Qew76HT/9Vxcv1oAC6qW5yAUwdHqWXD6pRFhXwMIdID4KV0 3RaHDiUzlqxOx/hTv98RYnqsmJVO9zk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-OkcUAu_-MFWkLPgsDDzZGA-1; Thu, 14 Dec 2023 07:13:54 -0500 X-MC-Unique: OkcUAu_-MFWkLPgsDDzZGA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 944BD85A58A; Thu, 14 Dec 2023 12:13:53 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E36D1121306; Thu, 14 Dec 2023 12:13:52 +0000 (UTC) To: libcamera-devel@lists.libcamera.org, Andrey Konovalov Date: Thu, 14 Dec 2023 13:13:39 +0100 Message-ID: <20231214121350.206015-2-hdegoede@redhat.com> In-Reply-To: <20231214121350.206015-1-hdegoede@redhat.com> References: <20231214121350.206015-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [libcamera-devel] [PATCH 01/11] 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: Hans de Goede via libcamera-devel From: Hans de Goede Reply-To: Hans de Goede Cc: Maxime Ripard , g.martti@gmail.com, t.langendam@gmail.com, srinivas.kandagatla@linaro.org, Bryan O'Donoghue , admin@dennisbonke.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Andrey Konovalov Signed-off-by: Andrey Konovalov --- include/libcamera/internal/meson.build | 1 + include/libcamera/internal/software_isp.h | 109 ++++++++++++++++++++++ src/libcamera/meson.build | 1 + src/libcamera/software_isp.cpp | 62 ++++++++++++ 4 files changed, 173 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..49cf7968 --- /dev/null +++ b/include/libcamera/internal/software_isp.h @@ -0,0 +1,109 @@ +/* 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 + +#include "libcamera/internal/pipeline_handler.h" + +namespace libcamera { + +class FrameBuffer; +class PixelFormat; +struct StreamConfiguration; + +LOG_DECLARE_CATEGORY(SoftwareIsp) + +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 */