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); + } } /*