From patchwork Fri Jul 2 15:09:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12792 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 B685DC0100 for ; Fri, 2 Jul 2021 15:09:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9168468506; Fri, 2 Jul 2021 17:09:52 +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="bn8u61qN"; 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 52FC1684EA for ; Fri, 2 Jul 2021 17:09:51 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id j2so12833902wrs.12 for ; Fri, 02 Jul 2021 08:09:51 -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=C0gP47j5UgDK8yhhXHaI9V3iumMujPU1ZTL7xRjpncw=; b=bn8u61qNrI4phw/d3UQJpZ0mvTCZTVirrN4iXvZV8juVuAKqeGKZvaSlGpqEQemEoj xcQC8DOj5eHw8a6Tj6fvk48YCtXJbnEMQE21qKK4WQcJJTOn43uLdRyU/P4TAaaCqSyB q/+pGevz/Sd7ZI96Al+i1y8/JaFUwsMAvn0S04+6U6X3U0gDOgA+7fc4sMsFXH7rZbfs BeCUDwVxehSSzAM46ElQlN4sHTXzYx1jNfmbLLs/P3lzcI/G6gWsNSh21owETitZQ9s/ x0U65cMUvs1x5eaN1YJjMo3W03NBhWYuEaJ1sD3PRY7SpF5yOLBK54QO7ccYMYk6bYKJ Vpdw== 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=C0gP47j5UgDK8yhhXHaI9V3iumMujPU1ZTL7xRjpncw=; b=dOVNOMcE/B5+EFkMFrU+2PHqon8XwGHXn+NlXT7uSlzLSD0NN53/25X3nTaUXvYibC dZMBLiRecn0S53VvXZu6FlBB3f2wSXy1eJSRm/0SvmLaupjBZ5K5PlGlwaA/LsAslz7M 5mp//zAzCuWUVSCn2N5m2PKG42MzAQJg+gD2DtcPuZWRsvP8c7hJ62Io29uDJk8MOTUx gdc3wZPKOrDUnLcu+ZBqbm8i5lgeutNFHZOmzU/fQJPmJQ3GTPjUK8L7Q/DgN2xnLRfq 7ZBkz7+whKNJ+Q7FtPd/b0wHwPOWmttMnW+4aj+I0683+sNmYmp5G2xOMIZbd2cxVsgl Ta/w== X-Gm-Message-State: AOAM533Q+pnbR8xU4so2p3q03S8axcwE4YFpcxyupiUfEjIxMr4IRFDo p92P0B3nBJ8g3wYSE7s7PBhpc556KtbfTw== X-Google-Smtp-Source: ABdhPJxMQWcAlGyOtqqD5pSE8LN3n/xrydOBodjXFlw3D9m5uyjJ+EdVY3HVIioMEQEvFtfx5Snx/w== X-Received: by 2002:adf:e384:: with SMTP id e4mr84967wrm.317.1625238590876; Fri, 02 Jul 2021 08:09:50 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:50 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:33 +0100 Message-Id: <20210702150940.226941-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/8] ipa: raspberrypi: Make device_status.h C++ only header, and update comments 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 header file is no longer C compatible, so remove the extern "C" declaration. Replace C++ style comments with C style based on libcamera guidelines. There are no functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../raspberrypi/controller/device_status.h | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index f74235248b12..733378dbfa27 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * * device_status.h - device (image sensor) status */ @@ -8,25 +8,19 @@ #include -// Definition of "device metadata" which stores things like shutter time and -// analogue gain that downstream control algorithms will want to know. - -#ifdef __cplusplus -extern "C" { -#endif +/* + * Definition of "device metadata" which stores things like shutter time and + * analogue gain that downstream control algorithms will want to know. + */ struct DeviceStatus { - // time shutter is open + /* time shutter is open */ libcamera::utils::Duration shutter_speed; double analogue_gain; - // 1.0/distance-in-metres, or 0 if unknown + /* 1.0/distance-in-metres, or 0 if unknown */ double lens_position; - // 1/f so that brightness quadruples when this doubles, or 0 if unknown + /* 1/f so that brightness quadruples when this doubles, or 0 if unknown */ double aperture; - // proportional to brightness with 0 = no flash, 1 = maximum flash + /* proportional to brightness with 0 = no flash, 1 = maximum flash */ double flash_intensity; }; - -#ifdef __cplusplus -} -#endif From patchwork Fri Jul 2 15:09:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12793 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 2A6C9BD794 for ; Fri, 2 Jul 2021 15:09:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D82E86850D; Fri, 2 Jul 2021 17:09:54 +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="biW6m5by"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 19872684E6 for ; Fri, 2 Jul 2021 17:09:52 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso9303943wmh.4 for ; Fri, 02 Jul 2021 08:09:52 -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=OsExjRL2W95T4NHe/EVVkRdhs/8/IaCpdYq657jQA14=; b=biW6m5byaq+yLS1uPV8QS5MPMK3zVRC6Cljyz0VYIUb9kpR9GFDtlm7Aj0MkZJefEB LvWv+KzACL9a7gTkhfJHr0KISrNtlYC7XuaOdAqbI7Pq3K91HFQBl8/8BDYvxcFlwNwe RBzKmD9eUsWT5Ln+eDmF5lITNWfypj/fDJYzlRdFS/kCVXiKF1mShj9iB8TS4jZWcqI1 Pq5Irh6ezRMqbzJzfbVIk1qBw6aeWHtb+taJHYalIy7fxIPNiZYwbL4CVH6XgnReD8q5 8eihW6FXDUnr5iRXlIG7hY68Pb0viQQ0f2plNB+frtc05qmz8rag5uRaZRYK4BbakbIA ETvw== 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=OsExjRL2W95T4NHe/EVVkRdhs/8/IaCpdYq657jQA14=; b=VqliTKmhcxfnBMxeFrfk6u6g81aMDSq820jtwERNZyOoyleDjW4baom9YUehn0OZE9 gYUMBMgfRe7tnR6Opu7LcqnFBfmiUNMqwClYRIvMR4KIozCilC1Uo6wckdJO1PJQot+r vmBVN2AlqKGUM4lffTVa/xlOBRPU9g+yPc6ebawfS5R5B/n74+uuzCNpY9eW/vpLXUpb tV3vwqpoXHRLgNOa+DYHGxn5dDvLHqL6PoryqgzDUUceM6zObib6x5Czh3joNAKKRTzF R5nrPiOEUxSjqKUBsb57QhR3yh9tzzSR+i/zfeYOI5PFHB0Uk15KJ5gf/hZnGZlJkphN cq1g== X-Gm-Message-State: AOAM533PInJtJqenjr4Hl3xmCYgc0gxhS4J3sCKJF+bHavJCpWZPL2VO P8/bFIKCLq6dGXW56avLfBLz8B/1dgSVpw== X-Google-Smtp-Source: ABdhPJy2jUowg1ANRQ8CFtzSK7/rB50TWC4jeeI9AFQBhNkOZoJ5RvC7xp+e4i75iiWjlTeXxXAJOw== X-Received: by 2002:a7b:c214:: with SMTP id x20mr5853997wmi.171.1625238591627; Fri, 02 Jul 2021 08:09:51 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:34 +0100 Message-Id: <20210702150940.226941-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/8] ipa: raspberrypi: Add a constructor struct DeviceStatus 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 constructor sets all fields to 0. This replaces the memset(0) and default value initialisation usage in the agc and lux controllers respectively. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/device_status.h | 6 ++++++ src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/lux.cpp | 8 +------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index 733378dbfa27..73df7ce228dd 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -14,6 +14,12 @@ */ struct DeviceStatus { + DeviceStatus() + : shutter_speed(std::chrono::seconds(0)), analogue_gain(0.0), + lens_position(0.0), aperture(0.0), flash_intensity(0.0) + { + } + /* time shutter is open */ libcamera::utils::Duration shutter_speed; double analogue_gain; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 6c3a4eb2a04d..393cfacea025 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -172,7 +172,7 @@ Agc::Agc(Controller *controller) // it's not been calculated yet (i.e. Process hasn't yet run). memset(&status_, 0, sizeof(status_)); status_.ev = ev_; - memset(&last_device_status_, 0, sizeof(last_device_status_)); + last_device_status_ = {}; } char const *Agc::Name() const diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index f58d69397e1c..a3ae633b867a 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -61,13 +61,7 @@ void Lux::Prepare(Metadata *image_metadata) void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) { // set some initial values to shut the compiler up - DeviceStatus device_status = { - .shutter_speed = 1.0ms, - .analogue_gain = 1.0, - .lens_position = 0.0, - .aperture = 0.0, - .flash_intensity = 0.0 - }; + DeviceStatus device_status; if (image_metadata->Get("device.status", device_status) == 0) { double current_gain = device_status.analogue_gain; double current_aperture = device_status.aperture; From patchwork Fri Jul 2 15:09:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12794 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 8601AC0100 for ; Fri, 2 Jul 2021 15:09:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C5C468510; Fri, 2 Jul 2021 17:09:55 +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="nBxzcD6h"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE87068501 for ; Fri, 2 Jul 2021 17:09:52 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id a13so12832924wrf.10 for ; Fri, 02 Jul 2021 08:09:52 -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=O7H1hFZyFkxaWCJ77Wzb3PdS3XbH9S/vOwpeZxUZzf4=; b=nBxzcD6h8lmYCahsnYL4YfhoGJT5S795pHeMd3styf1xaVyCJf8F/HETstJ3FuyYvu FvHS2TGnFVVF7Wu6EbdMCVRFMuWQaGt6va9hBmducZG4Y9JyLeg3KbWSKjDSRMa2EgC7 QgAi/hitr3st1dyAvTpQod7TNn6Um/wtR2JuoxZPswCdpBXcxl/s8v6sWPH2ADy2bEbI h/A9lj3rDqt56oso7q1jHf0UuFNvXFLkdh3m5AV/XhunG4rWZYS0Toxwxs6AE9YdUh3z a9nNuNuBsivAn290xI1f+En9tcOHx8zF3ixc7qUeu6TA+2asYCfTq+vMeAYeQG+VYo2g R3/A== 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=O7H1hFZyFkxaWCJ77Wzb3PdS3XbH9S/vOwpeZxUZzf4=; b=uk+SByHdeEsvq+FOKPccnTgUdzk07XeqSu8jXiQrRuaT5iEFdtTmgaYmWTlM2GaZYj p6KQM67hIYl3xhbc1WqmRX4DbmjXjz5uf5aerwUweJhzJKm2MaDY8tu7GIYh6bYFrW+4 WF2+ag6zFAhkJKQE8n9IB2PwBwyl7x/FLyCQZY3a/Y9zuINWMglAYROjmPm9DU5S9lGY Jn0TWT395g8W7sTe4fhCFSHOXpZ7Aa/nLZTRLQYnSAzQZM6hs8mG3CuDrLO22jxVQbSV CY8mACLGCJUqZPdaKWuLzRmm2fa0fjhsGImtRm02cKmv0aM/R9OqCIiWLKR+Kix1vzgi bSYQ== X-Gm-Message-State: AOAM533IfI8O99OBbhdRSwATAThHuteVLqGM7wDe5TOGBeLBzPqWPq/I m3rnVLisF13a2gG2h9Tt496VyX2pt5Z9jA== X-Google-Smtp-Source: ABdhPJws4avxQLBpaB121JYLthki1EVVhGFv68znmD6vxaY55xv95qTWz2DZeHKS2w/lztlzg8tvGQ== X-Received: by 2002:a5d:668e:: with SMTP id l14mr93955wru.227.1625238592298; Fri, 02 Jul 2021 08:09:52 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:35 +0100 Message-Id: <20210702150940.226941-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/8] ipa: raspberrypi: Add an operator<< to struct DeviceStatus 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" Add an operator<< overload to log all fields in DeviceStatus, and remove the manual logging statements in the IPA and CamHelper. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper.cpp | 5 +---- src/ipa/raspberrypi/controller/device_status.h | 15 +++++++++++++++ src/ipa/raspberrypi/raspberrypi.cpp | 5 +---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index e6d2258c66d7..1ec3f03e1aa3 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -188,10 +188,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; - LOG(IPARPI, Debug) << "Metadata updated - Exposure : " - << deviceStatus.shutter_speed - << " Gain : " - << deviceStatus.analogue_gain; + LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; metadata.Set("device.status", deviceStatus); } diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index 73df7ce228dd..e2511d19b96d 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -6,6 +6,8 @@ */ #pragma once +#include + #include /* @@ -20,6 +22,19 @@ struct DeviceStatus { { } + friend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) + { + using namespace libcamera; /* for the Duration operator<< overload */ + + out << "Exposure: " << d.shutter_speed + << " Gain: " << d.analogue_gain + << " Aperture: " << d.aperture + << " Lens: " << d.lens_position + << " Flash: " << d.flash_intensity; + + return out; + } + /* time shutter is open */ libcamera::utils::Duration shutter_speed; double analogue_gain; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 4d09a84f6532..f51c970befb5 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1019,10 +1019,7 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) deviceStatus.shutter_speed = helper_->Exposure(exposureLines); deviceStatus.analogue_gain = helper_->Gain(gainCode); - LOG(IPARPI, Debug) << "Metadata - Exposure : " - << deviceStatus.shutter_speed - << " Gain : " - << deviceStatus.analogue_gain; + LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; rpiMetadata_.Set("device.status", deviceStatus); } From patchwork Fri Jul 2 15:09:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12795 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 0DCB6BD794 for ; Fri, 2 Jul 2021 15:09:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9F87E6850B; Fri, 2 Jul 2021 17:09:55 +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="KQ7LlMbc"; 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 B5FF3684F2 for ; Fri, 2 Jul 2021 17:09:53 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id o33-20020a05600c5121b02901e360c98c08so9299734wms.5 for ; Fri, 02 Jul 2021 08:09:53 -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=XfILxhoSVcN7GeqHzwYfdA28qNC+FX05/kS6vxLb0B8=; b=KQ7LlMbcqyp4n6s8GYToi68D1N0ZoOA9fi0J/M0wIBbzaEdw5xBks7NRZdxlrgT81k f+aVnB2ZlulCB0eAtU8f9PKP2nXpQWMhMr0uqoX43uzO0mwladPmwdtbmLIVgPq3Al0q 3I+aN8zwsGU3WkJc+wLKCcsTM2WTbEDgQxC5tHkhEJkRj706bwKU3aa5oJoT38C6bXPb 5pQh8NqEYVZhKv0pQ61Vfnna0+ujIt3MD17ZcWJjYZ1abFoEHyK+wQkbskC1jIIUEknz 9SvFVBAZHlDknNoE8Prnq8U8k3e07ycK0+wT3HkV4ujiQmi9Ra2tKI0iwdcOKAvCPRcL pdWw== 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=XfILxhoSVcN7GeqHzwYfdA28qNC+FX05/kS6vxLb0B8=; b=FFocBUM/HXFqlozjOz+v1hPOYZxnEY1rEcppD8XS6qMhr2uH4o76x8jvwsqPeff8Bo QZOIFI+yXBS1QjoUNSU8IPxipwU0mbehRH+/3un2j3lx0WgiLZ3335D4ysHClssF1V6M OPInnq2uAOMGYesZ7z8paCADhm2LFEV5b7q+UuwUh5tIyng0aXwzU69UbWH8DBPKnUfr nNJdwVqXHpt2YjyLXHHh4ujJVqm2F8VzTcI9dDXApbX1EgZ4FBDikkoboIZMHMVmjUga Tw/brYqjXzbZKRiu3xe4pImxtfmACy97whJx+oF6K2Y7j2Z9EwhVsfZ5xRWfGVom3lII n7mA== X-Gm-Message-State: AOAM533Pc615B4TrU6r68QLPCr/DepKRd+t0ayeLMMCQWLW1Lya946BP JaJUqyQGA/a65MZbJTWOPqoaF3f+jrv2Nw== X-Google-Smtp-Source: ABdhPJy4N20Zl0zYTxbtZtwW6oQPYKV7Q/xT9Leayk+pg4hI+FZOZuJYDQ94YRqsFiKlnp4hg/0ftQ== X-Received: by 2002:a1c:2985:: with SMTP id p127mr6096325wmp.165.1625238593179; Fri, 02 Jul 2021 08:09:53 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:52 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:36 +0100 Message-Id: <20210702150940.226941-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/8] ipa: raspberrypi: Add frame_length to DeviceStatus 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" Update the IPA to fill frame length into the DeviceStatus struct from the VBLANK Control value passed from DelayedControls. Update imx477 and imx219 CamHelper classes to extract the frame length from the embedded data buffer. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper_imx219.cpp | 6 +++++- src/ipa/raspberrypi/cam_helper_imx477.cpp | 6 +++++- src/ipa/raspberrypi/controller/device_status.h | 5 ++++- src/ipa/raspberrypi/raspberrypi.cpp | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 4d68e01fce71..a3caab714602 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -30,7 +30,10 @@ using namespace RPiController; constexpr uint32_t gainReg = 0x157; constexpr uint32_t expHiReg = 0x15a; constexpr uint32_t expLoReg = 0x15b; -constexpr std::initializer_list registerList [[maybe_unused]] = { expHiReg, expLoReg, gainReg }; +constexpr uint32_t frameLengthHiReg = 0x160; +constexpr uint32_t frameLengthLoReg = 0x161; +constexpr std::initializer_list registerList [[maybe_unused]] + = { expHiReg, expLoReg, gainReg, frameLengthHiReg, frameLengthLoReg }; class CamHelperImx219 : public CamHelper { @@ -93,6 +96,7 @@ void CamHelperImx219::PopulateMetadata(const MdParser::RegisterMap ®isters, deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); deviceStatus.analogue_gain = Gain(registers.at(gainReg)); + deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); metadata.Set("device.status", deviceStatus); } diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 4098fde6f322..91d05d9226ff 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -23,7 +23,10 @@ constexpr uint32_t expHiReg = 0x0202; constexpr uint32_t expLoReg = 0x0203; constexpr uint32_t gainHiReg = 0x0204; constexpr uint32_t gainLoReg = 0x0205; -constexpr std::initializer_list registerList [[maybe_unused]] = { expHiReg, expLoReg, gainHiReg, gainLoReg }; +constexpr uint32_t frameLengthHiReg = 0x0340; +constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr std::initializer_list registerList = + { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg }; class CamHelperImx477 : public CamHelper { @@ -81,6 +84,7 @@ void CamHelperImx477::PopulateMetadata(const MdParser::RegisterMap ®isters, deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); + deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); metadata.Set("device.status", deviceStatus); } diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index e2511d19b96d..916471ab258b 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -17,7 +17,7 @@ struct DeviceStatus { DeviceStatus() - : shutter_speed(std::chrono::seconds(0)), analogue_gain(0.0), + : shutter_speed(std::chrono::seconds(0)), frame_length(0), analogue_gain(0.0), lens_position(0.0), aperture(0.0), flash_intensity(0.0) { } @@ -28,6 +28,7 @@ struct DeviceStatus { out << "Exposure: " << d.shutter_speed << " Gain: " << d.analogue_gain + << " Frame Length: " << d.frame_length << " Aperture: " << d.aperture << " Lens: " << d.lens_position << " Flash: " << d.flash_intensity; @@ -37,6 +38,8 @@ struct DeviceStatus { /* time shutter is open */ libcamera::utils::Duration shutter_speed; + // frame length given in number of lines + uint32_t frame_length; double analogue_gain; /* 1.0/distance-in-metres, or 0 if unknown */ double lens_position; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index f51c970befb5..db103a885b7a 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1015,9 +1015,11 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t exposureLines = sensorControls.get(V4L2_CID_EXPOSURE).get(); int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); + int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get(); deviceStatus.shutter_speed = helper_->Exposure(exposureLines); deviceStatus.analogue_gain = helper_->Gain(gainCode); + deviceStatus.frame_length = mode_.height + vblank; LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; From patchwork Fri Jul 2 15:09:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12796 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 67C35BD794 for ; Fri, 2 Jul 2021 15:09:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A5A568500; Fri, 2 Jul 2021 17:09:57 +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="od/O7oNY"; 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 78552684F2 for ; Fri, 2 Jul 2021 17:09:54 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id w13so6876657wmc.3 for ; Fri, 02 Jul 2021 08:09:54 -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=XBlZs4X9ro4jey+DyAWOiX9wIMQ7Shrs3R5dauejZKQ=; b=od/O7oNYGKIsaBIb0ZouUYFo/O7kC//CQHmHnepsUJJWir38ZskPo+BUAds84PJSFA M8kKhoBcD5UZO3GVA1WZYqeY33l53nTQ6rEFXt07uSxaJV5BFxL+39ywoLf8/uHttXVq nTvx/yNXKiQFSF0duFRZkn2eWYF/bnmyIVJEuiXMEj2Y0pBl3QLMGSBnAnuVdj/TLXoM F2+qjjCS/4LQkS5S2pvFC5SDU57/UJTVT106NN8Yg79ft8DWfPrbUArsd5aNiFegaSP1 c6xNy7PGgeqTKiTinwNRwQoRFN08zmOQRpYpGCphCMBJ0/lUUI7sEG8/BpJDrjCkFvbe 0HtQ== 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=XBlZs4X9ro4jey+DyAWOiX9wIMQ7Shrs3R5dauejZKQ=; b=pLk/6q7QofY/Xwn7LbbHj7/+s+kNWb2UQAcR/vSc+a8mjk4Hky0Vcqnb8Qb/xBkkcz A9ZO04voDmZbcI8bqdJFz4ATui6Xra3OeLRECDvz5laGzW3ViDijb7KGasVDFWQv1kt7 HfCeq3uTXb5og2zqMW4clyvs0yMhsZ4LZtIwp4Ld+ID2IFKMYflcbKwk2NwEJ0FcHcMW UgBWvpmJQ5g7w2jplk04RhvzlXVLSthPt3s1064H5q1kzjqUBymPGU9KNAu0N9ys5o2A 1TXF2jVuR85Wmr4sCOt/sWua3AU17HPSWkJyC00wRRJLJJnv0Ikvxuih+iL1fZpxf6o3 7LYw== X-Gm-Message-State: AOAM532kWyaAF/ZFfewhBGhLTgnoettlRtIEpfpVyrQTHEr1fXkw3b6Q mcPd+D/FITbU6x3aaaneq9cqr/iR4KbOhQ== X-Google-Smtp-Source: ABdhPJzNIbg2ysX2ciyYgTpTUNrmyId9oUEoBC9ohMrJhHmfq1/1H0oUXpQS9KYmaZFnSr/Lv/liXw== X-Received: by 2002:a1c:59c3:: with SMTP id n186mr309017wmb.48.1625238593948; Fri, 02 Jul 2021 08:09:53 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:53 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:37 +0100 Message-Id: <20210702150940.226941-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/8] ipa: raspberrypi: Allow long exposure modes for imx477. 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" Update the imx477 CamHelper to use long exposure modes if needed. This is done by overloading the CamHelper::GetVBlanking function to return a frame length (and vblank value) computed using a scaling factor when the value would be larger than what the sensor register could otherwise hold. CamHelperImx477::Prepare is also overloaded to ensure that the "device.status" metadata returns the right value if the long exposure scaling factor is used. The scaling factor is unfortunately not returned back in metadata. With the current imx477 driver, we can achieve a maximum exposure time of approx 127 seconds since the HBLANK control is read-only. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper_imx477.cpp | 95 +++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 91d05d9226ff..ddf0863c11b4 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -6,14 +6,23 @@ */ #include +#include #include #include #include +#include + #include "cam_helper.hpp" #include "md_parser.hpp" using namespace RPiController; +using namespace libcamera; +using libcamera::utils::Duration; + +namespace libcamera { +LOG_DECLARE_CATEGORY(IPARPI) +} /* * We care about two gain registers and a pair of exposure registers. Their @@ -34,6 +43,9 @@ public: CamHelperImx477(); uint32_t GainCode(double gain) const override; double Gain(uint32_t gain_code) const override; + void Prepare(libcamera::Span buffer, Metadata &metadata) override; + uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration, + Duration maxFrameDuration) const override; void GetDelays(int &exposure_delay, int &gain_delay, int &vblank_delay) const override; bool SensorEmbeddedDataPresent() const override; @@ -44,6 +56,10 @@ private: * in units of lines. */ static constexpr int frameIntegrationDiff = 22; + /* Maximum frame length allowable for long exposure calculations. */ + static constexpr int frameLengthMax = 0xffdc; + /* Largest long exposure scale factor given as a left shift on the frame length. */ + static constexpr int longExposureShiftMax = 7; void PopulateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const override; @@ -64,6 +80,85 @@ double CamHelperImx477::Gain(uint32_t gain_code) const return 1024.0 / (1024 - gain_code); } +void CamHelperImx477::Prepare(libcamera::Span buffer, Metadata &metadata) +{ + MdParser::RegisterMap registers; + Metadata parsedMetadata; + + if (buffer.empty()) + return; + + if (parser_->Parse(buffer, registers) != MdParser::Status::OK) { + LOG(IPARPI, Error) << "Embedded data buffer parsing failed"; + return; + } + + PopulateMetadata(registers, parsedMetadata); + metadata.Merge(parsedMetadata); + + DeviceStatus deviceStatus, parsedDeviceStatus; + if (metadata.Get("device.status", deviceStatus) || + parsedMetadata.Get("device.status", parsedDeviceStatus)) { + LOG(IPARPI, Error) << "DeviceStatus not found"; + return; + } + + /* + * The DeviceStatus struct is first populated with values obtained from + * DelayedControls. If this reports frame length is > frameLengthMax, + * it means we are using a long exposure mode. Since the long exposure + * scale factor is not returned back through embedded data, we must rely + * on the existing exposure lines and frame length values returned by + * DelayedControls. + * + * Otherwise, all values are updated with what is reported in the + * embedded data. + */ + if (deviceStatus.frame_length <= frameLengthMax) { + deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; + deviceStatus.frame_length = parsedDeviceStatus.frame_length; + } + deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; + + LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; + + metadata.Set("device.status", deviceStatus); +} + +uint32_t CamHelperImx477::GetVBlanking(Duration &exposure, + Duration minFrameDuration, + Duration maxFrameDuration) const +{ + uint32_t frameLength, exposureLines; + unsigned int shift = 0; + + frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration, + maxFrameDuration); + /* + * Check if the frame length calculated needs to be setup for long + * exposure mode. This will require us to use a long exposure scale + * factor provided by a shift operation in the sensor. + */ + while (frameLength > frameLengthMax) { + if (++shift > longExposureShiftMax) { + shift = longExposureShiftMax; + frameLength = frameLengthMax; + break; + } + frameLength >>= 1; + } + + if (shift) { + /* Account for any rounding in the scaled frame length value. */ + frameLength <<= shift; + exposureLines = CamHelper::ExposureLines(exposure); + exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); + exposure = CamHelper::Exposure(exposureLines); + } + + return frameLength - mode_.height; +} + void CamHelperImx477::GetDelays(int &exposure_delay, int &gain_delay, int &vblank_delay) const { From patchwork Fri Jul 2 15:09:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12797 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 C19C8C0100 for ; Fri, 2 Jul 2021 15:09:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8311968503; Fri, 2 Jul 2021 17:09:57 +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="W5tBv3y2"; dkim-atps=neutral Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E3D668511 for ; Fri, 2 Jul 2021 17:09:55 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id u8so12837588wrq.8 for ; Fri, 02 Jul 2021 08:09:55 -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=/YpVJmsa5egcjdYPoaMhnVTpbUvYaQTLQzwcDmDF1BE=; b=W5tBv3y2EEbyEwZPrxIJ+eIpO/QLTod1GIbFNYLAVZnyErmjOg6zC4yNn4gwHpMeIr PEsFuyeS9ZQuzDrxsEiUFk3JEW0akyws2PtRvTId03veej3EosU3IMwPuMWVJGyhIs1I UlNPWne/T/nUoLWeNYX88X2Chxy+0svX8kVXymVaSmlsNwO5nLohvNLtdX5xjmmwlgMK jrR6ew05Po8eDW6pf7j2BYDw/M9w5O26JEc35g8OuxYAwy+ULcCRnJocrlcsYTp6b/J6 KQj6+T44+F5thIBOio0fpeO/eFsKru0jHKLfQqZqN+gvwUBX3St0x6CE9aVJ8WHb4EUi RKHw== 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=/YpVJmsa5egcjdYPoaMhnVTpbUvYaQTLQzwcDmDF1BE=; b=Jou1SvTadOqcGiDUszvpkwfE88shlMTBBm3fr2cjfuNmSVn8KmuPH50YXxcwXFZkel isHg3oPMc/bfMu77T+vrrVHno0JJbZuA2giP1j+VhX3rgqaL/YlsgSuomXnlwSdAWXEk qMWMYqqqYM+YD8eaIRxEncPvdrIC4PH2ryW/TUskZX9rDvk3GxdYKaU4QFZB1GL0QFUf Wk65qWWN+mpLUZCwb7jGveKM/w2hY+S6ts1/wz84Cs+syVLUMVsfXsiQuHAYbs+tJR10 2S+Jmf/uZVZj0IFFVc6+d5ysRxn8UbzmbSrX4f7MFlHmhuskmxq7RHljIze3diwR8SDj ueLg== X-Gm-Message-State: AOAM5318bbv1pDs8P7UHQXSfDdSpasWGsHZLLngHICz23YoikE4IjfK0 Wwxsw6GABcNKsuv4rsKVHA2ttUOsBsNnkg== X-Google-Smtp-Source: ABdhPJzhwlK/k3B1Vc7poAKhLWFjnEYbCAwbFWBhexmiu0ZMsYloOkqpLMFCFYY7vdn+sY8nsbjQMA== X-Received: by 2002:adf:d205:: with SMTP id j5mr135535wrh.242.1625238594712; Fri, 02 Jul 2021 08:09:54 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:54 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:38 +0100 Message-Id: <20210702150940.226941-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/8] pipeline: raspberrypi: Use priority write for vblank when writing sensor ctrls 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" When directly writing controls to the sensor device, ensure that VBLANK is written ahead of and before the EXPOSURE control. This is the same priority write mechanism used in DelayedControls. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 082eb1ee1c23..53a30cff1864 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -154,6 +154,7 @@ public: void embeddedComplete(uint32_t bufferId); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); + void setSensorControls(ControlList &controls); /* bufferComplete signal handlers. */ void unicamBufferDequeue(FrameBuffer *buffer); @@ -828,7 +829,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) /* Apply any gain/exposure settings that the IPA may have passed back. */ if (!startConfig.controls.empty()) - data->unicam_[Unicam::Image].dev()->setControls(&startConfig.controls); + data->setSensorControls(startConfig.controls); /* Configure the number of dropped frames required on startup. */ data->dropFrameCount_ = startConfig.dropFrameCount; @@ -1294,22 +1295,20 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - if (!controls.empty()) - unicam_[Unicam::Image].dev()->setControls(&controls); - /* * 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); + controls.set(V4L2_CID_HFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); + controls.set(V4L2_CID_VFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); } + if (!controls.empty()) + setSensorControls(controls); + return 0; } @@ -1379,6 +1378,24 @@ void RPiCameraData::setDelayedControls(const ControlList &controls) handleState(); } +void RPiCameraData::setSensorControls(ControlList &controls) +{ + /* + * We need to ensure that if both VBLANK and EXPOSURE are present, the + * former must be written ahead of, and separately from EXPOSURE to avoid + * V4L2 rejecting the latter. This is identical to what DelayedControls + * does with the priority write flag. + */ + if (controls.contains(V4L2_CID_EXPOSURE) && controls.contains(V4L2_CID_VBLANK)) { + ControlList vblank_ctrl; + + vblank_ctrl.set(V4L2_CID_VBLANK, controls.get(V4L2_CID_VBLANK)); + unicam_[Unicam::Image].dev()->setControls(&vblank_ctrl); + } + + unicam_[Unicam::Image].dev()->setControls(&controls); +} + void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr; From patchwork Fri Jul 2 15:09:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12798 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 2F2E8BD794 for ; Fri, 2 Jul 2021 15:09:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA72568513; Fri, 2 Jul 2021 17:09:57 +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="szVGGkOo"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3272A6850C for ; Fri, 2 Jul 2021 17:09:56 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id l1so6859908wme.4 for ; Fri, 02 Jul 2021 08:09:56 -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=SfuMa5x7O4APwHSjQfdP/GutwR5rv+4mkTECTMGoD48=; b=szVGGkOonKmN9PnZMMtS2bZOPDm16FLaYYTu1V8U229S/rwN3Z0rMv6kfjGZeIyv5M rcot+JNQiDROjia4q4a2Rgfl73F8QlRK0EX6dsfHhY58x4QJO3h1MaFmIOlZ6WcgwWNC rJIHa5LtfI+bcD2l+kjoQmevHx0ny6JoiYvUP/Q8Hr3a1dIR9qiO3CSoGJfa7hRWvsSy yJtIuUmlMyBSGctY+aJQ88s12eEw5UPiqM9qZ6n2HypHl9nnFxgTe08cH6xHc4qKyDjY 7ZIuUOeEkH4vHma42q07siyGTkREpMrCgdIweEUJl/9SceWINY/9Mk6LTKr0GdjhoP47 CO6Q== 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=SfuMa5x7O4APwHSjQfdP/GutwR5rv+4mkTECTMGoD48=; b=bIF2eehNsV2eNRSQ0Qfzq71wlN0DeA0WZNB9alWxjcFmcbfQnFtxSi0W8dlwe+U97N +d9JMu1zxxBITVRr0uK/+jlmNu5elPRKVcp5OWgn+xL2AaC3x64y4TMFrTG/F2Ocpshr gijuTR5PbjtqGQYH3lo2P9fzlhu0i4c+OqwK5dnr6hKc7pAVTQeqcIVULfMtIoCTI+bS mDfvvhX2ECYUwhklO23+kV0wSyrOa1jlRyqukmcVJo9dDnG/Raw6IINLcHKjkd1v7c81 5YBUeE4eBpx9hBoeIsbHBEO8quc6GR3kE7zt9bK7RmDH85BEj4tbB6rt/mu4jr4oBTXu fZsQ== X-Gm-Message-State: AOAM530KP6Zl5u3s1xTMhb+Hjt12WPSReQsSBoRwGIT6k4f4OVSBpAWv W5T83xCNqeBU9mPuNoiFrNc4+nLLYFlG4Q== X-Google-Smtp-Source: ABdhPJzSJNs8aWt1cFUcxJATwkUDlTN99VG3W3HZkbbIWIH6JnCKBMhRYKseFou3mjdbkuygiyVXgQ== X-Received: by 2002:a05:600c:219a:: with SMTP id e26mr3950717wme.63.1625238595718; Fri, 02 Jul 2021 08:09:55 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:55 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:39 +0100 Message-Id: <20210702150940.226941-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/8] ipa: raspberrypi: Increase the default max frame duration to 250s 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" With the recent change to allow long exposures on the imx477, the existing 100s limit was not adequate. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index db103a885b7a..8fb98a49da63 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -62,7 +62,7 @@ using utils::Duration; constexpr double DefaultAnalogueGain = 1.0; constexpr Duration DefaultExposureTime = 20.0ms; constexpr Duration defaultMinFrameDuration = 1.0s / 30.0; -constexpr Duration defaultMaxFrameDuration = 100.0s; +constexpr Duration defaultMaxFrameDuration = 250.0s; /* * Determine the minimum allowable inter-frame duration to run the controller From patchwork Fri Jul 2 15:09:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12799 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 36D15C0100 for ; Fri, 2 Jul 2021 15:09:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B324868511; Fri, 2 Jul 2021 17:09:58 +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="Y4SdoOsU"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 00F526850A for ; Fri, 2 Jul 2021 17:09:57 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id w13so6876737wmc.3 for ; Fri, 02 Jul 2021 08:09:57 -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=XRqliTz93DSGGSQlWnMS4j2UEugn1xX6LG8wnraWzSo=; b=Y4SdoOsUmxqctbpdZQyGGbT1nbZQW4qgsUXMA55WDXQP5x3daS7CkC4dZvDccoMFkp /uO8e0++zeAs0pCWEe2vYojwSonQQw54CGuuPWjV7R+F+SNpxyvQuKRgAUZ/3YhtbGeT A8OwHdD8Y3TV65cL9mD73Y6/JJBdhqYU/HpVtXUAyQOvPVOMp9rWNWZJz/UP/QgsiXnQ WwuHjlmDABnO6ed7vA+jwaquGcLYlv2CkTHaDmgwxx+b75DYIFRFsnGQl/GItJtxz2AV RsDRPhPO2WFygaAp3/yW5eVUOUIB2vkeaAwHk5qtfn91cOGBg/VQlWbLpvOMpJizMN6c qUyQ== 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=XRqliTz93DSGGSQlWnMS4j2UEugn1xX6LG8wnraWzSo=; b=PjoYB9pBrOkEnlkqrdKtvHaMGLghC3sBjv7e/LFMmyDHKPPGOGxnJso8vzp6Y/H8KZ nDzm4DLCtNtUQ+U4doKzrits31JMiWrWQKZvOtq3SgphdT61uf9j7Tud3vNzw3tzOe0i VeQykSevqUIg0E8Ksgyb6fPxPH1EmuwHlb+p6rV+TATTQ0wQQBDyclVvUWo+YStBvDyY JbblpCdT2VUft0TOPD5L+qPBglNLK22ls9pYCKVBbQjVG8pB8+kpha+bZbvjEsGQjZe3 NyjpDaVG7m8Z4QmkcKexJCLJ2Knbo7VyDrbWYEkxpcNlIq/oHQBxF9N7YlFLK1SpCojD YN7A== X-Gm-Message-State: AOAM531d2ohCZcDylbyllPSTSACIgII3uOav3vgFOSubmRbzIWFjYRgZ vO1MYQUsuqE9LR+sGsxZFZsnFoed06w1tw== X-Google-Smtp-Source: ABdhPJx8EcTIrVVmst9jVYK0irij2f0jF2ujpLXYoWBbbLW8bF0y4BtiICfs1xyWWg0Q4bUsWY2pMQ== X-Received: by 2002:a1c:7410:: with SMTP id p16mr5841wmc.24.1625238596534; Fri, 02 Jul 2021 08:09:56 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:56 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:40 +0100 Message-Id: <20210702150940.226941-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 8/8] ipa: raspberrypi: Make variable names consistent 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" s/DefaultAnalogueGain/defaultAnalogueGain/ s/DefaultExposureTime/defaultExposureTime/ Change these for consistency with the other static const variables. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 8fb98a49da63..1dd7fd68c3e9 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -59,8 +59,8 @@ using namespace std::literals::chrono_literals; using utils::Duration; /* Configure the sensor with these values initially. */ -constexpr double DefaultAnalogueGain = 1.0; -constexpr Duration DefaultExposureTime = 20.0ms; +constexpr double defaultAnalogueGain = 1.0; +constexpr Duration defaultExposureTime = 20.0ms; constexpr Duration defaultMinFrameDuration = 1.0s / 30.0; constexpr Duration defaultMaxFrameDuration = 250.0s; @@ -390,8 +390,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, /* Supply initial values for gain and exposure. */ ControlList ctrls(sensorCtrls_); AgcStatus agcStatus; - agcStatus.shutter_time = DefaultExposureTime; - agcStatus.analogue_gain = DefaultAnalogueGain; + agcStatus.shutter_time = defaultExposureTime; + agcStatus.analogue_gain = defaultAnalogueGain; applyAGC(&agcStatus, ctrls); ASSERT(controls);