From patchwork Thu Mar 2 09:57:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13157027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44A0AC6FA8E for ; Thu, 2 Mar 2023 10:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjCBKAO (ORCPT ); Thu, 2 Mar 2023 05:00:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjCBJ7N (ORCPT ); Thu, 2 Mar 2023 04:59:13 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 306A248E2D for ; Thu, 2 Mar 2023 01:58:17 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6157798C; Thu, 2 Mar 2023 10:57:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1677751073; bh=3pNb+r4GCc1U5jxrZ2M009sao4/pMCjL/TvBNoa43k4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KJELN3+s5hDkRaRUkTNHXPL4TpmWB7l5arbydYzeyuEgItJFqk1Mgxx5Nr8tYCnui lDatTttgSMSwPf3cM0djA9IQXW5OPdEVaRdRKnQivrCqsJ4maJRyb/NlHMeS2qcSyv /ocvEMgofTljg6DhjXwJg84WoSJMEcWTolTNq4nY= From: Tomi Valkeinen To: Mauro Carvalho Chehab , Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, Jacopo Mondi Cc: Tomi Valkeinen Subject: [PATCH v2 1/3] media: subdev: Use 'shall' instead of 'may' in route validation Date: Thu, 2 Mar 2023 11:57:46 +0200 Message-Id: <20230302095748.100898-2-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302095748.100898-1-tomi.valkeinen@ideasonboard.com> References: <20230302095748.100898-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Route validation docs use the word 'may'. Change that to 'shall' for emphasis. Signed-off-by: Tomi Valkeinen Reviewed-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-subdev.c | 2 +- include/media/v4l2-subdev.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index dff1d9be7841..8308d20f1bd1 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1694,7 +1694,7 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, /* * V4L2_SUBDEV_ROUTING_NO_STREAM_MIX: Streams on the same pad - * may not be routed to streams on different pads. + * shall not be routed to streams on different pads. */ if (disallow & V4L2_SUBDEV_ROUTING_NO_STREAM_MIX) { if (remote_pads[route->sink_pad] != U32_MAX && diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 17773be4a4ee..3649f11a4c35 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1638,13 +1638,13 @@ u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state, * enum v4l2_subdev_routing_restriction - Subdevice internal routing restrictions * * @V4L2_SUBDEV_ROUTING_NO_1_TO_N: - * an input stream may not be routed to multiple output streams (stream + * an input stream shall not be routed to multiple output streams (stream * duplication) * @V4L2_SUBDEV_ROUTING_NO_N_TO_1: - * multiple input streams may not be routed to the same output stream + * multiple input streams shall not be routed to the same output stream * (stream merging) * @V4L2_SUBDEV_ROUTING_NO_STREAM_MIX: - * streams on the same pad may not be routed to streams on different pads + * streams on the same pad shall not be routed to streams on different pads * @V4L2_SUBDEV_ROUTING_ONLY_1_TO_1: * only non-overlapping 1-to-1 stream routing is allowed (a combination of * @V4L2_SUBDEV_ROUTING_NO_1_TO_N and @V4L2_SUBDEV_ROUTING_NO_N_TO_1) From patchwork Thu Mar 2 09:57:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13157030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5749BC6FA8E for ; Thu, 2 Mar 2023 10:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbjCBKBR (ORCPT ); Thu, 2 Mar 2023 05:01:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbjCBKAm (ORCPT ); Thu, 2 Mar 2023 05:00:42 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8372986AE for ; Thu, 2 Mar 2023 02:00:10 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 058249CA; Thu, 2 Mar 2023 10:57:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1677751074; bh=y408INqgborv/n2LPouFfV3nOVRWuxi9KgDdmCpBHKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FCq697lKHxgj8025Ca3aCu5cq5Xt98NtItc9jUBE55wvjGBjqO6QigszPZ8Wiroyj wH54AoY7OJZ8aXql6nomzo5Y7jZ748QHET0OOYuQFmRUBnnmLGBWjWtNTmNwrO4IlR DGitr6CMPcSUNnfDbe7mFoX+pnBWTKuvB+8og4TA= From: Tomi Valkeinen To: Mauro Carvalho Chehab , Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, Jacopo Mondi Cc: Tomi Valkeinen , Andy Shevchenko Subject: [PATCH v2 2/3] media: subdev: Split V4L2_SUBDEV_ROUTING_NO_STREAM_MIX Date: Thu, 2 Mar 2023 11:57:47 +0200 Message-Id: <20230302095748.100898-3-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302095748.100898-1-tomi.valkeinen@ideasonboard.com> References: <20230302095748.100898-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org V4L2_SUBDEV_ROUTING_NO_STREAM_MIX routing validation flag means that all routes from a sink pad must go to the same source pad and all routes going to the same source pad must originate from the same sink pad. This does not cover all use cases. For example, if a device routes all streams from a single sink pad to any of the source pads, but streams from multiple sink pads can go to the same source pad, the current flag is too restrictive. Split the flag into two parts, V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX and V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX, which add the restriction only on one side of the device. Together they mean the same as V4L2_SUBDEV_ROUTING_NO_STREAM_MIX. Signed-off-by: Tomi Valkeinen Reviewed-by: Andy Shevchenko Reviewed-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-subdev.c | 15 +++++++++++---- include/media/v4l2-subdev.h | 17 ++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 8308d20f1bd1..8e91f169ad9e 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1693,10 +1693,10 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, } /* - * V4L2_SUBDEV_ROUTING_NO_STREAM_MIX: Streams on the same pad - * shall not be routed to streams on different pads. + * V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX: all streams from a + * sink pad must be routed to a single source pad. */ - if (disallow & V4L2_SUBDEV_ROUTING_NO_STREAM_MIX) { + if (disallow & V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX) { if (remote_pads[route->sink_pad] != U32_MAX && remote_pads[route->sink_pad] != route->source_pad) { dev_dbg(sd->dev, @@ -1705,6 +1705,14 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, goto out; } + remote_pads[route->sink_pad] = route->source_pad; + } + + /* + * V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX: all streams on a + * source pad must originate from a single sink pad. + */ + if (disallow & V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX) { if (remote_pads[route->source_pad] != U32_MAX && remote_pads[route->source_pad] != route->sink_pad) { dev_dbg(sd->dev, @@ -1713,7 +1721,6 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, goto out; } - remote_pads[route->sink_pad] = route->source_pad; remote_pads[route->source_pad] = route->sink_pad; } diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 3649f11a4c35..fb4fddb9b599 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1643,19 +1643,30 @@ u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state, * @V4L2_SUBDEV_ROUTING_NO_N_TO_1: * multiple input streams shall not be routed to the same output stream * (stream merging) - * @V4L2_SUBDEV_ROUTING_NO_STREAM_MIX: - * streams on the same pad shall not be routed to streams on different pads + * @V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX: + * all streams from a sink pad must be routed to a single source pad + * @V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX: + * all streams on a source pad must originate from a single sink pad * @V4L2_SUBDEV_ROUTING_ONLY_1_TO_1: * only non-overlapping 1-to-1 stream routing is allowed (a combination of * @V4L2_SUBDEV_ROUTING_NO_1_TO_N and @V4L2_SUBDEV_ROUTING_NO_N_TO_1) + * @V4L2_SUBDEV_ROUTING_NO_STREAM_MIX: + * all streams from a sink pad must be routed to a single source pad, and + * that source pad shall not get routes from any other sink pad + * (a combination of @V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX and + * @V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX) */ enum v4l2_subdev_routing_restriction { V4L2_SUBDEV_ROUTING_NO_1_TO_N = BIT(0), V4L2_SUBDEV_ROUTING_NO_N_TO_1 = BIT(1), - V4L2_SUBDEV_ROUTING_NO_STREAM_MIX = BIT(2), + V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX = BIT(2), + V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX = BIT(3), V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 = V4L2_SUBDEV_ROUTING_NO_1_TO_N | V4L2_SUBDEV_ROUTING_NO_N_TO_1, + V4L2_SUBDEV_ROUTING_NO_STREAM_MIX = + V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX | + V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX, }; /** From patchwork Thu Mar 2 09:57:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13157029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E749C6FA8E for ; Thu, 2 Mar 2023 10:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229540AbjCBKAp (ORCPT ); Thu, 2 Mar 2023 05:00:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbjCBKAd (ORCPT ); Thu, 2 Mar 2023 05:00:33 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E131846158 for ; Thu, 2 Mar 2023 01:59:56 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AC2A99D9; Thu, 2 Mar 2023 10:57:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1677751075; bh=otiRC0BQdJgKPfjBrBRQAMDUNyp1x42gTyLKsgyg4GM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmBzRKUwAQGLJ/az30QEh69a9reQ2wM7ZZMTgUCMEABzZonyRDrGa7lDLznl4dF+Y rjj38SafAHcmVLV78rJT0lUrTmKg64DsdSD5tSe5txEWqNrQbY4Mr7eDW2KuPIfGgm A0KGFAekJce7w8jLJ2AHt8lLLRHmadKOlhCZE+qM= From: Tomi Valkeinen To: Mauro Carvalho Chehab , Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, Jacopo Mondi Cc: Tomi Valkeinen Subject: [PATCH v2 3/3] media: subdev: Add V4L2_SUBDEV_ROUTING_NO_MULTIPLEXING Date: Thu, 2 Mar 2023 11:57:48 +0200 Message-Id: <20230302095748.100898-4-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302095748.100898-1-tomi.valkeinen@ideasonboard.com> References: <20230302095748.100898-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A common case with subdev routing is that on the subdevice just before the DMA engines (video nodes), no multiplexing is allowed on the source pads, as the DMA engine can only handle a single stream. In some other situations one might also want to do the same check on the sink side. Add new routing validation flags to check these: V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING and V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING. Signed-off-by: Tomi Valkeinen Reviewed-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-subdev.c | 36 ++++++++++++++++++++++++--- include/media/v4l2-subdev.h | 11 ++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 8e91f169ad9e..3650eb3a413f 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1664,7 +1664,8 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, unsigned int i, j; int ret = -EINVAL; - if (disallow & V4L2_SUBDEV_ROUTING_NO_STREAM_MIX) { + if (disallow & (V4L2_SUBDEV_ROUTING_NO_STREAM_MIX | + V4L2_SUBDEV_ROUTING_NO_MULTIPLEXING)) { remote_pads = kcalloc(sd->entity.num_pads, sizeof(*remote_pads), GFP_KERNEL); if (!remote_pads) @@ -1704,8 +1705,6 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, i, "sink"); goto out; } - - remote_pads[route->sink_pad] = route->source_pad; } /* @@ -1720,7 +1719,38 @@ int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, i, "source"); goto out; } + } + + /* + * V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING: Pads on the sink + * side can not do stream multiplexing, i.e. there can be only + * a single stream in a sink pad. + */ + if (disallow & V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING) { + if (remote_pads[route->sink_pad] != U32_MAX) { + dev_dbg(sd->dev, + "route %u attempts to multiplex on %s pad %u\n", + i, "sink", route->sink_pad); + goto out; + } + } + /* + * V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING: Pads on the + * source side can not do stream multiplexing, i.e. there can + * be only a single stream in a source pad. + */ + if (disallow & V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING) { + if (remote_pads[route->source_pad] != U32_MAX) { + dev_dbg(sd->dev, + "route %u attempts to multiplex on %s pad %u\n", + i, "source", route->source_pad); + goto out; + } + } + + if (remote_pads) { + remote_pads[route->sink_pad] = route->source_pad; remote_pads[route->source_pad] = route->sink_pad; } diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index fb4fddb9b599..fa300019844b 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1647,6 +1647,10 @@ u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state, * all streams from a sink pad must be routed to a single source pad * @V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX: * all streams on a source pad must originate from a single sink pad + * @V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING: + * source pads shall not contain multiplexed streams + * @V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING: + * sink pads shall not contain multiplexed streams * @V4L2_SUBDEV_ROUTING_ONLY_1_TO_1: * only non-overlapping 1-to-1 stream routing is allowed (a combination of * @V4L2_SUBDEV_ROUTING_NO_1_TO_N and @V4L2_SUBDEV_ROUTING_NO_N_TO_1) @@ -1655,18 +1659,25 @@ u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state, * that source pad shall not get routes from any other sink pad * (a combination of @V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX and * @V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX) + * @V4L2_SUBDEV_ROUTING_NO_MULTIPLEXING: + * no multiplexed streams allowed on either source or sink sides. */ enum v4l2_subdev_routing_restriction { V4L2_SUBDEV_ROUTING_NO_1_TO_N = BIT(0), V4L2_SUBDEV_ROUTING_NO_N_TO_1 = BIT(1), V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX = BIT(2), V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX = BIT(3), + V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING = BIT(4), + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING = BIT(5), V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 = V4L2_SUBDEV_ROUTING_NO_1_TO_N | V4L2_SUBDEV_ROUTING_NO_N_TO_1, V4L2_SUBDEV_ROUTING_NO_STREAM_MIX = V4L2_SUBDEV_ROUTING_NO_SINK_STREAM_MIX | V4L2_SUBDEV_ROUTING_NO_SOURCE_STREAM_MIX, + V4L2_SUBDEV_ROUTING_NO_MULTIPLEXING = + V4L2_SUBDEV_ROUTING_NO_SINK_MULTIPLEXING | + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING, }; /**