From patchwork Fri Oct 16 20:28:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28482 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 0FFADC3316 for ; Fri, 16 Oct 2026 20:28:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B495168E61; Fri, 16 Oct 2026 22:28:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jpVS5PpV"; dkim-atps=neutral Received: from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com [IPv6:2607:f8b0:4864:20::a2b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B4F8B68E5B for ; Fri, 16 Oct 2026 22:28:40 +0200 (CEST) Received: by mail-vk1-xa2b.google.com with SMTP id 71dfb90a1353d-5e948e56b9dso117597e0c.1 for ; Fri, 16 Oct 2026 13:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792182519; x=1792787319; 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:content-type; bh=a4MfcP/aL8c25kdB23Fap6IzVB63xsEyY26YTqRub9Y=; b=jpVS5PpVQagFOXxjpNNG7OCnsvMTMS+CHMhrHaqT82lkKDM87oepY9U6yCkaxSIvpq 86mxubkKoZrWnaOkLb60lA1d3t4pRo7T1DOx6v/Xa8+S4GdbIKlhMnLfSD4DRUtSERT0 kgLCUTgxo8g/wHVHrgUtN9JNw1rgjsM+V/d4M6zZ8a++xFwca92pKGXLCk0HV+j430/y MNS1DN7Elvv3Jmnx9kzsHdWylZ3GS3RFGMbprj8t6pXGmkm3a8Q4DNAm0CqoRnzsHlfu 0/FXrtdOocmmsB2qZb+6v4paEsFQoOyG449PQKUf1twQ3R2BCGkGYpbNsZj6ZnVfv2HH LXtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792182519; x=1792787319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=a4MfcP/aL8c25kdB23Fap6IzVB63xsEyY26YTqRub9Y=; b=FrrEBIwmwgmUGJQ/ZGM4w6PF+SmJc6+x/FdAfVYWHaxOX2IeDGpzZDXueNBvh3Pp+3 bfREqn4P/56llWWs2WfPQzBpetV4J1spktkgrAnpZCs/ztcBQ2xDipF3ZWMH/5yEToMX k9dbsE4cZn5wRGF+MAZrd5igT0Am9vY4fcRloayoPGOj153rcLJ4gJetLDGS4mRHQKHW IiUMOz2ahBWmqIWJGHmrrAhnEhjzuWJSgQ68rQFD73kE33oHBTTfonGNPN+/UIokZ6yP xgdHId7sk0pBhkr6Bx6GSQRddxDdCphhmtWFuj4a+sbmry5jNF+vD0XXOeImreVid7GR mLhw== X-Gm-Message-State: AFq9FYIctkYMpu9X3tXCBnbbN+POVTb7PqUInoeRZOkmdbEMskLMJ8Wy 1rnUWUAIPoneBZC6PzTC44wHts2rU9M3wmsKevB83+3UdvXo5mqrvGMGZ3bCr0XzYfY= X-Gm-Gg: AYBFou3dWtbj7pOh5LDYVzUR1VPRhE+29aZcrDYUZxhQYqeXWWGegEdXOq/9op8qS7W gJv5Q7UqXhF/TX4sVKIgBPrT9N7HzDSgpdCQbb7e6tdlAeVMM3kl1yM6F40qo4a5UR6U//aJoPJ fO776ceDpC5AZvJQByEUxkjL+m6wyo0y3d8WaR/nDGSAXouvbrvZVlAMQjCO4Fj4knqrDvyc8m1 M0Y0LjouCTuBasxErfA5D9gVCbSsWsVfrXqG00gw85J5/cBKlvyx/W4IYHMVbVepmrczdl3xJbB VT0FdjABAq/83oaDvsJzZEupNdC+vB8jPolku+hfZINFt09+CnN2snXXoiSkpwMKzwFIHsiWqTr rlGHSQqFgNu/cr51BIyB3W+R+saBAJRtq6EdYpgtkBGALw/ZhiUOy+qPM3gffpWdnFZbhsonQ5G LOTSS15W3Uhmzi0J2iSA1wHOAqz5BAp+kzi0G9romsHFkuddtewa8ceywISSJcEqLgWKj0Sx36V g0tyjNfXktC1ByiJVlvKKLgfBPN X-Received: by 2002:a05:6122:e443:b0:5ea:a9e1:d87c with SMTP id 71dfb90a1353d-5eaaa67b7b3mr534234e0c.18.1792182519472; Fri, 16 Oct 2026 13:28:39 -0700 (PDT) Received: from localhost ([2601:19c:4a00:897d:3391:ed89:5571:41a8]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ea9b2fef79sm2422500e0c.1.2026.10.16.13.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 13:28:38 -0700 (PDT) From: Ray Strode To: libcamera-devel@lists.libcamera.org Cc: kieran.bingham@ideasonboard.com, bod.linux@nxsw.ie, laurent.pinchart@ideasonboard.com Subject: [PATCH v3 10/11] pipeline: simple: Report the software ISP's maximum crop Date: Fri, 16 Oct 2026 16:28:17 -0400 Message-ID: <20261016202818.1405645-11-halfline@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261016202818.1405645-1-halfline@gmail.com> References: <20261015223604.311616-1-halfline@gmail.com> <20261016202818.1405645-1-halfline@gmail.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" From: Ray Strode This commit reports the software ISP's configured image region through the ScalerCropMaximum camera property. The simple pipeline currently exposes sensor properties without identifying the region retained by software processing. CPU debayering crops to the output dimensions, while EGL also scales the image, so the visible region can be smaller than the analogue sensor crop. The reported rectangle uses native sensor coordinates relative to the active array. Reporting is limited to capture paths that preserve the sensor output, since intermediate cropping or scaling requires an additional mapping. Reconfiguration restores the sensor properties so raw-only configurations do not retain an earlier processed-image crop. Based on Kieran Bingham's ScalerCropMaximum reporting patch, extended to account for the software ISP's selected image region. Link: https://patchwork.libcamera.org/patch/26678/ Signed-off-by: Ray Strode --- src/libcamera/pipeline/simple/simple.cpp | 54 +++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 35c29cec..91b149d1 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "libcamera/internal/camera.h" @@ -44,6 +45,7 @@ #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/request.h" +#include "libcamera/internal/software_isp/debayer_geometry.h" #include "libcamera/internal/software_isp/software_isp.h" #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" @@ -292,6 +294,7 @@ public: Transform transform = Transform::Identity); void imageBufferReady(FrameBuffer *buffer); void clearIncompleteRequests(); + void updateScalerCrop(const Size &inputSize, Transform transform); unsigned int streamIndex(const Stream *stream) const { @@ -983,6 +986,48 @@ void SimpleCameraData::clearIncompleteRequests() } } +void SimpleCameraData::updateScalerCrop(const Size &inputSize, Transform transform) +{ + IPACameraSensorInfo sensorInfo; + if (sensor_->sensorInfo(&sensorInfo)) + return; + + /* + * The buffer-to-sensor mapping requires a capture path that preserves + * the sensor output. Intermediate cropping or scaling needs a separate + * mapping; do not report the analogue crop as if it included that work. + */ + if (sensorInfo.outputSize != inputSize) + return; + + for (const Entity &entity : entities_) { + if (!entity.sink || !entity.source) + continue; + + V4L2Subdevice *subdev = pipe()->subdev(entity.entity); + for (const MediaPad *pad : { entity.sink, entity.source }) { + V4L2SubdeviceFormat format{}; + if (subdev->getFormat(pad->index(), &format) || + format.size != inputSize) + return; + + for (unsigned int target : { V4L2_SEL_TGT_CROP, V4L2_SEL_TGT_COMPOSE }) { + Rectangle selection; + int ret = subdev->getSelection(pad->index(), target, &selection, true); + if (!ret && selection != Rectangle(inputSize)) + return; + if (ret && ret != -ENOTTY && ret != -EINVAL) + return; + } + } + } + + Rectangle crop = debayerCropToSensor(swIsp_->inputCrop(), inputSize, + sensorInfo.analogCrop, sensorInfo.activeArea, + transform); + properties_.set(properties::ScalerCropMaximum, crop); +} + void SimpleCameraData::tryCompleteRequest(Request *request) { if (request->hasPendingBuffers()) @@ -1505,6 +1550,8 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) V4L2VideoDevice *video = data->video_; int ret; + data->properties_ = data->sensor_->properties(); + /* * Configure links on the pipeline and propagate formats from the * sensor to the video node. @@ -1605,7 +1652,12 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) } else { ipa::softisp::IPAConfigInfo configInfo; configInfo.sensorControls = data->sensor_->controls(); - return data->swIsp_->configure(inputCfg, outputCfgs, configInfo, &data->controlInfo_); + ret = data->swIsp_->configure(inputCfg, outputCfgs, configInfo, &data->controlInfo_); + if (ret) + return ret; + + data->updateScalerCrop(inputCfg.size, config->combinedTransform()); + return 0; } }