From patchwork Tue Apr 27 13:08:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12119 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 3B652BDE3B for ; Tue, 27 Apr 2021 13:08:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F19D0688B6; Tue, 27 Apr 2021 15:08: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="WOu9A4j6"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87517602C2 for ; Tue, 27 Apr 2021 15:08:50 +0200 (CEST) Received: by mail-wm1-x332.google.com with SMTP id n84so4602035wma.0 for ; Tue, 27 Apr 2021 06:08: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=wG9J5D/wwMDG87CUQxw2d46l59UXBc9BQI+/bLGXxxo=; b=WOu9A4j6OvJ9gO9ZwfZCEjEu4wqabTRyX6AfP8KOn7S32W+PM2ZxVPLLk4V4TUwNKv XM60dUxEMEYqixaQm0Du/V1g9KzMuBDBfgkNhDTMIa10d5XAithhdakq8xeDplRBv4BY b4ZzU9D/tgMKP6Pl2bxc593Oqz3qUa7/g/pgLz78SCNlIt5FblNQWVizOXaKymZ1LrIX mxcJrMsO8G6xaYfjJenr6xqE/0kc+MWpwnBopDdvTxShkWzTo4kEvUpIXXuvGyqBYaeu qTLIy2HFP1byAPbA8BNiem43r7xSGeGq8TK1kKgGzcIuFGA9wpvOT65S5sUcTqDkcCcQ FF3g== 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=wG9J5D/wwMDG87CUQxw2d46l59UXBc9BQI+/bLGXxxo=; b=kP/gzQnirCKnpUsEVLYp4EPHE1iRbOtpt5s9kIBizRYVwvP4v1Ba/jzXDhmJR06g41 vm+gqRK3086z3qNyfFLFmkhc8Xsa3hKrCerVOZVk2e/Axt4hsqEUYw/s5fkpSq1Q7Ok/ 0g8RhD55tJ2f1BXipgb12pfDuZbTQqQooDn4cvJ1e4W92wn2lrshkaP5j5vop05NcWPE V2H7fRKys8K1RrNVhWJytz/Z/h+Za4pOLt9fXoagpaBx3b+fAS2DNr/EVdY3onNYfraZ zCEhDhawFlldfqxJgkfz0xkZXjkKJ5LQw4r4xDVQI2WzJrHsMakH0CFCY+vwoC5z8+d/ jkWQ== X-Gm-Message-State: AOAM530FtuojgIyWWDGV4Up9rSQxRfBb0WdrYkYWZaRkIX/RoRe2tmSU GTr9Z3LOxJYCVojxtaQywlr+rTZvOWnAuw== X-Google-Smtp-Source: ABdhPJyvWoYxEKdF0H0BI75F493KRnADzjRWZznZXbQq8g46cvG7owDA6kgf3bBT+dFota2bL5n8QQ== X-Received: by 2002:a05:600c:4e93:: with SMTP id f19mr24479679wmq.122.1619528930103; Tue, 27 Apr 2021 06:08:50 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id r11sm3899327wrx.22.2021.04.27.06.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:08:49 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Apr 2021 14:08:41 +0100 Message-Id: <20210427130844.11357-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427130844.11357-1-david.plowman@raspberrypi.com> References: <20210427130844.11357-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/4] ipa: raspberrypi: Make CamHelper exposure methods virtual 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 allows derived classes to override them if they have any special behaviours to implement. For instance if a particular camera mode produces a different signal level to other modes, you might choose to address that in the gain or exposure methods. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/cam_helper.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index c3ed5362..618391e9 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -66,8 +66,8 @@ public: virtual ~CamHelper(); void SetCameraMode(const CameraMode &mode); MdParser &Parser() const { return *parser_; } - uint32_t ExposureLines(double exposure_us) const; - double Exposure(uint32_t exposure_lines) const; // in us + virtual uint32_t ExposureLines(double exposure_us) const; + virtual double Exposure(uint32_t exposure_lines) const; // in us virtual uint32_t GetVBlanking(double &exposure_us, double minFrameDuration, double maxFrameDuration) const; virtual uint32_t GainCode(double gain) const = 0; From patchwork Tue Apr 27 13:08:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12120 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 425F3BDE3B for ; Tue, 27 Apr 2021 13:08:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D6287688B9; Tue, 27 Apr 2021 15:08: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="iyJv5dZs"; 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 3061E6885A for ; Tue, 27 Apr 2021 15:08:51 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id n84so4602053wma.0 for ; Tue, 27 Apr 2021 06:08: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=ohoT8WuC7h9DgVwzv9RJ54NlPOfdOQJQOBKorFlaCo8=; b=iyJv5dZsf7xvnAEpJbY2culjxCw4oeoXE/tA2/D1DEKOje6FJu01uF/+6SP5O5YFky Uj4dzwaMU4hWNWm3lS0QB5r9ioTAnmnFKF9TAyloQSxYwb34bBWzKcm25823mpFi49kd jihIW3x9viWGd4cks+4GwfQe9zmBFCZiCI3G77U2msKg947N0ERRLM54z3vdblHHiVoj stYvLGvT1xx8kEBfGRRjXB3CegKyFJAYevBvufwdr8qrzenIOWJf5QR/RelZq7ZZ+GEa OhqBlOADlvTOx2hebbXYofe+7PdswnRioYea8hRYoQ+oG1FZjCMbROho5G8aAiyUzpii pvHg== 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=ohoT8WuC7h9DgVwzv9RJ54NlPOfdOQJQOBKorFlaCo8=; b=WoX1gFYdQ733l1MGd357w0cLcAevtsj0spx2ajYmCj43xRAicNezhDPkmgdPIkYn9a M9Sa78WUt6lb5CdzWc+j614Xct2R3s0iaaqjy3AoceoYDqL+311Qj18uUf+KWgHfpvfs qB5a3Utz7aud60lnVv0mmzUnAgJEJQGP528zka73InBkpZdhC0v/lQCSle3Rnf/qNz4e 1VprH+Na/mlQM8t3k+WDHpRXurIhHMVDSi7V810g5ZiNdjskcz8yePWNzNUjRb6cE0+q WCZo4B9uFLlky6Qikcz8wSLZE4nOSBovArtsH3Y7SuxTjRmSfTRUSrNwJJFH8UfeuVBh GSGQ== X-Gm-Message-State: AOAM530F+u7jmHprinCQbDuJHP8Pd1We3M23U4mpCp/d+Jm3hPO+1Iz6 6xWuRUF5oLylXBDhX+GA62OZ6LgyOtfqCA== X-Google-Smtp-Source: ABdhPJxaSvBMHPjbhnh8nAB8Y4adoDQzua+cirvZqrARaQnuuXcziV81ZFh7wowQ82MP9eXmC9oTaA== X-Received: by 2002:a1c:7209:: with SMTP id n9mr5453501wmc.60.1619528930749; Tue, 27 Apr 2021 06:08:50 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id r11sm3899327wrx.22.2021.04.27.06.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:08:50 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Apr 2021 14:08:42 +0100 Message-Id: <20210427130844.11357-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427130844.11357-1-david.plowman@raspberrypi.com> References: <20210427130844.11357-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/4] ipa: raspberrypi: Add CamHelper::ColourGainCode method 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" Some sensors may require the V4L2_RED/BLUE_BALANCE to be set. These will require a ColourGainCode method in the CamHelper, analogous to the GainCode method, but which converts the red and blue gains to the codes that the driver will want. Most sensors don't require these values so it's helpful to provide a default method - noting that it should then never be called. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.cpp | 18 ++++++++++++++++++ src/ipa/raspberrypi/cam_helper.hpp | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 0ae0baa0..ad344d29 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -17,6 +17,11 @@ #include "md_parser.hpp" using namespace RPiController; +using namespace libcamera; + +namespace libcamera { +LOG_DECLARE_CATEGORY(IPARPI) +} static std::map cam_helpers; @@ -57,6 +62,19 @@ double CamHelper::Exposure(uint32_t exposure_lines) const return exposure_lines * mode_.line_length / 1000.0; } +uint32_t CamHelper::ColourGainCode([[maybe_unused]] double gain) const +{ + /* + * This is only used when the sensor has RED/BLUE_BALANCE controls. + * Most do not, so supplying a default is helpful - though no one + * should be calling it. + */ + LOG(IPARPI, Fatal) + << "Sensor is requesting RED/BLUE gains so a proper " + << "implementation of ColourGainCode must be provided"; + return 0; +} + uint32_t CamHelper::GetVBlanking(double &exposure, double minFrameDuration, double maxFrameDuration) const { diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 618391e9..8b8d1124 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -26,7 +26,8 @@ namespace RPiController { // // The ability to convert between number of lines of exposure and actual // exposure time, and to convert between the sensor's gain codes and actual -// gains. +// gains. Some sensors like to be told the colour (red and blue) gains, so +// there's a method for converting these to gain codes too. // // A method to return the number of frames of delay between updating exposure, // analogue gain and vblanking, and for the changes to take effect. For many @@ -72,6 +73,7 @@ public: double maxFrameDuration) const; virtual uint32_t GainCode(double gain) const = 0; virtual double Gain(uint32_t gain_code) const = 0; + virtual uint32_t ColourGainCode(double gain) const; virtual void GetDelays(int &exposure_delay, int &gain_delay, int &vblank_delay) const; virtual bool SensorEmbeddedDataPresent() const; From patchwork Tue Apr 27 13:08:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12121 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 41A72BDE3B for ; Tue, 27 Apr 2021 13:08:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C529D6885A; Tue, 27 Apr 2021 15:08: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="mieJF4K3"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD3A1688B4 for ; Tue, 27 Apr 2021 15:08:51 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id n2so6253603wrm.0 for ; Tue, 27 Apr 2021 06:08: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=lMKiEMNq5rniY5WVpexPk0iXE3oxK9Bmo7frnU7vnL0=; b=mieJF4K300ZGCUkYtE8XO/uMd47Bvg8HV6g863nL7Q3IqJHxHKzEPsJssJtHpIXTdP YZ1fnComzzbrKWIRHJYMbT9T/oepqTt0DNhIKie8wTTNt1+EXgcQUiM+8C8rKH7Hr6Au Ys8tizLfSna0PILL5dwUmgU1uTjZ3Rdln5CME9nHMPz//mdDvI+Lqn0kSLYY+h11DiXS WexazqOEb2d8NbmC4xupXTTqvJuG2piZhoNBxqJ4whBE7+4bVJ/nePz2H5FZyh5fnXDJ yB0KJWgjrhETGBuUw/dE7VBENQWUG2BC0IfuAyl5izuvWolLz6OtzB5pPL2zIRBtwfSL TVFg== 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=lMKiEMNq5rniY5WVpexPk0iXE3oxK9Bmo7frnU7vnL0=; b=m5/Sw4lN8/+RC+CfCblxb7Z4TfcofzFuZOAnwik0Q2BewTlDMkcOxxntwgWPNNAD1y hCG6HZFakrtsb0GsFcV2IjwY+O1RHARKBLGdMLMt/XSGE5PQj6BGJgbpqvSScPd4m5VC 7D3rh8jwCWd4vKIsYAqTc8c4nZRz519n9FNVCgqmYSE8N4UGcs4JdFDbLo0S4g9cSd/6 C8KtxzLjZvCuQEWf9vsXl3zqgRteRr5Z/Nv5Va0PajNEGSesLcZ54HstORO65nv3jsNR YRJ1JofuMWmKySpEZRs3JCbEQyn8AGBkw8+cQ0IEn+bMQy9BR390Ley5b63tml9CkRag QCig== X-Gm-Message-State: AOAM5335uhiQVUpdWF7zuLGgkU0li1U1w4YQdxaabXbXj05E1+5DtO6B hHNfm1i2jr4SCi6OVuGAjzphRyOs+Fcs6w== X-Google-Smtp-Source: ABdhPJxrfxJXIs5GeIQYMhE+y6Wfz4eSYlkkm+E3NMFLziaRjSUAJ2jgRE5CldyJhG65bnsas1vdOw== X-Received: by 2002:a05:6000:8b:: with SMTP id m11mr29160476wrx.224.1619528931337; Tue, 27 Apr 2021 06:08:51 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id r11sm3899327wrx.22.2021.04.27.06.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:08:50 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Apr 2021 14:08:43 +0100 Message-Id: <20210427130844.11357-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427130844.11357-1-david.plowman@raspberrypi.com> References: <20210427130844.11357-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/4] include: linux: Add V4L2_CID_NOTIFY_GAIN_XXX controls 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 the V4L2 controls V4L2_CID_NOTIFY_GAIN_RED V4L2_CID_NOTIFY_GAIN_GREENR V4L2_CID_NOTIFY_GAIN_BLUE V4L2_CID_NOTIFY_GAIN_GREENB In future some sensors may expose these controls when they want to be informed of the gains the downstream processing will apply, though the sensor will not apply the gains itself. Signed-off-by: David Plowman --- include/linux/v4l2-controls.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h index 59a57418..27079a6b 100644 --- a/include/linux/v4l2-controls.h +++ b/include/linux/v4l2-controls.h @@ -1109,6 +1109,10 @@ enum v4l2_jpeg_chroma_subsampling { #define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6) #define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7) #define V4L2_CID_UNIT_CELL_SIZE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8) +#define V4L2_CID_NOTIFY_GAIN_RED (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9) +#define V4L2_CID_NOTIFY_GAIN_GREENR (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 10) +#define V4L2_CID_NOTIFY_GAIN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 11) +#define V4L2_CID_NOTIFY_GAIN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12) /* Image processing controls */ From patchwork Tue Apr 27 13:08:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12122 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 17FAABDE3B for ; Tue, 27 Apr 2021 13:08:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C582B688BC; Tue, 27 Apr 2021 15:08:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iKk8ke3W"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52B89688B9 for ; Tue, 27 Apr 2021 15:08:52 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id i129so4829548wma.3 for ; Tue, 27 Apr 2021 06:08: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=SRcCNs41XyRBojY2uLGpAnfWWyGX6MGdxtj3SoKY7bA=; b=iKk8ke3W+gjuSdq7H1CVyIfROkXOgLIddT5vKbJI/V3lCg8a4s+FdX7O7aBCdXeqRc /3WfXAk7kHb61tzXjnvYT/h5e4oTfG6DjJjAHb8Kiag9y4PtYIAjOiDoRQ5/FCorHje7 82R94jWVskviwGqxkAN1osg+9IgftrbKgakb1kr0k+8yVvHs/WCwJoMIjqBVfJCu4DFD ZCY7TdkFeHMon9ytzdi/a8sP9Q/I7BgIGXthFohkzJ74o3tweNecDdDBkyRY8dSybADt ZdM77JD/Ev4wffuTVIUVeppTyC2v4Qefa/BuHgXnD+YsPx86lhvaB4dp4Vvv5K39SiFg QgKQ== 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=SRcCNs41XyRBojY2uLGpAnfWWyGX6MGdxtj3SoKY7bA=; b=GSlYSnSJyPOusYAR3+WL4MZp0Lr+1qbUIuYsJmBWeEzDC2fCm1fjkQAmXXRbggOzk9 CQzKWHN69jGCP6YMQVZxZu7GJyQ54yXcNzldGqq05V6iKpCy+JtOdOJdTE2HakeLwMD3 sU3v0OWzT3NTn+5LiMbRSUCyCUKexaFy7BGBkB/LFdSx2e6Ze5rfZqd7Em6JAh/uK7Oj hY4wx+dLMqtQ7riWoIIjndDSzh8Jb3/S5I2q0GDGqKYHJ1/hqf5tAo3WLE/rlukx7+Rw lRdw0LGHI7dGyL1yf1aGJ1D1s1dee0gUs3fU8Xj2ocMAMg/HJvNqtYhPPFIyjbDY3ka0 z1ag== X-Gm-Message-State: AOAM530Ud2jG5/Ky3N6t/93VQvyBzS9NOyTortd07YhVirhJ3PNPaRUE tgqlt6dvvw0/WCf5uXgcOeF4ipC8dHwALg== X-Google-Smtp-Source: ABdhPJy7DuZivxA2vMi8SNqnuqT8YrSLM3YU4YkP9FYXJpQoXNd2NGpUCoRnYrgQb4BCF9r500OWmA== X-Received: by 2002:a05:600c:4148:: with SMTP id h8mr4252934wmm.19.1619528931901; Tue, 27 Apr 2021 06:08:51 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id r11sm3899327wrx.22.2021.04.27.06.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:08:51 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Apr 2021 14:08:44 +0100 Message-Id: <20210427130844.11357-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427130844.11357-1-david.plowman@raspberrypi.com> References: <20210427130844.11357-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/4] ipa: raspberrypi: Update sensor's V4L2_CID_NOTIFY_GAIN_RED/BLUE controls when present 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" If the sensor exposes V4L2_CID_NOTIFY_GAIN_RED and V4L2_CID_NOTIFY_GAIN_BLUE controls, we pass it the colour gains. We want these to be applied as soon as possible so we add a new setSensorControls signal to the IPA which passes these back to the pipeline handler without using the DelayedControls mechanism. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 13 +++++++++++++ src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 42321bee..24015263 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -118,6 +118,7 @@ interface IPARPiEventInterface { statsMetadataComplete(uint32 bufferId, libcamera.ControlList controls); runIsp(uint32 bufferId); embeddedComplete(uint32 bufferId); + setSensorControls(libcamera.ControlList controls); setIspControls(libcamera.ControlList controls); setDelayedControls(libcamera.ControlList controls); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index dad6395f..f7d1aa0a 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1036,6 +1036,19 @@ void IPARPi::processStats(unsigned int bufferId) setDelayedControls.emit(ctrls); } + + struct AwbStatus awbStatus; + if (rpiMetadata_.Get("awb.status", awbStatus) == 0 && + sensorCtrls_.find(V4L2_CID_NOTIFY_GAIN_RED) != sensorCtrls_.end() && + sensorCtrls_.find(V4L2_CID_NOTIFY_GAIN_BLUE) != sensorCtrls_.end()) { + ControlList ctrls(sensorCtrls_); + ctrls.set(V4L2_CID_NOTIFY_GAIN_RED, + static_cast(helper_->ColourGainCode(awbStatus.gain_r))); + ctrls.set(V4L2_CID_NOTIFY_GAIN_BLUE, + static_cast(helper_->ColourGainCode(awbStatus.gain_b))); + + setSensorControls.emit(ctrls); + } } void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2a917455..054171d8 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -152,6 +152,7 @@ public: void statsMetadataComplete(uint32_t bufferId, const ControlList &controls); void runIsp(uint32_t bufferId); void embeddedComplete(uint32_t bufferId); + void setSensorControls(const ControlList &controls); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); @@ -1219,6 +1220,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) ipa_->statsMetadataComplete.connect(this, &RPiCameraData::statsMetadataComplete); ipa_->runIsp.connect(this, &RPiCameraData::runIsp); ipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete); + ipa_->setSensorControls.connect(this, &RPiCameraData::setSensorControls); ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); @@ -1361,6 +1363,14 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId) handleState(); } +void RPiCameraData::setSensorControls(const ControlList &controls) +{ + ControlList ctrls = controls; + + unicam_[Unicam::Image].dev()->setControls(&ctrls); + handleState(); +} + void RPiCameraData::setIspControls(const ControlList &controls) { ControlList ctrls = controls;