Patch Detail
Show a patch.
GET /api/patches/4183/?format=api
{ "id": 4183, "url": "https://patchwork.libcamera.org/api/patches/4183/?format=api", "web_url": "https://patchwork.libcamera.org/patch/4183/", "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": "<20200623190836.53446-10-paul.elder@ideasonboard.com>", "date": "2020-06-23T19:08:23", "name": "[libcamera-devel,v3,09/22] v4l2: v4l2_camera_proxy: Implement VIDIOC_G/S_PRIORITY", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ac47f97d71de37098977844d79bc80137d75d624", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/4183/mbox/", "series": [ { "id": 1034, "url": "https://patchwork.libcamera.org/api/series/1034/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1034", "date": "2020-06-23T19:08:14", "name": "Support v4l2-compliance", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1034/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/4183/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/4183/checks/", "tags": {}, "headers": { "Return-Path": "<paul.elder@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D96D8609A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 21:09:23 +0200 (CEST)", "from jade.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6CB4A2A9;\n\tTue, 23 Jun 2020 21:09:21 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"YRxFHLHk\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592939363;\n\tbh=n7o4XaM0fCDtbM/j31SgrWj8rIrdPjMgnkXHZW9aiTI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=YRxFHLHkBwC3Kz6ILgVJGZme8kf/x4DOUV9Czynsih1XRn37Tx29R5jzp81qNnKwr\n\tfOCFcTZuMNeaqCHvnnPhbdmWs8/EZho0lANQW9iwL444NmxFpjWekMkJkjLxOa9laq\n\tB4WYXvMeZZd4t88zq+zB+Ik/CEhjTM5K2FHnQZ+8=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 24 Jun 2020 04:08:23 +0900", "Message-Id": "<20200623190836.53446-10-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200623190836.53446-1-paul.elder@ideasonboard.com>", "References": "<20200623190836.53446-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 09/22] v4l2: v4l2_camera_proxy:\n\tImplement VIDIOC_G/S_PRIORITY", "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>", "X-List-Received-Date": "Tue, 23 Jun 2020 19:09:24 -0000" }, "content": "Implement VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY. The behaviour\ndocumented in the V4L2 specification doesn't match the implementation in\nthe Linux kernel, implement the latter.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v3:\n- save the priorities of every file\n - they're saved in V4L2CameraFile, so save a set of these in V4L2CameraProxy\n - they're unique from the perspective of the proxy so set is fine\n- actually check the priority for s_fmt, reqbufs, streamon, streamoff,\n s_input, and s_priority\n\nChanges in v2:\n- use V4L2CameraFile instead of fd and priorities map\n---\n src/v4l2/v4l2_camera_proxy.cpp | 59 ++++++++++++++++++++++++++++++++++\n src/v4l2/v4l2_camera_proxy.h | 5 +++\n 2 files changed, 64 insertions(+)", "diff": "diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex bf14ba0..361abe4 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -45,6 +45,8 @@ int V4L2CameraProxy::open(V4L2CameraFile *file)\n {\n \tLOG(V4L2Compat, Debug) << \"Servicing open fd = \" << file->efd();\n \n+\tfiles_.insert(file);\n+\n \tif (refcount_++)\n \t\treturn 0;\n \n@@ -75,6 +77,8 @@ void V4L2CameraProxy::close(V4L2CameraFile *file)\n {\n \tLOG(V4L2Compat, Debug) << \"Servicing close fd = \" << file->efd();\n \n+\tfiles_.erase(file);\n+\n \trelease(file);\n \n \tif (--refcount_ > 0)\n@@ -304,6 +308,9 @@ int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg)\n \tif (!validateBufferType(arg->type))\n \t\treturn -EINVAL;\n \n+\tif (file->priority() < maxPriority())\n+\t\treturn -EBUSY;\n+\n \tint ret = acquire(file);\n \tif (ret < 0)\n \t\treturn ret;\n@@ -340,6 +347,41 @@ int V4L2CameraProxy::vidioc_try_fmt(V4L2CameraFile *file, struct v4l2_format *ar\n \treturn 0;\n }\n \n+enum v4l2_priority V4L2CameraProxy::maxPriority()\n+{\n+\tenum v4l2_priority maxPrio = V4L2_PRIORITY_UNSET;\n+\tfor (V4L2CameraFile *f : files_)\n+\t\tif (f->priority() > maxPrio)\n+\t\t\tmaxPrio = f->priority();\n+\n+\treturn maxPrio;\n+}\n+\n+int V4L2CameraProxy::vidioc_g_priority(V4L2CameraFile *file, enum v4l2_priority *arg)\n+{\n+\tLOG(V4L2Compat, Debug) << \"Servicing vidioc_g_priority fd = \" << file->efd();\n+\n+\t*arg = maxPriority();\n+\n+\treturn 0;\n+}\n+\n+int V4L2CameraProxy::vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority *arg)\n+{\n+\tLOG(V4L2Compat, Debug)\n+\t\t<< \"Servicing vidioc_s_priority fd = \" << file->efd();\n+\n+\tif (*arg > V4L2_PRIORITY_RECORD)\n+\t\treturn -EINVAL;\n+\n+\tif (file->priority() < maxPriority())\n+\t\treturn -EBUSY;\n+\n+\tfile->setPriority(*arg);\n+\n+\treturn 0;\n+}\n+\n int V4L2CameraProxy::freeBuffers()\n {\n \tLOG(V4L2Compat, Debug) << \"Freeing libcamera bufs\";\n@@ -365,6 +407,9 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n \n \tLOG(V4L2Compat, Debug) << arg->count << \" buffers requested \";\n \n+\tif (file->priority() < maxPriority())\n+\t\treturn -EBUSY;\n+\n \tint ret = acquire(file);\n \tif (ret < 0)\n \t\treturn ret;\n@@ -516,6 +561,9 @@ int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n \tif (!validateBufferType(*arg))\n \t\treturn -EINVAL;\n \n+\tif (file->priority() < maxPriority())\n+\t\treturn -EBUSY;\n+\n \tif (!hasOwnership(file))\n \t\treturn -EBUSY;\n \n@@ -531,6 +579,9 @@ int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile *file, int *arg)\n \tif (!validateBufferType(*arg))\n \t\treturn -EINVAL;\n \n+\tif (file->priority() < maxPriority())\n+\t\treturn -EBUSY;\n+\n \tif (!hasOwnership(file) && owner_)\n \t\treturn -EBUSY;\n \n@@ -548,6 +599,8 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n \tVIDIOC_G_FMT,\n \tVIDIOC_S_FMT,\n \tVIDIOC_TRY_FMT,\n+\tVIDIOC_G_PRIORITY,\n+\tVIDIOC_S_PRIORITY,\n \tVIDIOC_REQBUFS,\n \tVIDIOC_QUERYBUF,\n \tVIDIOC_QBUF,\n@@ -590,6 +643,12 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n \tcase VIDIOC_TRY_FMT:\n \t\tret = vidioc_try_fmt(file, static_cast<struct v4l2_format *>(arg));\n \t\tbreak;\n+\tcase VIDIOC_G_PRIORITY:\n+\t\tret = vidioc_g_priority(file, static_cast<enum v4l2_priority *>(arg));\n+\t\tbreak;\n+\tcase VIDIOC_S_PRIORITY:\n+\t\tret = vidioc_s_priority(file, static_cast<enum v4l2_priority *>(arg));\n+\t\tbreak;\n \tcase VIDIOC_REQBUFS:\n \t\tret = vidioc_reqbufs(file, static_cast<struct v4l2_requestbuffers *>(arg));\n \t\tbreak;\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex 2582eb5..a7293bf 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -43,6 +43,7 @@ private:\n \tunsigned int calculateSizeImage(StreamConfiguration &streamConfig);\n \tvoid querycap(std::shared_ptr<Camera> camera);\n \tvoid tryFormat(struct v4l2_format *arg);\n+\tenum v4l2_priority maxPriority();\n \tvoid updateBuffers();\n \tint freeBuffers();\n \n@@ -51,6 +52,8 @@ private:\n \tint vidioc_g_fmt(V4L2CameraFile *file, struct v4l2_format *arg);\n \tint vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg);\n \tint vidioc_try_fmt(V4L2CameraFile *file, struct v4l2_format *arg);\n+\tint vidioc_g_priority(V4L2CameraFile *file, enum v4l2_priority *arg);\n+\tint vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority *arg);\n \tint vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg);\n \tint vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n@@ -84,6 +87,8 @@ private:\n \tstd::vector<struct v4l2_buffer> buffers_;\n \tstd::map<void *, unsigned int> mmaps_;\n \n+\tstd::set<V4L2CameraFile *> files_;\n+\n \tstd::unique_ptr<V4L2Camera> vcam_;\n \n \t/*\n", "prefixes": [ "libcamera-devel", "v3", "09/22" ] }