From patchwork Tue Apr 2 17:13:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 867 Return-Path: Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE7EC610BF for ; Tue, 2 Apr 2019 19:12:38 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 819E4FF812; Tue, 2 Apr 2019 17:12:38 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Apr 2019 19:13:07 +0200 Message-Id: <20190402171309.6447-12-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190402171309.6447-1-jacopo@jmondi.org> References: <20190402171309.6447-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 11/13] libcamera: ipu3: Set stream configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 17:12:39 -0000 Use the cached sensor maximum resolution and the pixel format generated by the ImgU output devices as default stream configuration. While at it, replace the hardcoded numerical value for the number of buffers with a named constexpr. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 34 ++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f6d08af906da..e4f8f90e2302 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -183,6 +183,8 @@ private: Stream stream_; }; + static constexpr unsigned int IPU3_BUFFER_COUNT = 4; + IPU3CameraData *cameraData(const Camera *camera) { return static_cast( @@ -215,26 +217,20 @@ std::map PipelineHandlerIPU3::streamConfiguration(Camera *camera, std::set &streams) { - IPU3CameraData *data = cameraData(camera); std::map configs; - V4L2SubdeviceFormat format = {}; - - /* - * FIXME: As of now, return the image format reported by the sensor. - * In future good defaults should be provided for each stream. - */ - if (data->cio2_.sensor_->getFormat(0, &format)) { - LOG(IPU3, Error) << "Failed to create stream configurations"; - return configs; - } - - StreamConfiguration config = {}; - config.width = format.width; - config.height = format.height; - config.pixelFormat = V4L2_PIX_FMT_IPU3_SGRBG10; - config.bufferCount = 4; - - configs[&data->stream_] = config; + IPU3CameraData *data = cameraData(camera); + StreamConfiguration *config = &configs[&data->stream_]; + Size *maxSize = &data->.cio2_.maxSize_; + + config->width = maxSize->width; + config->height = maxSize->height; + config->pixelFormat = V4L2_PIX_FMT_NV12; + config->bufferCount = IPU3_BUFFER_COUNT; + + LOG(IPU3, Debug) + << "Stream format set to " << config->width << "x" + << config->height << "-0x" << std::hex << std::setfill('0') + << std::setw(8) << config->pixelFormat; return configs; }