From nobody Thu Apr 9 05:48:55 2026 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 74F8939C63E; Mon, 6 Apr 2026 20:15:21 +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=1775506521; cv=none; b=I+bD9XsOaP7dwDBtxM6FQMpbV0CekCh8tQxC398ifpAiZwZVY2lj5kANkRWKckAp4Ir7S8ijRvKFqRVNqJHXPdmEQPjla5wuF6Lgb3D/Tl6C2ud4JcUpnA8Lo+kxJdL/AjRKXdbIgDRXu6HVCJWxxtkxTnwV8DqoMYF6DLJFa18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775506521; c=relaxed/simple; bh=slk4MNgaSC+kx7c2W231pz1R1uk/0PZTCyNeXo53Hek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KrTC8DGHCRCQfpir6uuEQx/cCXoUTX0q9h0x/nuUMz+s6GFKbKNsuci+CazKD8eMBykN8vvadjzpErxh/Ck7mIn1x2qYnsn0UbrbNZJS8NVkorqxdS6deCsBDnitssw933r0VzzeUYHx+ypHjgp9qhZNTuzx0TdR7nEZQHydxCw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nMjq8TK2; 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="nMjq8TK2" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3480CC19425; Mon, 6 Apr 2026 20:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775506521; bh=slk4MNgaSC+kx7c2W231pz1R1uk/0PZTCyNeXo53Hek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=nMjq8TK24j3D63dSO4imLTwT3pwAmhb60Ugm2mOs7ntNshQls6p5RZG4gae+PG0Zc 3amAqPSDKhvw+DGuEdjUKhL0XX6295iNLWO8+5IQzWUnEwzJEjSKi9KRHpmdTxSqhc c5P2n+NgoB2roiYzadhAp63AibafVK6uKQ/1v4kZRPN34QL3A8dCtFS81XIiNQfeIy leCkMMmIWsE+aMjIJjOAjqRK6bNU/JW1eclG8rwJHrMaMQpUQL8FWw73/nfPHflNNX mcxoPjV4EhCN0GasxHJWWSB9PM/JYLBVk2oEEfaNNczCiHw1mZ/M+e+d2Uwtj+/UWM gV59807RTBRAg== 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 1CE4BF46C78; Mon, 6 Apr 2026 20:15:21 +0000 (UTC) From: Dumitru Ceclan via B4 Relay Date: Mon, 06 Apr 2026 23:14:40 +0300 Subject: [PATCH v10 01/22] media: mc: Add INTERNAL pad flag 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: <20260406-gmsl2-3_serdes-v10-1-645560fedca5@analog.com> References: <20260406-gmsl2-3_serdes-v10-0-645560fedca5@analog.com> In-Reply-To: <20260406-gmsl2-3_serdes-v10-0-645560fedca5@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 , Cosmin Tanislav Cc: 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 , Tomi Valkeinen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775506518; l=4211; i=dumitru.ceclan@analog.com; s=20240313; h=from:subject:message-id; bh=AreK0kDB/CS0mvU6CVYiJXYgsOXsG4rDStXAaRX8fng=; b=+vIQLXVmK0Ie8XAN23rqnkTqkJO+5z+G1Q2Eg871gD5nkQ3ILglp2zgpZQy2noi7ZQyDponFo CG2Smw1YPWtBL3kupQZmSmYlSNBfXcoxTtXki4gCs7mHVV3r2zGaPtI 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/D= ocumentation/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 eleme= nts .. _MEDIA-PAD-FL-SINK: .. _MEDIA-PAD-FL-SOURCE: .. _MEDIA-PAD-FL-MUST-CONNECT: +.. _MEDIA-PAD-FL-INTERNAL: =20 .. flat-table:: Media pad flags :header-rows: 0 @@ -381,6 +382,14 @@ Types and flags used to represent the media graph elem= ents enabled links even when this flag isn't set; the absence of the flag doesn't imply there is none. =20 + * - ``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. =20 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 9519a537bfa2..df20356fa98b 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 *entit= y, u16 num_pads, mutex_lock(&mdev->graph_mutex); =20 media_entity_for_each_pad(entity, iter) { + const u32 pad_flags =3D iter->flags & (MEDIA_PAD_FL_SINK | + MEDIA_PAD_FL_SOURCE | + MEDIA_PAD_FL_INTERNAL); + iter->entity =3D entity; iter->index =3D i++; =20 - if (hweight32(iter->flags & (MEDIA_PAD_FL_SINK | - MEDIA_PAD_FL_SOURCE)) !=3D 1) { + if (pad_flags !=3D MEDIA_PAD_FL_SINK && + pad_flags !=3D (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL) && + pad_flags !=3D MEDIA_PAD_FL_SOURCE) { ret =3D -EINVAL; break; } @@ -1118,7 +1123,8 @@ int media_get_pad_index(struct media_entity *entity, = u32 pad_type, =20 for (i =3D 0; i < entity->num_pads; i++) { if ((entity->pads[i].flags & - (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE)) !=3D pad_type) + (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE | + MEDIA_PAD_FL_INTERNAL)) !=3D pad_type) continue; =20 if (entity->pads[i].sig_type =3D=3D sig_type) @@ -1148,6 +1154,9 @@ media_create_pad_link(struct media_entity *source, u1= 6 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; =20 link =3D media_add_link(&source->links); if (link =3D=3D 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) =20 struct media_pad_desc { __u32 entity; /* entity ID */ --=20 2.51.0