{"id":4081,"url":"https://patchwork.libcamera.org/api/patches/4081/?format=json","web_url":"https://patchwork.libcamera.org/patch/4081/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200619054123.19052-2-paul.elder@ideasonboard.com>","date":"2020-06-19T05:41:07","name":"[libcamera-devel,v2,01/17] v4l2: v4l2_camera_file: Add V4L2CameraFile to model the opened camera file","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"8e68817e4efc52cac314683251661389f5e77042","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/4081/mbox/","series":[{"id":1017,"url":"https://patchwork.libcamera.org/api/series/1017/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1017","date":"2020-06-19T05:41:06","name":"Support v4l2-compliance","version":2,"mbox":"https://patchwork.libcamera.org/series/1017/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/4081/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/4081/checks/","tags":{},"headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD8A1609C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 07:41:37 +0200 (CEST)","from jade.flets-east.jp (unknown\n\t[IPv6:2400:4051:61:600:e972:d773:e99a:4f79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 44549556;\n\tFri, 19 Jun 2020 07:41:35 +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=\"ACHmaiAT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592545297;\n\tbh=sGpECNNuvQhy36csLwcUlYnqDWMX3dqit3oJ1LHQneg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ACHmaiATHk6IIehPUNTJfTVvdvG1a61hlnndxL3s6rBBpFGNXJMEQhJuRM0ZXFb6q\n\t4i89No2Db96/AqJV7uAbrZE6fo01Cm4tIZxiYzxt22BTzM3jn7Zv+HMOiyFGC2Eg25\n\tzVth6mg4Lq4gCfjBpInV3Ehl7XzfImb0UY/0myuA=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 19 Jun 2020 14:41:07 +0900","Message-Id":"<20200619054123.19052-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200619054123.19052-1-paul.elder@ideasonboard.com>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 01/17] v4l2: v4l2_camera_file: Add\n\tV4L2CameraFile to model the opened camera file","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":"Fri, 19 Jun 2020 05:41:38 -0000"},"content":"With relation to opening files, the kernel has three objects related to\nfiles:\n- inodes, that represent files on disk\n- file objects, that are allocated at open() time and store all data\n  related to the open file\n- file descriptors, that are integers that map to a file\n\nIn the V4L2 compatibility layer, V4L2CameraProxy, which wraps a single\nlibcamera camera via V4L2Camera, is more or less equivalent to the\ninode. We also already have file descriptors (that are really eventfds)\nthat mirror the file descriptors. Here we create a V4L2CameraFile to\nmodel the file objects, to contain information related to the open file,\nnamely if the file has been opened as non-blocking, and the V4L2\npriority (to support VIDIOC_G/S_PRIORITY later on). This new class\nallows us to more cleanly support multiple open later on, since we can\nmove out of V4L2CameraProxy the handling of mapping the fd to the open\nfile information.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNew in v2\n---\n src/v4l2/meson.build          |  1 +\n src/v4l2/v4l2_camera_file.cpp | 45 +++++++++++++++++++++++++++++++++++\n src/v4l2/v4l2_camera_file.h   | 35 +++++++++++++++++++++++++++\n 3 files changed, 81 insertions(+)\n create mode 100644 src/v4l2/v4l2_camera_file.cpp\n create mode 100644 src/v4l2/v4l2_camera_file.h","diff":"diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\nindex f2e4aaf..e3838f0 100644\n--- a/src/v4l2/meson.build\n+++ b/src/v4l2/meson.build\n@@ -2,6 +2,7 @@\n \n v4l2_compat_sources = files([\n     'v4l2_camera.cpp',\n+    'v4l2_camera_file.cpp',\n     'v4l2_camera_proxy.cpp',\n     'v4l2_compat.cpp',\n     'v4l2_compat_manager.cpp',\ndiff --git a/src/v4l2/v4l2_camera_file.cpp b/src/v4l2/v4l2_camera_file.cpp\nnew file mode 100644\nindex 0000000..8916729\n--- /dev/null\n+++ b/src/v4l2/v4l2_camera_file.cpp\n@@ -0,0 +1,45 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * v4l2_camera_file.h - V4L2 compatibility camera file descriptor information\n+ */\n+\n+#include \"v4l2_camera_file.h\"\n+\n+#include <linux/videodev2.h>\n+\n+#include \"libcamera/internal/log.h\"\n+\n+#include \"v4l2_camera_proxy.h\"\n+\n+using namespace libcamera;\n+\n+LOG_DECLARE_CATEGORY(V4L2Compat);\n+\n+V4L2CameraFile::V4L2CameraFile(int efd, bool nonBlocking, V4L2CameraProxy *proxy)\n+\t: priority_(V4L2_PRIORITY_DEFAULT), proxy_(proxy),\n+\t  nonBlocking_(nonBlocking), efd_(efd)\n+{\n+\tproxy_->open(nonBlocking);\n+}\n+\n+V4L2CameraFile::~V4L2CameraFile()\n+{\n+\tproxy_->close();\n+}\n+\n+V4L2CameraProxy *V4L2CameraFile::proxy()\n+{\n+\treturn proxy_;\n+}\n+\n+bool V4L2CameraFile::nonBlocking()\n+{\n+\treturn nonBlocking_;\n+}\n+\n+int V4L2CameraFile::efd()\n+{\n+\treturn efd_;\n+}\ndiff --git a/src/v4l2/v4l2_camera_file.h b/src/v4l2/v4l2_camera_file.h\nnew file mode 100644\nindex 0000000..cf282e9\n--- /dev/null\n+++ b/src/v4l2/v4l2_camera_file.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * v4l2_camera_file.h - V4L2 compatibility camera file descriptor information\n+ */\n+\n+#ifndef __V4L2_CAMERA_FILE_H__\n+#define __V4L2_CAMERA_FILE_H__\n+\n+#include <linux/videodev2.h>\n+\n+class V4L2CameraProxy;\n+\n+class V4L2CameraFile\n+{\n+public:\n+\tV4L2CameraFile(int efd, bool nonBlocking, V4L2CameraProxy *proxy);\n+\t~V4L2CameraFile();\n+\n+\tV4L2CameraProxy *proxy();\n+\n+\tbool nonBlocking();\n+\tint efd();\n+\n+\tenum v4l2_priority priority_;\n+\n+private:\n+\tV4L2CameraProxy *proxy_;\n+\n+\tbool nonBlocking_;\n+\tint efd_;\n+};\n+\n+#endif /* __V4L2_CAMERA_FILE_H__ */\n","prefixes":["libcamera-devel","v2","01/17"]}