From patchwork Tue Dec 8 20:51:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10619 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 0912ABDB1F for ; Tue, 8 Dec 2020 20:51:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 687D067F0C; Tue, 8 Dec 2020 21:51:22 +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="aT9mfqYH"; dkim-atps=neutral Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC08F67F07 for ; Tue, 8 Dec 2020 21:51:20 +0100 (CET) Received: by mail-ed1-x542.google.com with SMTP id q16so18993562edv.10 for ; Tue, 08 Dec 2020 12:51:20 -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:mime-version :content-transfer-encoding; bh=rl95fGVd+cGJJ0yB5cFcprCZfchUW7zYAEtb8AQUeC8=; b=aT9mfqYH0bPPQZIrc8IeLTLebmBUwiIEEo0hKZYEfRuqO/rAOeJyiXojMuyM17G0A3 ATWSOVlYJttnI9Y5Df77vPaT6uESgMeUz1OGRIUknF53DHZpEbEIWfajOvzLf7ir2bYQ Bhe4QR+xuPpjWAvI3jStwtgk08/R8bWr7s75fChYp+YFclfnC64aKUlhCmT0HZg/wiG9 gBxXr7LwFdLIrhkeEG+F1esPlvObHAt7dqfnRcXm7I+5RSmZSJCeIcjnHnUvB1AWSIJG H9FjgMSY0MheRDp3UPuAIGxRqYuXKhWeKgBNLdyPYb+2syYznJyOt6KHuPjWDDJxkKjq 0j0w== 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:mime-version :content-transfer-encoding; bh=rl95fGVd+cGJJ0yB5cFcprCZfchUW7zYAEtb8AQUeC8=; b=uXpV8gF4B4lgdxO28JunTZvTXu3M//70ku7fO7zj50YofkURPaGRIDN0ypzXO2cIWJ 5k3vEWPx6L4+r4on4wWeo9H+UDUJDjHK8BZufxcC6Ade0JzOCR1xhAp/y89O5BEJ/wE8 Tg7sVLbf1Q+dxFnGDCjBcYKHyOYDfw60VLm99jt2cDYHEy2Q//+DllLu3V7bWcOdRNxZ eMA9/z4gc4d/mYJmNq62cBqcqQ3s8O+A6mxkuSzv3atbp3BdVaS4E5sGj6U8K9e8dfAa K55AkQM0ELR/AVyH4E9lsV8lyRmKo+EU68FXwSvU2RM5KZrJYVmv3WVSW77tE22D5mLs 2ymQ== X-Gm-Message-State: AOAM533coM0LZWLUQY6H3fMeT/wNYQh88t7h8n5yVME8230x5Qc6BTOs ztqoxVLwjhM4tlqyIqsPhbgRcMSDfT+teq+3 X-Google-Smtp-Source: ABdhPJwTEVbihKl+RlTcGZBP1D5G9462PEDHhWbPUvd2fJ0M2CH+ynUpo6+kg6NXuBfg5i59Vtso0w== X-Received: by 2002:a05:6402:d0a:: with SMTP id eb10mr26696654edb.305.1607460680090; Tue, 08 Dec 2020 12:51:20 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id d13sm16062688ejc.44.2020.12.08.12.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 12:51:19 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Dec 2020 20:51:17 +0000 Message-Id: <20201208205117.22204-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] src: pipeline: raspberrypi: Allow ScalerCrop to work when passed in Camera::start 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 ScalerCrop control is handled by the pipeline handler, not the IPA, so must be handled explicitly in the Camera::start method. The ScalerCrop code used when processing requests has been factored out to make it easy to reuse. Signed-off-by: David Plowman Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2ec1f6e7..593fd7ac 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -156,6 +156,7 @@ public: void handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream); void handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream); void handleState(); + void applyScalerCrop(const ControlList &controls); CameraSensor *sensor_; /* Array of Unicam and ISP device streams and associated buffers/streams. */ @@ -751,6 +752,10 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont return ret; } + /* Check if a ScalerCrop control was specified. */ + if (controls) + data->applyScalerCrop(*controls); + /* Start the IPA. */ IPAOperationData ipaData = {}; IPAOperationData result = {}; @@ -1610,24 +1615,10 @@ void RPiCameraData::checkRequestCompleted() } } -void RPiCameraData::tryRunPipeline() +void RPiCameraData::applyScalerCrop(const ControlList &controls) { - FrameBuffer *bayerBuffer, *embeddedBuffer; - IPAOperationData op; - - /* If any of our request or buffer queues are empty, we cannot proceed. */ - if (state_ != State::Idle || requestQueue_.empty() || - bayerQueue_.empty() || embeddedQueue_.empty()) - return; - - if (!findMatchingBuffers(bayerBuffer, embeddedBuffer)) - return; - - /* Take the first request from the queue and action the IPA. */ - Request *request = requestQueue_.front(); - - if (request->controls().contains(controls::ScalerCrop)) { - Rectangle nativeCrop = request->controls().get(controls::ScalerCrop); + if (controls.contains(controls::ScalerCrop)) { + Rectangle nativeCrop = controls.get(controls::ScalerCrop); if (!nativeCrop.width || !nativeCrop.height) nativeCrop = { 0, 0, 1, 1 }; @@ -1654,6 +1645,26 @@ void RPiCameraData::tryRunPipeline() updateScalerCrop_ = true; } } +} + +void RPiCameraData::tryRunPipeline() +{ + FrameBuffer *bayerBuffer, *embeddedBuffer; + IPAOperationData op; + + /* If any of our request or buffer queues are empty, we cannot proceed. */ + if (state_ != State::Idle || requestQueue_.empty() || + bayerQueue_.empty() || embeddedQueue_.empty()) + return; + + if (!findMatchingBuffers(bayerBuffer, embeddedBuffer)) + return; + + /* Take the first request from the queue and action the IPA. */ + Request *request = requestQueue_.front(); + + /* See if a new ScalerCrop value needs to be applied. */ + applyScalerCrop(request->controls()); /* * Process all the user controls by the IPA. Once this is complete, we