From nobody Mon Apr 6 23:17:57 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33CB33B6C0F; Tue, 17 Mar 2026 12:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773749398; cv=none; b=ipuu9aa55GXNDYD7aq6hUQbQ2fySbgCeF4j43iDPlS4yT2vb5CWiJhW009C+ZndZ7gUfGMddBi6t6XHumaf67iKaZtMjP+FDIM59bBDJfDoJ1NKCwfj7zPu/HckmT81aMoV1d5qv32vg5ot4Raqj/UV5ZE9EEkhPBzrNO+b2LHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773749398; c=relaxed/simple; bh=DPJnDdvkcI71JEwM7xlgTPDTft8Pz27VPtqaBDtOAbA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vz/04rNOQw4KI45MThCDl1xUtddTRx4njGf8kRazp1Rg1/tieRj1I0GHFli69b/BiamCKk0HyDg5dDNqLCNfY1rh4l2R4Flc9hdxYkzAwgTIr0I4y1oLX2jYXkQuqV0tJAcrwT4PZVppke5CVDwaRb2WsrdU5MfDVFJBWFVGbj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=UgLMpIDw; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UgLMpIDw" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EBD8B98A; Tue, 17 Mar 2026 13:08:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1773749323; bh=DPJnDdvkcI71JEwM7xlgTPDTft8Pz27VPtqaBDtOAbA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UgLMpIDwgWVPipn5/ZKC1TajoAC/++ZXvOa9SMg9SlG3QWLRPtSCs5njYAqu9z3fx I2c0emUJkWSOxk9TcMON26kyG7JeU3nz3rQJ87qPqB3v3ICWdyb6V/46fDqvxS9MVx L0bLm9vboIEOU5qMWxQF/1LiYeL/ULgKEGxNDx6E= From: Tomi Valkeinen Date: Tue, 17 Mar 2026 14:09:40 +0200 Subject: [PATCH v2 1/3] media: subdev: Improve v4l2_subdev_get_frame_desc_passthrough() kdoc Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260317-frame-desc-passthrough-impro-v2-1-0c93b437d85d@ideasonboard.com> References: <20260317-frame-desc-passthrough-impro-v2-0-0c93b437d85d@ideasonboard.com> In-Reply-To: <20260317-frame-desc-passthrough-impro-v2-0-0c93b437d85d@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2516; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=DPJnDdvkcI71JEwM7xlgTPDTft8Pz27VPtqaBDtOAbA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBpuUSQinFWxcl14dI2A/kQqWKZ/kZDSSixC690w P9pMOdcT/OJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCablEkAAKCRD6PaqMvJYe 9cWoD/wLkqDHUOh//2O+/9on2sJMnyg2yTOrUoltSjjfbiMrJEBFVJGTclxIQ6lUH5LeGHV2kiN C4HPhVKOjxHD3IV84KUfRuS3cx3E163/ZBDOhEoQrzCErH3M22J+Rultx9VGK3TiUXjhBdZyOfg SgXv3VPmZy2rzoXCo/rwxjzvCJ5iV8hE6JRHIxctdeM7h3QpDrHYOqdkYnQ0LYdW+oYVGeouhod Dy8w+SOQiStgiSdqvFChY22JvtWx24j2COV66ubjc+zf2tkTslYt+4uZGEpOarISS6gjoArg4BL Hy8/8qoYxNUUn2neYWdTFcBmNwrh2gtUFrvS2HepuAQu2VH2IWANzr1Mix+UXMUvv3xfMkYf1JH CgJk5HktWz1FL4eMm1LLns5lEE7NNJ+gDGAgYB3tbGBnnYS4gByCXIAcp/RT3CGR6cF8fGJZclt js0YB57mVPYqssbfnSzl/Q9SaEJGdtzofNphBPMMCeJrgAUaaL/Mn9VYirDGKKIzuXXpBb3U7y7 iUHGNB2242roIg6Ftv9fvhVsW+96BksX5DiQN76Gw6tfFdnswGnErwlDgsrw8QVsnA4chVelLoG is9oJbgGNtDHSSqFXyUw/vtu5nWh1NqzUV+CtRPtGnCgTPDfnLmZIvA3XdWAohilysQxXi7FP+7 nTRmZRh9CM5g/cw== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Improve the v4l2_subdev_get_frame_desc_passthrough() kernel doc: - Fix 'v4l2_get_frame_desc' operation to 'get_frame_desc' operation - Rewrite the body text to be more understandable and specific, and specifically mention the frame desc type handling. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- include/media/v4l2-subdev.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index e754ed3421c5..23c03ba7f84c 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1724,19 +1724,25 @@ int v4l2_subdev_s_stream_helper(struct v4l2_subdev = *sd, int enable); =20 /** * v4l2_subdev_get_frame_desc_passthrough() - Helper to implement the subd= ev - * v4l2_get_frame_desc operation in simple passthrough cases + * get_frame_desc operation in simple passthrough cases * @sd: The subdevice * @pad: The source pad index * @fd: The mbus frame desc * - * Subdevice drivers that only pass through the streams can use this helper - * to implement the &v4l2_subdev_pad_ops.v4l2_get_frame_desc operation. + * This helper implements get_frame_desc operation for subdevices that pass + * streams through without modification. It can be assigned directly as the + * .get_frame_desc callback in &v4l2_subdev_pad_ops. * - * The helper will call get_frame_desc on the subdevice's sources, create = a new - * frame desc which contains only the streams on the given source pad. The= data - * for each frame desc entry is copied directly from the data provided fro= m the - * calls to the subdevice's sources, with the exception of the 'stream' fi= eld - * which is set according to the subdevice's routing table. + * The helper iterates over the subdevice's sink pads, calls get_frame_des= c on + * the remote subdevice connected to each sink pad, and collects the frame= desc + * entries for streams that are routed to the given source pad according t= o the + * subdevice's routing table. Each entry is copied as-is from the upstream + * source, with the exception of the 'stream' field which is remapped to t= he + * source stream ID from the routing table. + * + * The frame desc type is taken from the first upstream source. If multiple + * sink pads are involved and the upstream sources report different frame = desc + * types, -EPIPE is returned. * * Return: 0 on success, or a negative error code otherwise. */ --=20 2.43.0 From nobody Mon Apr 6 23:17:57 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9C133BBA19; Tue, 17 Mar 2026 12:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773749401; cv=none; b=XbPGy7q0aVroM0AlD9pJ0uewvgAcmzupEAVGDKVaRpQYvYxCel53whTdxw9ky30e4exLYD2IiY06krPVCLusDLpXHNOiKfi+L14OA4MvFh9oYnL0n3qch84vdkSYnOGkv3QuXuMPkmnW1HACC0k9CxWXZETfA0bKT695VAFK4Uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773749401; c=relaxed/simple; bh=8sN9QwGz77K3Y0zsOpXU7uArFmzQe2gheap8pVeEnU4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WuQuycTzFSPNe+2z9nYkUhDPmgy2vQ06sYCXOebAGtRzjI9VcVNojji1toTCSaWN/bBOQfpuR5wAJMWT0QBoi0sMR7utMdjW/XypXUZcToDG+npoydpRNuRTuuaYOgO8XuYjYpfh2Y9OoXMwXr87OyUxMhZFY0Po/aft6lAoelQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=g7l47nzh; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="g7l47nzh" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 83D80BD2; Tue, 17 Mar 2026 13:08:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1773749323; bh=8sN9QwGz77K3Y0zsOpXU7uArFmzQe2gheap8pVeEnU4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g7l47nzhKxdxq0WnQ9WKbaubyK9DDy/rOWBN/K18yMks+nVSzEVcsQjUKhCOm7bMJ kYz8/ms/pzWqgPby5FljU566KXNs+zCRORK9IwREeCnFjIuc+onUgNE7/YZAOJA7B1 ILv4tJstWSyNEi8D/Vr9Q6fukVP95k1+INiKQf0g= From: Tomi Valkeinen Date: Tue, 17 Mar 2026 14:09:41 +0200 Subject: [PATCH v2 2/3] media: subdev: Minor v4l2_subdev_get_frame_desc_passthrough() cleanups Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260317-frame-desc-passthrough-impro-v2-2-0c93b437d85d@ideasonboard.com> References: <20260317-frame-desc-passthrough-impro-v2-0-0c93b437d85d@ideasonboard.com> In-Reply-To: <20260317-frame-desc-passthrough-impro-v2-0-0c93b437d85d@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2335; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=8sN9QwGz77K3Y0zsOpXU7uArFmzQe2gheap8pVeEnU4=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBpuUSRKhvAcYzmyNIFQ6TSJVZmeNPhmDyM7ko2w YES1+yKwouJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCablEkQAKCRD6PaqMvJYe 9QtEEACvn/pii3+0cC9wZ4C5VneHwojHz6kj48DtcJLnQ6W+HpNhDElBC7mtlvTUi+sYfAJZjXJ xd+BQNXiAGms1noS9X1F3Tq2qqBNdcCcFVoEFQl/TSGsgqU2Vwq5378IPkJAxfsg8b4f5isUzWn S7bfe03OkWbSsgEXjrBCsDLUfE2skhchjdMBAkOWRTaK7sVvPRWe12RMGOAbO0c4B3z94LGjImR F4SHU9EFD7LQXj1mV54R8GU3qEwxbF06VfmPWFhKWqQ9T+KxRzsFIvuC/fqiBslV8M5FM/RCEM9 nZdmVIz3I2MwZaFbIaqhfsewponVrHRudghRk0HDmRecwR24uIkwWNRhv+qFtcRqfMTbvDF916y tP/xGd8i59aNnkXr8GKiC5RKT73NpR9rf0PIXKL7jP4sJf4ZQjl9XUfeth/LXuzzLqA3s+UBQng ac+guOiWkRLasQbAnWKlFtyc2GEKW5LMcOCj9s+ZeT/sudUV99fuGsE08IgzCjgODqsAikAazgN 20APwYsR5W4wVe89zLZTLgQgx4m7iEKUrUonZZe9Sy1PCCLSf0/V2y5GNhsISof2BQY4cmhVWPb dz89lSwCOaQGyTAXcfdCBfAOwX/E7YE5kfktCZqqcTbtvoqlcGA2WU3jl16iWDGJ9OL9qM1jF5y netQnegA5VsyfRw== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Minor code cleanups, no functional change. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-subdev.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-cor= e/v4l2-subdev.c index 9efd14d4026f..2757378c628a 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -2549,14 +2549,13 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v= 4l2_subdev *sd, unsigned int pad, struct v4l2_mbus_frame_desc *fd) { - const struct media_pad *pads =3D sd->entity.pads; struct media_pad *local_sink_pad; struct v4l2_subdev_route *route; struct v4l2_subdev_state *state; struct device *dev =3D sd->dev; int ret =3D 0; =20 - if (WARN_ON(!(pads[pad].flags & MEDIA_PAD_FL_SOURCE))) + if (WARN_ON(!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))) return -EINVAL; =20 state =3D v4l2_subdev_lock_and_get_active_state(sd); @@ -2577,7 +2576,6 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l= 2_subdev *sd, struct v4l2_mbus_frame_desc_entry *source_entry =3D NULL; struct media_pad *remote_source_pad; struct v4l2_subdev *remote_sd; - unsigned int i; =20 if (route->source_pad !=3D pad || route->sink_pad !=3D local_sink_pad->index) @@ -2622,7 +2620,7 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l= 2_subdev *sd, } } =20 - for (i =3D 0; i < source_fd.num_entries; i++) { + for (unsigned int i =3D 0; i < source_fd.num_entries; i++) { if (source_fd.entry[i].stream =3D=3D route->sink_stream) { source_entry =3D &source_fd.entry[i]; break; @@ -2630,7 +2628,7 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l= 2_subdev *sd, } =20 if (!source_entry) { - dev_dbg(sd->dev, + dev_dbg(dev, "Failed to find stream %u from source frame desc\n", route->sink_stream); ret =3D -EPIPE; @@ -2638,7 +2636,7 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l= 2_subdev *sd, } =20 if (fd->num_entries >=3D V4L2_FRAME_DESC_ENTRY_MAX) { - dev_dbg(sd->dev, "Frame desc entry limit reached\n"); + dev_dbg(dev, "Frame desc entry limit reached\n"); ret =3D -ENOSPC; goto out_unlock; } --=20 2.43.0 From nobody Mon Apr 6 23:17:57 2026 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 420623BC674; Tue, 17 Mar 2026 12:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773749401; cv=none; b=QFtgmI28MJfugoyqd3bpjZUxDCQ3oIi8qzQuQhWjJvtZpF2vlAsKD40J1IwkYS+YbeVSupYY2u9JbsawYMvR0WKUmAmZg6upJV8LAthQnhJn/UkwMRhp625lKVmlrldCQCY2weQj23tLEOwmql6GSt1v+LRXvMZxmpDh4yXAngk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773749401; c=relaxed/simple; bh=cWXO8R44lS302LlLp0FBwxZcXLjXHWDn8I6yXfunBBs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rXuXdv3Ow94GDpEgzy89Q6owCqdn3rOlXp3z7xlrDD7cU7JwkQDLFEVzAtuGtoP8YJNFzK0HAczMcx6yNVBPrAf7CZB0ImKUuA5zHzk+GizlQjMJFznV5TSPyefzr1j3v/98d3uJeEDAk8djrgoxiCHeaMMkshs2ZbXz6LJBhWM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=H0U4AvRp; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="H0U4AvRp" Received: from [127.0.1.1] (91-158-153-178.elisa-laajakaista.fi [91.158.153.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1A32AC6C; Tue, 17 Mar 2026 13:08:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1773749324; bh=cWXO8R44lS302LlLp0FBwxZcXLjXHWDn8I6yXfunBBs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=H0U4AvRpelfkBPuuy1zHgTPQWa2X23wKgHzXeUFOCtycfRqBEBetS0gs1jSvBsjbm 1H6W1IQ73oSwbXO/rTkpOv7YwL+uFJx09kdzT+oHJ7um1U7dtbCOdpaUUBNrqaMO6E x4OC8ngXRleYJq1x2Yry5kiNhk9dvVa4Z5Jnv6q4= From: Tomi Valkeinen Date: Tue, 17 Mar 2026 14:09:42 +0200 Subject: [PATCH v2 3/3] media: subdev: Split v4l2_subdev_get_frame_desc_passthrough() into locked and unlocked Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260317-frame-desc-passthrough-impro-v2-3-0c93b437d85d@ideasonboard.com> References: <20260317-frame-desc-passthrough-impro-v2-0-0c93b437d85d@ideasonboard.com> In-Reply-To: <20260317-frame-desc-passthrough-impro-v2-0-0c93b437d85d@ideasonboard.com> To: Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jai Luthra , Tomi Valkeinen X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=8102; i=tomi.valkeinen+renesas@ideasonboard.com; h=from:subject:message-id; bh=cWXO8R44lS302LlLp0FBwxZcXLjXHWDn8I6yXfunBBs=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBpuUSRGvmnJGgDzn7WbiYXoE1AiHTYQLsLIkL6F 0RoLvFWKI+JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCablEkQAKCRD6PaqMvJYe 9cP9EACcldRYRHtx3Jdro4a1h89CLNGpjtHGFAjo+Wa7Sab2APDWPTC/E0w4UHhnWWnaQnmrNY+ 7qL8yVrfEZCtzcsBWih9zPD5M+mTCSYhDovQG6eyQVw32xjh8f2Xq0d95wp9mUDUTVugfCQ27RK a3SzPM5cW6AxC2smH0eX/BaourxwEH7vMzx5JW85lmsFQlSO7+R99zPIJYpD08uDPTxajoXIs4X cx0O+CDSnXDQmICxqU94RynkpzTjTLoWwTJQqMFLyqH2SregxtpPvi2c6c0MzALMcyJCJaSQzV+ oAenADPJZeAL+8/5tFGpyO28+UMcN0bPG9tjH9l9S5F4K5UtZZfbUnlZCOidJ9E8vzZgQjfT5/b VcAonvtOpolDZQi2/wuCYLIvFntzYHHDXA3brQZZpMcQbEZ/Op9Ir43rPjb19/pSXJBV32GvZ2l NzF4xCtpFXim8xEm4DOMLZOzL4NqDYt4s3up2rd+hMeuO/mqlaTNG3tDkmrVdMXo8A+/VSP9kVH MMBKayNSUy73LYOPp03xgJBynF4Hh4XK02Nlr11XYMpHb1KHfrgdLoSyLMEqxH17CoG2cBqruFE aoSvDCO2lFrrMlcxC7ezSV1Bi7X7JskLeK58k4GcQK3bWS64AsXu67iTfx3aSeo0/J1RaWvs2Q5 LQ3aiZScGU1msLg== X-Developer-Key: i=tomi.valkeinen+renesas@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 The recently added v4l2_subdev_get_frame_desc_passthrough() can be used directly as an implementation for .get_frame_desc subdev op. However, in some cases the drivers may want to add some customizations, while the bulk of the work is still identical to what v4l2_subdev_get_frame_desc_passthrough() does. Current locking scheme makes this impossible to do properly. Split v4l2_subdev_get_frame_desc_passthrough() into two functions: __v4l2_subdev_get_frame_desc_passthrough(), which takes a locked subdev state as a parameter, instead of locking and getting the active state internally. Other than that, it does the same as v4l2_subdev_get_frame_desc_passthrough() used to do. v4l2_subdev_get_frame_desc_passthrough(), which locks the active state and calls __v4l2_subdev_get_frame_desc_passthrough(). In other words, v4l2_subdev_get_frame_desc_passthrough() works as before, but drivers can now alternatively add custom .get_frame_desc code and call v4l2_subdev_get_frame_desc_passthrough(). An example use case is with DS90UB953 serializer: in normal use the serializer passes through everything, but when test-pattern-generator (TPG) is used, an internal TPG source is used. After this commit, the UB953 get_frame_desc() can lock the state, look at the routing table to see if we're in normal or TPG mode, then either call __v4l2_subdev_get_frame_desc_passthrough() if in normal mode, or construct a TPG frame desc if in TPG mode. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-subdev.c | 48 ++++++++++++++++++++-----------= ---- include/media/v4l2-subdev.h | 38 +++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-cor= e/v4l2-subdev.c index 2757378c628a..b73ccd1c83d2 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -2545,21 +2545,21 @@ int v4l2_subdev_s_stream_helper(struct v4l2_subdev = *sd, int enable) } EXPORT_SYMBOL_GPL(v4l2_subdev_s_stream_helper); =20 -int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd, - unsigned int pad, - struct v4l2_mbus_frame_desc *fd) +int __v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + unsigned int pad, + struct v4l2_mbus_frame_desc *fd) { struct media_pad *local_sink_pad; struct v4l2_subdev_route *route; - struct v4l2_subdev_state *state; struct device *dev =3D sd->dev; int ret =3D 0; =20 + lockdep_assert_held(state->lock); + if (WARN_ON(!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))) return -EINVAL; =20 - state =3D v4l2_subdev_lock_and_get_active_state(sd); - /* Iterate over sink pads */ media_entity_for_each_pad(&sd->entity, local_sink_pad) { struct v4l2_mbus_frame_desc source_fd; @@ -2586,15 +2586,12 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v= 4l2_subdev *sd, if (!remote_source_pad) { dev_dbg(dev, "Failed to find remote pad for sink pad %u\n", local_sink_pad->index); - ret =3D -EINVAL; - goto out_unlock; + return -EINVAL; } =20 remote_sd =3D media_entity_to_v4l2_subdev(remote_source_pad->entity); - if (!remote_sd) { - ret =3D -EINVAL; - goto out_unlock; - } + if (!remote_sd) + return -EINVAL; =20 ret =3D v4l2_subdev_call(remote_sd, pad, get_frame_desc, @@ -2604,7 +2601,7 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l= 2_subdev *sd, dev_err(dev, "Failed to get frame desc from remote subdev %s\n", remote_sd->name); - goto out_unlock; + return ret; } =20 have_source_fd =3D true; @@ -2615,8 +2612,7 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l= 2_subdev *sd, dev_err(dev, "Frame desc type mismatch: %u !=3D %u\n", fd->type, source_fd.type); - ret =3D -EPIPE; - goto out_unlock; + return -EPIPE; } } =20 @@ -2631,14 +2627,12 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v= 4l2_subdev *sd, dev_dbg(dev, "Failed to find stream %u from source frame desc\n", route->sink_stream); - ret =3D -EPIPE; - goto out_unlock; + return -EPIPE; } =20 if (fd->num_entries >=3D V4L2_FRAME_DESC_ENTRY_MAX) { dev_dbg(dev, "Frame desc entry limit reached\n"); - ret =3D -ENOSPC; - goto out_unlock; + return -ENOSPC; } =20 fd->entry[fd->num_entries] =3D *source_entry; @@ -2649,7 +2643,21 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4= l2_subdev *sd, } } =20 -out_unlock: + return 0; +} +EXPORT_SYMBOL_GPL(__v4l2_subdev_get_frame_desc_passthrough); + +int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd, + unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct v4l2_subdev_state *state; + int ret; + + state =3D v4l2_subdev_lock_and_get_active_state(sd); + + ret =3D __v4l2_subdev_get_frame_desc_passthrough(sd, state, pad, fd); + v4l2_subdev_unlock_state(state); =20 return ret; diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 23c03ba7f84c..d256b7ec8f84 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1723,15 +1723,15 @@ int v4l2_subdev_disable_streams(struct v4l2_subdev = *sd, u32 pad, int v4l2_subdev_s_stream_helper(struct v4l2_subdev *sd, int enable); =20 /** - * v4l2_subdev_get_frame_desc_passthrough() - Helper to implement the subd= ev - * get_frame_desc operation in simple passthrough cases + * __v4l2_subdev_get_frame_desc_passthrough - Helper to implement the + * subdev get_frame_desc operation in simple passthrough cases * @sd: The subdevice + * @state: The locked subdevice active state * @pad: The source pad index * @fd: The mbus frame desc * - * This helper implements get_frame_desc operation for subdevices that pass - * streams through without modification. It can be assigned directly as the - * .get_frame_desc callback in &v4l2_subdev_pad_ops. + * This helper implements the get_frame_desc operation for subdevices that= pass + * streams through without modification. * * The helper iterates over the subdevice's sink pads, calls get_frame_des= c on * the remote subdevice connected to each sink pad, and collects the frame= desc @@ -1744,6 +1744,34 @@ int v4l2_subdev_s_stream_helper(struct v4l2_subdev *= sd, int enable); * sink pads are involved and the upstream sources report different frame = desc * types, -EPIPE is returned. * + * The caller must hold the subdevice's active state lock. This variant is + * intended for drivers that need to perform additional work around the + * passthrough frame descriptor collection. Drivers that do not need any + * customization should use v4l2_subdev_get_frame_desc_passthrough() inste= ad. + * + * Return: 0 on success, or a negative error code otherwise. + */ +int __v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + unsigned int pad, + struct v4l2_mbus_frame_desc *fd); + +/** + * v4l2_subdev_get_frame_desc_passthrough() - Helper to implement the subd= ev + * get_frame_desc operation in simple passthrough cases + * @sd: The subdevice + * @pad: The source pad index + * @fd: The mbus frame desc + * + * This function locks the subdevice's active state, calls + * __v4l2_subdev_get_frame_desc_passthrough(), and unlocks the state. + * + * This function can be assigned directly as the .get_frame_desc callback = in + * &v4l2_subdev_pad_ops for subdevices that pass streams through without + * modification. Drivers that need to perform additional work should use + * __v4l2_subdev_get_frame_desc_passthrough() in their custom + * .get_frame_desc implementation instead. + * * Return: 0 on success, or a negative error code otherwise. */ int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd, --=20 2.43.0