From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D5ACC418A46; Mon, 31 Aug 2026 13:21:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182498; cv=none; b=ijjWC4nv7xlFM7MGiOw7rjhnSBQBOIQkfBYncMqcuuYl7KK0UX7MBtSpkXotK659+ILnRX+A5ReUf1sPCr7W8tKc+l0ypxIDKhsxdDOjKiZkgBSLUEO+mmzPSpcqVcdVenxZ47ytz84RTxk7R89ZFqUsgt2wShsr76ePMhBQ6uE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182498; c=relaxed/simple; bh=cpDukcPxVJzXko/L0eFDwxYderoS/dpMlVO2IjtjjHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lRfSxUzIHtLcmgsY4elTsylV0vvRukOLcJhJGQQzWiM0KZXqcinEXo6cD/eSRHaFYRkBcoP0Z1auBPSaHwXEDTo+tNxGaSv/nwVcYr22mnSTnUX4fwmPfs3FRsQz8VUPBXK2EFXGR/1j+H88SmpR4CcETx3UsGBsCw/WvZMs/h4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lDcwXZDi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lDcwXZDi" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8DD3DC2BCFA; Mon, 31 Aug 2026 13:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788182498; bh=cpDukcPxVJzXko/L0eFDwxYderoS/dpMlVO2IjtjjHE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lDcwXZDilNiSvoPDbe5iIj6E2ckVnTMVgq4WQTYkjYMpKj/JI0ZGfnQ6AbuB0lyEy W+/vBKUn94IqMyhuGupAva+r8A+YXXGxBlbgdp/h0ozuhcK5h6SABvT/vPqBlwFX3d 2/uRSmvg0k1yHUR4WU6nor7vZE75sogtUz3ZI8XHmQe2DiBKSdsiSd9D23qS7ptruv vGR6zVpn8r6Uv458cFhmxC95P5Y+3yjy14XWJRpvtm+dQOes4VaSBlCzCwSVEf8RwX IyeY8H3U7h47yp7uCWl8UD9bDTfo78k1w2YE4eflN0LXORuAKRxte2qr63L9pUwC2V Ze2zWa8WP1skQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 684A9C624A4; Mon, 31 Aug 2026 13:21:38 +0000 (UTC) From: Dumitru Ceclan via B4 Relay Date: Mon, 31 Aug 2026 16:21:20 +0300 Subject: [PATCH v16 01/22] media: mc: Add INTERNAL pad flag Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260831-gmsl2-3_serdes-v16-1-4fa6e08bb514@analog.com> References: <20260831-gmsl2-3_serdes-v16-0-4fa6e08bb514@analog.com> In-Reply-To: <20260831-gmsl2-3_serdes-v16-0-4fa6e08bb514@analog.com> To: Tomi Valkeinen , Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart , Julien Massot , Rob Herring , =?utf-8?q?Niklas_S=C3=B6derlund?= , Greg Kroah-Hartman Cc: Tomi Valkeinen , Dumitru Ceclan , mitrutzceclan@gmail.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-staging@lists.linux.dev, linux-gpio@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Martin Hecht , Andrian Suciu X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788182495; l=4211; i=dumitru.ceclan@analog.com; s=20240313; h=from:subject:message-id; bh=j75z8BDeqCgnWrq6GF1INTACeRkTAkS70gXnWGmC/2E=; b=URHaBEmEfzoWoM+e20CYqne/cfYPDI1bpsWxAN3uLVV4VL7iOIMs9Rh37U0tIIwic9c9PkDZg pzn1HaapvlFA4zGOt6ZEpWpMbJsAgPNZTB3wMooh0Jz0tcChLkhpEId X-Developer-Key: i=dumitru.ceclan@analog.com; a=ed25519; pk=HdqMlVyrcazwoiai7oN6ghU+Bj1pusGUFRl30jhS7Bo= X-Endpoint-Received: by B4 Relay for dumitru.ceclan@analog.com/20240313 with auth_id=140 X-Original-From: Dumitru Ceclan Reply-To: dumitru.ceclan@analog.com From: Sakari Ailus Internal sink pads will be used as routing endpoints in V4L2 [GS]_ROUTING IOCTLs, to indicate that the stream begins in the entity. Internal sink pads are pads that have both SINK and INTERNAL flags set. Also prevent creating links to pads that have been flagged as internal and initialising SOURCE pads with INTERNAL flag set. Signed-off-by: Sakari Ailus Reviewed-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- .../userspace-api/media/mediactl/media-types.rst | 9 +++++++++ drivers/media/mc/mc-entity.c | 15 ++++++++++++--- include/uapi/linux/media.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Documentation/userspace-api/media/mediactl/media-types.rst b/Documentation/userspace-api/media/mediactl/media-types.rst index 6332e8395263..200c37a1da26 100644 --- a/Documentation/userspace-api/media/mediactl/media-types.rst +++ b/Documentation/userspace-api/media/mediactl/media-types.rst @@ -361,6 +361,7 @@ Types and flags used to represent the media graph elements .. _MEDIA-PAD-FL-SINK: .. _MEDIA-PAD-FL-SOURCE: .. _MEDIA-PAD-FL-MUST-CONNECT: +.. _MEDIA-PAD-FL-INTERNAL: .. flat-table:: Media pad flags :header-rows: 0 @@ -381,6 +382,14 @@ Types and flags used to represent the media graph elements enabled links even when this flag isn't set; the absence of the flag doesn't imply there is none. + * - ``MEDIA_PAD_FL_INTERNAL`` + - The internal flag indicates an internal pad that has no external + connections. As they are internal to entities, internal pads shall not + be connected with links. + + The internal flag may currently be present only in a sink pad where it + indicates that the :ref:``stream `` originates + from within the entity. One and only one of ``MEDIA_PAD_FL_SINK`` and ``MEDIA_PAD_FL_SOURCE`` must be set for every pad. diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 3fa0bc687851..7938f785e2e3 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -209,11 +209,16 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads, mutex_lock(&mdev->graph_mutex); media_entity_for_each_pad(entity, iter) { + const u32 pad_flags = iter->flags & (MEDIA_PAD_FL_SINK | + MEDIA_PAD_FL_SOURCE | + MEDIA_PAD_FL_INTERNAL); + iter->entity = entity; iter->index = i++; - if (hweight32(iter->flags & (MEDIA_PAD_FL_SINK | - MEDIA_PAD_FL_SOURCE)) != 1) { + if (pad_flags != MEDIA_PAD_FL_SINK && + pad_flags != (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL) && + pad_flags != MEDIA_PAD_FL_SOURCE) { ret = -EINVAL; break; } @@ -1118,7 +1123,8 @@ int media_get_pad_index(struct media_entity *entity, u32 pad_type, for (i = 0; i < entity->num_pads; i++) { if ((entity->pads[i].flags & - (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE)) != pad_type) + (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE | + MEDIA_PAD_FL_INTERNAL)) != pad_type) continue; if (entity->pads[i].sig_type == sig_type) @@ -1148,6 +1154,9 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, return -EINVAL; if (WARN_ON(!(sink->pads[sink_pad].flags & MEDIA_PAD_FL_SINK))) return -EINVAL; + if (WARN_ON(source->pads[source_pad].flags & MEDIA_PAD_FL_INTERNAL) || + WARN_ON(sink->pads[sink_pad].flags & MEDIA_PAD_FL_INTERNAL)) + return -EINVAL; link = media_add_link(&source->links); if (link == NULL) diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 1c80b1d6bbaf..80cfd12a43fc 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -208,6 +208,7 @@ struct media_entity_desc { #define MEDIA_PAD_FL_SINK (1U << 0) #define MEDIA_PAD_FL_SOURCE (1U << 1) #define MEDIA_PAD_FL_MUST_CONNECT (1U << 2) +#define MEDIA_PAD_FL_INTERNAL (1U << 3) struct media_pad_desc { __u32 entity; /* entity ID */ -- 2.53.0