{"id":8876,"url":"https://patchwork.libcamera.org/api/1.1/patches/8876/?format=json","web_url":"https://patchwork.libcamera.org/patch/8876/","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":"<20200720104736.19986-5-jacopo@jmondi.org>","date":"2020-07-20T10:47:21","name":"[libcamera-devel,v4,04/19] libcamera: ipu3: Remove streams from generateConfiguration","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"de8a4145c40b8a16e1ae78f89d8d30c41914ce7e","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8876/mbox/","series":[{"id":1118,"url":"https://patchwork.libcamera.org/api/1.1/series/1118/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1118","date":"2020-07-20T10:47:17","name":"ipu3: rework pipe confiuguration","version":4,"mbox":"https://patchwork.libcamera.org/series/1118/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8876/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8876/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 8A2FCC2E67\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jul 2020 10:44:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6382560724;\n\tMon, 20 Jul 2020 12:44:19 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 64CE0605C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jul 2020 12:44:16 +0200 (CEST)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9B8396000B;\n\tMon, 20 Jul 2020 10:44:15 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 20 Jul 2020 12:47:21 +0200","Message-Id":"<20200720104736.19986-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200720104736.19986-1-jacopo@jmondi.org>","References":"<20200720104736.19986-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v4 04/19] libcamera: ipu3: Remove streams\n\tfrom generateConfiguration","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":"Remove stream assignment from the IPU3 pipeline handler\ngenerateConfiguration() implementation.\n\nThe function aims to provide a suitable default for the requested use\ncases. Defer stream assignment to validation and only initialize sizes\nand formats.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 104 ++++++++-------------------\n 1 file changed, 30 insertions(+), 74 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex eb00eecfd10a..b1f804d60664 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -31,6 +31,15 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPU3)\n \n+static constexpr unsigned int IPU3_BUFFER_COUNT = 4;\n+static constexpr unsigned int IPU3_MAX_STREAMS = 3;\n+static const Size IMGU_OUTPUT_MIN_SIZE = { 2, 2 };\n+static const Size IMGU_OUTPUT_MAX_SIZE = { 4480, 34004 };\n+static constexpr unsigned int IMGU_OUTPUT_WIDTH_ALIGN = 64;\n+static constexpr unsigned int IMGU_OUTPUT_HEIGHT_ALIGN = 4;\n+static constexpr unsigned int IMGU_OUTPUT_WIDTH_MARGIN = 64;\n+static constexpr unsigned int IMGU_OUTPUT_HEIGHT_MARGIN = 32;\n+\n class IPU3CameraData : public CameraData\n {\n public:\n@@ -61,9 +70,6 @@ public:\n \tconst std::vector<const Stream *> &streams() { return streams_; }\n \n private:\n-\tstatic constexpr unsigned int IPU3_BUFFER_COUNT = 4;\n-\tstatic constexpr unsigned int IPU3_MAX_STREAMS = 3;\n-\n \tvoid assignStreams();\n \tvoid adjustStream(StreamConfiguration &cfg, bool scale);\n \n@@ -299,94 +305,50 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n {\n \tIPU3CameraData *data = cameraData(camera);\n \tIPU3CameraConfiguration *config = new IPU3CameraConfiguration(camera, data);\n-\tstd::set<Stream *> streams = {\n-\t\t&data->outStream_,\n-\t\t&data->vfStream_,\n-\t\t&data->rawStream_,\n-\t};\n \n \tif (roles.empty())\n \t\treturn config;\n \n+\tSize sensorResolution = data->cio2_.sensor()->resolution();\n \tfor (const StreamRole role : roles) {\n \t\tStreamConfiguration cfg = {};\n-\t\tStream *stream = nullptr;\n-\n-\t\tcfg.pixelFormat = formats::NV12;\n \n \t\tswitch (role) {\n \t\tcase StreamRole::StillCapture:\n \t\t\t/*\n-\t\t\t * Pick the output stream by default as the Viewfinder\n-\t\t\t * and VideoRecording roles are not allowed on\n-\t\t\t * the output stream.\n-\t\t\t */\n-\t\t\tif (streams.find(&data->outStream_) != streams.end()) {\n-\t\t\t\tstream = &data->outStream_;\n-\t\t\t} else if (streams.find(&data->vfStream_) != streams.end()) {\n-\t\t\t\tstream = &data->vfStream_;\n-\t\t\t} else {\n-\t\t\t\tLOG(IPU3, Error)\n-\t\t\t\t\t<< \"No stream available for requested role \"\n-\t\t\t\t\t<< role;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\t/*\n-\t\t\t * FIXME: Soraka: the maximum resolution reported by\n-\t\t\t * both sensors (2592x1944 for ov5670 and 4224x3136 for\n-\t\t\t * ov13858) are returned as default configurations but\n-\t\t\t * they're not correctly processed by the ImgU.\n-\t\t\t * Resolutions up tp 2560x1920 have been validated.\n-\t\t\t *\n-\t\t\t * \\todo Clarify ImgU alignment requirements.\n+\t\t\t * Use as default full-frame configuration a value\n+\t\t\t * strictly smaller than the sensor resolution (limited\n+\t\t\t * to the ImgU  maximum output size) and aligned down to\n+\t\t\t * the required frame margin.\n \t\t\t */\n-\t\t\tcfg.size = { 2560, 1920 };\n+\t\t\tcfg.size = sensorResolution.boundedTo(IMGU_OUTPUT_MAX_SIZE);\n+\t\t\tcfg.size.width = utils::alignDown(cfg.size.width - 1,\n+\t\t\t\t\t\t\t  IMGU_OUTPUT_WIDTH_MARGIN);\n+\t\t\tcfg.size.height = utils::alignDown(cfg.size.height - 1,\n+\t\t\t\t\t\t\t   IMGU_OUTPUT_HEIGHT_MARGIN);\n+\t\t\tcfg.pixelFormat = formats::NV12;\n+\t\t\tcfg.bufferCount = IPU3_BUFFER_COUNT;\n \n \t\t\tbreak;\n \n \t\tcase StreamRole::StillCaptureRaw: {\n-\t\t\tif (streams.find(&data->rawStream_) == streams.end()) {\n-\t\t\t\tLOG(IPU3, Error)\n-\t\t\t\t\t<< \"Multiple raw streams are not supported\";\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\tstream = &data->rawStream_;\n-\n-\t\t\tcfg.size = data->cio2_.sensor()->resolution();\n+\t\t\tcfg = data->cio2_.generateConfiguration(sensorResolution);\n \n-\t\t\tcfg = data->cio2_.generateConfiguration(cfg.size);\n \t\t\tbreak;\n \t\t}\n \n \t\tcase StreamRole::Viewfinder:\n \t\tcase StreamRole::VideoRecording: {\n \t\t\t/*\n-\t\t\t * We can't use the 'output' stream for viewfinder or\n-\t\t\t * video capture roles.\n-\t\t\t *\n-\t\t\t * \\todo This is an artificial limitation until we\n-\t\t\t * figure out the exact capabilities of the hardware.\n+\t\t\t * Default viewfinder and videorecording to 1280x720,\n+\t\t\t * capped to the maximum sensor resolution and aligned\n+\t\t\t * to the ImgU output constraints.\n \t\t\t */\n-\t\t\tif (streams.find(&data->vfStream_) == streams.end()) {\n-\t\t\t\tLOG(IPU3, Error)\n-\t\t\t\t\t<< \"No stream available for requested role \"\n-\t\t\t\t\t<< role;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\tstream = &data->vfStream_;\n-\n-\t\t\t/*\n-\t\t\t * Align the default viewfinder size to the maximum\n-\t\t\t * available sensor resolution and to the IPU3\n-\t\t\t * alignment constraints.\n-\t\t\t */\n-\t\t\tconst Size &res = data->cio2_.sensor()->resolution();\n-\t\t\tunsigned int width = std::min(1280U, res.width);\n-\t\t\tunsigned int height = std::min(720U, res.height);\n-\t\t\tcfg.size = { width & ~7, height & ~3 };\n+\t\t\tcfg.size = sensorResolution.boundedTo({ 1280, 720 })\n+\t\t\t\t\t\t   .alignedDownTo(IMGU_OUTPUT_WIDTH_ALIGN,\n+\t\t\t\t\t\t\t          IMGU_OUTPUT_HEIGHT_ALIGN);\n+\t\t\tcfg.pixelFormat = formats::NV12;\n+\t\t\tcfg.bufferCount = IPU3_BUFFER_COUNT;\n \n \t\t\tbreak;\n \t\t}\n@@ -394,16 +356,10 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n \t\tdefault:\n \t\t\tLOG(IPU3, Error)\n \t\t\t\t<< \"Requested stream role not supported: \" << role;\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tif (!stream) {\n \t\t\tdelete config;\n \t\t\treturn nullptr;\n \t\t}\n \n-\t\tstreams.erase(stream);\n-\n \t\tconfig->addConfiguration(cfg);\n \t}\n \n","prefixes":["libcamera-devel","v4","04/19"]}