From patchwork Mon Oct 3 08:39:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17488 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 C88CDC0DA4 for ; Mon, 3 Oct 2022 08:40:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 74EB562CD8; Mon, 3 Oct 2022 10:40:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786400; bh=PjWiq/L7a4VC3oYdfXVuQxR0D5yH6HEqDmGss+Y5yGc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PkX1GET3T2EdrPjT5E+eghfW8I+eh9+DcSzpL74UiNYXCecnn+yC1TokfIr2AkFOn 9ostbzQQqvZeeGFm4UkxhwZOjxScr4VYU4UX8cMC130hppaWgMMQUeGX2B1Pwk/GnI rIS8Hm0ePAb7FOUHvooYaxkgmSqJgHiOR+ircDUKSOV39lMmpFJaHwhJwqaaC/W/lN 4MMUJU1+WkFX3MmZY+l50h70B2SWr4tIue3+WKXwW0ohLZz9Bky2L7WE9hqpCWQh2a oZ+8cTzmy6G7gDqVl+a8Q7z0OQ0oBOMQTjk7ew4cMxeXhsAQGueTlXWbxc5BkE168f pI+25qjFEhWGQ== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 683BB61F74 for ; Mon, 3 Oct 2022 10:39:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="SWyVqmyw"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id f11so12949208wrm.6 for ; Mon, 03 Oct 2022 01:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=LK2i2ckLcU1EfLDok6fdgMsrZrSMhaaEYIQAq22FIN4=; b=SWyVqmywuek5j6IOEBRH9n1V/Dz/rSzbzHsmh9oCW5L//QSqk863DaOaTVI2Ucjnzl ps05oO1nzI66i7A5Gxu2akCB0BFWbOq7wi5CgMg5INdOZwXyLsL1ivsuW31kk3KVN5lL AI9Kx44LkYnbmlDvOUXLLnpwB5ILRU/WgUoyG3QWJCjFkBtLWBWt6Tsxk0MzDMiroyOz mZarF5VieBSc9Lzq3v4bkRxVV1WZer0QaVryMqpi5GsJ4fpGlfYuW09/hrkZPqNejTFR RXXiCknhhtlpENJ2IyQtKLJGUC46AwCMmg6Msa+g3lVTrDd3Iw/Ayk5JD5gJiRvFeYkv 3T4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=LK2i2ckLcU1EfLDok6fdgMsrZrSMhaaEYIQAq22FIN4=; b=DhmLRBnzmx/CmKLK0/TW8PkgOJBifJBqWgzjcH+kHAoVjRplDcG0yEto6ATchARNtE 8J7u3x4ue9TVa2R3+wn5P6Uh1T67MZIEahOAlDO1eTBkpjthaljNVYpu8dOq0gDcBl2p FFzqj7LZALJfzfGKKVCuy4MdFbpXxIgPqfB0rchlnxZ5x6BVJzjGrO15E654GfCnArTt /9DopHqzp/Nu8RVN3m0dTUZZezD8LJVtD51SVZEM6wnI9ziUt8hnmcgXhS/g+QBIgHmq QgMLXySzXXDkArnWaorJ2mAiv06VoJ5MhKNKJpB1BswmPGsOj/6EA2xoN1swGMrK1xOR 4xKg== X-Gm-Message-State: ACrzQf3CgrMxofV42k0Jo1SDi702aaZZJfyrrHfcbEOOZz2GN8Cgdx0a /gCDQ2VqkHkaaF/PTlQlsNZbqiDzKiwx5g== X-Google-Smtp-Source: AMsMyM52TV2HmkFNZa9LhFjRdxscKRlU8pZx5e21wQnNKbmdOjm+2jtch24nY+BO57Om0xbDKMBpcw== X-Received: by 2002:adf:aad1:0:b0:22e:3667:d307 with SMTP id i17-20020adfaad1000000b0022e3667d307mr3595581wrc.359.1664786397786; Mon, 03 Oct 2022 01:39:57 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:39:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:27 +0100 Message-Id: <20221003083934.31629-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/9] camera_sensor: Add minimum and maximum line length to IPACameraSensorInfo 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add fields for minimum and maximum line length (in units of pixels) to the IPACameraSensorInfo structure. This replaces the existing lineLength field. Update the ipu3, raspberrypi and rkisp1 IPAs to use IPACameraSensorInfo::minLineLength instead of IPACameraSensorInfo::lineLength, as logically we will always want to use the fastest sensor readout by default. Signed-off-by: Naushir Patuck --- include/libcamera/ipa/core.mojom | 21 +++++++++++++++------ src/ipa/ipu3/ipu3.cpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/libcamera/camera_sensor.cpp | 6 ++++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index 74f3339e56f2..2bc3028c22d6 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -172,10 +172,17 @@ module libcamera; */ /** - * \var IPACameraSensorInfo::lineLength - * \brief Total line length in pixels + * \var IPACameraSensorInfo::minLineLength + * \brief The minimum line length in pixels * - * The total line length in pixel clock periods, including blanking. + * The minimum allowable line length in pixel clock periods, including blanking. + */ + +/** + * \var IPACameraSensorInfo::maxLineLength + * \brief The maximum line length in pixels + * + * The maximum allowable line length in pixel clock periods, including blanking. */ /** @@ -189,7 +196,7 @@ module libcamera; * To obtain the minimum frame duration: * * \verbatim - frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + frameDuration(s) = minFrameLength(lines) * minLineLength(pixels) / pixelRate(pixels per second) \endverbatim */ @@ -204,7 +211,7 @@ module libcamera; * To obtain the maximum frame duration: * * \verbatim - frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + frameDuration(s) = maxFrameLength(lines) * maxLineLength(pixels) / pixelRate(pixels per second) \endverbatim */ struct IPACameraSensorInfo { @@ -217,7 +224,9 @@ struct IPACameraSensorInfo { Size outputSize; uint64 pixelRate; - uint32 lineLength; + + uint32 minLineLength; + uint32 maxLineLength; uint32 minFrameLength; uint32 maxFrameLength; diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index d1ea081d595d..da029571ba55 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -341,7 +341,7 @@ int IPAIPU3::init(const IPASettings &settings, /* Clean context */ context_.configuration = {}; - context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate; + context_.configuration.sensor.lineDuration = sensorInfo.minLineLength * 1.0s / sensorInfo.pixelRate; /* Load the tuning data file. */ File file(settings.configurationFile); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 8d731435764e..358a119da222 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -356,7 +356,7 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) * Calculate the line length as the ratio between the line length in * pixels and the pixel rate. */ - mode_.lineLength = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); + mode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate); /* * Set the frame length limits for the mode to ensure exposure and diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 32feb1682749..ddb22d98eb41 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -246,7 +246,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, context_.configuration.hw.revision = hwRevision_; context_.configuration.sensor.size = info.outputSize; - context_.configuration.sensor.lineDuration = info.lineLength * 1.0s / info.pixelRate; + context_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate; /* * When the AGC computes the new exposure values for a frame, it needs diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 911fd0beae4e..c2c8d3d44e26 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -883,10 +883,12 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const return -EINVAL; } - int32_t hblank = ctrls.get(V4L2_CID_HBLANK).get(); - info->lineLength = info->outputSize.width + hblank; info->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get(); + const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); + info->minLineLength = info->outputSize.width + hblank.min().get(); + info->maxLineLength = info->outputSize.width + hblank.max().get(); + const ControlInfo vblank = ctrls.infoMap()->at(V4L2_CID_VBLANK); info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get(); From patchwork Mon Oct 3 08:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17489 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 185E6C327C for ; Mon, 3 Oct 2022 08:40:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1155762CE4; Mon, 3 Oct 2022 10:40:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786402; bh=pKEJ82w+q8AzYxYD5MzI7GOYv4UyMiRvHsZgi0chqa8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Myw+jqbYpecbULYz4tCCmDocaAOx23fvAsR0U3QDjI3Fodv7MjWiuqyQ9IlpikuEZ v+T07aFVxfPyr2erCMltj0wYz+EMF90AnaWbq9IMb2ScJYRoMm2cPAiqkcEdIjIIcC lB72Bo9Ga+3UQ4Semug+u9ZE73jk3Fw9/qribhzuT1BOMtwEzrnxtt4NKUQBYSX5Up 9nS77gbp9XiX+O4A3a4QfCkzomGWkCTF6iSFaT0BynmSH5+Z5nvBUjA/VDhk4QDzj1 PdlJxkn4gjDT/hlJTZozsZBrQK86A9gtKSVNw0FawYHLt8/CLpgrFGLb0++aBpaNiY 71O/2KDFradXg== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1504D61F74 for ; Mon, 3 Oct 2022 10:39:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PAODfqMP"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id iv17so6535905wmb.4 for ; Mon, 03 Oct 2022 01:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1QCNpi5jJlmRb7DM3+pXDRv9ADcRQP27dKFxrOHea6E=; b=PAODfqMPZfM/7lme+IkrjJ2KPJP0TohcXzh6UPMqHCYsKcju5wLP+sKGIgmDxatDSg GlU6gqDWf2+B1un2bqdq89VNvcQ+Y+ENM+6LpVAtOhVfRcDCRH84jBR3Yn29eSD64HFb U5AtlqwX0C3/Fn74yTtH5DMvhYAF0XSPfzC7O4pX0BaT+s919dSJsLMX4hMTAI6DC6ha UKAtzbQ2OpIG/PXrhdVM3GXoYDmYWFb9wY4Ofp7gGgh5zcd7POdlOUqm77IvnRw6Ll01 DHRtcoOy9DfE5PE8a9cv2ac7BMG8D83g3l0mO9qFaV6fImO0+JOEdwLUuV2+z1eWC1ch INsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=1QCNpi5jJlmRb7DM3+pXDRv9ADcRQP27dKFxrOHea6E=; b=CQr0PALMdyiYH7yf/qevv54WH9baOv08/FRVBTJD/axtUGast2mTPUsFz5Fa5VH4v2 vk8DRaF4WwHalJ9AQNC6eLOGqnyTz5OTHc4elZ5HTD2a5M0ZXNwc0qZydFtAstUVXs62 D9/IFoadYH4YFMg43T3jAvj2NJqkDV11aQFTKebwhaWuN3gvhvrkpALraHDI67JydoQ9 eTQC2HbI+ibCWWu+lguNiR6PshsyYScZLxxI+OOw9M/vZxbFXhIwwnXkSrMLGUDSz48U Uy02Kekuf9Ie5X2HrpkydhEzeK1OdMWOZPqEixNxEF6I7j/yuAoGFNwvMnQatZIvfh5o Qm+w== X-Gm-Message-State: ACrzQf2hIM6LO8sfBQ0PR+k3dPbd0aeIAe+Fmh81HdgHMEZxTGgBcEev XvzdCEsBti/2UABbKsXdo1AW3ejonqrmTg== X-Google-Smtp-Source: AMsMyM69cSLJj/iXo+PVpnpLc4qMTRQ9o4winclxmkpQfPdxpP/UuwVna2QBW1pfxldl+gSmmph51A== X-Received: by 2002:a05:600c:35cc:b0:3b4:c403:7888 with SMTP id r12-20020a05600c35cc00b003b4c4037888mr6118578wmq.206.1664786398568; Mon, 03 Oct 2022 01:39:58 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:39:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:28 +0100 Message-Id: <20221003083934.31629-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/9] ipa: raspberrypi: Add minimum and maximum line length fields to CameraMode 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add fields for minimum and maximum line length (in units of pixels) to the CameraMode structure. This replaces the existing lineLength field. Any use of the existing lineLength field is replaced by the new minLineLength field, as logically we always want to use the fastest sensor readout by default. Signed-off-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.cpp | 8 ++++---- src/ipa/raspberrypi/controller/camera_mode.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 13 +++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index cac8f39ee763..42251ba29682 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -64,13 +64,13 @@ void CamHelper::process([[maybe_unused]] StatisticsPtr &stats, uint32_t CamHelper::exposureLines(const Duration exposure) const { assert(initialized_); - return exposure / mode_.lineLength; + return exposure / mode_.minLineLength; } Duration CamHelper::exposure(uint32_t exposureLines) const { assert(initialized_); - return exposureLines * mode_.lineLength; + return exposureLines * mode_.minLineLength; } uint32_t CamHelper::getVBlanking(Duration &exposure, @@ -86,8 +86,8 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, * minFrameDuration and maxFrameDuration are clamped by the caller * based on the limits for the active sensor mode. */ - frameLengthMin = minFrameDuration / mode_.lineLength; - frameLengthMax = maxFrameDuration / mode_.lineLength; + frameLengthMin = minFrameDuration / mode_.minLineLength; + frameLengthMax = maxFrameDuration / mode_.minLineLength; /* * Limit the exposure to the maximum frame duration requested, and diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index a6ccf8c1c600..b7e73aae4698 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -32,7 +32,7 @@ struct CameraMode { /* scaling of the noise compared to the native sensor mode */ double noiseFactor; /* line time */ - libcamera::utils::Duration lineLength; + libcamera::utils::Duration minLineLength, maxLineLength; /* any camera transform *not* reflected already in the camera tuning */ libcamera::Transform transform; /* minimum and maximum fame lengths in units of lines */ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 358a119da222..67326bcf4a14 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -314,7 +314,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) } startConfig->dropFrameCount = dropFrameCount_; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); firstStart_ = false; @@ -356,7 +356,8 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) * Calculate the line length as the ratio between the line length in * pixels and the pixel rate. */ - mode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate); + mode_.minLineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate); + mode_.maxLineLength = sensorInfo.maxLineLength * (1.0s / sensorInfo.pixelRate); /* * Set the frame length limits for the mode to ensure exposure and @@ -458,8 +459,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, * based on the current sensor mode. */ ControlInfoMap::Map ctrlMap = ipaControls; - const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; ctrlMap[&controls::FrameDurationLimits] = ControlInfo(static_cast(minSensorFrameDuration.get()), static_cast(maxSensorFrameDuration.get())); @@ -1150,8 +1151,8 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration) { - const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; /* * This will only be applied once AGC recalculations occur. From patchwork Mon Oct 3 08:39:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17490 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 20BE0C3285 for ; Mon, 3 Oct 2022 08:40:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E3A7E62CE7; Mon, 3 Oct 2022 10:40:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786402; bh=D+O3A92GH+pY7AyNAjsM9mtZeLOyaplKIjW+yl5Z+/Q=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QbFV2BFSj8xhrjotiP3z34pd9j45YURUMqwx+/bbCAXRwz7wFNp3swRe5g8vYeSAz BeLRK+Jl29LxSvXA5Fu8c2yFGtwizHkvLVuBgLo1Ovnm2eN+I9ml6uzGREVcNvzUq7 DAl4QqaAjtHgKuTCOEkeVsV0PYL1duIIRrRmrIygRZsuOzDxROrzL6G+9Joo/parS5 xAE3kHbHS0mFaXXP9Ja2feMYY/wtK67787dUleG11Vpvj3n50LFoOWgyuuVqyuWO3P wjdKg1bk5UdeRQTPBvFETWn6oHx31/K2wPnAuv7ewChP/aEdYMUhfJs5sy5tGwVeZB spjneakH8ICSg== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 18E0161F74 for ; Mon, 3 Oct 2022 10:40:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Cbf0RYlE"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id n35-20020a05600c502300b003b4924c6868so6731728wmr.1 for ; Mon, 03 Oct 2022 01:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=tlMV8G5wGt0Z/9WlSigS1mH/aBSMhPPT2FEqWU+4Qx4=; b=Cbf0RYlErHLSczlpGUKVLhA5msEwM1YWEDFrclBsaN5z1j+3MwJfQan7/EHWoqMn2N sH35PXT6NWb+xWz4CldjYvT1Y8x1SYl1TAZ3xT5YkY6OAIPSf17Ucj+V6C+O/8IBJlvK bOeLqp602SQFYuMoEmhFpLLrOcxHsxNrw91B2Zl8qwiYWFC4tjtReZuOswGKjwLKMEwR K2zkxlDOpUrmGUKKkUuvN9YXBlAkNpJLkMg+7PBvCwSRzXom8C7rYwm4CJPjudfqq6zn p2/loEgFPKt0kskSPzGC2IHo/CfIOaFA8Kn9skEiVALe/y5w83cCHsVF4V/HyTlfOkCt p/zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=tlMV8G5wGt0Z/9WlSigS1mH/aBSMhPPT2FEqWU+4Qx4=; b=SHscvuMtGBJLOyv1gZCAjird0eD8a7t7dh4zxXbVRan0NicXpZ4rPh+c4064eR8i7z xNQ/XMDMrQTOpTnK5ZIEZCe7EcIH3QDMaT5fwjnw2EmUGROWXIFmyvBrCn8259vde+NA dBGAB0xae8dP7QUGAx6H2i4mvlKpuMRseTogJuxOUijrZIx9x41JEI/in/sDBfvxRAAa XCOtaohN3KcYewh7WVu944uQ1qQzu95TDCEnzS4aSwqzx3GfaqeGyo8CDzNJJwdC8reA 38NEz6lgWHVzQjDwPthY8vUZuuTJL3ofxRWnv/FbcWs/FDOlBq9oTSGudvCenNzsZBSb GGbQ== X-Gm-Message-State: ACrzQf3v0LvpYVDtRXHm0gtD9iUxcdGYwtDP87g63Q2dF693GgmqSJmX +qs4Q0D0WaSZkpHR0h4V4itebgdduTgi6A== X-Google-Smtp-Source: AMsMyM4ziDz6LBKzGH4NjxC0DFzwaF13IpUOtmhsm0A4lvtx1TMjOs6ZpLire2IkH8Ry+gbYj9IRtQ== X-Received: by 2002:a05:600c:4e15:b0:3b4:a621:b54e with SMTP id b21-20020a05600c4e1500b003b4a621b54emr6057678wmq.47.1664786399287; Mon, 03 Oct 2022 01:39:59 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:39:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:29 +0100 Message-Id: <20221003083934.31629-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/9] ipa: raspberrypi: Pass lineLength into the CamHelper API 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update CamHelper::exposureLines() and CamHelper::exposure() to take a line length duration parameter for use in the exposure calculations. For now, only use the minimum line length for all the calculations to match the existing IPA behavior. Signed-off-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.cpp | 12 ++++++------ src/ipa/raspberrypi/cam_helper.h | 6 ++++-- src/ipa/raspberrypi/cam_helper_imx219.cpp | 3 ++- src/ipa/raspberrypi/cam_helper_imx296.cpp | 10 ++++++---- src/ipa/raspberrypi/cam_helper_imx477.cpp | 7 ++++--- src/ipa/raspberrypi/cam_helper_imx519.cpp | 7 ++++--- src/ipa/raspberrypi/controller/camera_mode.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++---- 8 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 42251ba29682..fd3527b94501 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -61,16 +61,16 @@ void CamHelper::process([[maybe_unused]] StatisticsPtr &stats, { } -uint32_t CamHelper::exposureLines(const Duration exposure) const +uint32_t CamHelper::exposureLines(const Duration exposure, const Duration lineLength) const { assert(initialized_); - return exposure / mode_.minLineLength; + return exposure / lineLength; } -Duration CamHelper::exposure(uint32_t exposureLines) const +Duration CamHelper::exposure(uint32_t exposureLines, const Duration lineLength) const { assert(initialized_); - return exposureLines * mode_.minLineLength; + return exposureLines * lineLength; } uint32_t CamHelper::getVBlanking(Duration &exposure, @@ -78,7 +78,7 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, Duration maxFrameDuration) const { uint32_t frameLengthMin, frameLengthMax, vblank; - uint32_t exposureLines = CamHelper::exposureLines(exposure); + uint32_t exposureLines = CamHelper::exposureLines(exposure, mode_.minLineLength); assert(initialized_); @@ -94,7 +94,7 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, * re-calculate if it has been clipped. */ exposureLines = std::min(frameLengthMax - frameIntegrationDiff_, exposureLines); - exposure = CamHelper::exposure(exposureLines); + exposure = CamHelper::exposure(exposureLines, mode_.minLineLength); /* Limit the vblank to the range allowed by the frame length limits. */ vblank = std::clamp(exposureLines + frameIntegrationDiff_, diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h index 70d62719da86..9b5e602689f3 100644 --- a/src/ipa/raspberrypi/cam_helper.h +++ b/src/ipa/raspberrypi/cam_helper.h @@ -78,8 +78,10 @@ public: virtual void prepare(libcamera::Span buffer, Metadata &metadata); virtual void process(StatisticsPtr &stats, Metadata &metadata); - virtual uint32_t exposureLines(libcamera::utils::Duration exposure) const; - virtual libcamera::utils::Duration exposure(uint32_t exposureLines) const; + virtual uint32_t exposureLines(const libcamera::utils::Duration exposure, + const libcamera::utils::Duration lineLength) const; + virtual libcamera::utils::Duration exposure(uint32_t exposureLines, + const libcamera::utils::Duration lineLength) const; virtual uint32_t getVBlanking(libcamera::utils::Duration &exposure, libcamera::utils::Duration minFrameDuration, libcamera::utils::Duration maxFrameDuration) const; diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 7ded07a213cd..98a3b31956ec 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -94,7 +94,8 @@ void CamHelperImx219::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; - deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), + mode_.minLineLength); deviceStatus.analogueGain = gain(registers.at(gainReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp index ab1d157aaf45..74361ffe7cc2 100644 --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp @@ -21,8 +21,8 @@ public: CamHelperImx296(); uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; - uint32_t exposureLines(Duration exposure) const override; - Duration exposure(uint32_t exposureLines) const override; + uint32_t exposureLines(const Duration exposure, const Duration lineLength) const override; + Duration exposure(uint32_t exposureLines, const Duration lineLength) const override; private: static constexpr uint32_t maxGainCode = 239; @@ -51,12 +51,14 @@ double CamHelperImx296::gain(uint32_t gainCode) const return std::pow(10.0, gainCode / 200.0); } -uint32_t CamHelperImx296::exposureLines(Duration exposure) const +uint32_t CamHelperImx296::exposureLines(const Duration exposure, + [[maybe_unused]] const Duration lineLength) const { return (exposure - 14.26us) / timePerLine; } -Duration CamHelperImx296::exposure(uint32_t exposureLines) const +Duration CamHelperImx296::exposure(uint32_t exposureLines, + [[maybe_unused]] const Duration lineLength) const { return exposureLines * timePerLine + 14.26us; } diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index aa306d6661c6..71529bdd3034 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -144,9 +144,9 @@ uint32_t CamHelperImx477::getVBlanking(Duration &exposure, if (shift) { /* Account for any rounding in the scaled frame length value. */ frameLength <<= shift; - exposureLines = CamHelperImx477::exposureLines(exposure); + exposureLines = CamHelperImx477::exposureLines(exposure, mode_.minLineLength); exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); - exposure = CamHelperImx477::exposure(exposureLines); + exposure = CamHelperImx477::exposure(exposureLines, mode_.minLineLength); } return frameLength - mode_.height; @@ -170,7 +170,8 @@ void CamHelperImx477::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; - deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), + mode_.minLineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); deviceStatus.sensorTemperature = std::clamp(registers.at(temperatureReg), -20, 80); diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index 54e104e7659a..2c120dad1680 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -144,9 +144,9 @@ uint32_t CamHelperImx519::getVBlanking(Duration &exposure, if (shift) { /* Account for any rounding in the scaled frame length value. */ frameLength <<= shift; - exposureLines = CamHelperImx519::exposureLines(exposure); + exposureLines = CamHelperImx519::exposureLines(exposure, mode_.minLineLength); exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); - exposure = CamHelperImx519::exposure(exposureLines); + exposure = CamHelperImx519::exposure(exposureLines, mode_.minLineLength); } return frameLength - mode_.height; @@ -170,7 +170,8 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; - deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), + mode_.minLineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index b7e73aae4698..cda6ac4e200a 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -31,7 +31,7 @@ struct CameraMode { double scaleX, scaleY; /* scaling of the noise compared to the native sensor mode */ double noiseFactor; - /* line time */ + /* minimum and maximum line times */ libcamera::utils::Duration minLineLength, maxLineLength; /* any camera transform *not* reflected already in the camera tuning */ libcamera::Transform transform; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 67326bcf4a14..13807f4d47f7 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -477,7 +477,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const uint32_t exposureMin = sensorCtrls_.at(V4L2_CID_EXPOSURE).min().get(); ctrlMap[&controls::ExposureTime] = - ControlInfo(static_cast(helper_->exposure(exposureMin).get()), + ControlInfo(static_cast(helper_->exposure(exposureMin, mode_.minLineLength).get()), static_cast(maxShutter.get())); result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); @@ -550,7 +550,7 @@ void IPARPi::reportMetadata() deviceStatus->shutterSpeed.get()); libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogueGain); libcameraMetadata_.set(controls::FrameDuration, - helper_->exposure(deviceStatus->frameLength).get()); + helper_->exposure(deviceStatus->frameLength, mode_.minLineLength).get()); if (deviceStatus->sensorTemperature) libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature); } @@ -1106,7 +1106,7 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get(); - deviceStatus.shutterSpeed = helper_->exposure(exposureLines); + deviceStatus.shutterSpeed = helper_->exposure(exposureLines, mode_.minLineLength); deviceStatus.analogueGain = helper_->gain(gainCode); deviceStatus.frameLength = mode_.height + vblank; @@ -1198,7 +1198,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) /* getVBlanking might clip exposure time to the fps limits. */ Duration exposure = agcStatus->shutterTime; int32_t vblanking = helper_->getVBlanking(exposure, minFrameDuration_, maxFrameDuration_); - int32_t exposureLines = helper_->exposureLines(exposure); + int32_t exposureLines = helper_->exposureLines(exposure, mode_.minLineLength); LOG(IPARPI, Debug) << "Applying AGC Exposure: " << exposure << " (Shutter lines: " << exposureLines << ", AGC requested " From patchwork Mon Oct 3 08:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17491 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 35D1BC0DA4 for ; Mon, 3 Oct 2022 08:40:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C48E862CEE; Mon, 3 Oct 2022 10:40:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786405; bh=kdicR1GQ6QL/ACIu2H07yGwSFb41n8Xmz3VpXULzhe0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HobMQPhJ3+TXgwpI9OybZTLK+DDCH7Gcxmp1NLANgiARYBCovq3yx0NnZJvZIE3jo lQMR7tBWqRgdMXfsgUFfivYX/xoAFl3e08UAXyOnHk9jpKa1dP2xJoFtyrXwnRgVlX 6F2JfqcVAiohzze2uIa6m8mGEM3UcDdlmuKkg32USnERaQKpbsGmu+eX6CxuE19whl OuLae+8rpVbiHwatMNBAgBmb2XUrXgrJJ5JK/+QdbeNus3+rUY0MGWZOrXHO2FwObY 3yNEj1eVVZ7ngS4Z3HJydufy0K4Xd6LYSRBBF9C0RV4Feh2fIOMsCZbFUW+WqwrihI dJ3Y1WASXdFIA== 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 A40E762CDF for ; Mon, 3 Oct 2022 10:40:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ZtnrmQaQ"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id r6so15608835wru.8 for ; Mon, 03 Oct 2022 01:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=J3Pbv3t5I1/ZGMouVY4ib0G5AjvzkADTW/LkgrcjbCk=; b=ZtnrmQaQL6hc9PRPWch//fIlw7x1zar/IzszJQX25tl5GbDZQoBK/kmtILDD4S10EQ euJb+ULIkzCKirdtItilAT6nz+/jByXibcwfrKIsNsQH8c7rLCXi8pDsuJw9gC9i67B7 gX6gPYVs/tAYO5nMDErJBojBSx76y/ad8u68l6xtLmknJtb7h3JBNTOEawn9N9SQQNoo rwlCOIeqaCAIXh/ph2DnG4Ska4qDqN/h6W9iUln+lTixL2F105qOLp8yxCD0y9Ye7jCj q6QdCUApEHM6fxjR7BuH4O+CZjfOp59wnNc1/nfC6Z5QnETb5mXkyGp7HRnzx1i01vVG glaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=J3Pbv3t5I1/ZGMouVY4ib0G5AjvzkADTW/LkgrcjbCk=; b=Rz40xwF27M0Riu369xRh1XrS3xfAHPshHhM6HmNq327oWuLypEvWxWJSOSy3ZWhXbo wXFgeIiJ5XCDwxDJcVCLtN92GTvxRSdn7pqAkGYWY8Bghtq/EzTwxIV+DiTj09guHtAi zWzVmST++pkVsoLH+qTGKjkLDWmrrblrCRDtmiBAGkaiXytNUH2/mY+qJg6Q8NB3dBx7 lzqOyXa+7Q05SNC1KTAqqy+P3XWBtIm4QYwt5FMPxG6b4ZSmR9LK8PCGtwrjcngusKu4 Qsd5PdwCnGZZDpGxY+d0LjbU9Ikmo8xaB/pZ4M+TvaJ8U/1MiVlGkIsZJNvcMyLGEBRd 9JwA== X-Gm-Message-State: ACrzQf3LeZ8rgnZeLUJDXH+wLPppozcfm9pbMSSo3ebYONBrPJ8uC3IT tVglD6fi1GL2eVMrp/46mm0BWqnTuYYFrw== X-Google-Smtp-Source: AMsMyM7+W7Oq8RkVFyS+1VlM8GuFfUOsmWdPQxfXAmXgez/n5cZa7PRkJ4KAG0V4EbD/kYAUTIZbVQ== X-Received: by 2002:a05:6000:18aa:b0:22a:b61d:877a with SMTP id b10-20020a05600018aa00b0022ab61d877amr12298312wri.512.1664786400018; Mon, 03 Oct 2022 01:40:00 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:39:59 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:30 +0100 Message-Id: <20221003083934.31629-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/9] pipeline: ipa: raspberrypi: Add HBLANK control to DelayedControls 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update CamHelper::getDelays() to return the sensor HBLANK delay. The HBLANK delay is set to the same value as VBLANK delay for all sensors in the Raspberry Pi IPA. Return the HBLANK gain delay from the IPA to the pipeline handler, and initialise DelayedControls to handle V4L2_CID_HBLANK with this delay value. As a drive-by, check that the V4L2_CID_HBLANK control is aviailable when calling IPARPi::configure(). Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/cam_helper.cpp | 3 ++- src/ipa/raspberrypi/cam_helper.h | 2 +- src/ipa/raspberrypi/cam_helper_imx290.cpp | 5 +++-- src/ipa/raspberrypi/cam_helper_imx477.cpp | 5 +++-- src/ipa/raspberrypi/cam_helper_imx519.cpp | 5 +++-- src/ipa/raspberrypi/cam_helper_ov5647.cpp | 5 +++-- src/ipa/raspberrypi/cam_helper_ov9281.cpp | 5 +++-- src/ipa/raspberrypi/raspberrypi.cpp | 6 ++++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 1 + 10 files changed, 24 insertions(+), 14 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index c0de435b7b33..40f78d9e3b3f 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -23,6 +23,7 @@ struct SensorConfig { uint32 gainDelay; uint32 exposureDelay; uint32 vblankDelay; + uint32 hblankDelay; uint32 sensorMetadata; }; diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index fd3527b94501..916632f83037 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -114,7 +114,7 @@ void CamHelper::setCameraMode(const CameraMode &mode) } void CamHelper::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { /* * These values are correct for many sensors. Other sensors will @@ -123,6 +123,7 @@ void CamHelper::getDelays(int &exposureDelay, int &gainDelay, exposureDelay = 2; gainDelay = 1; vblankDelay = 2; + hblankDelay = 2; } bool CamHelper::sensorEmbeddedDataPresent() const diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h index 9b5e602689f3..1bbdd715d2b1 100644 --- a/src/ipa/raspberrypi/cam_helper.h +++ b/src/ipa/raspberrypi/cam_helper.h @@ -88,7 +88,7 @@ public: virtual uint32_t gainCode(double gain) const = 0; virtual double gain(uint32_t gainCode) const = 0; virtual void getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const; + int &vblankDelay, int &hblankDelay) const; virtual bool sensorEmbeddedDataPresent() const; virtual double getModeSensitivity(const CameraMode &mode) const; virtual unsigned int hideFramesStartup() const; diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp index 25f23d531c72..7d6f5b549a73 100644 --- a/src/ipa/raspberrypi/cam_helper_imx290.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp @@ -18,7 +18,7 @@ public: uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; void getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const override; + int &vblankDelay, int &hblankDelay) const override; unsigned int hideFramesModeSwitch() const override; private: @@ -46,11 +46,12 @@ double CamHelperImx290::gain(uint32_t gainCode) const } void CamHelperImx290::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { exposureDelay = 2; gainDelay = 2; vblankDelay = 2; + hblankDelay = 2; } unsigned int CamHelperImx290::hideFramesModeSwitch() const diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 71529bdd3034..76a82cc51378 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -49,7 +49,7 @@ public: uint32_t getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const override; void getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const override; + int &vblankDelay, int &hblankDelay) const override; bool sensorEmbeddedDataPresent() const override; private: @@ -153,11 +153,12 @@ uint32_t CamHelperImx477::getVBlanking(Duration &exposure, } void CamHelperImx477::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { exposureDelay = 2; gainDelay = 2; vblankDelay = 3; + hblankDelay = 3; } bool CamHelperImx477::sensorEmbeddedDataPresent() const diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index 2c120dad1680..9dff1eeb899f 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -49,7 +49,7 @@ public: uint32_t getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const override; void getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const override; + int &vblankDelay, int &hblankDelay) const override; bool sensorEmbeddedDataPresent() const override; private: @@ -153,11 +153,12 @@ uint32_t CamHelperImx519::getVBlanking(Duration &exposure, } void CamHelperImx519::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { exposureDelay = 2; gainDelay = 2; vblankDelay = 3; + hblankDelay = 3; } bool CamHelperImx519::sensorEmbeddedDataPresent() const diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp index 04fb725d42db..5a99083dee78 100644 --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp @@ -18,7 +18,7 @@ public: uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; void getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const override; + int &vblankDelay, int &hblankDelay) const override; unsigned int hideFramesStartup() const override; unsigned int hideFramesModeSwitch() const override; unsigned int mistrustFramesStartup() const override; @@ -53,7 +53,7 @@ double CamHelperOv5647::gain(uint32_t gainCode) const } void CamHelperOv5647::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { /* * We run this sensor in a mode where the gain delay is bumped up to @@ -62,6 +62,7 @@ void CamHelperOv5647::getDelays(int &exposureDelay, int &gainDelay, exposureDelay = 2; gainDelay = 2; vblankDelay = 2; + hblankDelay = 2; } unsigned int CamHelperOv5647::hideFramesStartup() const diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp index 66f56a31e1b8..86c5bc4c8fda 100644 --- a/src/ipa/raspberrypi/cam_helper_ov9281.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov9281.cpp @@ -18,7 +18,7 @@ public: uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; void getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const override; + int &vblankDelay, int &hblankDelay) const override; private: /* @@ -49,12 +49,13 @@ double CamHelperOv9281::gain(uint32_t gainCode) const } void CamHelperOv9281::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { /* The driver appears to behave as follows: */ exposureDelay = 2; gainDelay = 2; vblankDelay = 2; + hblankDelay = 2; } static CamHelper *create() diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 13807f4d47f7..9b0ad4361c97 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -219,13 +219,14 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) * Pass out the sensor config to the pipeline handler in order * to setup the staggered writer class. */ - int gainDelay, exposureDelay, vblankDelay, sensorMetadata; - helper_->getDelays(exposureDelay, gainDelay, vblankDelay); + int gainDelay, exposureDelay, vblankDelay, hblankDelay, sensorMetadata; + helper_->getDelays(exposureDelay, gainDelay, vblankDelay, hblankDelay); sensorMetadata = helper_->sensorEmbeddedDataPresent(); result->sensorConfig.gainDelay = gainDelay; result->sensorConfig.exposureDelay = exposureDelay; result->sensorConfig.vblankDelay = vblankDelay; + result->sensorConfig.hblankDelay = hblankDelay; result->sensorConfig.sensorMetadata = sensorMetadata; /* Load the tuning file for this sensor. */ @@ -607,6 +608,7 @@ bool IPARPi::validateSensorControls() V4L2_CID_ANALOGUE_GAIN, V4L2_CID_EXPOSURE, V4L2_CID_VBLANK, + V4L2_CID_HBLANK, }; for (auto c : ctrls) { diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index dcd81650c32d..623bec6bea3c 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1299,6 +1299,7 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me std::unordered_map params = { { V4L2_CID_ANALOGUE_GAIN, { result.sensorConfig.gainDelay, false } }, { V4L2_CID_EXPOSURE, { result.sensorConfig.exposureDelay, false } }, + { V4L2_CID_HBLANK, { result.sensorConfig.hblankDelay, false } }, { V4L2_CID_VBLANK, { result.sensorConfig.vblankDelay, true } } }; data->delayedCtrls_ = std::make_unique(data->sensor_->device(), params); From patchwork Mon Oct 3 08:39:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17492 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 1FE3FC327C for ; Mon, 3 Oct 2022 08:40:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA8C062CD5; Mon, 3 Oct 2022 10:40:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786406; bh=ZlHQANlib8VtQD2q2+BXk+D7XiprQLm1D5jzuM3Wbjs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TX2YDoSNoIJRYBan/NKcpb67M5LXoLB22My9ErRH6/68uHfW4krxsR1RWg6QrBnSo Ycto7J98LnzqsgbmzuvSBkAp9ChIdPMQpLfgbDZnjA/DvauqrTxT9AxH7Z0lgDsvjZ ua3uB3mEDAEl2yFUyUt4Y3Baa3NZNfmOEAEnZARqZ2UG3aBA2Z2AO3fllfG761+IE+ xnbvxnsa7RVZkjXMgL9mrAxzrer7w6ahDO3Twnc+Yh1MR2HjBCEXfezJLmOs+eDluG lC70DMn0MhC06YrKz+5OsgZM0sXVUws1bO9rY7MW8O9gBa+xIdczMj3/LIRo8T0o/U qU1PgXhm5FZDA== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C07D62CD9 for ; Mon, 3 Oct 2022 10:40:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="R049tP6p"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id t4so6521238wmj.5 for ; Mon, 03 Oct 2022 01:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NpYU6IMqq+SK1SXSbBSyyB8EzXZknPjcSHcCyLN0vg4=; b=R049tP6pVqcNZ/yBTJjyd9mjJBFqIwnIavWbDJFyFqxsjuKsRiCFqeZ7R4X7rLs/C9 dTq5xu2Zaq8e9k6O6Gf+Llnw7fpwa+N45KBIB7GRJ9OpT+NU0NUIt6dI4FRRSZJVI9yD 5KQOo8mwCVGfN93fX0QM/Mna9jZgDbE2+YFF1b4cf8aXR3b4oPVCrEPoWSkVvVhWDHzd fhKoAia0S1utLw5mSweUSqaOm75a0S8DGmzUG8JxH0SReDgbAR1AWPl6lVB0Ibz1/UvK GRj6A0GFnMUTybpwfzaF68WKnGQfOmJtzBmpO9z3mgyIrtpBwv7K3rpy+MYOT71bzBzW inQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=NpYU6IMqq+SK1SXSbBSyyB8EzXZknPjcSHcCyLN0vg4=; b=bBdAHvirD24/MG60ey99RCZ1L+52jUyPa9r+qlY0GgfzDmcuMDg3rnmRkjTHv3i+fm TVjxWk7jl/CiWYugZhIPbi6jltCOxKmGwqtWukuIoHE05g/AeEPd6i3cOPWAmCMJgMh4 3WvDSGAmVcCMoCe/mjreixi3pasLHrG6TNYKd6BIoOyoDxkrzDIqDGfVck8y+bgW5BW6 KrTWxEgqEQ1Jn7Pcby8T2GMPFTZd9pjbImTc/15NLgMm25AhbMqwGsWSu8dtkGp50/UP 1C722G2FIHj8ydUDvUuml3WsGA9lGlgAt12vpaKAplqwt06StyzKpaTReCMOkunNDBDo W6sA== X-Gm-Message-State: ACrzQf2URHEAhahU1ExPO/jGK3hDF1tZZdo3QeYjk4IieeKZLcnXvceq BdmyzJ7+PCeIPrw6YWeSD/BdIHD72mr/7w== X-Google-Smtp-Source: AMsMyM6znJp/DuP7LOuH2uMmeE1LRXslogXJVAwr11GORxAqodkXiIiY+84uuAm+UVP/Md2nrqgtCw== X-Received: by 2002:a05:600c:3786:b0:3b4:ef37:afdb with SMTP id o6-20020a05600c378600b003b4ef37afdbmr6241142wmr.164.1664786400644; Mon, 03 Oct 2022 01:40:00 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:31 +0100 Message-Id: <20221003083934.31629-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/9] ipa: raspberrypi: Add pixel clock rate to the CameraMode structure 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The pixel clock rate will be used in subsequent commits to calculate line length durations. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/camera_mode.h | 2 ++ src/ipa/raspberrypi/raspberrypi.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index cda6ac4e200a..b8dae386aee8 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -39,4 +39,6 @@ struct CameraMode { uint32_t minFrameLength, maxFrameLength; /* sensitivity of this mode */ double sensitivity; + /* pixel clock rate */ + uint64_t pixelRate; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9b0ad4361c97..b6289f151677 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -331,6 +331,7 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) mode_.sensorHeight = sensorInfo.activeAreaSize.height; mode_.cropX = sensorInfo.analogCrop.x; mode_.cropY = sensorInfo.analogCrop.y; + mode_.pixelRate = sensorInfo.pixelRate; /* * Calculate scaling parameters. The scale_[xy] factors are determined From patchwork Mon Oct 3 08:39:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17493 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 2BBC1C3286 for ; Mon, 3 Oct 2022 08:40:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 933D462CF6; Mon, 3 Oct 2022 10:40:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786407; bh=yp1Ca44TUrCliyF0MFAjwGlo++S33jpIAjzO0B6VpRU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OjFe1t2XF2rJZAQXdhpMzikCr7355kcMVz17Z5RHcD39zXaujl2GuFjt9bAkWr6Ty Q+L+CoEzy24RXtYGSqJb06gKHMwITCZg26o2HXtobQtuiU2sFQrFEp/FYMM406OP3i PtdvSIMygufxjg8uUr3vBSOm2R+VhK8CvsTs/NJQElFqR3/Eq2VNhfjiL0DL/rucS3 x7wbacXWZ0ajv3AXtPtcPSsmeONHDkwFtD/tsrGcpxXKWebSRvitADZ7OrpsyOD8Lm 4HRptnEqggl/CqWhMS/2UD8E/k9t87FFHSt9mu9pWxydFZk7MoVzzKUhaHoxX60eSW 8v5Zt+ZaM9xYA== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EB3E562CE2 for ; Mon, 3 Oct 2022 10:40:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Uj+qw7RB"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id iv17so6536009wmb.4 for ; Mon, 03 Oct 2022 01:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=rXNz/fXg9imuWnncnruQtP1N4L91amcYsLTGIkaMrUg=; b=Uj+qw7RB0sVlK86rryO5wmhFIQnbKA2oGDEwhQj0OSxwtZ2njfHuhFfqUfnJerPPaS VsmVKoDyPpdJxcB/idHF0H7H0TmZb6wJNeZFSK8dhGCQYqB13H88U58qgQ83RjaJDG7F XpWTG0SL5uplo5+/1dyG2E1tNxL16tYMTvL+rePiFkLhDM+0Dl4VPMXFEODmQCqWX08h e/6mMXHvUFGGFDTZrpq3BNnJHwzcWojfLwE7yEY5iAnRGD0i8BuPzFERahn05pa/3D/I Xsh6rZDdEmAI7lXbc4Y+rdkz6DAxKz/KmPirrUwk/+dqp4MSLud7nLiUHFwfUrQx3NXu aWzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=rXNz/fXg9imuWnncnruQtP1N4L91amcYsLTGIkaMrUg=; b=mjmGUavMRoT4df1KM96XdAsXPzSo+bD+M/K+lelJEP8rPxULpsZ/iGiGciohWdxBj9 sVzCR9M9BBS71kaV1rEC8gO7quK3266WKBpW8tNJI4eBKV8jXJY5td03pYQuGOCd+tyD N+S0SPDBVGsLd0fdCXTT+PwlNhA641kqmXA8CR0URByHDdZRYKteWA8KxORWJQc6GPwm QUrZSlTG08oPxxn+w1zCCjUTEbyggeURwb3ofbCyWszlJh56XDaZpgnPIZOMVhNuyKyl WEOhC4HIOYu/xWV3NYptH8WRdYc69t3OKY3/xHJ5mDPv3yAgmHWvLQ3CNmXZj872Ar27 sqcA== X-Gm-Message-State: ACrzQf3ZT0ic3LqFgwJLCR/d4Sb6DAmhfbrl4XTpLHAjizPFTyARgW/2 RAh7iStUH2h1jmEt5eopYB83REV4YbfkHw== X-Google-Smtp-Source: AMsMyM5VCPjYUWZ+dqtSzAvrPxyEk6ZQA+VduFzSRA9ldl4r/h2BnFKOBFcqohGn+WQlCrGqTf0QNA== X-Received: by 2002:a7b:ca46:0:b0:3b4:7ff2:1ca8 with SMTP id m6-20020a7bca46000000b003b47ff21ca8mr6113957wml.11.1664786401468; Mon, 03 Oct 2022 01:40:01 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:32 +0100 Message-Id: <20221003083934.31629-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 6/9] ipa: raspberrypi: Add line length to DeviceStatus 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a lineLength field to the DeviceStatus structure to store the line length used for a particular frame. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/device_status.cpp | 1 + src/ipa/raspberrypi/controller/device_status.h | 4 +++- src/ipa/raspberrypi/raspberrypi.cpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/controller/device_status.cpp b/src/ipa/raspberrypi/controller/device_status.cpp index 2360a77bf1ea..c907efdd7511 100644 --- a/src/ipa/raspberrypi/controller/device_status.cpp +++ b/src/ipa/raspberrypi/controller/device_status.cpp @@ -12,6 +12,7 @@ std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) { out << "Exposure: " << d.shutterSpeed << " Frame length: " << d.frameLength + << " Line length: " << d.lineLength << " Gain: " << d.analogueGain; if (d.aperture) diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index 8f74e21b0c6e..4384c2149589 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -19,7 +19,7 @@ struct DeviceStatus { DeviceStatus() : shutterSpeed(std::chrono::seconds(0)), frameLength(0), - analogueGain(0.0) + lineLength(std::chrono::seconds(0)), analogueGain(0.0) { } @@ -29,6 +29,8 @@ struct DeviceStatus { libcamera::utils::Duration shutterSpeed; /* frame length given in number of lines */ uint32_t frameLength; + /* line length for the current frame */ + libcamera::utils::Duration lineLength; double analogueGain; /* 1.0/distance-in-metres, or 0 if unknown */ std::optional lensPosition; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index b6289f151677..5d6b22ef6813 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1108,7 +1108,9 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t exposureLines = sensorControls.get(V4L2_CID_EXPOSURE).get(); int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get(); + int32_t hblank = sensorControls.get(V4L2_CID_HBLANK).get(); + deviceStatus.lineLength = (mode_.width + hblank) * (1.0s / mode_.pixelRate); deviceStatus.shutterSpeed = helper_->exposure(exposureLines, mode_.minLineLength); deviceStatus.analogueGain = helper_->gain(gainCode); deviceStatus.frameLength = mode_.height + vblank; From patchwork Mon Oct 3 08:39:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17494 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 225A5C3285 for ; Mon, 3 Oct 2022 08:40:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF60D62CEC; Mon, 3 Oct 2022 10:40:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786408; bh=t1UCF8Q7mQ1fCcwA8Uu0vQ+Qnx4V99ck8EbaIkOuaX0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=baJPatHHfPA3TJSBM52IRMm8msjX0geFrNUUX5L8DN/qL/7cOnaPFPhvIXonmQRfb f7mBWqMmHWmBZsVT+2UMcMSPiJ3VNYHqBFJnFXY2F7OymljbzMEj7uX0G9RoxXMKEx Gfc7oEPBxGMzHMiiuhFJrY0RnH2KoiYjNf4LxRt/6ti71/R4eXMuMtC58MoGv/Vh0C OXfYNiFdvS85NrW0NMm7y6BjPhTRTrg2g+gOPEEHN0wnCvaPpaOkr/e45z2srf5PuC s43xo63JxAPGxzw4AbhOInmNZbwoQUkvL7kAyUNRfWldGlhuKxO+aKJ+0X44WJ3XKV DHaSletA6/PiA== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DC16D62CE3 for ; Mon, 3 Oct 2022 10:40:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="SMjEMFm/"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id 130-20020a1c0288000000b003b494ffc00bso8065064wmc.0 for ; Mon, 03 Oct 2022 01:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=PVBXrAWjZI0UrO8LOKOH/Cj3AAKHluADuH/8z3r3jUc=; b=SMjEMFm/C0aAIIwbEdIZlFb6L9ESxkegbgi3/BH4+KSRZVIAQ9AKdB9pf716LJhRdn eZ06fsWby1mojT79EyUbyzylZyF2DuPDL5y42W4ABQlbiTgSDHfENWtBU832qpW/Rfsi Z17IGr2Kwm+BdwUi7Ht0MWc1ywDJB8Uk0LRKFO3Tlee8oN5E7zy1DAdxZb20aYAwm5ty JxKRrBsMZRNRSmSwXVU9e/GyRPfabp3yPc7A/rtkSCq0rxHmiJKuhp2Pi0rkKvMt7DgF o/7OXPtzZytJ3wD2B324da3FlDvhsbQozwUtujR+u1MjuvtMhSMTw/6cAoow2a7DkJKP C1pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=PVBXrAWjZI0UrO8LOKOH/Cj3AAKHluADuH/8z3r3jUc=; b=rcMvUb674JHJupsN/8xIAlRJL6D/4o/LB25njg86NydJc7VgKHSucdu+7/LQOMJY91 uTKoqz8l4rNZHM+MJqwl/1KrlQUaELZ6B0HRSzlohInEOQ55eio9wyE6TuY6B9KuHtBg jhfdRIhCNNnwrZVUgL2JopCvsg7CFgHb4Z625unzmm6iTSx6b4MlXDad+aEiJLa0mvhm 3yCoXEP6TsKPlX3ADxFhf6ZShUHQB7aDVl0p3LouQFNb0ve7lRNOVGZchJMeRfYdaa37 +orEtDZ9TgQjIRwWI4+ipEXr52oEum5s44JZh8s1eoWT7x+dKUM2oCD003ETbmBEs/36 vEjA== X-Gm-Message-State: ACrzQf3mIwmJt/UExxdyzEFjSBDpyNkrdrKHtU39Vuw9zISvGgOWoN5S 31ZdhznqkcDSG0Zt2nsakoFe4xRlYJQVwg== X-Google-Smtp-Source: AMsMyM52tu5sNhzRPwgS6BPagflG9Qm5SqiPVngp+X8ZEXBLyqpJgbcXwC3Cg4zvZlRU4TTQaRc+rg== X-Received: by 2002:a7b:c417:0:b0:3b4:5c94:24c1 with SMTP id k23-20020a7bc417000000b003b45c9424c1mr6049361wmi.86.1664786402189; Mon, 03 Oct 2022 01:40:02 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:01 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:33 +0100 Message-Id: <20221003083934.31629-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 7/9] ipa: raspberrypi: Add line length calculations helper functions 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add CamHelper::hblankToLineLength() to calculate the line length duration from the horizontal blanking (in pixels) value. Add CamHelper::LineLengthToHblank() to calculate the horizontal blanking (in pixels) value from the line length duration. Add CamHelper::lineLengthPckToDuration() to calculate the line length duration from the line length in pixels. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 16 ++++++++++++++++ src/ipa/raspberrypi/cam_helper.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 916632f83037..c255ab0cb53f 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -19,6 +19,7 @@ using namespace RPiController; using namespace libcamera; using libcamera::utils::Duration; +using namespace std::literals::chrono_literals; namespace libcamera { LOG_DECLARE_CATEGORY(IPARPI) @@ -102,6 +103,21 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, return vblank; } +Duration CamHelper::hblankToLineLength(uint32_t hblank) const +{ + return (mode_.width + hblank) * (1.0s / mode_.pixelRate); +} + +uint32_t CamHelper::lineLengthToHblank(const Duration &lineLength) const +{ + return (lineLength * mode_.pixelRate / 1.0s) - mode_.width; +} + +Duration CamHelper::lineLengthPckToDuration(uint32_t lineLengthPck) const +{ + return hblankToLineLength(lineLengthPck - mode_.width); +} + void CamHelper::setCameraMode(const CameraMode &mode) { mode_ = mode; diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h index 1bbdd715d2b1..b5c0726ff00e 100644 --- a/src/ipa/raspberrypi/cam_helper.h +++ b/src/ipa/raspberrypi/cam_helper.h @@ -85,6 +85,9 @@ public: virtual uint32_t getVBlanking(libcamera::utils::Duration &exposure, libcamera::utils::Duration minFrameDuration, libcamera::utils::Duration maxFrameDuration) const; + libcamera::utils::Duration hblankToLineLength(uint32_t hblank) const; + uint32_t lineLengthToHblank(const libcamera::utils::Duration &duration) const; + libcamera::utils::Duration lineLengthPckToDuration(uint32_t lineLengthPck) const; virtual uint32_t gainCode(double gain) const = 0; virtual double gain(uint32_t gainCode) const = 0; virtual void getDelays(int &exposureDelay, int &gainDelay, From patchwork Mon Oct 3 08:39:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17495 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 B4E84C3287 for ; Mon, 3 Oct 2022 08:40:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4DD6D62CEA; Mon, 3 Oct 2022 10:40:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786409; bh=QtTA413PQEFNDkJeBHXFQjs3DSW2osPsuoHi+6m9fek=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eis0EIOtqGUyYTDkGeuBGIc2nkGT7MI4tJnXO2x1NLuSLIybDkv9rO+Ah5Xd+2FN3 ipAV+pEHOqmAd2x+0VvKmDB9t1FXXEv9bfStvCyIcAlInnBWH1tOCxbFpyvoIAfpnR NGnXJOfUxg639HIC5a50aS+24xSIXPElsuATihL0jN8HeGmJPEKFbYBUrV5K84rpZr sjJ2gO7uferlQIPHZQwoBRL3vXo+8Efw22bwTCfPy7j8FWhtX545kt8DphwIXnaihd HQWibeI8xXUeaweUO1ls1wdYvgxZ1QA49zoEuPvklMaU2qXA20PtInj9p5MJcUVY0G KuwQiH8gxq+pw== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D8D9762CD5 for ; Mon, 3 Oct 2022 10:40:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="oXQI6A6Y"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id e18so6525688wmq.3 for ; Mon, 03 Oct 2022 01:40:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=likkbiXx7bdJfq6g4Kcjz6CER4IRvJggljDa82NlX20=; b=oXQI6A6Ys0V4DA3WkXCwp5SJA76+tGv0rFzzxoS/UlS8JQnojjbRd71dWHd62zns38 L1ho4InA4P6NAvA6cZVcXlwhpszLXV4VSEl487POLGWPCXLWiRtRs/nRItuM9Gl1JD9Q /MDvn577r0ofwLF3+S4cbR00rD8R4yulJH/ZkkNLcTECsUmWw5iw22VSAoD0d05TUlUJ B+K7jVJ5DIRl1pvzCnu+AbwfePmOMf/W6Abs7+89JJT/7wSjaLeMnwH00T+KKeHzvn5J yCKX9P7mG6MPZHshcwCxAUS8W31xyvBDUDf01LkGI+FKKAJzhtosyhYzTWJtjoblHP5K GR/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=likkbiXx7bdJfq6g4Kcjz6CER4IRvJggljDa82NlX20=; b=cvljhLG4oamMiVYtCa8GXNPvcrVxF0eyGe7+tXxaD+OAmzLNxV5mNER7xJ+Zk05T0x tdqCD3aw/cpDu05S7e440JqKUd8d4VIvP9YuN8C8rNksvuL+LJYRUCTnKzujdVzcWijC G8YdO15tlNCUFjoKwkjIAAo+3F5fUq6o1roAc3EDSrhsY85bzwBh0RB//XHz/ahY2rNW Prdbvg38Ah1p+1w5NdALuXfOtL5xoh/SU96IojBREs8sLv+3KmquB+Ow1OEZY9cAog/G tjO8OAwSt+D7SICoRop81WiohZlDYEHN60vgYmZoO5n1LEbi2JjN9LpJWz11ecOpyl5a +ENg== X-Gm-Message-State: ACrzQf0K6Il2vDJXxyqw8hRpIROQLdUIZDsdJUeHTUNKuP0hDIrzC5HS BZ4iCQte8UqL8JIYMeX1SQNJphydcIzYqQ== X-Google-Smtp-Source: AMsMyM6fryKRsopOwp8JOqT1SYkvDXd/JCNwtWMQiCBNzsbjyzVNNr+qoryMJhad+pr1mpq8n0ln4g== X-Received: by 2002:a05:600c:42d4:b0:3b3:3de1:7564 with SMTP id j20-20020a05600c42d400b003b33de17564mr6265041wme.152.1664786403055; Mon, 03 Oct 2022 01:40:03 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:02 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:34 +0100 Message-Id: <20221003083934.31629-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 8/9] ipa: raspberrypi: Allow full line length control 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Rename CamHelper::getVBlanking to CamHelper::getBlanking, and update the calculations in that function to return both horizontal and vertical blanking values for a given exposure time and frame duration limits. The calculations are setup such that vertical blanking is extended to the maximum allowable value, and any remainder gets put into horizontal blanking. The calculated horizontal blanking value is now return to the pipeline handler to pass into DelayedControls to program into the sensor. Update the IPA to now specify the maximum frame duration from the maximum horizontal + vertical blanking values provided by the sensor mode. Additionally, the IPA now uses the frame specific horizontal blanking value (as returned by DelayedControls) in all instances. Signed-off-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.cpp | 47 +++++++++++++++++------ src/ipa/raspberrypi/cam_helper.h | 7 ++-- src/ipa/raspberrypi/cam_helper_imx477.cpp | 24 +++++++----- src/ipa/raspberrypi/cam_helper_imx519.cpp | 24 +++++++----- src/ipa/raspberrypi/raspberrypi.cpp | 45 +++++++++++++--------- 5 files changed, 95 insertions(+), 52 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index c255ab0cb53f..f5f034ece711 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -74,33 +75,57 @@ Duration CamHelper::exposure(uint32_t exposureLines, const Duration lineLength) return exposureLines * lineLength; } -uint32_t CamHelper::getVBlanking(Duration &exposure, - Duration minFrameDuration, - Duration maxFrameDuration) const +std::pair CamHelper::getBlanking(Duration &exposure, + Duration minFrameDuration, + Duration maxFrameDuration) const { - uint32_t frameLengthMin, frameLengthMax, vblank; - uint32_t exposureLines = CamHelper::exposureLines(exposure, mode_.minLineLength); + uint32_t frameLengthMin, frameLengthMax, vblank, hblank; + Duration lineLength = mode_.minLineLength; assert(initialized_); /* * minFrameDuration and maxFrameDuration are clamped by the caller * based on the limits for the active sensor mode. + * + * frameLengthMax gets calculated on the smallest line length as we do + * not want to extend that unless absolutely necessary. */ frameLengthMin = minFrameDuration / mode_.minLineLength; frameLengthMax = maxFrameDuration / mode_.minLineLength; + /* + * Watch out for exposureLines overflowing a uint32_t when the exposure + * time is extremely (extremely!) long - as happens when the IPA calculates + * the maximum possible exposure time. + */ + uint32_t exposureLines = std::min(CamHelper::exposureLines(exposure, lineLength), + std::numeric_limits::max() - frameIntegrationDiff_); + uint32_t frameLengthLines = std::clamp(exposureLines + frameIntegrationDiff_, + frameLengthMin, frameLengthMax); + + /* + * If our frame length lines is above the maximum allowed, see if we can + * extend the line length to accommodate the requested frame length. + */ + if (frameLengthLines > mode_.maxFrameLength) { + Duration lineLengthAdjusted = lineLength * frameLengthLines / mode_.maxFrameLength; + lineLength = std::min(mode_.maxLineLength, lineLengthAdjusted); + frameLengthLines = mode_.maxFrameLength; + } + + hblank = lineLengthToHblank(lineLength); + vblank = frameLengthLines - mode_.height; + /* * Limit the exposure to the maximum frame duration requested, and * re-calculate if it has been clipped. */ - exposureLines = std::min(frameLengthMax - frameIntegrationDiff_, exposureLines); - exposure = CamHelper::exposure(exposureLines, mode_.minLineLength); + exposureLines = std::min(frameLengthLines - frameIntegrationDiff_, + CamHelper::exposureLines(exposure, lineLength)); + exposure = CamHelper::exposure(exposureLines, lineLength); - /* Limit the vblank to the range allowed by the frame length limits. */ - vblank = std::clamp(exposureLines + frameIntegrationDiff_, - frameLengthMin, frameLengthMax) - mode_.height; - return vblank; + return { vblank, hblank }; } Duration CamHelper::hblankToLineLength(uint32_t hblank) const diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h index b5c0726ff00e..21ac101a0a0b 100644 --- a/src/ipa/raspberrypi/cam_helper.h +++ b/src/ipa/raspberrypi/cam_helper.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -82,9 +83,9 @@ public: const libcamera::utils::Duration lineLength) const; virtual libcamera::utils::Duration exposure(uint32_t exposureLines, const libcamera::utils::Duration lineLength) const; - virtual uint32_t getVBlanking(libcamera::utils::Duration &exposure, - libcamera::utils::Duration minFrameDuration, - libcamera::utils::Duration maxFrameDuration) const; + virtual std::pair getBlanking(libcamera::utils::Duration &exposure, + libcamera::utils::Duration minFrameDuration, + libcamera::utils::Duration maxFrameDuration) const; libcamera::utils::Duration hblankToLineLength(uint32_t hblank) const; uint32_t lineLengthToHblank(const libcamera::utils::Duration &duration) const; libcamera::utils::Duration lineLengthPckToDuration(uint32_t lineLengthPck) const; diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 76a82cc51378..19a5e471c27e 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -46,8 +46,8 @@ public: uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; void prepare(libcamera::Span buffer, Metadata &metadata) override; - uint32_t getVBlanking(Duration &exposure, Duration minFrameDuration, - Duration maxFrameDuration) const override; + std::pair getBlanking(Duration &exposure, Duration minFrameDuration, + Duration maxFrameDuration) const override; void getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay, int &hblankDelay) const override; bool sensorEmbeddedDataPresent() const override; @@ -118,15 +118,19 @@ void CamHelperImx477::prepare(libcamera::Span buffer, Metadata &m } } -uint32_t CamHelperImx477::getVBlanking(Duration &exposure, - Duration minFrameDuration, - Duration maxFrameDuration) const +std::pair CamHelperImx477::getBlanking(Duration &exposure, + Duration minFrameDuration, + Duration maxFrameDuration) const { uint32_t frameLength, exposureLines; unsigned int shift = 0; - frameLength = mode_.height + CamHelper::getVBlanking(exposure, minFrameDuration, - maxFrameDuration); + auto [vblank, hblank] = CamHelper::getBlanking(exposure, minFrameDuration, + maxFrameDuration); + + frameLength = mode_.height + vblank; + Duration lineLength = hblankToLineLength(hblank); + /* * Check if the frame length calculated needs to be setup for long * exposure mode. This will require us to use a long exposure scale @@ -144,12 +148,12 @@ uint32_t CamHelperImx477::getVBlanking(Duration &exposure, if (shift) { /* Account for any rounding in the scaled frame length value. */ frameLength <<= shift; - exposureLines = CamHelperImx477::exposureLines(exposure, mode_.minLineLength); + exposureLines = CamHelperImx477::exposureLines(exposure, lineLength); exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); - exposure = CamHelperImx477::exposure(exposureLines, mode_.minLineLength); + exposure = CamHelperImx477::exposure(exposureLines, lineLength); } - return frameLength - mode_.height; + return { frameLength - mode_.height, hblank }; } void CamHelperImx477::getDelays(int &exposureDelay, int &gainDelay, diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index 9dff1eeb899f..d2eb171912da 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -46,8 +46,8 @@ public: uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; void prepare(libcamera::Span buffer, Metadata &metadata) override; - uint32_t getVBlanking(Duration &exposure, Duration minFrameDuration, - Duration maxFrameDuration) const override; + std::pair getBlanking(Duration &exposure, Duration minFrameDuration, + Duration maxFrameDuration) const override; void getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay, int &hblankDelay) const override; bool sensorEmbeddedDataPresent() const override; @@ -118,15 +118,19 @@ void CamHelperImx519::prepare(libcamera::Span buffer, Metadata &m } } -uint32_t CamHelperImx519::getVBlanking(Duration &exposure, - Duration minFrameDuration, - Duration maxFrameDuration) const +std::pair CamHelperImx519::getBlanking(Duration &exposure, + Duration minFrameDuration, + Duration maxFrameDuration) const { uint32_t frameLength, exposureLines; unsigned int shift = 0; - frameLength = mode_.height + CamHelper::getVBlanking(exposure, minFrameDuration, - maxFrameDuration); + auto [vblank, hblank] = CamHelper::getBlanking(exposure, minFrameDuration, + maxFrameDuration); + + frameLength = mode_.height + vblank; + Duration lineLength = hblankToLineLength(hblank); + /* * Check if the frame length calculated needs to be setup for long * exposure mode. This will require us to use a long exposure scale @@ -144,12 +148,12 @@ uint32_t CamHelperImx519::getVBlanking(Duration &exposure, if (shift) { /* Account for any rounding in the scaled frame length value. */ frameLength <<= shift; - exposureLines = CamHelperImx519::exposureLines(exposure, mode_.minLineLength); + exposureLines = CamHelperImx519::exposureLines(exposure, lineLength); exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); - exposure = CamHelperImx519::exposure(exposureLines, mode_.minLineLength); + exposure = CamHelperImx519::exposure(exposureLines, lineLength); } - return frameLength - mode_.height; + return { frameLength - mode_.height, hblank }; } void CamHelperImx519::getDelays(int &exposureDelay, int &gainDelay, diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 5d6b22ef6813..497a83939ae6 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -315,7 +315,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) } startConfig->dropFrameCount = dropFrameCount_; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength; startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); firstStart_ = false; @@ -462,7 +462,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, */ ControlInfoMap::Map ctrlMap = ipaControls; const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength; ctrlMap[&controls::FrameDurationLimits] = ControlInfo(static_cast(minSensorFrameDuration.get()), static_cast(maxSensorFrameDuration.get())); @@ -475,7 +475,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, * will limit the maximum control value based on the current VBLANK value. */ Duration maxShutter = Duration::max(); - helper_->getVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); + helper_->getBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); const uint32_t exposureMin = sensorCtrls_.at(V4L2_CID_EXPOSURE).min().get(); ctrlMap[&controls::ExposureTime] = @@ -552,7 +552,7 @@ void IPARPi::reportMetadata() deviceStatus->shutterSpeed.get()); libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogueGain); libcameraMetadata_.set(controls::FrameDuration, - helper_->exposure(deviceStatus->frameLength, mode_.minLineLength).get()); + helper_->exposure(deviceStatus->frameLength, deviceStatus->lineLength).get()); if (deviceStatus->sensorTemperature) libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature); } @@ -1110,8 +1110,8 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get(); int32_t hblank = sensorControls.get(V4L2_CID_HBLANK).get(); - deviceStatus.lineLength = (mode_.width + hblank) * (1.0s / mode_.pixelRate); - deviceStatus.shutterSpeed = helper_->exposure(exposureLines, mode_.minLineLength); + deviceStatus.lineLength = helper_->hblankToLineLength(hblank); + deviceStatus.shutterSpeed = helper_->exposure(exposureLines, deviceStatus.lineLength); deviceStatus.analogueGain = helper_->gain(gainCode); deviceStatus.frameLength = mode_.height + vblank; @@ -1157,7 +1157,7 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration) { const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength; /* * This will only be applied once AGC recalculations occur. @@ -1178,11 +1178,11 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur /* * Calculate the maximum exposure time possible for the AGC to use. - * getVBlanking() will update maxShutter with the largest exposure + * getBlanking() will update maxShutter with the largest exposure * value possible. */ Duration maxShutter = Duration::max(); - helper_->getVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); + helper_->getBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.getAlgorithm("agc")); @@ -1200,10 +1200,11 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) */ gainCode = std::min(gainCode, maxSensorGainCode_); - /* getVBlanking might clip exposure time to the fps limits. */ + /* getBlanking might clip exposure time to the fps limits. */ Duration exposure = agcStatus->shutterTime; - int32_t vblanking = helper_->getVBlanking(exposure, minFrameDuration_, maxFrameDuration_); - int32_t exposureLines = helper_->exposureLines(exposure, mode_.minLineLength); + auto [vblank, hblank] = helper_->getBlanking(exposure, minFrameDuration_, maxFrameDuration_); + int32_t exposureLines = helper_->exposureLines(exposure, + helper_->hblankToLineLength(hblank)); LOG(IPARPI, Debug) << "Applying AGC Exposure: " << exposure << " (Shutter lines: " << exposureLines << ", AGC requested " @@ -1211,14 +1212,22 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) << agcStatus->analogueGain << " (Gain Code: " << gainCode << ")"; - /* - * Due to the behavior of V4L2, the current value of VBLANK could clip the - * exposure time without us knowing. The next time though this function should - * clip exposure correctly. - */ - ctrls.set(V4L2_CID_VBLANK, vblanking); + ctrls.set(V4L2_CID_VBLANK, static_cast(vblank)); ctrls.set(V4L2_CID_EXPOSURE, exposureLines); ctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode); + + /* + * At present, there is no way of knowing if a control is read-only. + * As a workaround, assume that if the minimum and maximum values of + * the V4L2_CID_HBLANK control are the same, it implies the control + * is read-only. This seems to be the case for all the cameras our IPA + * works with. + * + * \todo The control API ought to have a flag to specify if a control + * is read-only which could be used below. + */ + if (mode_.minLineLength != mode_.maxLineLength) + ctrls.set(V4L2_CID_HBLANK, static_cast(hblank)); } void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) From patchwork Mon Oct 3 08:39:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17496 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 7BBD7C3288 for ; Mon, 3 Oct 2022 08:40:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0AEF462CFA; Mon, 3 Oct 2022 10:40:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786410; bh=AaC6lAuRrIb0QPhH2liWi7eEXXWDnFn2WPH3DcoZBRk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xt1TX/h9YNHL83sKzxUBsfw/CB7YpWTB6eF/ykSZt0U0TnIiuElq3ndKEfmtFeDMY BuJUJU7MViViiKGKOfEkawtBrYLiT/jSchUo+3y0sKecFD12uWGp46WKjlCySDPOqe AYU1lWHz2M0S715NJ6Bm/gp7uHZRE3KcFh8zyyRQPdB35o/9DXcB5/wJJ2PBR73HKW Z67mKDWt6UkQ5/b/4JobTCRTCGjh7ez/3R2D+WaV5QZZuW8Sv03CLFtab6wUIDILKP GfrqzYvyRsydQ8PmQoUreq3TO+x/+ZZekfmQJYiT4d9QwRioIE7wm13aTK9VCkjIUj BIbYEC/ZKND6Q== Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B36362CEA for ; Mon, 3 Oct 2022 10:40:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="aemwqF3u"; dkim-atps=neutral Received: by mail-wm1-x332.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso5415976wmq.2 for ; Mon, 03 Oct 2022 01:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ymnK8vfNa3P0z8WJVisbeR9rTR8rDaZY2QIaaCwwkRY=; b=aemwqF3ug8hns24q4V7K5ziC6rX/4XT1ct/Ypymgw+OlM5hTzGEIoIL6tpI+i7q3CB FJpv07ss+vCZyJUNDRRECScR5NHnqp4H6WKn00H6MtVEGlnVXnRUd00E770oWs9OySHd zIy9Abf21TyRlifp2WWtBzRVFU530fc+tUhfq7TveiH1W7swovmq1GIZP4yeGgUPjdbC rJham2vMZmLtLUhvhzQ2xxhKeXZ5RphN45Uo2FBjyada7BtbQc5vOU6VV+9T3eNxnShF v4doupGq+nrOzvtu8qQ+GjgcMbPEoklaq+Y9Ke5QjcQC05dL/CDAujgx8NOXELI+N2+G oABg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ymnK8vfNa3P0z8WJVisbeR9rTR8rDaZY2QIaaCwwkRY=; b=JBbjvL+kI/yj560HQQvh+jUpmA33GtAyB61ncUUOtl4aBjXlR900CUEzUv7Nnzarla ufKXRJjD1YYK5XiGQC/HLNDNauIhUlOpwBZ7hv+Ze/LcLHedVEWpwcY75NAvGFugyT6b Vaof6clB1TNVGaG6jUedLPyjTNJ+ZNT1tO8UV55Hu1jRZjiZGg6yd0rzmJOmHmDu9TlC U/3tFTNpao9+LUYls8SUvFPrg5EZWtIUlDGpJmjX7LTZ4HbaK2TgtznLU/ZAwgLFj76Z I0qjg3aOk4pfrKlwdArU9aAdOxPmelD5RLBxyLF3/J0hsUic6YaHmKduhgT7j+sDZ2IX AdKQ== X-Gm-Message-State: ACrzQf3ChqIEBO8UGNQMZINra9uz49IwFFcCCHG+ByQLyo+8fSPe5jmH oZF1iZsTyLwn7067+jCVGGTxT6Aimpb2Bg== X-Google-Smtp-Source: AMsMyM5i7NLKbjZ3p4bVR7uhJ7ND9ON7zqlps2L9QFumN9CPUw8MbxaTsz6lE4cl9oEZqEWEex7l2Q== X-Received: by 2002:a05:600c:4f46:b0:3b4:fed8:331e with SMTP id m6-20020a05600c4f4600b003b4fed8331emr6227992wmq.198.1664786403660; Mon, 03 Oct 2022 01:40:03 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:35 +0100 Message-Id: <20221003083934.31629-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 9/9] ipa: raspberrypi: Extract line length from the embedded data parser 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update the imx219, imx477 and imx519 parsers to extract the line length values from the embedded data stream and use these values in the deviceStatus metadata, replacing the DelayedControls provided values. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 3 ++- src/ipa/raspberrypi/cam_helper_imx219.cpp | 9 +++++++-- src/ipa/raspberrypi/cam_helper_imx477.cpp | 9 +++++++-- src/ipa/raspberrypi/cam_helper_imx519.cpp | 9 +++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index f5f034ece711..1811d231ad40 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -228,7 +228,7 @@ void CamHelper::parseEmbeddedData(Span buffer, metadata.merge(parsedMetadata); /* - * Overwrite the exposure/gain, frame length and sensor temperature values + * Overwrite the exposure/gain, line/frame length and sensor temperature values * in the existing DeviceStatus with values from the parsed embedded buffer. * Fetch it first in case any other fields were set meaningfully. */ @@ -242,6 +242,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutterSpeed = parsedDeviceStatus.shutterSpeed; deviceStatus.analogueGain = parsedDeviceStatus.analogueGain; deviceStatus.frameLength = parsedDeviceStatus.frameLength; + deviceStatus.lineLength = parsedDeviceStatus.lineLength; if (parsedDeviceStatus.sensorTemperature) deviceStatus.sensorTemperature = parsedDeviceStatus.sensorTemperature; diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 98a3b31956ec..c3337ed08466 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -32,8 +32,11 @@ constexpr uint32_t expHiReg = 0x15a; constexpr uint32_t expLoReg = 0x15b; constexpr uint32_t frameLengthHiReg = 0x160; constexpr uint32_t frameLengthLoReg = 0x161; +constexpr uint32_t lineLengthHiReg = 0x162; +constexpr uint32_t lineLengthLoReg = 0x163; constexpr std::initializer_list registerList [[maybe_unused]] - = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg }; + = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg }; class CamHelperImx219 : public CamHelper { @@ -94,8 +97,10 @@ void CamHelperImx219::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 19a5e471c27e..bc769ca75baa 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -35,9 +35,12 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; constexpr uint32_t temperatureReg = 0x013a; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, temperatureReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg, temperatureReg }; class CamHelperImx477 : public CamHelper { @@ -175,8 +178,10 @@ void CamHelperImx477::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); deviceStatus.sensorTemperature = std::clamp(registers.at(temperatureReg), -20, 80); diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index d2eb171912da..c7262aa0b6e6 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -36,8 +36,11 @@ constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; constexpr uint32_t frameLengthHiReg = 0x0340; constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; constexpr std::initializer_list registerList = - { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg }; + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg, + lineLengthHiReg, lineLengthLoReg }; class CamHelperImx519 : public CamHelper { @@ -175,8 +178,10 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters, { DeviceStatus deviceStatus; + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), - mode_.minLineLength); + deviceStatus.lineLength); deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);