From patchwork Thu Jun 30 13:38:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16474 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 B4FF3BE173 for ; Thu, 30 Jun 2022 13:39:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 568C7656B0; Thu, 30 Jun 2022 15:39:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656596388; bh=foCxZ0go4cL640cwJ1RY+DLYNuS4Pp9tGf3lwEIiy6U=; 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=dmJZSZ+hQsVDRp0DKDQ7za2us2BXYgAzcA9Ix5paFb1g+Axna4/2xfUBmlSkunJ9j n8o/h9pP8q7CPH2eyNLn+xMjelgBCXWZt1l/OWmW4iRd851bQd4Mc4Vae6agCeu6TC sk+cm2ii/pJFnXqukKeiXF0d5AC4bCOU0wlc14iinG4CEV6UaDDcz2tMDWTAQri5Mo Zb+Jw61tiHliopN/iEQV4wQ0n1CQE4JfxXRFi5g8EmYoTKjFaVVrFlViPGAlFHN0Re 7T6k0P2JTXcVNymJwfAuEhTRr1Xh55SYdDCLP/oI2Hy86AlHezZkmTvbCWvTuO7BSL TsX7Pe/KXIwlQ== Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C914D6564F for ; Thu, 30 Jun 2022 15:39:39 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 7E23A24000A; Thu, 30 Jun 2022 13:39:38 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Jun 2022 15:38:55 +0200 Message-Id: <20220630133902.321099-17-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630133902.321099-1-jacopo@jmondi.org> References: <20220630133902.321099-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 16/23] libcamera: IPACameraSensorInfo: Add VBLANK 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The IPA module needs the vertical blanking value to calculate the total frame size. In order to prepare removing usage of V4L2_CID_VBLANK in IPA modules, add the vblank value to the IPACameraSensorInfo structure. Signed-off-by: Jacopo Mondi --- include/libcamera/ipa/core.mojom | 6 ++++++ src/libcamera/camera_sensor/camera_sensor.cpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index 74f3339e56f2..d122fb7add4d 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -178,6 +178,11 @@ module libcamera; * The total line length in pixel clock periods, including blanking. */ +/** + * \var IPACameraSensorInfo::vblank + * \brief The vertical blanking, expressed in number of lines + */ + /** * \var IPACameraSensorInfo::minFrameLength * \brief The minimum allowable frame length in units of lines @@ -218,6 +223,7 @@ struct IPACameraSensorInfo { uint64 pixelRate; uint32 lineLength; + uint32 vblank; uint32 minFrameLength; uint32 maxFrameLength; diff --git a/src/libcamera/camera_sensor/camera_sensor.cpp b/src/libcamera/camera_sensor/camera_sensor.cpp index 02810c7c5ad0..08b96b9c3b40 100644 --- a/src/libcamera/camera_sensor/camera_sensor.cpp +++ b/src/libcamera/camera_sensor/camera_sensor.cpp @@ -1008,6 +1008,21 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get(); + /* + * Retrieve the vertical blanking. + * + * We can't rely on the valued cached as vblank can be modified while + * streaming to adjust the frame rate. + */ + ControlList ctrls = subdev_->getControls({ V4L2_CID_VBLANK }); + if (ctrls.empty()) { + LOG(CameraSensor, Error) + << "Failed to retrieve camera info controls"; + return -EINVAL; + } + + info->vblank = ctrls.get(V4L2_CID_VBLANK).get(); + return 0; }