From patchwork Tue Oct 26 10:39: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: 14332 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 D990DBF415 for ; Tue, 26 Oct 2021 10:39:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9203F64877; Tue, 26 Oct 2021 12:39:27 +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="DyKGdp0y"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D75C060123 for ; Tue, 26 Oct 2021 12:39:23 +0200 (CEST) Received: by mail-pl1-x62e.google.com with SMTP id i5so10019357pla.5 for ; Tue, 26 Oct 2021 03:39:23 -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=sn/P85sG2vAsIOKU//aGC58jCODDm1MBR6KhgoqZOgo=; b=DyKGdp0yK5X/5KyrwrZWyRtcvaPcEGfMEa3BoRFrlepcQjMF6fyjlNaUa/OO8bwDlQ OIP042C0rPVB7PIZ6J+ejg1vKI5nkgeliaosUvR6HJFvKqzCcZIXgIUIlFgd+GG9ZIg2 J5MGy+vR+RfcLfe4RFBVkekQfn1+aNsOlCwx0= 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=sn/P85sG2vAsIOKU//aGC58jCODDm1MBR6KhgoqZOgo=; b=k/Zh80DmehUEyk/iR1cUkNZwJicIR/XCoZ1JLoqWZWnpoXtAAP7+CvmGWFXBG+Q/Yo yn9oqoHvi38reLd3GZwkZR9+v1LZCLqrEhGnY2lNrn917mRqTiRQI5+gRt9sZaiq8/w0 YSC1lwp1npMuy0Uk0fbSSbX4i2lIPQ8DR9/816DlCxu1ZWYLRCjsXB/sqiRmuMJYf7gd uz7OMrSfBsHTY4bbZzFCNSQ7I1wkpESuonjtNZy4TpTjK3C/zrCbmAPt+36j3UvnzryB Pkj0akkXTEI8EtlATMSb6Y7VgMQPflZZ2rFEzapu7Ftwpq30B1HR/XT9TMzzfcHS2GJx wvMg== X-Gm-Message-State: AOAM532o7lCuPgZEGfYujU83NQQEI8gqXlt9ep4StRRPnDgYUtzzEmez u0J/TyHAIUJ5dsYM25CJUA13FudcOqlj6Q== X-Google-Smtp-Source: ABdhPJxoNgKolCRd32R7vEkhAoBMPmJIWZ7NRxDUb2hzsqyoM6WfhF0jo+FtBs0ueCX2POowRQ+gDQ== X-Received: by 2002:a17:90a:b105:: with SMTP id z5mr40864231pjq.64.1635244762164; Tue, 26 Oct 2021 03:39:22 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:d534:ad07:39b3:6828]) by smtp.gmail.com with ESMTPSA id b18sm25683732pfl.24.2021.10.26.03.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 03:39:21 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Oct 2021 19:39:14 +0900 Message-Id: <20211026103914.31449-2-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211026103914.31449-1-hiroh@chromium.org> References: <20211026103914.31449-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] 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 | 41 ++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index eb714aa6..e81ba63c 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; @@ -1130,8 +1138,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; @@ -1422,6 +1430,35 @@ 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); + + LOG(IPU3, Debug) << "Apply test pattern mode: " + << 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); + } + } + } + + /* Controls that don't affect immediately are applied in delayedCtrls. */ + delayedCtrls_->applyControls(sequence); +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3) } /* namespace libcamera */