From patchwork Wed Oct 23 09:52:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Show Liu X-Patchwork-Id: 2210 Return-Path: Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B286060C0F for ; Wed, 23 Oct 2019 11:53:12 +0200 (CEST) Received: by mail-pf1-x443.google.com with SMTP id y5so12592455pfo.4 for ; Wed, 23 Oct 2019 02:53:12 -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=1yKgIzaSQIdDWzOzWDLimlSo+2ECeuRbrUWxdl9upqA=; b=xQKfOlZ8E/nNukjC0mVgPcP/4p48WtJikVF+GClPvtoxT6uIIB3iP55o/tkLapwxeh Op1ipAnz+rdbRgk8DW0mJfnfmwTADTpi+mmFK2+roe3l9VD5vmj/C4XuBVsoESDMfy4n VjXQ32exjBLm3T13Kk9KwgQUcxYErVeCAKjRxI3RTFxr9YzECr1nDrDGnC/r68BFbm/q xW+shsQwy9RKwhwtD9pOBTizxJfnfAbXGu8K8sXiitAQsXj3nCVWWQx0t90v9u0r1QnQ euAkB49MGDTpRpVWODe+9xOKovEc/BJR/nYNegBFBHp5AvTPCJy9zmEwncSaSDtiBhF7 EpzQ== 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=1yKgIzaSQIdDWzOzWDLimlSo+2ECeuRbrUWxdl9upqA=; b=bHRBhS0DqYGUoElMeRwZ45Nq9xJkRr93m6z8AWaQ4f9jGOtC/j2wVh2tnVPkQGND9D q8johip8n0fovotSda9eyoc2OjEqBYKmKOnPoDZ0TxVlH9GxV90ZhtjQw+0/mzXWcl/o H4+hKHweWQqInjzxQk3u8BtqkAEg+taOJyUvNI6fe5pcou2kGImGyjiLMvRVX+n8m3Ga +5wFDOVtkDZQqIXG3J9+iJO3zJz6WQACA2wqeXTzNIodQKeqm7tzZoYexl4QoKC5XvfY QrXMoiNhAGIiaXSRGI0kHqKhDYA9U2PQYMX2KGSmQPT8BUocg/TN5ft1vdWrLU2gEkXa UVHA== X-Gm-Message-State: APjAAAVhWcOpTUDWPGy2y2NfkrhmlCS7v3LHu4+tCxdyLINpmIt5HbC8 k1zaoXNmm4QucljdNcZY9XcEWagasus= X-Google-Smtp-Source: APXvYqyM6DIlyEGGbkmkadgCFWaDKudSzccsyxyXrQ0GqU+ZB1tjWqUFhsQ3tjTj3NsoCSENefiHAg== X-Received: by 2002:a63:368c:: with SMTP id d134mr5818461pga.321.1571824391077; Wed, 23 Oct 2019 02:53:11 -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 m5sm23154759pgt.15.2019.10.23.02.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 02:53:10 -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: Wed, 23 Oct 2019 17:52:54 +0800 Message-Id: <20191023095254.1479-2-show.liu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023095254.1479-1-show.liu@linaro.org> References: <20191023095254.1479-1-show.liu@linaro.org> Subject: [libcamera-devel] [PATCH 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: Wed, 23 Oct 2019 09:53:12 -0000 Signed-off-by: Show Liu --- test/pipeline/meson.build | 1 + test/pipeline/rkisp1/meson.build | 12 ++ test/pipeline/rkisp1/rkisp1_pipeline_test.cpp | 109 ++++++++++++++++++ 3 files changed, 122 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..a463309 --- /dev/null +++ b/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * rkisp1_pipeline_test.cpp - Rockchip RK3399 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 dm_rkisp1 = enumerator->search(dm); + if (!dm_rkisp1) { + cerr << "Failed to find rkisp1: test skip" << endl; + return TestSkip; + } + + int ret = dm_rkisp1->populate(); + if (ret) { + cerr << "Failed to populate media device " << dm_rkisp1->deviceNode() << endl; + return TestFail; + } + + sensors_ = 0; + const vector &entities = dm_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)