From patchwork Tue Oct 18 08:34:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17621 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D9739BD16B for ; Tue, 18 Oct 2022 08:34:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F015A62E13; Tue, 18 Oct 2022 10:34:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666082090; bh=I95aLvl80NyxGP+T7jTfuDLd8aFZ4NvMzalyqWnFeY8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DF2z8Ohrk3kyFhI2UTkFX3vVLBW6Jq7WOwH2ecIZdtmWAH+EMlXXA/49yAIgzR3k4 aGkCAlkhcQSHZj9VG6Nmo6WTS7RqCRqVZwspeHmLBWQpOVEvkjlSNHBk81JbfSLXqO Ya6qy+/z+9GiOWKr4MmwZkOtKSHyAtteflDpbzUTNgoFfiFfmCDukAq9IyiikY3rn1 ZwRrHrQv1FeX8/ilzQCTNjy2GTcnbzD5Wv9XpAviGjVsPsT1mMiEtAfRxBfON5TxTX lsL+SAUS+I6F/w7tMHPJorSGvO7BQZoyXASZa/386Oe5Rx0I3i/lyF/MrSjx4VzhI4 HluhYg+nyt8nA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1210C62DD1 for ; Tue, 18 Oct 2022 10:34:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pWS+8L50"; dkim-atps=neutral Received: from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A00558CC; Tue, 18 Oct 2022 10:34:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1666082087; bh=I95aLvl80NyxGP+T7jTfuDLd8aFZ4NvMzalyqWnFeY8=; h=From:To:Cc:Subject:Date:From; b=pWS+8L506kAZHYTm5xNnCaqNTIfCbegpLST07xE8uJBb+GakKKWMERdXSILcUP+U5 XfnmpmtGvGAjK13ebulGx3lJn3Iv6jT+K5EygMJP5POcNbU99lmp0h7MOK7YtnWOdF uwp5PijpFCAM3dzx9C/S8yCaYU4lDxZkSNrn8W9g= To: libcamera-devel@lists.libcamera.org Date: Tue, 18 Oct 2022 17:34:38 +0900 Message-Id: <20221018083438.2937184-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] rkisp1: Add support for sensor test pattern control 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-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support for the TestPatternMode control. Signed-off-by: Paul Elder --- src/ipa/rkisp1/rkisp1.cpp | 7 +++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 38 +++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 3f5c1a58..1aac8884 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -183,6 +183,13 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, /* Return the controls handled by the IPA. */ ControlInfoMap::Map ctrlMap = rkisp1Controls; + + auto tpgInfo = sensorControls.find(V4L2_CID_TEST_PATTERN); + if (tpgInfo != sensorControls.end()) { + ctrlMap.emplace(&controls::draft::TestPatternMode, + ControlInfo(tpgInfo->second.values())); + } + *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls); return 0; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 455ee2a0..42803266 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -93,6 +93,8 @@ public: PipelineHandlerRkISP1 *pipe(); int loadIPA(unsigned int hwRevision); + int setSensorTestPattern(const ControlList *controls); + Stream mainPathStream_; Stream selfPathStream_; std::unique_ptr sensor_; @@ -104,6 +106,8 @@ public: RkISP1MainPath *mainPath_; RkISP1SelfPath *selfPath_; + controls::draft::TestPatternModeEnum testPatternMode_; + std::unique_ptr ipa_; private: @@ -357,6 +361,30 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return 0; } +int RkISP1CameraData::setSensorTestPattern(const ControlList *controls) +{ + if (!controls) + return 0; + + const auto &testPattern = controls->get(controls::draft::TestPatternMode); + + if (!testPattern) + return 0; + + if (testPattern && *testPattern == testPatternMode_) + return 0; + + testPatternMode_ = static_cast(*testPattern); + + int ret = sensor_->setTestPatternMode(testPatternMode_); + if (ret && !sensor_->testPatternModes().empty()) + return ret; + + LOG(RkISP1, Debug) << "Set test pattern to " << static_cast(testPatternMode_); + + return 0; +} + void RkISP1CameraData::paramFilled(unsigned int frame) { PipelineHandlerRkISP1 *pipe = RkISP1CameraData::pipe(); @@ -820,11 +848,15 @@ int PipelineHandlerRkISP1::freeBuffers(Camera *camera) return 0; } -int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlList *controls) +int PipelineHandlerRkISP1::start(Camera *camera, const ControlList *controls) { RkISP1CameraData *data = cameraData(camera); int ret; + ret = data->setSensorTestPattern(controls); + if (ret) + return ret; + /* Allocate buffers for internal pipeline usage. */ ret = allocateBuffers(camera); if (ret) @@ -923,6 +955,10 @@ int PipelineHandlerRkISP1::queueRequestDevice(Camera *camera, Request *request) { RkISP1CameraData *data = cameraData(camera); + int ret = data->setSensorTestPattern(&request->controls()); + if (ret) + return ret; + RkISP1FrameInfo *info = data->frameInfo_.create(data, request); if (!info) return -ENOENT;