From patchwork Mon Oct 28 17:36:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21763 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 DCAFFC32B5 for ; Mon, 28 Oct 2024 17:37:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 72D5860367; Mon, 28 Oct 2024 18:37:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ns7bJbeY"; dkim-atps=neutral Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8017860367 for ; Mon, 28 Oct 2024 18:37:10 +0100 (CET) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-539fe02c386so5175746e87.0 for ; Mon, 28 Oct 2024 10:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730137029; x=1730741829; 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=DiNR0C7VTDxS5e/TYC9jAVgTnLyfxZg5d9xwmdf6V28=; b=ns7bJbeYNp9Y1rtQjbLlIOXAHWWVWUbP5Jrs+R2E93RKEGgd5Dif8hPVazIfSF8zVq R77DiWbGmAovIbdS2GIpp0/LpqdQDF24tlyJftvCV/XFhU/r86/1d1O/PAsayNEv8N0N ZfKaDIFEO89UzhZPCF9c5YUXe3aJYYHFxpSTjUsnYxYWOz6EchEMULE4EdU2qFPXlrFD DQZpVInZ6mEefMOPm3zdD2ckBY8atb9faPoA/z3Zqe/XLJL1r7CK0PwIIBsTgttotU7q hwK7K3+13xaNlrZ7iPJL/2QJjU/bcrqHl8fqGpUno/eYh+XLVEQbax7MIFJ4QVtxyQkv nWzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730137029; x=1730741829; 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=DiNR0C7VTDxS5e/TYC9jAVgTnLyfxZg5d9xwmdf6V28=; b=pDdDn+o75T8+G4Q4RPT1qQpRqRsEA+8ZkcmM+p94+moPxTPZ1VD2ziji2oW0PBeOYE sgYBQHdN1lFZYULgR2wnhf5Ew1F4AEp1mcIEAQCW88foVlgWOfYMIHotwIt+VV9KjE5R GoCoxLogJn2q6b2pjAONgrBTAYZouyLvG1TAnMgrTni3+6pwO7d1UPzpVqhuZFJMi7xs 5ftVgKzesGdfGg+8agJL5GlFA2FRZNGAioAl0SFlLX4jROkPwr6HEU0T8X8LY7E9pwpm Wzrm8iezu2nMTXzrdeY6EPjTlSJdwUOt5ZmG4gMdOVyx700chL3e7HxrCUKhYghX4xSI AysA== X-Gm-Message-State: AOJu0Yw1Wttls9aAQatDP5/bLmgM/GTEoTj4zefKb6FiwmcmivZztQMk 4b5Qtv9yhjzwTxb+MDTul7iEnAib7Ogvh9nUbX+aliZIO5ZTfXjHgkp5dclMujE= X-Google-Smtp-Source: AGHT+IEvpRlfXa9UK33kaOcnse5s3ibpXh6WuFtBa16+AVNOS1++GWedi6wRvnIKe0ZRh0OsEgw75w== X-Received: by 2002:a05:651c:994:b0:2fa:d086:bca0 with SMTP id 38308e7fff4ca-2fcda0812eamr1689391fa.10.1730137029242; Mon, 28 Oct 2024 10:37:09 -0700 (PDT) Received: from localhost.localdomain ([45.12.135.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb453e3afsm12115511fa.57.2024.10.28.10.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 10:37:07 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Laurent Pinchart , Mikhail Rudenko Subject: [PATCH RFC 1/3] ipa: core: add IPASensorDelays structure Date: Mon, 28 Oct 2024 20:36:57 +0300 Message-ID: <20241028173659.247353-2-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241028173659.247353-1-mike.rudenko@gmail.com> References: <20241028173659.247353-1-mike.rudenko@gmail.com> MIME-Version: 1.0 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" Add struct IPASensorDelays for passing sensor delays from a CameraSensorHelper to a pipeline handler at initialization time. Distinct member variables instead of a map ensure at compile time that all delays required by the pipeline handler are defined. Signed-off-by: Mikhail Rudenko --- include/libcamera/ipa/core.mojom | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index bce79724..c95cce4b 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -341,3 +341,38 @@ struct IPAStream { uint32 pixelFormat; Size size; }; + +/** + * \struct IPASensorDelays + * \brief Sensor control delays for the IPA interface + * + * The IPASensorDelays structure is used to pass sensoer control delays from + * the CameraSensorHelper instance in an IPA to the DelayedControls instance + * in a pipeline handler. + */ + +/** + * \var IPASensorDelays::exposureDelay + * \brief The delay for CID_EXPOSURE + */ + +/** + * \var IPASensorDelays::gainDelay + * \brief The delay for CID_ANALOGUE_GAIN + */ + +/** + * \var IPASensorDelays::hblankDelay + * \brief The delay for CID_HBLANK + */ + +/** + * \var IPASensorDelays::vblankDelay + * \brief The delay for CID_VBLANK + */ +struct IPASensorDelays { + uint32 exposureDelay; + uint32 gainDelay; + uint32 hblankDelay; + uint32 vblankDelay; +}; From patchwork Mon Oct 28 17:36:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21764 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 3CD00C3220 for ; Mon, 28 Oct 2024 17:37:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4ACEF653AA; Mon, 28 Oct 2024 18:37:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YyU9YlxO"; dkim-atps=neutral Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B86C7653A8 for ; Mon, 28 Oct 2024 18:37:12 +0100 (CET) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2fb51e00c05so66528431fa.0 for ; Mon, 28 Oct 2024 10:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730137031; x=1730741831; 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=0MZLbbG5Qo3cBMwhK7+oDHDAVsCfu8MFjHiLIIpXIQE=; b=YyU9YlxOW/xAiBarQKoBrI5lTrsHuJkVsmk/89UnjLL/5iKWv38xZawV6KQq2edLeJ zb+bIi4hnWQb9WdlLG35PgpmxDUlES8bfEN4Oc8Pcuz8fgQ9pfCa8o8dd7NdTbGuKulC 1pIwx+AiAbQUniF1MG0qWT41YgRUbQU17+Wd9dq8qnyUBGpAPewhl3FtVeySE+YWtw+X duTkeLOTWdUKbeLx/PeXc4hVBJQjacThc9YJTjNMXtiGDx7ry1ZhxLTrCBaWhGWzRXqG h27oRlzVsBq9WAV/px5IXYJzTrN7MaoRWo0ra4ZmlGq0Vmgp/kfAwh9EmZTQkPOX4+Ej ppYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730137031; x=1730741831; 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=0MZLbbG5Qo3cBMwhK7+oDHDAVsCfu8MFjHiLIIpXIQE=; b=LZdQJYuZi5LBeZ8yI0vNTvWuUm0ScKHdGI3xehW0tysAUzaM4L4FFsy9IWF/GwfJzd erpfiocAnkvi95MO3qgJMsMca81zjogJ4w0cSwZytcTCOshGoUp8utJd4TPSdd8RW68K ROxo5GeemcX4lW8IxD5BX/F3aw8RNYRxZV4dC/Q0+jEgnBffDdsX6dpfMVK3J+s2zbhh V9uCDi4SQXvWWp9LNNhCRp/frwmqWcOKrYACw2NIk4E4pMnkCwT6klrp8E292biNUIRm PiciUO/laG7Xfn+InAgebhXso3s0LBnkZgPHlMBnA+REJ2Bx4Dt9SeQ/nPa6suI1gqpu p02g== X-Gm-Message-State: AOJu0Yyf7/ALjA7V7Ez34fQ3ZduRlOzhFcs2BAok1UQUijAjVpWJU7LP LK8EFbtxHBh/JJ5Ouhw0TwMValrV2dLIj1wFB6ZF6Zxuqt8w1ouIikYyj+3zJw4= X-Google-Smtp-Source: AGHT+IEp7c1h44SlSJ7txHyNPVWgZpaXMc6RS7E8nPb2qzF2fXmMmhrlp/0Ab5nhySN8aIeXtvbEZg== X-Received: by 2002:a2e:bc09:0:b0:2fa:cdac:8732 with SMTP id 38308e7fff4ca-2fcbe06462cmr52851151fa.30.1730137030699; Mon, 28 Oct 2024 10:37:10 -0700 (PDT) Received: from localhost.localdomain ([45.12.135.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb453e3afsm12115511fa.57.2024.10.28.10.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 10:37:10 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Laurent Pinchart , Mikhail Rudenko Subject: [PATCH RFC 2/3] libcamera: libipa: camera_sensor: Add sensorDelays method Date: Mon, 28 Oct 2024 20:36:58 +0300 Message-ID: <20241028173659.247353-3-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241028173659.247353-1-mike.rudenko@gmail.com> References: <20241028173659.247353-1-mike.rudenko@gmail.com> MIME-Version: 1.0 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" Add a method to return sensor control application delays. Internally, a protected member variable sensorDelays_ with default delays is added to the base class CameraSensorHelper. Subsclasses for specific sensor, where the delays are known, are supposed to override default values in their constructors. Also override the defaults where correct delays are known from CamHelper or other sources. Signed-off-by: Mikhail Rudenko --- src/ipa/libipa/camera_sensor_helper.cpp | 59 +++++++++++++++++++++++++ src/ipa/libipa/camera_sensor_helper.h | 5 +++ 2 files changed, 64 insertions(+) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index c6169bdc..117c2f4e 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -140,6 +140,17 @@ double CameraSensorHelper::gain(uint32_t gainCode) const } } +/** + * \fn CameraSensorHelper::sensorDelays() + * \brief Fetch the delays for sensor subdevice controls + * + * This function returns the delays between setting a control on a + * sensor subdevice and it becoming effective, measured in frames. If + * they are unknown, default values are used. + * + * \return The delays for sensor subdevice controls + */ + /** * \enum CameraSensorHelper::AnalogueGainType * \brief The gain calculation modes as defined by the MIPI CCS @@ -252,6 +263,12 @@ double CameraSensorHelper::gain(uint32_t gainCode) const * sensor specific. Use this variable to store the values at init time. */ +/** + * \var CameraSensorHelper::sensorDelays_ + * \brief The delays for sensor subdevice controls + * \sa CameraSensorHelper::sensorDelays() + */ + /** * \class CameraSensorHelperFactoryBase * \brief Base class for camera sensor helper factories @@ -567,6 +584,12 @@ public: blackLevel_ = 3200; gainType_ = AnalogueGainLinear; gainConstants_.linear = { 0, 2048, -1, 2048 }; + + /* Taken from CamHelper. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 2; + sensorDelays_.hblankDelay = 2; } }; REGISTER_CAMERA_SENSOR_HELPER("imx283", CameraSensorHelperImx283) @@ -578,6 +601,12 @@ public: { gainType_ = AnalogueGainExponential; gainConstants_.exp = { 1.0, expGainDb(0.3) }; + + /* Taken from CamHelper. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 2; + sensorDelays_.hblankDelay = 2; } }; REGISTER_CAMERA_SENSOR_HELPER("imx290", CameraSensorHelperImx290) @@ -589,6 +618,12 @@ public: { gainType_ = AnalogueGainExponential; gainConstants_.exp = { 1.0, expGainDb(0.1) }; + + /* Taken from CamHelper. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 2; + sensorDelays_.hblankDelay = 2; } }; REGISTER_CAMERA_SENSOR_HELPER("imx296", CameraSensorHelperImx296) @@ -629,6 +664,12 @@ public: { gainType_ = AnalogueGainLinear; gainConstants_.linear = { 0, 1024, -1, 1024 }; + + /* Taken from CamHelper. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 3; + sensorDelays_.hblankDelay = 3; } }; REGISTER_CAMERA_SENSOR_HELPER("imx477", CameraSensorHelperImx477) @@ -668,6 +709,12 @@ public: blackLevel_ = 1024; gainType_ = AnalogueGainLinear; gainConstants_.linear = { 1, 0, 0, 128 }; + + /* Found by experimentation. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 2; + sensorDelays_.hblankDelay = 2; } }; REGISTER_CAMERA_SENSOR_HELPER("ov4689", CameraSensorHelperOv4689) @@ -692,6 +739,12 @@ public: { gainType_ = AnalogueGainLinear; gainConstants_.linear = { 1, 0, 0, 16 }; + + /* Taken from CamHelper. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 2; + sensorDelays_.hblankDelay = 2; } }; REGISTER_CAMERA_SENSOR_HELPER("ov5647", CameraSensorHelperOv5647) @@ -738,6 +791,12 @@ public: { gainType_ = AnalogueGainLinear; gainConstants_.linear = { 1, 0, 0, 128 }; + + /* Taken from CamHelper. */ + sensorDelays_.exposureDelay = 2; + sensorDelays_.gainDelay = 2; + sensorDelays_.vblankDelay = 2; + sensorDelays_.hblankDelay = 2; } }; REGISTER_CAMERA_SENSOR_HELPER("ov64a40", CameraSensorHelperOv64a40) diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h index 75868205..bef8380e 100644 --- a/src/ipa/libipa/camera_sensor_helper.h +++ b/src/ipa/libipa/camera_sensor_helper.h @@ -14,6 +14,7 @@ #include #include +#include namespace libcamera { @@ -28,6 +29,7 @@ public: std::optional blackLevel() const { return blackLevel_; } virtual uint32_t gainCode(double gain) const; virtual double gain(uint32_t gainCode) const; + IPASensorDelays sensorDelays() const { return sensorDelays_; }; protected: enum AnalogueGainType { @@ -56,6 +58,9 @@ protected: AnalogueGainType gainType_; AnalogueGainConstants gainConstants_; + /* Generic values taken from the Raspberry Pi. */ + IPASensorDelays sensorDelays_{ 2, 1, 2, 2 }; + private: LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelper) }; From patchwork Mon Oct 28 17:36:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21765 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 5E227C330B for ; Mon, 28 Oct 2024 17:37:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1C5AB653A0; Mon, 28 Oct 2024 18:37:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DIsNB+O+"; dkim-atps=neutral Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 154936539E for ; Mon, 28 Oct 2024 18:37:14 +0100 (CET) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2fb5638dd57so41497931fa.0 for ; Mon, 28 Oct 2024 10:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730137033; x=1730741833; 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=T9wQAQt3kQ8GXfSTN5Q58fUB0Jku6lzj5kKx0V1cfjs=; b=DIsNB+O+2rwWq5XfCta7PfVd6HS6AwVDb1yFLtsJhKw/Yi66+4J5nXs05N+Oi9jnqG tV+lWFeI4nkq5WhbsQ3Y2Uw/jlw8lw2ZKrQVPirMxA5C71wagGqs3lb+8Dd7a7tSr0VL hDXbR9/pr5fZkOIDhURkc/w/XCsU2Q9BUmDeFO2RUedgcV6GTea9+yuGXVcGOylUlD67 WedPpI1Ey1ZLps99e3YEwpvslMu2ItgCLKaFXuocU0fhA4XG1WTcR13XEdntGIpPIzQD v/VXh6f6j8hsgiazLCx0igXvlIG5m6F4ULPrjE/v0zX1eKk8pUk5NDneRYyvYGl2R7T2 szFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730137033; x=1730741833; 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=T9wQAQt3kQ8GXfSTN5Q58fUB0Jku6lzj5kKx0V1cfjs=; b=vXRDUtSJ6F//nTjxVTlLpSqHWDIBD1OZJ0UvhGZSmIyju4MdM5GIPY1RVfkl+sSaWd +50q7SElM76XvktvncUESQ7iEgeWyINxmAEqgMnb0nIDuNRRlRkRF2sqstMqdsA/zKGa Nvat1wkmyV8pCpBO3+0+dgPK3LP7yStZenbLO57EWKRrQhp95F2Pku1XsVcFLLn9IHKQ zV82MOdlCkuWhX6m0lyFSycLZeJbbp7ja6NE57oNtz1qiDnV8jl3VVnqf/ycg71Wj4+P 5sleRo/maaLTSUYRJDtuF+1dpK+eaG8vNHkGF8rD9mJX0QDIOAe2qBYgcgDqtpPRJAuT Lx/w== X-Gm-Message-State: AOJu0YyjekHY0ghO4IWcyq4PQoFYlFsY2rrkcuH7KyoanXdgU58EjOKa bSJopIVEBZyX4UUmUZHkk7/q6AjIOVbiSaLBxFEeHbio3Sw0bHoaXJacJfRiEaQ= X-Google-Smtp-Source: AGHT+IHlGBH2z74ovj+bOs8SKFEtZlpb+JSrGy2ypL3fDmPK90hfeCj9fqAdH78x+VWsZU0wupWdtw== X-Received: by 2002:a05:651c:a0a:b0:2fb:6198:d230 with SMTP id 38308e7fff4ca-2fcbdfc65d6mr39555901fa.18.1730137032430; Mon, 28 Oct 2024 10:37:12 -0700 (PDT) Received: from localhost.localdomain ([45.12.135.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fcb453e3afsm12115511fa.57.2024.10.28.10.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 10:37:11 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Laurent Pinchart , Mikhail Rudenko Subject: [PATCH RFC 3/3] ipa: rkisp1: Pass sensor delays from IPA to pipeline handler Date: Mon, 28 Oct 2024 20:36:59 +0300 Message-ID: <20241028173659.247353-4-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241028173659.247353-1-mike.rudenko@gmail.com> References: <20241028173659.247353-1-mike.rudenko@gmail.com> MIME-Version: 1.0 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" At present, rkisp1 uses hardcoded sensor control delays. In the case when they do not match real sensor delays, the AGC algorithm operates in a suboptimal mode, leading to gain/exposure oscillations on capture start and slower convergence. So, pass the correct delays from IPA at the init() time. Signed-off-by: Mikhail Rudenko --- include/libcamera/ipa/rkisp1.mojom | 3 ++- src/ipa/rkisp1/rkisp1.cpp | 8 +++++-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 27 ++++++++++-------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 80d54a03..aedd9461 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -19,7 +19,8 @@ interface IPARkISP1Interface { uint32 hwRevision, libcamera.IPACameraSensorInfo sensorInfo, libcamera.ControlInfoMap sensorControls) - => (int32 ret, libcamera.ControlInfoMap ipaControls); + => (int32 ret, libcamera.ControlInfoMap ipaControls, + libcamera.IPASensorDelays sensorDelays); start() => (int32 ret); stop(); diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e161cab..b42ec976 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -54,7 +54,8 @@ public: int init(const IPASettings &settings, unsigned int hwRevision, const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, - ControlInfoMap *ipaControls) override; + ControlInfoMap *ipaControls, + IPASensorDelays *sensorDelays) override; int start() override; void stop() override; @@ -136,7 +137,8 @@ std::string IPARkISP1::logPrefix() const int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, - ControlInfoMap *ipaControls) + ControlInfoMap *ipaControls, + IPASensorDelays *sensorDelays) { /* \todo Add support for other revisions */ switch (hwRevision) { @@ -168,6 +170,8 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, return -ENODEV; } + *sensorDelays = context_.camHelper->sensorDelays(); + context_.configuration.sensor.lineDuration = sensorInfo.minLineLength * 1.0s / sensorInfo.pixelRate; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index c7b0b392..0ece3c55 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -96,7 +96,7 @@ public: } PipelineHandlerRkISP1 *pipe(); - int loadIPA(unsigned int hwRevision); + int loadIPA(unsigned int hwRevision, IPASensorDelays *sensorDelays); Stream mainPathStream_; Stream selfPathStream_; @@ -360,7 +360,7 @@ PipelineHandlerRkISP1 *RkISP1CameraData::pipe() return static_cast(Camera::Private::pipe()); } -int RkISP1CameraData::loadIPA(unsigned int hwRevision) +int RkISP1CameraData::loadIPA(unsigned int hwRevision, IPASensorDelays *sensorDelays) { ipa_ = IPAManager::createIPA(pipe(), 1, 1); if (!ipa_) @@ -391,7 +391,8 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) } ret = ipa_->init({ ipaTuningFile, sensor_->model() }, hwRevision, - sensorInfo, sensor_->controls(), &ipaControls_); + sensorInfo, sensor_->controls(), &controlInfo_, + sensorDelays); if (ret < 0) { LOG(RkISP1, Error) << "IPA initialization failure"; return ret; @@ -1240,14 +1241,14 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) /* Initialize the camera properties. */ data->properties_ = data->sensor_->properties(); - /* - * \todo Read delay values from the sensor itself or from a - * a sensor database. For now use generic values taken from - * the Raspberry Pi and listed as generic values. - */ + IPASensorDelays sensorDelays; + ret = data->loadIPA(media_->hwRevision(), &sensorDelays); + if (ret) + return ret; + std::unordered_map params = { - { V4L2_CID_ANALOGUE_GAIN, { 1, false } }, - { V4L2_CID_EXPOSURE, { 2, false } }, + { V4L2_CID_ANALOGUE_GAIN, { sensorDelays.gainDelay, false } }, + { V4L2_CID_EXPOSURE, { sensorDelays.exposureDelay, false } }, }; data->delayedCtrls_ = @@ -1256,12 +1257,6 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) isp_->frameStart.connect(data->delayedCtrls_.get(), &DelayedControls::applyControls); - ret = data->loadIPA(media_->hwRevision()); - if (ret) - return ret; - - updateControls(data.get()); - std::set streams{ &data->mainPathStream_, &data->selfPathStream_,