From patchwork Wed Jul 7 09:48:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12845 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 40C34C3224 for ; Wed, 7 Jul 2021 09:48:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 676C06851F; Wed, 7 Jul 2021 11:48: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="Oyzw3sYx"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E799F68506 for ; Wed, 7 Jul 2021 11:48:18 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id p8so2341992wrr.1 for ; Wed, 07 Jul 2021 02:48:18 -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=D3oFpFZ1p9wALh8EJbaFVtp6PZMGVEaHidSzqojaPWk=; b=Oyzw3sYxgKbdok7MiAIUVoEnHh+mZxYtYeEdu6WSSjaUL3CPFO/g5VzDd4SvTMQKnn A670L463l9f+1Oc0/fzO+IE+Bgd1vMKNAYJc8st6S1WA2bLvutM4ehpAXZlDl9AAQEfv UPiM3ze1O7QwW0zN35H9okldotW+2Vltxd8jFsA/91qdw589k4IFBkynTHDOhD2PbD1K jgaL3Sf5lP7nkibHptWEYJS1gbynLmOimkgKv+z9xfgpsZmf0vg8iKzE7xJy7zG/3Ily q5G+jj8O7jKawdQjGe+3xhxxxuZidDBg7/LcUfKSkUC3aAnJGkipuBh5u2hWsUU1ky1E lNkw== 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=D3oFpFZ1p9wALh8EJbaFVtp6PZMGVEaHidSzqojaPWk=; b=VaQbTEzd254iEdPyV07AfVbOA3khy9Rvg8Uoy98MrBfWWGEuOk5OI8IK/HUgHS61ks kk3eN9yXxhHgKRAUCu4Umb9fHJtkzoh5GHnh1Ed6+P0DrVWmOjffNJB45jJcUshINUAl UQnCZq8FdRPlSFVxeHhVX6rjf5HSjmnuUVVjAM8YjdCFFph+8O23LEl3TBs5Gjp+0xnW /q1zsYW92A3Ms4pRMLona1tv/HoXIp1cbRDaiZmGgd5Zznv5gveO+pQXp/r3v9lu81fw vSQtyE1tYG6CCV8MG1hP6a5Gi8BIs1at5yOQzOSPHpMEgSwbhXZi82LM0+540swiJyDx mTUQ== X-Gm-Message-State: AOAM530ro9LWZ56N2vVlZR8EY+tDEVJoj5RplvGeiPmkwHqKQkqSfbos BMCis4D0X3PtV1fj+hgMmYquWWoo9Ikqgw== X-Google-Smtp-Source: ABdhPJzbs6RMRuDkjYC+TR14J2NBtI2j8cwWuGE+0l6V+WLHKyCp8qFl9MQIHG657uPwPOygayRukg== X-Received: by 2002:adf:d232:: with SMTP id k18mr15789851wrh.35.1625651298458; Wed, 07 Jul 2021 02:48:18 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:17 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:08 +0100 Message-Id: <20210707094815.1500917-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jul 7 09:48:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12846 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 0842CC3224 for ; Wed, 7 Jul 2021 09:48:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AED1F6852B; Wed, 7 Jul 2021 11:48: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="mGD/JX6z"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DAD168506 for ; Wed, 7 Jul 2021 11:48:19 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id t14-20020a05600c198eb029020c8aac53d4so10124906wmq.1 for ; Wed, 07 Jul 2021 02:48:19 -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=xKQKDlA/B6wWUNDaLbnwgPOltVgogbkgEw+x4QjCkLg=; b=mGD/JX6zEIMZOmNAsMeNt5YcqfCHDqbppe+OcDIFh66ZKIS8Gaz5LmoZdS2hPyw5fk qAAxtQlZrbOCcQxDEfTVapXLMtTRXY26lhG0K3SXKnk3W0vRk2t15Yd8IMVIEjniS+A2 mv0uyOd9ZXHzCnKaAMRsA7wLp+bRCfyDvt6FcR+MPN9lOCqRc3qXKk1Flwpykh4wyzla WC7M2zvUZJqO+yeyWSHiWqwvFLpqa3jTV6q030JRTj88dC/28LRL92MPiYuhZ5IdLTKC onGW18piFS7QZVICUqWt6QkBN3ORFiFc2bP98bUeynl0b8h0THvLTtcP770hHMslT6eF TraA== 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=xKQKDlA/B6wWUNDaLbnwgPOltVgogbkgEw+x4QjCkLg=; b=ZsEXGr3/YjdrqjnQXUYXww/IS7NsdGLqIXXMOZJFCV6otpNYzGD51ifPQHEwDcFbEV AIryvGT0qT+BSK+4EKBaLLGLF6pFtllTkp/IBae4E6MvmyDXMYCu2TPTaQsQypvDDHXM ux/9Kkzg5kD8uOzpWlKbu9DB24hK2+/M8RCmyf8O9yI1hSbMiqu28AYJliedsjHMCWk+ uQTePb95x+Wi+W4XWHbjJANrexkUdLcjbflmy5S7DqwMUFr47hr1G17bZz6PS+CWGx5G WYAE7DEcq1ECFBrmt7u3D0YH6uTLC+yRJRJ9sGlhcsE1PjALUJ/1EX4aWnC623aGnr1F nhug== X-Gm-Message-State: AOAM531mYl0/eKwxYF0vxEbxvPq5B6OYoWX9DosMEB8lAs9IEkIkD2WQ DLNbKEW4a8x17lWBDnNFweseIruRoTPXRQ== X-Google-Smtp-Source: ABdhPJyLdeIMF+kfxRTXEGsQYjUphQkxje820efOHbKOLIYO1+8ofIrx+zhy+z8oO6U1j1uL8h65GA== X-Received: by 2002:a1c:f70d:: with SMTP id v13mr24800544wmh.183.1625651299144; Wed, 07 Jul 2021 02:48:19 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:18 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:09 +0100 Message-Id: <20210707094815.1500917-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 1 - src/ipa/raspberrypi/controller/rpi/lux.cpp | 9 +-------- 3 files changed, 7 insertions(+), 9 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..f57783f821ec 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -172,7 +172,6 @@ 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_)); } 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..6367b17dc7f4 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -60,14 +60,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 Wed Jul 7 09:48:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12847 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 16F17C3224 for ; Wed, 7 Jul 2021 09:48:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 992306851D; Wed, 7 Jul 2021 11:48:23 +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="oybOmDuS"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52BEC68525 for ; Wed, 7 Jul 2021 11:48:20 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id q18-20020a1ce9120000b02901f259f3a250so1261498wmc.2 for ; Wed, 07 Jul 2021 02:48:20 -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=2MOHkI9d2JftDLF72AIP/Z1PbT5IJT/M0ZOVm45a6as=; b=oybOmDuSdfjfaM6u9b7/usQANU+nsGh3ppGdZ31dXnEfRhq0gpb6MCaps9rTw+T/F1 eiJeYskVvr1dcEX9hVDJ/ZnBkmooVteXK7SaZ30U70JAxvnyYRI09pnMXbkJ9mDrsk+Q 8rR34TB7D3bCLqFmsE9Y4WtWhyO2I+RE4kzVH6YfEeBAYNatnhanGF7eVIiEbDVykWXd nry8zwmPAXRQFTv5kq2IPKLYRKghQKWzjTu6N3FWV8jHG+KOOGSKIApswiXBF5LWq2aX 3lrpzcQ9NSPZlN44gdmPfgiOtCsYYNSrz70Dqu/yKEFAVrDZC0nPZq+EYgqobnMSuh+l aGAw== 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=2MOHkI9d2JftDLF72AIP/Z1PbT5IJT/M0ZOVm45a6as=; b=LFdIhYvzxGc0C07Ef9dl3HmBE19zhkkemDdPFPE9bb2FjH2WZ22GqnTRkyCYQWOctX lpCzTHqIRRBBuU4iIz0e1zulUX+vZ7JqdAFtgKO8g+D7e6pCv8pijZg3Q45rGP27nCT5 8bMlpP5b1r/iSR8RaeNXM7BBDNW/XU4/v0C+w9ce/82qhMOB7vowZxM8dKAAVZ6FsIpx 3xopyFIeRIxC3la6GO4hnsqvZLNpyJIbjszjVmAG00cN9TovAyNkXPfL9E0tyG8GKEOI ukxQi+D7y7sDgthhqPNtoIgh6/4DZX38GgA9nZMKXJuB+mbjF3zcV+uFLs3flra6MRW5 x3fA== X-Gm-Message-State: AOAM531mtakzCiQI7/IKHRnGmmy7SWsLKfe7cv+6yMbNbLXXGSKkMWCr BpLwicOUiR95BEOV8MNDRner0aTpt7GRvA== X-Google-Smtp-Source: ABdhPJxQ3BtX/2CiKi7EU3Jql1VWvHu66158wERlwAVtXv9Crm570dNHfB2J/pwJze71s4iZLQcvBw== X-Received: by 2002:a05:600c:4143:: with SMTP id h3mr5734126wmm.35.1625651299797; Wed, 07 Jul 2021 02:48:19 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:19 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:10 +0100 Message-Id: <20210707094815.1500917-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jul 7 09:48:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12848 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 87853C3225 for ; Wed, 7 Jul 2021 09:48:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 48C7D6852D; Wed, 7 Jul 2021 11:48:24 +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="cNdFcpBH"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E67586852D for ; Wed, 7 Jul 2021 11:48:20 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id t14-20020a05600c198eb029020c8aac53d4so10125035wmq.1 for ; Wed, 07 Jul 2021 02:48:20 -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=SL2VE/oHSC2fXzf+qdGiYlkTgGyRfJpTg5+hSXVd9yw=; b=cNdFcpBHmVetCB12j/5L362wCfyprrY6fU8jt7dBpCTuuR0BbKXTvQe1kGif+sAIz1 S3r1h8hgCTxRqyOwkP+8aNyvlAxew36Q8l/lpgORDJAxTL2mj2YeTpZEAFoZUXrhWDQL qIh58i5Z0U4+NKCgFqnCll5UMxeihjTMfom1XVheX9O5e53rAZ6J73jFociY718uYowb Ej6FQIsc5AVzvRaWsoO1GfOJ8NfKCIscKQLo/CnvXYVDFC5+BQPDyqK0uoF5Xk/pWr2D IisiKstYaD9LCiAOY35VfQ9vreW13sOg2CkzlaSWCSva/hP0obUslagsBSgMl/NflNuz Tmmg== 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=SL2VE/oHSC2fXzf+qdGiYlkTgGyRfJpTg5+hSXVd9yw=; b=EdJ/5vIZPw6ZA9JCnJ+eaXs6VxdrU5lMULXwTCHW5bgbYl4xy5sndEpBjNsOqj6tQs CDvRqBIs+q40Inj9JDPQLIAAprfTvlv/jYF/6ZB6PDX5DveeSvqJmTWcXnIQHT7veDuE hBTAuJ5y9cjOrkRKlc2xM8M6BDgY5C9XcA2qjOW7DzTL66R+TNJpxvFtbSsacjvAmNWj blFxAl0K3IXgsIJCzr/qTZlyrKIyMet1gqIhTM0PnlshZH2DAqiXGVYantSsuZEokg8C AFSpNl2dusQBM4vHcS0PtUvSTUdz2hgV6A9FlA3RpnCjE02Czmufy4DOeGp6OohpCPU1 GCoQ== X-Gm-Message-State: AOAM532rP5yUnicF2jewOEHO3i1KMYHTOQ864ytR74MUC42TKXSkGvG3 pWOwmwZ40XHUMWnCVC5jwJrCAt/+SaKecg== X-Google-Smtp-Source: ABdhPJzC9N6BS42xjCoyeXdA+JvWP6bn9k+3iknBDPGfVC5Rgd7bPOeo/eX7ypB+1hfs7In7lGFg4g== X-Received: by 2002:a1c:25c6:: with SMTP id l189mr5988142wml.49.1625651300392; Wed, 07 Jul 2021 02:48:20 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:19 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:11 +0100 Message-Id: <20210707094815.1500917-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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.cpp | 1 + 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 ++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 1ec3f03e1aa3..3c6afce7572b 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -187,6 +187,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; + deviceStatus.frame_length = parsedDeviceStatus.frame_length; LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; 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 efd1a5893db8..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 = { 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 Wed Jul 7 09:48:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12849 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 1AF98C3224 for ; Wed, 7 Jul 2021 09:48:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A4D7A68532; Wed, 7 Jul 2021 11:48:24 +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="YeBVcR0r"; 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 846AD6851D for ; Wed, 7 Jul 2021 11:48:21 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id q17so2334651wrv.2 for ; Wed, 07 Jul 2021 02:48:21 -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=0g23v4pBAFw285BuG1E6vpBAHfnc6mX/ZaNFigt0a3Q=; b=YeBVcR0r9yazAveuz7bCmHc9XFlcvC/Z5WhRuilyuZV2Ug9hW05DKetEu9+pl1o2sM 5bEwBnCeQKqxTbFA64/bCY5xIk+eGLBraITzW7Q+uj0p7yD2lHPIluabcjO9EpjJv29r PVvwXDZshjUnF/Io7bmaeUt9VLwq/MglGyV36yKShDqPX2vVSXVSMwr08Da/F0Y3mH+2 GaZ2EoaxeV/9t3h0bF9Q6aro2YNoQEaqoPW+y+si/tQrEKFg/+K9frYBqXohfQt1KWNe 5mZHft8nXL9G60lr441molUKPP1pUjetVvoGaN7est5KsDur3K0qMoH7fPeACvz3XdHa 1Ijw== 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=0g23v4pBAFw285BuG1E6vpBAHfnc6mX/ZaNFigt0a3Q=; b=F3Z8NBcx+nNXVyPR088/2lsjbCDkhXp2FxCmTpi7KRdPL+GbZ4Rk/hcG5iWHsPTz5g j3Ewf5g5lpvoARGNLJnjUT/2bwfn2K/JoxZzfNersNyApq/XCCrs2tw7i8iG1sTrrWuq G89Avwt5cKbPOYVZFGW2o8HBRiClID8OOGQkXDOIZw3PHIOhahAITXBCptvc2h0/PEjL Qh1jhPpsK6Fm0jE7uMnszRx4qTtRJV6Z5idd2TwsXVo0bVk3QosQmUhYjHlb0QTHti9a A0TANB8Jyd3OKcLELLOADXe8M+zuP0lFyr7nWB1MPtpo7oAcLovYm+ZSwTJalhA7cpUW cKoQ== X-Gm-Message-State: AOAM533ooqHjQ9XQl3jZ+ezM1L+EztCVIaBHR1FquhwLXqd0/Wy8ciP/ lI+5XOwqS4K03fx4q0DxOCG6TZyI9DJYzQ== X-Google-Smtp-Source: ABdhPJz+MmwnO4nFjacOS3v3vga7aE1p3DDrFhCwQoXSW28+MFqx4NzeO3MyzlqeD+iR2r0zn1UYfg== X-Received: by 2002:adf:f850:: with SMTP id d16mr26703086wrq.258.1625651301093; Wed, 07 Jul 2021 02:48:21 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:20 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:12 +0100 Message-Id: <20210707094815.1500917-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 91d05d9226ff..3059a5c6c4d7 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,77 @@ 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; + DeviceStatus deviceStatus, parsedDeviceStatus; + + if (metadata.Get("device.status", deviceStatus)) { + LOG(IPARPI, Error) << "DeviceStatus not found from DelayedControls"; + return; + } + + parseEmbeddedData(buffer, metadata); + + if (metadata.Get("device.status", parsedDeviceStatus)) { + LOG(IPARPI, Error) << "DeviceStatus not found after parsing"; + 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) { + parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed; + parsedDeviceStatus.frame_length = deviceStatus.frame_length; + metadata.Set("device.status", parsedDeviceStatus); + LOG(IPARPI, Debug) << "Metadata updated for long exposure: " + << parsedDeviceStatus; + } +} + +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 = ExposureLines(exposure); + exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); + exposure = Exposure(exposureLines); + } + + return frameLength - mode_.height; +} + void CamHelperImx477::GetDelays(int &exposure_delay, int &gain_delay, int &vblank_delay) const { From patchwork Wed Jul 7 09:48:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12850 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 6D27BC3226 for ; Wed, 7 Jul 2021 09:48:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2483068539; Wed, 7 Jul 2021 11:48:25 +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="obSaFO+G"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2038168516 for ; Wed, 7 Jul 2021 11:48:22 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id n33so1419262wms.1 for ; Wed, 07 Jul 2021 02:48:22 -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=obSaFO+GsG/MZuEPQjlXN32iuOEEN9lzgWZNhbLoMImHwUP6kth1HWUSBnmvrQUydH WAKVMnWLbJ2MGDWImNy422KWCiD13+xzRiLrVJZPSlApNuvDO/+Fy17WPOMU/jAY+UW6 Dgc+MrttrTml8nwaZqKOV1n2PIC80VwIuv+MVuLAMPqfdD/BiOvGmsUFn5wIIJdcZLoz 00lgpl3VUOO4DhFLJbJJ6H8MnAIEgfxq5TBagyOOx+QtzhW5XiSfcjZdWRqZKWjwQOCc wjaccpBhCQ3abRZGMHcW7Uc7DHpo8MAbJkgc3cOhVT6+zs7Z1KTRtUOAcUPwH4L5GMKf eABA== 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=KNTwBOlQebkCVbwyGrXI721RjlYZ01vrC5teI3d4wOLH2/K166ZUNtoY5z/1H40YfE yxgfSMNCvzeZ/nksrAaMHfhbCaRGZoe6BZqImLAGujwD6u7csbAm9XFhk5IPrbm0EBiM OKmy3lEyFL3ux8h8HED/yYl2nrnCPxdZRDyiNEJboYuNZZ+rNvfuQTttks6fv4ijPoQ+ uJNtW67Yi2wGhzSSIctPSN06IOcKhjKyXnSyrG2+0PYFDVxmW+0hwmGHgQM10TqjuTp0 wgUJa8udopK54BekiE0c34OcXDrfRbMlW7d0fRNo3615peMNMav79WqG0Vbjz8GmRfve 7q9A== X-Gm-Message-State: AOAM532q4XW+L/oLa8mk1kd+Qw2usHVHWP5HleTqBVRiJQyBtduQZ25p /wQeWyAX/04gDQmPEJF+IfDak10JaBi7Bg== X-Google-Smtp-Source: ABdhPJzfpdo0thMBQtixTa0tZ5puuRXhcfnJAw2MImvusbXNqeVFNTHacOwMfvp4+r053DYtOqPfcw== X-Received: by 2002:a05:600c:1c8f:: with SMTP id k15mr25895370wms.91.1625651301716; Wed, 07 Jul 2021 02:48:21 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:21 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:13 +0100 Message-Id: <20210707094815.1500917-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jul 7 09:48:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12851 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 176E3C3224 for ; Wed, 7 Jul 2021 09:48:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BE72D68516; Wed, 7 Jul 2021 11:48:32 +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="AlKcPrrs"; dkim-atps=neutral Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E7F6E68525 for ; Wed, 7 Jul 2021 11:48:22 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id i94so2327745wri.4 for ; Wed, 07 Jul 2021 02:48:22 -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=AlKcPrrsp0e7/MAbXR+KUt2Uoumk+7BCoDf0hy8mrWVuMmUkM3VhG3DwOYETtfeWYE ssm3xfZ+XYwISF9Tz8JrJao9pcjtiHESOp2BLY6XIJTrI3YItgbkmrAE+oc5DFpJDc5r 9mGPodtidtDA1hgbrqyotPWUa7o1vi6d2ApOGRpbftuR8uSZXT9PxF3AbJYwzo+eEMFS 3JvOLRDITdIi5fUxtu1YiWyYPxCcwJI0TYjx1WivnuqNmckQh2xY7w2KXstqpFb/WJbm UtddVs2tVgdUrP9As8OFNVirNohuAJqsTW1EYJzFu+12iJGS5YB94EF1UMBr7MX57VNr s40w== 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=q0RAfZZ1FSnFfkBx3Rqr9ePAB56Jnsvs/+MLn156yDPuLYIfzNETRv2uoZz/862kxS V4J+KkqeNMfEwHcrKVe0ztDE15fYdECaXduo7SO43MLwvwKJFGo7wU+WMc9rg5KKSBh/ FJD7fYpzeIjyuaRKRsAzzlpFq7y5DXExLyJ8oJBoABR+haeSWE1yCeYxbMu3UIFjdLUx Nw2XGbNbhvbxESQ/9A2pMbhFPhp4jvWwxWi38HO/jgrSfmlOGHQXZj8Zsi6DWW7Ff+YJ fYis1HlaAlSy6Y/Rk3ALkjFtEHXepsU8f/fTCMsIKHF/Kiy09xahFm0zQtL+NTeWKMUP czhQ== X-Gm-Message-State: AOAM533RvHWODCeqRyb1RpandMECjKzdp6TA0PABSiG/beoIuH1s7Y1q yK/EPCnz8xUqiIUS9NZkMgUDUr50ogRWCw== X-Google-Smtp-Source: ABdhPJzO4adTzTsjYgn0s3ZWfClGQ2YlyBXbv9tai5qdcm6+uiPJ78iJD2l7JiFGDNvgcKFAdWoCZg== X-Received: by 2002:adf:ec07:: with SMTP id x7mr465657wrn.262.1625651302487; Wed, 07 Jul 2021 02:48:22 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:22 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:14 +0100 Message-Id: <20210707094815.1500917-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 Wed Jul 7 09:48:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12852 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 6AAD3C3225 for ; Wed, 7 Jul 2021 09:48:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 272EC6851F; Wed, 7 Jul 2021 11:48:33 +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="dN9i+D6R"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E3386851B for ; Wed, 7 Jul 2021 11:48:23 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id t6so2296264wrm.9 for ; Wed, 07 Jul 2021 02:48:23 -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=dN9i+D6RKPPLxUCHuh2KwqgOie/w5yIdl7EpIw3SR+PebDSbx+VmMsJygl479OGqqQ rM/7huivwoK+IEQn0n3DdDqdfjLMtLIoRmDINUvTIugOlCWgGB9Jc+qa29kVUOm+aNUb pXixzJ7/JfHA29XqNOPJTkgxG4Zl7wMFWBY5DqOxn4nk3MrcurmEOBc2mkN0crwU+hoM tq0wFIDsMDDI3+Fjc5h1njmw89ec+F/iJZ215gy5/EmtOn41pbsuNtCVYbh+LQ3rmFRi Q8n2cujAXDZBCMW2x/gQB6u7m2zlR7QFILaEp3iyzMoleOIE6CLoVPTJzY2cGGWqK8cF STbA== 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=ugAKTymgDU1Hdy7ztsUQar6W1h2KVZPHagFM/DXk/5kaNpbNBdyJHrp6l0lZUwXqY4 uT01jG1cAaz0UKucnv6krdM+XSVTPNht81T7s37TWpvKxnrQFV2kXPCru3ReW6GrAQGB j9ojGjltDwbEkf0YSAqolAHOtmb1ZQSv2WICQWsZikqEiz7ubAYUfuWantbUCe9k4W67 3ZkI7W/gP5IF+goL+nIhpimg5qIGYzVGOFyycUMJn+WNXoBbTy6qdFPY+s5SrTauLPvk QS52wWHN9O6JR+YFnH8D27axr8DRnk2W2TkZL9T65Vy508gff/lpLIZWTax1KFkYkt/I 127g== X-Gm-Message-State: AOAM533YnnOYnaQ3q1Dstn/orXaIVSxueFCXbXBtglhzc1+W62A7sFAY wL6XW0f0mcuEl+qR1ZhU86PhLs+kLpUJPQ== X-Google-Smtp-Source: ABdhPJwWQn7vWf9bCOMe3q9RJfCenKC6GFuzpqwNghALd8ZI8dl8IX3G3vRNMurIhfMtC+zbzKA/HQ== X-Received: by 2002:a05:6000:1b8c:: with SMTP id r12mr18642355wru.427.1625651303135; Wed, 07 Jul 2021 02:48:23 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f800:302e:bf7e:a06b]) by smtp.gmail.com with ESMTPSA id r16sm23377836wrx.63.2021.07.07.02.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 02:48:22 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 10:48:15 +0100 Message-Id: <20210707094815.1500917-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210707094815.1500917-1-naush@raspberrypi.com> References: <20210707094815.1500917-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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);