From patchwork Wed Dec 2 11:52:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10543 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 60378BE177 for ; Wed, 2 Dec 2020 11:53:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F76D635A3; Wed, 2 Dec 2020 12:53:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JI1C4A5E"; dkim-atps=neutral Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A336634A2 for ; Wed, 2 Dec 2020 12:53:00 +0100 (CET) Received: by mail-wr1-x443.google.com with SMTP id s8so3521167wrw.10 for ; Wed, 02 Dec 2020 03:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ekSVYZR1R2TpVJqM/5kfzNoQQzPb4N/VRXvaptAxp6E=; b=JI1C4A5E4p4cqcZAcIbJXcfuv2s6t90870h38AT1y9U2v1TwqfXl48ye/TYf60XJhY 2o8Vwoy4jE2xy3/2aW2CHzF/0xR0LgQCyylcwh9XNrHPWhJVO8qdz6tzuY1lhaSDUlt6 kZfPkGi/unJdf5J5LrIjPXN/4urP4920hsM7jtDOi9qPn7qBNP8FI00uoNxOw41mA55r 7InUUgmuoxaBCgXb9numVgYveaIn7yUgKdIvGkerlXKriIywaMaGmr2p60iRks7438fr X2et6MPn6RvoFuqUY15RiivfTHQJr8bxuSniGBCnxDfL/yPDc1xCisZGQunhu6o0y4J1 ps1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ekSVYZR1R2TpVJqM/5kfzNoQQzPb4N/VRXvaptAxp6E=; b=ZMTgXLB9jKgL8r+t0YKHuQEWhT72u5sCPJbW+PICN1ejXd6Z09Hg2BHIf55JSfi0PC FqWW39/AJ8/s9auYXMkr+P9Bhc3uFHeobJl+yf5e3TjKIXv7m2tRne2km88ZWoxh6JOO vJ8mAkmVIWcCCBpCOEMBkIWYQ77Vc4RPukQQK4Ei0zhLCnjP0aogUXDAn5G31ZdaBn4M FIif/v4swp96hjwRBFx7LNPM49UySFl/bxDt96jp+7U1JxgYyDgsSCD4jZAregBCXD3y 68ozzhR78HchOkZIpOhvKftnd3AZ99G04tLIFGSuh3IqcZomqu+hvA+QF64ZfaspYItk iqYg== X-Gm-Message-State: AOAM531idIaAP56sZ6C8p+Hc5b+kVKW4UKCa/UDptWTZ4UVjRv0Qu9gV GxrkewgrdX6Mo+i0yZfav3xaXKdxJOn8CuLy X-Google-Smtp-Source: ABdhPJy1+BrHTsTX2Jw15oZ80M9bUY6NvYNSVA7vMzTJ3zKz00nnwBWWZ+5vcZuCh2rz8enW+2+R9w== X-Received: by 2002:adf:c452:: with SMTP id a18mr3024151wrg.189.1606909979584; Wed, 02 Dec 2020 03:52:59 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id n189sm1739215wmf.20.2020.12.02.03.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:52:59 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Dec 2020 11:52:50 +0000 Message-Id: <20201202115253.14705-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201202115253.14705-1-david.plowman@raspberrypi.com> References: <20201202115253.14705-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] src: raspberrypi: Pass the drop frame count in start, not configure 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" The number of frames to drop (not display) is passed back now from the start method, not configure. This means applications have a chance to set fixed exposure/gain before starting the camera and this can affect the frame drop count that is returned. Both the IPA implementation file and the pipeline handler need matching modifications. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/raspberrypi.cpp | 38 +++++++++---------- .../pipeline/raspberrypi/raspberrypi.cpp | 25 ++++++------ 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index b8298768..0300b8d9 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -182,6 +182,25 @@ int IPARPi::start(const IPAOperationData &ipaConfig, IPAOperationData *result) result->operation |= RPi::IPA_CONFIG_SENSOR; } + /* + * Initialise frame counts, and decide how many frames must be hidden or + *"mistrusted", which depends on whether this is a startup from cold, + * or merely a mode switch in a running system. + */ + frameCount_ = 0; + checkCount_ = 0; + unsigned int dropFrame = 0; + if (firstStart_) { + dropFrame = helper_->HideFramesStartup(); + mistrustCount_ = helper_->MistrustFramesStartup(); + } else { + dropFrame = helper_->HideFramesModeSwitch(); + mistrustCount_ = helper_->MistrustFramesModeSwitch(); + } + + result->data.push_back(dropFrame); + result->operation |= RPi::IPA_CONFIG_DROP_FRAMES; + firstStart_ = false; return 0; @@ -298,25 +317,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, /* Pass the camera mode to the CamHelper to setup algorithms. */ helper_->SetCameraMode(mode_); - /* - * Initialise frame counts, and decide how many frames must be hidden or - *"mistrusted", which depends on whether this is a startup from cold, - * or merely a mode switch in a running system. - */ - frameCount_ = 0; - checkCount_ = 0; - unsigned int dropFrame = 0; - if (controllerInit_) { - dropFrame = helper_->HideFramesModeSwitch(); - mistrustCount_ = helper_->MistrustFramesModeSwitch(); - } else { - dropFrame = helper_->HideFramesStartup(); - mistrustCount_ = helper_->MistrustFramesStartup(); - } - - result->data.push_back(dropFrame); - result->operation |= RPi::IPA_CONFIG_DROP_FRAMES; - if (!controllerInit_) { /* Load the tuning file for this sensor. */ controller_.Read(tuningFile_.c_str()); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 89a44763..5ae56628 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -745,13 +745,6 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont return ret; } - ret = queueAllBuffers(camera); - if (ret) { - LOG(RPI, Error) << "Failed to queue buffers"; - stop(camera); - return ret; - } - /* Check if a ScalerCrop control was specified. */ if (controls) data->applyScalerCrop(*controls); @@ -778,6 +771,19 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont LOG(RPI, Error) << "V4L2 staggered set failed"; } + if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) { + /* Configure the number of dropped frames required on startup. */ + data->dropFrameCount_ = result.data[0]; + } + + /* We need to set the dropFrameCount_ before queueing buffers. */ + ret = queueAllBuffers(camera); + if (ret) { + LOG(RPI, Error) << "Failed to queue buffers"; + stop(camera); + return ret; + } + /* * IPA configure may have changed the sensor flips - hence the bayer * order. Get the sensor format and set the ISP input now. @@ -1231,11 +1237,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) LOG(RPI, Error) << "V4L2 staggered set failed"; } - if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) { - /* Configure the number of dropped frames required on startup. */ - dropFrameCount_ = result.data[resultIdx++]; - } - /* * Configure the H/V flip controls based on the combination of * the sensor and user transform.