From patchwork Fri Oct 16 20:28:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28481 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 76686C3305 for ; Fri, 16 Oct 2026 20:28:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2DBC768E77; 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="o1tUi+Pu"; dkim-atps=neutral Received: from mail-vk1-xa2f.google.com (mail-vk1-xa2f.google.com [IPv6:2607:f8b0:4864:20::a2f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 05C0E68E3A for ; Fri, 16 Oct 2026 22:28:39 +0200 (CEST) Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-5e930a11148so229657e0c.2 for ; Fri, 16 Oct 2026 13:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792182518; x=1792787318; 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=fqO4EYJ6COt1aye3c7JvLP4PBBEK2Ab6empI1mmiObs=; b=o1tUi+PuERbDmGbSkl9VUWMDzph6QdP2nA373YSDiI4RFus4P4HoI3GVvAXR5BuWNv O9i00XqK/tQ9ZtS6HJOHyK8uUdo+SUIemhKB5NddYlSbLN2nOU95OowPES01bOmpFGWl CO8xISeIM/kcu5kUzoP5LvOQgTgYdU/6aO11dB7WftPx/rOwCbSuehYHUYlucEIqXYYT R082pXjfelEg2Nowckkzs/ueueGBU1LbKBc1PxrUDh2+IIGx044LbGIHGFKyzq6Anl80 1640ODamhvJS6a5p0wg9ov1YMZqHHLwlrTz5aTkJAQjDdE578sJIqU0f27/2JrAdDIK1 RmSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792182518; x=1792787318; 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=fqO4EYJ6COt1aye3c7JvLP4PBBEK2Ab6empI1mmiObs=; b=JS4SZqsvViKQJDw8de6gKveybs3xYc66FT9Lv7tJioIel0TqwYERjiexZz6ReyW+bx veMODB9X6rcInfmYz8hoNfM45SdoZcu19kFFXq7IU7nVHOCbLpBBThqCFAn1dN3LiN78 PpovdktXBT0pIVYkb7ewBhpqFEy37LcnZnTk/rDXHHxHlVOxbDZzITJNeNzurYNvvb06 zkVfH8HWxj08fO1maAKYiugbYjwlPBxebSruuqxy1kUNJQeInnDuTWlN8/Cv7mGkaL1L P5dbxMJlh47xKUVGfy748Yj7rtPzDQzzOMN4uT32PYm63Mfkx1RJfNG7o2qNceIjDrL5 Wyeg== X-Gm-Message-State: AFq9FYLpdbavdaM77QAzDE+M4M6hkhe3JCIHi+UXK7fMdZajXMrynfNn cJU0E2XmgIECK9og1dGRFT+j8jqpT3q1EWYJUhMnCCO8857+7tPsnhlqMptoQriADA0= X-Gm-Gg: AYBFou0v7E7aFFHXwZrC+g9kYOwVq98ACkyzhCOL6WGZBwnmDnqOC1HtBr59LoQB6+t T+hI/x/lttL6OWGt4cuH9MxjnMgtn/RY7kiOfJxK8CXg6o2o2/Ik8nawzyskbDI3ZMfvnHX2yI7 HYk9jdFgNzvRkx/XA5+0pbLhOe0L2lIWRWXt/sjzSwfg/zOJ6bT/XcEghKSZ57ViC9PLZrnI9h4 9Draar6Zq5sWUyYPwZAOoLXzntlU1hdOfmj+YFAdUyNfJPUZ6eO9+P0/oOPPYKbmEWKNwcKeN5Q N8Z3pYngUHHe+ga/S6G6JTDevKfRd1jAAoH7BvkNqSwMqPg94WBpcvu5vWhxjhO8NdQP4vnmj+/ ATtNp8X4QhlSq1X9m0OLX0M+2dNKWBn8izQrcc5/51UN60l7dr4+RLio3W/Xlfh7r/ji8LaZlIw iJNTYcCj340n20tqeQyn54UHT5aurQXqbunaXv70GVKSgsrXv0A+fM/NHXsm13N+z4Zk6jH8Ba7 M6VaksssqTilbycOMIYaOMzOz4n X-Received: by 2002:a05:6122:e14b:b0:5c8:c5f:e8fa with SMTP id 71dfb90a1353d-5eaaa374143mr607698e0c.4.1792182517860; Fri, 16 Oct 2026 13:28:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 13:28:37 -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 09/11] v4l2: Allow probing optional selection rectangles Date: Fri, 16 Oct 2026 16:28:16 -0400 Message-ID: <20261016202818.1405645-10-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 allows callers to query optional subdevice selections without logging an error when the API or target is unsupported. Determining the sensor region captured by a pipeline requires checking whether its intermediate subdevices crop or compose the image. The selection ioctl or a particular target may be absent on a pass-through device, and that expected result currently produces an error message. Signed-off-by: Ray Strode --- include/libcamera/internal/v4l2_subdevice.h | 7 ++++--- src/libcamera/v4l2_subdevice.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c37a82af..41dc80f2 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -123,10 +123,11 @@ 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, bool optional = false); + int getSelection(unsigned int pad, unsigned int target, Rectangle *rect, + bool optional = false) { - return getSelection({ pad, 0 }, target, rect); + return getSelection({ pad, 0 }, target, rect, optional); } int setSelection(const Stream &stream, unsigned int target, Rectangle *rect); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a69de154..2e23f9ad 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1171,13 +1171,17 @@ int V4L2Subdevice::open() * \param[in] stream The stream the rectangle is retrieved from * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[out] rect The retrieved selection rectangle + * \param[in] optional Whether unsupported targets are expected + * + * Optional queries return -ENOTTY or -EINVAL without logging an error when + * the selection API or target is unsupported. Other errors are logged normally. * * \todo Define a V4L2SelectionTarget enum for the selection target * * \return 0 on success or a negative error code otherwise */ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, - Rectangle *rect) + Rectangle *rect, bool optional) { struct v4l2_subdev_selection sel = {}; @@ -1189,6 +1193,9 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, int ret = ioctl(VIDIOC_SUBDEV_G_SELECTION, &sel); if (ret < 0) { + if (optional && (ret == -ENOTTY || ret == -EINVAL)) + return ret; + LOG(V4L2, Error) << "Unable to get rectangle " << target << " on pad " << stream << ": " << strerror(-ret); @@ -1205,11 +1212,12 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, /** * \fn V4L2Subdevice::getSelection(unsigned int pad, unsigned int target, - * Rectangle *rect) + * Rectangle *rect, bool optional) * \brief Get selection rectangle \a rect for \a target * \param[in] pad The 0-indexed pad number the rectangle is retrieved from * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[out] rect The retrieved selection rectangle + * \param[in] optional Whether unsupported targets are expected * * \return 0 on success or a negative error code otherwise */