From patchwork Thu Oct 24 06:40:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Show Liu X-Patchwork-Id: 2216 Return-Path: Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 738C861376 for ; Thu, 24 Oct 2019 08:40:27 +0200 (CEST) Received: by mail-pf1-x441.google.com with SMTP id c13so3281642pfp.5 for ; Wed, 23 Oct 2019 23:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FE69LTTytZSkOA2byUYOeEH1L/XXPhuNHMguBRSbUoc=; b=S7aLdaCEvPuNgrcbxcoUcX0qoEu2mw+xS6smW1l8C01DvvXw6icTRqfSCzht7AXndT b4rOW5VcI0BzC62o8Wm4ddV39Pior4daCvkFZP88amFIGPDR0w0wQ3C9z+XHFg2UKRLY +1eCmOXhspJl1ZIkWEIwvvoyq3vUbGQ7uN4CXDb1xDnAyhQXE3IV4zY+7j+szxd2q+Pz 5YknFrQpqgS3UOXMna45l3H1yoxNYlq6bbB456O83CEgkvizpL0KFdpODrUZBO/3eQ5U 6ozYc6u1wQRdwji5uV07uqtb+wxE9x/oN9XsjbLhJahnZMmB+25td61RvCwPWceI5ypI tQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FE69LTTytZSkOA2byUYOeEH1L/XXPhuNHMguBRSbUoc=; b=pIiDTSih3WYA/YnmO2vWJE2jT8zrUkDOMIMqvUD6G+wlWWOp8+SiCcNE5l9WP7nM9z XXQYgkbFt4nE/Pd0xtanIjC2SlekgERPdxQmpY/Si07Q7LLA9pOjbk/xaygD8YLobMlm rRbLuVt45vCxEWgf1LJDoQfGii69VhsWEGSxDDZ2yqWGF/9Z8UU2hxkTex30wtoJUVBR mnefOMJxLvmb7Ff1EjNpiI9Ux0eZUwRI/pMO5lLnBeH5SHsU9J1DDDor8A8mwNG46eKk 4V9A1ExnCaxZnjmcevbBOZ6zIgVMog9GaAkBDp2y8pH58hlfvBNKaxFtdvNQCbiYedGR BIYg== X-Gm-Message-State: APjAAAWEmRmD1spl9hnpL5BO1i1uz/AY+IqgvVfOno4/6W6C2Xui78rP J3fOar1t0YRjoY3BeMwcsL+650OX/FE= X-Google-Smtp-Source: APXvYqxR/Jl0aRuwlauZP2CTVheDWnFFQzH+BX/rtrEI5v6bEQpQaGU7WbasfZwzZBJMdSy7l74PxA== X-Received: by 2002:a17:90a:a417:: with SMTP id y23mr4900827pjp.126.1571899225205; Wed, 23 Oct 2019 23:40:25 -0700 (PDT) Received: from localhost.localdomain (211-20-20-223.HINET-IP.hinet.net. [211.20.20.223]) by smtp.gmail.com with ESMTPSA id x190sm5571696pfc.89.2019.10.23.23.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 23:40:24 -0700 (PDT) From: Show Liu To: libcamera-devel@lists.libcamera.org Cc: peter.griffin@linaro.org, andrey.konovalov@linaro.org, show.liu@linaro.org Date: Thu, 24 Oct 2019 14:40:08 +0800 Message-Id: <20191024064008.25077-2-show.liu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024064008.25077-1-show.liu@linaro.org> References: <20191024064008.25077-1-show.liu@linaro.org> Subject: [libcamera-devel] [PATCH v2 1/1] rkisp1: add pipeline test for rkisp1 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 06:40:27 -0000 This is a simple test tool for rkisp1 pipeline refer from IPU3 pipeline test. Signed-off-by: Show Liu Reviewed-by: Kieran Bingham --- test/pipeline/meson.build | 1 + test/pipeline/rkisp1/meson.build | 12 ++ test/pipeline/rkisp1/rkisp1_pipeline_test.cpp | 112 ++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 test/pipeline/rkisp1/meson.build create mode 100644 test/pipeline/rkisp1/rkisp1_pipeline_test.cpp diff --git a/test/pipeline/meson.build b/test/pipeline/meson.build index f434c79..157f789 100644 --- a/test/pipeline/meson.build +++ b/test/pipeline/meson.build @@ -1 +1,2 @@ subdir('ipu3') +subdir('rkisp1') diff --git a/test/pipeline/rkisp1/meson.build b/test/pipeline/rkisp1/meson.build new file mode 100644 index 0000000..d3f9749 --- /dev/null +++ b/test/pipeline/rkisp1/meson.build @@ -0,0 +1,12 @@ +rkisp1_test = [ + ['rkisp1_pipeline_test', 'rkisp1_pipeline_test.cpp'], +] + +foreach t : rkisp1_test + exe = executable(t[0], t[1], + dependencies : libcamera_dep, + link_with : test_libraries, + include_directories : test_includes_internal) + + test(t[0], exe, suite : 'rkisp1', is_parallel : false) +endforeach diff --git a/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp b/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp new file mode 100644 index 0000000..274955e --- /dev/null +++ b/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * rkisp1_pipeline_test.cpp - Rockchip RK3399 rkisp1 pipeline test + */ + +#include + +#include +#include +#include + +#include +#include + +#include "device_enumerator.h" +#include "media_device.h" +#include "media_object.h" +#include "test.h" + +using namespace std; +using namespace libcamera; + +/* + * Verify that the RK3399 pipeline handler gets matched and cameras + * are enumerated correctly. + * + * The test is supposed to be run on rockchip platform. + * + * The test lists all cameras registered in the system, if any camera is + * available at all. + */ +class RKISP1PipelineTest : public Test +{ +protected: + int init(); + int run(); + void cleanup(); + +private: + CameraManager *cameraManager_; + unsigned int sensors_; +}; + +int RKISP1PipelineTest::init() +{ + unique_ptr enumerator = DeviceEnumerator::create(); + if (!enumerator) { + cerr << "Failed to create device enumerator" << endl; + return TestFail; + } + + if (enumerator->enumerate()) { + cerr << "Failed to enumerate media devices" << endl; + return TestFail; + } + + DeviceMatch dm("rkisp1"); + + std::shared_ptr rkisp1 = enumerator->search(dm); + if (!rkisp1) { + cerr << "Failed to find rkisp1: test skip" << endl; + return TestSkip; + } + + int ret = rkisp1->populate(); + if (ret) { + cerr << "Failed to populate media device " + << rkisp1->deviceNode() << endl; + return TestFail; + } + + sensors_ = 0; + const vector &entities = rkisp1->entities(); + for (MediaEntity *entity : entities) { + if (entity->function() == MEDIA_ENT_F_CAM_SENSOR) + sensors_++; + } + + cameraManager_ = new CameraManager(); + ret = cameraManager_->start(); + if (ret) { + cerr << "Failed to start the CameraManager" << endl; + return TestFail; + } + + return 0; +} + +int RKISP1PipelineTest::run() +{ + auto cameras = cameraManager_->cameras(); + for (const std::shared_ptr &cam : cameras) + cout << "Found camera '" << cam->name() << "'" << endl; + + if (cameras.size() != sensors_) { + cerr << cameras.size() << " cameras registered, but " << sensors_ + << " were expected" << endl; + return TestFail; + } + + return TestPass; +} + +void RKISP1PipelineTest::cleanup() +{ + cameraManager_->stop(); + delete cameraManager_; +} + +TEST_REGISTER(RKISP1PipelineTest)