From patchwork Mon Dec 6 05:49:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 15040 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 76054BDB13 for ; Mon, 6 Dec 2021 05:49:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E3F760822; Mon, 6 Dec 2021 06:49:33 +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="a5h5D9h+"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C94AB605C4 for ; Mon, 6 Dec 2021 06:49:29 +0100 (CET) Received: by mail-pj1-x1036.google.com with SMTP id x7so6890026pjn.0 for ; Sun, 05 Dec 2021 21:49:29 -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=dHKC2RYHq2gqVWdlhIepmvHhZoUkoLTI/xkbg0KNkD0=; b=a5h5D9h+iLpXPpN318V6ecKKpbo6yP0zrFF9O3fEYmkk3MO1pp5c+KM40mrgbSOgv9 TsSS4zAklCHU/4d13SKy3LAlSYBBChoCMzu5ztkbzUd8q/Q9RiCFWvXRYW+WQcTqYbci GPyS8gL17kgdvroMj8D77G5dgVlhzS9diq3Tw= 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=dHKC2RYHq2gqVWdlhIepmvHhZoUkoLTI/xkbg0KNkD0=; b=AUgnm4X8jeUB/wqf/GSAybpNDmULIavuR5WSUudcQ9qdxBg7WVQ3t3s0dMkU3bXb92 hArjco05N4Yau9Kqz0V/64WTZU9rag76IeFfPd3+qvJFGSnlsrfzGLeRS0wBk7McDMPP G7WQYZ2G90YFWUzcGAL5HaV+dJX3orgmsIGkAo9iIIgTMCg36fc171jvM2O+NYqBwI4k V85t9mRGZwTH51tzarFpzL5iIacsp5fJlFOIt8xsxsu+wGquGRDf2SssquhU7Qbgeb7l CUZBn7ZNaFa513nJQouIktQU8hsKQPX59IIKJFZxdl66WWKAuW171h0dTcWoScfTms48 C4oA== X-Gm-Message-State: AOAM531nQMfe1hEv8FO17xkWA1sMc7cAbHN56DChMak3xQAsY8aJm5jP lt/GKTnvdXoam8fyDOlQbuPAnqzAxwAGKw== X-Google-Smtp-Source: ABdhPJz7Qvw3eVnGCsUlRwJurehoG4QyX5QpAiWeXBZksIGvl0YpwJERtPs6Vg6TxSa/xZf+e6NlOQ== X-Received: by 2002:a17:902:e5d0:b0:141:cdfe:97d7 with SMTP id u16-20020a170902e5d000b00141cdfe97d7mr40752563plf.65.1638769768062; Sun, 05 Dec 2021 21:49:28 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:749e:cfe6:fd85:77b7]) by smtp.gmail.com with ESMTPSA id a1sm11492368pfv.99.2021.12.05.21.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 21:49:27 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 6 Dec 2021 14:49:18 +0900 Message-Id: <20211206054918.2467049-3-hiroh@chromium.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211206054918.2467049-1-hiroh@chromium.org> References: <20211206054918.2467049-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v10 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 Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 59 +++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 25490dcf..ee1ad27e 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_; @@ -564,6 +568,11 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) if (ret) return ret; + ret = cio2->sensor()->setTestPatternMode( + controls::draft::TestPatternModeEnum::TestPatternModeOff); + if (ret) + return ret; + IPACameraSensorInfo sensorInfo; cio2->sensor()->sensorInfo(&sensorInfo); data->cropRegion_ = sensorInfo.analogCrop; @@ -811,6 +820,8 @@ void PipelineHandlerIPU3::stop(Camera *camera) void IPU3CameraData::cancelPendingRequests() { + processingRequests_ = {}; + while (!pendingRequests_.empty()) { Request *request = pendingRequests_.front(); @@ -853,6 +864,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 +1134,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 +1427,48 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) ipa_->processEvent(ev); } +/* + * \brief Handle the start of frame exposure signal + * \param[in] sequence The sequence number of frame + * + * 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. + */ +void IPU3CameraData::frameStart(uint32_t sequence) +{ + delayedCtrls_->applyControls(sequence); + + if (processingRequests_.empty()) + return; + + /* Handle controls which are to be set ready for the next frame to start. */ + Request *request = processingRequests_.front(); + processingRequests_.pop(); + + /* Takes effect 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); + + 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 */