From patchwork Wed Nov 9 11:27:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17760 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 A2094BD16B for ; Wed, 9 Nov 2022 11:28:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A9B663083; Wed, 9 Nov 2022 12:28:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1667993286; bh=bCCfZHvk169uDJKP97d/XzvqdnKalmVVamMOMJm/ae4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gNRj4ykJJ8f/kK69H7uzdOzJkCy865GXSgpsAFpjEf31Zm/5HCrutXY205Pmv3CiX WSiMpJGXihlil4hQZSDtOLOpQMy64+OOe0lbPRX9i6uD1MY5xaUObuI+vQ9uHgf+zD DcjI0G9XqlwyWTAJloUBTN5p1UTj2P6aFzDjtCUdaSdhJQkEI3xiJdsjZISmi1ow0S 1eiyM5+RPX2L2XV4i8xQ8orE/xaMecM3SXkOKeatgG2FAgBsY68pqAmnVyCY89lp+j /6x3w2LOBU31xfv8TM/HXXBChBPZcCPpzqx/MzivS19+z9X1AaoVqnGkbykxSP1BJL yukljGiW8iBcA== 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 96BA16305E for ; Wed, 9 Nov 2022 12:28:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d7AnKp3i"; 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 F2AED896; Wed, 9 Nov 2022 12:28:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1667993285; bh=bCCfZHvk169uDJKP97d/XzvqdnKalmVVamMOMJm/ae4=; h=From:To:Cc:Subject:Date:From; b=d7AnKp3iFaBPUBpZl7qm63n7ZH7qWClnB6sUoBQNDdCXeX3kWadhDzaIOI1HoaaOX Zi4wgbAHTd94MwcyFCIg+IN+T7UEERMC3nIUmDFTgDeFRcCtlDjWtnPFJstqHaSUWT fZr1/fYqnr3RsDH7Us0h9WA75RMtm6Ex2OAAcmVU= To: libcamera-devel@lists.libcamera.org Date: Wed, 9 Nov 2022 20:27:53 +0900 Message-Id: <20221109112753.2313327-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] 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 --- Changes in v2: - move the control initialization to the pipeline handler --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 58 +++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 455ee2a0..26d8439d 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -93,6 +93,9 @@ public: PipelineHandlerRkISP1 *pipe(); int loadIPA(unsigned int hwRevision); + void initSensorTestPattern(); + int setSensorTestPattern(const ControlList *controls); + Stream mainPathStream_; Stream selfPathStream_; std::unique_ptr sensor_; @@ -104,6 +107,8 @@ public: RkISP1MainPath *mainPath_; RkISP1SelfPath *selfPath_; + controls::draft::TestPatternModeEnum testPatternMode_; + std::unique_ptr ipa_; private: @@ -357,6 +362,47 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return 0; } +void RkISP1CameraData::initSensorTestPattern() +{ + const ControlInfoMap &sensorControls = sensor_->controls(); + + ControlInfoMap::Map ctrlMap = {}; + for (const auto &ipaControl : controlInfo_) + ctrlMap[ipaControl.first] = ipaControl.second; + + auto tpgInfo = sensorControls.find(V4L2_CID_TEST_PATTERN); + if (tpgInfo != sensorControls.end()) { + ctrlMap.emplace(&controls::draft::TestPatternMode, + ControlInfo(tpgInfo->second.values())); + } + + controlInfo_ = ControlInfoMap(std::move(ctrlMap), controls::controls); +} + +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 +866,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 +973,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; @@ -1027,6 +1081,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) if (ret) return ret; + data->initSensorTestPattern(); + std::set streams{ &data->mainPathStream_, &data->selfPathStream_,