{"id":8728,"url":"https://patchwork.libcamera.org/api/1.1/patches/8728/?format=json","web_url":"https://patchwork.libcamera.org/patch/8728/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200709132835.112593-14-paul.elder@ideasonboard.com>","date":"2020-07-09T13:28:25","name":"[libcamera-devel,v5,13/23] libcamera: raspberrypi: Fill stride and frameSize at config validation","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"74a28bf2b78df4b1a7d44d998744e2ae9819a4a8","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8728/mbox/","series":[{"id":1093,"url":"https://patchwork.libcamera.org/api/1.1/series/1093/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1093","date":"2020-07-09T13:28:12","name":"Clean up formats in v4l2-compat and pipeline handlers","version":5,"mbox":"https://patchwork.libcamera.org/series/1093/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8728/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8728/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 988BFBD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jul 2020 13:29:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6666E61218;\n\tThu,  9 Jul 2020 15:29:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 100C661243\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jul 2020 15:29:21 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8AA56525;\n\tThu,  9 Jul 2020 15:29:19 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TECbZkSH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594301360;\n\tbh=EXuaUjfqdW0vH+xE8/bLlGW5Wr9ixh4D3YtVQ3EAfZ8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TECbZkSH2rHTxOYTnqIeWsUskswUCR6t9EOInpAbk1nOsbbRrvMWElPYLiOpyEfrz\n\tzyhE9SVxYuQxsckYRve4MxHLKRBXIrA7/JhNlNKlRZbK9k4VOKiEbMLp5ljW9zS+aI\n\t6+uP6rgx69/HISoxon7yKWrN8AVOFDjMs+wVpyNE=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  9 Jul 2020 22:28:25 +0900","Message-Id":"<20200709132835.112593-14-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200709132835.112593-1-paul.elder@ideasonboard.com>","References":"<20200709132835.112593-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v5 13/23] libcamera: raspberrypi: Fill\n\tstride and frameSize at config validation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Fill the stride and frameSize fields of the StreamConfiguration at\nconfiguration validation time instead of at camera configuration time.\nThis allows applications to get the stride when trying a configuration\nwithout modifying the active configuration of the camera.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v5:\n- clean up code a bit\n- move setting default size and width into separate patch\n\nChanges in v4:\n- mention motivation in commit message\n- also fill stride and frameSize in the default format\n\nNew in v3\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 34 +++++++++++++++----\n 1 file changed, 27 insertions(+), 7 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 1822ac9..a08ad6a 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -427,6 +427,10 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t\t */\n \t\t\tV4L2PixFmtMap fmts = data_->unicam_[Unicam::Image].dev()->formats();\n \t\t\tV4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size);\n+\t\t\tint ret = data_->unicam_[Unicam::Image].dev()->tryFormat(&sensorFormat);\n+\t\t\tif (ret)\n+\t\t\t\treturn Invalid;\n+\n \t\t\tPixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat();\n \t\t\tif (cfg.size != sensorFormat.size ||\n \t\t\t    cfg.pixelFormat != sensorPixFormat) {\n@@ -434,6 +438,10 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t\t\tcfg.pixelFormat = sensorPixFormat;\n \t\t\t\tstatus = Adjusted;\n \t\t\t}\n+\n+\t\t\tcfg.stride = sensorFormat.planes[0].bpl;\n+\t\t\tcfg.frameSize = sensorFormat.planes[0].size;\n+\n \t\t\trawCount++;\n \t\t} else {\n \t\t\toutSize[outCount] = std::make_pair(count, cfg.size);\n@@ -478,19 +486,34 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t * have that fixed up in the code above.\n \t\t *\n \t\t */\n-\t\tPixelFormat &cfgPixFmt = config_.at(outSize[i].first).pixelFormat;\n-\t\tV4L2PixFmtMap fmts;\n+\t\tStreamConfiguration &cfg = config_.at(outSize[i].first);\n+\t\tPixelFormat &cfgPixFmt = cfg.pixelFormat;\n+\t\tV4L2VideoDevice *dev;\n \n \t\tif (i == maxIndex)\n-\t\t\tfmts = data_->isp_[Isp::Output0].dev()->formats();\n+\t\t\tdev = data_->isp_[Isp::Output0].dev();\n \t\telse\n-\t\t\tfmts = data_->isp_[Isp::Output1].dev()->formats();\n+\t\t\tdev = data_->isp_[Isp::Output1].dev();\n+\n+\t\tV4L2PixFmtMap fmts = dev->formats();\n \n \t\tif (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {\n \t\t\t/* If we cannot find a native format, use a default one. */\n \t\t\tcfgPixFmt = formats::NV12;\n \t\t\tstatus = Adjusted;\n \t\t}\n+\n+\t\tV4L2DeviceFormat format = {};\n+\t\tformat.fourcc = dev->toV4L2PixelFormat(cfg.pixelFormat);\n+\t\tformat.size = cfg.size;\n+\n+\t\tint ret = dev->tryFormat(&format);\n+\t\tif (ret)\n+\t\t\treturn Invalid;\n+\n+\t\tcfg.stride = format.planes[0].bpl;\n+\t\tcfg.frameSize = format.planes[0].size;\n+\n \t}\n \n \treturn status;\n@@ -655,7 +678,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \n \t\tif (isRaw(cfg.pixelFormat)) {\n \t\t\tcfg.setStream(&data->isp_[Isp::Input]);\n-\t\t\tcfg.stride = sensorFormat.planes[0].bpl;\n \t\t\tdata->isp_[Isp::Input].setExternal(true);\n \t\t\tcontinue;\n \t\t}\n@@ -679,7 +701,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t\t\t}\n \n \t\t\tcfg.setStream(&data->isp_[Isp::Output0]);\n-\t\t\tcfg.stride = format.planes[0].bpl;\n \t\t\tdata->isp_[Isp::Output0].setExternal(true);\n \t\t}\n \n@@ -705,7 +726,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t\t */\n \t\tif (!cfg.stream()) {\n \t\t\tcfg.setStream(&data->isp_[Isp::Output1]);\n-\t\t\tcfg.stride = format.planes[0].bpl;\n \t\t\tdata->isp_[Isp::Output1].setExternal(true);\n \t\t}\n \t}\n","prefixes":["libcamera-devel","v5","13/23"]}