Patch Detail
Show a patch.
GET /api/1.1/patches/9423/?format=api
{ "id": 9423, "url": "https://patchwork.libcamera.org/api/1.1/patches/9423/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9423/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200828155136.541696-1-jacopo@jmondi.org>", "date": "2020-08-28T15:51:34", "name": "[libcamera-devel,v2,1/3] libcamera: raspberrypi: dmaheaps: Improve device open", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "c595aa75f40cb56e71112154b51e0e69e1b0bdb0", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9423/mbox/", "series": [ { "id": 1251, "url": "https://patchwork.libcamera.org/api/1.1/series/1251/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1251", "date": "2020-08-28T15:51:34", "name": "[libcamera-devel,v2,1/3] libcamera: raspberrypi: dmaheaps: Improve device open", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1251/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9423/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9423/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 49568BF019\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Aug 2020 15:47:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 06F3162919;\n\tFri, 28 Aug 2020 17:47:59 +0200 (CEST)", "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E551D61EA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Aug 2020 17:47:57 +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 relay12.mail.gandi.net (Postfix) with ESMTPSA id 74DD5200002;\n\tFri, 28 Aug 2020 15:47:57 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 28 Aug 2020 17:51:34 +0200", "Message-Id": "<20200828155136.541696-1-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.28.0", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 1/3] libcamera: raspberrypi: dmaheaps:\n\tImprove device open", "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": "Improve the device opening at class construction time by testing all\nthe available device paths and printout the appropriate error message.\n\nWhile at it, initialize dmaHeapHandle_ to -1 and check for it's value\nat destruction time.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n .../pipeline/raspberrypi/dma_heaps.cpp | 28 +++++++++++++------\n 1 file changed, 20 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\nindex 6769c04640f1..4d5dd6cb87cc 100644\n--- a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\n@@ -7,6 +7,7 @@\n \n #include \"dma_heaps.h\"\n \n+#include <array>\n #include <fcntl.h>\n #include <linux/dma-buf.h>\n #include <linux/dma-heap.h>\n@@ -22,8 +23,10 @@\n * Annoyingly, should the cma heap size be specified on the kernel command line\n * instead of DT, the heap gets named \"reserved\" instead.\n */\n-#define DMA_HEAP_CMA_NAME \"/dev/dma_heap/linux,cma\"\n-#define DMA_HEAP_CMA_ALT_NAME \"/dev/dma_heap/reserved\"\n+static constexpr std::array<const char *, 2> heapNames = {\n+\t\"/dev/dma_heap/linux,cma\",\n+\t\"/dev/dma_heap/reserved\"\n+};\n \n namespace libcamera {\n \n@@ -32,19 +35,28 @@ LOG_DECLARE_CATEGORY(RPI)\n namespace RPi {\n \n DmaHeap::DmaHeap()\n+\t: dmaHeapHandle_(-1)\n {\n-\tdmaHeapHandle_ = ::open(DMA_HEAP_CMA_NAME, O_RDWR, 0);\n-\tif (dmaHeapHandle_ == -1) {\n-\t\tdmaHeapHandle_ = ::open(DMA_HEAP_CMA_ALT_NAME, O_RDWR, 0);\n-\t\tif (dmaHeapHandle_ == -1) {\n-\t\t\tLOG(RPI, Error) << \"Could not open dmaHeap device\";\n+\tfor (const char *name : heapNames) {\n+\t\tint ret = ::open(name, O_RDWR, 0);\n+\t\tif (ret < 0) {\n+\t\t\tret = errno;\n+\t\t\tLOG(RPI, Debug) << \"Failed to open \" << name << \": \"\n+\t\t\t\t\t<< strerror(ret);\n+\t\t\tcontinue;\n \t\t}\n+\n+\t\tdmaHeapHandle_ = ret;\n+\t\tbreak;\n \t}\n+\n+\tif (dmaHeapHandle_ < 0)\n+\t\tLOG(RPI, Error) << \"Could not open any dmaHeap device\";\n }\n \n DmaHeap::~DmaHeap()\n {\n-\tif (dmaHeapHandle_)\n+\tif (dmaHeapHandle_ > -1)\n \t\t::close(dmaHeapHandle_);\n }\n \n", "prefixes": [ "libcamera-devel", "v2", "1/3" ] }