From patchwork Fri Oct 2 09:33:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9899 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 4A404C3B5B for ; Fri, 2 Oct 2020 09:33:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DF5C625AF; Fri, 2 Oct 2020 11:33:15 +0200 (CEST) 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="nHcoiBMS"; dkim-atps=neutral Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BFDC60394 for ; Fri, 2 Oct 2020 11:33:14 +0200 (CEST) Received: by mail-wm1-x344.google.com with SMTP id t17so995140wmi.4 for ; Fri, 02 Oct 2020 02:33:14 -0700 (PDT) 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=tKR6QKoHMdc2FLcGM9k70wkBXqJDIsU1JD4u0rBxRzE=; b=nHcoiBMSwZ04PE/h+a1rhRh8GBwe84H0qtUTvy7N9CeeVaS5F+PGt9aYv/DVWnYDG5 SK0lejTXnle8RbBLL2AImPUvyGJJ7znhIPHHhPkTMVQige1dHklm0uW0u+WqpE7eckNN 9iS3WErInRuFBRWaFTZClXW1hX0pGqZGvUiZsHjFmbowedXIH32AvW3T4xeFzl7N8FE1 ONrIJuDJMLjbgniExSE6Bye63slY5BJDHUrF0rcvkZS6GQm959b4FHm+qAsBz/GxxD9S Z9Kxqwmiaup5galwbyROpCTaLq2gsozJFYbLBeuAK55lVR3gBcKG51kYP1S8zkVKCC7C kHgg== 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=tKR6QKoHMdc2FLcGM9k70wkBXqJDIsU1JD4u0rBxRzE=; b=NFEftH36Csjauxj3lwHbbxKC5iq3/r7G8dJDIiYrjMb7XOKkbE51tTr2RZwf5nS5Ky h9+gknoGYK8CzK/6Nk/gLBzUkA2uXnp5RvsYnWTz9PnY4rLwZoEpdiFa4oI4ME0tsQ29 l+hAQB7nMOciAVOJzFn5vGa+CIkLzyi5+vc5E8LCKJR02ixLPEg9782z5Q+WRAtkr6N5 AaZ6sHjwRyONrpXNgi0+x1VjcOqBBMxt64X5qs9tyA+k9e7DfyRr9nX1j1mzmrlZqi8k +3UQiqn4dFfmY4nyfkIKdDuIAOCtYpw25Boe7BT4jfMcTMQ5wKkKuG3HOtvwAykwu0e8 GA0A== X-Gm-Message-State: AOAM5321vI6fEPyQtlwuzgjACh5t4OZVG0vDAs8mofKQXjLfhU6tqWOx m10okI3jonFgPA6vtKWVIUU6GqQCgyclMw== X-Google-Smtp-Source: ABdhPJwcs3s+PT9VB3ZOs4HU98YSQ5foqEloea1VlrO3CN4z4AuDVaFS2rb+D/ZQWnF1FmrbHVfxLA== X-Received: by 2002:a1c:2cc2:: with SMTP id s185mr1876269wms.77.1601631193816; Fri, 02 Oct 2020 02:33:13 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id t203sm1101145wmg.43.2020.10.02.02.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 02:33:13 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 10:33:05 +0100 Message-Id: <20201002093309.109180-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002093309.109180-1-naush@raspberrypi.com> References: <20201002093309.109180-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] pipeline: raspberrypi: Sensor flips should be applied unconditionally 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 code in pipeline_handler::start() that applies the flips were in a block that was conditional on the RPi::IPA_CONFIG_SENSOR return result. This should be applied unconditionally. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d4d04c0d..1052bdce 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1172,19 +1172,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) { V4L2_CID_EXPOSURE, result.data[resultIdx++] } }); sensorMetadata_ = result.data[resultIdx++]; } - - /* - * Configure the H/V flip controls based on the combination of - * the sensor and user transform. - */ - if (supportsFlips_) { - ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); - ctrls.set(V4L2_CID_HFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); - ctrls.set(V4L2_CID_VFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); - unicam_[Unicam::Image].dev()->setControls(&ctrls); - } } if (result.operation & RPi::IPA_CONFIG_SENSOR) { @@ -1198,6 +1185,19 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) dropFrameCount_ = result.data[resultIdx++]; } + /* + * Configure the H/V flip controls based on the combination of + * the sensor and user transform. + */ + if (supportsFlips_) { + ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); + ctrls.set(V4L2_CID_HFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); + ctrls.set(V4L2_CID_VFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); + unicam_[Unicam::Image].dev()->setControls(&ctrls); + } + return 0; } From patchwork Fri Oct 2 09:33:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9900 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 1B9B3C3B5B for ; Fri, 2 Oct 2020 09:33:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB50E63B2D; Fri, 2 Oct 2020 11:33:17 +0200 (CEST) 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="OVZHudQu"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1B1C63B2A for ; Fri, 2 Oct 2020 11:33:15 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id e2so1005192wme.1 for ; Fri, 02 Oct 2020 02:33:15 -0700 (PDT) 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=XGJvJJGE++8gqzo8hKCdOeNAIxqn17uwQPVXozmwjzY=; b=OVZHudQunXstwzyQt/inPEzteaXrA6vUa8Ol6g8sDjQB+9hcRdCRsjpN9vqjQlHXGP KTfJ6B2DsfdIeNvKIJyAKhR1NRwX1+fN0MFwX/DCKNsZXqXZakno07+vZJAYiOx1HNHD FbdiK7wuZbyKHnEH3vpo6IzVRFpxbxz0CnwvRnhV6bi8Wfuzfs9SOA7+Nok7POZTrbyG pBkHSNdkQ+gNTwr+cYAyP5APTQlbiWUvkzSB+JEbZ5U1mZWKmhRBjPSJUuJH/5my7TJO jsr+Z9JYGpvEf1DtCW4yUlsxIcMVDDpkjEuXb/Yap6F+qxtO3ypUigOn7UyahyeSmxm7 WkkQ== 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=XGJvJJGE++8gqzo8hKCdOeNAIxqn17uwQPVXozmwjzY=; b=XdFSV8ewjJs7/mz5kbj3UKRbu5sV7OUvNwtbUFmnLEXqVHX8pSIOrwaYjN4wYCXqQT ZXJ139FJVov/qenhNfjl8qeYt7auNQ6JQx953lnjF3dd8/b3B23sAUewyyTCkwNU9jTp /tt+BDJrfzoY9xRfNWR36s5dg8abpP4XfH0nvomy5gWKZ4DXTxBcImjQ2w/R0bBvrGpj uLSSiDzoe7o+Z9390Fgb251eh5pLblDVIpOSndE+YZYXp+YVi+mKkZM5ur01q+0tnQrx hZCJGwNIe/jq7O7Btwv2gCJOTwKkPFDvoWjpi5ZBcLdSVEfO2xeAaCGo/UvREZdgNCGu O2WA== X-Gm-Message-State: AOAM531KOv5dQEEpAcHA4ieReFFllMKowKv+x75SX8zU7y/uhq8Su+TB YefhvNeaKLfeNW+WV1GOtr3DuTKWfZWshg== X-Google-Smtp-Source: ABdhPJzIvb+B0Jc5/crWHgx/ck3JBRQHni0p2FKVz3VBUOFxX3UJkoJpaaDKKNcsOdm2/cWUcaJH2A== X-Received: by 2002:a1c:66c4:: with SMTP id a187mr1800217wmc.148.1601631194872; Fri, 02 Oct 2020 02:33:14 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id t203sm1101145wmg.43.2020.10.02.02.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 02:33:13 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 10:33:06 +0100 Message-Id: <20201002093309.109180-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002093309.109180-1-naush@raspberrypi.com> References: <20201002093309.109180-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: pipeline: Pass libcamera controls into pipeline_handler::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" Applications now have the ability to pass in controls that need to be applied on startup, rather than doing it through Request where there might be some frames of delay in getting the controls applied. This commit adds the ability to pass in a set of libcamera controls into the pipeline handlers through the pipeline_handler::start() method. These controls are provided by the application through the camera::start() public API. Signed-off-by: Naushir Patuck --- Documentation/guides/pipeline-handler.rst | 4 ++-- include/libcamera/camera.h | 2 +- include/libcamera/internal/pipeline_handler.h | 2 +- src/libcamera/camera.cpp | 11 ++++++----- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++-- src/libcamera/pipeline/simple/simple.cpp | 4 ++-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 4 ++-- src/libcamera/pipeline/vimc/vimc.cpp | 4 ++-- src/libcamera/pipeline_handler.cpp | 1 + 11 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 71ef2050..9792442d 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -209,7 +209,7 @@ methods for the overridden class members. int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; int queueRequestDevice(Camera *camera, Request *request) override; @@ -239,7 +239,7 @@ methods for the overridden class members. return -1; } - int PipelineHandlerVivid::start(Camera *camera) + int PipelineHandlerVivid::start(Camera *camera, ControlList *controls) { return -1; } diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index a2ee4e7e..a29caf08 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -99,7 +99,7 @@ public: Request *createRequest(uint64_t cookie = 0); int queueRequest(Request *request); - int start(); + int start(ControlList *controls = nullptr); int stop(); private: diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index a4e1b529..43de1110 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -78,7 +78,7 @@ public: virtual int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) = 0; - virtual int start(Camera *camera) = 0; + virtual int start(Camera *camera, ControlList *controls) = 0; virtual void stop(Camera *camera) = 0; int queueRequest(Camera *camera, Request *request); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index fb76077f..3342214f 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -922,9 +922,10 @@ int Camera::queueRequest(Request *request) /** * \brief Start capture from camera * - * Start the camera capture session. Once the camera is started the application - * can queue requests to the camera to process and return to the application - * until the capture session is terminated with \a stop(). + * Start the camera capture session, optionally providing a list of controls to + * action before starting. Once the camera is started the application can queue + * requests to the camera to process and return to the application until the + * capture session is terminated with \a stop(). * * \context This function may only be called when the camera is in the * Configured state as defined in \ref camera_operation, and shall be @@ -935,7 +936,7 @@ int Camera::queueRequest(Request *request) * \retval -ENODEV The camera has been disconnected from the system * \retval -EACCES The camera is not in a state where it can be started */ -int Camera::start() +int Camera::start(ControlList *controls) { int ret = p_->isAccessAllowed(Private::CameraConfigured); if (ret < 0) @@ -944,7 +945,7 @@ int Camera::start() LOG(Camera, Debug) << "Starting capture"; ret = p_->pipe_->invokeMethod(&PipelineHandler::start, - ConnectionTypeBlocking, this); + ConnectionTypeBlocking, this, controls); if (ret) return ret; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f5a20d30..1ef60555 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -100,7 +100,7 @@ public: int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; int queueRequestDevice(Camera *camera, Request *request) override; @@ -591,7 +591,7 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera) return 0; } -int PipelineHandlerIPU3::start(Camera *camera) +int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] ControlList *controls) { IPU3CameraData *data = cameraData(camera); CIO2Device *cio2 = &data->cio2_; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 1052bdce..307ed9a2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -230,7 +230,7 @@ public: int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; int queueRequestDevice(Camera *camera, Request *request) override; @@ -712,7 +712,7 @@ int PipelineHandlerRPi::exportFrameBuffers([[maybe_unused]] Camera *camera, Stre return ret; } -int PipelineHandlerRPi::start(Camera *camera) +int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *controls) { RPiCameraData *data = cameraData(camera); int ret; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index aec590ff..15af7e5c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -187,7 +187,7 @@ public: int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; int queueRequestDevice(Camera *camera, Request *request) override; @@ -822,7 +822,7 @@ int PipelineHandlerRkISP1::freeBuffers(Camera *camera) return 0; } -int PipelineHandlerRkISP1::start(Camera *camera) +int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] ControlList *controls) { RkISP1CameraData *data = cameraData(camera); int ret; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 10223a9b..b842e16e 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -125,7 +125,7 @@ public: int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; bool match(DeviceEnumerator *enumerator) override; @@ -637,7 +637,7 @@ int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream, return data->video_->exportBuffers(count, buffers); } -int SimplePipelineHandler::start(Camera *camera) +int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] ControlList *controls) { SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index ba0efc8b..0c871b19 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -76,7 +76,7 @@ public: int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; int queueRequestDevice(Camera *camera, Request *request) override; @@ -236,7 +236,7 @@ int PipelineHandlerUVC::exportFrameBuffers(Camera *camera, Stream *stream, return data->video_->exportBuffers(count, buffers); } -int PipelineHandlerUVC::start(Camera *camera) +int PipelineHandlerUVC::start(Camera *camera, [[maybe_unused]] ControlList *controls) { UVCCameraData *data = cameraData(camera); unsigned int count = data->stream_.configuration().bufferCount; diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index fc8085f1..3b868e4b 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -92,7 +92,7 @@ public: int exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) override; - int start(Camera *camera) override; + int start(Camera *camera, ControlList *controls) override; void stop(Camera *camera) override; int queueRequestDevice(Camera *camera, Request *request) override; @@ -313,7 +313,7 @@ int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream, return data->video_->exportBuffers(count, buffers); } -int PipelineHandlerVimc::start(Camera *camera) +int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] ControlList *controls) { VimcCameraData *data = cameraData(camera); unsigned int count = data->stream_.configuration().bufferCount; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 918aea1e..60339e3e 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -351,6 +351,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const * \fn PipelineHandler::start() * \brief Start capturing from a group of streams * \param[in] camera The camera to start + * \param[in] controls Controls for the IPA to action before starting the camera * * Start the group of streams that have been configured for capture by * \a configure(). The intended caller of this method is the Camera class which From patchwork Fri Oct 2 09:33:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9901 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 A3868C3B5B for ; Fri, 2 Oct 2020 09:33:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6929D63B2C; Fri, 2 Oct 2020 11:33:18 +0200 (CEST) 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="OXfanorP"; dkim-atps=neutral Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 86539623B6 for ; Fri, 2 Oct 2020 11:33:16 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id s12so1008127wrw.11 for ; Fri, 02 Oct 2020 02:33:16 -0700 (PDT) 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=F2qOlvN/lG1JG+AotBTh+2Tcwda21PM/APIMEEI8NjI=; b=OXfanorP8vu3vq1C8I7Pk8+154RZw2ipoK4nleGJHVQu3cFmIH/FHbc6S+hza81pyR 0K8SYzOVMy/+1waKuWKBcmodvVxR8VaCdkUCxB6sHuilvnkHsK7nxt+BegJwSOTlr6W9 8oDr5HWAKWw1aG36M7mm/atK8TIxeTGY+lOsF6yOgEv5QM1QWISGL9Tlf2VJR0WQTpxS oXskjaB8yjlFrqtc/xojjDyQhDZW+f4QsonGfBFKyDE7LoXAsBZrsAazFM6Hwp2kqFAw V1119BWvdsSYmu4xUyIbv+mfJFMPIYT0mQgII4vwrQF6HUico7Flw8pyFBPO3iS19zLQ XP8Q== 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=F2qOlvN/lG1JG+AotBTh+2Tcwda21PM/APIMEEI8NjI=; b=kYNlCGFAM+Pqbzyb8fuSTzBO/cjaT1BSmssPpWC+IyYB+rV4kec7naASlJV0eR86eA /a1R6LWZ8x4Q3GOd1msuDD+pdmUC9VGcZAMNbyG24KJUibLJk6e0sfbNXZjnWquD0ur+ OlCi2jPrfQtLrV5jgKa4esO54TpW/xzg1c8dTrnwTmY7gBBsFoIkVIHwg12nbOljCGZF mL3SUTy2F+2nnrPcbafOgpHdLquDt2FSfrJUWmo9EFWfu+IPmc+7Bs5GrKLrEFmQLuCU qC8k3aPN/aw8YZeUqgC/2o74Qlx1lFWWzwuTEJvDb7GtfWt5suYDiu1Vxv1BocK/9vYk NFRw== X-Gm-Message-State: AOAM530OrWmCSAlRsK7uVEjCuKqr/yOQxS3mNC3X7HnjxaiKnrWbKAbA l3/3wKaKofUsqXPFo8jrjEAis4S16sjO+w== X-Google-Smtp-Source: ABdhPJxWoz3qoEr/mPjZmsWsRpPF3H+9NwBH9RjPp3qcSbHyjeACoBPlFy64jzbpiYRxff7xch4c9w== X-Received: by 2002:adf:f7d0:: with SMTP id a16mr1869470wrq.381.1601631195667; Fri, 02 Oct 2020 02:33:15 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id t203sm1101145wmg.43.2020.10.02.02.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 02:33:15 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 10:33:07 +0100 Message-Id: <20201002093309.109180-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002093309.109180-1-naush@raspberrypi.com> References: <20201002093309.109180-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: ipa: Pass a set of controls and return results from ipa::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" This change allows controls passed into pipeline_hanlder::start to be forwarded onto ipa::start(). We also add a return channel if the pipeline handle must action any of these controls, e.g. setting the analogue gain or shutter speed in the sensor device. todo: The IPA interface wrapper needs a translation for passing IPAOperationData into start() and configure() Signed-off-by: Naushir Patuck --- include/libcamera/internal/ipa_context_wrapper.h | 3 ++- include/libcamera/ipa/ipa_interface.h | 3 ++- src/ipa/libipa/ipa_interface_wrapper.cpp | 4 +++- src/ipa/raspberrypi/raspberrypi.cpp | 3 ++- src/ipa/rkisp1/rkisp1.cpp | 3 ++- src/ipa/vimc/vimc.cpp | 6 ++++-- src/libcamera/ipa_context_wrapper.cpp | 6 ++++-- src/libcamera/ipa_interface.cpp | 7 +++++++ src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 +++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 +++-- src/libcamera/pipeline/vimc/vimc.cpp | 3 ++- src/libcamera/proxy/ipa_proxy_linux.cpp | 3 ++- src/libcamera/proxy/ipa_proxy_thread.cpp | 13 ++++++++----- test/ipa/ipa_interface_test.cpp | 3 ++- test/ipa/ipa_wrappers_test.cpp | 5 +++-- 15 files changed, 49 insertions(+), 22 deletions(-) diff --git a/include/libcamera/internal/ipa_context_wrapper.h b/include/libcamera/internal/ipa_context_wrapper.h index 8f767e84..1878a615 100644 --- a/include/libcamera/internal/ipa_context_wrapper.h +++ b/include/libcamera/internal/ipa_context_wrapper.h @@ -20,7 +20,8 @@ public: ~IPAContextWrapper(); int init(const IPASettings &settings) override; - int start() override; + int start(const IPAOperationData &ipaConfig, + IPAOperationData *result) override; void stop() override; void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index 5016ec25..ee7b2e87 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -153,7 +153,8 @@ public: virtual ~IPAInterface() {} virtual int init(const IPASettings &settings) = 0; - virtual int start() = 0; + virtual int start(const IPAOperationData &ipaConfig, + IPAOperationData *result) = 0; virtual void stop() = 0; virtual void configure(const CameraSensorInfo &sensorInfo, diff --git a/src/ipa/libipa/ipa_interface_wrapper.cpp b/src/ipa/libipa/ipa_interface_wrapper.cpp index cee532e3..fb2da9d3 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.cpp +++ b/src/ipa/libipa/ipa_interface_wrapper.cpp @@ -95,7 +95,9 @@ int IPAInterfaceWrapper::start(struct ipa_context *_ctx) { IPAInterfaceWrapper *ctx = static_cast(_ctx); - return ctx->ipa_->start(); + /* \todo Translate the ipaConfig and result. */ + IPAOperationData ipaConfig; + return ctx->ipa_->start(ipaConfig, nullptr); } void IPAInterfaceWrapper::stop(struct ipa_context *_ctx) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index b0c7d1c1..9610229a 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -77,7 +77,8 @@ public: } int init(const IPASettings &settings) override; - int start() override { return 0; } + int start([[maybe_unused]] const IPAOperationData &ipaConfig, + [[maybe_unused]] IPAOperationData *result) override { return 0; } void stop() override {} void configure(const CameraSensorInfo &sensorInfo, diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 07d7f1b2..0b8a9096 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -37,7 +37,8 @@ public: { return 0; } - int start() override { return 0; } + int start([[maybe_unused]] const IPAOperationData &ipaConfig, + [[maybe_unused]] IPAOperationData *result) override { return 0; } void stop() override {} void configure(const CameraSensorInfo &info, diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index ef257762..07951c17 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -34,7 +34,8 @@ public: int init(const IPASettings &settings) override; - int start() override; + int start(const IPAOperationData &ipaConfig, + IPAOperationData *result) override; void stop() override; void configure([[maybe_unused]] const CameraSensorInfo &sensorInfo, @@ -82,7 +83,8 @@ int IPAVimc::init(const IPASettings &settings) return 0; } -int IPAVimc::start() +int IPAVimc::start([[maybe_unused]] const IPAOperationData &ipaConfig, + [[maybe_unused]] IPAOperationData *result) { trace(IPAOperationStart); diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp index 231300ce..de96a606 100644 --- a/src/libcamera/ipa_context_wrapper.cpp +++ b/src/libcamera/ipa_context_wrapper.cpp @@ -86,14 +86,16 @@ int IPAContextWrapper::init(const IPASettings &settings) return 0; } -int IPAContextWrapper::start() +int IPAContextWrapper::start(const IPAOperationData &ipaConfig, + IPAOperationData *result) { if (intf_) - return intf_->start(); + return intf_->start(ipaConfig, result); if (!ctx_) return 0; + /* \todo Translate the ipaConfig and reponse */ return ctx_->ops->start(ctx_); } diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp index 23fc56d7..282c3c0f 100644 --- a/src/libcamera/ipa_interface.cpp +++ b/src/libcamera/ipa_interface.cpp @@ -536,10 +536,17 @@ namespace libcamera { /** * \fn IPAInterface::start() * \brief Start the IPA + * \param[in] ipaConfig Pipeline-handler-specific configuration data + * \param[out] result Pipeline-handler-specific configuration result * * This method informs the IPA module that the camera is about to be started. * The IPA module shall prepare any resources it needs to operate. * + * The \a ipaConfig and \a result parameters carry custom data passed by the + * pipeline handler to the IPA and back. The pipeline handler may set the \a + * result parameter to null if the IPA protocol doesn't need to pass a result + * back through the configure() function. + * * \return 0 on success or a negative error code otherwise */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 307ed9a2..2e0b0dcf 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -733,7 +733,9 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont } /* Start the IPA. */ - ret = data->ipa_->start(); + IPAOperationData ipaConfig, result; + ipaConfig.controls.emplace_back(*controls); + ret = data->ipa_->start(ipaConfig, &result); if (ret) { LOG(RPI, Error) << "Failed to start IPA for " << camera->id(); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 15af7e5c..872bfc07 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -832,7 +832,8 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] ControlList *c if (ret) return ret; - ret = data->ipa_->start(); + IPAOperationData ipaConfig = {}; + ret = data->ipa_->start(ipaConfig, nullptr); if (ret) { freeBuffers(camera); LOG(RkISP1, Error) @@ -911,7 +912,7 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] ControlList *c std::map entityControls; entityControls.emplace(0, data->sensor_->controls()); - IPAOperationData ipaConfig; + ipaConfig = {}; data->ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, nullptr); diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 3b868e4b..8eb1998d 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -322,7 +322,8 @@ int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] ControlList *con if (ret < 0) return ret; - ret = data->ipa_->start(); + IPAOperationData ipaConfig = {}; + ret = data->ipa_->start(ipaConfig, nullptr); if (ret) { data->video_->releaseBuffers(); return ret; diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp index b78a0e45..619976e5 100644 --- a/src/libcamera/proxy/ipa_proxy_linux.cpp +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp @@ -30,7 +30,8 @@ public: { return 0; } - int start() override { return 0; } + int start([[maybe_unused]] const IPAOperationData &ipaConfig, + [[maybe_unused]] IPAOperationData *result) override { return 0; } void stop() override {} void configure([[maybe_unused]] const CameraSensorInfo &sensorInfo, [[maybe_unused]] const std::map &streamConfig, diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp index eead2883..9a81b6e7 100644 --- a/src/libcamera/proxy/ipa_proxy_thread.cpp +++ b/src/libcamera/proxy/ipa_proxy_thread.cpp @@ -26,7 +26,8 @@ public: IPAProxyThread(IPAModule *ipam); int init(const IPASettings &settings) override; - int start() override; + int start(const IPAOperationData &ipaConfig, + IPAOperationData *result) override; void stop() override; void configure(const CameraSensorInfo &sensorInfo, @@ -50,9 +51,9 @@ private: ipa_ = ipa; } - int start() + int start(const IPAOperationData &ipaConfig, IPAOperationData *result) { - return ipa_->start(); + return ipa_->start(ipaConfig, result); } void stop() @@ -111,12 +112,14 @@ int IPAProxyThread::init(const IPASettings &settings) return 0; } -int IPAProxyThread::start() +int IPAProxyThread::start(const IPAOperationData &ipaConfig, + IPAOperationData *result) { running_ = true; thread_.start(); - return proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking); + return proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking, + ipaConfig, result); } void IPAProxyThread::stop() diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 1bc93a63..a7bfcce8 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -120,7 +120,8 @@ protected: } /* Test start of IPA module. */ - ipa_->start(); + IPAOperationData ipaConfig; + ipa_->start(ipaConfig, nullptr); timer.start(1000); while (timer.isRunning() && trace_ != IPAOperationStart) dispatcher->processEvents(); diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index 59d991cb..7b8ae77b 100644 --- a/test/ipa/ipa_wrappers_test.cpp +++ b/test/ipa/ipa_wrappers_test.cpp @@ -56,7 +56,8 @@ public: return 0; } - int start() override + int start([[maybe_unused]] const IPAOperationData &ipaConfig, + [[maybe_unused]] IPAOperationData *result) override { report(Op_start, TestPass); return 0; @@ -376,7 +377,7 @@ protected: return TestFail; } - ret = INVOKE(start); + ret = INVOKE(start, ipaConfig, nullptr); if (ret == TestFail) { cerr << "Failed to run start()"; return TestFail; From patchwork Fri Oct 2 09:33:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9902 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 1D8B6C3B5E for ; Fri, 2 Oct 2020 09:33:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C996263B2A; Fri, 2 Oct 2020 11:33:18 +0200 (CEST) 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="Lx7hH0Jn"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52FD0623B6 for ; Fri, 2 Oct 2020 11:33:17 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id t17so995321wmi.4 for ; Fri, 02 Oct 2020 02:33:17 -0700 (PDT) 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=FRLR4Qe7S0mbYWoA4CPpaFxkRcM5eogrblUzHby1gCU=; b=Lx7hH0JniXwpY7vZpH8WO9loAs1loTRHIjXybA6Rvror5z0niZbsx/CTwdeeRc7+Mu WuGk3XSexP1dVrg8fyXlOAQ2Zg/3qkkzqInUyOzFGgD/sTdUHOS+je+G4OAfpwH0Py2d tZgKwaPVnOq+YiuaOy4sSrKpss/xJiR++roCrOtoJqHBoVqpio0fEwbgIagKeDfUQ2zK uPEE7en4Z89xVvYQD9gVIlLK6lRe6AMNDS0I7Hk9G1oQLub9EAcl8O5Hc22uYj96KBTi wmn4oVYPuybnP7wEFDrd9lQO828OC9hIDASXGfg6JUhCU7h1F1lAgLfAho9fcMkEgBYI M1pQ== 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=FRLR4Qe7S0mbYWoA4CPpaFxkRcM5eogrblUzHby1gCU=; b=HQ2O8b8e+rzi0sUs1DS8qqNZKJp/Qa8cS7CPLzlyPtHkJLkS57SIB/FoY5UiRdnPzu vx1pRx8GPAXCn0NZ/O1USrHllF01FXYo+7+KgLfOkWMdptkz6XQU9wMPcbOEyyGVPxyB ucxhMl1G7b2iE56RrpjiRvAz2tnj7MsKTMiO6QWFhcemrD2fb+/rsomyCZpeBVmQM5h1 TR0H9a1Rkllve+UpHKPUF3foPuanY5Z9ptEp49XVX20hx98LqvuMK+Ahdnm2KwWCczcB mwAtt7haKkcLgWnjVR54+bGqgQnel59b+HubmtQ2GxZzmXf8rDwqFZo2V2dwcMBs1gCr D1pQ== X-Gm-Message-State: AOAM533T2ADpTQneX7TNme1bHoJyh0y7SPrD+r1nGwZXtcvWHx1dbY5L hk3Q7vW3sLUSU3d/axWlLE086VxOXDuruQ== X-Google-Smtp-Source: ABdhPJw2beWz19qiJnRa1xSLXSP3Ry+YKY77UQcHKKQ6dJPuN8l07hYoD0T7vTmHpmQ36GHvS7xgNA== X-Received: by 2002:a1c:4601:: with SMTP id t1mr1913910wma.5.1601631196529; Fri, 02 Oct 2020 02:33:16 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id t203sm1101145wmg.43.2020.10.02.02.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 02:33:15 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 10:33:08 +0100 Message-Id: <20201002093309.109180-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002093309.109180-1-naush@raspberrypi.com> References: <20201002093309.109180-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] pipeline: ipa: raspberrypi: Pass controls to IPA on 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" Forward any controls passed into the pipeline handler to the IPA. The IPA then sets up the Raspberry Pi controller with these settings appropriately, and passes back any V4L2 sensor controls that need to be applied. Signed-off-by: Naushir Patuck --- include/libcamera/ipa/raspberrypi.h | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 51 ++++++++++++------- .../pipeline/raspberrypi/raspberrypi.cpp | 14 ++++- 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index b3041591..8954aa66 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -19,6 +19,7 @@ enum ConfigParameters { IPA_CONFIG_STAGGERED_WRITE = (1 << 1), IPA_CONFIG_SENSOR = (1 << 2), IPA_CONFIG_DROP_FRAMES = (1 << 3), + IPA_CONFIG_STARTUP = (1 << 4) }; enum Operations { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9610229a..86b16089 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -77,8 +77,7 @@ public: } int init(const IPASettings &settings) override; - int start([[maybe_unused]] const IPAOperationData &ipaConfig, - [[maybe_unused]] IPAOperationData *result) override { return 0; } + int start(const IPAOperationData &ipaConfig, IPAOperationData *result) override; void stop() override {} void configure(const CameraSensorInfo &sensorInfo, @@ -154,6 +153,35 @@ int IPARPi::init(const IPASettings &settings) return 0; } +int IPARPi::start(const IPAOperationData &ipaConfig, IPAOperationData *result) +{ + RPiController::Metadata metadata; + + result->operation = 0; + if (ipaConfig.operation & RPi::IPA_CONFIG_STARTUP) { + /* We have been given some controls to action before start. */ + queueRequest(ipaConfig.controls[0]); + } + + controller_.SwitchMode(mode_, &metadata); + + /* SwitchMode may supply updated exposure/gain values to use. */ + AgcStatus agcStatus; + agcStatus.shutter_time = 0.0; + agcStatus.analogue_gain = 0.0; + + /* SwitchMode may supply updated exposure/gain values to use. */ + metadata.Get("agc.status", agcStatus); + if (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) { + ControlList ctrls(unicamCtrls_); + applyAGC(&agcStatus, ctrls); + result->controls.push_back(ctrls); + result->operation |= RPi::IPA_CONFIG_SENSOR; + } + + return 0; +} + void IPARPi::setMode(const CameraSensorInfo &sensorInfo) { mode_.bitdepth = sensorInfo.bitsPerPixel; @@ -229,7 +257,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, result->data.push_back(gainDelay); result->data.push_back(exposureDelay); result->data.push_back(sensorMetadata); - result->operation |= RPi::IPA_CONFIG_STAGGERED_WRITE; } @@ -285,11 +312,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, result->data.push_back(dropFrame); result->operation |= RPi::IPA_CONFIG_DROP_FRAMES; - /* These zero values mean not program anything (unless overwritten). */ - struct AgcStatus agcStatus; - agcStatus.shutter_time = 0.0; - agcStatus.analogue_gain = 0.0; - if (!controllerInit_) { /* Load the tuning file for this sensor. */ controller_.Read(tuningFile_.c_str()); @@ -297,20 +319,13 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, controllerInit_ = true; /* Supply initial values for gain and exposure. */ + ControlList ctrls(unicamCtrls_); + AgcStatus agcStatus; agcStatus.shutter_time = DefaultExposureTime; agcStatus.analogue_gain = DefaultAnalogueGain; - } - - RPiController::Metadata metadata; - controller_.SwitchMode(mode_, &metadata); - - /* SwitchMode may supply updated exposure/gain values to use. */ - metadata.Get("agc.status", agcStatus); - if (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) { - ControlList ctrls(unicamCtrls_); applyAGC(&agcStatus, ctrls); - result->controls.push_back(ctrls); + result->controls.push_back(ctrls); result->operation |= RPi::IPA_CONFIG_SENSOR; } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2e0b0dcf..81e23ed2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -734,7 +734,10 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont /* Start the IPA. */ IPAOperationData ipaConfig, result; - ipaConfig.controls.emplace_back(*controls); + if (controls) { + ipaConfig.operation = RPi::IPA_CONFIG_STARTUP; + ipaConfig.controls.emplace_back(*controls); + } ret = data->ipa_->start(ipaConfig, &result); if (ret) { LOG(RPI, Error) @@ -743,6 +746,14 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont return ret; } + /* Apply any gain/exposure settings that the IPA may have passed back. */ + ASSERT(data->staggeredCtrl_); + if (result.operation & RPi::IPA_CONFIG_SENSOR) { + const ControlList &ctrls = result.controls[0]; + if (!data->staggeredCtrl_.set(ctrls)) + LOG(RPI, Error) << "V4L2 staggered set failed"; + } + /* * IPA configure may have changed the sensor flips - hence the bayer * order. Get the sensor format and set the ISP input now. @@ -763,7 +774,6 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont * starting. First check that the staggered ctrl has been initialised * by configure(). */ - ASSERT(data->staggeredCtrl_); data->staggeredCtrl_.reset(); data->staggeredCtrl_.write(); data->expectedSequence_ = 0; From patchwork Fri Oct 2 09:33:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9903 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 8A320C3B5B for ; Fri, 2 Oct 2020 09:33:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5446563B27; Fri, 2 Oct 2020 11:33:20 +0200 (CEST) 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="kYCteFNK"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DC51163B32 for ; Fri, 2 Oct 2020 11:33:17 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id s12so1008193wrw.11 for ; Fri, 02 Oct 2020 02:33:17 -0700 (PDT) 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=zWOIeY/4BBoHvefHC8wdDNSshs9CTSgjzBE6ohOV7Po=; b=kYCteFNKCsoNjTQRTVQfDiOe2mE7ifjtyBVaTX6XkzuWhoqaNxTWsI5obuJGOwoCIe v2B6TvGZoscLItj9fCT1e5I5QFa1AnN0Ax4f1yTTtI86RL0PQn7yzZAbf9o0OiAH4rIt DQtN+7MsNIABFBbLPgwu5QGrmkKjlak6+LnvM2QZWDJbsOiWkgtVt6ngaOlZLmDLz98L 2RjaFKyxzyC2kbtIWizUrT4bH1mXYG6/84Xbpfv8Nri34Hmtqn0xhflW4qEGwXLmKQ9M aj1/G8yGxhOJ+XH8Le4XNXvrwhlpDszaIi2lSp1hKn1I/4sJ4ZJ+bNnjYvaDzxREAipu pmYA== 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=zWOIeY/4BBoHvefHC8wdDNSshs9CTSgjzBE6ohOV7Po=; b=ZUFA+c7/3GspFJ6365P2b5jlw9HDIihi7H3fkPUt7tN0dxnP1jJjY3r4pMLiPmDb4s WUAMYq0LCTElLw+6QdQZHlJRyW42UoDFZGcq4t53rtJc9LtFRsMMBwJc3R3rx1Ikazyu 3MAuSlKJIWt14lUHRDWpcuy1owCUjkhNJNBSrB9F1qyfBHTeEnrrPiFcqzlP4Y66e+Zv 9BOPq+YZLsro27sevcgcdngClmdDJMchEiZyb/vmCvgBi/+agyyAoZZNfoaGWrEKD7KH D7IdllK3AlD7eTqOG1PXTxpdWnG6xvnRUmJKOz6f1e06jiQzNiXv8IcImu4oeohvtrmv G8GA== X-Gm-Message-State: AOAM531WuFk0NsobHaj8qQDyH2dt9CHkyVYOB+RGFSoCJGeGJUiUPLj1 C5S6Nmqlm6FF2bkjvKUYt0u+Zjo5C/ZHfg== X-Google-Smtp-Source: ABdhPJzbndcOy5YoDEM3TDY/0Ji46Iz16tub26wcO0Tygnbj1bQjbpBBf2kP9qL6/P3qixX3PIAjxQ== X-Received: by 2002:adf:ffd0:: with SMTP id x16mr2019933wrs.104.1601631197311; Fri, 02 Oct 2020 02:33:17 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id t203sm1101145wmg.43.2020.10.02.02.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 02:33:16 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 10:33:09 +0100 Message-Id: <20201002093309.109180-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002093309.109180-1-naush@raspberrypi.com> References: <20201002093309.109180-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] DNI: qcam: Simple test to pass controls on 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" DO NOT MERGE --- src/qcam/main_window.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index ecb9dd66..cb24eb11 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "dng_writer.h" @@ -367,6 +368,7 @@ void MainWindow::toggleCapture(bool start) int MainWindow::startCapture() { StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]); + ControlList controls(libcamera::controls::controls); std::vector requests; int ret; @@ -509,7 +511,10 @@ int MainWindow::startCapture() framesCaptured_ = 0; lastBufferTime_ = 0; - ret = camera_->start(); + controls.set(libcamera::controls::AeEnable, false); + controls.set(libcamera::controls::ExposureTime, 60000); + controls.set(libcamera::controls::AnalogueGain, 6.0); + ret = camera_->start(&controls); if (ret) { qInfo() << "Failed to start capture"; goto error;