From patchwork Fri Jul 9 09:56:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12872 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 F3B6ABD794 for ; Fri, 9 Jul 2021 09:56:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2778468524; Fri, 9 Jul 2021 11:56:51 +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="NgHRY8Ki"; 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 776B9684F3 for ; Fri, 9 Jul 2021 11:56:49 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id m2so340643wrq.2 for ; Fri, 09 Jul 2021 02:56:49 -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:mime-version :content-transfer-encoding; bh=D3oFpFZ1p9wALh8EJbaFVtp6PZMGVEaHidSzqojaPWk=; b=NgHRY8KitMyYbpbIi8XJF8LYVbTwoKH4gJRZT6+X4QSc8hYncc7nbbiD0ywhX7jhvc NBS/cBaDP+rPGpM9fEJve8awsKD5p3Kq5flpNnxjoNN/YON3M+tg495OfYTRnLccMVCZ QEWDOz8Lc7beLsOIppD2vGbSHSHPNDmJuTNkFBoxjXVSUH3dUpODEdDNm6pLJnmtHOoC iSxq1wdoTmF3FRl2Qcd80j5IgoEASMpdG6vHYFOf7TvZdo8kC94iRPubUNTYqcbW2x3B barY32VLQ1dczRLTeVKNBJGuxt9WFNxyHw8aHj3MP7MhHpzLnSCySIPtyuEZ8kCWRRar XoAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=D3oFpFZ1p9wALh8EJbaFVtp6PZMGVEaHidSzqojaPWk=; b=PYNxUk9qFq6V3DzM4GWO8pEj8gnPkJstgU0wHlWQYZ1erQ2s2pOXcDznDXd22vuEh4 NbpwqVOqkfqnW36jiN4he8n7JvmJDr7vLZEpeZ+4qC4C/vZkR/aGDRFDoiHoCmI0/YBk hKMuHWaevvhcgvYyjHLvx4KIdhS329NvXWZQMxtnMxn/m2Xj5Or8OQvaP4qrZOkPDeoL qxLwEFZ71oY9KqfDvwT35AnvuP1sPEBpRqNit0W8aLmW9dbVwRzTjmKifIBxGTOVW9f+ NcYcp7WIUWX/Iy4NtfSnO4QLNfeV1bsUvB0ED1Ve/ENcrk8/0/IXu9nooRbFekjBbHMg uOBA== X-Gm-Message-State: AOAM530CYly9/NXC6/t8GhHXxftNeajFeAYQezITnsPoBmORJCOnGdQq soRv1AkdsD3kZOIShHcx1YuH2cdplWKjjw== X-Google-Smtp-Source: ABdhPJxWY0jlPQD5zdnL4RkHLyCj+Atst9N3qvHxsHuXxPgqYravg0NludQ7xMyfKAJ5dEaZk77y2w== X-Received: by 2002:a5d:64e4:: with SMTP id g4mr33690572wri.377.1625824608762; Fri, 09 Jul 2021 02:56:48 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:48 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:31 +0100 Message-Id: <20210709095638.2801713-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- .../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 09:56:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12873 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 0DCB2BD794 for ; Fri, 9 Jul 2021 09:56:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BEF7F6852A; Fri, 9 Jul 2021 11:56:51 +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="WqD6P+9r"; 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 05F44684F3 for ; Fri, 9 Jul 2021 11:56:50 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id i8so11321555wrp.12 for ; Fri, 09 Jul 2021 02:56:50 -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=WqD6P+9rdFO2LpCmSkvhWpOTht2iZz5JXTc/epY8xqvvqLP6r4IsZNH8sXXjVZpo6I Pht5kJjM+atmdWPND/x8YVzmcdLfrRfpfP28ZOLJvqSUQykYzyNA3X81YgAFLRhaTlal ELiLkEqE5bhr7efH0t0DFtyv43Xadyaj3vAY//sxRd4XsbOzM/a0H3+cVs7wtok3ItST MgnnzUXOvwQvPWUYVwJ8Z1m4aBKPPYWeosvPvUcMkxey3izHTNIjEIAIULbMBNr7UeYQ +ihAGkeIM0wmfcdL9WQCDRZm4NENcLmVD7JomPcFMK6ui9KHepJ0bQuxLa4uVXzutmFX 6Opw== 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=ObKzXRCU5/7czFu/qc2b6ah53Ypvsi+bu5N6bt8fU0ITED29uFYM1SQ5Lhhah2fBN/ Jii/Vd3+DN7sCnt71f7WuEs4Ljk8zQBAeK+Cz5tcXyTAE0K7JgJ5hm1Orn+b0lDl52JV iKDmoemYgg24ia8WZujI+ddlm+CYLbZoE2gm+2wO/dDFcuEpkcMp410uDjZVBOhlNy/f zzTKvisPQSlrkh6BEc9vsDB2a0W9EkTxOODtjEvVprOb4ZxGkX/cm3ih7g6N93g6OCAu 8y8fGCYOZTxO8H+VZHiwnAaVKn5eRVLu/FLdiS33mtxsOn4Q3VuV3/x+E71af34mtIzv LTfQ== X-Gm-Message-State: AOAM531eJzQnYVIxtO10xUH7/jUxPc/ahz/R5pRjDUzOMJBock+D6KBd PiEy7unkg1rdH3JxRmHkGswTy17XQq5jAg== X-Google-Smtp-Source: ABdhPJwdeg29lNFlpnrWm1tlcdT1mPs/Hm1e0tWL6RrR0lRX7KaLHsL107oEKu9jdtpOFfLaesFGeQ== X-Received: by 2002:a5d:4573:: with SMTP id a19mr3051548wrc.346.1625824609567; Fri, 09 Jul 2021 02:56:49 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:32 +0100 Message-Id: <20210709095638.2801713-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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 09:56:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12874 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 05733BD794 for ; Fri, 9 Jul 2021 09:56:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 126E96851D; Fri, 9 Jul 2021 11:56:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="oU0NyZni"; 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 C5DFF6851D for ; Fri, 9 Jul 2021 11:56:50 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id u8-20020a7bcb080000b02901e44e9caa2aso5895912wmj.4 for ; Fri, 09 Jul 2021 02:56:50 -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=oU0NyZniX+7/nmbMapveclodARBRnQA1NhlCdZ9ybse9SObF2RMlgmN5Q+H2LCsmRx DeGezZfXq4UmffqU1PEH1dZs6u9Auyblw6XLUFOck6Hlu9IYCEAbJMsREdE/AQyZ/uhO Ca8adFbc4JkOCnU/rJ8CvV7E+7xCYufTbHE/yXFfJIklNhJXyNOmX1z4tO68p3TPGzeG Is5v4hbsanE6fp5paGx1XNsB7o+2I9CJgDuHmaBN7cG8OmzSqronAYaed9zzmWlMTwOw sjGssYXOTTxwfYBwmmzomotLD3X99OyWg9RNQTAolev4UxZ1ZuDGME5RDLP7InLwCmoI kqoQ== 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=MPM9bSGavxzV81m8LLdQ5GniKJl4aGiASndykMz9x6tEH0FU4apqB3GnuGGQ6OGYHT JAaKJmFaa57Gdv3jX1TsMsZ2cuJYG1tBpa5L0r56aSEu+TfImOQREndVpwx9C7XRDYpc asO/mnyURpe9FWS9lknpDb+yQTszEE9X9y0UOOp0ZClqbLk+djLNOkA0DcdfYU5o6gro 71nKg5hx+v2eYM7Pftl0N/ljVrUWhgkejuNWd+uJ5zTVEWUixkY6cDOMZT4JHrcZWRj5 YaOvF++H+Aetoc9Uwc5BsDwNrOY6Q+0in6mEJwfiYO6BjBBLF8M4rjpErEWaYzlzlmQG +bjA== X-Gm-Message-State: AOAM531vnCt6qBmyph0SpkmVaYaxlVblL/1hkpnlAwtdCaGLY0JAvkXe Lrb5rJoGO9MtOHqbF9niWAf8s14a+5i/pw== X-Google-Smtp-Source: ABdhPJyKEL/SdkEx1GYR8Qko77UFTAMXJn/Hlj1uzz1qGwiq+k7OmQYU8EB+tQEFGR0AZR8W+vCG7Q== X-Received: by 2002:a05:600c:1546:: with SMTP id f6mr38419751wmg.164.1625824610231; Fri, 09 Jul 2021 02:56:50 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:33 +0100 Message-Id: <20210709095638.2801713-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/8] ipa: raspberrypi: Add an operator<< to struct DeviceStatus X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an operator<< overload to log all fields in DeviceStatus, and remove the manual logging statements in the IPA and CamHelper. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper.cpp | 5 +---- src/ipa/raspberrypi/controller/device_status.h | 15 +++++++++++++++ src/ipa/raspberrypi/raspberrypi.cpp | 5 +---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index e6d2258c66d7..1ec3f03e1aa3 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -188,10 +188,7 @@ void CamHelper::parseEmbeddedData(Span buffer, deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; - LOG(IPARPI, Debug) << "Metadata updated - Exposure : " - << deviceStatus.shutter_speed - << " Gain : " - << deviceStatus.analogue_gain; + LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; metadata.Set("device.status", deviceStatus); } diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index 73df7ce228dd..e2511d19b96d 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -6,6 +6,8 @@ */ #pragma once +#include + #include /* @@ -20,6 +22,19 @@ struct DeviceStatus { { } + friend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) + { + using namespace libcamera; /* for the Duration operator<< overload */ + + out << "Exposure: " << d.shutter_speed + << " Gain: " << d.analogue_gain + << " Aperture: " << d.aperture + << " Lens: " << d.lens_position + << " Flash: " << d.flash_intensity; + + return out; + } + /* time shutter is open */ libcamera::utils::Duration shutter_speed; double analogue_gain; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 4d09a84f6532..f51c970befb5 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1019,10 +1019,7 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) deviceStatus.shutter_speed = helper_->Exposure(exposureLines); deviceStatus.analogue_gain = helper_->Gain(gainCode); - LOG(IPARPI, Debug) << "Metadata - Exposure : " - << deviceStatus.shutter_speed - << " Gain : " - << deviceStatus.analogue_gain; + LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; rpiMetadata_.Set("device.status", deviceStatus); } From patchwork Fri Jul 9 09:56:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12875 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 ECCB2BD794 for ; Fri, 9 Jul 2021 09:56:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA96868523; Fri, 9 Jul 2021 11:56:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="aO5KNYtR"; 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 A84A868523 for ; Fri, 9 Jul 2021 11:56:51 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id i8so11321677wrp.12 for ; Fri, 09 Jul 2021 02:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SL2VE/oHSC2fXzf+qdGiYlkTgGyRfJpTg5+hSXVd9yw=; b=aO5KNYtRkrd0bUXwOAq/hAmwv4dUYGSglb6cWhyQdsyF+D3YymdAPr4L8AXV2XsGZn WlwcMCXA7ouGt7NuBsLyTHag+JHMATiH+j09Mu4zUMoxIQLcO+KoD4vNf/uuaWrgmtaZ RZj59YEk6HuXpafYNTH6TN6qwVF7dnnEXtAShningpNSSBJIi6Q+rrJ5Z5pNvvEIkjj4 aX4R/V1xSTJjmqH1j2SIRskwbFd8IlsVuaKJM82tXFkQxAk6r6vD/MwTi16zDtC2foUZ 5oFKq4eqNr5IcLgripLT/dpJ264O6arLZBJa8oQM8OZC++ofsLWddadR4cXMhDlqDB0i hV6g== 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=hlE3Ilc/k2/jJlxNaMovI2EJRIGLoAsEdjlU8GNHf1gGN9BFdCRuvITXr6+kzoTWEi T4ueYd7JV1fHs/yAYr0M30gdOvevHfJvNOrtB7IoveL+/dvWCzyM84CP8GZtQnreg2YD au03ydUmxWzErDk6sgxiubHshESu+B/Qd1AhTmh/EYJ22RzJPzroHipsbCQJuZyUGkr5 icG21mCutO9Btx7T5WXjIEfOEcs22ItvSMac6Vv7RgYUHDSZBLeJckLKgMNNqrPTqT6X XIEv+UR5rc+l8wWJ1PwjLHdcxtdXhdCJHoTghDZO1YQunCrXWgi4Hq/XWeAk7ut3kCbp e+3A== X-Gm-Message-State: AOAM530WFDNcEvNqQZc7Nf36U+iwlqr4ZfbphM+k+RXMg8t8hNiLPWMf oUTTooIS7JrDukeLdKOoh7IV0zUcJRxlPg== X-Google-Smtp-Source: ABdhPJzC+JZlWseELQNbe+RE0UYNqTkSVpVvMxrURV7cRl1ZKU3FsDQntdPNFB2gB4DlXl324cadHA== X-Received: by 2002:adf:c448:: with SMTP id a8mr20181620wrg.103.1625824610994; Fri, 09 Jul 2021 02:56:50 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:50 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:34 +0100 Message-Id: <20210709095638.2801713-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 when it's --- 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 Fri Jul 9 09:56:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12876 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 67F2BC3225 for ; Fri, 9 Jul 2021 09:56:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EFE1A68533; Fri, 9 Jul 2021 11:56:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="o62Af9ZR"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4EB1968531 for ; Fri, 9 Jul 2021 11:56:52 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id h18-20020a05600c3512b029020e4ceb9588so8703862wmq.5 for ; Fri, 09 Jul 2021 02:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=maS9Ine8zP34587cltgrRUI4ixqmUO8BFXsZOcr5y1k=; b=o62Af9ZREFIjmuVf6laLpdHc3rWx3AE4CyPIIRdphNdbjkefmsMw3zEaC2XgcXFTLj 3uAZ2jqVlBOpbV6Q04NMhOhCTuTj7y9SxKu/rK2aOHgcs48Hf5IyaUci5vEVysVk0CWz I5cL9R6EN+XhKE+4274lU5ufzFtyLpZzGFC3ndttY3CzkqDhI2Mz25D/UHQyYPae2/aC /xi3thK9tEuUui/kQlywiOWdx/xGKa8n79xPs0QmDu6soZ2LxZYiBqcVyUSv1VD/anUG ZdF0h61a4vE1C152HAXM8nojB0I0Z+vzIcoKqAM+lvOfiTB45Ze4qq+fo1uDBr5i9PFM 5EFA== 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=maS9Ine8zP34587cltgrRUI4ixqmUO8BFXsZOcr5y1k=; b=Rk5zR+pxQzDa3jMN27VgsVPhwvbB4zz2Ze8eOkkle2AnLJw15Ctyu6G7lq39pvpoxp AC3VGk/jNMOxMGxDeL+bbFuc2S/XO/XRNkbFQpd7mINz1Xm2aP4L84waerTnnyMdRuCG E6vSzNRugXIiDAmu4L6H8UWhk/xnB29YOdMP2aQMXxeyGG/2nPedTI+pD7vlHUDe+CZK qedQYiM2AvtYqxzy/gSZiiPT32MdV1Exv4UiruTO/XsTUkMiQLBkByBqnr2Hk7fwjjFo PV2OoyAm1DRWUMyTFQALIjxmVsDnmSP9qZp/F/UXFZ/kPj+CQtbJQZWKQkvuEf1FxTs/ kwOQ== X-Gm-Message-State: AOAM532/KMyeofpHB1yLSMBdyiYsI3KNtU0hNPwvjkxi8XLB6CxMqotn Nf0ySwvX8KOUjqpH4hPFY/V/VGutbPAqpg== X-Google-Smtp-Source: ABdhPJwufo8CLx+YDrtXHf+jqQLMCx44jJP181KBft+dx/Z7MULItf1QPX28QFJYW5mixpZpURQkTA== X-Received: by 2002:a1c:f312:: with SMTP id q18mr39256394wmq.12.1625824611743; Fri, 09 Jul 2021 02:56:51 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:35 +0100 Message-Id: <20210709095638.2801713-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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 09:56:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12877 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 C7CBAC3226 for ; Fri, 9 Jul 2021 09:56:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4590668538; Fri, 9 Jul 2021 11:56:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NTJOxwEN"; 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 F25AF6851F for ; Fri, 9 Jul 2021 11:56:52 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id f9so5689573wrq.11 for ; Fri, 09 Jul 2021 02:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/YpVJmsa5egcjdYPoaMhnVTpbUvYaQTLQzwcDmDF1BE=; b=NTJOxwENPK5DrYMdzsq70tIVH7ePQUBzMBBOOeaD+ydGSgxeGOBPrBJ3gXdVOgJ9Tt i5npVGHF6a7OR2/oOwGbcGz4y3JXKnnPFLLvu0N3IhWH3vGvJtDC2cnESJ8qycBb3mwd tp1TDSIrnduXHrj77mrh+7dIM0gB3+cdAF1lh1GiRzvD9b5JJ0kkIFDop7U77p22AjY+ EI8RbWIo32iaFM7zLdCDSHEfCzd4Sh1jk7xNXP5V0phkcDCcF6KD2JWMjUo2i60wGwRC gwh0oFGfT9xyOz9ev70e4wrblnIoJJtOzUe8Sc9cV60SV7sc9ZW+8kQAfnpoYRIIkVB9 7Rmw== 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=Hc9k2cYdMZDUhvyA58caFvFmNWbdU7rDgUt7MtXqJZwo8bdU9Mo2xRgBsyy8vRpAEF EvcAAg0D7TcKJLjX3pJhMbr7bRZ6NBt9KXkJMGHBtB4raMLEBWMDPtivSE12qFEy9iko tsK2jRUsIQdjILVE6NovZJPOiPy3Mtn6rRlvzgWkIogMXnLYXZeS2F+ZaM+DlmibHAn7 iWuCxdz0DXYI3r24WQdnGffyAsr65E8GX96CPp2PpVfUzUEsoOUKlOeOVEN2CeG7030F qEmr0mrGPjTidjymR2FI3IKWqbc19UfovnsfkaNem88fXmeNyGQbiqvoG31mzvdK01uw rBQg== X-Gm-Message-State: AOAM532kq4IIZ2K55atb6QOjJluFGgMt2LkqJuMnlEYBlCOleR7XqQyi jZ2iVuu0hQ0RgARy5k3XwOanniwmhUY= X-Google-Smtp-Source: ABdhPJzvQajxhPBSKV0XpKstJHknqNGbBsEo0OfV5o3+TiRHRsKKwUt2KhJEyUsAWeuyyL8N8/PMqw== X-Received: by 2002:a5d:6b8d:: with SMTP id n13mr10264865wrx.258.1625824612491; Fri, 09 Jul 2021 02:56:52 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:36 +0100 Message-Id: <20210709095638.2801713-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- .../pipeline/raspberrypi/raspberrypi.cpp | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 082eb1ee1c23..53a30cff1864 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -154,6 +154,7 @@ public: void embeddedComplete(uint32_t bufferId); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); + void setSensorControls(ControlList &controls); /* bufferComplete signal handlers. */ void unicamBufferDequeue(FrameBuffer *buffer); @@ -828,7 +829,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) /* Apply any gain/exposure settings that the IPA may have passed back. */ if (!startConfig.controls.empty()) - data->unicam_[Unicam::Image].dev()->setControls(&startConfig.controls); + data->setSensorControls(startConfig.controls); /* Configure the number of dropped frames required on startup. */ data->dropFrameCount_ = startConfig.dropFrameCount; @@ -1294,22 +1295,20 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - if (!controls.empty()) - unicam_[Unicam::Image].dev()->setControls(&controls); - /* * Configure the H/V flip controls based on the combination of * the sensor and user transform. */ if (supportsFlips_) { - ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); - ctrls.set(V4L2_CID_HFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); - ctrls.set(V4L2_CID_VFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); - unicam_[Unicam::Image].dev()->setControls(&ctrls); + controls.set(V4L2_CID_HFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); + controls.set(V4L2_CID_VFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); } + if (!controls.empty()) + setSensorControls(controls); + return 0; } @@ -1379,6 +1378,24 @@ void RPiCameraData::setDelayedControls(const ControlList &controls) handleState(); } +void RPiCameraData::setSensorControls(ControlList &controls) +{ + /* + * We need to ensure that if both VBLANK and EXPOSURE are present, the + * former must be written ahead of, and separately from EXPOSURE to avoid + * V4L2 rejecting the latter. This is identical to what DelayedControls + * does with the priority write flag. + */ + if (controls.contains(V4L2_CID_EXPOSURE) && controls.contains(V4L2_CID_VBLANK)) { + ControlList vblank_ctrl; + + vblank_ctrl.set(V4L2_CID_VBLANK, controls.get(V4L2_CID_VBLANK)); + unicam_[Unicam::Image].dev()->setControls(&vblank_ctrl); + } + + unicam_[Unicam::Image].dev()->setControls(&controls); +} + void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr; From patchwork Fri Jul 9 09:56:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12878 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 EE1D4BD794 for ; Fri, 9 Jul 2021 09:56:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C8B96852A; Fri, 9 Jul 2021 11:56:56 +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="EUzkfc35"; dkim-atps=neutral Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B624168528 for ; Fri, 9 Jul 2021 11:56:53 +0200 (CEST) Received: by mail-wr1-x42e.google.com with SMTP id p8so11398866wrr.1 for ; Fri, 09 Jul 2021 02:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SfuMa5x7O4APwHSjQfdP/GutwR5rv+4mkTECTMGoD48=; b=EUzkfc3589QO1u0ErX11oII8Fae2Y46BFE6KpDPswzq2oqnooXUH9t2SaljUraNYcn m3USOoxby0WbhOD8xmfrY1GAcF5rW2bzI/u+vysOWkwa8dl72IOiM8HFG7FQufknF5Y5 gpUo1FDtKljlbHcSfJwxVEBAmihK+SfCphL3fSP0zCHW0BNLME14Q3R8b/nvh7gy2ZXl oacFFD9jtfbURMekZa7H67mWrRBcRMoWM7QrqPBRuBfAYgiY+7t09Z5iKyPHWnl3Cf4k SnmwPRfmfJcecjt+OcrKqmioJxAYqRgTall6XOUpxCD6Jeuu8dtsQCxQZ2Oum48UUrO5 gv6g== 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=ookeMpwHj3+bicImWtv5icuY01aTSG5KwcYLRfb1n1SmIU9kCCsQMNgge/BpDTVEr8 Rq8/hqsf3RjQFZWNsqoSsn9mDrGtXmgHFIog2NkRYc1RNYXVNe69ilaubJcoVW5/1hcn JmHuNsVyq1//nB6kFAzcTkQ8oGKa3jPEatg4UAwpdnipPkp0NL/MdfbXGEgrYHE0HZsi CKJhQUOPTfjgJmnuSXDzJoKLhzSJkCqNb2hvJxnSHLR0Q/U0cMztNUG9I98x7UY7v3eh +0XG6hTPwKhQ9a2tx+RTp9V9+iYt9SIzlLdDHGUlRjFtAYtbgptwpB6vveVyB39yEoQ0 Bytg== X-Gm-Message-State: AOAM532vIQxqb1T8agzYzclghm1jmVaVPlO+zky8LY7G20v+9SHBKN1f zm2UMSaFYlKNwRnlszaXBBuTiRWfPYXenA== X-Google-Smtp-Source: ABdhPJwhnYDdIU4FbHJIRrKZ8ywa8XKfYI0hEQN7IxfCcgrXkHQEEQKtSu7la59tJG5kESCT10l2+w== X-Received: by 2002:adf:f949:: with SMTP id q9mr28850500wrr.178.1625824613262; Fri, 09 Jul 2021 02:56:53 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:52 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:37 +0100 Message-Id: <20210709095638.2801713-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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 09:56:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12879 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 55EC2BD794 for ; Fri, 9 Jul 2021 09:56:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0A1FC68526; Fri, 9 Jul 2021 11:56:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gqU6qDiR"; 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 875166851F for ; Fri, 9 Jul 2021 11:56:54 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id k4so5065026wrc.8 for ; Fri, 09 Jul 2021 02:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XRqliTz93DSGGSQlWnMS4j2UEugn1xX6LG8wnraWzSo=; b=gqU6qDiRISaxcYhJz97vNrv7uk2z+Ircv2wB+sLUYJcfwb92aTLX+I85lr+XWA+lIY N6z3f6wKi2ETJN0tZ/H4R6tK8V1XfEziMakzJjgNkOjQMTsCLzbPrvxU1IvEvtdehnbB xkJKr7xY1W12Nhphs79FwQxb9NMS05uIVPwBtEmpb3Q2Ll93q+lbTODjdruqveKMGC9n 0I8xlha828fJP2RIBlMoia04j3aNXAVvtgtuQylhOu04G11t5EeQ3c1k63AQte5hoPmU hFi1/gku8I1a9JWlSJRcZ8LAimMXW4eBbVvHlpkZuYq1ZYWD0YfCyu6owAE2siUtrS3U irww== 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=tDee+8ZS7FTpkSzluHFzSuZDdkzrSITBLV/4fdxG4qktjxS6Aod7fWARsje4IuoLHm 3LmiAA3bZds9ssNSWXeh7rQtvTY713MeiblBpOa95iKOAG1axkILORD0qjtfYMdPUmGA q1TkHWmxSL9SB/H0FtXoHHtdvnT3BeBwIjkWXr2CW34OThkVjn67g7OO85r+bwEoqrMY bp0Y0QXWVYTfEM9XU6hXYCmDev3YBx7OJWlP9jvZpVYFIO4RH9ITEeJKpr+tQ2hWta10 krBIZCcG/7KqFEo2DuCOIMhpeVQC93vJi+ZK7oUMENaV5GdnQ0KN5xNrqtLupVYs9qBb 4USw== X-Gm-Message-State: AOAM5315D88cppwzvfLe8gNU+1eYYfGGXrDLxMiOzq20cUOqZsAHmdRj KfDM88Gyc75l/aSPC1zKRY+Iv0URbrDm6g== X-Google-Smtp-Source: ABdhPJww0ry8sMh7P1mzcejttvoMqBNhidUdoK7OmcFOKYOg40HsqoMTnv6PNnsH2HA07sa5gAbarw== X-Received: by 2002:adf:f848:: with SMTP id d8mr33853855wrq.308.1625824614111; Fri, 09 Jul 2021 02:56:54 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:35c2:26d3:e217:4410]) by smtp.gmail.com with ESMTPSA id b16sm1599014wrw.46.2021.07.09.02.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 02:56:53 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Jul 2021 10:56:38 +0100 Message-Id: <20210709095638.2801713-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210709095638.2801713-1-naush@raspberrypi.com> References: <20210709095638.2801713-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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);