From patchwork Fri Jun 26 10:25:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 8439 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 604C2C0109 for ; Fri, 26 Jun 2020 10:25:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1A863609DF; Fri, 26 Jun 2020 12:25: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="McLarQn+"; dkim-atps=neutral Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B9F9F609C9 for ; Fri, 26 Jun 2020 12:25:51 +0200 (CEST) Received: by mail-wm1-x341.google.com with SMTP id t194so8866375wmt.4 for ; Fri, 26 Jun 2020 03:25: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=ssrOPFUZVLpjswytpOgwcHjf0cjPo3Sc5g8pdExedpw=; b=McLarQn+MguUonMzzXQeNRIf8dU1OQFhpyWJgqOI+Kp7lWvEWdUUEg012Q95OWjsqY odhNYSfrYyP0IkwKQjlDCTFrgo/RlFa0fwI68FfFbGJ/b3mRcAChRYL6d4FwM55sgHST IeuuOh3IRlCdGeF/1ZJ03Lx5npBImC8bmbTD2Y4snPxa560nHtZuIIA0tiIRtQJouAXQ PmvK0hxPq45mnwHnHJpB1Bnx/hCdRRQ0MJKcgzWbynDdQSMvbDCKmFXs2eyAd/oWYBAY na5gdSln8Ax8H9213s2F1SClrusj4MKr6rzbgVhNf4zS04jAV3eA3F8S/6JzSu95Fy5u DnLQ== 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=ssrOPFUZVLpjswytpOgwcHjf0cjPo3Sc5g8pdExedpw=; b=sCqyk272VrEXApypOGMemC71o2r53mD3La5XJWp23RJj1rUwFLnXcZDle/i1NuldFq rhW2LvsrzkR9qqM5AKPZIx4lnmb0w3i8Bq5lK51KXLss0XpCKLnvQFVHsUyVf/wlAuyg L6NuH3jOz9TRZeIZZZ7wzF0a1cACTY5AzbzCNf4HubO5X5BvyRxavUKQsKtjwdGopWag W8frHaFLgSSzbbKEgyoTdfRqLvjqAd0NsxWi3Vh/3MIfPDL77FXbFEXjY3bW1uUJadli kxo7PSbm07KbXp9ZanQNPVUAUtw/h7DQD4+vSXRpjzKXZ+YIAllR2K2BId/1GiJTvy/g utmQ== X-Gm-Message-State: AOAM532iNwZ1Vy5kVyOmmS1l4JNadcTBshjezp2xLs4wlKinkZb1O6G4 WVoRxYVWteu/XhCl0V/trvV0Sx1Lio0= X-Google-Smtp-Source: ABdhPJyNLbclmQ41bWTCWFi2oNMOcLPzqLghWX27RGxEhzEGI0j1ImY9C0p5Wv9e1ENN1VSOdWGxeg== X-Received: by 2002:a1c:4185:: with SMTP id o127mr2639525wma.8.1593167148975; Fri, 26 Jun 2020 03:25:48 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id r8sm21959679wrp.40.2020.06.26.03.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 03:25:48 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Jun 2020 11:25:28 +0100 Message-Id: <20200626102531.1187650-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200626102531.1187650-1-naush@raspberrypi.com> References: <20200626102531.1187650-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] libcamera: controls: Add focus Figure of Merit (FoM) control 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" Provide a control to allow the IPA to return a FoM to indicate how in-focus a scene is. Note, this is not to be used as a means to implement a focus algorithm by the application, rather an indication of how in-focus a scene is. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/libcamera/control_ids.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 8c3e4c72..b46693ec 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -251,4 +251,15 @@ controls: higher than anyone could reasonably want. Negative values are not allowed. Note also that sharpening is not applied to raw streams. + + - FocusFoM: + type: int32_t + description: | + Reports a Figure of Merit (FoM) to indicate how in-focus the frame is. + A larger FocusFoM value indicates a more in-focus frame. This control + depends on the IPA to gather ISP statistics from the defined focus + region, and combine them in a suitable way to generate a FocusFoM value. + In this respect, it is not necessarily aimed a providing a way to + implement a focus algorithm by the application, rather an indication of + how in-focus a frame is. ... From patchwork Fri Jun 26 10:25:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 8437 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 55045C0109 for ; Fri, 26 Jun 2020 10:25:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA845609DB; Fri, 26 Jun 2020 12:25: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="h9eDaAw/"; dkim-atps=neutral Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7C5D8609A9 for ; Fri, 26 Jun 2020 12:25:50 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id o2so8877887wmh.2 for ; Fri, 26 Jun 2020 03:25: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=ilBGmf7qx8NW1qoO21eVpclfnAKNglXLHtwud2JRoF4=; b=h9eDaAw/MnuzcGpm0aCszMToLbDX1eQcGiiwDPjB+U+6PXOai5WIOkJPA+lywwA0tj 5A6NhQztsJF61J+DOyfTohfb07D/nimy+i9h7WA0RbziY70o6f+zefVkmRa6ld/v9Xvv df8IRG/XjKG8KQ3SQBEWa+BxC2IVfdxJ6wRwmEXK5mq86Jce9RWsah7A9UtDqLYCFBng dwgeOCVqhlXk7+K66O4V0RDx9/j9rpsgh6K/MQ9w2MPcsuR5JirxFDXbBfBf7lTabNfX YlbMQwu/HqM7yP9agHX5G1lb99oBDiVmGIM/o927DLnLrA/3fhrvK8RFsCgqpJvIQ5nF iApA== 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=ilBGmf7qx8NW1qoO21eVpclfnAKNglXLHtwud2JRoF4=; b=afWJXgwbpwtuq8MmuRalXlvBbq66Ik30GmHtPOfFEOEzc5VhN4njOW7432bX1lwxz7 zvs2w1lTRRLf7zu/UfMvD6NLfBHccnd2cZUx7zLRQ7mb+NlVkTkMxWVaKFRHvGitc4kG F2iZPZc2Cf7febfWDkpm5mEizn0S5Tf2dYScw9qy0Hwh3Xz5Dx4HEgxLljcV0OUHiQIE N52ugDsZR384zKz0DgP+U3ccyGiS/t1P+cuaAyMITWvICQh3ivt3wNkmDttoHFexff0A CmpqrrTAq69gUaug5RzO6YREI84WIkgKju7Glt3zy+3kXRTT/CR2aRX6sLSv2b+B+a6d TRVg== X-Gm-Message-State: AOAM531vakgdwPY30jVAa9dirWXksjg08vP/Het3prxdkd0DPgdV1vvA b4bSGwJ7FMvNWTggeakTibZwCcCkVCY= X-Google-Smtp-Source: ABdhPJwhXSEJHabddSRZ5ZmBP62GNWRjsb9LAvA3+ns1VrGQyAsYlW+uxI5r1bNlE/aInCGDtKH+/A== X-Received: by 2002:a05:600c:4109:: with SMTP id j9mr2536053wmi.157.1593167149979; Fri, 26 Jun 2020 03:25:49 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id r8sm21959679wrp.40.2020.06.26.03.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 03:25:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Jun 2020 11:25:29 +0100 Message-Id: <20200626102531.1187650-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200626102531.1187650-1-naush@raspberrypi.com> References: <20200626102531.1187650-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] libcamera: ipa: raspberrypi: focus: Fix for uninitialised variable 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" Coverity static analysis check was reporting print_ was not initialised before being used in process(). Add an explicit initialiser for print_ to the constructor. Reported-by: Coverity CID=293456 Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp index 1e2b6491..4028ba56 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp @@ -15,7 +15,7 @@ using namespace RPi; #define NAME "rpi.focus" Focus::Focus(Controller *controller) - : Algorithm(controller) + : Algorithm(controller), print_(false) { } From patchwork Fri Jun 26 10:25:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 8438 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 CE784C0109 for ; Fri, 26 Jun 2020 10:25:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E83D60A16; Fri, 26 Jun 2020 12:25: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="Hq/HsPmO"; dkim-atps=neutral Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82976609A3 for ; Fri, 26 Jun 2020 12:25:51 +0200 (CEST) Received: by mail-wm1-x344.google.com with SMTP id f18so8875719wml.3 for ; Fri, 26 Jun 2020 03:25: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=eZEWDXHM+h7IQM//ELYz7IfKEtPACsZQnbKSWEjmbjo=; b=Hq/HsPmOpn15458T1PsPdfAAXZPEQGUDILIoAwqnkUtKsZPBFkfeYfXhrqipCbgWR6 0ggdUd2HKFofxEdpEcfi3SiWl73nTszxH4LVhDu6lNOYmceiIBlNl0UxHFP8GfRn7vx1 GHtdmLR0LMUgvbJDoCgrsaMBoPn6ZbeZ9stqHVrZp+T0k3p/0YMG8xFZiQHfneDmwcye v3ieAu0aBlFk6le2ow0bNgc9EV8ukLqsaSSGP8/yN1eDqps6GQmjxNi+UBHD8mDmQ9E/ FqB7Z5yMY2smWE3tFF0NfZ0VdVq3oLfF5xY9tyJEzvu2PNx30o2PIOFnWOa5TMMqgCpQ 3mlA== 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=eZEWDXHM+h7IQM//ELYz7IfKEtPACsZQnbKSWEjmbjo=; b=Yyihp5n8+hn4y6kiLinM/uyMKQVxOHEJct4eoLxpTCR1y8asPInASsd2vp12eVmCt4 8SCVh+p9qjtpMWjKcJitGvLeMSVEDRGiKqyTsKoSmrUckAYuBzB2PIHsK/nmyIHUgtes iJf4GWvd1MhEq0+WHmkyuEsnrDnJwj9Tqj8TXX0yCnW+e0e4VyMwlYaOl2IlM6KMb7AS niTb7x6GY/I2YN/Z76u5UTadYcI3+wSBgsFDRXPrSX3twY/Z9dEREjKxE34HzDNFH6/l HbvAUlpKlcvlYxmTP/OM+KjMJBi0aCHK8MQsI7SzAVgJ/jrrldvnxDU9+nBfAB3Oxc5z V9pA== X-Gm-Message-State: AOAM531Y0GTGJPR7QIvcU1ynrD6TGmVERUFZeiapG6rhpe7zQJvmabz8 seIdw27WRbLHKclcvXUXSht9d0DSjlo= X-Google-Smtp-Source: ABdhPJzqZPIou70cnT5u2Nk7eD3GQWBV0RR/QRtEOEKQsUtnBxoCjqUFMKjkKZQ/sEh8FJJALFRKCg== X-Received: by 2002:a1c:2e58:: with SMTP id u85mr2585749wmu.123.1593167151016; Fri, 26 Jun 2020 03:25:51 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id r8sm21959679wrp.40.2020.06.26.03.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 03:25:50 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Jun 2020 11:25:30 +0100 Message-Id: <20200626102531.1187650-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200626102531.1187650-1-naush@raspberrypi.com> References: <20200626102531.1187650-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] libcamera: ipa: raspberrypi: Populate libcamera metadata after controller process 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" For control algorithms like focus, this is needed to return out the the current frame focus statistics. For other algorithms, there is no functional change. Signed-off-By: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/raspberrypi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bc89ab58..62730198 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -318,6 +318,8 @@ void IPARPi::processEvent(const IPAOperationData &event) if (frame_count_ > mistrust_count_) processStats(bufferId); + reportMetadata(); + IPAOperationData op; op.operation = RPI_IPA_ACTION_STATS_METADATA_COMPLETE; op.data = { bufferId & RPiIpaMask::ID }; @@ -336,7 +338,6 @@ void IPARPi::processEvent(const IPAOperationData &event) * they are "unreliable". */ prepareISP(embeddedbufferId); - reportMetadata(); /* Ready to push the input buffer into the ISP. */ IPAOperationData op; From patchwork Fri Jun 26 10:25:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 8440 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 E9AD8C0109 for ; Fri, 26 Jun 2020 10:25:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A9461609E1; Fri, 26 Jun 2020 12:25: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="pWYUEeuC"; dkim-atps=neutral Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6DEC609C3 for ; Fri, 26 Jun 2020 12:25:52 +0200 (CEST) Received: by mail-wm1-x342.google.com with SMTP id g75so8320443wme.5 for ; Fri, 26 Jun 2020 03:25: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=3RU7nfROHXCrdwxGepRolrIoDIpO0fD+jscobJR6rCE=; b=pWYUEeuCebhaEj8X4U9WqHl8ql4oI5ErgL878bARbQvDDefs8cUmItcFEaIK4jj+Lj kSXBEdkUn/bBbHcu1H5asOGobH8Yk0EN2QUFyWFriFnMJlogJQ1Q1j3vuoxZk/IQzlOZ X8GQsf3+71Uo/eIoO9ASDCcBkmHB11hBDDGoQLRJaR65WwCUV1j+Vl1U8v6A+D6uwpqv 1X3vaGplZh5h6XqLdzqYo5ht/Lk3ULbKGNU3Plj+xnsoIjGCGowsXABae/jW1A19pGqX ++It4Xgbcl2eUET465OBgGbrIZsY1LJlBqqkdnBYL7sOL4VkD++6MlgBTI6FIHseF+zF jjIQ== 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=3RU7nfROHXCrdwxGepRolrIoDIpO0fD+jscobJR6rCE=; b=pHfWrjxXMDCdPcd7mI9dT/RYNi7uInpRTFIiJnavzgxMt7jpA+XBjiP2at0helsMYz tcr+hl1rs/dpH4njvVi/O0+ijQ6W2qm9eNXW+n0pF/uqQBcTiuGZWZxH72VKKUwkwhCZ 9PyX9oeOl4ijwGhVqGMyjLprRkGHPV510H6kgusDJF9NXl+GffTnczyulZ00Azcl2jnE jt/hZwUF5gk3UowfPIDhU+8ozYcwVojv+9mLqO7olHw6VYX1uo+N75Ft5gWZqqPhNIJO n21Wnfrl6vmB51uR5aMsc/A7d+Za+NnJmmBYyoMZiF+pvdYl7eCD4RztO5fMG4P74vgo f5GQ== X-Gm-Message-State: AOAM5301J+47XI4lhiJDYIW1DCOt2YMSHLfbK9ybAhmfuCcTGZaz/eoi aLk1ujyzie2ZZ+XNxoAcprha8e336FU= X-Google-Smtp-Source: ABdhPJxOhVy3mTi9xOfQCDfhhiemLGeiK5dZTRGaMQusDbmjJS3drBSRN+OKJF/1jAVGsnVfV8dy0g== X-Received: by 2002:a1c:2044:: with SMTP id g65mr589495wmg.127.1593167152170; Fri, 26 Jun 2020 03:25:52 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id r8sm21959679wrp.40.2020.06.26.03.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 03:25:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Jun 2020 11:25:31 +0100 Message-Id: <20200626102531.1187650-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200626102531.1187650-1-naush@raspberrypi.com> References: <20200626102531.1187650-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] libcamera: ipa: raspberrypi: Populate focus FoM from the ISP statistics 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" Switch FocusStatus::num to unsigned int for convenience. Fill in libcamera::controls::FocusFoM with the average of the middle two regions (across a 4x3 grid) FoM statistics from the ISP. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/focus_status.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h index 3ad88777..ace2fe2c 100644 --- a/src/ipa/raspberrypi/controller/focus_status.h +++ b/src/ipa/raspberrypi/controller/focus_status.h @@ -17,7 +17,7 @@ extern "C" { #endif struct FocusStatus { - int num; + unsigned int num; uint32_t focus_measures[FOCUS_REGIONS]; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 62730198..b1f27861 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -42,6 +42,7 @@ #include "contrast_status.h" #include "controller.hpp" #include "dpc_status.h" +#include "focus_status.h" #include "geq_status.h" #include "lux_status.h" #include "metadata.hpp" @@ -405,6 +406,17 @@ void IPARPi::reportMetadata() static_cast(blackLevelStatus->black_level_g), static_cast(blackLevelStatus->black_level_g), static_cast(blackLevelStatus->black_level_b) }); + + FocusStatus *focusStatus = rpiMetadata_.GetLocked("focus.status"); + if (focusStatus && focusStatus->num == 12) { + /* + * We get a 4x3 grid of regions by default. Calculate the average + * FoM over the central two positions to give an overall scene FoM. + * This can change later if it is not deemed suitable. + */ + int32_t focusFoM = (focusStatus->focus_measures[5] + focusStatus->focus_measures[6]) / 2; + libcameraMetadata_.set(controls::FocusFoM, focusFoM); + } } /*