From patchwork Thu Jan 12 11:06:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 18101 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 86DCAC3240 for ; Thu, 12 Jan 2023 11:06:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA3E4625CF; Thu, 12 Jan 2023 12:06:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1673521598; bh=xPiopR120v4Z4oi1OyCyf0x0thBJ4Q7vzttadYgQdbQ=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=F8pySWYBApk0HaJ9zvXzR7rIWb6k83/Fo37H88B/zR2TNBT8k0jUPFRSEVpoWadUd dansUkQA6JTqk28lHzVIg3WpN9JGvnrPZfq3iOAGt9gcs5UKFDPMiqGA0x3mwgzwAf /mSvdy9uKFQVP+GO0qIlbonuiDAPMDinauWThotAALqkxurBVBagROlgLw4oAgsZ7G wzqUPeUHZEzOjDCP0T5wly/W19TU76RDv3IkXO3W/lvKcL8pF0bKj9D/YnKwV2/JbJ aTSGvoJZWEuf7XkvHVPyHePFv+c97FjwVLg0/vig7fhwhO7AzBTUihEHDHsc3ZXgSt GQdh0Sggxo7GQ== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E52361F05 for ; Thu, 12 Jan 2023 12:06:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="s9CFnLLi"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id i17-20020a05600c355100b003d99434b1cfso14735385wmq.1 for ; Thu, 12 Jan 2023 03:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FluAGgwqe2Ej6b0HtW8dFkRGtz9mtiy4vnrAJZlJU5I=; b=s9CFnLLi9CBKAj9Fhb179i5U0UlpWQX2q5///CrLnnB40l5CSTa17yLrMYyTsOIQxk TY3nhbqab+gMd4OC014SNaCdwl1l5/025pm7XO4Yh0SVo2JwvYoIZHIgQXQ9vdTJmyIV YKtiNjQ2bwBzcVjMCMBTkJkWhv3FW0WX2O+kTetZybaLVZLu2lYPg1YHit2f5bE+1XWn dE/kaHp3SRQZwxdHMs9e9UGBgRY78vFTjLhfxst5/V5cwtWeX7H4GEop027u83jeEPYz XrOnZJBFHEKOA7qO6sQju4oigiZRtEWJFTsomSDV3j3ebtig6yVYDc5P6X39Nd+hjQ4Y STeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FluAGgwqe2Ej6b0HtW8dFkRGtz9mtiy4vnrAJZlJU5I=; b=Wxdc5K5mpLNRaQ8muAMYMjF1U/QSYIZQrC9DoNN67fboYjtCKsmChoHBB34AzHF/7N cHKLY989UFwM4HLyffSlZYP6lq5yMaMJwjiiLw5y51VG2llp5aCrxWwA6QNpvZARw984 ckjRh5ClX4wg9BuKfm6Zn5VHIAsmfr4TGXtXcy+FbXnzIEMzeeph/A6cFlhwLUYr2/Bt 3VbfsiNvMByKIgtn0o4RogdLmjZVQb3Ea3p+oisG0W4UN+irISbYQK43cBuF6sCvDN+n gSA1sNMYAztfa7TS05jQx289BA8tlFZoUvYk2IWJyVI5K/JNGC0wS+Ko/hFCkDv6dn91 OT9Q== X-Gm-Message-State: AFqh2kryi0fyR3QKOurS6j/mAFiVTg2IYfZGMUbsGNAN1FuJG7Vzjm8a bN1D5efS+Hy2zt5mFmlVJfnOZ+54pGfPb+YZ X-Google-Smtp-Source: AMrXdXvML6oVWXJGj4zAfjUSS0X7CX8soeOH80N17VXnBX7uX6eUhrOTN2i2IRrUKuuA4xJLena9uw== X-Received: by 2002:a05:600c:34ce:b0:3cf:614e:b587 with SMTP id d14-20020a05600c34ce00b003cf614eb587mr58239064wmq.26.1673521595578; Thu, 12 Jan 2023 03:06:35 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:e4a2:3070:eea4:e434]) by smtp.gmail.com with ESMTPSA id f11-20020a05600c4e8b00b003d04e4ed873sm29841722wmq.22.2023.01.12.03.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 03:06:35 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Jan 2023 11:06:33 +0000 Message-Id: <20230112110633.25329-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: raspberrypi: Improve the values reported in the ScalerCrop 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: , X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Previously the x,y offsets in the min/max ScalerCrop control values were zero. Here we make them the same as the sensor's analogue crop offset which is I think less misleading. With this change, it also seems reasonable to advertise the default scaler crop value to be the true default that you will get. This makes it possible for applications to see what that value will be without having to start the camera and wait for frames. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8569df17..809af4d2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -905,6 +905,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) /* Adjust aspect ratio by providing crops on the input image. */ Size size = unicamFormat.size.boundedToAspectRatio(maxSize); Rectangle crop = size.centeredTo(Rectangle(unicamFormat.size).center()); + Rectangle defaultCrop = crop; data->ispCrop_ = crop; data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop); @@ -958,9 +959,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) ctrlMap.emplace(c.first, c.second); /* Add the ScalerCrop control limits based on the current mode. */ - Rectangle ispMinCrop(data->ispMinCropSize_); - ispMinCrop.scaleBy(data->sensorInfo_.analogCrop.size(), data->sensorInfo_.outputSize); - ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, Rectangle(data->sensorInfo_.analogCrop.size())); + Rectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->ispMinCropSize_)); + defaultCrop = data->scaleIspCrop(defaultCrop); + ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, defaultCrop); data->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap());