From patchwork Thu Oct 6 13:17:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17546 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 C390FC3285 for ; Thu, 6 Oct 2022 13:18:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67A9962D12; Thu, 6 Oct 2022 15:18:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665062281; bh=LiJykRHySPwMITHpitnktWgOfZ/SebcLk52NJaiBcf4=; 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=O57b42VunBALK7mcc7U1fm/6oDYrjq6se3PIYDqwsCjgalbtILj49xD6c5z4ewk2Q Rd1KArh6iP4hXiNNx8JkQ+a1As59Yr8chFnv7q+suJOZeEp8I2KdfODKBjHRoC2Ty4 nqFhXWKG9tPNxPSXrYvYwaprb3fCG4URZbLkVmWtJa1J2kNAOo5g4BQerfn+RTKu2a kqOOdFDzAjspr/QJn+xPePKVn35mJhfiD6Gg++vEcF99qkSOqYgfbaEpfV9gRaWUJY JJPA/Oxl1DOeZ3uuSkZBn0jJhGN+ZcmjXd/mYUtf4tL//bQlYHh7JLeysIdjShOJi7 f9GF0dFi8IIgw== Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EF74A62CF1 for ; Thu, 6 Oct 2022 15:17:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="B2ewzxDV"; dkim-atps=neutral Received: by mail-wr1-x429.google.com with SMTP id j7so2695203wrr.3 for ; Thu, 06 Oct 2022 06:17:57 -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=3A80b1nsNT2hQAo3ttEhnCdEVBVLiw4c2Pt97Cf+Zds=; b=B2ewzxDVtVP/tfhkO2vOO4/HcCPCU5BloHFnti2+5oUefgfBVb4WZz5neqpitKZV8h xHqDM8KOdWzJkpNyd21fFXL/PIEIL710vk0YJewuxQjTh1RWjoSNCIhwbAhghPDzCYDW S/i7tQudc6pDkTd/1mJzdblmDbIC8cL+C+SKA2DIjllIgkUlfjoZP1/gkTV7iHp2PZq3 3LwHFiSqr3D2vAs0I/7dfL5i23WJbxMy91/P2JezCM5kYIas7lhhKcFLPbiZGs+PlatI bU7H1hzFT/SNoXMQ87oHIgZ/Z6ZpPu0DnEpIIt2Hapd3tTVakqECOEr7MYoFbIAWDsAa M/2g== 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=3A80b1nsNT2hQAo3ttEhnCdEVBVLiw4c2Pt97Cf+Zds=; b=odwIpT7woJOdcG3trAsY/do8TkW3Sn2qLsz6MQ1asPZE1V0bOcX5q/w7Qh/5SE1/lP E+zsdacKrOzBmTle5u7mQtr/CM1d1eshPLo0+SqRkfNLdzWdDBcFW3Po/4u3oKeAh4Jg XQk4uF/ugOb2qsdUA+4DA8tCmmw0GbwyfrxFCyatm2ZrspJH2iEueq1Cxmd5dRHlFaeL BRQuPYyg+HkTzX/NvpJ1jF+XLEnSicCU5IJbx/t5tkLXBtxLtZQZAXmQKWBtjDUa0DSS 6X0Z+x7UhLiEN5BGgnQ7HBLPJ+WN8SKzyV6wnf/RSpOivdPcevsY+4JvLz36vEynUKOW 1yoA== X-Gm-Message-State: ACrzQf1VsOkqGwFTVK6a8zQUr6bn6cY99fTNc57nUh9KNZ/xu4JpmAbw sPFhQdCgiLwEWQObvkqPzSklJSi0Qf9cLQ== X-Google-Smtp-Source: AMsMyM7n8MDXVQefyKPdgaZajwWIzILh1oOg1jou6jVKz0Pa6yxpbAjdBJk3HZY7WE5/MiR9jcZQyw== X-Received: by 2002:a5d:65c4:0:b0:22c:dbdd:7177 with SMTP id e4-20020a5d65c4000000b0022cdbdd7177mr3053983wrw.470.1665062277356; Thu, 06 Oct 2022 06:17:57 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 06:17:56 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Oct 2022 14:17:39 +0100 Message-Id: <20221006131744.5179-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221006131744.5179-1-naush@raspberrypi.com> References: <20221006131744.5179-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 05/10] 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 available when calling IPARPi::configure(). Signed-off-by: Naushir Patuck Tested-by: Dave Stevenson 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_imx296.cpp | 6 ++++-- 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 + 11 files changed, 28 insertions(+), 16 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 45214531626e..dd7236f1b693 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -107,7 +107,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 @@ -116,6 +116,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 6771829a56da..db2387afc993 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_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp index d86ff3878983..ecb845e76e12 100644 --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp @@ -23,7 +23,8 @@ public: double gain(uint32_t gainCode) const override; uint32_t exposureLines(const Duration exposure, const Duration lineLength) const override; Duration exposure(uint32_t exposureLines, const Duration lineLength) const override; - void getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const override; private: static constexpr uint32_t minExposureLines = 1; @@ -66,11 +67,12 @@ Duration CamHelperImx296::exposure(uint32_t exposureLines, } void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay, - int &vblankDelay) const + int &vblankDelay, int &hblankDelay) const { exposureDelay = 2; gainDelay = 2; vblankDelay = 2; + hblankDelay = 2; } static CamHelper *create() 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 bcb5bb8a1e73..61997326f7f9 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1289,6 +1289,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);