From patchwork Fri Jul 9 14:58:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12884 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 36652C3225 for ; Fri, 9 Jul 2021 14:58:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E53C36851B; Fri, 9 Jul 2021 16:58: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="CrxyJf3U"; 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 DF1A9684E7 for ; Fri, 9 Jul 2021 16:58:30 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id t14-20020a05600c198eb029020c8aac53d4so26039070wmq.1 for ; Fri, 09 Jul 2021 07:58:30 -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=dNPy1AuK4kcuuK0B4jDCWxmKmOZ6QX0jJpC6NtzaGA4=; b=CrxyJf3U3yW2/kAhIuYrLYOgu2VsaEcUwOmfkyV/SGGgDzYfOosBdn8pGCUMKEfs5f J0sQsYHSestTAQb1wb096leGQfpWPUDk5tVLAqry+ILxHmkgykMuDuX2EnjceX2Pjecb TzX5xcodyCwa7swVNREaS9Tutvb+Dz8gXZUIpz+bmeWVuJbqv3y+wbiQX11EULReRj6U 1cfPCmxtutzpeaKw0Eez4WvNBv31I6BTI3QngtmORO5f4FqPPQ1vrBAWuMVJiaDwJmrt vFg0GesTjbcEUR95WrX78h9O03jlXKBnXPtIVlbQ3g6XeVUjrohVwproU8eukD5guFvA o6CA== 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=dNPy1AuK4kcuuK0B4jDCWxmKmOZ6QX0jJpC6NtzaGA4=; b=MFe0ruC6KQLCk5Et93mI1EAVsAYNbgcflKyKQcZOoairC15RrbIE19BCFN5LfUnmNh JZKhy16OtSRXYQsunnI6KcXoOdcX6pBPqfl+uGivBBA2VD2MgjgFkX0FRP6j01LVHN6w q4YHeofby7HkURpVAy2qoSJ+GOBuklN8Gj5EXWC4lOYIQf2X7qORvjY/GTSSgDyT4zp/ aagixZOYuDE/4n2XEUtbbFxg5BN+D9QjbiL0RyjYPLI8tPq8q1v0kBXpaOADGj73b0JX SFkD/ZaZdxwlNJUd99z3Qk073xfv8+Y3JsPJdGlhy6OguEgrko+QaiFesAIkYMFtnuUd zHkQ== X-Gm-Message-State: AOAM532/VG3ltIPEAlIOngLFWS0fFuZb9XB5SBwSK6fpblUo/hzwP4XB 2ymAbbRX6U4P7YgrRDoTFLD6+PB6iyz+dQ== X-Google-Smtp-Source: ABdhPJxcHpARqbVsoFLEvfPMH6XiJU8f5ltOZFAQ+t8Aga+hKVQIH9rhEbnuRwTaxg9B/PZce4Cs2w== X-Received: by 2002:a7b:c258:: with SMTP id b24mr12645737wmj.122.1625842710397; Fri, 09 Jul 2021 07:58:30 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:29 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:18 +0100 Message-Id: <20210709145825.2943443-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- .../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 9 14:58:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12885 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 80F32BD794 for ; Fri, 9 Jul 2021 14:58:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4189F68530; Fri, 9 Jul 2021 16:58:34 +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="DdJrvY7Y"; 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 BA2856851D for ; Fri, 9 Jul 2021 16:58:31 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id t14-20020a05600c198eb029020c8aac53d4so26039167wmq.1 for ; Fri, 09 Jul 2021 07:58:31 -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=CBcHuMVRJcBtnrr3Y7E6tv89VxQZh5+qq8+9trsTclk=; b=DdJrvY7YOzhlqfHAwUbCv+xwT9qWkr29lZcD1qcFQiCtfbYaIsXrPFgQoZdoNyHgQ1 Mx4nDC9ozxwtqXyKUSo1hRVMDqCphpu+/Vct6baO6/rBrVVypIMYguX4hAVTg3uWY8+R I4JDG6wT6wRHaA4EZs1y6YL8WZRvAZ6yrAZrsess1fMiIllnJ1HHFeSMTKa5XvG6gAWQ 6KgzOTP0zpjdGw44dS5+SbpjnRUb24TFZbgcIUkjq75wWaOuWn0Zph/tCg38Sq/aTuEy D5Smszr+DyLn0wVFUP8fOkWZPPtB4IMg/yrPGE3S0tSKZn9vxxxmtSIcZ6vH1Nq6QHNu 1zxg== 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=CBcHuMVRJcBtnrr3Y7E6tv89VxQZh5+qq8+9trsTclk=; b=TpWSeWEXrXRG1q3FSHzAEffNKr5YY9p2IIaPXJzMxypnIbGKOygSjSrPSX2TSDQE2+ G46nzwR5w88jO65DhvajoYn2tTe5Ee74ax6cl2H8tYaNI9WG4CExJWUK5iYaljt5Ah3N +73k/TXahRCiT2xfZazyFrehcLPsfXN7+40oBB5dGN/CsrfI9i+0aG6QyvAWSrpnN5+u oNVaRjW+XIaQNYxORptJK7kB7hwlJOEPxAy2Ghae8linzNAW23/Q/N7iwlroKn9HcgZX cVX/fs+NhjRwcmSOWk2cc6KjjP/98fIMgLgWtPlYJxCsjNemXvvwuCaY/O0e/8nPxXVW WzCQ== X-Gm-Message-State: AOAM53094AuuetUKDM3eCE/d+/J7AkPULppEaGqAu9lfJ0I/3/b0uFUx 98NaPkU927XbXgBsXrpRks6usJqyFNr7Qw== X-Google-Smtp-Source: ABdhPJy2B2rO3BjBYopqljufrekTVKuw+1PPhXmFRl7c1GyHDUr5gx9XA3GB3dH3wRbjkj/v1fCBlg== X-Received: by 2002:a05:600c:2058:: with SMTP id p24mr40235568wmg.76.1625842711155; Fri, 09 Jul 2021 07:58:31 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:30 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:19 +0100 Message-Id: <20210709145825.2943443-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- 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 Fri Jul 9 14:58:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12886 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 01337C3225 for ; Fri, 9 Jul 2021 14:58:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9689168533; Fri, 9 Jul 2021 16:58:34 +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="G05tTqeF"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 70D506851B for ; Fri, 9 Jul 2021 16:58:32 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id u8-20020a7bcb080000b02901e44e9caa2aso6483414wmj.4 for ; Fri, 09 Jul 2021 07:58:32 -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=G05tTqeFfQahWWCHmx76vZjNNueD6VVWKpIcs1DC3BIsMR8t48vkRrC01ecYzrsuDy i1EzPbx1WpNo5NrrZDbvkv5fF0pguAoYWqZkvAIXo20PMwr+skPgMn4CzHEAhyDCxnfr EokwAAKnVH3gvFdahXjO5SKjtSUBSg6WHyUP9rQ1+7Rwvfc2u0kB84KLkyV6BJJD3G8O 7jz7iSLJiJJklrLpGMNM0ERaRYH5X7Svo6Q7GPYRsN1cKWkK3IsuZ+YaHfFtpMpAOhY2 1xHHsbuq1ESTxF/7X+LVIRSjvdiIFHMIkzy2TUgUctrJoqm39ruTaQ+qXvGxhstCP+xE JiZw== 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=rN8vzsmK+MLBchE8BAueniuk4JILAsPc+v3Xwop4u9hORDZjsaiomaE7djq4thq8B4 JxqpY6zu+oYtI7hp5H6P3UhUgB1SFNDwwoW9L5M/0C+5Mx/ezd5Vd7qESlk1K0LkRuM3 21c31I5b6j7WL4lBzDd8oKPrsfcxdOgfEVsD/9yhSE44zPXYDni87LISDyPOZTN1fTY5 E2Qq9I02SvigOon261RDNy8A2kGs1s8gauo75Dk7cyQ49dAWzS7FqoPwJJZ/6mgvbk2V wmdvpqzD6XhueDuG2F1wlS4b4abWCSIEHiAZwC4dqqHg/wtIqknlG9uMH6aYV7nCyz8Z coPw== X-Gm-Message-State: AOAM532XTKT5NFmF+9vnBBTTD8ZCg3f4VOnCI8sBcgq3oxHN4vneZuA+ 2kt/OEP/VV1UKg6006JgcJ2o2wRxiB9bPw== X-Google-Smtp-Source: ABdhPJxmwG97rw6pPRCoj+EYu41cL+Zyshoma6eJkH/xhk8bLKZzlP5Q4lpHp07mfq5wdP/c2uC93Q== X-Received: by 2002:a1c:771a:: with SMTP id t26mr39781166wmi.107.1625842711985; Fri, 09 Jul 2021 07:58:31 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:31 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:20 +0100 Message-Id: <20210709145825.2943443-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Jacopo Mondi --- 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 9 14:58:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12887 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 A0C69BD794 for ; Fri, 9 Jul 2021 14:58:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40A946852D; Fri, 9 Jul 2021 16:58:35 +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="ATsMNzSQ"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 55D2468524 for ; Fri, 9 Jul 2021 16:58:33 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id l7so11608585wrv.7 for ; Fri, 09 Jul 2021 07:58:33 -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=BaTL83jvOXSdWoI1dTPwX0aZv+Y/Ov8YWzEfe+v8ktE=; b=ATsMNzSQFs/3Rgm1Lb6oF2sQWQf1kfXNI9uenWUzEBdfp3sOdzhMY92Tl2NlFG26YV zHxJ4hmeqmdlkos9zmXPDrmZW5WZWPTLc5dXLdsqqqTu+/FXSD9AVJkNgR3Zx9wDr89B bETQMRMY6bivYcTLxZsLjAoTMnKNvkl/c2aIopX6swrKb3+ZIXFcQiV/6LAmEjeu4j/r yW9P/+eu95VubXfeTmRWuqqWh3V6JiXr5Bn/LNGZP8fKjEiFpUpsNk0xl5wJhejAMUUw 5JpbRNVE1oxFoM6V3T7CHLaoJ8Mt13iP76g1jqDgb+5AAQawtoafZ1ba2/IkS404ji6F W0ag== 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=BaTL83jvOXSdWoI1dTPwX0aZv+Y/Ov8YWzEfe+v8ktE=; b=QIHrQqjtrgs2qCJnoHd3UgETUbAMd7rauv/1E7iZIiNZQUWKAI+gMElxHVJI+uKyff d8o98ODQTmU2TZqn+5Rrt26ba50c7xR0c3nanBDFOD1mL7OlfYljiHe4N7QET8PZ3lqS ScNPWlkaF3VdlzZ6o/nBkGzkvbtPHCrzFFce2hcdo1lD248jXx2w3lAU/N3ILOEDWTRI xxvBZGYzxStPYA/3OkaFD4FhiAI0md48r8SdI/bP3mkpaP6BVGi9Ob44VFpTy1FkmzPk rhVIRiWJYWax8kQOyrym8NA7jS673Z0uB2RylN4K8zxnA58bSu3v4hD7PJsOM6XN306+ baqA== X-Gm-Message-State: AOAM530H9ObPb/oR09R4q3tG1RBQdzCC24bke7N7/kzaAPur4Tl2wqmv 0BGu82Vb7gaMLMM/Jibb5kFLcyFQ5aD+9A== X-Google-Smtp-Source: ABdhPJyo0V/FPlJymnxXWo6bidv96c0plXA5tRbrV7tM+tHpWe99j4SPt8PxY7dpF6xcTSpXxhyMmQ== X-Received: by 2002:a05:6000:1843:: with SMTP id c3mr42964007wri.301.1625842712721; Fri, 09 Jul 2021 07:58:32 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:32 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:21 +0100 Message-Id: <20210709145825.2943443-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- 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..7bb8852375bd 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 9 14:58:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12888 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 605FBBD794 for ; Fri, 9 Jul 2021 14:58:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14F6668539; Fri, 9 Jul 2021 16:58:37 +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="MJyovD9h"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 03E616851D for ; Fri, 9 Jul 2021 16:58:34 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id v5so12553317wrt.3 for ; Fri, 09 Jul 2021 07:58:34 -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=ypB7ftg8zDueJJ6fwvcqa12JR5INT0ou4cXYJuiy1Qg=; b=MJyovD9h7cW3YlAqiLtCBUpW1S4VDmm2jhKYVuvBpBUmDliF+AIHRPx8uNd5ep+qvi aFVg8HC6z7bzsXjNDB41OCxoqZs7G+bPlPm82biXgdUGUVhkGRY7/s1uFeO5UUsMiTB0 XQet285wxMFaEv4GPa729q125CAuvIKIOztMekkz4WKs4rDLvORBsmUaLJiaAMkFzQEq UW3PAqP+Am428eptb/0h2gcyrUe5GpJwkPpkx8dwXmpq8OzvRGaUxDwj5M+GhT92z4XD FqqY2fHlx2A6xijcbO2h1agECkz8IRrziiu5ptfg6pOwuE+vsjLqE7sM8V1tFxkM7dW0 jNNQ== 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=ypB7ftg8zDueJJ6fwvcqa12JR5INT0ou4cXYJuiy1Qg=; b=UAv9nzod+ddGdliFNHeUeGKrj/ehTGaBfRnzJj2FpcnbxK/V4r6OQasD9lCg6HkA1K +MhZmHvh8SKjoY0aADW0VGY1dMLIP3JughYOtbeEskqB1y8eG8fsjZdRHk9+JiD2MzK1 LkvB1fLqUgg3mVcwkBOcuFWiOEQFjGgIafzyM0mU1SIAdbzviNt2kNvlqjvQto/8fIOg iLTJjblofrJ5Tm6lM0XYebD6/LoVOM20wPOSRsVwFENcKppNVl3+/grBwUZ+4gWHo1TW Rfxp0ztkgXOegJDgHaFjbvGA9utkS8BC7vjcsX7JJho50KDlcuh7btdapPPscp7LpThn G3gA== X-Gm-Message-State: AOAM5328VyLVJ1pBL+4TqXBQ8QiTYNT+7BudtqFeoTHc2zSsspvhL8dJ CkpKF90RCVuTTtGd0t2hR70arzFt2bpSwg== X-Google-Smtp-Source: ABdhPJz8ByNG0a581ByD5/vz0AwrnLA37p6wwFBIdc4JTCGYPLQ664+ziUI1cQAgwBDrEyCtp90nBQ== X-Received: by 2002:adf:d1e6:: with SMTP id g6mr31186978wrd.140.1625842713473; Fri, 09 Jul 2021 07:58:33 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:32 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:22 +0100 Message-Id: <20210709145825.2943443-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper_imx477.cpp | 86 +++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 91d05d9226ff..338fdc0c416a 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,76 @@ 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; + + if (metadata.Get("device.status", deviceStatus)) { + LOG(IPARPI, Error) << "DeviceStatus not found from DelayedControls"; + return; + } + + parseEmbeddedData(buffer, metadata); + + /* + * 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 parsedDeviceStatus; + + metadata.Get("device.status", parsedDeviceStatus); + 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 Fri Jul 9 14:58:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12889 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 D72F5C3225 for ; Fri, 9 Jul 2021 14:58:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8919A68526; Fri, 9 Jul 2021 16:58:37 +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="XYQdrjXj"; 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 E010F68535 for ; Fri, 9 Jul 2021 16:58:34 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id j34so6494361wms.5 for ; Fri, 09 Jul 2021 07:58:34 -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=9Qm+sWatsYcAykyKyO/dDov0LMdnllNiYyhQV+ZFn1Y=; b=XYQdrjXjjn3mPM9gRuElruCgIgrqsGQ5cA4rab1CneXJgIey3sheJ5imy4jaJgDttR Im6GlufnmaA4cI+1+QjNtimoIZTgu5nYU3GqHfvUSDjWaUqkHtW8z5JhLCOqZrOiEp0O EaANmzxAzVa83RIYPnq8CEJ2XTZ1k+tTqn3aZKtF7Dl7mxBmb/5Rxb+FaXlL6Te7J0gO rU4eQqYsCdtOPvWqpvWH65Vt1WE0kKEBI143br2fhM2g4HywAe2nBHTSD4ZBUQF+Zavj d4NzEKDAor3AetQAAJpNlt4OvMczVwrf+YrIUkFbPPiAVLa1eS2VRTzGajTKiXxyVvvj fPKQ== 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=9Qm+sWatsYcAykyKyO/dDov0LMdnllNiYyhQV+ZFn1Y=; b=dZapRvSNizHP1vmMOVd1+dh/4tyPKNpPtLhD8ubayTK2gCrgjZzXFulGwBRtwVjBeR ZaZyRQk5YTG1imCVO/wwhEcBLYOeqrzIewUgbF3ltwI4ZwLJjDhrJdEr0NcPseJFuZet IwoHvohkMeu/M8k8j68tphUmZmyUi4VKZhJwDcy4mvhnWudPNHW0jJq8yCLgkcBy6sNJ q/cKMWqj8v16ZfX4/aH+tmWynM8ltdg9VZEMA5nCkggKq92EYc96MpSat7yFixnWd+YF L1t64xZwWJ6w7hFPsdBOpD9KRbJa2NngEy5cC8y8FrI45mk4X1Y2h+rPWdPqzmJC6DuU cs3Q== X-Gm-Message-State: AOAM533RTOEk3L11ypWGeWp92RXI0nQ+BqqEO5/pGmIdd0ActAtSQOQj Y0ug4AnUKT8PHkuGhOausSEVxRxL4VbaKA== X-Google-Smtp-Source: ABdhPJwFZA37iad30KWK6c5GGIGaX941dZQso5vdiJC220HfgK+5zRZgCytNpNPpX22WaWzx9cskag== X-Received: by 2002:a05:600c:a04:: with SMTP id z4mr39782773wmp.103.1625842714366; Fri, 09 Jul 2021 07:58:34 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:33 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:23 +0100 Message-Id: <20210709145825.2943443-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 082eb1ee1c23..e09328ffa0bc 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,28 @@ 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. + * + * As a consequence of the below logic, VBLANK gets set twice, and we + * rely on the v4l2 framework to not pass the second control set to the + * driver as the actual control value has not changed. + */ + 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 9 14:58:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12890 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 7930DBD794 for ; Fri, 9 Jul 2021 14:58:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2D9DB6853C; Fri, 9 Jul 2021 16:58:38 +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="poT/256K"; dkim-atps=neutral Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 946AA68528 for ; Fri, 9 Jul 2021 16:58:35 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id p8so12578343wrr.1 for ; Fri, 09 Jul 2021 07:58:35 -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=yhs6kXrpMLkUCrWwNn5w5AdUxztG6BvQZehEvpCQvQs=; b=poT/256KIbfL1bioYhoM8iQOfKVWcy7FUiiF4G3DWbWVgATg5qQOAnOoSBEUAWB4SD aBJlAOprv9c+iXfnGJYXt7qnGOqV9w9vXhr1sAfOrfAGriPMKE2msTPwIP/Cimr79oLt ZnGNvlvJbmDnRKZgN7cXFOpRA55OqcSrQT10U8HvxtrUiwAKIG4xNeLO73wxIt/nzpIv uVsHlvthUM/WV0iZKPOkmqDAn53L0dBPYdJ0yGAHlU0aSVvyHoVJWXBvnH1vtzYAka7n mRrwMQqRiCwO3JXXTMnDV0OTxXXhFA32/Lj+sAAH9PgUxRrGdK4JXVEI/B/KOm3W9j7u XlQg== 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=yhs6kXrpMLkUCrWwNn5w5AdUxztG6BvQZehEvpCQvQs=; b=mnmTuY+3/LKas+3Z39/zyn7wPHV4HNu0Ey8dwnrCgIzjGV/4baGgWhOYMo8sodsuqd 7yV8GHN5jjEkxFKcEBKaeXRTsYxD+EjBIXTtoZUaEJgHKDkvvxZFdjhqVZ2uX5gLps96 psPS/pQd1XYdEW5w8AtDtUWgkqBi2lIMppAUZ0zRBOW54/3EJpP8tNtERUmHnPXJP19V cayY8VFv8i490B/E10ozS3pvjxtiKV1G/+rME4uocKPvBwgLkDQ6RuU6F29aUjfIQmih gqoVoOYAfA2+trpB6vQiGevbHBGk0ls0FFhECgWdAe9+F+5zhxZSfMyitOusCl5DfQzg Oc2w== X-Gm-Message-State: AOAM532+Qd8aNoAy9ipQMn2ZlGSM35RS+Mq5hxBx3qmjtwZ9IXYLhAZ3 xXRNB3etwrehu8XVIdS5qIenvi/0aNtc9Q== X-Google-Smtp-Source: ABdhPJwtBBbYm3CgnfLicwUPZ2xlFTaMSY7DIT2/St7hFhvmTlZ2e+c9R8bE+5GKP3weS9fmtkoeoA== X-Received: by 2002:a5d:6506:: with SMTP id x6mr11328272wru.86.1625842715154; Fri, 09 Jul 2021 07:58:35 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:34 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:24 +0100 Message-Id: <20210709145825.2943443-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- 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 9 14:58:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12891 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 1E07CC3226 for ; Fri, 9 Jul 2021 14:58:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5DFC68528; Fri, 9 Jul 2021 16:58:38 +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="VVEq0Kl0"; 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 4C2B768528 for ; Fri, 9 Jul 2021 16:58:36 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id g16so2638698wrw.5 for ; Fri, 09 Jul 2021 07:58:36 -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=+/4A6ABHPnLQLSLzSzJ8J1XyM12VeDFiiq0NwDb/Dis=; b=VVEq0Kl035cb/PKDl95rMiTcUW5hOukS7fXRNzN2kyY8If6rkWT0WABNw10nIysNSl qvokmwzEpKumo2TfzzsAjV5ulo7fLcCipRnzhftOpUgdU1O+xugUqTVD67GQ3SL4vqqT 35iOI1+1+zbqrPNP5EKSHAd3fyqgvjQvLLR/axkR64/2aZCxC3W/VkOpuQduu9U5zo9T XnYdJk6mpcg8plIB7mLqZRioo8kz+qQ3ZtxITBxO9mU9bca7Gek0MFnoxssik4zofByB Rm600ZORmdIw7J72cXI5vsJIr41og6C6nA3RQ+eOrKLOjuAezp/GW8e9kM69fkWfiHTN HcjA== 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=+/4A6ABHPnLQLSLzSzJ8J1XyM12VeDFiiq0NwDb/Dis=; b=NiGh16yXrKwAXlKF9r4xXQI41qL5/t1SQHKTtFQYgTCiSVPDj8xt4uX2GGBa8zRKVb YkIScXREL8creW+kWK1Di1fdUE33lQmGJnRZzO2tkeai7e5pOgNimDduCN8PmTxYuYhk 5sBge2g7YDpBSDCD1Vr4pp6yfPGRXqT04+tRElyO42oUgv1Uuo06SuFp3I9+D+WwIbBA UFE33iXccfGrUIVNyzweVULgM/ZOSdLl6vyD8FH+dQ1/UvrVB3g8oi0LNUyboZh9e94f tz0CAgdLssjMdJiheuwKB+BPm607wE8Z58d2JoRn90/Od+X5s5OQIDi/urSE8hMQWqnd S8tA== X-Gm-Message-State: AOAM532M2ev3CDZC5s/OtPjHa74bpa4i5vePPRLvoovWbMWKK9jC6v3F 9xXWhmjnpUuQB1rsyOcLPvkLI7+lQFgVtQ== X-Google-Smtp-Source: ABdhPJzblk4kkFk0g2Ovg2fiFCSm37oEyMuyM9TS0Mds++Hke4n+ua5I+o9WNreH8KAKOiV5yqV9ng== X-Received: by 2002:a5d:56d0:: with SMTP id m16mr42688149wrw.26.1625842715818; Fri, 09 Jul 2021 07:58:35 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id c2sm1480995wrn.28.2021.07.09.07.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 07:58:35 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 15:58:25 +0100 Message-Id: <20210709145825.2943443-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709145825.2943443-1-naush@raspberrypi.com> References: <20210709145825.2943443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- 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);