From patchwork Sun Jan 29 13:58:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18220 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 D567DBEFBE for ; Sun, 29 Jan 2023 13:58:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A0697625F6; Sun, 29 Jan 2023 14:58:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675000731; bh=7I/GCOvyVNiB9qdM1G7m3uc8iw1MKi3ccXoUClTIZo8=; 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=vSbzPnpFJT86OAt1ah6iDG0y7XeVN0cQrwKMDMgQTJPYPOQsNS67SYUZWEX8lwRPI 9Z5VBa/dheZs0gqTjX19xHLZ0UQm/l8qorBguP0xwV7gyrG/T5YBZv6L03wZDqJcFw PxfBDcDMAM0QnQZx2ZhJD/ggs4+4wKnB8iG2ppCl3e8Ob2kuN/DdRDx9BzCJW5I7j1 B9fcygXwofu0Lp9KzQdU7A/NpEdsPb8UEqYLg7sVlRyrMQV4txc0wKvTULmIcJwRx3 YDUfmmDZ0k3cO65GT3X7bFsDRJaOsfCmcrXj0yqzNUc+/pdcvAS2T4lOwW1g7PmQWG Zg/ECs6fWgj+g== 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 98D4B625E8 for ; Sun, 29 Jan 2023 14:58:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="W8OhejvQ"; dkim-atps=neutral Received: from uno.localdomain (mob-5-90-54-203.net.vodafone.it [5.90.54.203]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A95C449; Sun, 29 Jan 2023 14:58:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1675000728; bh=7I/GCOvyVNiB9qdM1G7m3uc8iw1MKi3ccXoUClTIZo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8OhejvQJA0ynpE0uX64Ig8UgFnVgO0vXMnvpqsfMySRvoBt0pwqXJC5zxwMRCmgA b6VhAljDevk5zYKMgrWonZDfNnql7/xxI1hx9LjoAx44oEK7i5RerB5/Vb5ke7gPNg /QyNCD23+ee4sLA44KCykaC8PK35btXN8LmdIwjo= To: libcamera-devel@lists.libcamera.org Date: Sun, 29 Jan 2023 14:58:28 +0100 Message-Id: <20230129135830.27490-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230129135830.27490-1-jacopo.mondi@ideasonboard.com> References: <20230129135830.27490-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] 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 getYubMediaBusFormat() 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: 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 445fad32656c..5976a63d27dd 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;