From patchwork Wed Jul 22 13:30:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8918 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 B4BADBDB1B for ; Wed, 22 Jul 2020 13:30:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AAEF60991; Wed, 22 Jul 2020 15:30:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="G6OPeEVf"; dkim-atps=neutral Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DFEE60540 for ; Wed, 22 Jul 2020 15:30:21 +0200 (CEST) Received: by mail-pg1-x52c.google.com with SMTP id g67so1257743pgc.8 for ; Wed, 22 Jul 2020 06:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4E1ZlEtGdGzXU4Xw7uWK+RfEUYGCwrDfIrGBicfEWTI=; b=G6OPeEVfuuVVAVc3zdxqjVYx0lnfy6tbxPpo/y8EYlOoeKEQcD2ou85RFPAmi/AH5U fI5RBM76amduV+qch4KPWXdGNnZSSwALLywIp2NsbWWML1PDv3F1lXTkffnOsSYRGKil +Ag7xYDJqHcE2Mjv7ZuSOhEXeGsUUV+Ulqm2VORoPG4TaYPKrPYZ9GyQRI8u5U8JzQWt sDkjIUkmf6SzDww8yUsTrxUkzF/Dk8xK6CWUKTkxN2n00VNQC4DQiqTPPsAEuE8k3SJ9 ldOQ8RR7E37iI7nM2hSxRr/Yx295gKmZkagaadZMhRZUVn0V+/nW98dP1vCWCR2s6+np +5kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4E1ZlEtGdGzXU4Xw7uWK+RfEUYGCwrDfIrGBicfEWTI=; b=oJu7rZdyIFJeysPMnCFzqAeY9drELpkbCmuwcyaVYkeJK9tcfZBzaZDQYqalGNnY2d rIR+vnlnpkx9CGgVSx/phLbEd8YcImNNQTgpesP1+BYehSMOocXppJOBGFbjqWwvW1xh EE/WNDUUb3srlfVMsE7sUsyarLt/6sxCCYICil0LQxmmWyYuGDpMDy5SbA7dZn2aZJw0 VDOFTOjbhtMEMBDWyzdb2uWcjlAYrZcEmWFnd9UJrZRFC3MEonoraG4wF5BmcOqHKFjp Pp5pXX9uhQcStTNsMPxtYp5PJVN/By5Kn2/KetigXB7fFNrC2FiAqI8nIyqFYeReyGc/ shIg== X-Gm-Message-State: AOAM532i83zCdx+gyneqjNacP6moJokbLEKAJhxkQUgd0g6xzRDAl19l J2VcShCFe9CF3aLVbP3I2X96yovtY7s= X-Google-Smtp-Source: ABdhPJzsy6a+E9dBx0IIe/9vgnhp+Xi2Y7bAIy4P5GqznCCzKhEA1NlIaPAJtvctJNCVwkswkPcE7g== X-Received: by 2002:a62:fc15:: with SMTP id e21mr29671276pfh.167.1595424619855; Wed, 22 Jul 2020 06:30:19 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id 19sm24251482pfy.193.2020.07.22.06.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:19 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:03 +0530 Message-Id: <20200722133009.26528-2-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200722133009.26528-1-kgupta@es.iitr.ac.in> References: <20200722133009.26528-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH 1/7] libcamera: formats: Move isRaw() helper to formats.cpp 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: , Cc: Kaaira Gupta MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" isRaw() helper is used in subsequent patches by VIMC as well. Hence move it from raspberrypi pippeline handler to a common place to make it reusable. Signed-off-by: Kaaira Gupta --- include/libcamera/internal/formats.h | 1 + src/libcamera/formats.cpp | 13 +++++++++ .../pipeline/raspberrypi/raspberrypi.cpp | 27 ++++++++----------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index cad41ad..8032fab 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -49,6 +49,7 @@ public: }; bool isValid() const { return format.isValid(); } + bool isRaw(PixelFormat &pixFmt) const; static const PixelFormatInfo &info(const PixelFormat &format); static const PixelFormatInfo &info(const V4L2PixelFormat &format); diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index af3996c..efb7de9 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -853,4 +853,17 @@ PixelFormatInfo::frameSize(const Size &size, return sum; } +/** + * \brief Check if given pixel format is RAW or not + * \return True if the format is RAW, false otherwise + */ +bool PixelFormatInfo::isRaw(PixelFormat &pixFmt) const +{ + const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt); + if (!info.isValid()) + return false; + + return info.colourEncoding == PixelFormatInfo::ColourEncodingRAW; +} + } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index bf1c771..8f35434 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -43,19 +43,6 @@ using V4L2PixFmtMap = std::map>; namespace { -bool isRaw(PixelFormat &pixFmt) -{ - /* - * The isRaw test might be redundant right now the pipeline handler only - * supports RAW sensors. Leave it in for now, just as a sanity check. - */ - const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt); - if (!info.isValid()) - return false; - - return info.colourEncoding == PixelFormatInfo::ColourEncodingRAW; -} - double scoreFormat(double desired, double actual) { double score = desired - actual; @@ -405,7 +392,13 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() std::pair outSize[2]; Size maxSize; for (StreamConfiguration &cfg : config_) { - if (isRaw(cfg.pixelFormat)) { + /* + * The isRaw test might be redundant right now the pipeline handler only + * supports RAW sensors. Leave it in for now, just as a sanity check. + */ + const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); + + if (info.isRaw(cfg.pixelFormat)) { /* * Calculate the best sensor mode we can use based on * the user request. @@ -616,8 +609,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) */ for (unsigned i = 0; i < config->size(); i++) { StreamConfiguration &cfg = config->at(i); + const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); - if (isRaw(cfg.pixelFormat)) { + if (info.isRaw(cfg.pixelFormat)) { /* * If we have been given a RAW stream, use that size * for setting up the sensor. @@ -661,7 +655,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) for (unsigned i = 0; i < config->size(); i++) { StreamConfiguration &cfg = config->at(i); - if (isRaw(cfg.pixelFormat)) { + const PixelFormatInfo &info = PixelFormatInfo::info(cfg..pixelFormat); + if (info.isRaw(cfg.pixelFormat)) { cfg.setStream(&data->isp_[Isp::Input]); data->isp_[Isp::Input].setExternal(true); continue;