{"id":631,"url":"https://patchwork.libcamera.org/api/1.1/patches/631/?format=json","web_url":"https://patchwork.libcamera.org/patch/631/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20190226162641.12116-2-jacopo@jmondi.org>","date":"2019-02-26T16:26:34","name":"[libcamera-devel,v3,1/8] libcamera: v4l2_subdevice: Store media entity","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"aa87a5bad41e802b5e522827d13bbbaceba02236","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/631/mbox/","series":[{"id":193,"url":"https://patchwork.libcamera.org/api/1.1/series/193/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=193","date":"2019-02-26T16:26:33","name":"v4l2_(sub)dev: improvements and tests","version":3,"mbox":"https://patchwork.libcamera.org/series/193/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/631/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/631/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F05D8610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Feb 2019 17:26:18 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 811E76000F;\n\tTue, 26 Feb 2019 16:26:18 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 26 Feb 2019 17:26:34 +0100","Message-Id":"<20190226162641.12116-2-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190226162641.12116-1-jacopo@jmondi.org>","References":"<20190226162641.12116-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 1/8] libcamera: v4l2_subdevice: Store\n\tmedia entity","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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, 26 Feb 2019 16:26:19 -0000"},"content":"Store the media entity backing the V4L2Subdevice and add a deviceName()\nmethod to retrieve the human readable name of the subdevice, which is\ncreated using the name of the associated media entity.\n\nUse the deviceName() in error messages where appropriate, as the entity\nname is sometimes more informative than the device node path.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_subdevice.h |  8 +++++---\n src/libcamera/v4l2_subdevice.cpp       | 17 ++++++++++++-----\n 2 files changed, 17 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 82fa6685ab52..eac699a06109 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -9,9 +9,10 @@\n \n #include <string>\n \n+#include \"media_object.h\"\n+\n namespace libcamera {\n \n-class MediaEntity;\n struct Rectangle;\n \n struct V4L2SubdeviceFormat {\n@@ -31,7 +32,8 @@ public:\n \tbool isOpen() const;\n \tvoid close();\n \n-\tstd::string deviceNode() const { return deviceNode_; }\n+\tstd::string deviceNode() const { return entity_->deviceNode(); }\n+\tstd::string deviceName() const { return entity_->name(); }\n \n \tint setCrop(unsigned int pad, Rectangle *rect);\n \tint setCompose(unsigned int pad, Rectangle *rect);\n@@ -43,7 +45,7 @@ private:\n \tint setSelection(unsigned int pad, unsigned int target,\n \t\t\t Rectangle *rect);\n \n-\tstd::string deviceNode_;\n+\tconst MediaEntity *entity_;\n \tint fd_;\n };\n \ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex b436f73cc75f..56ecf3851cb0 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -88,7 +88,7 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)\n  * path\n  */\n V4L2Subdevice::V4L2Subdevice(const MediaEntity *entity)\n-\t: deviceNode_(entity->deviceNode()), fd_(-1)\n+\t: entity_(entity), fd_(-1)\n {\n }\n \n@@ -106,11 +106,11 @@ int V4L2Subdevice::open()\n \t\treturn -EBUSY;\n \t}\n \n-\tret = ::open(deviceNode_.c_str(), O_RDWR);\n+\tret = ::open(deviceNode().c_str(), O_RDWR);\n \tif (ret < 0) {\n \t\tret = -errno;\n \t\tLOG(V4L2Subdev, Error)\n-\t\t\t<< \"Failed to open V4L2 subdevice '\" << deviceNode_\n+\t\t\t<< \"Failed to open V4L2 subdevice '\" << deviceNode()\n \t\t\t<< \"': \" << strerror(-ret);\n \t\treturn ret;\n \t}\n@@ -147,6 +147,13 @@ void V4L2Subdevice::close()\n  * \\return The subdevice's device node system path\n  */\n \n+/**\n+ * \\fn V4L2Subdevice::deviceName()\n+ * \\brief Retrieve the name of the media entity associated with the subdevice\n+ *\n+ * \\return The name of the media entity the subdevice is associated to\n+ */\n+\n /**\n  * \\brief Set a crop rectangle on one of the V4L2 subdevice pads\n  * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n@@ -189,7 +196,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n \t\tret = -errno;\n \t\tLOG(V4L2Subdev, Error)\n \t\t\t<< \"Unable to get format on pad \" << pad\n-\t\t\t<< \" of \" << deviceNode_ << \": \" << strerror(-ret);\n+\t\t\t<< \" of \" << deviceName() << \": \" << strerror(-ret);\n \t\treturn ret;\n \t}\n \n@@ -255,7 +262,7 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n \t\tret = -errno;\n \t\tLOG(V4L2Subdev, Error)\n \t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n-\t\t\t<< pad << \" of \" << deviceNode_ << \": \"\n+\t\t\t<< pad << \" of \" << deviceName() << \": \"\n \t\t\t<< strerror(-ret);\n \t\treturn ret;\n \t}\n","prefixes":["libcamera-devel","v3","1/8"]}