From patchwork Mon Mar 23 08:44:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3241 Return-Path: Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4049A60412 for ; Mon, 23 Mar 2020 09:45:02 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id z25so2843087pfa.5 for ; Mon, 23 Mar 2020 01:45:02 -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=ENR2ZXbULvslVVT/YEa7TVoYRuaNKidlflmuKf7SFHo=; b=b6oGt/dXc7qmS83x5eXHuQ+lIWN5cXjP+yc5beE7DfMSziqTaHHvVFi7IW96aAEj3L 3kqCH73WurMR0ialJ6PRG4X1w+Y0yiwC5j3K19RmIQG0oS/v/Rd19xLGb16qvVV7bQ+P nm9EaT9IXbqe+/KlTienysHzHGTNUqbP69j08hOHMpJsSUkctqQDTkgq4EC9nabK/zTi u10poAV/tzQAJHymnt/r3v1ghttykNDMeVV0Q5A2xoPyQm8fbg6+WTsA9FtQfWjFaiHT uESY8mFGjCeA0x8GDL6C5vk8ls3d8NMMdrJ1k3zN7Pk8tstA8/RLaA0FAtFo9qbGY0+b OXXg== 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=ENR2ZXbULvslVVT/YEa7TVoYRuaNKidlflmuKf7SFHo=; b=M71pd4sfMtO8oiEFmwxg8ot6gJA4LyZvE5IsGWfifLCcu0gjeirKamN1mJl+9TuZiN qb8f4BwhSSx33kt0ghPJ3cNFpmdimLb3rrYWDOycZN6q3sM/vEVm3xJIn0MigT3EJzKg pWePH6Uhva5aBy9aYw4eHwx09zxNCBRmQhWoRNl+dChFVkY9xR3OpEdvosBqDGpmqq61 YQlLiF64ci4NhvY14iFtJOCAWgpGeTgj0w2WRYiLOxcpyqBQIseFJhzm/F6L5pKXvxIQ fOUrQoWwGStmTRFCMT+RxlBNXpb7LGBFtqTJKS9RhNdz/ND8F+B21TMbqPQ9M/SRX4NU 3FLw== X-Gm-Message-State: ANhLgQ1HKJofHEpiBgmR3Xk1cAqpuYsR/HuEeHNw71LN96OTPTPIqHz9 AUvsRjO0yJfrnVtI7sqXeiwgvX2vsldjcQ== X-Google-Smtp-Source: ADFU+vvJP81QrtTtrGqjdpbgbiRsx4IF5uNFSZvZ/NPakdDka0f7P31Kz5u5x2n7HcQoQ35PWttjIg== X-Received: by 2002:a62:447:: with SMTP id 68mr22814466pfe.174.1584953100252; Mon, 23 Mar 2020 01:45:00 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.154]) by smtp.gmail.com with ESMTPSA id s19sm12956408pfh.218.2020.03.23.01.44.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Mar 2020 01:44:59 -0700 (PDT) Date: Mon, 23 Mar 2020 14:14:53 +0530 From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, kieran.bingham@ideasonboard.com, Helen Koike , Vaishali Thakkar Message-ID: <20200323084430.GA7565@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 v3] 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: Mon, 23 Mar 2020 08:45:03 -0000 Use of default constructor StreamConfiguration() is 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 parametered 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. Changes since v2: - Rearaange the order of declaration of friend class. - Add constructor implementation again to stream.cpp - Corrections in range of erase() include/libcamera/stream.h | 4 ++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 39 ++++++++++++++++-------- src/libcamera/stream.cpp | 6 ++-- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index b1441f8..a379ebb 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,6 +51,9 @@ struct StreamConfiguration { std::string toString() const; private: + friend class Stream; + StreamConfiguration(); + Stream *stream_; StreamFormats formats_; }; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 2f909ce..6839e3c 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()); 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..7e41378 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -275,9 +275,9 @@ SizeRange StreamFormats::range(const PixelFormat &pixelformat) const */ /** - * \todo This method is deprecated and should be removed once all pipeline - * handlers provied StreamFormats. - */ +* \todo This method is deprecated and should be removed once all pipeline +* handlers provied StreamFormats. +*/ StreamConfiguration::StreamConfiguration() : pixelFormat(0), stream_(nullptr) {