From patchwork Wed Nov 18 16:08:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 29018 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 34F84C3355 for ; Wed, 18 Nov 2026 16:08:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF0AE6A8FD; Wed, 18 Nov 2026 17:08:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TZZeiTBP"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C5E36A8C7 for ; Wed, 18 Nov 2026 17:08:38 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:c717:cce:84f5:c6f0]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A0E0C63C; Wed, 18 Nov 2026 17:06:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1795017969; bh=TZjTH+INvZsf3Rd8nMym9bH5LWV5qfciqFiZYmzspHc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TZZeiTBP9Dpnpzon6uS5N7Yv+zE7/vfpyvfhSeX42UWoTq9mjlQlURL6DDeeR4bgm NDv7n/1B4dRQvnXBHO77yUgJkMa3i+3g7uY3ecCaxSTefkSEeVWjYrdFVCG/0lTyES UTwMeBBv9MFjozsxDcAODAL9VGtA9i0I3N642bVQ= From: Stefan Klug Date: Wed, 18 Nov 2026 17:08:10 +0100 Subject: [PATCH RFC 1/3] libcamera: v4l2_subdevice: Add whence parameter to set/getSelection() MIME-Version: 1.0 Message-Id: <20261118-sklug-binning-factors-v1-v1-1-5e552aefbb07@ideasonboard.com> References: <20261118-sklug-binning-factors-v1-v1-0-5e552aefbb07@ideasonboard.com> In-Reply-To: <20261118-sklug-binning-factors-v1-v1-0-5e552aefbb07@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug X-Mailer: b4 0.14.3 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 whence parameter to V4L2Subdevice::setSelection() and V4L2Subdevice::getSelection() to be able to use try state with these functions. Signed-off-by: Stefan Klug --- include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ src/libcamera/v4l2_subdevice.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c37a82afa881..36848915fbb1 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -123,16 +123,18 @@ public: const MediaEntity *entity() const { return entity_; } int getSelection(const Stream &stream, unsigned int target, - Rectangle *rect); - int getSelection(unsigned int pad, unsigned int target, Rectangle *rect) + Rectangle *rect, Whence whence = ActiveFormat); + int getSelection(unsigned int pad, unsigned int target, Rectangle *rect, + Whence whence = ActiveFormat) { - return getSelection({ pad, 0 }, target, rect); + return getSelection({ pad, 0 }, target, rect, whence); } int setSelection(const Stream &stream, unsigned int target, - Rectangle *rect); - int setSelection(unsigned int pad, unsigned int target, Rectangle *rect) + Rectangle *rect, Whence whence = ActiveFormat); + int setSelection(unsigned int pad, unsigned int target, Rectangle *rect, + Whence whence = ActiveFormat) { - return setSelection({ pad, 0 }, target, rect); + return setSelection({ pad, 0 }, target, rect, whence); } Formats formats(const Stream &stream); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a69de154e8bb..e5b88c4a3ed1 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1177,11 +1177,11 @@ int V4L2Subdevice::open() * \return 0 on success or a negative error code otherwise */ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, - Rectangle *rect) + Rectangle *rect, Whence whence) { struct v4l2_subdev_selection sel = {}; - sel.which = V4L2_SUBDEV_FORMAT_ACTIVE; + sel.which = whence; sel.pad = stream.pad; sel.stream = stream.stream; sel.target = target; @@ -1225,11 +1225,11 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, * \return 0 on success or a negative error code otherwise */ int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, - Rectangle *rect) + Rectangle *rect, Whence whence) { struct v4l2_subdev_selection sel = {}; - sel.which = V4L2_SUBDEV_FORMAT_ACTIVE; + sel.which = whence; sel.pad = stream.pad; sel.stream = stream.stream; sel.target = target;