From patchwork Mon Sep 30 15:20:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 21435 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 2FA8FC32D4 for ; Mon, 30 Sep 2024 15:20:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D1C86351E; Mon, 30 Sep 2024 17:20:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="siOfSjyN"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4789163512 for ; Mon, 30 Sep 2024 17:20:48 +0200 (CEST) Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3FEEB280; Mon, 30 Sep 2024 17:19:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727709557; bh=ZFbCMdeyClpW6m/Cx5DO2jWLzUi48LOTOy3oZp7GJIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=siOfSjyNbHfDuAwIxYrF1bebXWt5lRNwDDdyg/IbuhOf4ZRz9EqC6XL3n1233EMiW LtBXaccjbFn2AO5CakiDpD2WTnoOuSWkVI7FXY2SYwgUAPBMKoya9IhUIsBTx9Kkfz NB3CBNqSFBlwhcaqn6Cx7YSqhiQQLx7juet4XX8Q= From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Laurent Pinchart , Jacopo Mondi , Kieran Bingham , Daniel Scally , Umang Jain Subject: [PATCH 2/2] libcamera: pipeline: Use isRaw() helper to check RAW pixel formats Date: Mon, 30 Sep 2024 20:50:39 +0530 Message-ID: <20240930152039.72459-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930152039.72459-1-umang.jain@ideasonboard.com> References: <20240930152039.72459-1-umang.jain@ideasonboard.com> 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" Use the isRaw() helper provided by the PixelFormat class in order to determine if the given pixel format is a raw format or not. Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/rkisp1.cpp | 3 +-- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 13 ++++-------- src/libcamera/pipeline/ipu3/ipu3.cpp | 6 ++---- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 20 +++++-------------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 +++------ src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 13 +++++------- 6 files changed, 20 insertions(+), 44 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e161cab..d0917c19 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -273,8 +273,7 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, context_.configuration.raw = std::any_of(streamConfig.begin(), streamConfig.end(), [](auto &cfg) -> bool { PixelFormat pixelFormat{ cfg.second.pixelFormat }; - const PixelFormatInfo &format = PixelFormatInfo::info(pixelFormat); - return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; + return pixelFormat.isRaw(); }); for (auto const &a : algorithms()) { diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 72aa6c75..e531ff5e 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -313,8 +313,7 @@ unsigned int ISICameraData::getYuvMediaBusFormat(const PixelFormat &pixelFormat) unsigned int ISICameraData::getMediaBusFormat(PixelFormat *pixelFormat) const { - if (PixelFormatInfo::info(*pixelFormat).colourEncoding == - PixelFormatInfo::ColourEncodingRAW) + if (pixelFormat->isRaw()) return getRawMediaBusFormat(pixelFormat); return getYuvMediaBusFormat(*pixelFormat); @@ -453,8 +452,7 @@ ISICameraConfiguration::validateYuv(std::set &availableStreams, LOG(ISI, Debug) << "Stream " << i << ": " << cfg.toString(); /* If the stream is RAW or not supported default it to YUYV. */ - const PixelFormatInfo &cfgInfo = PixelFormatInfo::info(cfg.pixelFormat); - if (cfgInfo.colourEncoding == PixelFormatInfo::ColourEncodingRAW || + if (cfg.pixelFormat.isRaw() || !formatsMap_.count(cfg.pixelFormat)) { LOG(ISI, Debug) << "Stream " << i << " format: " @@ -522,10 +520,8 @@ CameraConfiguration::Status ISICameraConfiguration::validate() maxResolution.width = std::min(2048U, maxResolution.width); /* Validate streams according to the format of the first one. */ - const PixelFormatInfo info = PixelFormatInfo::info(config_[0].pixelFormat); - Status validationStatus; - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + if (config_[0].pixelFormat.isRaw()) validationStatus = validateRaw(availableStreams, maxResolution); else validationStatus = validateYuv(availableStreams, maxResolution); @@ -652,8 +648,7 @@ StreamConfiguration PipelineHandlerISI::generateYUVConfiguration(Camera *camera, std::map> streamFormats; for (const auto &[pixFmt, pipeFmt] : ISICameraConfiguration::formatsMap_) { - const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt); - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + if (pixFmt.isRaw()) continue; streamFormats[pixFmt] = { { kMinISISize, sensorSize } }; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 430aa902..4e7f43ac 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -215,9 +215,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() Size rawSize; for (const StreamConfiguration &cfg : config_) { - const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); - - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { + if (cfg.pixelFormat.isRaw()) { rawCount++; rawSize = std::max(rawSize, cfg.size); } else { @@ -285,7 +283,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() LOG(IPU3, Debug) << "Validating stream: " << config_[i].toString(); - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { + if (config_[i].pixelFormat.isRaw()) { /* Initialize the RAW stream with the CIO2 configuration. */ cfg->size = cio2Configuration_.size; cfg->pixelFormat = cio2Configuration_.pixelFormat; diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 45c71c1d..a659a99c 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -31,16 +31,6 @@ #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" -namespace { - -bool isFormatRaw(const libcamera::PixelFormat &pixFmt) -{ - return libcamera::PixelFormatInfo::info(pixFmt).colourEncoding == - libcamera::PixelFormatInfo::ColourEncodingRAW; -} - -} /* namespace */ - namespace libcamera { LOG_DEFINE_CATEGORY(MaliC55) @@ -227,7 +217,7 @@ PixelFormat MaliC55CameraData::bestRawFormat() const */ for (const auto &maliFormat : maliC55FmtToCode) { PixelFormat pixFmt = maliFormat.first; - if (!isFormatRaw(pixFmt)) + if (!pixFmt.isRaw()) continue; unsigned int rawCode = maliFormat.second; @@ -330,7 +320,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() bool frPipeAvailable = true; StreamConfiguration *rawConfig = nullptr; for (StreamConfiguration &config : config_) { - if (!isFormatRaw(config.pixelFormat)) + if (!config.pixelFormat.isRaw()) continue; if (rawConfig) { @@ -375,7 +365,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() /* Adjust processed streams. */ Size maxYuvSize; for (StreamConfiguration &config : config_) { - if (isFormatRaw(config.pixelFormat)) + if (config.pixelFormat.isRaw()) continue; /* Adjust format and size for processed streams. */ @@ -599,7 +589,7 @@ PipelineHandlerMaliC55::generateConfiguration(Camera *camera, std::map> formats; for (const auto &maliFormat : maliC55FmtToCode) { PixelFormat pixFmt = maliFormat.first; - bool isRaw = isFormatRaw(pixFmt); + bool isRaw = pixFmt.isRaw(); /* RAW formats are only supported on the FR pipe. */ if (pipe != &pipes_[MaliC55FR] && isRaw) @@ -795,7 +785,7 @@ int PipelineHandlerMaliC55::configure(Camera *camera, Stream *stream = streamConfig.stream(); MaliC55Pipe *pipe = pipeFromStream(data, stream); - if (isFormatRaw(streamConfig.pixelFormat)) + if (streamConfig.pixelFormat.isRaw()) ret = configureRawStream(data, streamConfig, subdevFormat); else ret = configureProcessedStream(data, streamConfig, subdevFormat); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index c02c7cf3..6cee7893 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -485,8 +485,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() */ if (config_.size() > 1) { for (const auto &cfg : config_) { - if (PixelFormatInfo::info(cfg.pixelFormat).colourEncoding == - PixelFormatInfo::ColourEncodingRAW) { + if (cfg.pixelFormat.isRaw()) { config_.resize(1); status = Adjusted; break; @@ -566,8 +565,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() Size maxSize; for (const StreamConfiguration &cfg : config_) { - const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + if (cfg.pixelFormat.isRaw()) rawFormat = cfg.pixelFormat; maxSize = std::max(maxSize, cfg.size); @@ -749,8 +747,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) << " crop " << rect; const PixelFormat &streamFormat = config->at(0).pixelFormat; - const PixelFormatInfo &info = PixelFormatInfo::info(streamFormat); - isRaw_ = info.colourEncoding == PixelFormatInfo::ColourEncodingRAW; + isRaw_ = streamFormat.isRaw(); /* YUYV8_2X8 is required on the ISP source path pad for YUV output. */ if (!isRaw_) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index da8d25c3..cb6117b9 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -182,10 +182,8 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size, PixelFormat rawFormat; for (const auto &format : streamFormats_) { - const PixelFormatInfo &info = PixelFormatInfo::info(format); - /* Populate stream formats for non-RAW configurations. */ - if (info.colourEncoding != PixelFormatInfo::ColourEncodingRAW) { + if (!format.isRaw()) { if (role == StreamRole::Raw) continue; @@ -217,6 +215,7 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size, * Store the raw format with the highest bits per pixel for * later usage. */ + const PixelFormatInfo &info = PixelFormatInfo::info(format); if (info.bitsPerPixel > rawBitsPerPixel) { rawBitsPerPixel = info.bitsPerPixel; rawFormat = format; @@ -272,9 +271,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor, bool found = false; for (const auto &format : streamFormats_) { - const PixelFormatInfo &info = PixelFormatInfo::info(format); - - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { + if (format.isRaw()) { /* Skip raw formats not supported by the sensor. */ uint32_t mbusCode = formatToMediaBus.at(format); if (std::find(mbusCodes.begin(), mbusCodes.end(), mbusCode) == @@ -285,6 +282,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor, * Store the raw format with the highest bits per pixel * for later usage. */ + const PixelFormatInfo &info = PixelFormatInfo::info(format); if (info.bitsPerPixel > rawBitsPerPixel) { rawBitsPerPixel = info.bitsPerPixel; rawFormat = format; @@ -297,8 +295,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor, } } - bool isRaw = PixelFormatInfo::info(cfg->pixelFormat).colourEncoding == - PixelFormatInfo::ColourEncodingRAW; + bool isRaw = cfg->pixelFormat.isRaw(); /* * If no raw format supported by the sensor has been found, use a