From patchwork Fri Nov 6 15:13:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 28790 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 A6BA8C3304 for ; Fri, 6 Nov 2026 15:13:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 757796A7D5; Fri, 6 Nov 2026 16:13:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="MRfJkANy"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="cRnL0G1N"; dkim-atps=neutral Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9296D6917D for ; Fri, 6 Nov 2026 16:13:52 +0100 (CET) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6A6F05QC2671820 for ; Fri, 6 Nov 2026 15:13:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= zEuDfvNyBI/3kEaxhabUhBY45YJLppM+BpglngAuO7Y=; b=MRfJkANy0AZCVDRK D8xjUtOzqcrDmMzlD/Z4UHWbofKjwVygjTvUgXfvbyuKt0IDFupe0hhJiJk7UUgB /rXTt75T2luYGxJvS4IbmLxqwVCkCqarL18T4LWMtNkoRteApBTJvxu5WqTVX5ij iWFwqyA6Ni1yN5YBzxxIrrPTpd7+sul/8acq6TBO05txVS43IlDtbUK2LoPlg5JU 2BlzPSyKsLlve4lFf2uNsMmSCSniuzPPm4xUwIzNfjR1iaAl+h0WBmdmuWj7jE08 zNtyOzNGK4SJ9WEjh6DoJ4QRhyl31ZV/z4X2Bjxq30cf6V7GEIwnVaOGjMaDvd/s uaTMIQ== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hs3pcbad1-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 06 Nov 2026 15:13:50 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93f322ef7d3so177650485a.0 for ; Fri, 06 Nov 2026 07:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1793978030; x=1794582830; darn=lists.libcamera.org; h=content-transfer-encoding:content-type: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=zEuDfvNyBI/3kEaxhabUhBY45YJLppM+BpglngAuO7Y=; b=cRnL0G1Nhwe2vtz18zBjo9bOKNdBeyRCcv1Bsy0uwm16wYlgnSZW7ziHqILhI9ibw8 dD+nXauEUbvwGqc426I3ArWjQSaVEwoklnT1jWULulrGrWSRyWapHNHRFR872sCsD2L+ Q/dJG5e9k9vqrGD1cVEwY6UmwqSgWy1rqwG4vnrl/dTz9GJU2WX+fZgNL14yhux8nHXe xaicPg0hssPqyLGGzcXWOCTk5Fn2Acg6lxptoqyTIKNVxJsk2bjC2nDN1dVzVJJB5J9e +R72jpwihN42yOvBNm+fK0uOoqA0K80p25eA8nqpwWowl58Tv/FuUaAbtyBak/jMTvrc tsNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793978030; x=1794582830; h=content-transfer-encoding:content-type: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=zEuDfvNyBI/3kEaxhabUhBY45YJLppM+BpglngAuO7Y=; b=Pex0jgdzfSfp2E1vowWDOEPe0EsUdSKeVCFfF0UpFpoRdglHVgzys5nyCp/FfgYB/B j0bbrGhTa9P4+g85L9X0BFCR6o0AqKF8neijQQchlSmMqaPR0g5yonDhOJNMqAVVO8d2 c4eHId0m7VLSZBz5hxsDy7urIB+yxFre+obVSflSyfagNJwpK7L52W0bjzt3oZRv3ok2 tdE4a4Iz54CAM/Gxm4ycDrjaVRLkkqqlDRvElNjHGowj79Esw1k/y1kRR7y6II5LL7PY mp2XQ8GnGQjwN19JIh7ap66wvoqHmStFPN8rh8zTyz1A8lw0hxXqKhzPAab8w5V9w3DE IWfg== X-Gm-Message-State: APuU4Z/+YvhWJNdVZvDt+qYDF1oTmz4JQT5m5UvEVL1L7zETzepwenwr MnWxhL4QRD3KXCSWgWw5snVohcHRLQgp2vtE7TORiFjPivE8BGZ0uzRGtV6FirHa4fz29a13+ws 9dxODXSmNq1q6rHOPGOAU03OQAeQkj/UP28+kqUc4Q3YXTONmfzpIHWQMsKLqeLcg9vt6kOTBkn 0BygV4VlRR X-Gm-Gg: AYBFou3pfgBxxdKVZlT2K2MlrOofRNAFScObWpNpdHlHtvl29mjq9BQvq69ByQQe/yc /EUoS0q/bDnsBVLzkSnY4yBfqqSHYJoOCuF6s1XG6PR2BWQpVuDLxnj39/XP6JUGs0isAxc77x4 x4CykgeCFOFOtivKHgOZj9kwxKwoQDHrbAeh8nkvANVOS8u3hV0GTIia/pzKlXsAlLomonG5IRu XAi8oI356Jof+UMDCHBvBj5TbZrH+NX5H1w1fx7OFnd/1jLR8YkFbCeSQmMAArgQ5Znyg/Bb/dW ZyMilweBHZJlH+PzEtbj2h8WrUC7Q9Dlr7ETT3nl8x6HXS3uUzLD2CVADCMLKlvuEx1MT1AVkPp r88nak6PIFqPGZloKIc6scpL8xLMWpkxj+bzBloKxwVgTl1TOodHNMjUwvbtNovkt7zK1nV/BlG vAZIABy366sykPsGKd+tSN5lmYDZ4t+AjiMaee2W4hkUde8Il9ayCZ3dYiygHQdAaV X-Received: by 2002:a05:620a:2b9a:b0:945:e23a:455c with SMTP id af79cd13be357-945f34d7864mr382186585a.20.1793978029650; Fri, 06 Nov 2026 07:13:49 -0800 (PST) X-Received: by 2002:a05:620a:2b9a:b0:945:e23a:455c with SMTP id af79cd13be357-945f34d7864mr382181385a.20.1793978029122; Fri, 06 Nov 2026 07:13:49 -0800 (PST) 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-c4d3569b856sm86042466b.46.2026.11.06.07.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2026 07:13:48 -0800 (PST) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Gjorgji Rosikopulos , Loic Poulain , Hans de Goede , Kieran Bingham , =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v3 1/7] libcamera: V4L2Subdevice: Add whence argument to [get|set]Selection() Date: Fri, 6 Nov 2026 16:13:35 +0100 Message-ID: <20261106151345.32491-2-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261106151345.32491-1-johannes.goede@oss.qualcomm.com> References: <20261106151345.32491-1-johannes.goede@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: SFSux-AVOd02OsP9JW4vORclnYr8DumB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA2MDA1OSBTYWx0ZWRfX6mM0N1nbHZar aVfk1NYqzIjvqkNBII1pVtvIotfCTAyTA5iQYG0r17nO6XC+hOr9BJpO8jgZKQL1vn4fGs4H50K WrkkNhEUigNc5o2Nj3VUwSw+pRqKQPhGil+v1Xv4nMioq5xgpo8YK6DUhn1r48upq5K0msXPXd1 C1IizRHh3MmMG2V/R26deco4m5H7ktG0OF/wwx48SkAPUqGF4VJUaqPSF3Q2BApwrnNUMcu4Db3 k6DerIUOO9h7OqWx5goNkQAiOMEYCRjmGuPt8LmmihnP2zysIDoepsSY+847uykt2r9gJ+mlLF8 /NW1vox8/9wrUGTEzeTfkmTRr+P/TAd2KCJM/EoDKRTZ0Kw7cYIwfVRJMX8W2egzTttCNInV6hS cdDnAYPO20bP8wv9FJX1ikkj142d/tbJW1RQYjH8zZNdjATlhEXGt3W36oFgcfUuHe2q+9ei9/y dVr5DQQ7Fk8SL279wlQ== X-Proofpoint-GUID: SFSux-AVOd02OsP9JW4vORclnYr8DumB X-Authority-Analysis: v=2.4 cv=TI3Q2Fla c=1 sm=1 tr=0 ts=6aedeeae cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=P1BnusSwAAAA:8 a=EUspDBNiAAAA:8 a=BV3TIWPM9q02PJwuZ20A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 a=D0XLA9XvdZm18NrgonBM:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTA2MDA1OSBTYWx0ZWRfXzRtlvTSf/ng/ uiYaD4XNhZcr+f83MsphwqF9wvNOp0RRpJDjT9K1BgFBjsk7WFiLwj6cNci+meECTSmt8pHvpcr S9F2G4h1Q7tIP+3VZCk5xY1BiPknJ2c= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293, Aquarius:18.0.1176, Hydra:6.1.138, FMLib:17.12.100.49 definitions=2026-11-06_05,2026-11-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611060059 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. Reviewed-by: Kieran Bingham Reviewed-by: Barnabás Pőcze 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 *