From nobody Thu Apr 9 05:49:09 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 681AA3A3E9F; Wed, 11 Mar 2026 07:17:37 +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=1773213457; cv=none; b=TjG4IL789jYVMF7zGupv5cHmJCtKuqwVcuYT4RBRCLM0cBAqCLsnAPB+J7A5sL3X/2aMNmHvx/KNHx+0cO3irQoKH97izAxLTnlbUX4UVk+Sj7BkGNDZWNIgmfie0nZHWLnaF9Lgsjnm9hIhnFKD+HLA5nzcdaw3Ng+8Kv3xo7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773213457; c=relaxed/simple; bh=slk4MNgaSC+kx7c2W231pz1R1uk/0PZTCyNeXo53Hek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ijznllMzv92hw/06iEsHpnPC2jTDqeuce9gxR8b0ivKDSyGe3UZiyq+k644Dp3l/ALivAnXY4OiU1zdqsi8a7vum04Ing60RhVxaaWMi3ro+SOhVFA905cUBhJ9/PxOudotStJzUO7F9TiZwqeshBfAjj1hG6toFSj4o89oQSGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sliDP2+H; 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="sliDP2+H" Received: by smtp.kernel.org (Postfix) with ESMTPS id CD543C4CEF7; Wed, 11 Mar 2026 07:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773213456; bh=slk4MNgaSC+kx7c2W231pz1R1uk/0PZTCyNeXo53Hek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sliDP2+Hl61BInbN+V/wxLMMxCIHBkRQPwwgpkhbCNtNeUtZCxTmNmz2WlcaKoFVe 033K8RuhxJQvdtm2Ga0UPT7jFPjRzF4itptcAy5tH0fF++lqnsf8+Gn7cmPZjAQMej br6hBjz56CuGsogLDmY9m8rtH/hp1ZrKMr0rVFtZv1R2L5E9Ue/M1ZXv95lgFkfdzo oDeEJ6QLoT67cq7KPmeaFha3exxxM9xlQGQuJr21y6N6UJgPxQBAaCPPdId+R47I8w AeNOAhZ0NfBypYtCuzax2gKaR62VEpY2ytRtPIagzW+AuqdyEr8j4XzZaVuUPZyR6+ RiYjOPlJrzeyw== 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 BD292FD063C; Wed, 11 Mar 2026 07:17:36 +0000 (UTC) From: Dumitru Ceclan via B4 Relay Date: Wed, 11 Mar 2026 09:17:13 +0200 Subject: [PATCH v9 01/21] 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: <20260311-gmsl2-3_serdes-v9-1-41499f09004f@analog.com> References: <20260311-gmsl2-3_serdes-v9-0-41499f09004f@analog.com> In-Reply-To: <20260311-gmsl2-3_serdes-v9-0-41499f09004f@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=1773213453; l=4211; i=dumitru.ceclan@analog.com; s=20240313; h=from:subject:message-id; bh=AreK0kDB/CS0mvU6CVYiJXYgsOXsG4rDStXAaRX8fng=; b=IhzybTwrA0s2ocr8e2MuOQzjp2UV2vgx+4S7YWH2iB7c6mqbEygKrCm8zsytDqrnDSc38BK0b VU8At7qNUNwCLNGcgmS/kSTtKFvSeW9yHftG4N2XzJhkvxgK6W4azdj 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