Patch Detail
Show a patch.
GET /api/patches/971/?format=api
{ "id": 971, "url": "https://patchwork.libcamera.org/api/patches/971/?format=api", "web_url": "https://patchwork.libcamera.org/patch/971/", "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": "<20190414013506.10515-3-niklas.soderlund@ragnatech.se>", "date": "2019-04-14T01:34:57", "name": "[libcamera-devel,RFC,02/11] libcamera: media_device: Open and close media device inside populate()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4532b41bd69e5df958fd822e7aa8d7a1868aa3eb", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/971/mbox/", "series": [ { "id": 249, "url": "https://patchwork.libcamera.org/api/series/249/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=249", "date": "2019-04-14T01:34:55", "name": "libcamerea: Add support for exclusive access to cameras between processes", "version": 1, "mbox": "https://patchwork.libcamera.org/series/249/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/971/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/971/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1138960DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 14 Apr 2019 03:35:16 +0200 (CEST)", "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 8cd43bf5-5e55-11e9-8e2c-005056917f90;\n\tSun, 14 Apr 2019 03:35:15 +0200 (CEST)" ], "X-Halon-ID": "8cd43bf5-5e55-11e9-8e2c-005056917f90", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 14 Apr 2019 03:34:57 +0200", "Message-Id": "<20190414013506.10515-3-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190414013506.10515-1-niklas.soderlund@ragnatech.se>", "References": "<20190414013506.10515-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 02/11] libcamera: media_device: Open and\n\tclose media device inside populate()", "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": "Sun, 14 Apr 2019 01:35:16 -0000" }, "content": "Remove the need for the caller to open and close the media device when\npopulating the MediaDeivce. This is done as an effort to make the usage\nof the MediaDevice less error prone and the interface stricter.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/device_enumerator.cpp | 8 +-------\n src/libcamera/media_device.cpp | 10 ++++++++--\n test/media_device/media_device_print_test.cpp | 6 ------\n test/pipeline/ipu3/ipu3_pipeline_test.cpp | 5 -----\n 4 files changed, 9 insertions(+), 20 deletions(-)", "diff": "diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex 58b81c354a706f03..6c08806d17dbfeec 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -212,11 +212,7 @@ int DeviceEnumerator::addDevice(const std::string &deviceNode)\n {\n \tstd::shared_ptr<MediaDevice> media = std::make_shared<MediaDevice>(deviceNode);\n \n-\tint ret = media->open();\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = media->populate();\n+\tint ret = media->populate();\n \tif (ret < 0) {\n \t\tLOG(DeviceEnumerator, Info)\n \t\t\t<< \"Unable to populate media device \" << deviceNode\n@@ -243,8 +239,6 @@ int DeviceEnumerator::addDevice(const std::string &deviceNode)\n \t\t\treturn ret;\n \t}\n \n-\tmedia->close();\n-\n \tLOG(DeviceEnumerator, Debug)\n \t\t<< \"Added device \" << deviceNode << \": \" << media->driver();\n \ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 1e9024bf97217bcf..ecb00a1d5abffe80 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -220,6 +220,10 @@ int MediaDevice::populate()\n \n \tclear();\n \n+\tret = open();\n+\tif (ret)\n+\t\treturn ret;\n+\n \t/*\n \t * Keep calling G_TOPOLOGY until the version number stays stable.\n \t */\n@@ -236,7 +240,7 @@ int MediaDevice::populate()\n \t\t\tLOG(MediaDevice, Error)\n \t\t\t\t<< \"Failed to enumerate topology: \"\n \t\t\t\t<< strerror(-ret);\n-\t\t\treturn ret;\n+\t\t\tgoto err_out;\n \t\t}\n \n \t\tif (version == topology.topology_version)\n@@ -260,6 +264,8 @@ int MediaDevice::populate()\n \t populatePads(topology) &&\n \t populateLinks(topology))\n \t\tvalid_ = true;\n+err_out:\n+\tclose();\n \n \tdelete[] ents;\n \tdelete[] interfaces;\n@@ -268,7 +274,7 @@ int MediaDevice::populate()\n \n \tif (!valid_) {\n \t\tclear();\n-\t\treturn -EINVAL;\n+\t\treturn ret ? ret : -EINVAL;\n \t}\n \n \treturn 0;\ndiff --git a/test/media_device/media_device_print_test.cpp b/test/media_device/media_device_print_test.cpp\nindex 3eef973939201b27..ceffd538e13fca73 100644\n--- a/test/media_device/media_device_print_test.cpp\n+++ b/test/media_device/media_device_print_test.cpp\n@@ -124,10 +124,6 @@ int MediaDevicePrintTest::testMediaDevice(const string deviceNode)\n \n \tdev.close();\n \n-\tret = dev.open();\n-\tif (ret)\n-\t\treturn ret;\n-\n \tret = dev.populate();\n \tif (ret)\n \t\treturn ret;\n@@ -135,8 +131,6 @@ int MediaDevicePrintTest::testMediaDevice(const string deviceNode)\n \t/* Print out the media graph. */\n \tprintMediaGraph(dev, cerr);\n \n-\tdev.close();\n-\n \treturn 0;\n }\n \ndiff --git a/test/pipeline/ipu3/ipu3_pipeline_test.cpp b/test/pipeline/ipu3/ipu3_pipeline_test.cpp\nindex 953f0233cde485cb..1d4cc4d4950b8391 100644\n--- a/test/pipeline/ipu3/ipu3_pipeline_test.cpp\n+++ b/test/pipeline/ipu3/ipu3_pipeline_test.cpp\n@@ -71,11 +71,6 @@ int IPU3PipelineTest::init()\n \t\treturn TestSkip;\n \t}\n \n-\tif (cio2->open()) {\n-\t\tcerr << \"Failed to open media device \" << cio2->deviceNode() << endl;\n-\t\treturn TestFail;\n-\t}\n-\n \t/*\n \t * Camera sensor are connected to the CIO2 unit.\n \t * Count how many sensors are connected in the system\n", "prefixes": [ "libcamera-devel", "RFC", "02/11" ] }