From patchwork Wed Jan 8 08:30:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Show Liu X-Patchwork-Id: 2527 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 93FDB6045F for ; Wed, 8 Jan 2020 09:30:19 +0100 (CET) Received: by mail-pf1-x441.google.com with SMTP id i6so1261740pfc.1 for ; Wed, 08 Jan 2020 00:30:19 -0800 (PST) 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=5ETf0lop4gmj3B/JpBtP3zJmLxk+MqjsqGhTmotieOo=; b=HWWrnJA5DH0U1NFa6fiCGSq0c1b6h7uuyIqptC5gWIdBP8T9/qrZD/JtJRWzSq5nc9 jiff3zY2/0WiUQmDQsHlay4S0X7AFdkZZxJsuWgSBvK1MJXqvC/roeJBwZkIQmbg/ccd /wCtyCOSCAl37ZRqAdZ0cw6qQwqJ/ad/4OoWLDCrmx9cCx5gr44r0YhGwXRtRadVMGls 3jMWCOqOj8G4dhpVZJkO993yDAEEKoP8BP/UXFllVgcqdXHNJLJ622lqxZJKpavrTPru kA+P5cSF2+CZN+juDrcAiVDQQJotGwHJq+ymHWmPoAGZSZLYlCsh5fpIB316v6NJfvsx 3QmA== 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=5ETf0lop4gmj3B/JpBtP3zJmLxk+MqjsqGhTmotieOo=; b=bUdPhYxxmIyttHR+qCd27xwZ9XMBoh3Bd5lw+srNoWZfJnyWfVBETX3KJbphVKx8s/ ejkk1sIUaLtpT5hJPRzGuLIJ9WxjgSzmeXZV0dOuT1AujrJ11bC+hTCBg27coqWsNVCW pNOEbLOX7OLIB8p4tZKjn7Xe68ucJHIzn1kwzdLjYggMdZxdEbN0TLZJtn3abdSyUonv +Gx+cmA/gqEBRJXeYznBWzgeHR0GcOr/mFG06GZrRKGh60z9hNXffSR+F/+zEVnQTH/w FdDwO5WyJFRpjm9fWbX0nb4KLECYVZhEzDbkVUTrase36fGRFNx8OQNfNys2YvOHtbIF XEzw== X-Gm-Message-State: APjAAAVxzfFyhcM3YTCIe5OuIg/g9y9ytKE6rgT3IBQRYEGUROPCUl/K Wtz+JwPl5Spuwj8/dkJBhEzuewj6jXw= X-Google-Smtp-Source: APXvYqyJiIkGP/hAO8pJ/b4cec4r/cUepSzuV+vYtYA/cWHO+IZXVXWnsUtHBl0FwqGpLXt1R5OHAg== X-Received: by 2002:aa7:8687:: with SMTP id d7mr3830311pfo.164.1578472217844; Wed, 08 Jan 2020 00:30:17 -0800 (PST) Received: from localhost.localdomain (211-20-20-223.HINET-IP.hinet.net. [211.20.20.223]) by smtp.gmail.com with ESMTPSA id r14sm2440781pfh.10.2020.01.08.00.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 00:30:17 -0800 (PST) From: Show Liu To: libcamera-devel@lists.libcamera.org Cc: peter.griffin@linaro.org, andrey.konovalov@linaro.org, show.liu@linaro.org Date: Wed, 8 Jan 2020 16:30:03 +0800 Message-Id: <20200108083003.16428-2-show.liu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200108083003.16428-1-show.liu@linaro.org> References: <20200108083003.16428-1-show.liu@linaro.org> Subject: [libcamera-devel] [PATCH v3 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, 08 Jan 2020 08:30:19 -0000 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 | 114 ++++++++++++++++++ 3 files changed, 127 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..91a4772 --- /dev/null +++ b/test/pipeline/rkisp1/rkisp1_pipeline_test.cpp @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2020, Linaro + * + * Based on test/pipeline/ipu3/ipu3_pipeline_test.cpp + * + * 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)