@@ -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 <media-glossary-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.
@@ -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;
}
@@ -1112,7 +1117,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)
@@ -1142,6 +1148,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)
@@ -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 */