From patchwork Tue Mar 15 17:53:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15454 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 00D96C3262 for ; Tue, 15 Mar 2022 17:53:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E63FB604DA; Tue, 15 Mar 2022 18:53:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647366836; bh=rHcFZzLLbiRXEO5UNZlK2Upbi+S11EVe2qeCnKUc9AY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=D4RWjG/QACA9Rz42vaU3Cr2LfFMfhIMcli6yb13Op9+5rEJcpXxTCrNy/CqMALya8 6zsCSWoBZMIf0ByaYpdN2pOqfzTUoeZvi6PW0Ql4eBuF2FenkzoH0hyvpziE+S/g+U VOh4CnUh037xdeK7JbrST//M3cTgse8k350HpTZlRXq6oN5/EqqobtZ+GjLo6jfRls bd7d58v7H1CUfXazGHIQrLQUaDILKAcDVFhPOMYMVv3fo7a47Gtk3T2LIMwHlb7FOY OGBm1uIV2Wcs/Sjf9PFs0CcKfplJav/fBbOnd425BjphE1KuK5HwMZPeJ5LasjLuJm /Jh9xLpedvCDA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0BA3C604DA for ; Tue, 15 Mar 2022 18:53:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NBQuLVtP"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A7C8F1C57; Tue, 15 Mar 2022 18:53:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1647366833; bh=rHcFZzLLbiRXEO5UNZlK2Upbi+S11EVe2qeCnKUc9AY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NBQuLVtPabSW+MBuxdNxo+rjrmkoiyK8WPJeNlEN0s4RSUesfdwP1Vfz0VehNOf66 yJB7mrQXAzxvSrdyW/YIUpsLiDTaSVvNeIJjflmzLLSsixRCGpfsXe/P0sx/L+b1nl a7Kx0nhhzAK6R0bBilaVAC64Hor1GnFiSDNsVtPo= To: libcamera devel Date: Tue, 15 Mar 2022 17:53:44 +0000 Message-Id: <20220315175345.479951-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220315175345.479951-1-kieran.bingham@ideasonboard.com> References: <20220315175345.479951-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] ipa: ipu3: af: Use geometry classes to perform grid centering 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use our geometry classes for Rectangle, Size and Point to identify the region of interest for the autofocus, and center it on the BDS output. This will facilitate custom ROI being passed in through controls at a later time. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/algorithms/af.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index 3cedf8cbd687..469762a29937 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -141,16 +141,24 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo) grid.block_height_log2 = kAfMinGridBlockHeight; grid.height_per_slice = kAfDefaultHeightPerSlice; - /* x_start and y start are default to BDS center */ - grid.x_start = (configInfo.bdsOutputSize.width / 2) - - (((grid.width << grid.block_width_log2) / 2)); - grid.y_start = (configInfo.bdsOutputSize.height / 2) - - (((grid.height << grid.block_height_log2) / 2)); + /* Position the AF grid in the center of the BDS output. */ + Rectangle bds(configInfo.bdsOutputSize); + Size gridSize(grid.width << grid.block_width_log2, + grid.height << grid.block_height_log2); + + /* + * \todo - Support request metadata + * - Set the ROI based on any input controls in the request + * - Return the AF ROI as metadata in the Request + * - Provide an alignedTo on a point, or Rectangle x,y position + */ + Rectangle roi = gridSize.centeredTo(bds.center()); + Point start = roi.topLeft(); /* x_start and y_start should be even */ - grid.x_start = (grid.x_start / 2) * 2; - grid.y_start = (grid.y_start / 2) * 2; - grid.y_start = grid.y_start | IPU3_UAPI_GRID_Y_START_EN; + grid.x_start = (start.x / 2) * 2; + grid.y_start = (start.y / 2) * 2; + grid.y_start |= IPU3_UAPI_GRID_Y_START_EN; /* Initial max focus step */ maxStep_ = kMaxFocusSteps;