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