From patchwork Mon Jan 22 12:13:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 19445 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 80460C323E for ; Mon, 22 Jan 2024 12:14:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9600962944; Mon, 22 Jan 2024 13:14:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="T/HaL2iK"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9AEFC61D30 for ; Mon, 22 Jan 2024 13:14:15 +0100 (CET) Received: from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp [175.177.49.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 607A074A; Mon, 22 Jan 2024 13:13:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1705925582; bh=t5fvTXS2pYa6De0aX3+TnX/c1drxrbyRYTDGlGolUm8=; h=From:To:Cc:Subject:Date:From; b=T/HaL2iKaKlvmarEU26UMZCwEGoAdbnekQS1KVctemMcecNMRu+LS7e1rVS0BKH9E jAHBVSe4OEAvnMWVrRUkCYs1UCwW6agEEZTknJxBrLyUh5sapL4D+/H5j8jYXUrrDD yYoDa9AJ1zksLRdnORdeCp/UWaOy9q/zWnRJ1rQg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2] libcamera: camera_sensor: Cache pixel rate Date: Mon, 22 Jan 2024 21:13:58 +0900 Message-Id: <20240122121358.3426521-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Cache the pixel rate at set format time instead of fetching it from the v4l2 subdev every time it's needed. It needs to be cached at set format time as opposed to initialization time as some sensor drives (eg. imx708) change the pixel rate depending on the mode. Signed-off-by: Paul Elder --- Changes in v2: - Cache the pixel rate at set format time instead of at initialization time --- include/libcamera/internal/camera_sensor.h | 2 ++ src/libcamera/camera_sensor.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 60a8b106d..da3bf12b3 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -105,6 +105,8 @@ private: std::string model_; std::string id_; + uint64_t pixelRate_; + V4L2Subdevice::Formats formats_; std::vector mbusCodes_; std::vector sizes_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 0ef78d9c8..127610321 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -515,6 +515,9 @@ int CameraSensor::initProperties() properties_.set(properties::draft::ColorFilterArrangement, cfa); } + ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE }); + pixelRate_ = ctrls.get(V4L2_CID_PIXEL_RATE).get(); + return 0; } @@ -814,6 +817,9 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format, Transform transform) if (ret) return ret; + ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE }); + pixelRate_ = ctrls.get(V4L2_CID_PIXEL_RATE).get(); + updateControlInfo(); return 0; } @@ -1080,7 +1086,7 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const return -EINVAL; } - info->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get(); + info->pixelRate = pixelRate_; const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); info->minLineLength = info->outputSize.width + hblank.min().get();