From patchwork Tue Jul 21 14:59:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 27427 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 D6ADDBE080 for ; Tue, 21 Jul 2026 15:00:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2EEB967E6E; Tue, 21 Jul 2026 17:00:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="nrIlssm9"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="DakKHFYh"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE6596601C for ; Tue, 21 Jul 2026 17:00:05 +0200 (CEST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66LDg3W91958685 for ; Tue, 21 Jul 2026 15:00:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=26USYEaNweJ ZtnHULZ3L3rzdqfTLZs2n2K/0B+cc0ok=; b=nrIlssm9LbQLbfsMWSE6tR+FGIH xTjZd4aUezo7pY/ZvgkPwEuQ0KqgGb2o9/o66YflaBI2NwArmFUVfyZRasfDQcu3 wJWZC6iIWPPr6RPJifaIjthWoUprdw2MQFuG8vLxGg9T/zHCdsdpA3uayM4mG3Qh qVTuR66FtjLHtSnjpSjBhN3hc9ACUy243ZOAR5qRYxuQ+2KjlzjUzPuorcyOiI0k 67ZX0aciIu2sGzMJvcX+CFjgv2MzqybILEjoDf9GpdmpDuXVwie0sLgT6ypMFKWt OwM8TJq1WqGjFvaLyb6kFFzRJQNM5uhWaMsVXBYGLDR1aBgGKmjZAEflszQ== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fj1bvu2q4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 21 Jul 2026 15:00:04 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-51c12e43b98so222069171cf.1 for ; Tue, 21 Jul 2026 08:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784646003; x=1785250803; 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=26USYEaNweJZtnHULZ3L3rzdqfTLZs2n2K/0B+cc0ok=; b=DakKHFYhhsMj1vODeCkMvisP89ByZSKAqUqHxbwUzWmJ+cl/ShB6MwRNUAHZHG2Ft+ 3mn4AEJarWsteQzO6sAvZzlKBN1IsRcBG8h2fvGFCa0k3B1v2xLyRcYkFoR80mVO0mBa HBQaGQp14ZJ5Sf+OZ12RCLR8A0gvRnziJYnc1ZeHcsAHPisfjbNtdaIR+LkiOU8STAJm d+zSFLKUTAhaqqg2LqoUj5q9MGMkvSA454uNZ5CBy6z8uoidzEZaO0LFcO/B/PaX8Yrr P9yHsUqtr9MIJ3+yLcTPZvU5404VNiCF2B0TqRZN5xrqBJoW8jmNbc15/dLcsP/tf83G ezbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784646003; x=1785250803; 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=26USYEaNweJZtnHULZ3L3rzdqfTLZs2n2K/0B+cc0ok=; b=Xzm5wPmczmFd64qKZn07zzsloRz6LUNdP+a6sNjdWF+kMoUWcZqyosYYGElGYiw0Qp UNX0mJhqwnAKb0GxxMvdYk30/MiGY+HcR7CGQ4PE72FA7FMUGOpwJW/s2PTrwsF5t642 1lI+TTwCY//59V8Q2p1WukNHAORQnqlA2Hg/CtgV4fNBkUBe3LLyEQkHH3maSaOC6ost jDbXAzE27WCg9ykhS+Hf7IWO4EmgnBweYxcdNQNOPPC8irCoTCJfbW+jRPjslJQHJXy7 kpEg72uEW/Up6ziZdbEEYFC2mnk2S/XT2wumDaSyLfA7MmH0yoDtBv1bvmw2/9omGD1J ZhJw== X-Gm-Message-State: AOJu0Yw1wUOktwA458J4mv/HpuYntpb/uzVzMmo6C38ZvrQoedNZx8/l jBFV6BBjz5AHT7M8A1HciO+mxFv4OquIubjW9Hhez9ywZft8hFTYjvgJGlivMeiPSpsJnMXr5Xe 5Z3QN/C+wpN2+EGu68I8ybA5s7myW54i6A0lTGiR9JWTL1WJuE8B244K837b2oLLOwxe1ZyrXcL VNe13A8OKi X-Gm-Gg: AfdE7cm9/3azcCj174gR4OY8yN5HMqC4mJW9aFUwkKMVQ2u7Ub6k+POeff6WVOQR4/8 0g0CrWK1w31yWPWulThmWqVcAjIqXyX+v7qmxAztTalItdme9AC5w23UV6bA/MiVFk7qLVDeqU+ JN7JuLx5G+9JakQ6nz+3yZ/l0LcRVkxTfyS7K1fkWnb45bdF1hDNrlhGtY5NsR7MDBZpvRuI2jF 4DOwa21HVtgZ3k+BY3Hjt0wdx7qCmVJtXLWgx3Ict3dE0BVNmhoF089K9SWlH0+g51rN+aN7WUu dzjB6mmZz7HM2TcjLc6mI4mQt5wYp5EekGTdiot0O3slz8P7Xbh9LbjJw6jYnFl70OZRjeq/XGV o/um893zGMbexop+BJNIO9Xe8+pv3BCSfDOr1RRo0dqK7a4U+yMcpAV5C59URWXFq52aRhpB+72 RRDEN8iO12xtH595s= X-Received: by 2002:a05:622a:c85:b0:519:e020:6087 with SMTP id d75a77b69052e-5213c013438mr183324131cf.11.1784646002245; Tue, 21 Jul 2026 08:00:02 -0700 (PDT) X-Received: by 2002:a05:622a:c85:b0:519:e020:6087 with SMTP id d75a77b69052e-5213c013438mr183323661cf.11.1784646001609; Tue, 21 Jul 2026 08:00:01 -0700 (PDT) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1712a5f837sm615968066b.32.2026.07.21.08.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 08:00:00 -0700 (PDT) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Loic Poulain , Hans de Goede Subject: [PATCH v2 1/7] libcamera: V4L2Subdevice: Add whence argument to [get|set]Selection() Date: Tue, 21 Jul 2026 16:59:51 +0200 Message-ID: <20260721145958.68489-2-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721145958.68489-1-johannes.goede@oss.qualcomm.com> References: <20260721145958.68489-1-johannes.goede@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: JEY2GDOIFrFtpwc0rh_lJItj3JT_adKL X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIxMDE1OCBTYWx0ZWRfX4C55jp9GtyEK s/aJ6+bC3TiXLBin2FN85vkQu/wjhUnRV5XHI6hdv7oOarFqo/Q4jS4Oanxyhx2G3m6pnSyQ7cq ep+wY4Z8jT06fQJ6nbQPNGmiMFj7BG4= X-Proofpoint-GUID: JEY2GDOIFrFtpwc0rh_lJItj3JT_adKL X-Authority-Analysis: v=2.4 cv=Sb7HsPRu c=1 sm=1 tr=0 ts=6a5f8974 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=xqWC_Br6kY4A:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=BV3TIWPM9q02PJwuZ20A:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIxMDE1OCBTYWx0ZWRfX28oV5yqvvMIK z2q+FGkwk3OAUZEdtWB/n3cCFOndNLOT4pjdIR7Tdiq6wQtWkhct0Q6WvvCEqwWU7xCRlFCoGID 5iNjBQBvlqWkb1woX3geLG14SX0OCaxEG4WKq79y/IwGDXzJd0hLqtSwten30udjxhSkwJ9TPx1 FGmQG5L4L92TWkd7j9AsZwCH+Vpg4wqdg9NWNsGrA8VnAbVt7RzQbcL/lUbSFDxXDyhRV4Q71/i QSDcpP0UlchlWVp0xLGqPQ0/YyFdxGX5w9yB8hXWI1iDRlCoM1k589WUual88ZY9dP3mIF0n8o7 W09Em1GBrps0F9tqcN8GinU9AM5DNw8ABM1kHKr2lVqXz3SvZI8mVwP7D1lDMNl2HNuMWMTgazt t8EAgxWFpMnsg5AUC7DMki19hw3jeX69XqdcgXyNfrkeOz83UyeTo6f2X4XyM+DqPiPxCkKFyi4 ATfAQcg/JQMY0g1ODAA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293, Aquarius:18.0.1143, Hydra:6.1.134, FMLib:17.12.100.49 definitions=2026-07-21_03,2026-07-20_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607210158 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 whence argument to V4L2Subdevice::[get|set]Selection() allowing callers to specify that the operation should be applied to the try state, rather then always applying it to the active state. Signed-off-by: Hans de Goede --- include/libcamera/internal/v4l2_subdevice.h | 14 ++++++++------ src/libcamera/v4l2_subdevice.cpp | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c37a82afa..36848915f 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 a69de154e..8f9d4dbd9 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1171,17 +1171,19 @@ 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] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \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, 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; @@ -1205,11 +1207,13 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, /** * \fn V4L2Subdevice::getSelection(unsigned int pad, unsigned int target, - * Rectangle *rect) + * Rectangle *rect, Whence whence = ActiveFormat) * \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] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \return 0 on success or a negative error code otherwise */ @@ -1219,17 +1223,19 @@ int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target, * \param[in] stream The stream the rectangle is to be applied to * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[inout] rect The selection rectangle to be applied + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \todo Define a V4L2SelectionTarget enum for the selection 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; @@ -1258,11 +1264,13 @@ int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target, /** * \fn V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, - * Rectangle *rect) + * Rectangle *rect, Whence whence = ActiveFormat) * \brief Set selection rectangle \a rect for \a target * \param[in] pad The 0-indexed pad number the rectangle is to be applied to * \param[in] target The selection target defined by the V4L2_SEL_TGT_* flags * \param[inout] rect The selection rectangle to be applied + * \param[in] whence The format to get, \ref V4L2Subdevice::ActiveFormat + * "ActiveFormat" or \ref V4L2Subdevice::TryFormat "TryFormat" * * \todo Define a V4L2SelectionTarget enum for the selection target *