From patchwork Mon Jul 6 08:56:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 8647 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 5E32DBD792 for ; Mon, 6 Jul 2020 08:56:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2ACB660E05; Mon, 6 Jul 2020 10:56:42 +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="V2fBFJaY"; dkim-atps=neutral Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA0EF60E35 for ; Mon, 6 Jul 2020 10:56:39 +0200 (CEST) Received: by mail-wm1-x343.google.com with SMTP id j18so38381333wmi.3 for ; Mon, 06 Jul 2020 01:56:39 -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=qSV2uqoWNA3gnKhA2JBI5GAxVQ3yH469eK933yQUNrg=; b=V2fBFJaYqFlYeaj1+8IRDuS6D0cC8rFTKpQCWvSZdYd+FXC1vOHzdgEukEhrYHQLhG aym36yCzhxn411c5I0Dlbeu51zP8DCO6P/t82jeku2RrM2c+tYy33YNop687wbLplR0+ 4X/AF9Os7xIoJiKCSl8KUIYJI4WtWbD6CEaZ6JdkM70miL2E/hzCBNWKEiuYjVzgVHLr eWTrY/VoZ9RqT6hW7FbSolbEVXHmd5Ub04ACXJHe0LgB0K/VxAYInjQqpuFwCC6ukGWG iYc+kKmRgOHJJo7ShGqeDe7SES1vnZqTu5/pO4z3eUD8HuMCMFrjY/q5J0+G98EVRB6Z hJYg== 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=qSV2uqoWNA3gnKhA2JBI5GAxVQ3yH469eK933yQUNrg=; b=EZ/CDwOEHn+8+ReGjAn/ny0tVuPt4DCiqOYcQK0eSf0r1rmQG05bPt9biDUS+Db+V9 Z+bj5/+A3fx7N6vdSkyMX2yKwWXcALy6acc8Al/pgu/ZPosYB2hPb+d5S3vjtsOh3stL Qg3hWvdgkPphEjQ+WvZgw4GbBMkDTg12CB3mliq1HJvo/dJ4tjFgutQ6iyg94Pk4rnqR JP7rOsmaY/Og6GwOGodWJMJDZBLcUrHxHx7clhuugPiHwn6laYSXE/WYRafCYTTwdfc4 iPMxj45AoZfID/hcXt/55IlFb5iHr793C4QMXzRgAObYbsml9H4HvMvCEeAfvZXc6JM6 PeZg== X-Gm-Message-State: AOAM533qClQBUTrgqGJ1ApFecpWZDFbZXDV3rTiXc27hQtdflH0H8dxE g1H19WLm+Kh7OeLg+9x0J1paR5zqMDk= X-Google-Smtp-Source: ABdhPJzRKg3lWI6bQ9BnhkChyyMuoQojc7MKmejiz2mT/RhFQHU363ubuCUbAe0XxsibZkquAWEZBA== X-Received: by 2002:a1c:9a06:: with SMTP id c6mr9579150wme.23.1594025799335; Mon, 06 Jul 2020 01:56:39 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id k185sm22600282wmk.47.2020.07.06.01.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 01:56:38 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 6 Jul 2020 09:56:25 +0100 Message-Id: <20200706085625.1625432-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200706085625.1625432-1-naush@raspberrypi.com> References: <20200706085625.1625432-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] 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); + } } /*