From: Daniel Scally <dan.scally@ideasonboard.com>
To: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: Anthony.McGivern@arm.com, jacopo.mondi@ideasonboard.com,
nayden.kanchev@arm.com, robh+dt@kernel.org, mchehab@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
jerome.forissier@linaro.org, kieran.bingham@ideasonboard.com,
laurent.pinchart@ideasonboard.com, dan.scally@ideasonboard.com,
Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: [PATCH v11 01/19] media: mc: entity: Add pipeline_started/stopped ops
Date: Mon, 14 Jul 2025 16:06:27 +0100 [thread overview]
Message-ID: <20250714-c55-v11-1-bc20e460e42a@ideasonboard.com> (raw)
In-Reply-To: <20250714-c55-v11-0-bc20e460e42a@ideasonboard.com>
Add two new members to struct media_entity_operations, along with new
functions in media-entity.c to traverse a media pipeline and call the
new operations. The new functions are intended to be used to signal
to a media pipeline that it has fully started, with the entity ops
allowing drivers to define some action to be taken when those
conditions are met.
The combination of the new functions and operations allows drivers
which are part of a multi-driver pipeline to delay actually starting
streaming until all of the conditions for streaming succcessfully are
met across all drivers.
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
Changes in v5:
- Update kerneldoc comments with Optional statement in the
right place
Changes in v4:
- Reverted to having the iter variable
Changes in v3:
- Dropped the iter variable now that the pipeline entity
iterator functions don't need it.
- Updated documentation to specify Optional and return
values
Changes in v2:
- Refactored media_pipeline_started() such that the cleanup
function for media_pipeline_entity_iter is unconditionally
called
- Avoided using media_entity_call() helper for operation that
has return type void to avoid compiler warnings
---
drivers/media/mc/mc-entity.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
include/media/media-entity.h | 29 ++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 045590905582054c46656e20463271b1f93fa6b4..d3443537d4304e12cb015630101efba22375c011 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -1053,6 +1053,52 @@ __media_pipeline_entity_iter_next(struct media_pipeline *pipe,
}
EXPORT_SYMBOL_GPL(__media_pipeline_entity_iter_next);
+int media_pipeline_started(struct media_pipeline *pipe)
+{
+ struct media_pipeline_entity_iter iter;
+ struct media_entity *entity;
+ int ret;
+
+ ret = media_pipeline_entity_iter_init(pipe, &iter);
+ if (ret)
+ return ret;
+
+ media_pipeline_for_each_entity(pipe, &iter, entity) {
+ ret = media_entity_call(entity, pipeline_started);
+ if (ret && ret != -ENOIOCTLCMD)
+ break;
+ }
+
+ media_pipeline_entity_iter_cleanup(&iter);
+
+ ret = ret == -ENOIOCTLCMD ? 0 : ret;
+ if (ret)
+ media_pipeline_stopped(pipe);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(media_pipeline_started);
+
+int media_pipeline_stopped(struct media_pipeline *pipe)
+{
+ struct media_pipeline_entity_iter iter;
+ struct media_entity *entity;
+ int ret;
+
+ ret = media_pipeline_entity_iter_init(pipe, &iter);
+ if (ret)
+ return ret;
+
+ media_pipeline_for_each_entity(pipe, &iter, entity)
+ if (entity->ops && entity->ops->pipeline_stopped)
+ entity->ops->pipeline_stopped(entity);
+
+ media_pipeline_entity_iter_cleanup(&iter);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(media_pipeline_stopped);
+
/* -----------------------------------------------------------------------------
* Links management
*/
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 64cf590b11343f68a456c5870ca2f32917c122f9..1e1026f65f2050bb9aa39bde68794da8d2d0a669 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -269,6 +269,10 @@ struct media_pad {
* media_entity_has_pad_interdep().
* Optional: If the operation isn't implemented all pads
* will be considered as interdependent.
+ * @pipeline_started: Optional: Notify this entity that the pipeline it is a
+ * part of has been started.
+ * @pipeline_stopped: Optional: Notify this entity that the pipeline it is a
+ * part of has been stopped.
*
* .. note::
*
@@ -284,6 +288,8 @@ struct media_entity_operations {
int (*link_validate)(struct media_link *link);
bool (*has_pad_interdep)(struct media_entity *entity, unsigned int pad0,
unsigned int pad1);
+ int (*pipeline_started)(struct media_entity *entity);
+ void (*pipeline_stopped)(struct media_entity *entity);
};
/**
@@ -1261,6 +1267,29 @@ __media_pipeline_entity_iter_next(struct media_pipeline *pipe,
entity != NULL; \
entity = __media_pipeline_entity_iter_next((pipe), iter, entity))
+/**
+ * media_pipeline_started - Inform entities in a pipeline that it has started
+ * @pipe: The pipeline
+ *
+ * Iterate on all entities in a media pipeline and call their pipeline_started
+ * member of media_entity_operations.
+ *
+ * Return: zero on success, or a negative error code passed through from an
+ * entity's .pipeline_started() operation.
+ */
+int media_pipeline_started(struct media_pipeline *pipe);
+
+/**
+ * media_pipeline_stopped - Inform entities in a pipeline that it has stopped
+ * @pipe: The pipeline
+ *
+ * Iterate on all entities in a media pipeline and call their pipeline_stopped
+ * member of media_entity_operations.
+ *
+ * Return: zero on success, or -ENOMEM if the iterator initialisation failed.
+ */
+int media_pipeline_stopped(struct media_pipeline *pipe);
+
/**
* media_pipeline_alloc_start - Mark a pipeline as streaming
* @pad: Starting pad
--
2.34.1
next prev parent reply other threads:[~2025-07-14 15:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 15:06 [PATCH v11 00/19] Add Arm Mali-C55 Image Signal Processor Driver Daniel Scally
2025-07-14 15:06 ` Daniel Scally [this message]
2025-08-05 7:45 ` [PATCH v11 01/19] media: mc: entity: Add pipeline_started/stopped ops Jacopo Mondi
2025-08-20 10:47 ` Dan Scally
2025-07-14 15:06 ` [PATCH v11 02/19] media: v4l2-dev: Add helpers to run media_pipeline_[started|stopped]() Daniel Scally
2025-08-05 8:52 ` Jacopo Mondi
2025-07-14 15:06 ` [PATCH v11 03/19] media: uapi: Add MEDIA_BUS_FMT_RGB202020_1X60 format code Daniel Scally
2025-07-14 15:06 ` [PATCH v11 04/19] media: uapi: Add 20-bit bayer formats Daniel Scally
2025-07-14 15:06 ` [PATCH v11 05/19] media: v4l2-common: Add RAW16 format info Daniel Scally
2025-07-14 15:06 ` [PATCH v11 06/19] media: v4l2-common: Add RAW14 " Daniel Scally
2025-07-14 15:06 ` [PATCH v11 07/19] dt-bindings: media: Add bindings for ARM mali-c55 Daniel Scally
2025-07-14 21:25 ` Rob Herring
2025-07-15 6:28 ` Dan Scally
2025-07-15 8:53 ` Krzysztof Kozlowski
2025-07-31 7:11 ` [PATCH v11.1 " Daniel Scally
2025-07-31 13:35 ` Rob Herring
2025-07-14 15:06 ` [PATCH v11 08/19] media: uapi: Add controls for Mali-C55 ISP Daniel Scally
2025-08-05 11:27 ` Jacopo Mondi
2025-08-21 11:14 ` Dan Scally
2025-07-14 15:06 ` [PATCH v11 09/19] media: mali-c55: Add Mali-C55 ISP driver Daniel Scally
2025-08-05 12:23 ` Jacopo Mondi
2025-07-14 15:06 ` [PATCH v11 10/19] media: Documentation: Add Mali-C55 ISP Documentation Daniel Scally
2025-07-14 15:06 ` [PATCH v11 11/19] MAINTAINERS: Add entry for mali-c55 driver Daniel Scally
2025-07-14 15:06 ` [PATCH v11 12/19] media: Add MALI_C55_3A_STATS meta format Daniel Scally
2025-07-14 15:06 ` [PATCH v11 13/19] media: uapi: Add 3a stats buffer for mali-c55 Daniel Scally
2025-07-14 15:06 ` [PATCH v11 14/19] media: platform: Add mali-c55 3a stats devnode Daniel Scally
2025-07-14 15:06 ` [PATCH v11 15/19] Documentation: mali-c55: Add Statistics documentation Daniel Scally
2025-07-14 15:06 ` [PATCH v11 16/19] media: mali-c55: Add image formats for Mali-C55 parameters buffer Daniel Scally
2025-07-14 15:06 ` [PATCH v11 17/19] media: uapi: Add parameters structs to mali-c55-config.h Daniel Scally
2025-07-14 15:06 ` [PATCH v11 18/19] media: platform: Add mali-c55 parameters video node Daniel Scally
2025-07-30 14:36 ` Sakari Ailus
2025-07-30 21:11 ` Dan Scally
2025-07-30 21:22 ` Sakari Ailus
2025-07-14 15:06 ` [PATCH v11 19/19] Documentation: mali-c55: Document the mali-c55 parameter setting Daniel Scally
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250714-c55-v11-1-bc20e460e42a@ideasonboard.com \
--to=dan.scally@ideasonboard.com \
--cc=Anthony.McGivern@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jacopo.mondi@ideasonboard.com \
--cc=jerome.forissier@linaro.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=nayden.kanchev@arm.com \
--cc=robh+dt@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).