From patchwork Thu Aug 8 10:23:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20832 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 E7058C323E for ; Thu, 8 Aug 2024 10:23:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E506A633AC; Thu, 8 Aug 2024 12:23:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="lOSO9bNo"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D7E16337F for ; Thu, 8 Aug 2024 12:23:47 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-368712acb8dso447233f8f.2 for ; Thu, 08 Aug 2024 03:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112627; x=1723717427; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+/STe4ThVU9OKTfydcOuaJT8p+RpiuamPQ1PRGTFiSM=; b=lOSO9bNot3HWVatkkTg7LYpeoXZsEO3bz2is4znVz/GJUEeiiI3p7pl7hBSdUSdN3W Va1veh/vbonC/WSCndK9Jx4cabnJm8isKe/E5hwu7oj5lrWjVbVmg3tFuILK8E8HskdE tKqT4E49WprPnPGLGGbIC994Bv8TfH852FhsNH63xGMghZFXzUsT3WST7SN7WGSTBQL9 Q5RS1qx8nN+hKILGXAJlL2hggvWVaU/BHAn0kS5TxZ9TvW423cRzGCLV5M8RS1gNUspp K3JEjkTJPi0BhcYnEcMaLlWfkxNB+2Vt6RnAhs/LXEDptkuaoSpMF/XKi1EOnOkgNCJp pGAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112627; x=1723717427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+/STe4ThVU9OKTfydcOuaJT8p+RpiuamPQ1PRGTFiSM=; b=uLuis5+pwWJY4EgCS9L+AiMrQINVXqXazlxNYIIhb+OLRmrloEaWVNt3P6fWMrJc/0 tKucpjB+g9ECq2/78nu4bN0LV6LpDpSGd8AE0F6WTopP3Za4v9bUoid91wmOuSJhbVd1 /mAAXylftW3B/ZsA2sguGeISyieIZZaWKM0u4kepVkp8EIP+z6dVxG04qBztEsE4VyHp ZxOeuXBWBP5Xyc8eDoI3ZJ9QgD39aGVBVDfqFOmgiCiDgI/BPS0fiEl3WPsYBh6wpVXO dPWXWQWcmIc1LygzBQfNApPMOTrIbje1aLwh59YAxBH7WSMUZ/1/suoJAbDwjBxyJksB L40A== X-Gm-Message-State: AOJu0Yw9TX3/wx50gxTHQLwAG7wLtE23jZvpZBFlG67/4LZsFJ9NE+a+ Nid0g3SjtO/oanC4mJLX3rzv3xzM6NI8iWpxH2M1L/R5MONwiB0us0YIWqEHWcFuCQCg9x7vHhG K X-Google-Smtp-Source: AGHT+IFpg3HYxx1TrsdDAbcTzj3ebcwAhd9DhE9eERgd/zbIQ13zBmFgttBOPD+Bes63xI+BMLusxA== X-Received: by 2002:a5d:6e0c:0:b0:367:8847:5bf4 with SMTP id ffacd0b85a97d-36d273d43a2mr1099085f8f.10.1723112626577; Thu, 08 Aug 2024 03:23:46 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:46 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 1/7] controls: rpi: Add a vendor rpi::ScalerCrops control Date: Thu, 8 Aug 2024 11:23:40 +0100 Message-Id: <20240808102346.13065-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" Add a vendor control rpi::ScalerCrops that is analogous to the current core::ScalerCrop, but can apply a different crop to each configured stream. This control takes a span of Rectangle structures - the order of rectangles must match the order of streams configured by the application. Signed-off-by: Naushir Patuck --- src/ipa/rpi/common/ipa_base.cpp | 2 ++ src/libcamera/control_ids_rpi.yaml | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index ee3848b54f21..463f6d384c9e 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -71,6 +71,7 @@ const ControlInfoMap::Map ipaControls{ { &controls::HdrMode, ControlInfo(controls::HdrModeValues) }, { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, + { &controls::rpi::ScalerCrops, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurationLimits, ControlInfo(INT64_C(33333), INT64_C(120000)) }, { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, { &controls::rpi::StatsOutputEnable, ControlInfo(false, true, false) }, @@ -1070,6 +1071,7 @@ void IpaBase::applyControls(const ControlList &controls) break; } + case controls::rpi::SCALER_CROPS: case controls::SCALER_CROP: { /* We do nothing with this, but should avoid the warning below. */ break; diff --git a/src/libcamera/control_ids_rpi.yaml b/src/libcamera/control_ids_rpi.yaml index cb097f887e16..3d4a305dd8f5 100644 --- a/src/libcamera/control_ids_rpi.yaml +++ b/src/libcamera/control_ids_rpi.yaml @@ -26,4 +26,19 @@ controls: \sa StatsOutputEnable + - ScalerCrops: + type: Rectangle + size: [n] + description: | + An array of rectangles, where each singular value has identical functionality + to the ScalerCrop control. This control allows the Raspberry Pi pipeline + handler to control individual scaler crops per output stream. + + The order of rectangles passed into the control must match the order of + streams configured by the application. + + Note that using different crop rectangles for each output stream is only + applicable on the Pi5/PiSP platform. + + \sa ScalerCrop ... From patchwork Thu Aug 8 10:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20833 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 C6DE0C324E for ; Thu, 8 Aug 2024 10:23:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3E822633B1; Thu, 8 Aug 2024 12:23:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pnCrsCfo"; dkim-atps=neutral Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F22AF63382 for ; Thu, 8 Aug 2024 12:23:47 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-368380828d6so427060f8f.1 for ; Thu, 08 Aug 2024 03:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112627; x=1723717427; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8sYDQCCj57XZitX0+7BLhUA3FP4/j7VspqlO+P/HyUY=; b=pnCrsCfoMwdi4BiksWzLh3HmTvrvu61ap6MPixRnt1Iat5Azq3r4L9dVoXeFjGGTG/ EaejBs8+esGeCrgWbpAtslCW4e5lyfSOJjSAIW8sn24Ak5DiXg8+8MUtLOD4cVIOKJL0 Vfm789Omu9zLKhGy6Ek6bEk0s7m08C1oFKhmY8eW9xBvwwNsBsG3uM64C+Mafn6NEZ0O mDMpEuIXrdcKfxB7I8Asijcgt1GVSQ4YBP4i4reOMqQ1arcUIBrWgB8BJsXo7AegqjsZ okQAEX9b7B/Y2Q4cEMTGf4IIllpEkzIIwprCQcZUytSq56kiBREp4G1uJviUdPKDS9X3 Yjpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112627; x=1723717427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8sYDQCCj57XZitX0+7BLhUA3FP4/j7VspqlO+P/HyUY=; b=IfJU1WOxoONU2UOrM15M7HQopBKzpC9iqWduYRsF/cul2N4vkSCtVp5LGrbEh3OiE1 6tldT/e+L/5jFohn5KylTfdvJ6Vuv5SdgEi6bMQryCFMxGaOZsuv5VdxMz6HYPoKG3RF KHnDSynoBlEJXNVtP2cu/xcy5AIrui6rGvcBDhD2nr0xNvDNV3f78i9j77XvqNi57nAR qGhh+48nk9RcSK0WuXKkEZR0SN82B0VibP1sdzcFTYR/ypHuYqenTKiEObbq7s518qqn 6kp1kfJ5BkA9Hjz5vwqOMmU25I1nChh1QCYCZY7tRsOXjMLz0L0NNfWXh8JgfIUpEPSv 4HOQ== X-Gm-Message-State: AOJu0YxKMCR/XG+9TvffvRpyH2iK0p0WVu1BEjKVrWA/njE0hQVADLRE pSYcdahN3/zimUkPOr9tnfA/1f785fYLOR7ofj/K07Ais6aw07B2AdCkoiBH18kMApkLx3a7jRb i X-Google-Smtp-Source: AGHT+IHuzKcbdu+6yEQxqqSvyqM2vmBsibvD9At9FjqwgVKkEMETk8yCcbII2fgdlLYqBU9OHgHX5g== X-Received: by 2002:adf:ec85:0:b0:367:434f:ca9a with SMTP id ffacd0b85a97d-36d2728fea8mr882259f8f.0.1723112627142; Thu, 08 Aug 2024 03:23:47 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:46 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 2/7] pipeline: rpi: Remove CameraData::scalerCrop_ Date: Thu, 8 Aug 2024 11:23:41 +0100 Message-Id: <20240808102346.13065-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" Do not cache the scalerCrop_ parameter. The cached value is used to update the request metadata, but since this is not an expensive operation (and can only occur once per frame), caching it is of limited value. This will simplify logic in a future commit where we can specify a crop per-output stream. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- .../pipeline/rpi/common/pipeline_base.cpp | 17 +++-------------- .../pipeline/rpi/common/pipeline_base.h | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 3041fd1ed9fd..5322fd798a36 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -544,12 +544,6 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config) return ret; } - /* - * Set the scaler crop to the value we are using (scaled to native sensor - * coordinates). - */ - data->scalerCrop_ = data->scaleIspCrop(data->ispCrop_); - /* * Update the ScalerCropMaximum to the correct value for this camera mode. * For us, it's the same as the "analogue crop". @@ -569,7 +563,8 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config) /* Add the ScalerCrop control limits based on the current mode. */ Rectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->ispMinCropSize_)); - ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, data->scalerCrop_); + ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, + data->scaleIspCrop(data->ispCrop_)); data->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap()); @@ -1321,12 +1316,6 @@ void CameraData::applyScalerCrop(const ControlList &controls) ispCrop_ = ispCrop; platformSetIspCrop(); - /* - * Also update the ScalerCrop in the metadata with what we actually - * used. But we must first rescale that from ISP (camera mode) pixels - * back into sensor native pixels. - */ - scalerCrop_ = scaleIspCrop(ispCrop_); } } } @@ -1483,7 +1472,7 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request request->metadata().set(controls::SensorTimestamp, bufferControls.get(controls::SensorTimestamp).value_or(0)); - request->metadata().set(controls::ScalerCrop, scalerCrop_); + request->metadata().set(controls::ScalerCrop, scaleIspCrop(ispCrop_)); } } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index f9cecf70f179..5161c16e518f 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -134,7 +134,6 @@ public: /* For handling digital zoom. */ IPACameraSensorInfo sensorInfo_; Rectangle ispCrop_; /* crop in ISP (camera mode) pixels */ - Rectangle scalerCrop_; /* crop in sensor native pixels */ Size ispMinCropSize_; unsigned int dropFrameCount_; From patchwork Thu Aug 8 10:23:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20834 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 9BF68C32D5 for ; Thu, 8 Aug 2024 10:24:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 92362633C0; Thu, 8 Aug 2024 12:23:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AxbCVfw5"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8056B61955 for ; Thu, 8 Aug 2024 12:23:48 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3683f56b9bdso521333f8f.1 for ; Thu, 08 Aug 2024 03:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112628; x=1723717428; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Nb+gdwWarnJNCQUVUUakWYok4gsIJIituzonUdU6Ang=; b=AxbCVfw5bg1P3TZN4HC/YWHBPl3f66OQ4MluPEgE9TiL39C9dZB1KB1GmKQe5S1sEN MwPtq2hR4avpKvfmX0uGE/6aGR0t8YFng3PrXRSZwjMXKsSYPRaf+WJhdHc1idtLT5RB k8/AKxuK80eeb5rTYamW8tr0p3l9ju5LBtVuWkMkMmZlJqQoJWpd05GRXEJztqLqORHf ge86BPw648APjvLbXEWkMSQ6Z6Ijs8rrGeILLU0hFffFajiKuRSOBC5Agkmg1uDKL9Zz 98QYFa6EdxfZNqkulL0okSq49cB3FYfhYCgevLmOxdYZkK8JAA6yhWooZEQ091glre3j SmqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112628; x=1723717428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nb+gdwWarnJNCQUVUUakWYok4gsIJIituzonUdU6Ang=; b=lb97dD77jownE0zDyE8yc3Eu5UqKLE/1633Ek9QF1jjIf3+g5ZOdCVHJtJQWCnAeIh RftElgSeZoq/cj9LUIQFG4Hu3xfrEnw7mtUlWcChmyoSZG1jLKKI5TBWgV94RzaCD2aL +H4igzLousL38jfe/8SP69eRZTgMDmQwMkrxcWI8XAZWJcctZkN+bgmaHEXFXG7iije6 cPbj4A1sQAKUTsgwjNhyPaDV+5pL+aVzP7g3f7TvIRr9e5yJ8IAGMbja1bO5B4vWtxue tA/rw1ml+dRKkJf29MJGtqc3+t3TrvP7/ZCM4i2hBLNYJN/FWLMC9CRnvhifRYvwM6Dr a7LA== X-Gm-Message-State: AOJu0YzYr9Djls0PJto7no3yWH8JMRygqHSe9yUYs4JCdmheJM9vFqi4 wY+VYogFd7W4sgrzWF2D5wQ/zlSFLMrYn3TeXlukKxS/5NB5teaK2yxIhur2aoXxQTYibX97yCl E X-Google-Smtp-Source: AGHT+IGF05oNHM8p7Ce31bwXn08Ac7E8BGPabGvHPbgeQePR9ZipFLQHp9ZH/10O5ZlWsZ7Hsk3bDQ== X-Received: by 2002:a5d:6d01:0:b0:367:9828:f42d with SMTP id ffacd0b85a97d-36d275798c6mr1213909f8f.53.1723112627728; Thu, 08 Aug 2024 03:23:47 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:47 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 3/7] pipeline: rpi: Pass crop rectangle as a parameter to platformSetIspCrop() Date: Thu, 8 Aug 2024 11:23:42 +0100 Message-Id: <20240808102346.13065-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" This will be required when we program separate crop values to each ISP output in a future commit. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 3 +-- src/libcamera/pipeline/rpi/common/pipeline_base.h | 2 +- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 5322fd798a36..2de6111bacfd 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1314,8 +1314,7 @@ void CameraData::applyScalerCrop(const ControlList &controls) if (ispCrop != ispCrop_) { ispCrop_ = ispCrop; - platformSetIspCrop(); - + platformSetIspCrop(ispCrop); } } } diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index 5161c16e518f..d65b695c30b5 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -83,7 +83,7 @@ public: Rectangle scaleIspCrop(const Rectangle &ispCrop) const; void applyScalerCrop(const ControlList &controls); - virtual void platformSetIspCrop() = 0; + virtual void platformSetIspCrop(const Rectangle &ispCrop) = 0; void cameraTimeout(); void frameStarted(uint32_t sequence); diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index e5b6ef2b37cd..0ea032293bc9 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -109,9 +109,10 @@ public: Config config_; private: - void platformSetIspCrop() override + void platformSetIspCrop(const Rectangle &ispCrop) override { - isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &ispCrop_); + Rectangle crop = ispCrop; + isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop); } int platformConfigure(const RPi::RPiCameraConfiguration *rpiConfig) override; @@ -707,7 +708,7 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi Size size = unicamFormat.size.boundedToAspectRatio(maxSize); ispCrop_ = size.centeredTo(Rectangle(unicamFormat.size).center()); - platformSetIspCrop(); + platformSetIspCrop(ispCrop_); return 0; } From patchwork Thu Aug 8 10:23:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20836 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 0CE6BC32D6 for ; Thu, 8 Aug 2024 10:24:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 80789633B4; Thu, 8 Aug 2024 12:24:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EKQdKb7p"; dkim-atps=neutral Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F3E90633B3 for ; Thu, 8 Aug 2024 12:23:49 +0200 (CEST) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-52f01b8738dso615477e87.1 for ; Thu, 08 Aug 2024 03:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112629; x=1723717429; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=udLn4pl0gbPuXta+jTkKmxnNGVbdVMnTNow0Ki0JMVw=; b=EKQdKb7pibM9yyiE1WwDgzIM+J1Wrr3GXF1LhLMpPtXT88ev3hqaPwkeKqCW903jWI BEm2wVXcGHCASScx1lDodxHj8tG8YOj6v04q+Nx+jtH5hXjH8iDP8pW5Oed0gmCjuRvz Cddh/QD/VMgRDL9CUSn1JlYhQ1aXzhkjOYpFZll+kdfV4qWWjtOn1+OiQg4CyVrrwYo9 eVGK7hWhouNj0xkku3wEw7VU1SwtQqCPY8ner3UVvqMuWu9C25ooclmnhKenI9OmIPwI HWGo8CjJ5O1hUXQO4ejHAZbbh/E72FgMRpzw54oZzy4DtO/BHungT01mHooDmPKHXtOs 3Lgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112629; x=1723717429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=udLn4pl0gbPuXta+jTkKmxnNGVbdVMnTNow0Ki0JMVw=; b=JOC6XKRNXvo0ywAfaTuh5WkEAUYQf9OZTdDqWOMvnBudnB8rv4Cu4Dan82vnR0i6JK NagOQqV7Awy9yHvefFOu8pRS9tuJvZaO5GjNL7zjxv6mDL46qHqiTSjneDibP/mnv1tz R3OqbiYB0Ec5ofJEkju4Jjk1lHkWKI1Q/jgSqTSWjQEUfZeGB1jLJWA3EpJ6nEzjRm7C cG1fLH9NLKeK/aKknX2rH+3wFr3Y29LvkcA4uXJSK1xZD+If11jH+y+59inPTQTo0LMS /yPTaCMI2Ave4sNiJU1QkkStzyCU7BAAi0F24MZYxarUwnLtn9NkzpCRwffYGVbSHccR cVXA== X-Gm-Message-State: AOJu0YzkMtN2ZcJkwFGWDMFrKzl0O4VIQZ2Np09p49KcM0Uh7uGmURGt Llv7MEwtthl2LcflYC1B4Bra1ytlo4ch/GUaJx1iFz1SOIrXTV3KJXLyv4FgjcItli2Im3a1r+u x X-Google-Smtp-Source: AGHT+IEz8y4uHvVJv+XWKKqm0330tldGJlTx+mcpbOx/p3BYhOKpZU/t2NzjsFM5pJfs3+i0cvnKjA== X-Received: by 2002:a05:6512:3e0d:b0:52c:df6d:e52e with SMTP id 2adb3069b0e04-530e582d6acmr1140484e87.16.1723112628283; Thu, 08 Aug 2024 03:23:48 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:47 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 4/7] pipeline: rpi: Introduce CameraData::CropParams Date: Thu, 8 Aug 2024 11:23:43 +0100 Message-Id: <20240808102346.13065-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" In preparation for assigning separate crop windows for each stream, add a new CropParams structure that stores the existing ispCrop_ and ispMinCropSize_ as fields. Use a new std::map to store a CropParams structure where the map key is the index of the stream configuration in the CameraConfiguration vector. At preset, only a single CropParams structure will be set at key == 0 to preserve the existing crop handling logic. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- .../pipeline/rpi/common/pipeline_base.cpp | 23 +++++++++++-------- .../pipeline/rpi/common/pipeline_base.h | 21 +++++++++++++++-- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 13 ++++++++--- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 2de6111bacfd..412e71648231 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -561,10 +561,12 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config) for (auto const &c : result.controlInfo) ctrlMap.emplace(c.first, c.second); - /* Add the ScalerCrop control limits based on the current mode. */ - Rectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->ispMinCropSize_)); - ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, - data->scaleIspCrop(data->ispCrop_)); + if (data->cropParams_.count(0)) { + /* Add the ScalerCrop control limits based on the current mode. */ + Rectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->cropParams_[0].ispMinCropSize)); + ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, + data->scaleIspCrop(data->cropParams_[0].ispCrop)); + } data->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap()); @@ -1291,7 +1293,8 @@ Rectangle CameraData::scaleIspCrop(const Rectangle &ispCrop) const void CameraData::applyScalerCrop(const ControlList &controls) { const auto &scalerCrop = controls.get(controls::ScalerCrop); - if (scalerCrop) { + if (scalerCrop && cropParams_.count(0)) { + CropParams &cropParams = cropParams_[0]; Rectangle nativeCrop = *scalerCrop; if (!nativeCrop.width || !nativeCrop.height) @@ -1308,12 +1311,12 @@ void CameraData::applyScalerCrop(const ControlList &controls) * 2. With the same mid-point, if possible. * 3. But it can't go outside the sensor area. */ - Size minSize = ispMinCropSize_.expandedToAspectRatio(nativeCrop.size()); + Size minSize = cropParams.ispMinCropSize.expandedToAspectRatio(nativeCrop.size()); Size size = ispCrop.size().expandedTo(minSize); ispCrop = size.centeredTo(ispCrop.center()).enclosedIn(Rectangle(sensorInfo_.outputSize)); - if (ispCrop != ispCrop_) { - ispCrop_ = ispCrop; + if (ispCrop != cropParams.ispCrop) { + cropParams.ispCrop = ispCrop; platformSetIspCrop(ispCrop); } } @@ -1471,7 +1474,9 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request request->metadata().set(controls::SensorTimestamp, bufferControls.get(controls::SensorTimestamp).value_or(0)); - request->metadata().set(controls::ScalerCrop, scaleIspCrop(ispCrop_)); + if (cropParams_.count(0)) + request->metadata().set(controls::ScalerCrop, + scaleIspCrop(cropParams_[0].ispCrop)); } } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index d65b695c30b5..2bed905178bc 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -133,8 +133,25 @@ public: /* For handling digital zoom. */ IPACameraSensorInfo sensorInfo_; - Rectangle ispCrop_; /* crop in ISP (camera mode) pixels */ - Size ispMinCropSize_; + + struct CropParams { + CropParams(Rectangle ispCrop_, Size ispMinCropSize_) + : ispCrop(ispCrop_), ispMinCropSize(ispMinCropSize_) + { + } + + CropParams() + { + } + + /* Crop in ISP (camera mode) pixels */ + Rectangle ispCrop; + /* Minimum crop size in ISP output pixels */ + Size ispMinCropSize; + }; + + /* Mapping of CropParams keyed by the stream index in CameraConfiguration */ + std::map cropParams_; unsigned int dropFrameCount_; diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 0ea032293bc9..d118252f02dd 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -702,13 +702,20 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi /* Figure out the smallest selection the ISP will allow. */ Rectangle testCrop(0, 0, 1, 1); isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &testCrop); - ispMinCropSize_ = testCrop.size(); /* Adjust aspect ratio by providing crops on the input image. */ Size size = unicamFormat.size.boundedToAspectRatio(maxSize); - ispCrop_ = size.centeredTo(Rectangle(unicamFormat.size).center()); + Rectangle ispCrop = size.centeredTo(Rectangle(unicamFormat.size).center()); - platformSetIspCrop(ispCrop_); + platformSetIspCrop(ispCrop); + /* + * Set the scaler crop to the value we are using (scaled to native sensor + * coordinates). + */ + cropParams_.clear(); + cropParams_.emplace(std::piecewise_construct, + std::forward_as_tuple(0), + std::forward_as_tuple(scaleIspCrop(ispCrop), testCrop.size())); return 0; } From patchwork Thu Aug 8 10:23:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20835 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 D88B0C323E for ; Thu, 8 Aug 2024 10:24:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9453A6337F; Thu, 8 Aug 2024 12:23:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JZgKu1iB"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D3A4B63398 for ; Thu, 8 Aug 2024 12:23:49 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42816ca797fso5632385e9.2 for ; Thu, 08 Aug 2024 03:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112629; x=1723717429; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yf16f/8809mBEiavgIV3g6OlgJ66hlAI1lvZj9UlDg4=; b=JZgKu1iBhAb6oL+1qE53nEtQoCzT7R28M84WLqdw/t6f3bB04/B5PKEwQXGceeiIl4 a5lqV2gqooi2EU2AsHsbEOobRYFPwLfvKo/lSTuhEwDunDeic4gTzlANz5xykAISB3fX y1owLJfcs93ceeFKAmEElSqhteTnEv8YgFGL10HUGPCUogypXp890dfNM0hu2YHL35H1 NGPDe99RVbVLuoQDDjehHqUoUDt2HnXtF6LTnKXdrLD8YkOoGCPshXsbkpLgyw0uR5vF lkVHCTofk1DZzysed5n6xmWvrDoKyp14evzeHT5h+rJ3KEGW3ipwL6mQdv9LC4YkUYTH fOXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112629; x=1723717429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yf16f/8809mBEiavgIV3g6OlgJ66hlAI1lvZj9UlDg4=; b=ENpkXew9q5JHzzV1JOZTSknnO5kdLbE9fuGKLmGPO07y7p2Vn41werL0qAdT6CHVp2 TnCcidJUBhp2N7uqOy76dVMfW5OGlzq+rICQt6NO0uBgcrhf4Kd1tyBmU2h9hip1vlqY 6YG9/DaFrReEBi1pAlFC76uakFfjQplZIz9U9WqLCIwj60VIX38sSjoKliaCI+dDq4So 0aEZLmR0EEetMrIYD3K8miJzDqZI2IMqu4Kta2csSsg1vQgQTZovsgRTkvYczhJt6bZU vEA7tSwOeb8/2lt8ebfQcq00kWGHaKABkatWvgLmfMxCnOBhHke4t7JMDWrZ6ub8WBhg iNkw== X-Gm-Message-State: AOJu0Yxy1cC+y/WuB8wl4HMTObrhRGoRMj9Nuh6gDYdhjGaWz6sAo0L1 DARkjXhLFyIpLOYGm0WWBKNJdSNU/ucANXclaUr2QfkFVlggOWgSRF4oMouG3/UfdHUs+wtq2iD 4 X-Google-Smtp-Source: AGHT+IHsyns4ohzuHV8hf8rQvX1bSTc60E5TDbh8+itCX3HD3Xg1GY/v/wQe6SzNPFaExcFrfpdwMA== X-Received: by 2002:a5d:50ca:0:b0:367:8ff0:e022 with SMTP id ffacd0b85a97d-36d275830eamr957298f8f.63.1723112628875; Thu, 08 Aug 2024 03:23:48 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:48 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 5/7] pipeline: rpi: Track which ISP output is configured for a stream Date: Thu, 8 Aug 2024 11:23:44 +0100 Message-Id: <20240808102346.13065-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" Add a ispIndex field to CropParams that is used to track which ISP output (0/1) will be used for a given stream during configuration. Tracking this information is required for an upcoming change where crop rectangles can be specified for each configured stream. Currently, the value is fixed to 0. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rpi/common/pipeline_base.h | 6 ++++-- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index 2bed905178bc..0ccfa4e82e86 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -135,8 +135,8 @@ public: IPACameraSensorInfo sensorInfo_; struct CropParams { - CropParams(Rectangle ispCrop_, Size ispMinCropSize_) - : ispCrop(ispCrop_), ispMinCropSize(ispMinCropSize_) + CropParams(Rectangle ispCrop_, Size ispMinCropSize_, unsigned int ispIndex_) + : ispCrop(ispCrop_), ispMinCropSize(ispMinCropSize_), ispIndex(ispIndex_) { } @@ -148,6 +148,8 @@ public: Rectangle ispCrop; /* Minimum crop size in ISP output pixels */ Size ispMinCropSize; + /* Index of the ISP output channel for this crop */ + unsigned int ispIndex; }; /* Mapping of CropParams keyed by the stream index in CameraConfiguration */ diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index d118252f02dd..ffc45653daf1 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -715,7 +715,7 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi cropParams_.clear(); cropParams_.emplace(std::piecewise_construct, std::forward_as_tuple(0), - std::forward_as_tuple(scaleIspCrop(ispCrop), testCrop.size())); + std::forward_as_tuple(scaleIspCrop(ispCrop), testCrop.size(), 0)); return 0; } From patchwork Thu Aug 8 10:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20837 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 EE232C32D7 for ; Thu, 8 Aug 2024 10:24:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A2D64633C3; Thu, 8 Aug 2024 12:24:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NL1LjAMi"; dkim-atps=neutral Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1827B6337F for ; Thu, 8 Aug 2024 12:23:51 +0200 (CEST) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2f035ae1083so7481681fa.3 for ; Thu, 08 Aug 2024 03:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112630; x=1723717430; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VjueByByZqvccxa/i0QAXN2/rnotxj6xlf7+JpUcICE=; b=NL1LjAMiOcHdV39I80vkqrKKxRrAoDYQJYhyDvnmU82z+iVuQJBwb9mTnuwFUnfecH BwZGgabngZtzOUA3b293IjDvQipMMQtiSi07VSnTvfhJJMg2GB9btSvBzEgn/GCkfKD6 wAVHUvh3mDGQcokmG+EkbxhkgMb1gIsKhFNYBlXGVNKRoZ34i1Su/l/08pqYCsWCBNul vv3GWrGESj7w6Yds1lGcP48ydEizeXU7DwBl20M+M6M93rIw06R3l6c49AtRT+KOod8E ACW8PbXizEaXi7Yeabp84sVnF1SJWGnh9MZy0/jzj2XkzKzptXgnZOx0soFxdhl2n9KO GuRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112630; x=1723717430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VjueByByZqvccxa/i0QAXN2/rnotxj6xlf7+JpUcICE=; b=CbzI9P92MnSlJ3jb5BdfuiixouLqXvGuprF7Adja+ayKFTu/ArQejrYJpn4TIlnvFT W8P0H72+tBEYxuQxWiH3I0asKyaxkVoCevLl8XavP+Av96vRcmVX3IkZjkpLJI8HWC1V yjcT3zb7k1UXGsl0IZiTn2sh8IF69XLFaMHXtAfXnxtcn808fAa+sR5TKNStkmc4996A DqUhf5T+RaBvVVWiLRk2PGu05fxpO7JM2BcvQA+MAvJ1qBCM5Ywr1R7URtJ5emngTvkU taJX9i2+VH19sZN0asSCjg1yNajtbyORc/w3O0nn1BVAVNH0UgNlpVT5gyJK/HnoWet6 XKCA== X-Gm-Message-State: AOJu0Ywnf32AWrgAOrpH3bIXMYx3N2e6KW+puSGn3xFgIPwhx1eiduIA M4Hjt1FdS9cfcXWLmZSJshMWe9DxGgUkW1Vx/OUMVcFYfjxWoJxlCuRZb7qcG8rGIWnqqHZqq2x t X-Google-Smtp-Source: AGHT+IHHvbyJV9J2ORFB/SNQ8SaTTLjCAQ+SFLF0al0KAqRC6nPfOVhy37Rh48UpQU5f8UrtKGr9uA== X-Received: by 2002:a2e:90ce:0:b0:2ef:2d5a:485 with SMTP id 38308e7fff4ca-2f19de86b91mr8825831fa.46.1723112629898; Thu, 08 Aug 2024 03:23:49 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 6/7] pipeline: rpi: Pass ISP output index into platformSetIspCrop() Date: Thu, 8 Aug 2024 11:23:45 +0100 Message-Id: <20240808102346.13065-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" At this point, the index is unused, but will be in a future commit where we can set different crops on each ISP output. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 2 +- src/libcamera/pipeline/rpi/common/pipeline_base.h | 2 +- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 412e71648231..a6ea4e9c47dd 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1317,7 +1317,7 @@ void CameraData::applyScalerCrop(const ControlList &controls) if (ispCrop != cropParams.ispCrop) { cropParams.ispCrop = ispCrop; - platformSetIspCrop(ispCrop); + platformSetIspCrop(cropParams.ispIndex, ispCrop); } } } diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index 0ccfa4e82e86..7959d874dd6f 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -83,7 +83,7 @@ public: Rectangle scaleIspCrop(const Rectangle &ispCrop) const; void applyScalerCrop(const ControlList &controls); - virtual void platformSetIspCrop(const Rectangle &ispCrop) = 0; + virtual void platformSetIspCrop(unsigned int index, const Rectangle &ispCrop) = 0; void cameraTimeout(); void frameStarted(uint32_t sequence); diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index ffc45653daf1..04fb3c066baf 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -109,7 +109,7 @@ public: Config config_; private: - void platformSetIspCrop(const Rectangle &ispCrop) override + void platformSetIspCrop([[maybe_unused]] unsigned int index, const Rectangle &ispCrop) override { Rectangle crop = ispCrop; isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop); @@ -707,7 +707,7 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi Size size = unicamFormat.size.boundedToAspectRatio(maxSize); Rectangle ispCrop = size.centeredTo(Rectangle(unicamFormat.size).center()); - platformSetIspCrop(ispCrop); + platformSetIspCrop(0, ispCrop); /* * Set the scaler crop to the value we are using (scaled to native sensor * coordinates). From patchwork Thu Aug 8 10:23:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20838 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 ADBCBC324E for ; Thu, 8 Aug 2024 10:24:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 79E1D633C4; Thu, 8 Aug 2024 12:24:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="B5BEjglt"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71479633B4 for ; Thu, 8 Aug 2024 12:23:51 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-369f68f63b1so420101f8f.2 for ; Thu, 08 Aug 2024 03:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1723112631; x=1723717431; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FutAzOzdno63Zw2uUf3aHTsbgoCwqzcG1+IrkzQMZCA=; b=B5BEjglti5iYCcxCEvcfT/HjN5KGQzQBvzuHRQLkTOmQ6THpiZ3vC/H8K+gk06h2kR 5AsX5j5z8+qDFjKr+udrISZuQJVvgkYHGINGzAJ2GI5z2FjH2ZK/NOqIm5ukNf/1OKeZ N5lZaIJFU4w7Xn/0sXAiXa1WqTh0au1pnncfH5gzdm8ylDtgHQ+lyZANRMn/LACcBqwh JwYySHWSoUHq0D7O+ezvvjgdyrvJSURbsJlFS5YDI2r2gJiEV5LkcWg4zxFsvr5DlXKV xyieGFxrCoTFjT/qVHFYh8gwMD+nLPhK/er6XTnaTNucUlnarUINFFhUvvkdZDDOFrt3 adAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112631; x=1723717431; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FutAzOzdno63Zw2uUf3aHTsbgoCwqzcG1+IrkzQMZCA=; b=ftjNY/09a/AbgWhq0qKVuYwCQlySe0Ux6EfJsKrpgo13bkO4tt4ywM8WNZiQYrw2se Yuch6p1YVkdFFGPi7s7xTldZOrUBb9aQsEJwUpRTZIfeAu3pcLFQUaLisTkB0sMDOoC0 kdX9+XeVtxeD8X7xaue9ocZr8k9AU584YM7zYmFT3Eahj3rvoBXDtPYJld0Tmny3PZlO 4W+tXUyrJMmFN6Un7ekPrkH9EBncZjXQB2U7qLzo2QpJxsWNSp8Mda0WVhpDrc1Z4pp4 MdJfI+f2tJ04LB8K+FsDlh04ESaiValWLV1wjGjssubS7ZU9uU3VwxCYYFimzPcWsgfU qcuQ== X-Gm-Message-State: AOJu0YyApFtdPz237lJsnXXapFCVvhSk0hAGPuMBZbK1TqZ1ttVavI0N qyfJsoXZ9nBMSvbEQnwnZ/v8hesu/l8DTkFVZvETtGLpVRiemDEA6UP4m6Z0hWVWFhb+s9GMNBi R X-Google-Smtp-Source: AGHT+IHf8KONfa8fzGhfky3HDVP/MfpyOgsmFt+8bcW9H+Sewrl2QhY7uqNebMA2jCdxvpVzR7i1bw== X-Received: by 2002:adf:cf05:0:b0:36b:a3c8:12aa with SMTP id ffacd0b85a97d-36d274dcc2fmr931558f8f.26.1723112630516; Thu, 08 Aug 2024 03:23:50 -0700 (PDT) Received: from naush-laptop.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d272290c2sm1404234f8f.92.2024.08.08.03.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:23:50 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 7/7] pipeline: rpi: Handler controls::rpi::ScalerCrops Date: Thu, 8 Aug 2024 11:23:46 +0100 Message-Id: <20240808102346.13065-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240808102346.13065-1-naush@raspberrypi.com> References: <20240808102346.13065-1-naush@raspberrypi.com> MIME-Version: 1.0 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" Handle multiple scaler crops being set through the rpi::ScalerCrops control. We now populate the cropParams_ map in the loop where we handle the output stream configuration items. The key of this map is the index of the stream configuration structure set by the application. This will also be the same index used to specify the crop rectangles through the ScalerCrops control. CameraData::applyScalerCrop() has been adapted to look at either controls::ScalerCrop or controls::rpi::ScalerCrops. The former takes priority over the latter, and if present, will apply the same scaler crop to all output streams. Finally return all crops through the same ScalerCrops control via request metadata. The first configure stream's crop rectangle is also returned via the ScalerCrop control in the request metadata. Signed-off-by: Naushir Patuck --- .../pipeline/rpi/common/pipeline_base.cpp | 69 +++++++++++++++---- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index a6ea4e9c47dd..b9759b682f0d 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -561,11 +561,28 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config) for (auto const &c : result.controlInfo) ctrlMap.emplace(c.first, c.second); - if (data->cropParams_.count(0)) { - /* Add the ScalerCrop control limits based on the current mode. */ + if (data->cropParams_.size()) { + /* + * Add the ScalerCrop control limits based on the current mode and + * the first configured stream. + */ Rectangle ispMinCrop = data->scaleIspCrop(Rectangle(data->cropParams_[0].ispMinCropSize)); ctrlMap[&controls::ScalerCrop] = ControlInfo(ispMinCrop, data->sensorInfo_.analogCrop, data->scaleIspCrop(data->cropParams_[0].ispCrop)); + if (data->cropParams_.size() == 2) { + /* + * The control map for rpi::ScalerCrops has the min value + * as the default crop for stream 0, max value as the default + * value for stream 1. + */ + ctrlMap[&controls::rpi::ScalerCrops] = + ControlInfo(data->scaleIspCrop(data->cropParams_[0].ispCrop), + data->scaleIspCrop(data->cropParams_[1].ispCrop), + ctrlMap[&controls::ScalerCrop].def()); + } else { + /* Match the same ControlInfo for rpi::ScalerCrops. */ + ctrlMap[&controls::rpi::ScalerCrops] = ctrlMap[&controls::ScalerCrop]; + } } data->controlInfo_ = ControlInfoMap(std::move(ctrlMap), result.controlInfo.idmap()); @@ -1292,10 +1309,29 @@ Rectangle CameraData::scaleIspCrop(const Rectangle &ispCrop) const void CameraData::applyScalerCrop(const ControlList &controls) { - const auto &scalerCrop = controls.get(controls::ScalerCrop); - if (scalerCrop && cropParams_.count(0)) { - CropParams &cropParams = cropParams_[0]; - Rectangle nativeCrop = *scalerCrop; + const auto &scalerCropRPi = controls.get>(controls::rpi::ScalerCrops); + const auto &scalerCropCore = controls.get(controls::ScalerCrop); + std::vector scalerCrops; + + /* + * First thing to do is create a vector of crops to apply to each ISP output + * based on either controls::ScalerCrop or controls::rpi::ScalerCrops if + * present. + * + * If controls::ScalerCrop is present, apply the same crop to all ISP output + * streams. Otherwise if controls::rpi::ScalerCrops, apply the given crops + * to the ISP output streams, indexed by the same order in which they had + * been configured. This is not the same as the ISP output index. + */ + for (unsigned int i = 0; i < cropParams_.size(); i++) { + if (scalerCropRPi && i < scalerCropRPi->size()) + scalerCrops.push_back(scalerCropRPi->data()[i]); + else if (scalerCropCore) + scalerCrops.push_back(*scalerCropCore); + } + + for (auto const &[i, scalerCrop] : utils::enumerate(scalerCrops)) { + Rectangle nativeCrop = scalerCrop; if (!nativeCrop.width || !nativeCrop.height) nativeCrop = { 0, 0, 1, 1 }; @@ -1311,13 +1347,13 @@ void CameraData::applyScalerCrop(const ControlList &controls) * 2. With the same mid-point, if possible. * 3. But it can't go outside the sensor area. */ - Size minSize = cropParams.ispMinCropSize.expandedToAspectRatio(nativeCrop.size()); + Size minSize = cropParams_[i].ispMinCropSize.expandedToAspectRatio(nativeCrop.size()); Size size = ispCrop.size().expandedTo(minSize); ispCrop = size.centeredTo(ispCrop.center()).enclosedIn(Rectangle(sensorInfo_.outputSize)); - if (ispCrop != cropParams.ispCrop) { - cropParams.ispCrop = ispCrop; - platformSetIspCrop(cropParams.ispIndex, ispCrop); + if (ispCrop != cropParams_[i].ispCrop) { + cropParams_[i].ispCrop = ispCrop; + platformSetIspCrop(cropParams_[i].ispIndex, ispCrop); } } } @@ -1474,9 +1510,16 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request request->metadata().set(controls::SensorTimestamp, bufferControls.get(controls::SensorTimestamp).value_or(0)); - if (cropParams_.count(0)) - request->metadata().set(controls::ScalerCrop, - scaleIspCrop(cropParams_[0].ispCrop)); + if (cropParams_.size()) { + std::vector crops; + + for (auto const &[k, v] : cropParams_) + crops.push_back(scaleIspCrop(v.ispCrop)); + + request->metadata().set(controls::ScalerCrop, crops[0]); + request->metadata().set(controls::rpi::ScalerCrops, + Span(crops.data(), crops.size())); + } } } /* namespace libcamera */