{"id":517,"url":"https://patchwork.libcamera.org/api/patches/517/?format=json","web_url":"https://patchwork.libcamera.org/patch/517/","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":"<20190206060818.13907-3-laurent.pinchart@ideasonboard.com>","date":"2019-02-06T06:07:53","name":"[libcamera-devel,02/27] test: v4l2_device: Use DeviceEnumerator to find a UVCVideo","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"9e98152e86d6449e91bd0f1ab36059ff0349cce8","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/517/mbox/","series":[{"id":170,"url":"https://patchwork.libcamera.org/api/series/170/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=170","date":"2019-02-06T06:07:51","name":"Capture frames throught requests","version":1,"mbox":"https://patchwork.libcamera.org/series/170/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/517/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/517/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@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 CD71761022\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:23 +0100 (CET)","from pendragon.ideasonboard.com (d51A4137F.access.telenet.be\n\t[81.164.19.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C11B2D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Feb 2019 07:08:23 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549433303;\n\tbh=cccDYJYCqgClqeKTmMAB9NH3IcXKA0AXfF7TghxU+UU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=USzbhqmKbdy2P1Hlvto41fEKb6B19J/e9fKHAD4JHFip8Yx7Xg9ueBMpnOptJYUyx\n\tnxOrFnGlfI25cQstjc1Q53MCMX7DfvJ7AgW/vq2a4DUb5oCV+BCqZD4Yxy2ccfuOAU\n\tCzeSSp2/RgaQag1owdZaJqA5PjB2vN7FZu4yY7R4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  6 Feb 2019 08:07:53 +0200","Message-Id":"<20190206060818.13907-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>","References":"<20190206060818.13907-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 02/27] 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":"Wed, 06 Feb 2019 06:08:24 -0000"},"content":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nUtilise 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>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/v4l2_device/v4l2_device_test.cpp | 34 +++++++++++++++++++++++----\n test/v4l2_device/v4l2_device_test.h   |  7 ++++++\n 2 files changed, 36 insertions(+), 5 deletions(-)","diff":"diff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp\nindex 362553712caa..18d014caf4c8 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,40 @@ 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+\tif (enumerator_->enumerate()) {\n+\t\tcerr << \"Failed to enumerate media devices\" << 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+\tDeviceMatch dm(\"uvcvideo\");\n+\tmedia_ = std::move(enumerator_->search(dm));\n+\tif (!media_)\n \t\treturn TestSkip;\n+\n+\tmedia_->acquire();\n+\n+\tfor (MediaEntity *entity : media_->entities()) {\n+\t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n+\t\t\tdev_ = new V4L2Device(entity);\n+\t\t\tbreak;\n+\t\t}\n \t}\n \n-\tdev_ = new V4L2Device(device);\n+\tif (!dev_)\n+\t\treturn TestSkip;\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..ca231ab47fde 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 <memory>\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","02/27"]}