From patchwork Thu Sep 28 18:55:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 19094 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 0F02DC0F2A for ; Thu, 28 Sep 2023 18:56:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFFF162965; Thu, 28 Sep 2023 20:56:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695927401; bh=JBU65R7c//9e4z7g5JrHGKqa8T0iaHXFk0mO+RreV7A=; 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=jEKdFsqf3bwwtvDyKAR+DgqLfyx+R1KK1dFPsmIkycikc0zWP/YLTt/iMIy4m/vEU 5RkNydljFLlS/35X8M1GEGbHBgF+Z/XQ9Ickzm12/TIm16UQCn9IGTcG2/DnB6Nv5x 7Dhxgbi21bSJwRmt2taRBPlbxQk6Ao+2G4JNai/BL+2Xv7uGL1ra6QGlxPRQiDsbGw l9UofUM02sec4B1DTlqwK+J98EFw9sd1QhBevEGit4Co2Y43BnG+AOOG2MwbrVWpmZ LWoho8xDISmgV7l6IrLmDzDeGpvH8zmbCZlfp0+cH1U9Ab2sLvt6xn6d8fjLKF84yD 5zNYCL36io5kQ== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4862761DE3 for ; Thu, 28 Sep 2023 20:56:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ul4OkIr4"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3231dff4343so6242757f8f.0 for ; Thu, 28 Sep 2023 11:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695927400; x=1696532200; 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=ypxvKBx6mrteqp8A4cjPERuJutJlBXx0XrDjTtsVzPY=; b=ul4OkIr42jnyq4hCWGfQ3kLoxKP4qS7sKClj5yfQQhESPDoe6608O7Znk5pqVF8DI1 18xw0v8GKhAJzFPH44hlPoQtz2sHgZM/gMqA4DtkJjxMeBXTBBvGKyQnjuRpOVOdUdc1 1b1MZGTYSdVH3cSncr5gruTuy8yQ4jxese1PaGYnQUlPwh8oGfe72S9XctCpzhGkGbX7 sunGwpy8SwE0RqL8fPY19CpgenhU37NFS0jsTs8pjl5cKVP/ITKd7RPVUWFXlW/bg0Vi e4mYSS9+9skyIuIk0XpPXYOVK12rhXrMDfkqn/T2v15d1FrSyTywweXMCgUE0KcT9RTT vLrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695927400; x=1696532200; 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=ypxvKBx6mrteqp8A4cjPERuJutJlBXx0XrDjTtsVzPY=; b=LzHQgS3e5IPPlpbjkmWXoOi+RnyTF2wEeTXTyZTzoqFT9PtSnar/RNSsGMr4lCGfPC heD6wmiAPfONTg1Bj4zjCWbcbKdQ/N0xtHWvmtkL2hT64u7kWhQfLrBoIqGDtmdwrMiJ F1PZ39y6rkvdEHQ7Kb6PRjMKESl/jWD4V6CPllu3zP4NqbN5V+hk/w0Z0/jMTwwU8WlU oI+TqzWQofgkr16unk7OwR+SbVZ7JQppa5T2V6Ew9TOmrVXvuggYo3HQly7sUUiHERLm J2ua6PM8NxCCExc5NiF8sO7Ue7xpWzDSQx+0PZCgiyTKz5NxsD5uP9LDMeceDxW8PGeR DrBA== X-Gm-Message-State: AOJu0YzMhunRKA+vSLDxB1KQWjbAmdil7N1d/YmwV/LCMUSohvGqnpGR T+BqyGHWu/aTqk4Lhnq+lJOcEz4xCaxzG/5nm6c= X-Google-Smtp-Source: AGHT+IFR4xGaH2DlR0ZodomGberS7Pl8FnRVon25Mbl+UFSWACLfCFVA5r2H8xcvTk2piNAxu/N98w== X-Received: by 2002:a5d:4052:0:b0:31f:eb45:462e with SMTP id w18-20020a5d4052000000b0031feb45462emr1897064wrp.28.1695927399933; Thu, 28 Sep 2023 11:56:39 -0700 (PDT) Received: from Lat-5310.. ([87.116.164.210]) by smtp.gmail.com with ESMTPSA id u1-20020adfed41000000b003247d3e5d99sm890842wro.55.2023.09.28.11.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 11:56:39 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Sep 2023 21:55:33 +0300 Message-Id: <20230928185537.20178-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928185537.20178-1-andrey.konovalov@linaro.org> References: <20230928185537.20178-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/5] libcamera: converter: a few fixes to ConverterFactoryBase documentation 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: jacopo.mondi@ideasonboard.com, bryan.odonoghue@linaro.org, srinivas.kandagatla@linaro.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The description of ConverterFactoryBase::registerType() referred to a converter factory as "converter class" and "converter". Fix that. Also make the descriptions of ConverterFactoryBase::compatibles() and ConverterFactoryBase::create() a bit more specific. Signed-off-by: Andrey Konovalov Reviewed-by: Mattijs Korpershoek Reviewed-by: Laurent Pinchart --- src/libcamera/converter.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index fa0f1ec8..15701363 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -199,16 +199,19 @@ ConverterFactoryBase::ConverterFactoryBase(const std::string name, std::initiali /** * \fn ConverterFactoryBase::compatibles() - * \return The names compatibles + * \return The list of compatible name aliases of the converter */ /** - * \brief Create an instance of the converter corresponding to a named factory - * \param[in] media Name of the factory + * \brief Create an instance of the converter corresponding to the media device + * \param[in] media The media device to create the converter for * * \return A unique pointer to a new instance of the converter subclass - * corresponding to the named factory or one of its alias. Otherwise a null - * pointer if no such factory exists + * corresponding to the media device. The converter is created by matching + * the factory name or any of its compatible aliases with the media device + * driver name. + * If the media device driver name doesn't match anything a null pointer is + * returned. */ std::unique_ptr ConverterFactoryBase::create(MediaDevice *media) { @@ -236,10 +239,11 @@ std::unique_ptr ConverterFactoryBase::create(MediaDevice *media) } /** - * \brief Add a converter class to the registry + * \brief Add a converter factory to the registry * \param[in] factory Factory to use to construct the converter class * - * The caller is responsible to guarantee the uniqueness of the converter name. + * The caller is responsible to guarantee the uniqueness of the converter + * factory name. */ void ConverterFactoryBase::registerType(ConverterFactoryBase *factory) { From patchwork Thu Sep 28 18:55:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 19095 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 B076EC0F2A for ; Thu, 28 Sep 2023 18:56:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A15A62968; Thu, 28 Sep 2023 20:56:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695927413; bh=EHb2i6k1F8BEjNdgGNoJxw6Wjc0/kqRNHiZEF32X3TY=; 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=JUQVlE0RXvyDlAyZT/w86T2XR3elYTEGj8mWAPievTQuLaLuhscpYArmJG/QiHRHv imzYvYzz6pOgzbS9rnbeG6uD7JHIrXlJeasSS5KYEQ5m+TwqQbqfcvRgla5LcdL0Et H+7EJeIUAW7fbXMbg/uCVldISF2LN5LAmT1Zajdwn8tKUfkedv/OFZ7gihMkuqZnta WdIxKPtOD3vRv3QBrWRPD3HsS3QZeSDv/o2q0PmtLv0J6lu+cb+w+rHBR83P6voLt2 /kwOaD+2X6RPJBZRlrJ+PC9DtPdCj+yUaLeGZURDTouiOCcjtQndVhIrz7sc/ArYBg hPaE0qSvmJD+w== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 14A1861DE4 for ; Thu, 28 Sep 2023 20:56:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PpkvyTuR"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40651a72807so10702775e9.1 for ; Thu, 28 Sep 2023 11:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695927411; x=1696532211; 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=0X0jp8tu3YPggEMuVBiDIV1hMDm5/OmdecoTIWvMQzs=; b=PpkvyTuRuEBq9se9hE6kcHhlkc3B90NvUD8VCT0FyVKK9krRL+yV7O75XA/0FmMifv NmsDV1C8bMnBTgrnBvY8JEz5J37qguDpuPVxkLpqCzrv/8AqHwhqoGX4EW09dEVfsVBE XDtDykH66SV8GjS+uqYhSK4m2OqwnktIoAjmgGmY9hEL7pn0Qowuk7503bI5bHWklEQM OFhz13o9vl1UITkCw3hf7tro3XGXrgTK08e3B3vaHac5xtSBNTLZ9K3vuw46BnHflTny wEG/ldVJosoI50hRdRUpQu3J0aO+/p+wLLhARZ5WDY1iBHaluE9O9cur6O+TWqurrZH1 77wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695927411; x=1696532211; 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=0X0jp8tu3YPggEMuVBiDIV1hMDm5/OmdecoTIWvMQzs=; b=Q1ueRaufbEXaa/dQWjggWni7p5bCCgX/Cz/ajZCHziBwaYSp62ngqsYdy0ZzvbCm4H Mb810Zx7EQsagMMjXEXmsCKFSl0ZGRLGTCbErc4QE6D8MbmSX5SgPQA851PqsGWTMVx6 OfT/R23uUFohEfMf8IbbpiP6yfhjBd+Mdu06Lz5almeE4hR6Ah9sq0hLfNuVrzAZD/yk COkhc9ecgmXnoz/JChvXKuTtcNtxNw7KMWcJolcZU4YRawXAcUhL3oP4/IM/8XdaWHtO fZX2s/68YISXphMgc8EKQyxtqCdC6VVLkzTdOiOgRqyfZmBkzSG8IbzT194ObbPS8xSB vMTA== X-Gm-Message-State: AOJu0YwsqtAPTr7c8yhH9VCBOND8BirD9Qoa5qOlQF1clnUovCquMkvG LoIyeFn4JuxkMY6YzcrXL8ZyD5AUpvSY8EH/kzs= X-Google-Smtp-Source: AGHT+IFN38ggRB73Il0pEUVoZ7SY+IJwIWvP9QcLUzrBuc4NzzfQL2Uk0gvztdZjtU8VdaaU7KIG1A== X-Received: by 2002:a1c:7704:0:b0:401:dc7c:2494 with SMTP id t4-20020a1c7704000000b00401dc7c2494mr2007911wmi.27.1695927411600; Thu, 28 Sep 2023 11:56:51 -0700 (PDT) Received: from Lat-5310.. ([87.116.164.210]) by smtp.gmail.com with ESMTPSA id u1-20020adfed41000000b003247d3e5d99sm890842wro.55.2023.09.28.11.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 11:56:51 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Sep 2023 21:55:34 +0300 Message-Id: <20230928185537.20178-3-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928185537.20178-1-andrey.konovalov@linaro.org> References: <20230928185537.20178-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/5] libcamera: converter: drop unnecessary #include directive 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: jacopo.mondi@ideasonboard.com, bryan.odonoghue@linaro.org, srinivas.kandagatla@linaro.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera/internal/media_device.h includes linux/media.h already. Signed-off-by: Andrey Konovalov Suggested-by: Jacopo Mondi Reviewed-by: Mattijs Korpershoek Reviewed-by: Laurent Pinchart --- src/libcamera/converter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index 15701363..aca4fbc7 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -13,8 +13,6 @@ #include "libcamera/internal/media_device.h" -#include "linux/media.h" - /** * \file internal/converter.h * \brief Abstract converter From patchwork Thu Sep 28 18:55:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 19096 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 48F46C0F2A for ; Thu, 28 Sep 2023 18:57:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 035DC62964; Thu, 28 Sep 2023 20:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695927428; bh=uXauu6ouhtLjZWNP5XLgaZ9jTggEIKauHcBLGkaqxEg=; 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=gIdAGRB73oQ7mxGuGl4sgkEIlVT7OK0/+mKkZPeOugeRkA29hu62vyRtRtzrgHxbs gb8pQy8daWxx7sChwNFXRZ15hYRN37BGViWiWg0r0n0LBpHj/9mGUDSBW3S/VYK1nJ KBbpD2h3pm8Yi94PJ398dzMPNPFjbfcm6rUG/WN0TmwUrcHM13szTLL8akAk7mvpIe zulQTsDXjiztrQl+TZk5DgsGurtQRrsfkRVf1LxVfpPHdXSOT3UOP9xjXxjXzh3Z36 Jzp6uqSObwa3veAq4ZS8nRoUaMzvxYDI5s6QisUivjBnlY+F9z+kVeqh7sxG/Kjrdb dhSZ31cNwT3/g== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F68F61DE4 for ; Thu, 28 Sep 2023 20:57:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="obCZG18P"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4053c6f0db8so127753205e9.3 for ; Thu, 28 Sep 2023 11:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695927426; x=1696532226; 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=OI2VKm75pLdX9VEIRplvrxvoZJu4os9OOVGF8JqDQLs=; b=obCZG18Pn03mD+IZsxqPiocC6b5ZxUVdVZRyeLnw7NDAIdivwBBN27YfItr0WK4zXH DVKZjivsIZW00x8ZMFlkHUkaBBp7Pr5P258ITZ3g3S0J1funs27TRq6OaVQ+QU1U81jH sMyiyPHV3NechlKumqeCgxMO+jVl6YlKDvFiIdsRXIXtIgwxlQWFlkdMsoUdQausHnqE FBZzNK21t9xbi/8OZ7s4OiyB6I3uEcn5d07GJ0wlasDBEYWu9Hqd32DfSVfnTpLB4yBJ ERSLgyfimLHwQkiF0k/yS8y2ak1FXpeHCEfeSr45D1I7iwoDIUNE91Ka+SnS8plisJOv hqBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695927426; x=1696532226; 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=OI2VKm75pLdX9VEIRplvrxvoZJu4os9OOVGF8JqDQLs=; b=qEvmZDBfH1JvA+Fvhwa9h2ezZ67KCKXWMXJfF0Bq1SiNLoLp/TjGmFZ2qebPU49+3N pQxiydAqmKZNj2Jd2fNsPvrY40eOo8ahZ12vPx4IXfpQVX+WTwkKq/Pc44/KH9WA1neH 1h01n6SU2Mk8/KzlUOh/6uW7SenMECS9acVs1oR5YCCq/xu4gj6V5cmSUTWQMhPL3l0M Tks+N6UKlwXdMrCmV40GPMHqkyqB2SvD1sDqdHXK2QDO5vXNYI75yixyDSJaUVvXr96j 9JwBa9tzYjGahCs22OFgkhqMPBsXWYM0a1ewyQ8/bET0ZOJT5a+ZgRaA2CiMFdRyVlx9 enfQ== X-Gm-Message-State: AOJu0YwbTgBWoFLKP00GHg1xACqJy/2HPKtEi36jV90nmi0cjQ9rm7uy LiLjacEk7naxvnWZIJbdSB5d+gWbzcnLb/5+eds= X-Google-Smtp-Source: AGHT+IGYx3+YrFp7aVlrfHrSPnkd6eNYVE62jov0aEMuObOwddr266S8uoBS/0YrPNIy+5t6ZE1QxQ== X-Received: by 2002:a05:6000:136a:b0:317:1b08:b317 with SMTP id q10-20020a056000136a00b003171b08b317mr1929996wrz.6.1695927425719; Thu, 28 Sep 2023 11:57:05 -0700 (PDT) Received: from Lat-5310.. ([87.116.164.210]) by smtp.gmail.com with ESMTPSA id u1-20020adfed41000000b003247d3e5d99sm890842wro.55.2023.09.28.11.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 11:57:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Sep 2023 21:55:35 +0300 Message-Id: <20230928185537.20178-4-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928185537.20178-1-andrey.konovalov@linaro.org> References: <20230928185537.20178-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/5] libcamera: converter: make using MediaDevice optional for the Converter 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: jacopo.mondi@ideasonboard.com, bryan.odonoghue@linaro.org, srinivas.kandagatla@linaro.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Make Converter a bit more generic by making pointer to MediaDevice an optional argument for Converter::Converter(), ConverterFactoryBase::create(), ConverterFactoryBase::createInstance(), and ConverterFactory::createInstance() functions to prepare for adding support for coverters not backed by a media device. Instead of the MediaDevice driver name, use a generic string to match against the converter factory name and its compatibles list. For MediaDevice based converters this string will be the MediaDevice driver name as before. Signed-off-by: Andrey Konovalov Reviewed-by: Mattijs Korpershoek --- include/libcamera/internal/converter.h | 9 +++--- src/libcamera/converter.cpp | 40 +++++++++++++++--------- src/libcamera/pipeline/simple/simple.cpp | 39 ++++++++++++++++------- 3 files changed, 58 insertions(+), 30 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index 834ec5ab..d0c70296 100644 --- a/include/libcamera/internal/converter.h +++ b/include/libcamera/internal/converter.h @@ -2,6 +2,7 @@ /* * Copyright (C) 2020, Laurent Pinchart * Copyright 2022 NXP + * Copyright 2023, Linaro Ltd * * converter.h - Generic format converter interface */ @@ -31,7 +32,7 @@ struct StreamConfiguration; class Converter { public: - Converter(MediaDevice *media); + Converter(MediaDevice *media = nullptr); virtual ~Converter(); virtual int loadConfiguration(const std::string &filename) = 0; @@ -72,7 +73,7 @@ public: const std::vector &compatibles() const { return compatibles_; } - static std::unique_ptr create(MediaDevice *media); + static std::unique_ptr create(std::string name, MediaDevice *media = nullptr); static std::vector &factories(); static std::vector names(); @@ -81,7 +82,7 @@ private: static void registerType(ConverterFactoryBase *factory); - virtual std::unique_ptr createInstance(MediaDevice *media) const = 0; + virtual std::unique_ptr createInstance(MediaDevice *media = nullptr) const = 0; std::string name_; std::vector compatibles_; @@ -96,7 +97,7 @@ public: { } - std::unique_ptr createInstance(MediaDevice *media) const override + std::unique_ptr createInstance(MediaDevice *media = nullptr) const override { return std::make_unique<_Converter>(media); } diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index aca4fbc7..fe073bf2 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright 2022 NXP + * Copyright 2023 Linaro Ltd * * converter.cpp - Generic format converter interface */ @@ -36,13 +37,16 @@ LOG_DEFINE_CATEGORY(Converter) /** * \brief Construct a Converter instance - * \param[in] media The media device implementing the converter + * \param[in] media The media device implementing the converter (optional) * * This searches for the entity implementing the data streaming function in the * media graph entities and use its device node as the converter device node. */ Converter::Converter(MediaDevice *media) { + if (!media) + return; + const std::vector &entities = media->entities(); auto it = std::find_if(entities.begin(), entities.end(), [](MediaEntity *entity) { @@ -160,7 +164,8 @@ Converter::~Converter() /** * \fn Converter::deviceNode() * \brief The converter device node attribute accessor - * \return The converter device node string + * \return The converter device node string. If there is no device node for + * the converter returns an empty string. */ /** @@ -201,32 +206,37 @@ ConverterFactoryBase::ConverterFactoryBase(const std::string name, std::initiali */ /** - * \brief Create an instance of the converter corresponding to the media device - * \param[in] media The media device to create the converter for + * \brief Create an instance of the converter corresponding to the converter + * name + * \param[in] name The name of the converter to create + * \param[in] media The media device to create the converter for (optional) + * + * The converter \a name must match the name of the converter factory, or one + * of its compatibles. For media device based converters the converter \a name + * is the media device driver name. + * + * \return A unique pointer to a new instance of the converter subclass. + * The converter is created by matching the factory name or any of its + * compatible aliases with the converter name. * - * \return A unique pointer to a new instance of the converter subclass - * corresponding to the media device. The converter is created by matching - * the factory name or any of its compatible aliases with the media device - * driver name. - * If the media device driver name doesn't match anything a null pointer is - * returned. + * If the converter name doesn't match anything a null pointer is returned. */ -std::unique_ptr ConverterFactoryBase::create(MediaDevice *media) +std::unique_ptr ConverterFactoryBase::create(std::string name, MediaDevice *media) { const std::vector &factories = ConverterFactoryBase::factories(); for (const ConverterFactoryBase *factory : factories) { const std::vector &compatibles = factory->compatibles(); - auto it = std::find(compatibles.begin(), compatibles.end(), media->driver()); + auto it = std::find(compatibles.begin(), compatibles.end(), name); - if (it == compatibles.end() && media->driver() != factory->name_) + if (it == compatibles.end() && name != factory->name_) continue; LOG(Converter, Debug) << "Creating converter from " << factory->name_ << " factory with " - << (it == compatibles.end() ? "no" : media->driver()) << " alias."; + << (it == compatibles.end() ? "no" : name) << " alias."; std::unique_ptr converter = factory->createInstance(media); if (converter->isValid()) @@ -317,7 +327,7 @@ std::vector &ConverterFactoryBase::factories() /** * \fn ConverterFactory::createInstance() const * \brief Create an instance of the Converter corresponding to the factory - * \param[in] media Media device pointer + * \param[in] media Media device pointer (optional) * \return A unique pointer to a newly constructed instance of the Converter * subclass corresponding to the factory */ diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 05ba76bc..c7da700b 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -178,20 +178,26 @@ LOG_DEFINE_CATEGORY(SimplePipeline) class SimplePipelineHandler; +enum class ConverterFlag { + NoFlag = 0, + MediaDevice = (1 << 0), +}; +using ConverterFlags = Flags; + struct SimplePipelineInfo { const char *driver; /* * Each converter in the list contains the name * and the number of streams it supports. */ - std::vector> converters; + std::vector> converters; }; namespace { static const SimplePipelineInfo supportedDevices[] = { { "dcmipp", {} }, - { "imx7-csi", { { "pxp", 1 } } }, + { "imx7-csi", { { ConverterFlag::MediaDevice, "pxp", 1 } } }, { "j721e-csi2rx", {} }, { "mxc-isi", {} }, { "qcom-camss", {} }, @@ -330,6 +336,7 @@ public: V4L2VideoDevice *video(const MediaEntity *entity); V4L2Subdevice *subdev(const MediaEntity *entity); + const char *converterName() { return converterName_; } MediaDevice *converter() { return converter_; } protected: @@ -358,6 +365,7 @@ private: MediaDevice *media_; std::map entities_; + const char *converterName_; MediaDevice *converter_; }; @@ -495,9 +503,10 @@ int SimpleCameraData::init() int ret; /* Open the converter, if any. */ - MediaDevice *converter = pipe->converter(); - if (converter) { - converter_ = ConverterFactoryBase::create(converter); + const char *converterName = pipe->converterName(); + if (converterName) { + LOG(SimplePipeline, Info) << "Creating converter '" << converterName << "'"; + converter_ = ConverterFactoryBase::create(std::string(converterName), pipe->converter()); if (!converter_) { LOG(SimplePipeline, Warning) << "Failed to create converter, disabling format conversion"; @@ -1409,13 +1418,21 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) if (!media_) return false; - for (const auto &[name, streams] : info->converters) { - DeviceMatch converterMatch(name); - converter_ = acquireMediaDevice(enumerator, converterMatch); - if (converter_) { - numStreams = streams; - break; + for (const auto &[flags, name, streams] : info->converters) { + if (flags & ConverterFlag::MediaDevice) { + DeviceMatch converterMatch(name); + converter_ = acquireMediaDevice(enumerator, converterMatch); + if (!converter_) { + LOG(SimplePipeline, Debug) + << "Failed to acquire converter media device '" + << name << "'"; + continue; + } } + + converterName_ = name; + numStreams = streams; + break; } /* Locate the sensors. */ From patchwork Thu Sep 28 18:55:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 19097 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 CB366C0F2A for ; Thu, 28 Sep 2023 18:57:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8A34862968; Thu, 28 Sep 2023 20:57:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695927432; bh=zDUi3LpHVJzJwwbZMHnvqrjZ4wAnwzhd1Wy4V3S/DJg=; 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=Fs0mL9zqwc8yFaRPhDl0M2Y5qQc/Z2ePtCciT67oJENj1FtDcRqQCOUJdtMUrfLY5 s6yXqXuQlVQY9mHlC5TUZRDfsxL9ZbZ/pt0s+2IKBvq3Y3MLTaYQ7ptqMqd23seKM8 023dop3db7645LBU/sgwni2undw/fk9/XWYG0P3dhTKMLh3pvWnl5eAHrwBbLy9h6p MrWrdjs1m/uDD++pclLMkyOqCz0f7AuKI2F7a2NOltEHf/gj70ab92H3wVNqz/jw+6 BOac0sCKJE4UHkfJJSqK0TYxgP7V1utVuzaSe3n0dI5rjxC6ZGLJ8Qg4ihP3eCk/Q3 l4jZNHrOp4/VA== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7751962963 for ; Thu, 28 Sep 2023 20:57:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ddd6DS7u"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3232be274a0so5450048f8f.1 for ; Thu, 28 Sep 2023 11:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695927431; x=1696532231; 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=eMsETHaSws+NBrGN8EhisryMSR4UFOOVrra7FOgytfw=; b=Ddd6DS7uFqtfUXIq1d2JqubbWaC+7FY1G96tJ6zhjpk3w9ciL0RXebierdNpqDH6a2 Cr+y7v0kFHf7L+zX9VztgfZwyo/17SnaJIPz8G/yB8A7mJ0W5ihBAreKo4SWPWOPyGIr aoMWk8Qa0UYBjDyoammAQYW4jgYWg2K/pAyqBhA3oDF/nk/yIhMX7EzAUvgdybX48glW KsOk/a2rcmXHfRgodAi1sYr5VdYQjmmm8sWUmaIhbpXBu9/XgtkK1weA92e8RqvjXU18 NjZQvoIM+GuNZvq5V2ymGGNCqIQEQwArQaUpldxHnNv+SKCn/S5IspIC/9rWqu2KARYm wJFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695927431; x=1696532231; 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=eMsETHaSws+NBrGN8EhisryMSR4UFOOVrra7FOgytfw=; b=msJ7qYcezXmqdW4Jq9F5xPf+eYejA+ubuUdthj9rnsUS6KkQxw3vulDcOU/SK205x+ ZgUVKrf9sIV6Mse+BVso8Ez0+RLQO68fsl6egFcCPwEvmPfE1/VX//pw66BkWbVFe12A BQ8cRA8Blq07MmRXLp0kNjc4ETzhSuHBI1NXvWyY+GM8M6nUDdP/ZRZ0bo6krcsPpdYg p/c5whM6Ug5Mgx6awlCvlmg9Bj3uUNdUqi0xRlCOJsezc2mAWNYdEXIaf4Znqk48CN8t EVGeWgQMIN6wKZDGKjpNjUxvwtaPAAz6HJ7aUbUNn0ymy/VfxLUnuq2FSMeh4Nf8fJUM XB/w== X-Gm-Message-State: AOJu0YwM02D00uag34rzEzmdIFYF2pFyFsiqZQsuJbVuFuaDBLV38hD+ fhMpsZKIqoAZgsKokx2B63n7c2hKI8/3No7FmIQ= X-Google-Smtp-Source: AGHT+IFXbWgnM8eWvD8W8DCdpsm4j3/z6ysDs9jyDb/iXGGagJbxjQUwAnucP+IMM5zZ5SMo+NyQnw== X-Received: by 2002:adf:e68a:0:b0:321:57a5:6e6c with SMTP id r10-20020adfe68a000000b0032157a56e6cmr1980795wrm.34.1695927431131; Thu, 28 Sep 2023 11:57:11 -0700 (PDT) Received: from Lat-5310.. ([87.116.164.210]) by smtp.gmail.com with ESMTPSA id u1-20020adfed41000000b003247d3e5d99sm890842wro.55.2023.09.28.11.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 11:57:10 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Sep 2023 21:55:36 +0300 Message-Id: <20230928185537.20178-5-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928185537.20178-1-andrey.konovalov@linaro.org> References: <20230928185537.20178-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 4/5] libcamera: converter: add software converter 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: jacopo.mondi@ideasonboard.com, bryan.odonoghue@linaro.org, srinivas.kandagatla@linaro.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the Converter interface to implement bilinear Bayer demosaic filtering and very simple AWB on CPU. The only output format currently supported is RGB888. Signed-off-by: Andrey Konovalov --- .../internal/converter/converter_softw.h | 100 ++++ .../libcamera/internal/converter/meson.build | 1 + src/libcamera/converter/converter_softw.cpp | 445 ++++++++++++++++++ src/libcamera/converter/meson.build | 3 +- 4 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 include/libcamera/internal/converter/converter_softw.h create mode 100644 src/libcamera/converter/converter_softw.cpp diff --git a/include/libcamera/internal/converter/converter_softw.h b/include/libcamera/internal/converter/converter_softw.h new file mode 100644 index 00000000..daa2d6da --- /dev/null +++ b/include/libcamera/internal/converter/converter_softw.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Linaro Ltd + * + * converter_softw.h - interface of software converter (runs 100% on CPU) + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "libcamera/internal/converter.h" + +namespace libcamera { + +class FrameBuffer; +class MediaDevice; +class Size; +class SizeRange; +struct StreamConfiguration; + +class SwConverter : public Converter +{ +public: + SwConverter(MediaDevice *media); + + int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; } + bool isValid() const { return isp_ != nullptr; } + + std::vector formats(PixelFormat input); + SizeRange sizes(const Size &input); + + std::tuple + strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size); + + int configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfg); + int exportBuffers(unsigned int ouput, unsigned int count, + std::vector> *buffers); + + void process(FrameBuffer *input, FrameBuffer *output); + int start(); + void stop(); + + int queueBuffers(FrameBuffer *input, + const std::map &outputs); + +private: + class Isp : public Object + { + public: + Isp(SwConverter *converter); + ~Isp(); + + int configure(const StreamConfiguration &inputCfg, + const StreamConfiguration &outputCfg); + int exportBuffers(unsigned int count, + std::vector> *buffers); + void process(FrameBuffer *input, FrameBuffer *output); + int start(); + void stop(); + void waitForIdle(); + + private: + void debayer(uint8_t *dst, const uint8_t *src); + + SwConverter *converter_; + + Thread thread_; + + libcamera::Mutex idleMutex_; + libcamera::ConditionVariable idleCV_; + bool idle_ LIBCAMERA_TSA_GUARDED_BY(idleMutex_); + + unsigned int width_; + unsigned int height_; + unsigned int stride_; + Point red_shift_; + + unsigned long rNumerat_, rDenomin_; /* red gain for AWB */ + unsigned long bNumerat_, bDenomin_; /* blue gain for AWB */ + unsigned long gNumerat_, gDenomin_; /* green gain for AWB */ + }; + + std::unique_ptr isp_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/converter/meson.build b/include/libcamera/internal/converter/meson.build index 891e79e7..843a0483 100644 --- a/include/libcamera/internal/converter/meson.build +++ b/include/libcamera/internal/converter/meson.build @@ -1,5 +1,6 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_internal_headers += files([ + 'converter_softw.h', 'converter_v4l2_m2m.h', ]) diff --git a/src/libcamera/converter/converter_softw.cpp b/src/libcamera/converter/converter_softw.cpp new file mode 100644 index 00000000..67245715 --- /dev/null +++ b/src/libcamera/converter/converter_softw.cpp @@ -0,0 +1,445 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Linaro Ltd + * + * converter_softw.h - interface of software converter (runs 100% on CPU) + */ + +#include "libcamera/internal/converter/converter_softw.h" + +#include +#include +#include + +#include +#include + +#include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/mapped_framebuffer.h" + +namespace libcamera { + +LOG_DECLARE_CATEGORY(Converter) + +SwConverter::SwConverter([[maybe_unused]] MediaDevice *media) + : Converter() +{ + isp_ = std::make_unique(this); +} + +std::vector SwConverter::formats(PixelFormat input) +{ + BayerFormat inputFormat = BayerFormat::fromPixelFormat(input); + + /* Only RAW10P is currently supported */ + if (inputFormat.bitDepth != 10 || + inputFormat.packing != BayerFormat::Packing::CSI2) { + LOG(Converter, Info) + << "Unsupported input format " << input.toString(); + return {}; + } + + return { formats::RGB888 }; +} + +SizeRange SwConverter::sizes(const Size &input) +{ + if (input.width < 2 || input.height < 2) { + LOG(Converter, Error) + << "Input format size too small: " << input.toString(); + return {}; + } + + return SizeRange(Size(input.width - 2, input.height - 2)); +} + +std::tuple +SwConverter::strideAndFrameSize(const PixelFormat &pixelFormat, + const Size &size) +{ + /* Only RGB888 output is currently supported */ + if (pixelFormat != formats::RGB888) + return {}; + + unsigned int stride = size.width * 3; + return std::make_tuple(stride, stride * (size.height)); +} + +int SwConverter::configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs) +{ + if (outputCfgs.size() != 1) { + LOG(Converter, Error) + << "Unsupported number of output streams: " + << outputCfgs.size(); + return -EINVAL; + } + + return isp_->invokeMethod(&SwConverter::Isp::configure, + ConnectionTypeBlocking, inputCfg, outputCfgs[0]); +} + +SwConverter::Isp::Isp(SwConverter *converter) + : converter_(converter) +{ + moveToThread(&thread_); + thread_.start(); +} + +SwConverter::Isp::~Isp() +{ + thread_.exit(); + thread_.wait(); +} + +int SwConverter::Isp::configure(const StreamConfiguration &inputCfg, + const StreamConfiguration &outputCfg) +{ + BayerFormat bayerFormat = + BayerFormat::fromPixelFormat(inputCfg.pixelFormat); + width_ = inputCfg.size.width; + height_ = inputCfg.size.height; + stride_ = inputCfg.stride; + + if (bayerFormat.bitDepth != 10 || + bayerFormat.packing != BayerFormat::Packing::CSI2 || + width_ < 2 || height_ < 2) { + LOG(Converter, Error) << "Input format " + << inputCfg.size << "-" + << inputCfg.pixelFormat + << "not supported"; + return -EINVAL; + } + + switch (bayerFormat.order) { + case BayerFormat::BGGR: + red_shift_ = Point(0, 0); + break; + case BayerFormat::GBRG: + red_shift_ = Point(1, 0); + break; + case BayerFormat::GRBG: + red_shift_ = Point(0, 1); + break; + case BayerFormat::RGGB: + default: + red_shift_ = Point(1, 1); + break; + } + + if (outputCfg.size.width != width_ - 2 || + outputCfg.size.height != height_ - 2 || + outputCfg.stride != (width_ - 2) * 3 || + outputCfg.pixelFormat != formats::RGB888) { + LOG(Converter, Error) + << "Output format not supported"; + return -EINVAL; + } + + LOG(Converter, Info) << "SwConverter configuration: " + << inputCfg.size << "-" << inputCfg.pixelFormat + << " -> " + << outputCfg.size << "-" << outputCfg.pixelFormat; + + /* set r/g/b gains to 1.0 until frame data collected */ + rNumerat_ = rDenomin_ = 1; + bNumerat_ = bDenomin_ = 1; + gNumerat_ = gDenomin_ = 1; + + return 0; +} + +int SwConverter::exportBuffers(unsigned int output, unsigned int count, + std::vector> *buffers) +{ + /* single output for now */ + if (output >= 1) + return -EINVAL; + + return isp_->invokeMethod(&SwConverter::Isp::exportBuffers, + ConnectionTypeBlocking, count, buffers); +} + +int SwConverter::Isp::exportBuffers(unsigned int count, + std::vector> *buffers) +{ + /* V4L2_PIX_FMT_BGR24 aka 'BGR3' for output: */ + unsigned int bufSize = (height_ - 2) * (width_ - 2) * 3; + + for (unsigned int i = 0; i < count; i++) { + std::string name = "frame-" + std::to_string(i); + + const int ispFd = memfd_create(name.c_str(), 0); + int ret = ftruncate(ispFd, bufSize); + if (ret < 0) { + LOG(Converter, Error) << "ftruncate() for memfd failed " + << strerror(-ret); + return ret; + } + + FrameBuffer::Plane outPlane; + outPlane.fd = SharedFD(std::move(ispFd)); + outPlane.offset = 0; + outPlane.length = bufSize; + + std::vector planes{ outPlane }; + buffers->emplace_back(std::make_unique(std::move(planes))); + } + + return count; +} + +int SwConverter::Isp::start() +{ + return 0; +} + +void SwConverter::Isp::stop() +{ +} + +void SwConverter::Isp::waitForIdle() +{ + MutexLocker locker(idleMutex_); + + idleCV_.wait(locker, [&]() LIBCAMERA_TSA_REQUIRES(idleMutex_) { + return idle_; + }); +} + +int SwConverter::start() +{ + return isp_->invokeMethod(&SwConverter::Isp::start, + ConnectionTypeBlocking); +} + +void SwConverter::stop() +{ + isp_->invokeMethod(&SwConverter::Isp::stop, + ConnectionTypeBlocking); + isp_->invokeMethod(&SwConverter::Isp::waitForIdle, + ConnectionTypeDirect); +} + +int SwConverter::queueBuffers(FrameBuffer *input, + const std::map &outputs) +{ + unsigned int mask = 0; + + /* + * Validate the outputs as a sanity check: at least one output is + * required, all outputs must reference a valid stream and no two + * outputs can reference the same stream. + */ + if (outputs.empty()) + return -EINVAL; + + for (auto [index, buffer] : outputs) { + if (!buffer) + return -EINVAL; + if (index >= 1) /* only single stream atm */ + return -EINVAL; + if (mask & (1 << index)) + return -EINVAL; + + mask |= 1 << index; + } + + process(input, outputs.at(0)); + + return 0; +} + +void SwConverter::process(FrameBuffer *input, FrameBuffer *output) +{ + isp_->invokeMethod(&SwConverter::Isp::process, + ConnectionTypeQueued, input, output); +} + +void SwConverter::Isp::process(FrameBuffer *input, FrameBuffer *output) +{ + { + MutexLocker locker(idleMutex_); + idle_ = false; + } + + /* Copy metadata from the input buffer */ + FrameMetadata &metadata = output->_d()->metadata(); + metadata.status = input->metadata().status; + metadata.sequence = input->metadata().sequence; + metadata.timestamp = input->metadata().timestamp; + + MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); + MappedFrameBuffer out(output, MappedFrameBuffer::MapFlag::Write); + if (!in.isValid() || !out.isValid()) { + LOG(Converter, Error) << "mmap-ing buffer(s) failed"; + metadata.status = FrameMetadata::FrameError; + converter_->outputBufferReady.emit(output); + converter_->inputBufferReady.emit(input); + return; + } + + debayer(out.planes()[0].data(), in.planes()[0].data()); + metadata.planes()[0].bytesused = out.planes()[0].size(); + + converter_->outputBufferReady.emit(output); + converter_->inputBufferReady.emit(input); + + { + MutexLocker locker(idleMutex_); + idle_ = true; + } + idleCV_.notify_all(); +} + +void SwConverter::Isp::debayer(uint8_t *dst, const uint8_t *src) +{ + /* RAW10P input format is assumed */ + + /* output buffer is in BGR24 format and is of (width-2)*(height-2) */ + + int w_out = width_ - 2; + int h_out = height_ - 2; + + unsigned long sumR = 0; + unsigned long sumB = 0; + unsigned long sumG = 0; + + for (int y = 0; y < h_out; y++) { + const uint8_t *pin_base = src + (y + 1) * stride_; + uint8_t *pout = dst + y * w_out * 3; + int phase_y = (y + red_shift_.y) % 2; + + for (int x = 0; x < w_out; x++) { + int phase_x = (x + red_shift_.x) % 2; + int phase = 2 * phase_y + phase_x; + + /* x part of the offset in the input buffer: */ + int x_m1 = x + x / 4; /* offset for (x-1) */ + int x_0 = x + 1 + (x + 1) / 4; /* offset for x */ + int x_p1 = x + 2 + (x + 2) / 4; /* offset for (x+1) */ + /* the colour component value to write to the output */ + unsigned val; + + switch (phase) { + case 0: /* at R pixel */ + /* blue: ((-1,-1)+(1,-1)+(-1,1)+(1,1)) / 4 */ + val = ( *(pin_base + x_m1 - stride_) + + *(pin_base + x_p1 - stride_) + + *(pin_base + x_m1 + stride_) + + *(pin_base + x_p1 + stride_) ) >> 2; + val = val * bNumerat_ / bDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* green: ((0,-1)+(-1,0)+(1,0)+(0,1)) / 4 */ + val = ( *(pin_base + x_0 - stride_) + + *(pin_base + x_p1) + + *(pin_base + x_m1) + + *(pin_base + x_0 + stride_) ) >> 2; + val = val * gNumerat_ / gDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* red: (0,0) */ + val = *(pin_base + x_0); + sumR += val; + val = val * rNumerat_ / rDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + break; + case 1: /* at Gr pixel */ + /* blue: ((0,-1) + (0,1)) / 2 */ + val = ( *(pin_base + x_0 - stride_) + + *(pin_base + x_0 + stride_) ) >> 1; + val = val * bNumerat_ / bDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* green: (0,0) */ + val = *(pin_base + x_0); + sumG += val; + val = val * gNumerat_ / gDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* red: ((-1,0) + (1,0)) / 2 */ + val = ( *(pin_base + x_m1) + + *(pin_base + x_p1) ) >> 1; + val = val * rNumerat_ / rDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + break; + case 2: /* at Gb pixel */ + /* blue: ((-1,0) + (1,0)) / 2 */ + val = ( *(pin_base + x_m1) + + *(pin_base + x_p1) ) >> 1; + val = val * bNumerat_ / bDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* green: (0,0) */ + val = *(pin_base + x_0); + sumG += val; + val = val * gNumerat_ / gDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* red: ((0,-1) + (0,1)) / 2 */ + val = ( *(pin_base + x_0 - stride_) + + *(pin_base + x_0 + stride_) ) >> 1; + val = val * rNumerat_ / rDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + break; + default: /* at B pixel */ + /* blue: (0,0) */ + val = *(pin_base + x_0); + sumB += val; + val = val * bNumerat_ / bDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* green: ((0,-1)+(-1,0)+(1,0)+(0,1)) / 4 */ + val = ( *(pin_base + x_0 - stride_) + + *(pin_base + x_p1) + + *(pin_base + x_m1) + + *(pin_base + x_0 + stride_) ) >> 2; + val = val * gNumerat_ / gDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + /* red: ((-1,-1)+(1,-1)+(-1,1)+(1,1)) / 4 */ + val = ( *(pin_base + x_m1 - stride_) + + *(pin_base + x_p1 - stride_) + + *(pin_base + x_m1 + stride_) + + *(pin_base + x_p1 + stride_) ) >> 2; + val = val * rNumerat_ / rDenomin_; + *pout++ = (uint8_t)std::min(val, 0xffU); + } + } + } + + /* calculate red and blue gains for simple AWB */ + LOG(Converter, Debug) << "sumR = " << sumR + << ", sumB = " << sumB << ", sumG = " << sumG; + + sumG /= 2; /* the number of G pixels is twice as big vs R and B ones */ + + /* normalize red, blue, and green sums to fit into 22-bit value */ + unsigned long fRed = sumR / 0x400000; + unsigned long fBlue = sumB / 0x400000; + unsigned long fGreen = sumG / 0x400000; + unsigned long fNorm = std::max({ 1UL, fRed, fBlue, fGreen }); + sumR /= fNorm; + sumB /= fNorm; + sumG /= fNorm; + + LOG(Converter, Debug) << "fNorm = " << fNorm; + LOG(Converter, Debug) << "Normalized: sumR = " << sumR + << ", sumB= " << sumB << ", sumG = " << sumG; + + /* make sure red/blue gains never exceed approximately 256 */ + unsigned long minDenom; + rNumerat_ = (sumR + sumB + sumG) / 3; + minDenom = rNumerat_ / 0x100; + rDenomin_ = std::max(minDenom, sumR); + bNumerat_ = rNumerat_; + bDenomin_ = std::max(minDenom, sumB); + gNumerat_ = rNumerat_; + gDenomin_ = std::max(minDenom, sumG); + + LOG(Converter, Debug) << "rGain = [ " + << rNumerat_ << " / " << rDenomin_ + << " ], bGain = [ " << bNumerat_ << " / " << bDenomin_ + << " ], gGain = [ " << gNumerat_ << " / " << gDenomin_ + << " (minDenom = " << minDenom << ")"; +} + +static std::initializer_list compatibles = {}; + +REGISTER_CONVERTER("linaro-sw-converter", SwConverter, compatibles) + +} /* namespace libcamera */ diff --git a/src/libcamera/converter/meson.build b/src/libcamera/converter/meson.build index 2aa72fe4..1f1e0ea4 100644 --- a/src/libcamera/converter/meson.build +++ b/src/libcamera/converter/meson.build @@ -1,5 +1,6 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_sources += files([ - 'converter_v4l2_m2m.cpp' + 'converter_softw.cpp', + 'converter_v4l2_m2m.cpp', ]) From patchwork Thu Sep 28 18:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 19098 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 47675C0F2A for ; Thu, 28 Sep 2023 18:57:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0568E62967; Thu, 28 Sep 2023 20:57:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1695927436; bh=+JqH+OtZ6M/mY3b3dLItICkeQQfY4h0WgZVmUgi0lS8=; 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=ANx/jWO63H8Cvu7HTYkj5YnDW8BeM/bHy2PnIi664JCIEAFFf2dH4UyFHisxUiRmn xOWEC7L8fUUgHvSrVa+H1hIdO/6y5Ktqjq87tt+4sqIa83hyyRmKbcx+d6K4pMH20E 8dPKfIZsNArY1TCl9WH4DQ6/ZfoielsPpzqFq7JcznPhXxXFivjd5YVGgQw3bztDXY rTcePtKdMS1oW9CD8PeHXgF38Tm3OpkXFSUSA5HY+E9RtNNVS/VKWadiHIaiXgpF8v wXy5ORFbWNLv6LqamFd7T0qk+Q/59FFhJR4wQAwFH3AiX/c3/kUEMo/R1lQ+cf2pUo 1yYynIgdNvSsw== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD29F62963 for ; Thu, 28 Sep 2023 20:57:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="CBBzSNbF"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40651a72807so10706285e9.1 for ; Thu, 28 Sep 2023 11:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695927434; x=1696532234; 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=YCZ23QSeXoYjY34lYlTI+VvVfns9ZbXuemkX2tCADKo=; b=CBBzSNbFI2bSEIZipJBg6F/XsolQoZBxa0g7uHvQqUITrXp1fQVbuqBjGtV9bj649X QYov14J1Rup4E2KdvN//YT2sQA3wkHb29NRLIlnBcP/g8tNK/JCYr7b400i3sySYeY53 puvWUwmkI/6Ks4xzIE/5vlyXX5i9OwNgLMUt2xOH6nFm8KGmRq6IqXWwsGmM5zoRO5oD 8cQd9efPydS9nZrEplDWi3FP4cFiFXn9SgV62jrSsVZb7D9S2g9ij+NcpDN9VknmqGQ2 h4GUR9KRh+F1jwMAcYIHeC3mlRRkwUis40v6Kq7A07Qv+soXlG87eu/OuVpJMcQqsvBo MJHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695927434; x=1696532234; 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=YCZ23QSeXoYjY34lYlTI+VvVfns9ZbXuemkX2tCADKo=; b=ArVribTAo+ocYqK3atK3s+RHXMJTYN4WBme+PUm7W4IXPz6HDm9H50MT9IGtV5ULL2 kvkyyfFcRlEvC+XffTCZKAKwqWHCRcQWjzwd1yKCkjZLbl0yqzH5lGE8KsFu9eWZ+9ao vuvzog6TZf6ZWiNzBAcXtqZTq6Eh5lj3H+nd0Nk8/F3J5YRAEK4G6qOhKsqSeJfuFTlW ocTxMXzA5AV4DxxEXGNru9s+Qr38rInlrFAnsvTrdzrNnyA9WLszmmk2jbKcHwiMdPaC S7863mTG1nk0z5M+S7T2eq0reVbvYWjgkAU4LF1F5HxOdJJReEsesGM4iljDOhwKqf38 IiKA== X-Gm-Message-State: AOJu0YyaFG/rJoItxD1/bg55rNGIyWqu85zXoFYyLz+7upuI4nLsgR6o k3AT9VzQeNz1An22QX3bRWoWOuUUEsCBDKtn0jI= X-Google-Smtp-Source: AGHT+IEVxL6YywaEYoOjAcNkMJr91q4f4k76I0xkf8Dz1VKHAT6RWMHAJ4/9z7Tu+ETwQS16X6zW8Q== X-Received: by 2002:a7b:cd15:0:b0:401:c52c:5ed9 with SMTP id f21-20020a7bcd15000000b00401c52c5ed9mr2018954wmj.32.1695927434562; Thu, 28 Sep 2023 11:57:14 -0700 (PDT) Received: from Lat-5310.. ([87.116.164.210]) by smtp.gmail.com with ESMTPSA id u1-20020adfed41000000b003247d3e5d99sm890842wro.55.2023.09.28.11.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 11:57:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Sep 2023 21:55:37 +0300 Message-Id: <20230928185537.20178-6-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928185537.20178-1-andrey.konovalov@linaro.org> References: <20230928185537.20178-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 5/5] libcamera: pipeline: simple: enable software converter for qcom-camss 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: jacopo.mondi@ideasonboard.com, bryan.odonoghue@linaro.org, srinivas.kandagatla@linaro.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Signed-off-by: Andrey Konovalov --- src/libcamera/pipeline/simple/simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c7da700b..5bdd00ea 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -200,7 +200,7 @@ static const SimplePipelineInfo supportedDevices[] = { { "imx7-csi", { { ConverterFlag::MediaDevice, "pxp", 1 } } }, { "j721e-csi2rx", {} }, { "mxc-isi", {} }, - { "qcom-camss", {} }, + { "qcom-camss", { { ConverterFlag::NoFlag, "linaro-sw-converter", 1 } } }, { "sun6i-csi", {} }, };