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; From patchwork Wed Jul 22 13:30:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8919 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 D9664BDB1B for ; Wed, 22 Jul 2020 13:30:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A48FB60991; Wed, 22 Jul 2020 15:30:26 +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="CGt+aRtL"; dkim-atps=neutral Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 16D6A6053C for ; Wed, 22 Jul 2020 15:30:25 +0200 (CEST) Received: by mail-pg1-x52a.google.com with SMTP id o13so1279391pgf.0 for ; Wed, 22 Jul 2020 06:30:25 -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=Inu6TdNqo/wikV1TauBqX/BnETqTDy3fmj9CxK6jz9I=; b=CGt+aRtLEA4gf0d8v1eYbOlb0BGtfChm0RHJC2zcvqsX9Rcz7FH8XBXpbqEvIo4XKh CojIuOK29u6Suil9JqBmwSnhp0+9Jw8XH6SPrRU5hzQWzhT27+VyfuwtK+u0dyvqcQ/R PCPrskERGOUF4pz15TqFqQ3d4xQjGsGZhwpuB2D+Shdy8zhGmICfB0hM+Pxfha8E2HTT JGnqJBsgxvxMHCAqbHdVt+fccPK2AMUTIvKIIdhF8nO+nsl4XP4c8zA7Tz/vMITPulzs YHs9v1j4G2vSjN/oY7ywGt6DVJ2rkI0lGTNUAVUeYMHMlUaeJJ7grJHnOsJkM27mqWS3 9zrw== 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=Inu6TdNqo/wikV1TauBqX/BnETqTDy3fmj9CxK6jz9I=; b=RlObnRfhORL738W1IxBpqIwst5YR+DBOJZorGdGMAll6J/g0jZj+hTxZ/qL2WETNno 7Lk7lLoLyhycRuDBW6qmysw6/tXAhbrnhO4CHwgpplu/iqHwSzfQOFSrXuLK+2qEJSM4 okT4WePiR2w7x2xyh5BqBj96j6CJuxwlAsH/bkBc8mH632O0u87zwu4hZ+Lg8+vv6Y6M SJ0JGDT8htbDR7RkFn5x5MbFBamQJtaXOUxATVFkATzthK+WdfeRZ9jifZ3dHxgr4rZV kZgwgheXhLhlc9jO57zkbqLxZ9kcxafo25Y2PXhDpCPThQiByRpKYxQ98KFAATZ3HPp4 mCpQ== X-Gm-Message-State: AOAM533ck7lac0ICZqvmx9MHDtypq8aGZMqLfIJzOxejLbSXpFyygmBA 8pCUoHu6TPbBkgoimY0FBlga+g== X-Google-Smtp-Source: ABdhPJxzZ6w7ktUD9HniFxiVHFCq5eIcL4bUefP1DBl+pXXWUcBPGCltVCoOhFHO+LaHePZvok5AYw== X-Received: by 2002:a65:6795:: with SMTP id e21mr27756048pgr.289.1595424623708; Wed, 22 Jul 2020 06:30:23 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id p19sm20704699pgj.74.2020.07.22.06.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:23 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:04 +0530 Message-Id: <20200722133009.26528-3-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 2/7] libcamera: pipeline: vimc: Introduce rawStream_ 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" Change "stream_" to "rgbStream_" as it represents stream at RGB/YUV Capture, and introduce a raw stream for streaming with RAW capture 1 Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 4f461b9..bd6ddde 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -66,7 +66,8 @@ public: V4L2Subdevice *scaler_; V4L2VideoDevice *video_; V4L2VideoDevice *raw_; - Stream stream_; + Stream rgbStream_; + Stream rawStream_; }; class VimcCameraConfiguration : public CameraConfiguration @@ -290,7 +291,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) if (ret) return ret; - cfg.setStream(&data->stream_); + cfg.setStream(&data->rgbStream_); return 0; } @@ -307,7 +308,7 @@ int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream, int PipelineHandlerVimc::start(Camera *camera) { VimcCameraData *data = cameraData(camera); - unsigned int count = data->stream_.configuration().bufferCount; + unsigned int count = data->rgbStream_.configuration().bufferCount; int ret = data->video_->importBuffers(count); if (ret < 0) @@ -380,7 +381,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request) int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request) { VimcCameraData *data = cameraData(camera); - FrameBuffer *buffer = request->findBuffer(&data->stream_); + FrameBuffer *buffer = request->findBuffer(&data->rgbStream_); if (!buffer) { LOG(VIMC, Error) << "Attempt to queue request with invalid stream"; @@ -433,7 +434,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::string name{ "VIMC " + data->sensor_->model() }; - std::set streams{ &data->stream_ }; + std::set streams{ &data->rgbStream_, &data->rawStream_ }; std::shared_ptr camera = Camera::create(this, name, streams); registerCamera(std::move(camera), std::move(data)); From patchwork Wed Jul 22 13:30:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8920 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 63061BDB1B for ; Wed, 22 Jul 2020 13:30:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1B81B609C5; Wed, 22 Jul 2020 15:30:30 +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="1FyqB4Kf"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EB1960540 for ; Wed, 22 Jul 2020 15:30:29 +0200 (CEST) Received: by mail-pl1-x636.google.com with SMTP id w17so987799ply.11 for ; Wed, 22 Jul 2020 06:30:29 -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=KSv3HNYWyvKZjLaLjbxU0Va1M99Ttw6+yOqTeHiqQqo=; b=1FyqB4KfD+VMyvTbYFuYpK2+MrsgenBgtBYa4rATVdo9F7zoEWcBuDIs66/uvtJhYY 6iwZnoe6P/CgsP4t44t8RgPipFY+ASk04PuDIVPuTr4nNnSTpzOXQSZq1uQXnLy4xejN FUkBD+yInOIhitkrg4tq2biMwqdfGadMH6WhMz0/EPtxRlvo8+VDgBq1xbz/7o9/+8YL cap34UVvfA5h2WKfv953nVWciaRBq3tuzGYAromrZ2IU4C1anISgavneUzsF/km62ltm KY28iT6/QNv92cTrglf4TW0HIB3Q4u4rHrTjQKFyXKQ7/A3zPin7L5m8mq6+QIOYWyyc 6jUg== 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=KSv3HNYWyvKZjLaLjbxU0Va1M99Ttw6+yOqTeHiqQqo=; b=BdUeUVMpuSsp78envmQucfdABp+ogNJIOfpB7qlPAuyrtqiTcHtnXXuSlOUDee9QC7 u/x/YqoqOizTsO7ilVERToNIMiB9Vr01vHtCuQ+eC2Uv2IyeXLUinO4n5shytAkqKFro 2q+ROw1iU7wGLpGLClbsGOqIti8NjqlvETLQdXwN+nq8U1QSXJbyP//LR769cUe7mIDT qHVK1GiH5SpnJOve/zFzALEhUYMuR2Tc/m0/SiSooQdfZXX3TfSkfa0k/GZUoZmNB+YW WRqrL3HpkzhDtkYLRX7ip6OwyEwJ3fhTC/TGZnlXsxvslKv3uDEoFVbMMTZNMES5s9ka myOQ== X-Gm-Message-State: AOAM533Bd6pKHT3ANxDOGifZb0koK2qj8Lu2xEyTY4znSrTxZyCJixQR zAAgexBX5huTQo/MlrIP6qRgvw== X-Google-Smtp-Source: ABdhPJwDrLd74zaSCY7s1Ud818sW9nlNgq1A31DmqYA3nYEZQ8WmAsBKsKlK57cj9/+k2GuSJ2tLqA== X-Received: by 2002:a17:90a:d998:: with SMTP id d24mr9718553pjv.43.1595424627318; Wed, 22 Jul 2020 06:30:27 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id n14sm21791703pgd.78.2020.07.22.06.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:26 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:05 +0530 Message-Id: <20200722133009.26528-4-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 3/7] libcamera: pipeline: vimc: Generate and Validate stream configurations 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" Implement generating configurations for StillCaptureRaw role. Also validate them. Declare a bool which takes note of the configuration which is raw (if any). If two configurations are asked for, we consider one of them to be asking for a raw stream. If no role is provided, consider the configuration with least with to be associated wth raw stream. If both the pixelformat and size are provided, give preferance to pixelformat in determining the configuration with raw stream. Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 180 ++++++++++++++++++--------- 1 file changed, 122 insertions(+), 58 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index bd6ddde..83dd541 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -117,6 +117,17 @@ static const std::map pixelformats{ { formats::BGR888, MEDIA_BUS_FMT_RGB888_1X24 }, }; +static const std::map pixelFormatsRaw{ + { formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 }, + { formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 }, + { formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 }, + { formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 }, + { formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 }, + { formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 }, + { formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 }, + { formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 } +}; + } /* namespace */ VimcCameraConfiguration::VimcCameraConfiguration(VimcCameraData *data) @@ -127,53 +138,90 @@ VimcCameraConfiguration::VimcCameraConfiguration(VimcCameraData *data) CameraConfiguration::Status VimcCameraConfiguration::validate() { Status status = Valid; + bool hasRaw = false; + unsigned rindex = 2; + int ret; if (config_.empty()) return Invalid; /* Cap the number of entries to the available streams. */ - if (config_.size() > 1) { - config_.resize(1); + if (config_.size() > 2) { + config_.resize(2); status = Adjusted; } - StreamConfiguration &cfg = config_[0]; - - /* Adjust the pixel format. */ - const std::vector formats = cfg.formats().pixelformats(); - if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == formats.end()) { - LOG(VIMC, Debug) << "Adjusting format to BGR888"; - cfg.pixelFormat = formats::BGR888; - status = Adjusted; + if (config_.size() > 1) { + if (config_[0].size.width < config_[1].size.width) { + rindex = 0; + } else { + rindex = 1; + } + hasRaw = true; } - /* Clamp the size based on the device limits. */ - const Size size = cfg.size; - - /* The scaler hardcodes a x3 scale-up ratio. */ - cfg.size.width = std::max(48U, std::min(4096U, cfg.size.width)); - cfg.size.height = std::max(48U, std::min(2160U, cfg.size.height)); - cfg.size.width -= cfg.size.width % 3; - cfg.size.height -= cfg.size.height % 3; - - if (cfg.size != size) { - LOG(VIMC, Debug) - << "Adjusting size to " << cfg.size.toString(); - status = Adjusted; + for (unsigned i = 0; i < config_.size(); i++) { + const PixelFormatInfo &info = PixelFormatInfo::info(config_[i].pixelFormat); + if (info.isRaw(config_[i].pixelFormat)) { + rindex = i; + hasRaw = true; + } } - cfg.bufferCount = 4; + for (unsigned i = 0; i < config_.size(); i++) { + StreamConfiguration &cfg = config_[i]; + V4L2DeviceFormat format = {}; + const Size size = cfg.size; + if (i == rindex) { + /* Clamp the size based on the device limits. */ + cfg.size.width = std::max(16U, std::min(1365U, cfg.size.width)); + cfg.size.height = std::max(16U, std::min(720U, cfg.size.height)); + /* Adjust the pixel format. */ + if (pixelFormatsRaw.find(cfg.pixelFormat) == pixelFormatsRaw.end()) { + LOG(VIMC, Debug) << "Adjusting format to SGRBG8"; + cfg.pixelFormat = formats::SGRBG8; + status = Adjusted; + } + format.fourcc = data_->raw_->toV4L2PixelFormat(cfg.pixelFormat); + format.size = cfg.size; + ret = data_->raw_->tryFormat(&format); + } else { + const std::vector formats = cfg.formats().pixelformats(); + if (hasRaw) { + cfg.size.width = config_[(i + 1) % 2].size.width * 3; + cfg.size.height = config_[(i + 1) % 2].size.height * 3; + } else { + /* Clamp the size based on the device limits. */ + cfg.size.width = std::max(48U, std::min(4096U, cfg.size.width)); + cfg.size.height = std::max(48U, std::min(2160U, cfg.size.height)); + /* The scaler hardcodes a x3 scale-up ratio. */ + cfg.size.width -= cfg.size.width % 3; + cfg.size.height -= cfg.size.height % 3; + } - V4L2DeviceFormat format = {}; - format.fourcc = data_->video_->toV4L2PixelFormat(cfg.pixelFormat); - format.size = cfg.size; + /* Adjust the pixel format. */ + if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == formats.end()) { + LOG(VIMC, Debug) << "Adjusting format to BGR888"; + cfg.pixelFormat = formats::BGR888; + status = Adjusted; + } + format.fourcc = data_->video_->toV4L2PixelFormat(cfg.pixelFormat); + format.size = cfg.size; + ret = data_->video_->tryFormat(&format); + } - int ret = data_->video_->tryFormat(&format); - if (ret) - return Invalid; + if (ret) + return Invalid; + if (cfg.size != size) { + LOG(VIMC, Debug) + << "Adjusting size to " << cfg.size.toString(); + status = Adjusted; + } - cfg.stride = format.planes[0].bpl; - cfg.frameSize = format.planes[0].size; + cfg.bufferCount = 4; + cfg.stride = format.planes[0].bpl; + cfg.frameSize = format.planes[0].size; + } return status; } @@ -194,35 +242,51 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, std::map> formats; - for (const auto &pixelformat : pixelformats) { - /* - * Kernels prior to v5.7 incorrectly report support for RGB888, - * but it isn't functional within the pipeline. - */ - if (data->media_->version() < KERNEL_VERSION(5, 7, 0)) { - if (pixelformat.first != formats::BGR888) { - LOG(VIMC, Info) - << "Skipping unsupported pixel format " - << pixelformat.first.toString(); - continue; + for (const StreamRole role : roles) { + switch (role) { + case StreamRole::StillCaptureRaw: { + for (const auto &pixelformat : pixelFormatsRaw) { + std::vector sizes{ + SizeRange{ { 16, 16 }, { 1365, 720 } } + }; + formats[pixelformat.first] = sizes; + } + StreamConfiguration cfg(formats); + cfg.pixelFormat = formats::SGRBG8; + cfg.size = { 640, 360 }; + cfg.bufferCount = 4; + config->addConfiguration(cfg); + break; + } + default: + for (const auto &pixelformat : pixelformats) { + /* + * Kernels prior to v5.7 incorrectly report support for RGB888, + * but it isn't functional within the pipeline. + */ + if (data->media_->version() < KERNEL_VERSION(5, 7, 0)) { + if (pixelformat.first != formats::BGR888) { + LOG(VIMC, Info) + << "Skipping unsupported pixel format " + << pixelformat.first.toString(); + continue; + } + } + + /* The scaler hardcodes a x3 scale-up ratio. */ + std::vector sizes{ + SizeRange{ { 48, 48 }, { 4096, 2160 } } + }; + formats[pixelformat.first] = sizes; } + StreamConfiguration cfg(formats); + cfg.pixelFormat = formats::BGR888; + cfg.size = { 1920, 1080 }; + cfg.bufferCount = 4; + config->addConfiguration(cfg); + break; } - - /* The scaler hardcodes a x3 scale-up ratio. */ - std::vector sizes{ - SizeRange{ { 48, 48 }, { 4096, 2160 } } - }; - formats[pixelformat.first] = sizes; } - - StreamConfiguration cfg(formats); - - cfg.pixelFormat = formats::BGR888; - cfg.size = { 1920, 1080 }; - cfg.bufferCount = 4; - - config->addConfiguration(cfg); - config->validate(); return config; From patchwork Wed Jul 22 13:30:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8921 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 D2951BDB1B for ; Wed, 22 Jul 2020 13:30:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C0FE60991; Wed, 22 Jul 2020 15:30:33 +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="v5RGy43m"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9257260540 for ; Wed, 22 Jul 2020 15:30:32 +0200 (CEST) Received: by mail-pf1-x442.google.com with SMTP id a14so1298822pfi.2 for ; Wed, 22 Jul 2020 06:30:32 -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=K57dU5fR3o0ZZW/FaxLXeft1XT7kjvlbON2oY1sl2kk=; b=v5RGy43m4TNVUy1PHjWkwp42aOAXKjc9UwKTk81xhEey2XU0fOR3J/hSXZtkZpD64Z KJKqFpARMPY/g7paceCDnYYtL+IIJwgsknkqEFtndhM/6OudWToEqVO3c9BnlVDKf5JY td71E9b6+j23rWN/DV2GywCA9gTzs5bby8LFqb10mQpqwsjztQS7Tw2UF6aEsvSDHh46 lC1WxGTcVsyf8W6GxSHBli37hlsnEmTgnaOIfDQ2jZn65ErnzHb5vZNWYAhpXLwPbJpV OSuGY1tKrIOn/58T/Kl8DRhZZrnbeQ5+j39Na5gnmi/ImcqB5Go/UNlOjdqMrNUxWz9I NNGA== 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=K57dU5fR3o0ZZW/FaxLXeft1XT7kjvlbON2oY1sl2kk=; b=Y+yDU0SmGuZ4EzI1rRc6Hi+RVT+0UcaxAFkW7d0S+EVbib/Kb68OlJLCqnEI60sUvt jLzrVcueYyzTHCEeLU0Vjhat1k3rPOyoTEHep970edtsTdkfUSODv5Zs2oj6VhYnEDGJ 1iW50Zzge6mX2nKVkaz6FSDXiScJgha1bkQqLFWd0bo3rGYCY6Z1KHbokRlNhD7FPwOH baG1EKPm/NN407KUjQ2aFk4vlShw2KTbK1yKSXwzKmtlKCGLc6cQdJv7n+FIRY26qRSL OIGdVyJwkhQzjhnn9fi7/RPlF28Fv+QCaXRWN5E76T8R2QqUosa/ln7+WgnzPou+NDtx UdXA== X-Gm-Message-State: AOAM5313rMlfHLZQAJtbnUmzWWWRZeptViQ62L4Pjrq9iQXcL3Kr9Hoi qX08eE4tnHk6wY6b6q3E6LZDbURtBwA= X-Google-Smtp-Source: ABdhPJwFc7TOj7Fz78taJsBoyNhO/ep1FTUFYdECs3pio5mV5r80pmq2PoKkPVe2bjiffh6jkuZC2w== X-Received: by 2002:aa7:8f03:: with SMTP id x3mr27392325pfr.64.1595424631094; Wed, 22 Jul 2020 06:30:31 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id z2sm24295928pff.36.2020.07.22.06.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:30 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:06 +0530 Message-Id: <20200722133009.26528-5-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 4/7] libcamera: pipeline: vimc: Configure the entities of VIMC pipeline 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" Configure the pads according to the configuration asked for. In case only one stream (RBG or RAW) is asked for, configurations still need to be set on the other entities in the pipeline. Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 175 ++++++++++++++++++--------- 1 file changed, 121 insertions(+), 54 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 83dd541..c2ed5b6 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -295,68 +295,135 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) { VimcCameraData *data = cameraData(camera); - StreamConfiguration &cfg = config->at(0); - int ret; + for (unsigned i = 0; i < config->size(); i++) { + StreamConfiguration &cfg = config->at(i); + const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); + int ret; + if (info.isRaw(cfg.pixelFormat)) { + V4L2SubdeviceFormat subformat = {}; + subformat.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8; + subformat.size = cfg.size; + ret = data->sensor_->setFormat(&subformat); + if (ret) + return ret; + + V4L2DeviceFormat format = {}; + format.fourcc = data->raw_->toV4L2PixelFormat(cfg.pixelFormat); + format.size = cfg.size; + ret = data->raw_->setFormat(&format); + if (ret) + return ret; + + /* + * Formats have to be set on debayer, scaler, and RGB/YUB Capture + * otherwise the VIMC driver will fail pipeline validation + */ + + ret = data->debayer_->setFormat(0, &subformat); + if (ret) + return ret; + + subformat.mbus_code = MEDIA_BUS_FMT_RGB888_1X24; + ret = data->debayer_->setFormat(1, &subformat); + if (ret) + return ret; + + ret = data->scaler_->setFormat(0, &subformat); + if (ret) + return ret; + + if (data->media_->version() >= KERNEL_VERSION(5, 6, 0)) { + Rectangle crop = { + .x = 0, + .y = 0, + .width = subformat.size.width, + .height = subformat.size.height, + }; + ret = data->scaler_->setSelection(0, V4L2_SEL_TGT_CROP, &crop); + if (ret) + return ret; + } - /* The scaler hardcodes a x3 scale-up ratio. */ - V4L2SubdeviceFormat subformat = {}; - subformat.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8; - subformat.size = { cfg.size.width / 3, cfg.size.height / 3 }; + subformat.mbus_code = MEDIA_BUS_FMT_RGB888_1X24; + subformat.size = { cfg.size.width * 3, cfg.size.height * 3 }; + ret = data->scaler_->setFormat(1, &subformat); + if (ret) + return ret; - ret = data->sensor_->setFormat(&subformat); - if (ret) - return ret; + format.fourcc = V4L2PixelFormat(V4L2_PIX_FMT_RGB24); + format.size = { cfg.size.width * 3, cfg.size.height * 3 }; + ret = data->video_->setFormat(&format); + if (ret) + return ret; - ret = data->debayer_->setFormat(0, &subformat); - if (ret) - return ret; + cfg.setStream(&data->rawStream_); - subformat.mbus_code = pixelformats.find(cfg.pixelFormat)->second; - ret = data->debayer_->setFormat(1, &subformat); - if (ret) - return ret; + } else { + /* The scaler hardcodes a x3 scale-up ratio. */ + V4L2SubdeviceFormat subformat = {}; + subformat.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8; + subformat.size = { cfg.size.width / 3, cfg.size.height / 3 }; + + ret = data->sensor_->setFormat(&subformat); + if (ret) + return ret; + + ret = data->debayer_->setFormat(0, &subformat); + if (ret) + return ret; + + subformat.mbus_code = pixelformats.find(cfg.pixelFormat)->second; + ret = data->debayer_->setFormat(1, &subformat); + if (ret) + return ret; + + ret = data->scaler_->setFormat(0, &subformat); + if (ret) + return ret; + + if (data->media_->version() >= KERNEL_VERSION(5, 6, 0)) { + Rectangle crop = { + .x = 0, + .y = 0, + .width = subformat.size.width, + .height = subformat.size.height, + }; + ret = data->scaler_->setSelection(0, V4L2_SEL_TGT_CROP, &crop); + if (ret) + return ret; + } - ret = data->scaler_->setFormat(0, &subformat); - if (ret) - return ret; + subformat.size = cfg.size; + ret = data->scaler_->setFormat(1, &subformat); + if (ret) + return ret; - if (data->media_->version() >= KERNEL_VERSION(5, 6, 0)) { - Rectangle crop{ 0, 0, subformat.size }; - ret = data->scaler_->setSelection(0, V4L2_SEL_TGT_CROP, &crop); - if (ret) - return ret; + V4L2DeviceFormat format = {}; + format.fourcc = data->video_->toV4L2PixelFormat(cfg.pixelFormat); + format.size = cfg.size; + ret = data->video_->setFormat(&format); + if (ret) + return ret; + + if (format.size != cfg.size || + format.fourcc != data->video_->toV4L2PixelFormat(cfg.pixelFormat)) + return -EINVAL; + + /* + * Format has to be set on the raw capture video node, otherwise the + * vimc driver will fail pipeline validation. + */ + format.fourcc = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8); + format.size = { cfg.size.width / 3, cfg.size.height / 3 }; + + ret = data->raw_->setFormat(&format); + if (ret) + return ret; + + cfg.setStream(&data->rgbStream_); + } } - subformat.size = cfg.size; - ret = data->scaler_->setFormat(1, &subformat); - if (ret) - return ret; - - V4L2DeviceFormat format = {}; - format.fourcc = data->video_->toV4L2PixelFormat(cfg.pixelFormat); - format.size = cfg.size; - - ret = data->video_->setFormat(&format); - if (ret) - return ret; - - if (format.size != cfg.size || - format.fourcc != data->video_->toV4L2PixelFormat(cfg.pixelFormat)) - return -EINVAL; - - /* - * Format has to be set on the raw capture video node, otherwise the - * vimc driver will fail pipeline validation. - */ - format.fourcc = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8); - format.size = { cfg.size.width / 3, cfg.size.height / 3 }; - - ret = data->raw_->setFormat(&format); - if (ret) - return ret; - - cfg.setStream(&data->rgbStream_); - return 0; } From patchwork Wed Jul 22 13:30:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8922 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 6DB54BDB1B for ; Wed, 22 Jul 2020 13:30:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B04E6099C; Wed, 22 Jul 2020 15:30:37 +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="B8TAcVme"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D6436053C for ; Wed, 22 Jul 2020 15:30:36 +0200 (CEST) Received: by mail-pf1-x42f.google.com with SMTP id a14so1298884pfi.2 for ; Wed, 22 Jul 2020 06:30:36 -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=poWeSreCTal/V0s2LiZRT7HUmka+2mMTBFWoj7kaSlo=; b=B8TAcVmeDfrEsTSbCN+045mcI65NDZVdUDPUEts8Ca2jUaUrVfOPxu8ELkIAWt2mUA yYW095xlgjc6ZKk2CKIRljtXGBUPK0W6RR8UIjp4VmnjbpveeDQQ55TfXeoMp90ougdg 2VeaYCwMozsifS5ShAUdxfoPx65tpw4gwFkJoRLx9+NZT3Jvb+J8oHdNyKiWi0jfkG3o vOovK/QpnMRa1LWY//Sr9LoeBaTgbXzxlOQNedXou4Q5hUUtr+h/uufYy+2gnYExrTsZ pqlWet5HEameVNmsDY5pSOz3RVWwc9z598rEVhQtwP7NRQaHY25anXOk0n79vmLJkMok +Jzg== 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=poWeSreCTal/V0s2LiZRT7HUmka+2mMTBFWoj7kaSlo=; b=XNmkpv12cb9+cz5oOXnQ4sVcgRorDCLceEz8rK1piSF1giY/p/J9kjOVKz1zYeqiqa FxJTWDU017cUxwg995rW1DZE3h0AjKxCftwYsx9WFrNq5jDpQP8/nfnI3pT+/cvT6lcM a0Oxe9cKilh2rdedELcp5dHPStBlfBuzMv3y6nvZ6rRWvKZ23+npnUWh9Fk/wuKM5sh3 M2tJwtF1DgGqsAxrdaU8bT4ON0D9jwZecx1LujNav3mu5eaC5NJjaBsWAz0P5of5bQxl +8LWzrRHvtjtacaXojmbOn1QkoXdq008r/+flXw2D5QKwh2lfFZ9MGiS6SEORudvTDgK vYoQ== X-Gm-Message-State: AOAM531PpFdzXDPKQnWwpIdrZw9dhPYEpAKgJrOSRxvOtdIsT1pfi+dJ XtREixhUB81Vw0U8cKwgoeieoA== X-Google-Smtp-Source: ABdhPJzQ/OZ1ABZv/UANRJUMSdjl8fWUtRugh/g1FfRCgMTzpWr2lhV444VF0io4lH8Q4d32F60+Vg== X-Received: by 2002:a62:7e51:: with SMTP id z78mr29027453pfc.3.1595424634901; Wed, 22 Jul 2020 06:30:34 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id cv3sm6529541pjb.45.2020.07.22.06.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:34 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:07 +0530 Message-Id: <20200722133009.26528-6-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 5/7] libcamera: pipeline: vimc: Take care of buffers 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" Introduce a bufferReady function for RAW streams. Take care of exporting the correct buffers according to the stream required. Also start and stop the correct buffers accordingly. Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 52 ++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index c2ed5b6..6010e1e 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -59,6 +59,7 @@ public: int init(); void bufferReady(FrameBuffer *buffer); + void bufferReadyRaw(FrameBuffer *buffer); MediaDevice *media_; CameraSensor *sensor_; @@ -433,29 +434,50 @@ int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream, VimcCameraData *data = cameraData(camera); unsigned int count = stream->configuration().bufferCount; - return data->video_->exportBuffers(count, buffers); + if (stream == &data->rawStream_) + return data->raw_->exportBuffers(count, buffers); + else if (stream == &data->rgbStream_) + return data->video_->exportBuffers(count, buffers); + else + return -EINVAL; } int PipelineHandlerVimc::start(Camera *camera) { VimcCameraData *data = cameraData(camera); unsigned int count = data->rgbStream_.configuration().bufferCount; + unsigned int rCount = data->rawStream_.configuration().bufferCount; int ret = data->video_->importBuffers(count); if (ret < 0) return ret; + ret = data->raw_->importBuffers(rCount); + if (ret < 0) + return ret; + ret = data->ipa_->start(); if (ret) { data->video_->releaseBuffers(); + data->raw_->releaseBuffers(); return ret; } - ret = data->video_->streamOn(); - if (ret < 0) { - data->ipa_->stop(); - data->video_->releaseBuffers(); - return ret; + if (count) { + ret = data->video_->streamOn(); + if (ret < 0) { + data->ipa_->stop(); + data->video_->releaseBuffers(); + return ret; + } + } + if (rCount) { + ret = data->raw_->streamOn(); + if (ret < 0) { + data->ipa_->stop(); + data->raw_->releaseBuffers(); + return ret; + } } return 0; @@ -464,8 +486,10 @@ int PipelineHandlerVimc::start(Camera *camera) void PipelineHandlerVimc::stop(Camera *camera) { VimcCameraData *data = cameraData(camera); + data->raw_->streamOff(); data->video_->streamOff(); data->ipa_->stop(); + data->raw_->releaseBuffers(); data->video_->releaseBuffers(); } @@ -653,7 +677,21 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer) Request *request = buffer->request(); pipe_->completeBuffer(camera_, request, buffer); - pipe_->completeRequest(camera_, request); + if (!(request->hasPendingBuffers())) { + pipe_->completeRequest(camera_, request); + } + return; +} + +void VimcCameraData::bufferReadyRaw(FrameBuffer *buffer) +{ + Request *request = buffer->request(); + + pipe_->completeBuffer(camera_, request, buffer); + if (!(request->hasPendingBuffers())) { + pipe_->completeRequest(camera_, request); + } + return; } REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc); From patchwork Wed Jul 22 13:30:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8923 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 D367DBDB1B for ; Wed, 22 Jul 2020 13:30:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9FE3660994; Wed, 22 Jul 2020 15:30:41 +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="o/54liiM"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 311AF6053C for ; Wed, 22 Jul 2020 15:30:40 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id o1so1007973plk.1 for ; Wed, 22 Jul 2020 06:30:40 -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=+3c51sUyT4iYVoTl5eFwaN3u9y2+PNbkP+wIjWb1BkA=; b=o/54liiMDYEKyESIJdayAzX5SutPw7oqPcSH+bhKQPog+2Xr+UnHkwmzYsGwDYNgr1 wv540dbKjMTt9JQZY/uneWvpPBRIHuY3hRqSvU2SjllKmI3wXruRVVbpslWRnTBrpq69 +7xvM5hx3/CzuB1i2fZotpbgb93bk//yGuxOPjL+4LNCYNJU4KUisA+ODVpH6Tj+ZAvw BAV4C5opzleLUxoJiB5mZOtvA+VL7Vf80bU7XXNKTriCdVfj4sKq5kJtAFEYzKNZ605u CxumuzHcHAplorvCb/u9ipdjNb1gLPatY8YRC0jii+I/uB3jbgE2u2zhyI4r2vFbafkb OR9g== 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=+3c51sUyT4iYVoTl5eFwaN3u9y2+PNbkP+wIjWb1BkA=; b=omQovNTvhHcev5FpstrAgeay8Q/k9AboCxIiYwdenMRHPCJU0ldMAtvK5UAgSFUMTe uC8E4enXADcffZWWKZqopxOHGVRNql5+58PZlH0zv2AIE3Lyx2bHpad2woeAlNCXJ3fi h9ccbxura2pfwGSY0HvwQHuKgm4PV1D/VKWVX1ZVarV6YWxAdt4wdMYZccNdnbkuS7Lt kWeHp/mc0Z6+3MQiioTTPatpX61rr/UW46vSUqcYYYXgSm024ob98uqQNJzd0fBfWxNa EapVgOZ3TTf4U2Cdx0vlb7JE1Obuphv9tjE6UpPNTPGMhV3p9SQqxjIONTaOqJB3uM5f kj4g== X-Gm-Message-State: AOAM533qtagS3YAHEn5CmNKfzpmWZ2nr9tVjQ3nhXKhfXcBANeVthp4J YnIK/XDWNCOc7vd1vvGDkz9eVA== X-Google-Smtp-Source: ABdhPJx6J3n9lzAagjUdiF4W742vusRB4lnE7d/+rIkCQV/tXdTbGAipZrLvYPMF4/kTXsid5F3VCQ== X-Received: by 2002:a17:902:b714:: with SMTP id d20mr24859373pls.318.1595424638816; Wed, 22 Jul 2020 06:30:38 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id z6sm23517788pfn.173.2020.07.22.06.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:38 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:08 +0530 Message-Id: <20200722133009.26528-7-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 6/7] libcamera: pipeline: vimc: Queue the buffers 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" Queue the buffers correctly according to the streams requested. Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 6010e1e..7e8d355 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -536,19 +536,30 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request) int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request) { VimcCameraData *data = cameraData(camera); - FrameBuffer *buffer = request->findBuffer(&data->rgbStream_); - if (!buffer) { - LOG(VIMC, Error) - << "Attempt to queue request with invalid stream"; + for (auto it : request->buffers()) { + Stream *stream = static_cast(it.first); + FrameBuffer *buffer = it.second; + if (!buffer) { + LOG(VIMC, Error) + << "Attempt to queue request with invalid stream"; + + return -ENOENT; + } - return -ENOENT; - } + int ret; - int ret = processControls(data, request); - if (ret < 0) - return ret; + if (stream == &data->rgbStream_) + ret = data->video_->queueBuffer(buffer); + if (stream == &data->rawStream_) + ret = data->raw_->queueBuffer(buffer); + else + continue; - ret = data->video_->queueBuffer(buffer); + if (ret < 0) + return ret; + return ret; + } + int ret = processControls(data, request); if (ret < 0) return ret; From patchwork Wed Jul 22 13:30:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 8924 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 46F62BDB1B for ; Wed, 22 Jul 2020 13:30:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1361760948; Wed, 22 Jul 2020 15:30:46 +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="SpPcLVcM"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EADE46093F for ; Wed, 22 Jul 2020 15:30:43 +0200 (CEST) Received: by mail-pf1-x442.google.com with SMTP id a14so1299048pfi.2 for ; Wed, 22 Jul 2020 06:30:43 -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=EqcWv8qYz3kuHeRR9zuZ9xcSIRNdKfabdektmmDvWmg=; b=SpPcLVcMg+U5DAUXYPe2mcPTGEf7gZwiFgL3sFSnk/N7XN0/tgcVBmKmSl3bpxm+nS J8QgjOyjQh/mGHn0Kdw95D6fDCcAEHh2LrSHjQccuYVn+DUxN6KIKo7q9pDRe7jy2CKA fVLd3VdKIULaOV8WVvDRF6CH5EfFX6TY8RgG4xfi4S4x8vfRzW+eIKKSqqp9oaJhFTVS lt5xN8B4qigNPk4vtv5U6UrSM6BaAOlItbJlf1gbnQKDYWCH/WxYVMQJmr1i9mEA8fvM oYljHeVr57VjwogG6WIVkI6SLE1LTjhEYELZKoY3oW1FTLpUOvTYuQ0WLh+uxTsiDF3p mdQA== 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=EqcWv8qYz3kuHeRR9zuZ9xcSIRNdKfabdektmmDvWmg=; b=pgt1zgfLqXDOM6bWBBbL3Y1Y+R0pmDMGBb3kfO9pPhqiVStHI1HZGwZd8EHWII9z35 faxYmTvwnlBf3LulTj72r9i31gM4EO2n+yLGBf2D1uRfRtSHAhtkBeC06AE5nrfPq1ec 2caF3vBz7kk2GLBSBTs4/Z85Ifj+lwGXMLAdSsLXU+2or/hK3/vVjAuJOfCa235PsSFP V6qXJeALZBib6HGFZpreJqmGOgMn3UDAgC1sUKdUCM+Z5W57T/tPOtcHmLuUEreRe1n0 ZVPq9d04drBg5ig+ZA3V2tnhyhCqZNWBG3o7dgiKm68HPyhWSWCZvqptS3g8cHtV+c1T dBDA== X-Gm-Message-State: AOAM530U569JEDAQYQR3TmmbMMW/B8bAH4FLAmXkSJyyahHlWPtS4PW5 2LwkgwUhaMOKtxhh3RQaBtFefqcYvTo= X-Google-Smtp-Source: ABdhPJzls9BtwhjpXYDnAkbP1xob4V4ZCAfcEG1u3m/YaFxO7Cv/i5yRr0tQAppcUPhntgwivl4hXQ== X-Received: by 2002:aa7:9e4e:: with SMTP id z14mr28707347pfq.256.1595424642621; Wed, 22 Jul 2020 06:30:42 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id g10sm6299678pjs.20.2020.07.22.06.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 06:30:42 -0700 (PDT) From: Kaaira Gupta To: libcamera-devel@lists.libcamera.org, Kieran Bingham Date: Wed, 22 Jul 2020 19:00:09 +0530 Message-Id: <20200722133009.26528-8-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 7/7] libcamera: pipeline: vimc: Initialise raw capture connection 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" Finally, connect RAW Capture to its bufferReady function. Signed-off-by: Kaaira Gupta --- src/libcamera/pipeline/vimc/vimc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 7e8d355..a942cb1 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -647,6 +647,8 @@ int VimcCameraData::init() if (raw_->open()) return -ENODEV; + raw_->bufferReady.connect(this, &VimcCameraData::bufferReadyRaw); + /* Initialise the supported controls. */ const ControlInfoMap &controls = sensor_->controls(); ControlInfoMap::Map ctrls;