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) };