Show a patch.

GET /api/patches/12542/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 12542,
    "url": "https://patchwork.libcamera.org/api/patches/12542/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12542/",
    "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": "<20210610075027.523672-10-hiroh@chromium.org>",
    "date": "2021-06-10T07:50:26",
    "name": "[libcamera-devel,v2,09/10] libcamera: pipeline: raspberrypi: DmaHeaps: Use ScopedFD for a file descriptor",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "1a9f4fa882aa956bcd1e12d8218d463a0b6289eb",
    "submitter": {
        "id": 63,
        "url": "https://patchwork.libcamera.org/api/people/63/?format=api",
        "name": "Hirokazu Honda",
        "email": "hiroh@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12542/mbox/",
    "series": [
        {
            "id": 2115,
            "url": "https://patchwork.libcamera.org/api/series/2115/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2115",
            "date": "2021-06-10T07:50:17",
            "name": "Introduce ScopedFD",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2115/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12542/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12542/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 83314BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 10 Jun 2021 07:50:51 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4090268937;\n\tThu, 10 Jun 2021 09:50:51 +0200 (CEST)",
            "from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com\n\t[IPv6:2607:f8b0:4864:20::1030])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DEDE268933\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Jun 2021 09:50:48 +0200 (CEST)",
            "by mail-pj1-x1030.google.com with SMTP id\n\tk22-20020a17090aef16b0290163512accedso5053830pjz.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Jun 2021 00:50:48 -0700 (PDT)",
            "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:98e0:b356:1c8a:25d4])\n\tby smtp.gmail.com with ESMTPSA id\n\td66sm1565161pfa.32.2021.06.10.00.50.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 10 Jun 2021 00:50:46 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"MSpbbfKJ\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=tRd9oNMvJz1cb4+9G5xPCdGe7j9zeJmXlD0Yo4r3yXg=;\n\tb=MSpbbfKJY6zmdfEyj4Wa8Kho+TqhQYSFpfNe3dtvzQDUPyNZO2gwiXqRyGdhtByGr2\n\tkIhYMuGB+4WGBKSmBj6MRpoxFqra619WJUYG62htl2Vj4AVtDf+Klo2Ir15KZPwjQf9d\n\tOid0WJBxWT5hMYPRjpC3wnB5nK0wJmhsA1PKE=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=tRd9oNMvJz1cb4+9G5xPCdGe7j9zeJmXlD0Yo4r3yXg=;\n\tb=Vhbk9cFKn0gSj4EOs0bzn73BbJ+ChYhXOrqQEI2+2AnJUDMq6NULDScqkGeoIjvvqe\n\tN2DsojB/tsOjGdmalni9CU4N0jWFveyQSeQo6KzEUV/bwQJxcyx3ng514S+lLBEaHbxt\n\tJejrqM45DcXnkC/5hZkOwbKg5pGXUV/HFWUSzOg4iP9XyxZ9ZqK/QID5UXLO6CUfvf9r\n\t8nIy/bB87hV4OWIH7qftaWfSp0N4AaeVnajadc54u017Jt44pHqCT16ky9g+pIXTEjm/\n\tkDWx2pvH1/tywuO8Lmd/2iR/MBpdHTmUvnYdPeI3zgkzh4pCJ29zHdhRBxBxs7psd/aW\n\t6HBA==",
        "X-Gm-Message-State": "AOAM5305K8MPNDGTdZHqEJTEkKfkG0GgRdwkyEFpVQ3ptZ5/5HuNvg5g\n\tFsTs4H41wtisQ2G59GP+74Crwyy7huf4Jw==",
        "X-Google-Smtp-Source": "ABdhPJwIAnbFLQLhjqQWg94WPvOdJYNx2zU6Mz5toiRZ17BkIDDxHXsddd1IwyU8Eey7QOqPWi3l0Q==",
        "X-Received": "by 2002:a17:90a:f015:: with SMTP id\n\tbt21mr2045899pjb.37.1623311447263; \n\tThu, 10 Jun 2021 00:50:47 -0700 (PDT)",
        "From": "Hirokazu Honda <hiroh@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 10 Jun 2021 16:50:26 +0900",
        "Message-Id": "<20210610075027.523672-10-hiroh@chromium.org>",
        "X-Mailer": "git-send-email 2.32.0.rc1.229.g3e70b5a671-goog",
        "In-Reply-To": "<20210610075027.523672-1-hiroh@chromium.org>",
        "References": "<20210610075027.523672-1-hiroh@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 09/10] libcamera: pipeline:\n\traspberrypi: DmaHeaps: Use ScopedFD for a file descriptor",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Manages a file descriptor owned by DmaHeaps for a dma handle by\nScopedFD. Furthermore, DmaHeaps::alloc() creates a new file\ndescriptor and the returned file descriptor is owned by a caller.\nThis also clarifies it by changing the returned value to ScopedFD.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n .../pipeline/raspberrypi/dma_heaps.cpp        | 23 ++++++++-----------\n .../pipeline/raspberrypi/dma_heaps.h          | 10 ++++----\n .../pipeline/raspberrypi/raspberrypi.cpp      |  7 ++++--\n 3 files changed, 21 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\nindex 4d5dd6cb..d5b000b8 100644\n--- a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\n@@ -35,7 +35,6 @@ LOG_DECLARE_CATEGORY(RPI)\n namespace RPi {\n \n DmaHeap::DmaHeap()\n-\t: dmaHeapHandle_(-1)\n {\n \tfor (const char *name : heapNames) {\n \t\tint ret = ::open(name, O_RDWR, 0);\n@@ -46,49 +45,47 @@ DmaHeap::DmaHeap()\n \t\t\tcontinue;\n \t\t}\n \n-\t\tdmaHeapHandle_ = ret;\n+\t\tdmaHeapHandle_ = ScopedFD(ret);\n \t\tbreak;\n \t}\n \n-\tif (dmaHeapHandle_ < 0)\n+\tif (!dmaHeapHandle_.isValid())\n \t\tLOG(RPI, Error) << \"Could not open any dmaHeap device\";\n }\n \n DmaHeap::~DmaHeap()\n {\n-\tif (dmaHeapHandle_ > -1)\n-\t\t::close(dmaHeapHandle_);\n }\n \n-FileDescriptor DmaHeap::alloc(const char *name, std::size_t size)\n+ScopedFD DmaHeap::alloc(const char *name, std::size_t size)\n {\n \tint ret;\n \n \tif (!name)\n-\t\treturn FileDescriptor();\n+\t\treturn ScopedFD();\n \n \tstruct dma_heap_allocation_data alloc = {};\n \n \talloc.len = size;\n \talloc.fd_flags = O_CLOEXEC | O_RDWR;\n \n-\tret = ::ioctl(dmaHeapHandle_, DMA_HEAP_IOCTL_ALLOC, &alloc);\n+\tret = ::ioctl(dmaHeapHandle_.get(), DMA_HEAP_IOCTL_ALLOC, &alloc);\n \n \tif (ret < 0) {\n \t\tLOG(RPI, Error) << \"dmaHeap allocation failure for \"\n \t\t\t\t<< name;\n-\t\treturn FileDescriptor();\n+\t\treturn ScopedFD();\n \t}\n \n-\tret = ::ioctl(alloc.fd, DMA_BUF_SET_NAME, name);\n+\tScopedFD allocFd(alloc.fd);\n+\tret = ::ioctl(allocFd.get(), DMA_BUF_SET_NAME, name);\n \tif (ret < 0) {\n \t\tLOG(RPI, Error) << \"dmaHeap naming failure for \"\n \t\t\t\t<< name;\n-\t\t::close(alloc.fd);\n-\t\treturn FileDescriptor();\n+\t\treturn ScopedFD();\n \t}\n \n-\treturn FileDescriptor(std::move(alloc.fd));\n+\treturn allocFd;\n }\n \n } /* namespace RPi */\ndiff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.h b/src/libcamera/pipeline/raspberrypi/dma_heaps.h\nindex 79f39c51..3a0765e6 100644\n--- a/src/libcamera/pipeline/raspberrypi/dma_heaps.h\n+++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.h\n@@ -7,7 +7,9 @@\n #ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_DMA_HEAPS_H__\n #define __LIBCAMERA_PIPELINE_RASPBERRYPI_DMA_HEAPS_H__\n \n-#include <libcamera/file_descriptor.h>\n+#include <stddef.h>\n+\n+#include <libcamera/scoped_fd.h>\n \n namespace libcamera {\n \n@@ -18,11 +20,11 @@ class DmaHeap\n public:\n \tDmaHeap();\n \t~DmaHeap();\n-\tbool isValid() const { return dmaHeapHandle_ > -1; }\n-\tFileDescriptor alloc(const char *name, std::size_t size);\n+\tbool isValid() const { return dmaHeapHandle_.isValid(); }\n+\tScopedFD alloc(const char *name, std::size_t size);\n \n private:\n-\tint dmaHeapHandle_;\n+\tScopedFD dmaHeapHandle_;\n };\n \n } /* namespace RPi */\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex a65b4568..13faa96e 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1263,10 +1263,13 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \n \t/* Allocate the lens shading table via dmaHeap and pass to the IPA. */\n \tif (!lsTable_.isValid()) {\n-\t\tlsTable_ = dmaHeap_.alloc(\"ls_grid\", ipa::RPi::MaxLsGridSize);\n-\t\tif (!lsTable_.isValid())\n+\t\tScopedFD scopedFD =\n+\t\t\tdmaHeap_.alloc(\"ls_grid\", ipa::RPi::MaxLsGridSize);\n+\t\tif (!scopedFD.isValid())\n \t\t\treturn -ENOMEM;\n \n+\t\tlsTable_ = FileDescriptor(std::move(scopedFD));\n+\n \t\t/* Allow the IPA to mmap the LS table via the file descriptor. */\n \t\t/*\n \t\t * \\todo Investigate if mapping the lens shading table buffer\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "09/10"
    ]
}