{"id":488,"url":"https://patchwork.libcamera.org/api/1.1/patches/488/?format=json","web_url":"https://patchwork.libcamera.org/patch/488/","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":"<20190203110102.5663-2-kieran.bingham@ideasonboard.com>","date":"2019-02-03T11:00:52","name":"[libcamera-devel,01/11] test: v4l2_device: Use DeviceEnumerator to find a UVCVideo","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"caf58d7d188a4eb8a5d4cabf61e347c4dee69c28","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/488/mbox/","series":[{"id":165,"url":"https://patchwork.libcamera.org/api/1.1/series/165/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=165","date":"2019-02-03T11:00:51","name":"libcamera: V4L2 Streams","version":1,"mbox":"https://patchwork.libcamera.org/series/165/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/488/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/488/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@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 2D68660DB8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 Feb 2019 12:01:07 +0100 (CET)","from localhost.localdomain\n\t(218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A97835AA;\n\tSun,  3 Feb 2019 12:01:06 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549191666;\n\tbh=6IEmseyYCDF7xAtlbgbit0IeGxn/U4GY5MhKc462adI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ZEUEy6Bumu2yw9oSf5sGD6SudSHxeN+f3nIkolNzvqmGc+Rgky+8ev5AwYRG7r7gz\n\tGPvNmDcGiW92HhjL2psGl9sF3S/8H1uN0js3Nneoj0IKziWKmVlJ5u1A+KO5ZCScBC\n\t1jNwls9GMYQPcAAcf5ELOXNHOXL+je7NdqOVtRLs=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Sun,  3 Feb 2019 12:00:52 +0100","Message-Id":"<20190203110102.5663-2-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.19.1","In-Reply-To":"<20190203110102.5663-1-kieran.bingham@ideasonboard.com>","References":"<20190203110102.5663-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 01/11] test: v4l2_device: Use\n\tDeviceEnumerator to find a UVCVideo","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, 03 Feb 2019 11:01:07 -0000"},"content":"Utilise the existing DeviceEnumerator system to identify a suitable\nV4L2Device for testing.\n\nSpecifically target these tests at a uvcvideo driver based device as a known\nsupported target.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/v4l2_device/v4l2_device_test.cpp | 28 +++++++++++++++++++++------\n test/v4l2_device/v4l2_device_test.h   |  7 +++++++\n 2 files changed, 29 insertions(+), 6 deletions(-)","diff":"diff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp\nindex 362553712caa..e71a93cf2453 100644\n--- a/test/v4l2_device/v4l2_device_test.cpp\n+++ b/test/v4l2_device/v4l2_device_test.cpp\n@@ -10,6 +10,10 @@\n \n #include \"v4l2_device_test.h\"\n \n+#include \"device_enumerator.h\"\n+#include \"media_device.h\"\n+\n+using namespace std;\n using namespace libcamera;\n \n bool exists(const std::string &path)\n@@ -24,20 +28,32 @@ bool exists(const std::string &path)\n \n int V4L2DeviceTest::init()\n {\n-\tconst std::string device(\"/dev/video0\");\n+\tenumerator_ = DeviceEnumerator::create();\n+\tif (!enumerator_) {\n+\t\tcerr << \"Failed to create device enumerator\" << endl;\n+\t\treturn TestFail;\n+\t}\n \n-\t/* Validate the device node exists. */\n-\tif (!exists(device)) {\n-\t\tstd::cout << \"No video device available\" << std::endl;\n-\t\treturn TestSkip;\n+\tif (enumerator_->enumerate()) {\n+\t\tcerr << \"Failed to enumerate media devices\" << endl;\n+\t\treturn TestFail;\n \t}\n \n-\tdev_ = new V4L2Device(device);\n+\tDeviceMatch dm(\"uvcvideo\");\n+\tmedia_ = std::move(enumerator_->search(dm));\n+\tif (!media_)\n+\t\treturn TestSkip;\n+\n+\tmedia_->acquire();\n+\n+\tdev_ = new V4L2Device(*media_->entities()[0]);\n \n \treturn dev_->open();\n }\n \n void V4L2DeviceTest::cleanup()\n {\n+\tmedia_->release();\n+\n \tdelete dev_;\n };\ndiff --git a/test/v4l2_device/v4l2_device_test.h b/test/v4l2_device/v4l2_device_test.h\nindex 405cb7d6f404..d8652a5c9e15 100644\n--- a/test/v4l2_device/v4l2_device_test.h\n+++ b/test/v4l2_device/v4l2_device_test.h\n@@ -7,7 +7,12 @@\n #ifndef __LIBCAMERA_V4L2_DEVICE_TEST_H_\n #define __LIBCAMERA_V4L2_DEVICE_TEST_H_\n \n+#include <unistd.h>\n+\n #include \"test.h\"\n+\n+#include \"device_enumerator.h\"\n+#include \"media_device.h\"\n #include \"v4l2_device.h\"\n \n using namespace libcamera;\n@@ -21,6 +26,8 @@ protected:\n \tint init();\n \tvoid cleanup();\n \n+\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n+\tstd::shared_ptr<MediaDevice> media_;\n \tV4L2Device *dev_;\n };\n \n","prefixes":["libcamera-devel","01/11"]}