media: mc: entity: Add has_pad_interdep entity operation
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Wed, 31 Aug 2022 14:13:38 +0000 (16:13 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 07:20:30 +0000 (09:20 +0200)
Add a new media entity operation, has_pad_interdep. The optional op is
used to discover the pad interdependencies inside an entity during the
pipeline construction.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/mc/mc-entity.c
include/media/media-entity.h

index 0a5c92b8bbce2732a6f599c7c7a0eb862eea6467..831076b3684768830902346398d8d3e03c63931f 100644 (file)
@@ -232,7 +232,10 @@ EXPORT_SYMBOL_GPL(media_entity_pads_init);
  * and enabling one of the pads means that the other pad will become "locked"
  * and doesn't allow configuration changes.
  *
- * For the time being all pads are considered interdependent.
+ * This function uses the &media_entity_operations.has_pad_interdep() operation
+ * to check the dependency inside the entity between @pad0 and @pad1. If the
+ * has_pad_interdep operation is not implemented, all pads of the entity are
+ * considered to be interdependent.
  */
 static bool media_entity_has_pad_interdep(struct media_entity *entity,
                                          unsigned int pad0, unsigned int pad1)
@@ -244,7 +247,10 @@ static bool media_entity_has_pad_interdep(struct media_entity *entity,
            (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE))
                return false;
 
-       return true;
+       if (!entity->ops || !entity->ops->has_pad_interdep)
+               return true;
+
+       return entity->ops->has_pad_interdep(entity, pad0, pad1);
 }
 
 static struct media_entity *
index 00990b20b3d5a810220a7b06cc18fbe47ceb4c0a..8e9fd309aa653584f1f2153571ac1b290eda3bf6 100644 (file)
@@ -237,6 +237,14 @@ struct media_pad {
  * @link_validate:     Return whether a link is valid from the entity point of
  *                     view. The media_pipeline_start() function
  *                     validates all links by calling this operation. Optional.
+ * @has_pad_interdep:  Return whether a two pads inside the entity are
+ *                     interdependent. If two pads are interdependent they are
+ *                     part of the same pipeline and enabling one of the pads
+ *                     means that the other pad will become "locked" and
+ *                     doesn't allow configuration changes. pad0 and pad1 are
+ *                     guaranteed to not both be sinks or sources.
+ *                     Optional: If the operation isn't implemented all pads
+ *                     will be considered as interdependent.
  *
  * .. note::
  *
@@ -250,6 +258,8 @@ struct media_entity_operations {
                          const struct media_pad *local,
                          const struct media_pad *remote, u32 flags);
        int (*link_validate)(struct media_link *link);
+       bool (*has_pad_interdep)(struct media_entity *entity, unsigned int pad0,
+                                unsigned int pad1);
 };
 
 /**