From patchwork Tue Nov 23 19:08:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14730 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 DF52EBF415 for ; Tue, 23 Nov 2021 19:08:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C5CE60230; Tue, 23 Nov 2021 20:08:28 +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="e5s5yaVj"; dkim-atps=neutral Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B4C0D60121 for ; Tue, 23 Nov 2021 20:08:26 +0100 (CET) Received: by mail-pj1-x102b.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so2732491pjj.0 for ; Tue, 23 Nov 2021 11:08:26 -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=NAGwrqk/6sxLdYfulrdkK4538cN3U1ACtQJMMm76BKM=; b=e5s5yaVjR9BQNRCsVz09r1DbU5cvZekHsVSCFnhvZjHC+Vq1zUUed0zHkg+qOeJ9DK drlG1Owch40bodxIl9haPKUrYrz7Oycioh+oeKAyodHw7DtNbdpAcsYuHhHiUXVOGzQb 4BuipZ/8CASQJNAc9GV4pK9+wCQ4HluNKk2bQ= 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=NAGwrqk/6sxLdYfulrdkK4538cN3U1ACtQJMMm76BKM=; b=JTM9AcJqODMBRiZK0fzO3lyL5a+U5iLMcOtQglKiCpX1kTzW/kSp7B/720GdmmSUmP /UiyAFMlZxGYMY+C98iI+qAJMJOYgJV0oRaQV1ePasXG3f5MPF7uHYpf0rcv/cdSC2XP G2zaxaaQZIVtycv+1cqSUl05PrDSfFkgN9uIqMDxDxxSK5k1Fv5jrWb5QUwjh6F39B71 xOg3B62KSCscq7hQ/XT+I4Za1aAWQLoKc+/Z1oxO+7rMbc62H8DVbMJ4HCrrXaS1xmQq S/egwRHhG0DCNUeCbdoLBaVYSeu0+4MCxJBNW63C5kGcOzYDylsV9mo9unTYWeDp8ApX fsIQ== X-Gm-Message-State: AOAM530kp7UUa88OggUb4F031dtBtNGGcD/4//8bS7hJiNLKab08UzpU sBKLjSEOA8x0tYX8f3BKkzdEkD01QvstFA== X-Google-Smtp-Source: ABdhPJy+F6U8LOZ5fyoSWUYJWXwY3XRbNd8zsHrmOZGNAVLTOADW1SVpfO92IobzRiUTFGND9w7Uxw== X-Received: by 2002:a17:90b:30c4:: with SMTP id hi4mr5981503pjb.12.1637694504636; Tue, 23 Nov 2021 11:08:24 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:cc8f:f5a6:5a9f:7275]) by smtp.gmail.com with ESMTPSA id t4sm14550916pfq.163.2021.11.23.11.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Nov 2021 11:08:24 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Nov 2021 04:08:12 +0900 Message-Id: <20211123190812.69805-4-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211123190812.69805-1-hiroh@chromium.org> References: <20211123190812.69805-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 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 enables ipu3 pipeline handler to apply a test pattern mode per frame. Signed-off-by: Hirokazu Honda Reviewed-by: Jean-Michel Hautbois Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 45 ++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 25490dcf..a15c6466 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_; @@ -803,6 +807,7 @@ void PipelineHandlerIPU3::stop(Camera *camera) ret |= data->imgu_->stop(); ret |= data->cio2_.stop(); + if (ret) LOG(IPU3, Warning) << "Failed to stop camera " << camera->id(); @@ -823,6 +828,8 @@ void IPU3CameraData::cancelPendingRequests() pipe()->completeRequest(request); pendingRequests_.pop(); } + + processingRequests_ = {}; } void IPU3CameraData::queuePendingRequests() @@ -853,6 +860,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 +1130,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 +1423,38 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) ipa_->processEvent(ev); } +void IPU3CameraData::frameStart(uint32_t 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)) { + 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; + } else { + request->metadata().set(controls::draft::TestPatternMode, + testPatternMode); + } + } + } + + /* Controls that don't affect immediately are applied in delayedCtrls. */ + delayedCtrls_->applyControls(sequence); +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3) } /* namespace libcamera */