Patch Detail
Show a patch.
GET /api/patches/8535/?format=api
{ "id": 8535, "url": "https://patchwork.libcamera.org/api/patches/8535/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8535/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200701123036.51922-9-jacopo@jmondi.org>", "date": "2020-07-01T12:30:29", "name": "[libcamera-devel,08/15] libcamera: ipu3: Assign streams at configure() time", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "3ad59afe4622550c45e9ce23dbe36eb7899edc36", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/8535/mbox/", "series": [ { "id": 1066, "url": "https://patchwork.libcamera.org/api/series/1066/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1066", "date": "2020-07-01T12:30:21", "name": "libcamera: ipu3: Rework streams configuration", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1066/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8535/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8535/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 BE446C2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 1 Jul 2020 12:27:26 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9818860CDD;\n\tWed, 1 Jul 2020 14:27:26 +0200 (CEST)", "from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA8FF60C62\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 1 Jul 2020 14:27:23 +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 relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 77E851C0007;\n\tWed, 1 Jul 2020 12:27:23 +0000 (UTC)" ], "X-Originating-IP": "93.34.118.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 1 Jul 2020 14:30:29 +0200", "Message-Id": "<20200701123036.51922-9-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200701123036.51922-1-jacopo@jmondi.org>", "References": "<20200701123036.51922-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 08/15] libcamera: ipu3: Assign streams at\n\tconfigure() time", "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": "Assign streams to StreamConfiguration at configure() time, instead of\ndoing so during validation.\n\nThis allows easier computation of stream assignement and will allow\nremoving the vector of stream instances from the\nIPU3CameraConfiguration.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 146 +++++++++++++--------------\n 1 file changed, 69 insertions(+), 77 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 651e0c93a7ab..8f75c5186b13 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -67,8 +67,6 @@ public:\n \tconst std::vector<const Stream *> &streams() { return streams_; }\n \n private:\n-\tvoid assignStreams();\n-\n \t/*\n \t * The IPU3CameraData instance is guaranteed to be valid as long as the\n \t * corresponding Camera instance is valid. In order to borrow a\n@@ -133,50 +131,6 @@ IPU3CameraConfiguration::IPU3CameraConfiguration(Camera *camera,\n \tdata_ = data;\n }\n \n-void IPU3CameraConfiguration::assignStreams()\n-{\n-\t/*\n-\t * Verify and update all configuration entries, and assign a stream to\n-\t * each of them. The viewfinder stream can scale, while the output\n-\t * stream can crop only, so select the output stream when the requested\n-\t * resolution is equal to the sensor resolution, and the viewfinder\n-\t * stream otherwise.\n-\t */\n-\tstd::set<const Stream *> availableStreams = {\n-\t\t&data_->outStream_,\n-\t\t&data_->vfStream_,\n-\t\t&data_->rawStream_,\n-\t};\n-\n-\t/*\n-\t * The caller is responsible to limit the number of requested streams\n-\t * to a number supported by the pipeline before calling this function.\n-\t */\n-\tASSERT(availableStreams.size() >= config_.size());\n-\n-\tstreams_.clear();\n-\tstreams_.reserve(config_.size());\n-\n-\tfor (const StreamConfiguration &cfg : config_) {\n-\t\tconst PixelFormatInfo &info =\n-\t\t\tPixelFormatInfo::info(cfg.pixelFormat);\n-\t\tconst Stream *stream;\n-\n-\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n-\t\t\tstream = &data_->rawStream_;\n-\t\telse if (cfg.size == cio2Configuration_.size)\n-\t\t\tstream = &data_->outStream_;\n-\t\telse\n-\t\t\tstream = &data_->vfStream_;\n-\n-\t\tif (availableStreams.find(stream) == availableStreams.end())\n-\t\t\tstream = *availableStreams.begin();\n-\n-\t\tstreams_.push_back(stream);\n-\t\tavailableStreams.erase(stream);\n-\t}\n-}\n-\n CameraConfiguration::Status IPU3CameraConfiguration::validate()\n {\n \tStatus status = Valid;\n@@ -209,9 +163,6 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \tif (!cio2Configuration_.pixelFormat.isValid())\n \t\treturn Invalid;\n \n-\t/* Assign streams to each configuration entry. */\n-\tassignStreams();\n-\n \t/* Verify and adjust configuration if needed. */\n \tunsigned int rawCount = 0;\n \tunsigned int outCount = 0;\n@@ -385,9 +336,6 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \tIPU3CameraConfiguration *config =\n \t\tstatic_cast<IPU3CameraConfiguration *>(c);\n \tIPU3CameraData *data = cameraData(camera);\n-\tStream *outStream = &data->outStream_;\n-\tStream *vfStream = &data->vfStream_;\n-\tCIO2Device *cio2 = &data->cio2_;\n \tImgUDevice *imgu = data->imgu_;\n \tV4L2DeviceFormat outputFormat;\n \tint ret;\n@@ -435,12 +383,36 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \t\treturn ret;\n \n \t/*\n-\t * Pass the requested stream size to the CIO2 unit and get back the\n-\t * adjusted format to be propagated to the ImgU output devices.\n+\t * Identify the maximum sizes and the number of non-raw streams\n+\t * requested.\n+\t */\n+\tunsigned int outCount = 0;\n+\tSize maxOut;\n+\tfor (unsigned int i = 0; i < config->size(); ++i) {\n+\t\tconst StreamConfiguration &cfg = (*config)[i];\n+\t\tconst PixelFormatInfo &info =\n+\t\t\tPixelFormatInfo::info(cfg.pixelFormat);\n+\n+\t\t/*\n+\t\t * We have validated that only one raw stream can be requested\n+\t\t * and the CIO2 configuration has been set during validation.\n+\t\t */\n+\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n+\t\t\tcontinue;\n+\n+\t\t/* Get the largest size of the two available processed streams. */\n+\t\tif (maxOut < cfg.size)\n+\t\t\tmaxOut = cfg.size;\n+\t\toutCount++;\n+\t}\n+\n+\t/*\n+\t * Configure the CIO2 unit with the format computed during validation\n+\t * and apply the same format to the ImgU input.\n \t */\n \tconst Size &sensorSize = config->cio2Format().size;\n \tV4L2DeviceFormat cio2Format = {};\n-\tret = cio2->configure(sensorSize, &cio2Format);\n+\tret = data->cio2_.configure(sensorSize, &cio2Format);\n \tif (ret)\n \t\treturn ret;\n \n@@ -451,40 +423,60 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \t/* Apply the format to the configured streams output devices. */\n \tbool outActive = false;\n \tbool vfActive = false;\n-\n \tfor (unsigned int i = 0; i < config->size(); ++i) {\n-\t\t/*\n-\t\t * Use a const_cast<> here instead of storing a mutable stream\n-\t\t * pointer in the configuration to let the compiler catch\n-\t\t * unwanted modifications of camera data in the configuration\n-\t\t * validate() implementation.\n-\t\t */\n-\t\tStream *stream = const_cast<Stream *>(config->streams()[i]);\n \t\tStreamConfiguration &cfg = (*config)[i];\n+\t\tconst PixelFormatInfo &info =\n+\t\t\tPixelFormatInfo::info(cfg.pixelFormat);\n+\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n+\t\t\t/*\n+\t\t\t * The RAW stream is configured as part of the CIO2 and\n+\t\t\t * no configuration is needed for the ImgU.\n+\t\t\t */\n+\t\t\tcfg.setStream(&data->rawStream_);\n+\t\t\tcfg.stride = cio2Format.planes[0].bpl;\n \n-\t\tcfg.setStream(stream);\n+\t\t\tLOG(IPU3, Debug) << \"Assigned \" << cfg.toString()\n+\t\t\t\t\t << \" to the raw output\";\n+\t\t\tcontinue;\n+\t\t}\n \n-\t\tif (stream == outStream) {\n+\t\t/*\n+\t\t * The viewfinder stream can scale, while the main output stream\n+\t\t * can crop only. Select the main output for the largest\n+\t\t * non-raw stream only if another smaller one has been\n+\t\t * requested.\n+\t\t */\n+\t\tif (cfg.size == maxOut && outCount > 1) {\n \t\t\tret = imgu->configureOutput(cfg, &outputFormat);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n \n \t\t\tcfg.stride = outputFormat.planes[0].bpl;\n+\t\t\tcfg.setStream(&data->outStream_);\n \t\t\toutActive = true;\n-\t\t} else if (stream == vfStream) {\n-\t\t\tret = imgu->configureViewfinder(cfg, &outputFormat);\n-\t\t\tif (ret)\n-\t\t\t\treturn ret;\n \n-\t\t\tcfg.stride = outputFormat.planes[0].bpl;\n-\t\t\tvfActive = true;\n-\t\t} else {\n-\t\t\t/*\n-\t\t\t * The RAW stream is configured as part of the CIO2 and\n-\t\t\t * no configuration is needed for the ImgU.\n-\t\t\t */\n-\t\t\tcfg.stride = cio2Format.planes[0].bpl;\n+\t\t\tLOG(IPU3, Debug) << \"Assigned \" << cfg.toString()\n+\t\t\t\t\t << \" to the main output\";\n+\t\t\tcontinue;\n \t\t}\n+\n+\t\t/*\n+\t\t * If a single non-raw stream has been requested, assign it to\n+\t\t * the viewfinder output regardless of its size. If more than\n+\t\t * one non-raw stream has been requested, assign to viewfinder\n+\t\t * the smaller one to reduce the cropping required (if any) on\n+\t\t * the main output.\n+\t\t */\n+\t\tret = imgu->configureViewfinder(cfg, &outputFormat);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tcfg.stride = outputFormat.planes[0].bpl;\n+\t\tcfg.setStream(&data->vfStream_);\n+\t\tvfActive = true;\n+\n+\t\tLOG(IPU3, Debug) << \"Assigned \" << cfg.toString()\n+\t\t\t\t << \" to the viewfinder output\";\n \t}\n \n \t/*\n", "prefixes": [ "libcamera-devel", "08/15" ] }