From patchwork Thu Apr 27 14:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18569 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 AADD1C0DA4 for ; Thu, 27 Apr 2023 14:48:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA068627E8; Thu, 27 Apr 2023 16:48:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682606884; bh=lqfECWfOb42pSWi49n7DEpmr+1CaFoHQcjYReous4kM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=M0qBKdG4vjPJkBMOikSHdQrOFDKpTWydJceCufAKVnmOcXwVUpP0YrzS1FjnyokdK FBBz5uWjydJ/+05yEgjHsEx+JLor8pjG0ZS+h/tGs69sCldfFJQ5323XOBx3LevgJB PSjDSf87J7ro37qLFs14iTGPjaV0Ibzqx51uUBchavJbEykusNlH+ODE1SotV32Tsf h8aNsZj4wsHg5Ky5oZboeHlBWVQWPteOgPmCQvtO86xI12KAn/SJoV1YTiUqiUqj5W A9mH+QRy3v8Yy76kkgxwrEoHWtiL/p1fn2LBxtSHEo0QRaNFTKjWVBIVlST1dFz4Q2 rrG0ulrhtRnQA== 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 3F929627DF for ; Thu, 27 Apr 2023 16:48:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="luP5HkKr"; dkim-atps=neutral Received: from uno.lan (unknown [IPv6:2001:b07:5d2e:52c9:1cf0:b3bc:c785:4625]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ED5609B9; Thu, 27 Apr 2023 16:47:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1682606868; bh=lqfECWfOb42pSWi49n7DEpmr+1CaFoHQcjYReous4kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=luP5HkKrF1L+v+5h6TxdVYhFgJ84ysPNrE+uoe35VvjUwNBSg19V/gqgbEkw0RuJj ZWUOT7XbdErPbqwxkkJ5R3854scRFqYbhwsP5Jm1HG47S1/WQcrhP2E5oKxIH0V3AL YE/AAbK02/JnXXpEgSgsuEqXQ+Ws4Vxadj+PVfCY= To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Apr 2023 16:47:37 +0200 Message-Id: <20230427144740.64075-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230427144740.64075-1-jacopo.mondi@ideasonboard.com> References: <20230427144740.64075-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/6] libcamera: imx8-isi: Automatically select media bus code 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 Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The ISICameraConfiguration::validate() function selects which media bus format to configure the sensor with based on the pixel format of the first configured stream using the media bus code associated to it in the formatsMap_ map. In order to remove the PixelFormamt-to-mbus-code association in formatsMap_ provide a wrapper function for the newly introduced getRawMediaBusFormat() and getYuvMediaBusFormat() that automatically selects what media bus format to use based on the first stream pixel format. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Daniel Scally Tested-by: Daniel Scally Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 148f108d630f..ee3dc4ad4d3e 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -61,6 +61,7 @@ public: unsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const; unsigned int getYuvMediaBusFormat(const PixelFormat &pixelFormat) const; + unsigned int getMediaBusFormat(PixelFormat *pixelFormat) const; std::unique_ptr sensor_; std::unique_ptr csis_; @@ -318,6 +319,15 @@ unsigned int ISICameraData::getYuvMediaBusFormat(const PixelFormat &pixelFormat) return supportedCodes[0]; } +unsigned int ISICameraData::getMediaBusFormat(PixelFormat *pixelFormat) const +{ + if (PixelFormatInfo::info(*pixelFormat).colourEncoding == + PixelFormatInfo::ColourEncodingRAW) + return getRawMediaBusFormat(pixelFormat); + + return getYuvMediaBusFormat(*pixelFormat); +} + /* ----------------------------------------------------------------------------- * Camera Configuration */ @@ -631,16 +641,16 @@ CameraConfiguration::Status ISICameraConfiguration::validate() * image quality in exchange of a usually slower frame rate. * Usage of the STILL_CAPTURE role could be consider for this. */ - const PipeFormat &pipeFmt = formatsMap_.at(config_[0].pixelFormat); - Size maxSize; for (const auto &cfg : config_) { if (cfg.size > maxSize) maxSize = cfg.size; } + PixelFormat pixelFormat = config_[0].pixelFormat; + V4L2SubdeviceFormat sensorFormat{}; - sensorFormat.mbus_code = pipeFmt.sensorCode; + sensorFormat.mbus_code = data_->getMediaBusFormat(&pixelFormat); sensorFormat.size = maxSize; LOG(ISI, Debug) << "Computed sensor configuration: " << sensorFormat;