Show a patch.

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

{
    "id": 15262,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15262/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15262/",
    "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": "<20220109073330.923675-1-vedantparanjape160201@gmail.com>",
    "date": "2022-01-09T07:33:30",
    "name": "[libcamera-devel,RFC,v1] v4l2: Add support for PREPARE_BUF as one of the supported ioctl",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "f00626480140554639d5dd1b0425ce867adf0d53",
    "submitter": {
        "id": 85,
        "url": "https://patchwork.libcamera.org/api/1.1/people/85/?format=api",
        "name": "Vedant Paranjape",
        "email": "vedantparanjape160201@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15262/mbox/",
    "series": [
        {
            "id": 2884,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2884/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2884",
            "date": "2022-01-09T07:33:30",
            "name": "[libcamera-devel,RFC,v1] v4l2: Add support for PREPARE_BUF as one of the supported ioctl",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2884/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15262/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15262/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 BAC59BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  9 Jan 2022 07:34:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B2E5A60938;\n\tSun,  9 Jan 2022 08:34:00 +0100 (CET)",
            "from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n\t[IPv6:2607:f8b0:4864:20::1032])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C1A0F6017E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  9 Jan 2022 08:33:59 +0100 (CET)",
            "by mail-pj1-x1032.google.com with SMTP id\n\tl16-20020a17090a409000b001b2e9628c9cso12812316pjg.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 08 Jan 2022 23:33:59 -0800 (PST)",
            "from veware.localdomain ([1.186.167.81])\n\tby smtp.googlemail.com with ESMTPSA id\n\tg9sm3023347pfc.203.2022.01.08.23.33.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 08 Jan 2022 23:33:57 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"JKyt1ZC0\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=luV6mm+MmicBfKS9bBddluS5k+rvZ2HkQVHeugY0BPg=;\n\tb=JKyt1ZC0fxFxxQjFGIYet6Cia8/GaxUQYIeXxxrcAFf3pJEWPAy+Ath+AwLuwteZTu\n\tTxLnTlwbRclOdGvj+ruWAuhBa6M1nCB74sOQSeoo3dVF4gJm8ZYkfhKvG6pTr56X9FR6\n\tB2p1TxSIsfrCH8MmBYJ9gR8q5zr8CHxLv7Fz8nGE01HU7oZh6/5rRsHXLC9Ano3J8L8Z\n\tyrdHBMsGnUAk8hAK39Y+1hEQJ3IdfpwVDr2ueoUDvJqYHTxSkQTIS2L/BdFEG5y9S67b\n\tDGj+BgXKM4txFOewVVYYga+3W1FyQMuXQiLh9mH8rTwgRjGbfMU3Z8JieZxo8ruITuEa\n\tfarg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=luV6mm+MmicBfKS9bBddluS5k+rvZ2HkQVHeugY0BPg=;\n\tb=X8ecPW17Deds6O8lkP2895AeRVMsAkzNqE8cTjF01oaV7XzvhQ7Kw3GXqdOmmpUhXu\n\t73NfY9Jka5i2Jrq8VZ0oz/novRC2Z4EsJAbyCUhnUdn2bvuYgE/Su037KA4o+/cWHn6W\n\tbGUF4R/9Pho7yXws1Z1o9c1z4UMQWfhXdKY8Znl46jfkVDK8kBg97PeG+Xovl4OxXRz1\n\tK5M5s5PHbrTdqM4HBQqSK/0FCLXzsndUt5TTwMwB2oyTY5/FkaXj9brNv/X4mgsUDc9k\n\tAlPM+kFmMG7nIxU9Tdb+XDhFcLHmr1k3ylR2+qUUh0e+asjmY9Bj9Jhx1FHVabhsZ5LL\n\tBOHQ==",
        "X-Gm-Message-State": "AOAM531CVF0b19lZ+b8v3FckqyZkcxrmZy1EEqt10DsNbKFqgK1Wfawb\n\tLnhxSlWpMqg+72mIBxwfuykwG+/tAXw=",
        "X-Google-Smtp-Source": "ABdhPJw+vz1K6QTZy7RAWdSMDSKy1gGS1GRC5QDelFLplu+z0IAUET9uMgB5+neV6VolLAD06K8LHQ==",
        "X-Received": "by 2002:a17:90b:3b92:: with SMTP id\n\tpc18mr24454559pjb.137.1641713637967; \n\tSat, 08 Jan 2022 23:33:57 -0800 (PST)",
        "From": "Vedant Paranjape <vedantparanjape160201@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun,  9 Jan 2022 13:03:30 +0530",
        "Message-Id": "<20220109073330.923675-1-vedantparanjape160201@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC PATCH v1] v4l2: Add support for PREPARE_BUF\n\tas one of the supported ioctl",
        "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>",
        "Cc": "Vedant Paranjape <vedantparanjape160201@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add support for PREPARE_BUF as one of the ioctl. This needs adding the\nprepare_buf function to the v4l2_camera class as this operation involves\npassing on the ownership of buffers to the driver.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n---\nI have not cargo copied the error checking or the function, I actually\nwent to kernel source and checked what parameters are being checked to\ngive out a error and checked those in my definition as well.\n\nhttps://elixir.bootlin.com/linux/latest/source/drivers/media/common/videobuf2/videobuf2-v4l2.c#L729\n\nPlease review the v4l2_camera_proxy part, if the function looks good\nenough hypothetically assuming vcam_->prepare_buf() has a correct\nimplementation.\n\nAs for the part in v4l2_camera, prepare_buf. Seeing the pattern of code,\nany operation that needs exchanging buffers with the drivers needs to\nhave a function to be implemented inside v4l2_camera just like qbuf is.\nLet me know if my assumption is wrong, and this change is absolutely not\nneeded. \n\nI am unable to figure out what is the equivalent of transfering ownership \nof the buffer in the libcamera compat world. Just like queueing a buffer\nhas an equivalent, camera_->queueRequest(request) (not comparing apples\nto apples, but to some extent).\n---\nsrc/v4l2/v4l2_camera.cpp       | 10 ++++++++++\n src/v4l2/v4l2_camera.h         |  1 +\n src/v4l2/v4l2_camera_proxy.cpp | 32 ++++++++++++++++++++++++++++++++\n src/v4l2/v4l2_camera_proxy.h   |  1 +\n 4 files changed, 44 insertions(+)",
    "diff": "diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex e922b9e6aab2..2c155a63f836 100644\n--- a/src/v4l2/v4l2_camera.cpp\n+++ b/src/v4l2/v4l2_camera.cpp\n@@ -275,6 +275,16 @@ int V4L2Camera::qbuf(unsigned int index)\n \treturn 0;\n }\n \n+int V4L2Camera::prepare_buf(unsigned int index, unsigned int memory)\n+{\n+\t// just a stub for now\n+\t// referring to\n+\t// https://elixir.bootlin.com/linux/latest/source/drivers/media/common/videobuf2/videobuf2-v4l2.c#L729\n+\t// https://elixir.bootlin.com/linux/latest/source/drivers/media/common/videobuf2/videobuf2-core.c#L1341\n+\n+\treturn 0;\n+}\n+\n void V4L2Camera::waitForBufferAvailable()\n {\n \tMutexLocker locker(bufferMutex_);\ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex 03e741180e8f..b4e4b65ed701 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -57,6 +57,7 @@ public:\n \tint streamOff();\n \n \tint qbuf(unsigned int index);\n+\tint prepare_buf(unsigned int index, unsigned int memory);\n \n \tvoid waitForBufferAvailable();\n \tbool isBufferAvailable();\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 4d529bc29a4d..ae0b0691ca4e 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -544,6 +544,37 @@ int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *a\n \treturn 0;\n }\n \n+int V4L2CameraProxy::vidioc_prepare_buf(V4L2CameraFile *file, struct v4l2_buffer *arg)\n+{\n+\tLOG(V4L2Compat, Debug) << \"Servicing vidioc_prepare_buf, index = \"\n+\t\t\t       << arg->index << \" fd = \" << file->efd();\n+\n+\tif (arg->index >= bufferCount_)\n+\t\treturn -EINVAL;\n+\n+\tif (arg->flags & V4L2_BUF_FLAG_REQUEST_FD ||\n+\t    arg->flags & V4L2_BUF_FLAG_PREPARED)\n+\t\treturn -EINVAL;\n+\n+\tif (!hasOwnership(file))\n+\t\treturn -EBUSY;\n+\n+\tif (!validateBufferType(arg->type) ||\n+\t    !validateMemoryType(arg->memory))\n+\t\treturn -EINVAL;\n+\n+\t/* \\todo when DMABUF memory type is supported, add support here as well */\n+\tint ret = vcam_->prepare_buf(arg->index, arg->memory);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tbuffers_[arg->index].flags |= V4L2_BUF_FLAG_PREPARED;\n+\n+\targ->flags = buffers_[arg->index].flags;\n+\n+\treturn ret;\n+}\n+\n int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)\n {\n \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_qbuf, index = \"\n@@ -709,6 +740,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n \tVIDIOC_S_INPUT,\n \tVIDIOC_REQBUFS,\n \tVIDIOC_QUERYBUF,\n+\tVIDIOC_PREPARE_BUF,\n \tVIDIOC_QBUF,\n \tVIDIOC_DQBUF,\n \tVIDIOC_EXPBUF,\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex 14e027c3e7d1..6baba94262a9 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -57,6 +57,7 @@ private:\n \tint vidioc_s_input(V4L2CameraFile *file, int *arg);\n \tint vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg);\n \tint vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n+\tint vidioc_prepare_buf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n \tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n \t\t\t libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v1"
    ]
}