From patchwork Sat Mar 21 18:32:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3238 Return-Path: Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D34D560415 for ; Sat, 21 Mar 2020 19:32:54 +0100 (CET) Received: by mail-pg1-x542.google.com with SMTP id d17so4270943pgo.0 for ; Sat, 21 Mar 2020 11:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=Vut/haz12uCQ/pDO9/q3asl7pFHcPnGWfdpApXdplxU=; b=bNflZaXpW0ZvS1n4Ymd/GZ+AHh4rDky+ysjykchlmAOrv3ek3bxjy78nDmLyjMdY/5 z7Mva1dKRVT9B0RBM3eIfHVkm2MUNiYifRK8nk56ThKF5NBDwcjSz9pCW41atUOoMAEa 03xW5n7R5Z29zV/r6TWB2keIRjH5lHsa4/afMszFQ/mi7O+TFz+Pr1nKnab1+UHJ9HxL fHWTwDqAN0KfFSiyAHePTGwLVRTCAyrGMTy1kUSRKfQnL4wekhsdankC6bWyS+LA2THV Lp7Q0JNbI0/HeBCwzTEn3QxnVdFHvmdltS98D6rebOVI9q8ywzee0qcxOM409U1Xelt1 a1EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=Vut/haz12uCQ/pDO9/q3asl7pFHcPnGWfdpApXdplxU=; b=GQRQcHRkCONNWq+dLDH5DMAlv99A9m/kgq1iqNiWRrT8PUAE6IjvuZamkZqTQxHjJ7 4TbMBulApZUo5d7TzJPpMrgoYX0E3PaLKE3WZL8BY6Q8urv7DgGt0RNJsDVLVyB9qaW0 OrHL2DN2WtNnfq13xFCb54/3NAkl331GkkG+Wg07PY09MupoG2oGunWYd2dqv4OiMbt8 VeTlZIRDpG9PG6G/Xds5+hVcZ3ktJoHHJ8Yi+5EPE1qdSbAMlSmei0vRg8xehsmVkTQo 02+ENA6NoiLQtb2RdtMrT4M8AiIKLEx1hbD6sCbVejIpAYudULrRZu8UsLJel/3CRU4+ vuTw== X-Gm-Message-State: ANhLgQ2lnPeg6KTfqJZZkbkLbb1diiQZun1JfmB8iSTxQ3PZIKH9jDlP UOSE33uw+kUCxP0tF8fSphRzrQ== X-Google-Smtp-Source: ADFU+vv4o03XV/ghDswKEBfsS23g2Jj8zfTLqkDb18O3vRFZ6uTKAWLREDlaSjFPD5+v9NEWBcMwiA== X-Received: by 2002:a63:8b41:: with SMTP id j62mr13939088pge.18.1584815573282; Sat, 21 Mar 2020 11:32:53 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.154]) by smtp.gmail.com with ESMTPSA id u12sm8745822pfm.165.2020.03.21.11.32.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Mar 2020 11:32:52 -0700 (PDT) Date: Sun, 22 Mar 2020 00:02:46 +0530 From: Kaaira Gupta To: jacopo@jmondi.org, libcamera-devel@lists.libcamera.org, kieran.bingham@ideasonboard.com, Helen Koike , Vaishali Thakkar Message-ID: <20200321183246.GA14651@kaaira-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Subject: [libcamera-devel] [PATCH LIBCAMERA v2] libcamera: rkisp1: Use parametered constructor instead of default 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-List-Received-Date: Sat, 21 Mar 2020 18:32:55 -0000 Use of default constructor StreamConfiguration() in deprecated, hence make it private. Make Stream class a friend of StreamConfiguration as it uses the default constructor. Replace default constructor StreamConfiguration() by it's parametrized counterpart by using StreamFormats in generateConfiguration() in rkisp1 Also, use erase(), instead of replace() in validate() to prevent it from creating a new instance with empty constructor. Signed-off-by: Kaaira Gupta --- Changes since v1: - replace resize() by erase() in validate() to prevent it from creating a new instance with empty constructor. WIP: - It fails to build as other pipelines still use default constructor. include/libcamera/stream.h | 4 ++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 39 ++++++++++++++++-------- src/libcamera/stream.cpp | 9 ------ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index b1441f8..c19aed6 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -37,7 +37,6 @@ private: }; struct StreamConfiguration { - StreamConfiguration(); StreamConfiguration(const StreamFormats &formats); PixelFormat pixelFormat; @@ -52,8 +51,11 @@ struct StreamConfiguration { std::string toString() const; private: + StreamConfiguration(); Stream *stream_; StreamFormats formats_; + + friend class Stream; }; enum StreamRole { diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 2f909ce..8e8414e 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -218,6 +218,21 @@ private: Camera *activeCamera_; }; +namespace { + +static const std::array formats{ + PixelFormat(DRM_FORMAT_YUYV), + PixelFormat(DRM_FORMAT_YVYU), + PixelFormat(DRM_FORMAT_VYUY), + PixelFormat(DRM_FORMAT_NV16), + PixelFormat(DRM_FORMAT_NV61), + PixelFormat(DRM_FORMAT_NV21), + PixelFormat(DRM_FORMAT_NV12), + /* \todo Add support for 8-bit greyscale to DRM formats */ +}; + +} /* namespace */ + RkISP1Frames::RkISP1Frames(PipelineHandler *pipe) : pipe_(dynamic_cast(pipe)) { @@ -430,17 +445,6 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera, CameraConfiguration::Status RkISP1CameraConfiguration::validate() { - static const std::array formats{ - PixelFormat(DRM_FORMAT_YUYV), - PixelFormat(DRM_FORMAT_YVYU), - PixelFormat(DRM_FORMAT_VYUY), - PixelFormat(DRM_FORMAT_NV16), - PixelFormat(DRM_FORMAT_NV61), - PixelFormat(DRM_FORMAT_NV21), - PixelFormat(DRM_FORMAT_NV12), - /* \todo Add support for 8-bit greyscale to DRM formats */ - }; - const CameraSensor *sensor = data_->sensor_; Status status = Valid; @@ -449,7 +453,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() /* Cap the number of entries to the available streams. */ if (config_.size() > 1) { - config_.resize(1); + config_.erase(config_.begin() + 1, config_.end() - 1); status = Adjusted; } @@ -537,7 +541,16 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera if (roles.empty()) return config; - StreamConfiguration cfg{}; + std::map> pixelformats; + + for (PixelFormat pixelformat : formats) { + std::vector sizes{ + SizeRange{ { 32, 16 }, { 4416, 3312 } } + }; + pixelformats[pixelformat] = sizes; + } + StreamFormats format(pixelformats); + StreamConfiguration cfg(format); cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12); cfg.size = data->sensor_->resolution(); diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index ea3d214..96b3dc5 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -274,15 +274,6 @@ SizeRange StreamFormats::range(const PixelFormat &pixelformat) const * configured for a single video stream. */ -/** - * \todo This method is deprecated and should be removed once all pipeline - * handlers provied StreamFormats. - */ -StreamConfiguration::StreamConfiguration() - : pixelFormat(0), stream_(nullptr) -{ -} - /** * \brief Construct a configuration with stream formats */