From patchwork Mon Mar 13 09:19:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18386 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 37A1DC329C for ; Mon, 13 Mar 2023 09:20:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B0C6962706; Mon, 13 Mar 2023 10:20:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678699207; bh=2kwdxLJ8KK9CeegsffhjUTIUNbeuof79GYeeS/CAa3I=; 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=z07rUkOjpHJ++rjXP8Kh4X+8HySunqCjrGbNO3A0cbCQ2z6WmhcDvmoJPu+Y+QNxa 5RnMSAYv6TGK0d4VzJVOksTrX5wa+pJDUnifX97QM9VHTccxyOTXufMXQLYxfDKlrg tHKWODr6AIV8ukl3iKWT8sMnI4+rissfWNyKle9EYMYUV3dRsityNzX7M/5J8s03l+ feOKS6LZ82I5+yOgDmzSPKzb90QJppilmsvOt0D7jLn2EWqaCQ8SexoqM0GlgUg4Ul kRZz8pgwdT8YmvaeghmSnc5jLDPPQxo4JJ3RZmAyx0coVM3yf8UgSG8ySPinzPcovX T4WXhe7HrWI2A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 241CC6270E for ; Mon, 13 Mar 2023 10:20:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SPeP6HRU"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-79-33-55-183.retail.telecomitalia.it [79.33.55.183]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C6E88CC; Mon, 13 Mar 2023 10:20:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1678699203; bh=2kwdxLJ8KK9CeegsffhjUTIUNbeuof79GYeeS/CAa3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPeP6HRUNE78EISjtYgELzu5wbEGwov+nbT1a3v2s/ZbbFY3/eaka40Ix7+J7X1Ki QMKakF8t9Gwezo4tsFuJ7Yfw33qg9SHqJCyu239gIjZbOz/ZrxP6ETDZO8z4/Gwwoz UouL3MS28H5xyUs9edMSNQn28ZQWXn6hhoGQrPDI= To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Mar 2023 10:19:41 +0100 Message-Id: <20230313091944.9530-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230313091944.9530-1-jacopo.mondi@ideasonboard.com> References: <20230313091944.9530-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 390e82b6947f..146ba7465012 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(PixelFormat *pixelFormat) const; + unsigned int getMediaBusFormat(PixelFormat *pixelFormat) const; std::unique_ptr sensor_; std::unique_ptr csis_; @@ -315,6 +316,15 @@ unsigned int ISICameraData::getYuvMediaBusFormat(PixelFormat *pixelFormat) const 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 */ @@ -628,16 +638,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;