From patchwork Fri Nov 26 05:08:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14794 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 3C1D2BDB13 for ; Fri, 26 Nov 2021 05:08:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EDC6B6049A; Fri, 26 Nov 2021 06:08:25 +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="e55YqXkb"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6BB7F60492 for ; Fri, 26 Nov 2021 06:08:23 +0100 (CET) Received: by mail-pj1-x1029.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so9094531pjc.4 for ; Thu, 25 Nov 2021 21:08:23 -0800 (PST) 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=oOLVLe+hX0g+Qrj/5QThziAsLyhcjI7qFpkEZYN0EjA=; b=e55YqXkb7MvGfFqWA/tlDewrEexEi7IRBhabSls5GxwHXu4x5FpJp9C/9GuqWyTrHm jfK/2V4MxWMBmvhls1c1cdOZhbeCIhnHzw8zeQk1liKncrGRhS5WxUMbiC5W1XpsSy16 s2UL/sVCjHpPbDc9OU2rsj9b7+tSFMHb931rM= 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=oOLVLe+hX0g+Qrj/5QThziAsLyhcjI7qFpkEZYN0EjA=; b=PQIZimPCI6AZyX5Bz6g7IpAJVlUzCIvTnUWS1LVMEDMMpYUbVKq2b+OiMX7hPAHUGP S24GtP0cis59lVuTJjUAcTCWWgDTOA0T/a1kSFDzIHgKAhkytcxLaBAFZuDFCBT72AJq l6B4Iz2LDngHX6zEYTDjGAzQ02s9HdkBUsK6U0ablvxlv6v/4Hnt9v1UnsPO+qaD8VPL KjbYHVMGWEF3Dkww2ZiFUUmOs2bT9UlN9duVzp6g4gHPr+SZnc/b+jP0qEhxFY7QOPyH VpkHjAaf+O+p4oXA1ktX4ivV1BDqHc+NTfj/jJ3wH6ePESenZZyICe+K3pldNNXDTXLt JlCw== X-Gm-Message-State: AOAM532cudWnT5mAiQDYPN74SE3P5sHRAj3yiSpHKsJUIdm5wxgpRcXq Vz0iFxoSEYxnHu8RLBHoCNIIp972D/pc6g== X-Google-Smtp-Source: ABdhPJx1kwtTqog9Bojqt8XWk2ZRazXjDvL0tkZgDRgo2qSoRDWTqi3quIri1p49awouhZu+ApQKGg== X-Received: by 2002:a17:90b:4d8f:: with SMTP id oj15mr12737068pjb.127.1637903301768; Thu, 25 Nov 2021 21:08:21 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:139c:952e:8861:d909]) by smtp.gmail.com with ESMTPSA id k6sm9280248pjt.14.2021.11.25.21.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 21:08:21 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Nov 2021 14:08:10 +0900 Message-Id: <20211126050810.1871781-4-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211126050810.1871781-1-hiroh@chromium.org> References: <20211126050810.1871781-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 3/3] libcamera: pipeline: ipu3: Apply a 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 introduces a way to set controls immediately for a capture in ipu3 pipeline handler. It enables to apply a test pattern mode per frame. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Jean-Michel Hautbois --- src/libcamera/pipeline/ipu3/ipu3.cpp | 55 +++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 25490dcf..31f5f9dd 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_; @@ -76,7 +77,10 @@ public: std::unique_ptr ipa_; + /* Requests before queueing cio2 device. */ std::queue pendingRequests_; + /* Requests queued in cio2 device and before passing imgu device. */ + std::queue processingRequests_; ControlInfoMap ipaControls_; @@ -823,6 +827,8 @@ void IPU3CameraData::cancelPendingRequests() pipe()->completeRequest(request); pendingRequests_.pop(); } + + processingRequests_ = {}; } void IPU3CameraData::queuePendingRequests() @@ -853,6 +859,8 @@ void IPU3CameraData::queuePendingRequests() info->rawBuffer = rawBuffer; + processingRequests_.push(request); + ipa::ipu3::IPU3Event ev; ev.op = ipa::ipu3::EventProcessControls; ev.frame = info->id; @@ -1121,8 +1129,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; @@ -1414,6 +1422,49 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) ipa_->processEvent(ev); } +void IPU3CameraData::frameStart(uint32_t sequence) +{ + /* + * Handle the start of frame exposure signal. + * + * Inspect the list of pending requests waiting for a RAW frame to be + * produced and apply controls for the 'next' one. + * + * Some controls need to be applied immediately, such as the + * TestPatternMode one. Other controls are handled through the delayed + * controls class. + */ + + delayedCtrls_->applyControls(sequence); + + if (!processingRequests_.empty()) { + /* Handle controls which are to be set ready for the next frame to start. */ + Request *request = processingRequests_.front(); + processingRequests_.pop(); + + /* Assumes applying the test pattern mode affects immediately. */ + if (!request->controls().contains(controls::draft::TestPatternMode)) + return; + const int32_t testPatternMode = request->controls().get( + controls::draft::TestPatternMode); + + LOG(IPU3, Debug) << "Apply test pattern mode: " + << testPatternMode; + + int ret = cio2_.sensor()->setTestPatternMode( + static_cast( + testPatternMode)); + if (ret) { + LOG(IPU3, Error) << "Failed to set test pattern mode: " + << ret; + return; + } + + request->metadata().set(controls::draft::TestPatternMode, + testPatternMode); + } +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3) } /* namespace libcamera */