Patch Detail
Show a patch.
GET /api/patches/8470/?format=api
{ "id": 8470, "url": "https://patchwork.libcamera.org/api/patches/8470/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8470/", "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": "<20200628001532.2685967-14-niklas.soderlund@ragnatech.se>", "date": "2020-06-28T00:15:32", "name": "[libcamera-devel,v2,13/13] libcamera: ipu3: imgu: Use unique_ptr for video and subdevices", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "dd0f7cf358dec4659908fbd5fa0e86b4e2ae36ef", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8470/mbox/", "series": [ { "id": 1048, "url": "https://patchwork.libcamera.org/api/series/1048/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1048", "date": "2020-06-28T00:15:19", "name": "libcamera: ipu3: Refactoring of ImgU", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1048/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8470/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8470/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 13785C2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Jun 2020 00:16:05 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E23C1609C8;\n\tSun, 28 Jun 2020 02:16:04 +0200 (CEST)", "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C17160AF7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Jun 2020 02:15:56 +0200 (CEST)", "from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 7437b4bc-b8d4-11ea-86ee-0050569116f7;\n\tSun, 28 Jun 2020 02:15:21 +0200 (CEST)" ], "X-Halon-ID": "7437b4bc-b8d4-11ea-86ee-0050569116f7", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 28 Jun 2020 02:15:32 +0200", "Message-Id": "<20200628001532.2685967-14-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200628001532.2685967-1-niklas.soderlund@ragnatech.se>", "References": "<20200628001532.2685967-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 13/13] libcamera: ipu3: imgu: Use\n\tunique_ptr for video and subdevices", "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=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Instead of manually deleting the video and subdevices in the destructor\nuse std::unique_ptr.\n\nSuggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/ipu3/imgu.cpp | 24 ++++++++++++++-------\n src/libcamera/pipeline/ipu3/imgu.h | 32 ++++++++--------------------\n 2 files changed, 25 insertions(+), 31 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\nindex 6a721d47cdacf3d6..4f11dc0dbb5fe94a 100644\n--- a/src/libcamera/pipeline/ipu3/imgu.cpp\n+++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n@@ -44,28 +44,36 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)\n \t * by the match() function: no need to check for newly created\n \t * video devices and subdevice validity here.\n \t */\n-\timgu_ = V4L2Subdevice::fromEntityName(media, name_);\n+\timgu_ = std::unique_ptr<V4L2Subdevice>(\n+\t\t\tV4L2Subdevice::fromEntityName(media, name_));\n \tret = imgu_->open();\n \tif (ret)\n \t\treturn ret;\n \n-\tinput_ = V4L2VideoDevice::fromEntityName(media, name_ + \" input\");\n+\tinput_ = std::unique_ptr<V4L2VideoDevice>(\n+\t\t\tV4L2VideoDevice::fromEntityName(media,\n+\t\t\t\t\t\t\tname_ + \" input\"));\n \tret = input_->open();\n \tif (ret)\n \t\treturn ret;\n \n-\toutput_ = V4L2VideoDevice::fromEntityName(media, name_ + \" output\");\n+\toutput_ = std::unique_ptr<V4L2VideoDevice>(\n+\t\t\tV4L2VideoDevice::fromEntityName(media,\n+\t\t\t\t\t\t\tname_ + \" output\"));\n \tret = output_->open();\n \tif (ret)\n \t\treturn ret;\n \n-\tviewfinder_ = V4L2VideoDevice::fromEntityName(media,\n-\t\t\t\t\t\t name_ + \" viewfinder\");\n+\tviewfinder_ = std::unique_ptr<V4L2VideoDevice>(\n+\t\t\tV4L2VideoDevice::fromEntityName(media,\n+\t\t\t\t\t\t\tname_ + \" viewfinder\"));\n \tret = viewfinder_->open();\n \tif (ret)\n \t\treturn ret;\n \n-\tstat_ = V4L2VideoDevice::fromEntityName(media, name_ + \" 3a stat\");\n+\tstat_ = std::unique_ptr<V4L2VideoDevice>(\n+\t\t\tV4L2VideoDevice::fromEntityName(media,\n+\t\t\t\t\t\t\tname_ + \" 3a stat\"));\n \tret = stat_->open();\n \tif (ret)\n \t\treturn ret;\n@@ -150,7 +158,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,\n \t\treturn ret;\n \n \t/* No need to apply format to the stat node. */\n-\tif (dev == stat_)\n+\tif (dev == stat_.get())\n \t\treturn 0;\n \n \t*outputFormat = {};\n@@ -162,7 +170,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,\n \tif (ret)\n \t\treturn ret;\n \n-\tconst char *name = dev == output_ ? \"output\" : \"viewfinder\";\n+\tconst char *name = dev == output_.get() ? \"output\" : \"viewfinder\";\n \tLOG(IPU3, Debug) << \"ImgU \" << name << \" format = \"\n \t\t\t << outputFormat->toString();\n \ndiff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h\nindex 7be25e40957fcb03..308bf26ee56e4e82 100644\n--- a/src/libcamera/pipeline/ipu3/imgu.h\n+++ b/src/libcamera/pipeline/ipu3/imgu.h\n@@ -24,21 +24,6 @@ struct StreamConfiguration;\n class ImgUDevice\n {\n public:\n-\tImgUDevice()\n-\t\t: imgu_(nullptr), input_(nullptr), output_(nullptr),\n-\t\t viewfinder_(nullptr), stat_(nullptr)\n-\t{\n-\t}\n-\n-\t~ImgUDevice()\n-\t{\n-\t\tdelete imgu_;\n-\t\tdelete input_;\n-\t\tdelete output_;\n-\t\tdelete viewfinder_;\n-\t\tdelete stat_;\n-\t}\n-\n \tint init(MediaDevice *media, unsigned int index);\n \n \tint configureInput(const Size &size, V4L2DeviceFormat *inputFormat);\n@@ -46,21 +31,22 @@ public:\n \tint configureOutput(const StreamConfiguration &cfg,\n \t\t\t V4L2DeviceFormat *outputFormat)\n \t{\n-\t\treturn configureVideoDevice(output_, PAD_OUTPUT, cfg,\n+\t\treturn configureVideoDevice(output_.get(), PAD_OUTPUT, cfg,\n \t\t\t\t\t outputFormat);\n \t}\n \n \tint configureViewfinder(const StreamConfiguration &cfg,\n \t\t\t\tV4L2DeviceFormat *outputFormat)\n \t{\n-\t\treturn configureVideoDevice(viewfinder_, PAD_VF, cfg,\n+\t\treturn configureVideoDevice(viewfinder_.get(), PAD_VF, cfg,\n \t\t\t\t\t outputFormat);\n \t}\n \n \tint configureStat(const StreamConfiguration &cfg,\n \t\t\t V4L2DeviceFormat *outputFormat)\n \t{\n-\t\treturn configureVideoDevice(stat_, PAD_STAT, cfg, outputFormat);\n+\t\treturn configureVideoDevice(stat_.get(), PAD_STAT, cfg,\n+\t\t\t\t\t outputFormat);\n \t}\n \n \tint allocateBuffers(unsigned int bufferCount);\n@@ -71,11 +57,11 @@ public:\n \n \tint enableLinks(bool enable);\n \n-\tV4L2Subdevice *imgu_;\n-\tV4L2VideoDevice *input_;\n-\tV4L2VideoDevice *output_;\n-\tV4L2VideoDevice *viewfinder_;\n-\tV4L2VideoDevice *stat_;\n+\tstd::unique_ptr<V4L2Subdevice> imgu_;\n+\tstd::unique_ptr<V4L2VideoDevice> input_;\n+\tstd::unique_ptr<V4L2VideoDevice> output_;\n+\tstd::unique_ptr<V4L2VideoDevice> viewfinder_;\n+\tstd::unique_ptr<V4L2VideoDevice> stat_;\n \t/* \\todo Add param video device for 3A tuning */\n \n private:\n", "prefixes": [ "libcamera-devel", "v2", "13/13" ] }