From patchwork Thu Nov 4 06:42:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14454 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 BBA70C324E for ; Thu, 4 Nov 2021 06:43:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 57F316033D; Thu, 4 Nov 2021 07:43:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="EN025RLr"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0CF986033D for ; Thu, 4 Nov 2021 07:43:05 +0100 (CET) Received: by mail-pl1-x629.google.com with SMTP id k4so5628944plx.8 for ; Wed, 03 Nov 2021 23:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GlBe5o3IfiKGRsb6hEZvnIPGee2xBRdPPb3dmgbxfzA=; b=EN025RLrb1OtdI0RcqX/5ILp7vGKfw7W2J5CGhRD8AbftSUsVoEjn1VksP1eFbwuQE /lDDQ8NjUhQiYqKF/6vuvU9wkkLsxCFzxhleIJnC1v4znXksFSrImmXhRCvfOd849Lvk OQRuQJk/RyzgbXTHmsprFKfYJAUuX8QlVUwJU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GlBe5o3IfiKGRsb6hEZvnIPGee2xBRdPPb3dmgbxfzA=; b=qeZptontKhzLaigPAgxi8Zne23wDdKGnpZQ3JEPmqnblGUplnsPn35eoWuXNrw3vLc v0fNRHCNNOtMx11sWWSlerwEZPdMeYWWAss1yIR2XyzF0jKNpMkfdzLO4WZ94DA5ztMT swSFPO4jmi3HyNNny4J1ddx0oAIQEtB70kvM3r+I6BrcYsxpCVRZJIK8y+OoAXkV7xz1 RegKHDhl3S9PvWlJ71aTLVr+qSHz1saCG4rnXcEL7MlNPpZ9Wp5trLaM7hy8yBIKpue1 T3NLbm6hsrul0dHt8cZeErN0f8baLX9lnouG+b1B20aoEWSv5KLmT8wh5otIpwRCmVmW RP8A== X-Gm-Message-State: AOAM530Hfa+aVsaPRBunyoKMo9gpZ0rz+20BE777cpu89hRtI3oxtKPF 7WBzuZaLADUZcfrA3fTC13A+XnBlQBwaCA== X-Google-Smtp-Source: ABdhPJyETqHxDglpztu0soOMFhojfs5OjW1rAOz6VuXu98D938zG4aHI1EBA7OsRuuKPEFSrMraZsQ== X-Received: by 2002:a17:90b:4a89:: with SMTP id lp9mr20162763pjb.6.1636008183423; Wed, 03 Nov 2021 23:43:03 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:9022:fd2e:f66e:b99b]) by smtp.gmail.com with ESMTPSA id s6sm4265580pfu.137.2021.11.03.23.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 23:43:02 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Nov 2021 15:42:52 +0900 Message-Id: <20211104064252.2091330-4-hiroh@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211104064252.2091330-1-hiroh@chromium.org> References: <20211104064252.2091330-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/3] libcamera: pipeline: ipu3: Apply the requested test pattern mode 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This enables ipu3 pipeline handler to apply the test pattern mode per frame. Signed-off-by: Hirokazu Honda Reviewed-by: Jean-Michel Hautbois --- src/libcamera/pipeline/ipu3/ipu3.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 63cb7f11..cb141ba9 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -59,6 +59,7 @@ public: void statBufferReady(FrameBuffer *buffer); void queuePendingRequests(); void cancelPendingRequests(); + void frameStart(uint32_t sequence); CIO2Device cio2_; ImgUDevice *imgu_; @@ -78,6 +79,7 @@ public: std::unique_ptr ipa_; std::queue pendingRequests_; + std::queue processingRequests_; ControlInfoMap ipaControls_; @@ -569,6 +571,8 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) cio2->sensor()->sensorInfo(&sensorInfo); data->cropRegion_ = sensorInfo.analogCrop; + cio2->sensor()->setTestPatternMode(controls::draft::TestPatternModeOff); + /* * Configure the H/V flip controls based on the combination of * the sensor and user transform. @@ -797,11 +801,13 @@ void PipelineHandlerIPU3::stop(Camera *camera) int ret = 0; data->cancelPendingRequests(); + data->processingRequests_ = {}; data->ipa_->stop(); ret |= data->imgu_->stop(); ret |= data->cio2_.stop(); + if (ret) LOG(IPU3, Warning) << "Failed to stop camera " << camera->id(); @@ -852,6 +858,8 @@ void IPU3CameraData::queuePendingRequests() info->rawBuffer = rawBuffer; + processingRequests_.push(request); + ipa::ipu3::IPU3Event ev; ev.op = ipa::ipu3::EventProcessControls; ev.frame = info->id; @@ -1131,8 +1139,8 @@ int PipelineHandlerIPU3::registerCameras() data->delayedCtrls_ = std::make_unique(cio2->sensor()->device(), params); - data->cio2_.frameStart().connect(data->delayedCtrls_.get(), - &DelayedControls::applyControls); + data->cio2_.frameStart().connect(data.get(), + &IPU3CameraData::frameStart); /* Convert the sensor rotation to a transformation */ int32_t rotation = 0; @@ -1423,6 +1431,22 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) ipa_->processEvent(ev); } +void IPU3CameraData::frameStart(uint32_t sequence) +{ + if (!processingRequests_.empty()) { + /* Assumes applying the test pattern mode affects immediately. */ + Request *request = processingRequests_.front(); + processingRequests_.pop(); + + int ret = cio2_.sensor()->applyRequestControls(request); + if (ret) + LOG(IPU3, Error) << "Failed applying controls: " << ret; + } + + /* Controls that don't affect immediately are applied in delayedCtrls. */ + delayedCtrls_->applyControls(sequence); +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3) } /* namespace libcamera */