From patchwork Tue Oct 5 05:44:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14043 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 00F5DBDC71 for ; Tue, 5 Oct 2021 05:44:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 760F3691B8; Tue, 5 Oct 2021 07:44:22 +0200 (CEST) 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="Gs+2VI60"; dkim-atps=neutral Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 49D616023D for ; Tue, 5 Oct 2021 07:44:21 +0200 (CEST) Received: by mail-pl1-x633.google.com with SMTP id x4so1525337pln.5 for ; Mon, 04 Oct 2021 22:44:21 -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:mime-version :content-transfer-encoding; bh=KyYOWQGKmTE5Y3u4WcGVbPThbP4h3QrZQVOPAWc2g9I=; b=Gs+2VI60qaPdQnurGR4+m2YNPRvYr2B9YEUJ0jisaSG8jqYjjmVyhF4RzkEhMq5zjW 1YNreX7e+Flohcet/s1oDMztipHvkr+THEQSidXmdcRGIQeAjni+99+eSJrGc2n3q2Wv prg5sEclZTK4s6KGGc+83UFxTEto3pm+4S60Q= 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:mime-version :content-transfer-encoding; bh=KyYOWQGKmTE5Y3u4WcGVbPThbP4h3QrZQVOPAWc2g9I=; b=7wGgLpe3+JapaiSmIQyIa+CjWVwrgmf4GyDKQApRzy5ezXFAnwWNfT2dMf0k6l7pE/ lWKh2vQUaqYNr3n5LTg/VgYrXoqhK93Gkyua724tOyuQ9QDmiK440lDC5JNWNPjmJkkr x7DBTCdGKI9Gz4DrsfCKZdNhHaLnXQdrLT7NIIKTO5oebJf/K28e9y4HdKW0MljqEGqD YkfWc8m/TTcWqq+XcJyxTscAGSRdRPpONgSJr/XcvdiNNzzCbHbnEYGvRABMCUWQg1AM 03Zz3dmoeOWcSF/VwQW0A17SnfdM6mi+sQAtoNcu0V7c4NP4W9ZyonYH34X7TkFahQ05 /YTQ== X-Gm-Message-State: AOAM531FtyjXz94zUaZ4HGdXphHM42g6dgi0sMQ7BQc5ow09uPz71mXw S+spxuNuuj/br0cA5QS8LsyNg497IS8wrw== X-Google-Smtp-Source: ABdhPJzm8EGRUQ0ctTMIe+PIup75Nf9JRmpFFgudH36qd/50vz24uqeUEYS46lXnaED19I6vneAdtQ== X-Received: by 2002:a17:90b:1b06:: with SMTP id nu6mr1551391pjb.170.1633412659478; Mon, 04 Oct 2021 22:44:19 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:debc:d0db:3bd8:f961]) by smtp.gmail.com with ESMTPSA id l185sm16321230pfd.29.2021.10.04.22.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 22:44:18 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Oct 2021 14:44:14 +0900 Message-Id: <20211005054414.873711-1-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2] 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 | 38 ++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 92e86925..07fda65f 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -69,6 +69,7 @@ public: void statBufferReady(FrameBuffer *buffer); void queuePendingRequests(); void cancelPendingRequests(); + void frameStart(uint32_t sequence); CIO2Device cio2_; ImgUDevice *imgu_; @@ -88,6 +89,7 @@ public: std::unique_ptr ipa_; std::queue pendingRequests_; + std::queue processingRequests_; ControlInfoMap ipaControls_; @@ -568,6 +570,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. @@ -801,6 +805,9 @@ void PipelineHandlerIPU3::stop(Camera *camera) ret |= data->imgu_->stop(); ret |= data->cio2_.stop(); + + data->processingRequests_ = {}; + if (ret) LOG(IPU3, Warning) << "Failed to stop camera " << camera->id(); @@ -851,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; @@ -1107,8 +1116,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; @@ -1399,6 +1408,31 @@ 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(); + + if (request->controls().contains(controls::draft::TestPatternMode)) { + const int32_t testPatternMode = request->controls().get( + controls::draft::TestPatternMode); + + int ret = cio2_.sensor()->setTestPatternMode(testPatternMode); + if (ret) { + LOG(IPU3, Error) << "Failed to set test pattern mode: " + << ret; + } else { + request->metadata().set(controls::draft::TestPatternMode, + testPatternMode); + } + } + } + + delayedCtrls_->applyControls(sequence); +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3) } /* namespace libcamera */