* [PATCH v3 00/23] Unrestricted media entity ID range support
@ 2015-12-16 13:32 Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 01/23] media: Enforce single entity->pipe in a pipeline Sakari Ailus
` (23 more replies)
0 siblings, 24 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
Hello all,
This is the third version of the unrestricted media entity ID range
support set. I've taken Mauro's comments into account and fixed a number
of bugs as well (omap3isp memory leak and omap4iss stream start).
The more specific changes since v2 are here:
- Renamed struct media_entity_enum "entities" as ent_enum.
- Renamed struct media_entity_enum.e as bmap.
- Fix KernelDoc documentation
- Remove pre-allocated bitmap from entity enumerations. This is done in a
separate patch due to API changes it necessitates. (Init may fail.)
- Drop MEDIA_ENTITY_ENUM_STACK_ALLOC. Move MEDIA_ENTITY_MAX_PADS to
media-entity.c.
- Replace BUG_ON() in media_entity_pipeline_stop() by WARN_ON().
- Fix enumeration and graph walk init / cleanup in iss_video_streamon() in
omap4iss driver.
v2 is available here:
<URL:http://www.spinics.net/lists/linux-media/msg95150.html>
The documentation remains unchanged so far.
--
Kind regards,
Sakari
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH v3 01/23] media: Enforce single entity->pipe in a pipeline
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 02/23] media: Introduce internal index for media entities Sakari Ailus
` (22 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
If a different entity->pipe in a pipeline was encountered, a warning was
issued but the execution continued as if nothing had happened. Return an
error instead right there.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 66b8db0..d11f440 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -431,7 +431,12 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
entity->stream_count++;
- WARN_ON(entity->pipe && entity->pipe != pipe);
+
+ if (WARN_ON(entity->pipe && entity->pipe != pipe)) {
+ ret = -EBUSY;
+ goto error;
+ }
+
entity->pipe = pipe;
/* Already streaming --- no need to check. */
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 02/23] media: Introduce internal index for media entities
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 01/23] media: Enforce single entity->pipe in a pipeline Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 03/23] media: Add an API to manage entity enumerations Sakari Ailus
` (21 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
The internal index can be used internally by the framework in order to keep
track of entities for a purpose or another. The internal index is constant
while it's registered to a media device, but the same index may be re-used
once the entity having that index is unregistered.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-device.c | 17 +++++++++++++++++
include/media/media-device.h | 4 ++++
include/media/media-entity.h | 3 +++
3 files changed, 24 insertions(+)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index c181758..ebb84cb 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -22,6 +22,7 @@
#include <linux/compat.h>
#include <linux/export.h>
+#include <linux/idr.h>
#include <linux/ioctl.h>
#include <linux/media.h>
#include <linux/types.h>
@@ -546,6 +547,7 @@ void media_device_init(struct media_device *mdev)
INIT_LIST_HEAD(&mdev->links);
spin_lock_init(&mdev->lock);
mutex_init(&mdev->graph_mutex);
+ ida_init(&mdev->entity_internal_idx);
dev_dbg(mdev->dev, "Media device initialized\n");
}
@@ -558,6 +560,8 @@ EXPORT_SYMBOL_GPL(media_device_init);
*/
void media_device_cleanup(struct media_device *mdev)
{
+ ida_destroy(&mdev->entity_internal_idx);
+ mdev->entity_internal_idx_max = 0;
mutex_destroy(&mdev->graph_mutex);
}
EXPORT_SYMBOL_GPL(media_device_cleanup);
@@ -658,6 +662,17 @@ int __must_check media_device_register_entity(struct media_device *mdev,
INIT_LIST_HEAD(&entity->links);
spin_lock(&mdev->lock);
+
+ entity->internal_idx = ida_simple_get(&mdev->entity_internal_idx, 1, 0,
+ GFP_KERNEL);
+ if (entity->internal_idx < 0) {
+ spin_unlock(&mdev->lock);
+ return entity->internal_idx;
+ }
+
+ mdev->entity_internal_idx_max =
+ max(mdev->entity_internal_idx_max, entity->internal_idx);
+
/* Initialize media_gobj embedded at the entity */
media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
@@ -690,6 +705,8 @@ void media_device_unregister_entity(struct media_entity *entity)
spin_lock(&mdev->lock);
+ ida_simple_remove(&mdev->entity_internal_idx, entity->internal_idx);
+
/* Remove interface links with this entity on it */
list_for_each_entry_safe(link, tmp, &mdev->links, graph_obj.list) {
if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY
diff --git a/include/media/media-device.h b/include/media/media-device.h
index a2c7570..c0e1764 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -30,6 +30,7 @@
#include <media/media-devnode.h>
#include <media/media-entity.h>
+struct ida;
struct device;
/**
@@ -47,6 +48,7 @@ struct device;
* @pad_id: Unique ID used on the last pad registered
* @link_id: Unique ID used on the last link registered
* @intf_devnode_id: Unique ID used on the last interface devnode registered
+ * @entity_internal_idx: Allocated internal entity indices
* @entities: List of registered entities
* @interfaces: List of registered interfaces
* @pads: List of registered pads
@@ -82,6 +84,8 @@ struct media_device {
u32 pad_id;
u32 link_id;
u32 intf_devnode_id;
+ struct ida entity_internal_idx;
+ int entity_internal_idx_max;
struct list_head entities;
struct list_head interfaces;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index eebdd24..d3d3a39 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -159,6 +159,8 @@ struct media_entity_operations {
* @num_pads: Number of sink and source pads.
* @num_links: Number of existing links, both enabled and disabled.
* @num_backlinks: Number of backlinks
+ * @internal_idx: An unique internal entity specific number. The numbers are
+ * re-used if entities are unregistered or registered again.
* @pads: Pads array with the size defined by @num_pads.
* @links: Linked list for the data links.
* @ops: Entity operations.
@@ -187,6 +189,7 @@ struct media_entity {
u16 num_pads;
u16 num_links;
u16 num_backlinks;
+ int internal_idx;
struct media_pad *pads;
struct list_head links;
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 03/23] media: Add an API to manage entity enumerations
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 01/23] media: Enforce single entity->pipe in a pipeline Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 02/23] media: Introduce internal index for media entities Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:44 ` [PATCH v3.1 " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 04/23] media: Move struct media_entity_graph definition up Sakari Ailus
` (20 subsequent siblings)
23 siblings, 1 reply; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
This is useful in e.g. knowing whether certain operations have already
been performed for an entity. The users include the framework itself (for
graph walking) and a number of drivers.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 39 ++++++++++++
include/media/media-device.h | 15 +++++
include/media/media-entity.h | 140 ++++++++++++++++++++++++++++++++++++++++---
3 files changed, 186 insertions(+), 8 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index d11f440..67eebcb 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -213,6 +213,45 @@ void media_gobj_remove(struct media_gobj *gobj)
}
/**
+ * __media_entity_enum_init - Initialise an entity enumeration
+ *
+ * @ent_enum: Entity enumeration to be initialised
+ * @idx_max: Maximum number of entities in the enumeration
+ *
+ * Returns zero on success or a negative error code.
+ */
+int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max)
+{
+ if (idx_max > MEDIA_ENTITY_ENUM_MAX_ID) {
+ ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG),
+ sizeof(long), GFP_KERNEL);
+ if (!ent_enum->bmap)
+ return -ENOMEM;
+ } else {
+ ent_enum->bmap = ent_enum->prealloc_bmap;
+ }
+
+ bitmap_zero(ent_enum->bmap, idx_max);
+ ent_enum->idx_max = idx_max;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(__media_entity_enum_init);
+
+/**
+ * media_entity_enum_cleanup - Release resources of an entity enumeration
+ *
+ * @e: Entity enumeration to be released
+ */
+void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
+{
+ if (ent_enum->bmap != ent_enum->prealloc_bmap)
+ kfree(ent_enum->bmap);
+ ent_enum->bmap = NULL;
+}
+EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
+
+/**
* media_entity_init - Initialize a media entity
*
* @num_pads: Total number of sink and source pads.
diff --git a/include/media/media-device.h b/include/media/media-device.h
index c0e1764..abf94b4 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -110,6 +110,21 @@ struct media_device {
/* media_devnode to media_device */
#define to_media_device(node) container_of(node, struct media_device, devnode)
+/**
+ * media_entity_enum_init - Initialise an entity enumeration
+ *
+ * @e: Entity enumeration to be initialised
+ * @mdev: The related media device
+ *
+ * Returns zero on success or a negative error code.
+ */
+static inline __must_check int media_entity_enum_init(
+ struct media_entity_enum *ent_enum, struct media_device *mdev)
+{
+ return __media_entity_enum_init(ent_enum,
+ mdev->entity_internal_idx_max + 1);
+}
+
void media_device_init(struct media_device *mdev);
void media_device_cleanup(struct media_device *mdev);
int __must_check __media_device_register(struct media_device *mdev,
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index d3d3a39..70803f7 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -23,7 +23,7 @@
#ifndef _MEDIA_ENTITY_H
#define _MEDIA_ENTITY_H
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/media.h>
@@ -71,6 +71,32 @@ struct media_gobj {
struct list_head list;
};
+#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
+#define MEDIA_ENTITY_ENUM_MAX_ID 64
+
+/*
+ * The number of pads can't be bigger than the number of entities,
+ * as the worse-case scenario is to have one entity linked up to
+ * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
+ */
+#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
+
+/**
+ * struct media_entity_enum - An enumeration of media entities.
+ *
+ * @prealloc_bmap: Pre-allocated space reserved for media entities if the
+ * total number of entities does not exceed
+ * MEDIA_ENTITY_ENUM_MAX_ID.
+ * @bmap: Bit map in which each bit represents one entity at struct
+ * media_entity->internal_idx.
+ * @idx_max: Number of bits in bmap
+ */
+struct media_entity_enum {
+ DECLARE_BITMAP(prealloc_bmap, MEDIA_ENTITY_ENUM_MAX_ID);
+ unsigned long *bmap;
+ int idx_max;
+};
+
struct media_pipeline {
};
@@ -307,15 +333,113 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
}
}
-#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
-#define MEDIA_ENTITY_ENUM_MAX_ID 64
+int __media_entity_enum_init(struct media_entity_enum *e, int idx_max);
+void media_entity_enum_cleanup(struct media_entity_enum *e);
-/*
- * The number of pads can't be bigger than the number of entities,
- * as the worse-case scenario is to have one entity linked up to
- * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
+/**
+ * media_entity_enum_zero - Clear the entire enum
+ *
+ * @e: Entity enumeration to be cleared
*/
-#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
+static inline void media_entity_enum_zero(struct media_entity_enum *ent_enum)
+{
+ bitmap_zero(ent_enum->bmap, ent_enum->idx_max);
+}
+
+/**
+ * media_entity_enum_set - Mark a single entity in the enum
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be marked
+ */
+static inline void media_entity_enum_set(struct media_entity_enum *ent_enum,
+ struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return;
+
+ __set_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_clear - Unmark a single entity in the enum
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be unmarked
+ */
+static inline void media_entity_enum_clear(struct media_entity_enum *ent_enum,
+ struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return;
+
+ __clear_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_test - Test whether the entity is marked
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be tested
+ *
+ * Returns true if the entity was marked.
+ */
+static inline bool media_entity_enum_test(struct media_entity_enum *ent_enum,
+ struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return true;
+
+ return test_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_test - Test whether the entity is marked, and mark it
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be tested
+ *
+ * Returns true if the entity was marked, and mark it before doing so.
+ */
+static inline bool media_entity_enum_test_and_set(
+ struct media_entity_enum *ent_enum, struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return true;
+
+ return __test_and_set_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_test - Test whether the entire enum is empty
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be tested
+ *
+ * Returns true if the entity was marked.
+ */
+static inline bool media_entity_enum_empty(struct media_entity_enum *ent_enum)
+{
+ return bitmap_empty(ent_enum->bmap, ent_enum->idx_max);
+}
+
+/**
+ * media_entity_enum_intersects - Test whether two enums intersect
+ *
+ * @e: First entity enumeration
+ * @f: Second entity enumeration
+ *
+ * Returns true if entity enumerations e and f intersect, otherwise false.
+ */
+static inline bool media_entity_enum_intersects(
+ struct media_entity_enum *ent_enum1,
+ struct media_entity_enum *ent_enum2)
+{
+ WARN_ON(ent_enum1->idx_max != ent_enum2->idx_max);
+
+ return bitmap_intersects(ent_enum1->bmap, ent_enum2->bmap,
+ min(ent_enum1->idx_max, ent_enum2->idx_max));
+}
struct media_entity_graph {
struct {
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 04/23] media: Move struct media_entity_graph definition up
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (2 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 03/23] media: Add an API to manage entity enumerations Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 05/23] media: Add KernelDoc documentation for struct media_entity_graph Sakari Ailus
` (19 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
It will be needed in struct media_pipeline shortly.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/media-entity.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 70803f7..4f789a4 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -97,6 +97,16 @@ struct media_entity_enum {
int idx_max;
};
+struct media_entity_graph {
+ struct {
+ struct media_entity *entity;
+ struct list_head *link;
+ } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
+
+ DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
+ int top;
+};
+
struct media_pipeline {
};
@@ -441,16 +451,6 @@ static inline bool media_entity_enum_intersects(
min(ent_enum1->idx_max, ent_enum2->idx_max));
}
-struct media_entity_graph {
- struct {
- struct media_entity *entity;
- struct list_head *link;
- } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
-
- DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
- int top;
-};
-
#define gobj_to_entity(gobj) \
container_of(gobj, struct media_entity, graph_obj)
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 05/23] media: Add KernelDoc documentation for struct media_entity_graph
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (3 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 04/23] media: Move struct media_entity_graph definition up Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 06/23] media: Move media graph state for streamon/off to the pipeline Sakari Ailus
` (18 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
KernelDoc doesn't appear to handle anonymous structs defined inside
another gracefully. As the struct is internal to the framework graph walk
algorithm, detailed documentation isn't seen very important.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/media-entity.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 4f789a4..3068c30 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -97,6 +97,15 @@ struct media_entity_enum {
int idx_max;
};
+/**
+ * struct media_entity_graph - Media graph traversal state
+ *
+ * @stack: Graph traversal stack; the stack contains information
+ * on the path the media entities to be walked and the
+ * links through which they were reached.
+ * @entities: Visited entities
+ * @top: The top of the stack
+ */
struct media_entity_graph {
struct {
struct media_entity *entity;
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 06/23] media: Move media graph state for streamon/off to the pipeline
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (4 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 05/23] media: Add KernelDoc documentation for struct media_entity_graph Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 07/23] media: Amend media graph walk API by init and cleanup functions Sakari Ailus
` (17 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The struct media_entity_graph was allocated in the stack, limiting the
number of entities that could be reasonably allocated. Instead, move the
struct to struct media_pipeline which is typically allocated using
kmalloc() instead.
The intent is to keep the enumeration around for later use for the
duration of the streaming. As streaming is eventually stopped, an
unfortunate memory allocation failure would prevent stopping the
streaming. As no memory will need to be allocated, the problem is avoided
altogether.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
drivers/media/media-entity.c | 16 ++++++++--------
include/media/media-entity.h | 6 ++++++
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 67eebcb..786a01f 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -456,16 +456,16 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
struct media_pipeline *pipe)
{
struct media_device *mdev = entity->graph_obj.mdev;
- struct media_entity_graph graph;
+ struct media_entity_graph *graph = &pipe->graph;
struct media_entity *entity_err = entity;
struct media_link *link;
int ret;
mutex_lock(&mdev->graph_mutex);
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ while ((entity = media_entity_graph_walk_next(graph))) {
DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
@@ -546,9 +546,9 @@ error:
* Link validation on graph failed. We revert what we did and
* return the error.
*/
- media_entity_graph_walk_start(&graph, entity_err);
+ media_entity_graph_walk_start(graph, entity_err);
- while ((entity_err = media_entity_graph_walk_next(&graph))) {
+ while ((entity_err = media_entity_graph_walk_next(graph))) {
entity_err->stream_count--;
if (entity_err->stream_count == 0)
entity_err->pipe = NULL;
@@ -582,13 +582,13 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
void media_entity_pipeline_stop(struct media_entity *entity)
{
struct media_device *mdev = entity->graph_obj.mdev;
- struct media_entity_graph graph;
+ struct media_entity_graph *graph = &entity->pipe->graph;
mutex_lock(&mdev->graph_mutex);
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ while ((entity = media_entity_graph_walk_next(graph))) {
entity->stream_count--;
if (entity->stream_count == 0)
entity->pipe = NULL;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 3068c30..9315158 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -116,7 +116,13 @@ struct media_entity_graph {
int top;
};
+/*
+ * struct media_pipeline - Media pipeline related information
+ *
+ * @graph: Media graph walk during pipeline start / stop
+ */
struct media_pipeline {
+ struct media_entity_graph graph;
};
/**
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 07/23] media: Amend media graph walk API by init and cleanup functions
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (5 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 06/23] media: Move media graph state for streamon/off to the pipeline Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 08/23] media: Use the new media graph walk interface Sakari Ailus
` (16 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
Add media_entity_graph_walk_init() and media_entity_graph_walk_cleanup()
functions in order to dynamically allocate memory for the graph. This is
not done in media_entity_graph_walk_start() as there are situations where
e.g. correct error handling, that itself may not fail, requires successful
graph walk.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 39 ++++++++++++++++++++++++++++++++++-----
include/media/media-entity.h | 5 ++++-
2 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 786a01f..d63204e 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -353,14 +353,44 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph)
#define stack_top(en) ((en)->stack[(en)->top].entity)
/**
+ * media_entity_graph_walk_init - Allocate resources for graph walk
+ * @graph: Media graph structure that will be used to walk the graph
+ * @mdev: Media device
+ *
+ * Reserve resources for graph walk in media device's current
+ * state. The memory must be released using
+ * media_entity_graph_walk_free().
+ *
+ * Returns error on failure, zero on success.
+ */
+__must_check int media_entity_graph_walk_init(
+ struct media_entity_graph *graph, struct media_device *mdev)
+{
+ return 0;
+}
+EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
+
+/**
+ * media_entity_graph_walk_cleanup - Release resources related to graph walking
+ * @graph: Media graph structure that was used to walk the graph
+ */
+void media_entity_graph_walk_cleanup(struct media_entity_graph *graph)
+{
+}
+EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup);
+
+/**
* media_entity_graph_walk_start - Start walking the media graph at a given entity
* @graph: Media graph structure that will be used to walk the graph
* @entity: Starting entity
*
- * This function initializes the graph traversal structure to walk the entities
- * graph starting at the given entity. The traversal structure must not be
- * modified by the caller during graph traversal. When done the structure can
- * safely be freed.
+ * Before using this function, media_entity_graph_walk_init() must be
+ * used to allocate resources used for walking the graph. This
+ * function initializes the graph traversal structure to walk the
+ * entities graph starting at the given entity. The traversal
+ * structure must not be modified by the caller during graph
+ * traversal. After the graph walk, the resources must be released
+ * using media_entity_graph_walk_cleanup().
*/
void media_entity_graph_walk_start(struct media_entity_graph *graph,
struct media_entity *entity)
@@ -377,7 +407,6 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph,
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_start);
-
/**
* media_entity_graph_walk_next - Get the next entity in the graph
* @graph: Media graph structure
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 9315158..eaddcba 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -511,8 +511,11 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad);
struct media_entity *media_entity_get(struct media_entity *entity);
void media_entity_put(struct media_entity *entity);
+__must_check int media_entity_graph_walk_init(
+ struct media_entity_graph *graph, struct media_device *mdev);
+void media_entity_graph_walk_cleanup(struct media_entity_graph *graph);
void media_entity_graph_walk_start(struct media_entity_graph *graph,
- struct media_entity *entity);
+ struct media_entity *entity);
struct media_entity *
media_entity_graph_walk_next(struct media_entity_graph *graph);
__must_check int media_entity_pipeline_start(struct media_entity *entity,
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 08/23] media: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (6 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 07/23] media: Amend media graph walk API by init and cleanup functions Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 09/23] v4l: omap3isp: " Sakari Ailus
` (15 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index d63204e..2232cb3 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -492,7 +492,13 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
mutex_lock(&mdev->graph_mutex);
- media_entity_graph_walk_start(graph, entity);
+ ret = media_entity_graph_walk_init(&pipe->graph, mdev);
+ if (ret) {
+ mutex_unlock(&mdev->graph_mutex);
+ return ret;
+ }
+
+ media_entity_graph_walk_start(&pipe->graph, entity);
while ((entity = media_entity_graph_walk_next(graph))) {
DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
@@ -590,6 +596,8 @@ error:
break;
}
+ media_entity_graph_walk_cleanup(graph);
+
mutex_unlock(&mdev->graph_mutex);
return ret;
@@ -623,6 +631,8 @@ void media_entity_pipeline_stop(struct media_entity *entity)
entity->pipe = NULL;
}
+ media_entity_graph_walk_cleanup(graph);
+
mutex_unlock(&mdev->graph_mutex);
}
EXPORT_SYMBOL_GPL(media_entity_pipeline_stop);
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 09/23] v4l: omap3isp: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (7 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 08/23] media: Use the new media graph walk interface Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 10/23] v4l: exynos4-is: " Sakari Ailus
` (14 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/platform/omap3isp/isp.c | 63 ++++++++++++++++++------------
drivers/media/platform/omap3isp/isp.h | 4 +-
drivers/media/platform/omap3isp/ispvideo.c | 20 +++++++++-
drivers/media/platform/omap3isp/ispvideo.h | 1 +
4 files changed, 61 insertions(+), 27 deletions(-)
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 0d1249f..4a01a36 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -683,14 +683,14 @@ static irqreturn_t isp_isr(int irq, void *_isp)
*
* Return the total number of users of all video device nodes in the pipeline.
*/
-static int isp_pipeline_pm_use_count(struct media_entity *entity)
+static int isp_pipeline_pm_use_count(struct media_entity *entity,
+ struct media_entity_graph *graph)
{
- struct media_entity_graph graph;
int use = 0;
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ while ((entity = media_entity_graph_walk_next(graph))) {
if (is_media_entity_v4l2_io(entity))
use += entity->use_count;
}
@@ -742,27 +742,27 @@ static int isp_pipeline_pm_power_one(struct media_entity *entity, int change)
*
* Return 0 on success or a negative error code on failure.
*/
-static int isp_pipeline_pm_power(struct media_entity *entity, int change)
+static int isp_pipeline_pm_power(struct media_entity *entity, int change,
+ struct media_entity_graph *graph)
{
- struct media_entity_graph graph;
struct media_entity *first = entity;
int ret = 0;
if (!change)
return 0;
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while (!ret && (entity = media_entity_graph_walk_next(&graph)))
+ while (!ret && (entity = media_entity_graph_walk_next(graph)))
if (is_media_entity_v4l2_subdev(entity))
ret = isp_pipeline_pm_power_one(entity, change);
if (!ret)
- return 0;
+ return ret;
- media_entity_graph_walk_start(&graph, first);
+ media_entity_graph_walk_start(graph, first);
- while ((first = media_entity_graph_walk_next(&graph))
+ while ((first = media_entity_graph_walk_next(graph))
&& first != entity)
if (is_media_entity_v4l2_subdev(first))
isp_pipeline_pm_power_one(first, -change);
@@ -782,7 +782,8 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change)
* off is assumed to never fail. No failure can occur when the use parameter is
* set to 0.
*/
-int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
+int omap3isp_pipeline_pm_use(struct media_entity *entity, int use,
+ struct media_entity_graph *graph)
{
int change = use ? 1 : -1;
int ret;
@@ -794,7 +795,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
WARN_ON(entity->use_count < 0);
/* Apply power change to connected non-nodes. */
- ret = isp_pipeline_pm_power(entity, change);
+ ret = isp_pipeline_pm_power(entity, change, graph);
if (ret < 0)
entity->use_count -= change;
@@ -820,35 +821,49 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
static int isp_pipeline_link_notify(struct media_link *link, u32 flags,
unsigned int notification)
{
+ struct media_entity_graph *graph =
+ &container_of(link->graph_obj.mdev, struct isp_device,
+ media_dev)->pm_count_graph;
struct media_entity *source = link->source->entity;
struct media_entity *sink = link->sink->entity;
- int source_use = isp_pipeline_pm_use_count(source);
- int sink_use = isp_pipeline_pm_use_count(sink);
- int ret;
+ int source_use;
+ int sink_use;
+ int ret = 0;
+
+ if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
+ ret = media_entity_graph_walk_init(graph,
+ link->graph_obj.mdev);
+ if (ret)
+ return ret;
+ }
+
+ source_use = isp_pipeline_pm_use_count(source, graph);
+ sink_use = isp_pipeline_pm_use_count(sink, graph);
if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
!(flags & MEDIA_LNK_FL_ENABLED)) {
/* Powering off entities is assumed to never fail. */
- isp_pipeline_pm_power(source, -sink_use);
- isp_pipeline_pm_power(sink, -source_use);
+ isp_pipeline_pm_power(source, -sink_use, graph);
+ isp_pipeline_pm_power(sink, -source_use, graph);
return 0;
}
if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
(flags & MEDIA_LNK_FL_ENABLED)) {
- ret = isp_pipeline_pm_power(source, sink_use);
+ ret = isp_pipeline_pm_power(source, sink_use, graph);
if (ret < 0)
return ret;
- ret = isp_pipeline_pm_power(sink, source_use);
+ ret = isp_pipeline_pm_power(sink, source_use, graph);
if (ret < 0)
- isp_pipeline_pm_power(source, -sink_use);
-
- return ret;
+ isp_pipeline_pm_power(source, -sink_use, graph);
}
- return 0;
+ if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH)
+ media_entity_graph_walk_cleanup(graph);
+
+ return ret;
}
/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 5acc2e6..b6f81f2 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -176,6 +176,7 @@ struct isp_device {
struct v4l2_device v4l2_dev;
struct v4l2_async_notifier notifier;
struct media_device media_dev;
+ struct media_entity_graph pm_count_graph;
struct device *dev;
u32 revision;
@@ -265,7 +266,8 @@ void omap3isp_subclk_enable(struct isp_device *isp,
void omap3isp_subclk_disable(struct isp_device *isp,
enum isp_subclk_resource res);
-int omap3isp_pipeline_pm_use(struct media_entity *entity, int use);
+int omap3isp_pipeline_pm_use(struct media_entity *entity, int use,
+ struct media_entity_graph *graph);
int omap3isp_register_entities(struct platform_device *pdev,
struct v4l2_device *v4l2_dev);
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 52843ac..20dda20 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -227,8 +227,15 @@ static int isp_video_get_graph_data(struct isp_video *video,
struct media_entity *entity = &video->video.entity;
struct media_device *mdev = entity->graph_obj.mdev;
struct isp_video *far_end = NULL;
+ int ret;
mutex_lock(&mdev->graph_mutex);
+ ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
+ if (ret) {
+ mutex_unlock(&mdev->graph_mutex);
+ return ret;
+ }
+
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -252,6 +259,8 @@ static int isp_video_get_graph_data(struct isp_video *video,
mutex_unlock(&mdev->graph_mutex);
+ media_entity_graph_walk_cleanup(&graph);
+
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
pipe->input = far_end;
pipe->output = video;
@@ -1242,7 +1251,12 @@ static int isp_video_open(struct file *file)
goto done;
}
- ret = omap3isp_pipeline_pm_use(&video->video.entity, 1);
+ ret = media_entity_graph_walk_init(&handle->graph,
+ &video->isp->media_dev);
+ if (ret)
+ goto done;
+
+ ret = omap3isp_pipeline_pm_use(&video->video.entity, 1, &handle->graph);
if (ret < 0) {
omap3isp_put(video->isp);
goto done;
@@ -1273,6 +1287,7 @@ static int isp_video_open(struct file *file)
done:
if (ret < 0) {
v4l2_fh_del(&handle->vfh);
+ media_entity_graph_walk_cleanup(&handle->graph);
kfree(handle);
}
@@ -1292,7 +1307,8 @@ static int isp_video_release(struct file *file)
vb2_queue_release(&handle->queue);
mutex_unlock(&video->queue_lock);
- omap3isp_pipeline_pm_use(&video->video.entity, 0);
+ omap3isp_pipeline_pm_use(&video->video.entity, 0, &handle->graph);
+ media_entity_graph_walk_cleanup(&handle->graph);
/* Release the file handle. */
v4l2_fh_del(vfh);
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h
index 4071dd7..6c498ea 100644
--- a/drivers/media/platform/omap3isp/ispvideo.h
+++ b/drivers/media/platform/omap3isp/ispvideo.h
@@ -189,6 +189,7 @@ struct isp_video_fh {
struct vb2_queue queue;
struct v4l2_format format;
struct v4l2_fract timeperframe;
+ struct media_entity_graph graph;
};
#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 10/23] v4l: exynos4-is: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (8 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 09/23] v4l: omap3isp: " Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 11/23] v4l: xilinx: " Sakari Ailus
` (13 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media
Cc: laurent.pinchart, mchehab, hverkuil, javier, Kamil Debski,
Sylwester Nawrocki
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Kamil Debski <k.debski@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
drivers/media/platform/exynos4-is/media-dev.c | 31 +++++++++++++++++----------
drivers/media/platform/exynos4-is/media-dev.h | 1 +
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index d55b4f3..704040c 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -1046,10 +1046,10 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable)
}
/* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */
-static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)
+static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable,
+ struct media_entity_graph *graph)
{
struct media_entity *entity_err = entity;
- struct media_entity_graph graph;
int ret;
/*
@@ -1058,9 +1058,9 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)
* through active links. This is needed as we cannot power on/off the
* subdevs in random order.
*/
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ while ((entity = media_entity_graph_walk_next(graph))) {
if (!is_media_entity_v4l2_io(entity))
continue;
@@ -1071,10 +1071,11 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)
}
return 0;
- err:
- media_entity_graph_walk_start(&graph, entity_err);
- while ((entity_err = media_entity_graph_walk_next(&graph))) {
+err:
+ media_entity_graph_walk_start(graph, entity_err);
+
+ while ((entity_err = media_entity_graph_walk_next(graph))) {
if (!is_media_entity_v4l2_io(entity_err))
continue;
@@ -1090,21 +1091,29 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)
static int fimc_md_link_notify(struct media_link *link, unsigned int flags,
unsigned int notification)
{
+ struct media_entity_graph *graph =
+ &container_of(link->graph_obj.mdev, struct fimc_md,
+ media_dev)->link_setup_graph;
struct media_entity *sink = link->sink->entity;
int ret = 0;
/* Before link disconnection */
if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
+ ret = media_entity_graph_walk_init(graph,
+ link->graph_obj.mdev);
+ if (ret)
+ return ret;
if (!(flags & MEDIA_LNK_FL_ENABLED))
- ret = __fimc_md_modify_pipelines(sink, false);
+ ret = __fimc_md_modify_pipelines(sink, false, graph);
#if 0
else
/* TODO: Link state change validation */
#endif
/* After link activation */
- } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
- (link->flags & MEDIA_LNK_FL_ENABLED)) {
- ret = __fimc_md_modify_pipelines(sink, true);
+ } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) {
+ if (link->flags & MEDIA_LNK_FL_ENABLED)
+ ret = __fimc_md_modify_pipelines(sink, true, graph);
+ media_entity_graph_walk_cleanup(graph);
}
return ret ? -EPIPE : 0;
diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h
index 9a69913..e80c55d 100644
--- a/drivers/media/platform/exynos4-is/media-dev.h
+++ b/drivers/media/platform/exynos4-is/media-dev.h
@@ -154,6 +154,7 @@ struct fimc_md {
bool user_subdev_api;
spinlock_t slock;
struct list_head pipelines;
+ struct media_entity_graph link_setup_graph;
};
static inline
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 11/23] v4l: xilinx: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (9 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 10/23] v4l: exynos4-is: " Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 12/23] v4l: vsp1: " Sakari Ailus
` (12 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Hyun Kwon
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hyun Kwon <hyun.kwon@xilinx.com>
---
drivers/media/platform/xilinx/xilinx-dma.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index bc244a0..0a19824 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -182,10 +182,17 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
struct media_device *mdev = entity->graph_obj.mdev;
unsigned int num_inputs = 0;
unsigned int num_outputs = 0;
+ int ret;
mutex_lock(&mdev->graph_mutex);
/* Walk the graph to locate the video nodes. */
+ ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
+ if (ret) {
+ mutex_unlock(&mdev->graph_mutex);
+ return ret;
+ }
+
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -206,6 +213,8 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
mutex_unlock(&mdev->graph_mutex);
+ media_entity_graph_walk_cleanup(&graph);
+
/* We need exactly one output and zero or one input. */
if (num_outputs != 1 || num_inputs > 1)
return -EPIPE;
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 12/23] v4l: vsp1: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (10 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 11/23] v4l: xilinx: " Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 13/23] media: Use entity enums in graph walk Sakari Ailus
` (11 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/platform/vsp1/vsp1_video.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index f741582..ce10d86 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -415,6 +415,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
mutex_lock(&mdev->graph_mutex);
/* Walk the graph to locate the entities and video nodes. */
+ ret = media_entity_graph_walk_init(&graph, mdev);
+ if (ret) {
+ mutex_unlock(&mdev->graph_mutex);
+ return ret;
+ }
+
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -448,6 +454,8 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
mutex_unlock(&mdev->graph_mutex);
+ media_entity_graph_walk_cleanup(&graph);
+
/* We need one output and at least one input. */
if (pipe->num_inputs == 0 || !pipe->output) {
ret = -EPIPE;
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 13/23] media: Use entity enums in graph walk
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (11 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 12/23] v4l: vsp1: " Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 14/23] media: Keep using the same graph walk object for a given pipeline Sakari Ailus
` (10 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
This will also mean that the necessary graph related data structures will
be allocated dynamically, removing the need for maximum ID checks.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 16 ++++++----------
include/media/media-entity.h | 4 ++--
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 2232cb3..2dd60d75 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -366,7 +366,7 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph)
__must_check int media_entity_graph_walk_init(
struct media_entity_graph *graph, struct media_device *mdev)
{
- return 0;
+ return media_entity_enum_init(&graph->ent_enum, mdev);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
@@ -376,6 +376,7 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_init);
*/
void media_entity_graph_walk_cleanup(struct media_entity_graph *graph)
{
+ media_entity_enum_cleanup(&graph->ent_enum);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup);
@@ -395,14 +396,11 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup);
void media_entity_graph_walk_start(struct media_entity_graph *graph,
struct media_entity *entity)
{
+ media_entity_enum_zero(&graph->ent_enum);
+ media_entity_enum_set(&graph->ent_enum, entity);
+
graph->top = 0;
graph->stack[graph->top].entity = NULL;
- bitmap_zero(graph->entities, MEDIA_ENTITY_ENUM_MAX_ID);
-
- if (WARN_ON(media_entity_id(entity) >= MEDIA_ENTITY_ENUM_MAX_ID))
- return;
-
- __set_bit(media_entity_id(entity), graph->entities);
stack_push(graph, entity);
}
EXPORT_SYMBOL_GPL(media_entity_graph_walk_start);
@@ -445,11 +443,9 @@ media_entity_graph_walk_next(struct media_entity_graph *graph)
/* Get the entity in the other end of the link . */
next = media_entity_other(entity, link);
- if (WARN_ON(media_entity_id(next) >= MEDIA_ENTITY_ENUM_MAX_ID))
- return NULL;
/* Has the entity already been visited? */
- if (__test_and_set_bit(media_entity_id(next), graph->entities)) {
+ if (media_entity_enum_test_and_set(&graph->ent_enum, next)) {
link_top(graph) = link_top(graph)->next;
continue;
}
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index eaddcba..c29ddc2 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -103,7 +103,7 @@ struct media_entity_enum {
* @stack: Graph traversal stack; the stack contains information
* on the path the media entities to be walked and the
* links through which they were reached.
- * @entities: Visited entities
+ * @ent_enum: Visited entities
* @top: The top of the stack
*/
struct media_entity_graph {
@@ -112,7 +112,7 @@ struct media_entity_graph {
struct list_head *link;
} stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
- DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
+ struct media_entity_enum ent_enum;
int top;
};
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 14/23] media: Keep using the same graph walk object for a given pipeline
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (12 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 13/23] media: Use entity enums in graph walk Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 15/23] v4l: omap3isp: Use media entity enumeration interface Sakari Ailus
` (9 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
Initialise a given graph walk object once, and then keep using it whilst
the same pipeline is running. Once the pipeline is stopped, release the
graph walk object.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 17 +++++++++++------
include/media/media-entity.h | 4 +++-
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 2dd60d75..ddf3c23 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -488,10 +488,10 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
mutex_lock(&mdev->graph_mutex);
- ret = media_entity_graph_walk_init(&pipe->graph, mdev);
- if (ret) {
- mutex_unlock(&mdev->graph_mutex);
- return ret;
+ if (!pipe->streaming_count++) {
+ ret = media_entity_graph_walk_init(&pipe->graph, mdev);
+ if (ret)
+ goto error_graph_walk_start;
}
media_entity_graph_walk_start(&pipe->graph, entity);
@@ -592,7 +592,9 @@ error:
break;
}
- media_entity_graph_walk_cleanup(graph);
+error_graph_walk_start:
+ if (!--pipe->streaming_count)
+ media_entity_graph_walk_cleanup(graph);
mutex_unlock(&mdev->graph_mutex);
@@ -616,9 +618,11 @@ void media_entity_pipeline_stop(struct media_entity *entity)
{
struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph *graph = &entity->pipe->graph;
+ struct media_pipeline *pipe = entity->pipe;
mutex_lock(&mdev->graph_mutex);
+ WARN_ON(!pipe->streaming_count);
media_entity_graph_walk_start(graph, entity);
while ((entity = media_entity_graph_walk_next(graph))) {
@@ -627,7 +631,8 @@ void media_entity_pipeline_stop(struct media_entity *entity)
entity->pipe = NULL;
}
- media_entity_graph_walk_cleanup(graph);
+ if (!--pipe->streaming_count)
+ media_entity_graph_walk_cleanup(graph);
mutex_unlock(&mdev->graph_mutex);
}
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index c29ddc2..251eddf 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -119,9 +119,11 @@ struct media_entity_graph {
/*
* struct media_pipeline - Media pipeline related information
*
- * @graph: Media graph walk during pipeline start / stop
+ * @streaming_count: Streaming start count - streaming stop count
+ * @graph: Media graph walk during pipeline start / stop
*/
struct media_pipeline {
+ int streaming_count;
struct media_entity_graph graph;
};
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 15/23] v4l: omap3isp: Use media entity enumeration interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (13 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 14/23] media: Keep using the same graph walk object for a given pipeline Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 16/23] v4l: vsp1: " Sakari Ailus
` (8 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Instead of using a bitmap directly in a driver, use the new media entity
enumeration interface to perform the same.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/platform/omap3isp/isp.c | 21 +++++++++++++--------
drivers/media/platform/omap3isp/isp.h | 5 +++--
drivers/media/platform/omap3isp/ispccdc.c | 2 +-
drivers/media/platform/omap3isp/ispvideo.c | 20 ++++++++++++++------
drivers/media/platform/omap3isp/ispvideo.h | 4 ++--
5 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 4a01a36..939671d 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -896,7 +896,7 @@ static int isp_pipeline_enable(struct isp_pipeline *pipe,
* starting entities if the pipeline won't start anyway (those entities
* would then likely fail to stop, making the problem worse).
*/
- if (pipe->entities & isp->crashed)
+ if (media_entity_enum_intersects(&pipe->ent_enum, &isp->crashed))
return -EIO;
spin_lock_irqsave(&pipe->lock, flags);
@@ -989,7 +989,6 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)
struct v4l2_subdev *subdev;
int failure = 0;
int ret;
- u32 id;
/*
* We need to stop all the modules after CCDC first or they'll
@@ -1041,10 +1040,9 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)
if (ret) {
dev_info(isp->dev, "Unable to stop %s\n", subdev->name);
isp->stop_failure = true;
- if (subdev == &isp->isp_prev.subdev) {
- id = media_entity_id(&subdev->entity);
- isp->crashed |= 1U << id;
- }
+ if (subdev == &isp->isp_prev.subdev)
+ media_entity_enum_set(&isp->crashed,
+ &subdev->entity);
failure = -ETIMEDOUT;
}
}
@@ -1250,7 +1248,7 @@ static int isp_reset(struct isp_device *isp)
}
isp->stop_failure = false;
- isp->crashed = 0;
+ media_entity_enum_zero(&isp->crashed);
return 0;
}
@@ -1661,7 +1659,8 @@ static void __omap3isp_put(struct isp_device *isp, bool save_ctx)
/* Reset the ISP if an entity has failed to stop. This is the
* only way to recover from such conditions.
*/
- if (isp->crashed || isp->stop_failure)
+ if (!media_entity_enum_empty(&isp->crashed) ||
+ isp->stop_failure)
isp_reset(isp);
isp_disable_clocks(isp);
}
@@ -2201,6 +2200,8 @@ static int isp_remove(struct platform_device *pdev)
isp_detach_iommu(isp);
__omap3isp_put(isp, false);
+ media_entity_enum_cleanup(&isp->crashed);
+
return 0;
}
@@ -2348,6 +2349,10 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
struct isp_bus_cfg *bus;
int ret;
+ ret = media_entity_enum_init(&isp->crashed, &isp->media_dev);
+ if (ret)
+ return ret;
+
list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
/* Only try to link entities whose interface was set on bound */
if (sd->host_priv) {
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index b6f81f2..49b7f71 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -17,6 +17,7 @@
#ifndef OMAP3_ISP_CORE_H
#define OMAP3_ISP_CORE_H
+#include <media/media-entity.h>
#include <media/v4l2-async.h>
#include <media/v4l2-device.h>
#include <linux/clk-provider.h>
@@ -152,7 +153,7 @@ struct isp_xclk {
* @stat_lock: Spinlock for handling statistics
* @isp_mutex: Mutex for serializing requests to ISP.
* @stop_failure: Indicates that an entity failed to stop.
- * @crashed: Bitmask of crashed entities (indexed by entity ID)
+ * @crashed: Crashed ent_enum
* @has_context: Context has been saved at least once and can be restored.
* @ref_count: Reference count for handling multiple ISP requests.
* @cam_ick: Pointer to camera interface clock structure.
@@ -195,7 +196,7 @@ struct isp_device {
spinlock_t stat_lock; /* common lock for statistic drivers */
struct mutex isp_mutex; /* For handling ref_count field */
bool stop_failure;
- u32 crashed;
+ struct media_entity_enum crashed;
int has_context;
int ref_count;
unsigned int autoidle;
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index f0e530c..80cf550 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -1608,7 +1608,7 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc)
/* Wait for the CCDC to become idle. */
if (ccdc_sbl_wait_idle(ccdc, 1000)) {
dev_info(isp->dev, "CCDC won't become idle!\n");
- isp->crashed |= 1U << media_entity_id(&ccdc->subdev.entity);
+ media_entity_enum_set(&isp->crashed, &ccdc->subdev.entity);
omap3isp_pipeline_cancel_stream(pipe);
return 0;
}
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 20dda20..be57a38 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -241,7 +241,7 @@ static int isp_video_get_graph_data(struct isp_video *video,
while ((entity = media_entity_graph_walk_next(&graph))) {
struct isp_video *__video;
- pipe->entities |= 1 << media_entity_id(entity);
+ media_entity_enum_set(&pipe->ent_enum, entity);
if (far_end != NULL)
continue;
@@ -899,7 +899,6 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
struct v4l2_ext_control ctrl;
unsigned int i;
int ret;
- u32 id;
/* Memory-to-memory pipelines have no external subdev. */
if (pipe->input != NULL)
@@ -907,7 +906,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
for (i = 0; i < ARRAY_SIZE(ents); i++) {
/* Is the entity part of the pipeline? */
- if (!(pipe->entities & (1 << media_entity_id(ents[i]))))
+ if (!media_entity_enum_test(&pipe->ent_enum, ents[i]))
continue;
/* ISP entities have always sink pad == 0. Find source. */
@@ -959,8 +958,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
pipe->external_rate = ctrl.value64;
- id = media_entity_id(&isp->isp_ccdc.subdev.entity);
- if (pipe->entities & (1 << id)) {
+ if (media_entity_enum_test(&pipe->ent_enum,
+ &isp->isp_ccdc.subdev.entity)) {
unsigned int rate = UINT_MAX;
/*
* Check that maximum allowed CCDC pixel rate isn't
@@ -1026,7 +1025,9 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
pipe = video->video.entity.pipe
? to_isp_pipeline(&video->video.entity) : &video->pipe;
- pipe->entities = 0;
+ ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev);
+ if (ret)
+ goto err_enum_init;
/* TODO: Implement PM QoS */
pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]);
@@ -1100,6 +1101,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
}
mutex_unlock(&video->stream_lock);
+
return 0;
err_set_stream:
@@ -1120,7 +1122,11 @@ err_pipeline_start:
INIT_LIST_HEAD(&video->dmaqueue);
video->queue = NULL;
+ media_entity_enum_cleanup(&pipe->ent_enum);
+
+err_enum_init:
mutex_unlock(&video->stream_lock);
+
return ret;
}
@@ -1172,6 +1178,8 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
/* TODO: Implement PM QoS */
media_entity_pipeline_stop(&video->video.entity);
+ media_entity_enum_cleanup(&pipe->ent_enum);
+
done:
mutex_unlock(&video->stream_lock);
return 0;
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h
index 6c498ea..5bdad2c 100644
--- a/drivers/media/platform/omap3isp/ispvideo.h
+++ b/drivers/media/platform/omap3isp/ispvideo.h
@@ -80,7 +80,7 @@ enum isp_pipeline_state {
* struct isp_pipeline - An ISP hardware pipeline
* @field: The field being processed by the pipeline
* @error: A hardware error occurred during capture
- * @entities: Bitmask of entities in the pipeline (indexed by entity ID)
+ * @ent_enum: Entities in the pipeline
*/
struct isp_pipeline {
struct media_pipeline pipe;
@@ -89,7 +89,7 @@ struct isp_pipeline {
enum isp_pipeline_stream_state stream_state;
struct isp_video *input;
struct isp_video *output;
- u32 entities;
+ struct media_entity_enum ent_enum;
unsigned long l3_ick;
unsigned int max_rate;
enum v4l2_field field;
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 16/23] v4l: vsp1: Use media entity enumeration interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (14 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 15/23] v4l: omap3isp: Use media entity enumeration interface Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 17/23] staging: v4l: omap4iss: Fix sub-device power management code Sakari Ailus
` (7 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Instead of using a bitmap directly in a driver, use the new media entity
enumeration interface to perform the same.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/platform/vsp1/vsp1_video.c | 45 ++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index ce10d86..58e6429 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -311,24 +311,35 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,
struct vsp1_rwpf *output)
{
struct vsp1_entity *entity;
- unsigned int entities = 0;
+ struct media_entity_enum ent_enum;
struct media_pad *pad;
+ int rval;
bool bru_found = false;
input->location.left = 0;
input->location.top = 0;
+ rval = media_entity_enum_init(
+ &ent_enum, input->entity.pads[RWPF_PAD_SOURCE].graph_obj.mdev);
+ if (rval)
+ return rval;
+
pad = media_entity_remote_pad(&input->entity.pads[RWPF_PAD_SOURCE]);
while (1) {
- if (pad == NULL)
- return -EPIPE;
+ if (pad == NULL) {
+ rval = -EPIPE;
+ goto out;
+ }
/* We've reached a video node, that shouldn't have happened. */
- if (!is_media_entity_v4l2_subdev(pad->entity))
- return -EPIPE;
+ if (!is_media_entity_v4l2_subdev(pad->entity)) {
+ rval = -EPIPE;
+ goto out;
+ }
- entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity));
+ entity = to_vsp1_entity(
+ media_entity_to_v4l2_subdev(pad->entity));
/* A BRU is present in the pipeline, store the compose rectangle
* location in the input RPF for use when configuring the RPF.
@@ -351,15 +362,18 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,
break;
/* Ensure the branch has no loop. */
- if (entities & (1 << media_entity_id(&entity->subdev.entity)))
- return -EPIPE;
-
- entities |= 1 << media_entity_id(&entity->subdev.entity);
+ if (media_entity_enum_test_and_set(&ent_enum,
+ &entity->subdev.entity)) {
+ rval = -EPIPE;
+ goto out;
+ }
/* UDS can't be chained. */
if (entity->type == VSP1_ENTITY_UDS) {
- if (pipe->uds)
- return -EPIPE;
+ if (pipe->uds) {
+ rval = -EPIPE;
+ goto out;
+ }
pipe->uds = entity;
pipe->uds_input = bru_found ? pipe->bru
@@ -377,9 +391,12 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,
/* The last entity must be the output WPF. */
if (entity != &output->entity)
- return -EPIPE;
+ rval = -EPIPE;
- return 0;
+out:
+ media_entity_enum_cleanup(&ent_enum);
+
+ return rval;
}
static void __vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe)
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 17/23] staging: v4l: omap4iss: Fix sub-device power management code
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (15 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 16/23] v4l: vsp1: " Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 18/23] staging: v4l: omap4iss: Use media entity enumeration interface Sakari Ailus
` (6 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The same bug was present in the omap4iss driver as was in the omap3isp
driver. The code got copied to the omap4iss driver while broken. Fix the
omap4iss driver as well.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/staging/media/omap4iss/iss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index 076ddd4..c097fd5 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -533,14 +533,14 @@ static int iss_pipeline_link_notify(struct media_link *link, u32 flags,
int ret;
if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
- !(link->flags & MEDIA_LNK_FL_ENABLED)) {
+ !(flags & MEDIA_LNK_FL_ENABLED)) {
/* Powering off entities is assumed to never fail. */
iss_pipeline_pm_power(source, -sink_use);
iss_pipeline_pm_power(sink, -source_use);
return 0;
}
- if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
+ if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
(flags & MEDIA_LNK_FL_ENABLED)) {
ret = iss_pipeline_pm_power(source, sink_use);
if (ret < 0)
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 18/23] staging: v4l: omap4iss: Use media entity enumeration interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (16 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 17/23] staging: v4l: omap4iss: Fix sub-device power management code Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 19/23] staging: v4l: omap4iss: Use the new media graph walk interface Sakari Ailus
` (5 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Instead of using a bitmap directly in a driver, use the new media
entity enumeration interface to perform the same.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/staging/media/omap4iss/iss.c | 15 +++++++++++----
drivers/staging/media/omap4iss/iss.h | 4 ++--
drivers/staging/media/omap4iss/iss_video.c | 23 ++++++++++++++++-------
drivers/staging/media/omap4iss/iss_video.h | 4 ++--
4 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index c097fd5..6738d01 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -606,7 +606,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,
* crashed. Mark it as such, the ISS will be reset when
* applications will release it.
*/
- iss->crashed |= 1U << media_entity_id(&subdev->entity);
+ media_entity_enum_set(&iss->crashed, &subdev->entity);
failure = -ETIMEDOUT;
}
}
@@ -641,7 +641,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe,
* pipeline won't start anyway (those entities would then likely fail to
* stop, making the problem worse).
*/
- if (pipe->entities & iss->crashed)
+ if (media_entity_enum_intersects(&pipe->ent_enum, &iss->crashed))
return -EIO;
spin_lock_irqsave(&pipe->lock, flags);
@@ -761,7 +761,8 @@ static int iss_reset(struct iss_device *iss)
return -ETIMEDOUT;
}
- iss->crashed = 0;
+ media_entity_enum_zero(&iss->crashed);
+
return 0;
}
@@ -1090,7 +1091,7 @@ void omap4iss_put(struct iss_device *iss)
* be worth investigating whether resetting the ISP only can't
* fix the problem in some cases.
*/
- if (iss->crashed)
+ if (!media_entity_enum_empty(&iss->crashed))
iss_reset(iss);
iss_disable_clocks(iss);
}
@@ -1490,6 +1491,10 @@ static int iss_probe(struct platform_device *pdev)
if (ret < 0)
goto error_modules;
+ ret = media_entity_enum_init(&iss->crashed, &iss->media_dev);
+ if (ret)
+ goto error_entities;
+
ret = iss_create_pads_links(iss);
if (ret < 0)
goto error_entities;
@@ -1500,6 +1505,7 @@ static int iss_probe(struct platform_device *pdev)
error_entities:
iss_unregister_entities(iss);
+ media_entity_enum_cleanup(&iss->crashed);
error_modules:
iss_cleanup_modules(iss);
error_iss:
@@ -1517,6 +1523,7 @@ static int iss_remove(struct platform_device *pdev)
struct iss_device *iss = platform_get_drvdata(pdev);
iss_unregister_entities(iss);
+ media_entity_enum_cleanup(&iss->crashed);
iss_cleanup_modules(iss);
return 0;
diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h
index 35df8b4..5dd0d99 100644
--- a/drivers/staging/media/omap4iss/iss.h
+++ b/drivers/staging/media/omap4iss/iss.h
@@ -82,7 +82,7 @@ struct iss_reg {
/*
* struct iss_device - ISS device structure.
* @syscon: Regmap for the syscon register space
- * @crashed: Bitmask of crashed entities (indexed by entity ID)
+ * @crashed: Crashed entities
*/
struct iss_device {
struct v4l2_device v4l2_dev;
@@ -101,7 +101,7 @@ struct iss_device {
u64 raw_dmamask;
struct mutex iss_mutex; /* For handling ref_count field */
- unsigned int crashed;
+ struct media_entity_enum crashed;
int has_context;
int ref_count;
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index cbe5783..4fd5fc8 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -751,7 +751,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
struct iss_video_fh *vfh = to_iss_video_fh(fh);
struct iss_video *video = video_drvdata(file);
struct media_entity_graph graph;
- struct media_entity *entity;
+ struct media_entity *entity = &video->video.entity;
enum iss_pipeline_state state;
struct iss_pipeline *pipe;
struct iss_video *far_end;
@@ -766,24 +766,26 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
/* Start streaming on the pipeline. No link touching an entity in the
* pipeline can be activated or deactivated once streaming is started.
*/
- pipe = video->video.entity.pipe
- ? to_iss_pipeline(&video->video.entity) : &video->pipe;
+ pipe = entity->pipe
+ ? to_iss_pipeline(entity) : &video->pipe;
pipe->external = NULL;
pipe->external_rate = 0;
pipe->external_bpp = 0;
- pipe->entities = 0;
+
+ ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev);
+ if (ret)
+ goto err_enum_init;
if (video->iss->pdata->set_constraints)
video->iss->pdata->set_constraints(video->iss, true);
- ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
+ ret = media_entity_pipeline_start(entity, &pipe->pipe);
if (ret < 0)
goto err_media_entity_pipeline_start;
- entity = &video->video.entity;
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph)))
- pipe->entities |= 1 << media_entity_id(entity);
+ media_entity_enum_set(&pipe->ent_enum, entity);
/* Verify that the currently configured format matches the output of
* the connected subdev.
@@ -854,6 +856,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
}
mutex_unlock(&video->stream_lock);
+
return 0;
err_omap4iss_set_stream:
@@ -865,7 +868,11 @@ err_media_entity_pipeline_start:
video->iss->pdata->set_constraints(video->iss, false);
video->queue = NULL;
+ media_entity_enum_cleanup(&pipe->ent_enum);
+
+err_enum_init:
mutex_unlock(&video->stream_lock);
+
return ret;
}
@@ -903,6 +910,8 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
vb2_streamoff(&vfh->queue, type);
video->queue = NULL;
+ media_entity_enum_cleanup(&pipe->ent_enum);
+
if (video->iss->pdata->set_constraints)
video->iss->pdata->set_constraints(video->iss, false);
media_entity_pipeline_stop(&video->video.entity);
diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h
index f11fce2..d16bc45 100644
--- a/drivers/staging/media/omap4iss/iss_video.h
+++ b/drivers/staging/media/omap4iss/iss_video.h
@@ -77,7 +77,7 @@ enum iss_pipeline_state {
/*
* struct iss_pipeline - An OMAP4 ISS hardware pipeline
- * @entities: Bitmask of entities in the pipeline (indexed by entity ID)
+ * @ent_enum: Entities in the pipeline
* @error: A hardware error occurred during capture
*/
struct iss_pipeline {
@@ -87,7 +87,7 @@ struct iss_pipeline {
enum iss_pipeline_stream_state stream_state;
struct iss_video *input;
struct iss_video *output;
- unsigned int entities;
+ struct media_entity_enum ent_enum;
atomic_t frame_number;
bool do_propagation; /* of frame number */
bool error;
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 19/23] staging: v4l: omap4iss: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (17 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 18/23] staging: v4l: omap4iss: Use media entity enumeration interface Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 20/23] staging: v4l: davinci_vpbe: " Sakari Ailus
` (4 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/staging/media/omap4iss/iss.c | 59 +++++++++++++++++++-----------
drivers/staging/media/omap4iss/iss.h | 4 +-
drivers/staging/media/omap4iss/iss_video.c | 33 +++++++++++++++--
drivers/staging/media/omap4iss/iss_video.h | 1 +
4 files changed, 70 insertions(+), 27 deletions(-)
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index 6738d01..d7eadc8 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -389,14 +389,14 @@ static irqreturn_t iss_isr(int irq, void *_iss)
*
* Return the total number of users of all video device nodes in the pipeline.
*/
-static int iss_pipeline_pm_use_count(struct media_entity *entity)
+static int iss_pipeline_pm_use_count(struct media_entity *entity,
+ struct media_entity_graph *graph)
{
- struct media_entity_graph graph;
int use = 0;
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ while ((entity = media_entity_graph_walk_next(graph))) {
if (is_media_entity_v4l2_io(entity))
use += entity->use_count;
}
@@ -449,27 +449,27 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change)
*
* Return 0 on success or a negative error code on failure.
*/
-static int iss_pipeline_pm_power(struct media_entity *entity, int change)
+static int iss_pipeline_pm_power(struct media_entity *entity, int change,
+ struct media_entity_graph *graph)
{
- struct media_entity_graph graph;
struct media_entity *first = entity;
int ret = 0;
if (!change)
return 0;
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(graph, entity);
- while (!ret && (entity = media_entity_graph_walk_next(&graph)))
+ while (!ret && (entity = media_entity_graph_walk_next(graph)))
if (is_media_entity_v4l2_subdev(entity))
ret = iss_pipeline_pm_power_one(entity, change);
if (!ret)
return 0;
- media_entity_graph_walk_start(&graph, first);
+ media_entity_graph_walk_start(graph, first);
- while ((first = media_entity_graph_walk_next(&graph))
+ while ((first = media_entity_graph_walk_next(graph))
&& first != entity)
if (is_media_entity_v4l2_subdev(first))
iss_pipeline_pm_power_one(first, -change);
@@ -489,7 +489,8 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change)
* off is assumed to never fail. No failure can occur when the use parameter is
* set to 0.
*/
-int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)
+int omap4iss_pipeline_pm_use(struct media_entity *entity, int use,
+ struct media_entity_graph *graph)
{
int change = use ? 1 : -1;
int ret;
@@ -501,7 +502,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)
WARN_ON(entity->use_count < 0);
/* Apply power change to connected non-nodes. */
- ret = iss_pipeline_pm_power(entity, change);
+ ret = iss_pipeline_pm_power(entity, change, graph);
if (ret < 0)
entity->use_count -= change;
@@ -526,34 +527,48 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)
static int iss_pipeline_link_notify(struct media_link *link, u32 flags,
unsigned int notification)
{
+ struct media_entity_graph *graph =
+ &container_of(link->graph_obj.mdev, struct iss_device,
+ media_dev)->pm_count_graph;
struct media_entity *source = link->source->entity;
struct media_entity *sink = link->sink->entity;
- int source_use = iss_pipeline_pm_use_count(source);
- int sink_use = iss_pipeline_pm_use_count(sink);
+ int source_use;
+ int sink_use;
int ret;
+ if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) {
+ ret = media_entity_graph_walk_init(graph,
+ link->graph_obj.mdev);
+ if (ret)
+ return ret;
+ }
+
+ source_use = iss_pipeline_pm_use_count(source, graph);
+ sink_use = iss_pipeline_pm_use_count(sink, graph);
+
if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH &&
!(flags & MEDIA_LNK_FL_ENABLED)) {
/* Powering off entities is assumed to never fail. */
- iss_pipeline_pm_power(source, -sink_use);
- iss_pipeline_pm_power(sink, -source_use);
+ iss_pipeline_pm_power(source, -sink_use, graph);
+ iss_pipeline_pm_power(sink, -source_use, graph);
return 0;
}
if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH &&
(flags & MEDIA_LNK_FL_ENABLED)) {
- ret = iss_pipeline_pm_power(source, sink_use);
+ ret = iss_pipeline_pm_power(source, sink_use, graph);
if (ret < 0)
return ret;
- ret = iss_pipeline_pm_power(sink, source_use);
+ ret = iss_pipeline_pm_power(sink, source_use, graph);
if (ret < 0)
- iss_pipeline_pm_power(source, -sink_use);
-
- return ret;
+ iss_pipeline_pm_power(source, -sink_use, graph);
}
- return 0;
+ if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH)
+ media_entity_graph_walk_cleanup(graph);
+
+ return ret;
}
/* -----------------------------------------------------------------------------
diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h
index 5dd0d99..ee7dc08 100644
--- a/drivers/staging/media/omap4iss/iss.h
+++ b/drivers/staging/media/omap4iss/iss.h
@@ -87,6 +87,7 @@ struct iss_reg {
struct iss_device {
struct v4l2_device v4l2_dev;
struct media_device media_dev;
+ struct media_entity_graph pm_count_graph;
struct device *dev;
u32 revision;
@@ -151,7 +152,8 @@ void omap4iss_isp_subclk_enable(struct iss_device *iss,
void omap4iss_isp_subclk_disable(struct iss_device *iss,
enum iss_isp_subclk_resource res);
-int omap4iss_pipeline_pm_use(struct media_entity *entity, int use);
+int omap4iss_pipeline_pm_use(struct media_entity *entity, int use,
+ struct media_entity_graph *graph);
int omap4iss_register_entities(struct platform_device *pdev,
struct v4l2_device *v4l2_dev);
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 4fd5fc8..450578b 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -210,6 +210,12 @@ iss_video_far_end(struct iss_video *video)
struct iss_video *far_end = NULL;
mutex_lock(&mdev->graph_mutex);
+
+ if (media_entity_graph_walk_init(&graph, mdev)) {
+ mutex_unlock(&mdev->graph_mutex);
+ return NULL;
+ }
+
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -227,6 +233,9 @@ iss_video_far_end(struct iss_video *video)
}
mutex_unlock(&mdev->graph_mutex);
+
+ media_entity_graph_walk_cleanup(&graph);
+
return far_end;
}
@@ -774,7 +783,11 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev);
if (ret)
- goto err_enum_init;
+ goto err_graph_walk_init;
+
+ ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
+ if (ret)
+ goto err_graph_walk_init;
if (video->iss->pdata->set_constraints)
video->iss->pdata->set_constraints(video->iss, true);
@@ -855,6 +868,8 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
spin_unlock_irqrestore(&video->qlock, flags);
}
+ media_entity_graph_walk_cleanup(&graph);
+
mutex_unlock(&video->stream_lock);
return 0;
@@ -868,9 +883,11 @@ err_media_entity_pipeline_start:
video->iss->pdata->set_constraints(video->iss, false);
video->queue = NULL;
+ media_entity_graph_walk_cleanup(&graph);
+
+err_graph_walk_init:
media_entity_enum_cleanup(&pipe->ent_enum);
-err_enum_init:
mutex_unlock(&video->stream_lock);
return ret;
@@ -994,7 +1011,13 @@ static int iss_video_open(struct file *file)
goto done;
}
- ret = omap4iss_pipeline_pm_use(&video->video.entity, 1);
+ ret = media_entity_graph_walk_init(&handle->graph,
+ &video->iss->media_dev);
+ if (ret)
+ goto done;
+
+ ret = omap4iss_pipeline_pm_use(&video->video.entity, 1,
+ &handle->graph);
if (ret < 0) {
omap4iss_put(video->iss);
goto done;
@@ -1033,6 +1056,7 @@ static int iss_video_open(struct file *file)
done:
if (ret < 0) {
v4l2_fh_del(&handle->vfh);
+ media_entity_graph_walk_cleanup(&handle->graph);
kfree(handle);
}
@@ -1048,12 +1072,13 @@ static int iss_video_release(struct file *file)
/* Disable streaming and free the buffers queue resources. */
iss_video_streamoff(file, vfh, video->type);
- omap4iss_pipeline_pm_use(&video->video.entity, 0);
+ omap4iss_pipeline_pm_use(&video->video.entity, 0, &handle->graph);
/* Release the videobuf2 queue */
vb2_queue_release(&handle->queue);
/* Release the file handle. */
+ media_entity_graph_walk_cleanup(&handle->graph);
v4l2_fh_del(vfh);
kfree(handle);
file->private_data = NULL;
diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h
index d16bc45..94764ea 100644
--- a/drivers/staging/media/omap4iss/iss_video.h
+++ b/drivers/staging/media/omap4iss/iss_video.h
@@ -183,6 +183,7 @@ struct iss_video_fh {
struct vb2_queue queue;
struct v4l2_format format;
struct v4l2_fract timeperframe;
+ struct media_entity_graph graph;
};
#define to_iss_video_fh(fh) container_of(fh, struct iss_video_fh, vfh)
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 20/23] staging: v4l: davinci_vpbe: Use the new media graph walk interface
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (18 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 19/23] staging: v4l: omap4iss: Use the new media graph walk interface Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 21/23] media: Remove pre-allocated entity enumeration bitmap Sakari Ailus
` (3 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Prabhakar Lad
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Prabhakar Lad <prabhakar.lad@ti.com>
---
drivers/staging/media/davinci_vpfe/vpfe_video.c | 37 ++++++++++++++++++-------
drivers/staging/media/davinci_vpfe/vpfe_video.h | 1 +
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 2dbf14b..1bacd19 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -127,13 +127,14 @@ __vpfe_video_get_format(struct vpfe_video_device *video,
}
/* make a note of pipeline details */
-static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
+static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
{
+ struct media_entity_graph graph;
struct media_entity *entity = &video->video_dev.entity;
struct media_device *mdev = entity->graph_obj.mdev;
struct vpfe_pipeline *pipe = &video->pipe;
struct vpfe_video_device *far_end = NULL;
- struct media_entity_graph graph;
+ int ret;
pipe->input_num = 0;
pipe->output_num = 0;
@@ -144,6 +145,11 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
pipe->outputs[pipe->output_num++] = video;
mutex_lock(&mdev->graph_mutex);
+ ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
+ if (ret) {
+ mutex_unlock(&video->lock);
+ return -ENOMEM;
+ }
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
if (entity == &video->video_dev.entity)
@@ -156,7 +162,10 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
else
pipe->outputs[pipe->output_num++] = far_end;
}
+ media_entity_graph_walk_cleanup(&graph);
mutex_unlock(&mdev->graph_mutex);
+
+ return 0;
}
/* update pipe state selected by user */
@@ -165,7 +174,9 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video)
struct vpfe_pipeline *pipe = &video->pipe;
int ret;
- vpfe_prepare_pipeline(video);
+ ret = vpfe_prepare_pipeline(video);
+ if (ret)
+ return ret;
/* Find out if there is any input video
if yes, it is single shot.
@@ -276,11 +287,10 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe)
*/
static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
{
- struct media_entity_graph graph;
struct media_entity *entity;
struct v4l2_subdev *subdev;
struct media_device *mdev;
- int ret = 0;
+ int ret;
if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
entity = vpfe_get_input_entity(pipe->outputs[0]);
@@ -289,8 +299,12 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
mdev = entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex);
- media_entity_graph_walk_start(&graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ ret = media_entity_graph_walk_init(&pipe->graph,
+ entity->graph_obj.mdev);
+ if (ret)
+ goto out;
+ media_entity_graph_walk_start(&pipe->graph, entity);
+ while ((entity = media_entity_graph_walk_next(&pipe->graph))) {
if (!is_media_entity_v4l2_subdev(entity))
continue;
@@ -299,6 +313,9 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
if (ret < 0 && ret != -ENOIOCTLCMD)
break;
}
+out:
+ if (ret)
+ media_entity_graph_walk_cleanup(&pipe->graph);
mutex_unlock(&mdev->graph_mutex);
return ret;
}
@@ -316,7 +333,6 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
*/
static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
{
- struct media_entity_graph graph;
struct media_entity *entity;
struct v4l2_subdev *subdev;
struct media_device *mdev;
@@ -329,9 +345,9 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
mdev = entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex);
- media_entity_graph_walk_start(&graph, entity);
+ media_entity_graph_walk_start(&pipe->graph, entity);
- while ((entity = media_entity_graph_walk_next(&graph))) {
+ while ((entity = media_entity_graph_walk_next(&pipe->graph))) {
if (!is_media_entity_v4l2_subdev(entity))
continue;
@@ -342,6 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
}
mutex_unlock(&mdev->graph_mutex);
+ media_entity_graph_walk_cleanup(&pipe->graph);
return ret ? -ETIMEDOUT : 0;
}
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h
index 1b1b6c4..81f7698 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.h
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h
@@ -51,6 +51,7 @@ enum vpfe_video_state {
struct vpfe_pipeline {
/* media pipeline */
struct media_pipeline *pipe;
+ struct media_entity_graph graph;
/* state of the pipeline, continuous,
* single-shot or stopped
*/
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 21/23] media: Remove pre-allocated entity enumeration bitmap
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (19 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 20/23] staging: v4l: davinci_vpbe: " Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 22/23] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.c Sakari Ailus
` (2 subsequent siblings)
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
The bitmaps for entity enumerations used to be statically allocated. Now
that the drivers have been converted to use the new interface which
explicitly initialises the enum objects, drop the pre-allocated bitmaps.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 16 +++++-----------
include/media/media-entity.h | 9 ++-------
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index ddf3c23..c799a4e 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -222,14 +222,10 @@ void media_gobj_remove(struct media_gobj *gobj)
*/
int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max)
{
- if (idx_max > MEDIA_ENTITY_ENUM_MAX_ID) {
- ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG),
- sizeof(long), GFP_KERNEL);
- if (!ent_enum->bmap)
- return -ENOMEM;
- } else {
- ent_enum->bmap = ent_enum->prealloc_bmap;
- }
+ ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG),
+ sizeof(long), GFP_KERNEL);
+ if (!ent_enum->bmap)
+ return -ENOMEM;
bitmap_zero(ent_enum->bmap, idx_max);
ent_enum->idx_max = idx_max;
@@ -245,9 +241,7 @@ EXPORT_SYMBOL_GPL(__media_entity_enum_init);
*/
void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
{
- if (ent_enum->bmap != ent_enum->prealloc_bmap)
- kfree(ent_enum->bmap);
- ent_enum->bmap = NULL;
+ kfree(ent_enum->bmap);
}
EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 251eddf..034b9d7 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -72,27 +72,22 @@ struct media_gobj {
};
#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
-#define MEDIA_ENTITY_ENUM_MAX_ID 64
/*
* The number of pads can't be bigger than the number of entities,
* as the worse-case scenario is to have one entity linked up to
- * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
+ * 63 entities.
*/
-#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
+#define MEDIA_ENTITY_MAX_PADS 63
/**
* struct media_entity_enum - An enumeration of media entities.
*
- * @prealloc_bmap: Pre-allocated space reserved for media entities if the
- * total number of entities does not exceed
- * MEDIA_ENTITY_ENUM_MAX_ID.
* @bmap: Bit map in which each bit represents one entity at struct
* media_entity->internal_idx.
* @idx_max: Number of bits in bmap
*/
struct media_entity_enum {
- DECLARE_BITMAP(prealloc_bmap, MEDIA_ENTITY_ENUM_MAX_ID);
unsigned long *bmap;
int idx_max;
};
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 22/23] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.c
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (20 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 21/23] media: Remove pre-allocated entity enumeration bitmap Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 23/23] media: Update media graph walk documentation for the changed API Sakari Ailus
2015-12-16 14:03 ` [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
This isn't really a part of any interface drivers are expected to use. In
order to keep drivers from using it, hide it in media-entity.c. This was
always an arbitrary number and should be removed in the long run.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/media-entity.c | 5 +++++
include/media/media-entity.h | 7 -------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index c799a4e..2e4ffaf 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -245,6 +245,11 @@ void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
}
EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
+/*
+ * TODO: Get rid of this.
+ */
+#define MEDIA_ENTITY_MAX_PADS 63
+
/**
* media_entity_init - Initialize a media entity
*
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 034b9d7..d2d668a 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -73,13 +73,6 @@ struct media_gobj {
#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
-/*
- * The number of pads can't be bigger than the number of entities,
- * as the worse-case scenario is to have one entity linked up to
- * 63 entities.
- */
-#define MEDIA_ENTITY_MAX_PADS 63
-
/**
* struct media_entity_enum - An enumeration of media entities.
*
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3 23/23] media: Update media graph walk documentation for the changed API
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (21 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 22/23] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.c Sakari Ailus
@ 2015-12-16 13:32 ` Sakari Ailus
2015-12-16 14:03 ` [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
23 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:32 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier
media_entity_graph_walk_init() and media_entity_graph_walk_cleanup() are
now mandatory.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Documentation/media-framework.txt | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt
index b424de6..738a526 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -241,13 +241,22 @@ supported by the graph traversal API. To prevent infinite loops, the graph
traversal code limits the maximum depth to MEDIA_ENTITY_ENUM_MAX_DEPTH,
currently defined as 16.
-Drivers initiate a graph traversal by calling
+The graph traversal must be initialised calling
+
+ media_entity_graph_walk_init(struct media_entity_graph *graph);
+
+The return value of the function must be checked. Should the number of
+graph entities exceed the pre-allocated memory, it will also allocate
+memory for the enumeration.
+
+Once initialised, the graph walk may be started by calling
media_entity_graph_walk_start(struct media_entity_graph *graph,
struct media_entity *entity);
-The graph structure, provided by the caller, is initialized to start graph
-traversal at the given entity.
+The graph structure, provided by the caller, is initialized to start
+graph traversal at the given entity. It is possible to start the graph
+walk multiple times using the same graph struct.
Drivers can then retrieve the next entity by calling
@@ -255,8 +264,11 @@ Drivers can then retrieve the next entity by calling
When the graph traversal is complete the function will return NULL.
-Graph traversal can be interrupted at any moment. No cleanup function call is
-required and the graph structure can be freed normally.
+Graph traversal can be interrupted at any moment. Once the graph
+structure is no longer needed, the resources that have been allocated
+by media_entity_graph_walk_init() are released using
+
+ media_entity_graph_walk_cleanup(struct media_entity_graph *graph);
Helper functions can be used to find a link between two given pads, or a pad
connected to another pad through an enabled link
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH v3.1 03/23] media: Add an API to manage entity enumerations
2015-12-16 13:32 ` [PATCH v3 03/23] media: Add an API to manage entity enumerations Sakari Ailus
@ 2015-12-16 13:44 ` Sakari Ailus
0 siblings, 0 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 13:44 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, mchehab, hverkuil, javier, Sakari Ailus
From: Sakari Ailus <sakari.ailus@linux.intel.com>
This is useful in e.g. knowing whether certain operations have already
been performed for an entity. The users include the framework itself (for
graph walking) and a number of drivers.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
since v3:
- Also rename the argument "e" in the prototype of
__media_entity_enum_init().
- Add __must_check modifier to __media_entity_enum_init().
drivers/media/media-entity.c | 40 ++++++++++++
include/media/media-device.h | 15 +++++
include/media/media-entity.h | 141 ++++++++++++++++++++++++++++++++++++++++---
3 files changed, 188 insertions(+), 8 deletions(-)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index d11f440..678cc57 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -213,6 +213,46 @@ void media_gobj_remove(struct media_gobj *gobj)
}
/**
+ * __media_entity_enum_init - Initialise an entity enumeration
+ *
+ * @ent_enum: Entity enumeration to be initialised
+ * @idx_max: Maximum number of entities in the enumeration
+ *
+ * Returns zero on success or a negative error code.
+ */
+__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
+ int idx_max)
+{
+ if (idx_max > MEDIA_ENTITY_ENUM_MAX_ID) {
+ ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG),
+ sizeof(long), GFP_KERNEL);
+ if (!ent_enum->bmap)
+ return -ENOMEM;
+ } else {
+ ent_enum->bmap = ent_enum->prealloc_bmap;
+ }
+
+ bitmap_zero(ent_enum->bmap, idx_max);
+ ent_enum->idx_max = idx_max;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(__media_entity_enum_init);
+
+/**
+ * media_entity_enum_cleanup - Release resources of an entity enumeration
+ *
+ * @e: Entity enumeration to be released
+ */
+void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
+{
+ if (ent_enum->bmap != ent_enum->prealloc_bmap)
+ kfree(ent_enum->bmap);
+ ent_enum->bmap = NULL;
+}
+EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
+
+/**
* media_entity_init - Initialize a media entity
*
* @num_pads: Total number of sink and source pads.
diff --git a/include/media/media-device.h b/include/media/media-device.h
index c0e1764..abf94b4 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -110,6 +110,21 @@ struct media_device {
/* media_devnode to media_device */
#define to_media_device(node) container_of(node, struct media_device, devnode)
+/**
+ * media_entity_enum_init - Initialise an entity enumeration
+ *
+ * @e: Entity enumeration to be initialised
+ * @mdev: The related media device
+ *
+ * Returns zero on success or a negative error code.
+ */
+static inline __must_check int media_entity_enum_init(
+ struct media_entity_enum *ent_enum, struct media_device *mdev)
+{
+ return __media_entity_enum_init(ent_enum,
+ mdev->entity_internal_idx_max + 1);
+}
+
void media_device_init(struct media_device *mdev);
void media_device_cleanup(struct media_device *mdev);
int __must_check __media_device_register(struct media_device *mdev,
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index d3d3a39..064cf73 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -23,7 +23,7 @@
#ifndef _MEDIA_ENTITY_H
#define _MEDIA_ENTITY_H
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/media.h>
@@ -71,6 +71,32 @@ struct media_gobj {
struct list_head list;
};
+#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
+#define MEDIA_ENTITY_ENUM_MAX_ID 64
+
+/*
+ * The number of pads can't be bigger than the number of entities,
+ * as the worse-case scenario is to have one entity linked up to
+ * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
+ */
+#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
+
+/**
+ * struct media_entity_enum - An enumeration of media entities.
+ *
+ * @prealloc_bmap: Pre-allocated space reserved for media entities if the
+ * total number of entities does not exceed
+ * MEDIA_ENTITY_ENUM_MAX_ID.
+ * @bmap: Bit map in which each bit represents one entity at struct
+ * media_entity->internal_idx.
+ * @idx_max: Number of bits in bmap
+ */
+struct media_entity_enum {
+ DECLARE_BITMAP(prealloc_bmap, MEDIA_ENTITY_ENUM_MAX_ID);
+ unsigned long *bmap;
+ int idx_max;
+};
+
struct media_pipeline {
};
@@ -307,15 +333,114 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
}
}
-#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
-#define MEDIA_ENTITY_ENUM_MAX_ID 64
+__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
+ int idx_max);
+void media_entity_enum_cleanup(struct media_entity_enum *e);
-/*
- * The number of pads can't be bigger than the number of entities,
- * as the worse-case scenario is to have one entity linked up to
- * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
+/**
+ * media_entity_enum_zero - Clear the entire enum
+ *
+ * @e: Entity enumeration to be cleared
*/
-#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
+static inline void media_entity_enum_zero(struct media_entity_enum *ent_enum)
+{
+ bitmap_zero(ent_enum->bmap, ent_enum->idx_max);
+}
+
+/**
+ * media_entity_enum_set - Mark a single entity in the enum
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be marked
+ */
+static inline void media_entity_enum_set(struct media_entity_enum *ent_enum,
+ struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return;
+
+ __set_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_clear - Unmark a single entity in the enum
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be unmarked
+ */
+static inline void media_entity_enum_clear(struct media_entity_enum *ent_enum,
+ struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return;
+
+ __clear_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_test - Test whether the entity is marked
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be tested
+ *
+ * Returns true if the entity was marked.
+ */
+static inline bool media_entity_enum_test(struct media_entity_enum *ent_enum,
+ struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return true;
+
+ return test_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_test - Test whether the entity is marked, and mark it
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be tested
+ *
+ * Returns true if the entity was marked, and mark it before doing so.
+ */
+static inline bool media_entity_enum_test_and_set(
+ struct media_entity_enum *ent_enum, struct media_entity *entity)
+{
+ if (WARN_ON(entity->internal_idx >= ent_enum->idx_max))
+ return true;
+
+ return __test_and_set_bit(entity->internal_idx, ent_enum->bmap);
+}
+
+/**
+ * media_entity_enum_test - Test whether the entire enum is empty
+ *
+ * @e: Entity enumeration
+ * @entity: Entity to be tested
+ *
+ * Returns true if the entity was marked.
+ */
+static inline bool media_entity_enum_empty(struct media_entity_enum *ent_enum)
+{
+ return bitmap_empty(ent_enum->bmap, ent_enum->idx_max);
+}
+
+/**
+ * media_entity_enum_intersects - Test whether two enums intersect
+ *
+ * @e: First entity enumeration
+ * @f: Second entity enumeration
+ *
+ * Returns true if entity enumerations e and f intersect, otherwise false.
+ */
+static inline bool media_entity_enum_intersects(
+ struct media_entity_enum *ent_enum1,
+ struct media_entity_enum *ent_enum2)
+{
+ WARN_ON(ent_enum1->idx_max != ent_enum2->idx_max);
+
+ return bitmap_intersects(ent_enum1->bmap, ent_enum2->bmap,
+ min(ent_enum1->idx_max, ent_enum2->idx_max));
+}
struct media_entity_graph {
struct {
--
2.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
` (22 preceding siblings ...)
2015-12-16 13:32 ` [PATCH v3 23/23] media: Update media graph walk documentation for the changed API Sakari Ailus
@ 2015-12-16 14:03 ` Sakari Ailus
2015-12-16 17:39 ` Mauro Carvalho Chehab
2015-12-23 12:32 ` Mauro Carvalho Chehab
23 siblings, 2 replies; 32+ messages in thread
From: Sakari Ailus @ 2015-12-16 14:03 UTC (permalink / raw)
To: linux-media, javier; +Cc: laurent.pinchart, mchehab, hverkuil
Hi Javier,
On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
> This is the third version of the unrestricted media entity ID range
> support set. I've taken Mauro's comments into account and fixed a number
> of bugs as well (omap3isp memory leak and omap4iss stream start).
Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
test the OMAP4 ISS with these patches?
Thanks.
--
Kind regards,
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-16 14:03 ` [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
@ 2015-12-16 17:39 ` Mauro Carvalho Chehab
2015-12-21 14:17 ` Javier Martinez Canillas
2015-12-23 12:32 ` Mauro Carvalho Chehab
1 sibling, 1 reply; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-16 17:39 UTC (permalink / raw)
To: Sakari Ailus; +Cc: linux-media, javier, laurent.pinchart, hverkuil
Em Wed, 16 Dec 2015 16:03:01 +0200
Sakari Ailus <sakari.ailus@iki.fi> escreveu:
> Hi Javier,
>
> On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
> > This is the third version of the unrestricted media entity ID range
> > support set. I've taken Mauro's comments into account and fixed a number
> > of bugs as well (omap3isp memory leak and omap4iss stream start).
Patches merged on my experimental tree:
ssh://linuxtv.org/git/mchehab/experimental.git
branch media-controller-rc4
I had to do some rebase, as you were using some older changeset.
Also, several documentation tags were with troubles (renamed
vars not renamed there).
Next time, please check the documentation with:
make DOCBOOKS=device-drivers.xml htmldocs 2>&1
> Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
> test the OMAP4 ISS with these patches?
As Sakari patches were rebased, it would be good to test them again
on omap3.
Regards,
Mauro
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-16 17:39 ` Mauro Carvalho Chehab
@ 2015-12-21 14:17 ` Javier Martinez Canillas
0 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-12-21 14:17 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Sakari Ailus
Cc: linux-media, laurent.pinchart, hverkuil
On 12/16/2015 02:39 PM, Mauro Carvalho Chehab wrote:
> Em Wed, 16 Dec 2015 16:03:01 +0200
> Sakari Ailus <sakari.ailus@iki.fi> escreveu:
>
>> Hi Javier,
>>
>> On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
>>> This is the third version of the unrestricted media entity ID range
>>> support set. I've taken Mauro's comments into account and fixed a number
>>> of bugs as well (omap3isp memory leak and omap4iss stream start).
>
> Patches merged on my experimental tree:
>
> ssh://linuxtv.org/git/mchehab/experimental.git
>
> branch media-controller-rc4
>
> I had to do some rebase, as you were using some older changeset.
> Also, several documentation tags were with troubles (renamed
> vars not renamed there).
>
> Next time, please check the documentation with:
> make DOCBOOKS=device-drivers.xml htmldocs 2>&1
>
>> Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
>> test the OMAP4 ISS with these patches?
>
Sakari, I used to have an OMAP4 board (OMAP4460 Panda ES) but I don't
have it anymore, only OMAP3 and AM335x boards using TI SoCs for now.
> As Sakari patches were rebased, it would be good to test them again
> on omap3.
>
Mauro, I tested your latest media-controller-rc4 branch that contains
Sakari's patches and both graph enumration and video capture work on
my OMAP3 IGEPv2 board.
> Regards,
> Mauro
>
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-16 14:03 ` [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
2015-12-16 17:39 ` Mauro Carvalho Chehab
@ 2015-12-23 12:32 ` Mauro Carvalho Chehab
2015-12-27 17:11 ` Laurent Pinchart
1 sibling, 1 reply; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-23 12:32 UTC (permalink / raw)
To: Sakari Ailus
Cc: linux-media, javier, laurent.pinchart, hverkuil, linux-kernel,
linux-omap, Benoît Cousson, Arnd Bergmann, linux-arm-kernel
Em Wed, 16 Dec 2015 16:03:01 +0200
Sakari Ailus <sakari.ailus@iki.fi> escreveu:
> Hi Javier,
>
> On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
> > This is the third version of the unrestricted media entity ID range
> > support set. I've taken Mauro's comments into account and fixed a number
> > of bugs as well (omap3isp memory leak and omap4iss stream start).
>
> Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
> test the OMAP4 ISS with these patches?
>
> Thanks.
>
Sakari,
Testing with OMAP4 is not possible. The driver is broken: it doesn't
support DT, and the required pdata definition is missing.
Both Javier and I tried to fix it in the last couple days, in order to test
it with a PandaBoard. We came with the enclosed patch, but it is still
incomplete. Based on what's written on this e-mail:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg89247.html
It seems that this is an already known issue.
So, I'm considering this driver as BROKEN. Not much sense on doing any
tests on it, while this doesn't get fixed.
Regards,
Mauro
PS.: With the enclosed patch, I got this error:
[ 0.267639] platform omap4iss: failed to claim resource 2
But, even if I comment out the platform code that returns this error,
there are still other missing things:
[ 7.131622] omap4iss omap4iss: Unable to get iss_fck clock info
[ 7.137878] omap4iss omap4iss: Unable to get clocks
---
ARM: add a pdata quirks for OMAP4 panda camera
This is a hack to make it to believe that the pandaboard
has a camera.
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 1dfe34654c43..998bb6936dc0 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -36,6 +36,8 @@
#include "soc.h"
#include "hsmmc.h"
+#include "../../../drivers/staging/media/omap4iss/iss.h"
+
struct pdata_init {
const char *compatible;
void (*fn)(void);
@@ -408,6 +410,124 @@ static void __init t410_abort_init(void)
}
#endif
+#ifdef CONFIG_ARCH_OMAP4
+
+static struct resource panda_iss_resource[] = {
+ {
+ .start = 0x52000000,
+ .end = 0x52000000 + 0x100,
+ .name = "top",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52001000,
+ .end = 0x52001000 + 0x170,
+ .name = "csi2_a_regs1",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52001170,
+ .end = 0x52001170 + 0x020,
+ .name = "camerarx_core1",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52001400,
+ .end = 0x52001400 + 0x170,
+ .name = "csi2_b_regs1",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52001570,
+ .end = 0x52001570 + 0x020,
+ .name = "camerarx_core2",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52002000,
+ .end = 0x52002000 + 0x200,
+ .name = "bte",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52010000,
+ .end = 0x52010000 + 0x0a0,
+ .name = "isp_sys1",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52010400,
+ .end = 0x52010400 + 0x400,
+ .name = "isp_resizer",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52010800,
+ .end = 0x52010800 + 0x800,
+ .name = "isp_ipipe",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52011000,
+ .end = 0x52011000 + 0x200,
+ .name = "isp_isif",
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = 0x52011200,
+ .end = 0x52011200 + 0x080,
+ .name = "isp_ipipeif",
+ .flags = IORESOURCE_MEM,
+ }
+};
+
+static struct i2c_board_info panda_camera_i2c_device = {
+ I2C_BOARD_INFO("smia", 0x10),
+};
+
+static struct iss_subdev_i2c_board_info panda_camera_subdevs[] = {
+ {
+ .board_info = &panda_camera_i2c_device,
+ .i2c_adapter_id = 3,
+ },
+};
+
+static struct iss_v4l2_subdevs_group iss_subdevs[] = {
+ {
+ .subdevs = panda_camera_subdevs,
+ .interface = ISS_INTERFACE_CSI2A_PHY1,
+ .bus = {
+ .csi2 = {
+ .lanecfg = {
+ .clk = {
+ .pol = 0,
+ .pos = 2,
+ },
+ .data[0] = {
+ .pol = 0,
+ .pos = 1,
+ },
+ .data[1] = {
+ .pol = 0,
+ .pos = 3,
+ },
+ },
+ } },
+ },
+ { /* sentinel */ },
+};
+
+static struct iss_platform_data iss_pdata = {
+ .subdevs = iss_subdevs,
+};
+
+static struct platform_device omap4iss_device = {
+ .name = "omap4iss",
+ .id = -1,
+ .dev = {
+ .platform_data = &iss_pdata,
+ },
+ .num_resources = ARRAY_SIZE(panda_iss_resource),
+ .resource = panda_iss_resource,
+};
+
+static void __init omap4_panda_legacy_init(void)
+{
+ platform_device_register(&omap4iss_device);
+}
+
+#endif /* CONFIG_ARCH_OMAP4 */
+
#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
static struct iommu_platform_data omap4_iommu_pdata = {
.reset_name = "mmu_cache",
@@ -539,6 +659,9 @@ static struct pdata_init pdata_quirks[] __initdata = {
#ifdef CONFIG_SOC_TI81XX
{ "hp,t410", t410_abort_init, },
#endif
+#ifdef CONFIG_ARCH_OMAP4
+ { "ti,omap4-panda", omap4_panda_legacy_init, },
+#endif
#ifdef CONFIG_SOC_OMAP5
{ "ti,omap5-uevm", omap5_uevm_legacy_init, },
#endif
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index 30b473cfb020..b528cacda17b 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -1412,6 +1412,9 @@ static int iss_probe(struct platform_device *pdev)
unsigned int i;
int ret;
+
+printk("%s: pdata=%p\n", __func__, pdata);
+
if (!pdata)
return -EINVAL;
@@ -1437,24 +1440,33 @@ static int iss_probe(struct platform_device *pdev)
iss->syscon = syscon_regmap_lookup_by_compatible("syscon");
if (IS_ERR(iss->syscon)) {
ret = PTR_ERR(iss->syscon);
+ dev_err(iss->dev, "Unable to find syscon");
goto error;
}
/* Clocks */
ret = iss_map_mem_resource(pdev, iss, OMAP4_ISS_MEM_TOP);
- if (ret < 0)
+ if (ret < 0) {
+ dev_err(iss->dev, "Unable to map memory resource\n");
goto error;
+ }
ret = iss_get_clocks(iss);
- if (ret < 0)
+ if (ret < 0) {
+ dev_err(iss->dev, "Unable to get clocks\n");
goto error;
+ }
- if (!omap4iss_get(iss))
+ if (!omap4iss_get(iss)) {
+ dev_err(iss->dev, "Failed to acquire ISS resource\n");
goto error;
+ }
ret = iss_reset(iss);
- if (ret < 0)
+ if (ret < 0) {
+ dev_err(iss->dev, "Unable to reset ISS\n");
goto error_iss;
+ }
iss->revision = iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_REVISION);
dev_info(iss->dev, "Revision %08x found\n", iss->revision);
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-23 12:32 ` Mauro Carvalho Chehab
@ 2015-12-27 17:11 ` Laurent Pinchart
2015-12-28 3:06 ` Javier Martinez Canillas
2015-12-28 10:05 ` Mauro Carvalho Chehab
0 siblings, 2 replies; 32+ messages in thread
From: Laurent Pinchart @ 2015-12-27 17:11 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Sakari Ailus, linux-media, javier, hverkuil, linux-kernel,
linux-omap, Benoît Cousson, Arnd Bergmann, linux-arm-kernel
Hi Mauro,
On Wednesday 23 December 2015 10:32:42 Mauro Carvalho Chehab wrote:
> Em Wed, 16 Dec 2015 16:03:01 +0200 Sakari Ailus escreveu:
> > On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
> > > This is the third version of the unrestricted media entity ID range
> > > support set. I've taken Mauro's comments into account and fixed a number
> > > of bugs as well (omap3isp memory leak and omap4iss stream start).
> >
> > Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
> > test the OMAP4 ISS with these patches?
> >
> > Thanks.
>
> Sakari,
>
> Testing with OMAP4 is not possible. The driver is broken: it doesn't
> support DT, and the required pdata definition is missing.
What do you mean by missing ? struct iss_platform_data is defined in
include/media/omap4iss.h.
> Both Javier and I tried to fix it in the last couple days, in order to test
> it with a PandaBoard. We came with the enclosed patch, but it is still
> incomplete. Based on what's written on this e-mail:
> https://www.mail-archive.com/linux-media@vger.kernel.org/msg89247.html
>
> It seems that this is an already known issue.
>
> So, I'm considering this driver as BROKEN. Not much sense on doing any
> tests on it, while this doesn't get fixed.
>
> Regards,
> Mauro
>
> PS.: With the enclosed patch, I got this error:
> [ 0.267639] platform omap4iss: failed to claim resource 2
>
> But, even if I comment out the platform code that returns this error,
> there are still other missing things:
> [ 7.131622] omap4iss omap4iss: Unable to get iss_fck clock info
> [ 7.137878] omap4iss omap4iss: Unable to get clocks
>
> ---
>
> ARM: add a pdata quirks for OMAP4 panda camera
>
> This is a hack to make it to believe that the pandaboard
> has a camera.
>
>
> diff --git a/arch/arm/mach-omap2/pdata-quirks.c
> b/arch/arm/mach-omap2/pdata-quirks.c index 1dfe34654c43..998bb6936dc0
> 100644
> --- a/arch/arm/mach-omap2/pdata-quirks.c
> +++ b/arch/arm/mach-omap2/pdata-quirks.c
> @@ -36,6 +36,8 @@
> #include "soc.h"
> #include "hsmmc.h"
>
> +#include "../../../drivers/staging/media/omap4iss/iss.h"
> +
> struct pdata_init {
> const char *compatible;
> void (*fn)(void);
> @@ -408,6 +410,124 @@ static void __init t410_abort_init(void)
> }
> #endif
>
> +#ifdef CONFIG_ARCH_OMAP4
> +
> +static struct resource panda_iss_resource[] = {
> + {
> + .start = 0x52000000,
> + .end = 0x52000000 + 0x100,
> + .name = "top",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52001000,
> + .end = 0x52001000 + 0x170,
> + .name = "csi2_a_regs1",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52001170,
> + .end = 0x52001170 + 0x020,
> + .name = "camerarx_core1",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52001400,
> + .end = 0x52001400 + 0x170,
> + .name = "csi2_b_regs1",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52001570,
> + .end = 0x52001570 + 0x020,
> + .name = "camerarx_core2",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52002000,
> + .end = 0x52002000 + 0x200,
> + .name = "bte",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52010000,
> + .end = 0x52010000 + 0x0a0,
> + .name = "isp_sys1",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52010400,
> + .end = 0x52010400 + 0x400,
> + .name = "isp_resizer",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52010800,
> + .end = 0x52010800 + 0x800,
> + .name = "isp_ipipe",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52011000,
> + .end = 0x52011000 + 0x200,
> + .name = "isp_isif",
> + .flags = IORESOURCE_MEM,
> + }, {
> + .start = 0x52011200,
> + .end = 0x52011200 + 0x080,
> + .name = "isp_ipipeif",
> + .flags = IORESOURCE_MEM,
> + }
> +};
> +
> +static struct i2c_board_info panda_camera_i2c_device = {
> + I2C_BOARD_INFO("smia", 0x10),
> +};
> +
> +static struct iss_subdev_i2c_board_info panda_camera_subdevs[] = {
> + {
> + .board_info = &panda_camera_i2c_device,
> + .i2c_adapter_id = 3,
> + },
> +};
> +
> +static struct iss_v4l2_subdevs_group iss_subdevs[] = {
> + {
> + .subdevs = panda_camera_subdevs,
> + .interface = ISS_INTERFACE_CSI2A_PHY1,
> + .bus = {
> + .csi2 = {
> + .lanecfg = {
> + .clk = {
> + .pol = 0,
> + .pos = 2,
> + },
> + .data[0] = {
> + .pol = 0,
> + .pos = 1,
> + },
> + .data[1] = {
> + .pol = 0,
> + .pos = 3,
> + },
> + },
> + } },
> + },
> + { /* sentinel */ },
> +};
> +
> +static struct iss_platform_data iss_pdata = {
> + .subdevs = iss_subdevs,
> +};
> +
> +static struct platform_device omap4iss_device = {
> + .name = "omap4iss",
> + .id = -1,
> + .dev = {
> + .platform_data = &iss_pdata,
> + },
> + .num_resources = ARRAY_SIZE(panda_iss_resource),
> + .resource = panda_iss_resource,
> +};
> +
> +static void __init omap4_panda_legacy_init(void)
> +{
> + platform_device_register(&omap4iss_device);
> +}
> +
> +#endif /* CONFIG_ARCH_OMAP4 */
> +
> #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
> static struct iommu_platform_data omap4_iommu_pdata = {
> .reset_name = "mmu_cache",
> @@ -539,6 +659,9 @@ static struct pdata_init pdata_quirks[] __initdata = {
> #ifdef CONFIG_SOC_TI81XX
> { "hp,t410", t410_abort_init, },
> #endif
> +#ifdef CONFIG_ARCH_OMAP4
> + { "ti,omap4-panda", omap4_panda_legacy_init, },
> +#endif
> #ifdef CONFIG_SOC_OMAP5
> { "ti,omap5-uevm", omap5_uevm_legacy_init, },
> #endif
>
> diff --git a/drivers/staging/media/omap4iss/iss.c
> b/drivers/staging/media/omap4iss/iss.c index 30b473cfb020..b528cacda17b
> 100644
> --- a/drivers/staging/media/omap4iss/iss.c
> +++ b/drivers/staging/media/omap4iss/iss.c
> @@ -1412,6 +1412,9 @@ static int iss_probe(struct platform_device *pdev)
> unsigned int i;
> int ret;
>
> +
> +printk("%s: pdata=%p\n", __func__, pdata);
> +
> if (!pdata)
> return -EINVAL;
>
> @@ -1437,24 +1440,33 @@ static int iss_probe(struct platform_device *pdev)
> iss->syscon = syscon_regmap_lookup_by_compatible("syscon");
> if (IS_ERR(iss->syscon)) {
> ret = PTR_ERR(iss->syscon);
> + dev_err(iss->dev, "Unable to find syscon");
> goto error;
> }
>
> /* Clocks */
> ret = iss_map_mem_resource(pdev, iss, OMAP4_ISS_MEM_TOP);
> - if (ret < 0)
> + if (ret < 0) {
> + dev_err(iss->dev, "Unable to map memory resource\n");
> goto error;
> + }
>
> ret = iss_get_clocks(iss);
> - if (ret < 0)
> + if (ret < 0) {
> + dev_err(iss->dev, "Unable to get clocks\n");
> goto error;
> + }
>
> - if (!omap4iss_get(iss))
> + if (!omap4iss_get(iss)) {
> + dev_err(iss->dev, "Failed to acquire ISS resource\n");
> goto error;
> + }
>
> ret = iss_reset(iss);
> - if (ret < 0)
> + if (ret < 0) {
> + dev_err(iss->dev, "Unable to reset ISS\n");
> goto error_iss;
> + }
>
> iss->revision = iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_REVISION);
> dev_info(iss->dev, "Revision %08x found\n", iss->revision);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-27 17:11 ` Laurent Pinchart
@ 2015-12-28 3:06 ` Javier Martinez Canillas
2015-12-28 10:05 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-12-28 3:06 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab
Cc: Sakari Ailus, linux-media, hverkuil, linux-kernel, linux-omap,
Benoît Cousson, Arnd Bergmann, linux-arm-kernel
Hello Laurent,
On 12/27/2015 02:11 PM, Laurent Pinchart wrote:
> Hi Mauro,
>
> On Wednesday 23 December 2015 10:32:42 Mauro Carvalho Chehab wrote:
>> Em Wed, 16 Dec 2015 16:03:01 +0200 Sakari Ailus escreveu:
>>> On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
>>>> This is the third version of the unrestricted media entity ID range
>>>> support set. I've taken Mauro's comments into account and fixed a number
>>>> of bugs as well (omap3isp memory leak and omap4iss stream start).
>>>
>>> Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
>>> test the OMAP4 ISS with these patches?
>>>
>>> Thanks.
>>
>> Sakari,
>>
>> Testing with OMAP4 is not possible. The driver is broken: it doesn't
>> support DT, and the required pdata definition is missing.
>
> What do you mean by missing ? struct iss_platform_data is defined in
> include/media/omap4iss.h.
>
That's true but at the very least the omap4iss hwmod is broken in mainline
as you mentioned in the linux-media thread that Mauro shared below.
I think what Mauro meant is that there isn't an omap4 board supported in
mainline that makes use of the iss platform data structures. So testing the
driver in a popular omap4 board such as the pandaboard isn't possible without
adding plumbing board code. And even in that case, the driver fails to probe
due a missing iss_fck clock as Mauro mentioned in his boot log below as well.
I know is not a requirement for a driver to have mainline users but without
DT bindings, using this driver will not be possible sooner rather than later
once the mach-omap2 pdata-quirks.c workaround is removed from mainline since
the omap4 board files were deleted almost 3 years ago (3.11 according to git).
>> Both Javier and I tried to fix it in the last couple days, in order to test
>> it with a PandaBoard. We came with the enclosed patch, but it is still
>> incomplete. Based on what's written on this e-mail:
>> https://www.mail-archive.com/linux-media@vger.kernel.org/msg89247.html
>>
>> It seems that this is an already known issue.
>>
>> So, I'm considering this driver as BROKEN. Not much sense on doing any
>> tests on it, while this doesn't get fixed.
>>
>> Regards,
>> Mauro
>>
>> PS.: With the enclosed patch, I got this error:
>> [ 0.267639] platform omap4iss: failed to claim resource 2
>>
>> But, even if I comment out the platform code that returns this error,
>> there are still other missing things:
>> [ 7.131622] omap4iss omap4iss: Unable to get iss_fck clock info
>> [ 7.137878] omap4iss omap4iss: Unable to get clocks
>>
>> ---
>>
>> ARM: add a pdata quirks for OMAP4 panda camera
>>
>> This is a hack to make it to believe that the pandaboard
>> has a camera.
>>
>>
>> diff --git a/arch/arm/mach-omap2/pdata-quirks.c
>> b/arch/arm/mach-omap2/pdata-quirks.c index 1dfe34654c43..998bb6936dc0
>> 100644
>> --- a/arch/arm/mach-omap2/pdata-quirks.c
>> +++ b/arch/arm/mach-omap2/pdata-quirks.c
>> @@ -36,6 +36,8 @@
>> #include "soc.h"
>> #include "hsmmc.h"
>>
>> +#include "../../../drivers/staging/media/omap4iss/iss.h"
>> +
>> struct pdata_init {
>> const char *compatible;
>> void (*fn)(void);
>> @@ -408,6 +410,124 @@ static void __init t410_abort_init(void)
>> }
>> #endif
>>
>> +#ifdef CONFIG_ARCH_OMAP4
>> +
>> +static struct resource panda_iss_resource[] = {
>> + {
>> + .start = 0x52000000,
>> + .end = 0x52000000 + 0x100,
>> + .name = "top",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52001000,
>> + .end = 0x52001000 + 0x170,
>> + .name = "csi2_a_regs1",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52001170,
>> + .end = 0x52001170 + 0x020,
>> + .name = "camerarx_core1",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52001400,
>> + .end = 0x52001400 + 0x170,
>> + .name = "csi2_b_regs1",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52001570,
>> + .end = 0x52001570 + 0x020,
>> + .name = "camerarx_core2",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52002000,
>> + .end = 0x52002000 + 0x200,
>> + .name = "bte",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52010000,
>> + .end = 0x52010000 + 0x0a0,
>> + .name = "isp_sys1",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52010400,
>> + .end = 0x52010400 + 0x400,
>> + .name = "isp_resizer",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52010800,
>> + .end = 0x52010800 + 0x800,
>> + .name = "isp_ipipe",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52011000,
>> + .end = 0x52011000 + 0x200,
>> + .name = "isp_isif",
>> + .flags = IORESOURCE_MEM,
>> + }, {
>> + .start = 0x52011200,
>> + .end = 0x52011200 + 0x080,
>> + .name = "isp_ipipeif",
>> + .flags = IORESOURCE_MEM,
>> + }
>> +};
>> +
>> +static struct i2c_board_info panda_camera_i2c_device = {
>> + I2C_BOARD_INFO("smia", 0x10),
>> +};
>> +
>> +static struct iss_subdev_i2c_board_info panda_camera_subdevs[] = {
>> + {
>> + .board_info = &panda_camera_i2c_device,
>> + .i2c_adapter_id = 3,
>> + },
>> +};
>> +
>> +static struct iss_v4l2_subdevs_group iss_subdevs[] = {
>> + {
>> + .subdevs = panda_camera_subdevs,
>> + .interface = ISS_INTERFACE_CSI2A_PHY1,
>> + .bus = {
>> + .csi2 = {
>> + .lanecfg = {
>> + .clk = {
>> + .pol = 0,
>> + .pos = 2,
>> + },
>> + .data[0] = {
>> + .pol = 0,
>> + .pos = 1,
>> + },
>> + .data[1] = {
>> + .pol = 0,
>> + .pos = 3,
>> + },
>> + },
>> + } },
>> + },
>> + { /* sentinel */ },
>> +};
>> +
>> +static struct iss_platform_data iss_pdata = {
>> + .subdevs = iss_subdevs,
>> +};
>> +
>> +static struct platform_device omap4iss_device = {
>> + .name = "omap4iss",
>> + .id = -1,
>> + .dev = {
>> + .platform_data = &iss_pdata,
>> + },
>> + .num_resources = ARRAY_SIZE(panda_iss_resource),
>> + .resource = panda_iss_resource,
>> +};
>> +
>> +static void __init omap4_panda_legacy_init(void)
>> +{
>> + platform_device_register(&omap4iss_device);
>> +}
>> +
>> +#endif /* CONFIG_ARCH_OMAP4 */
>> +
>> #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
>> static struct iommu_platform_data omap4_iommu_pdata = {
>> .reset_name = "mmu_cache",
>> @@ -539,6 +659,9 @@ static struct pdata_init pdata_quirks[] __initdata = {
>> #ifdef CONFIG_SOC_TI81XX
>> { "hp,t410", t410_abort_init, },
>> #endif
>> +#ifdef CONFIG_ARCH_OMAP4
>> + { "ti,omap4-panda", omap4_panda_legacy_init, },
>> +#endif
>> #ifdef CONFIG_SOC_OMAP5
>> { "ti,omap5-uevm", omap5_uevm_legacy_init, },
>> #endif
>>
>> diff --git a/drivers/staging/media/omap4iss/iss.c
>> b/drivers/staging/media/omap4iss/iss.c index 30b473cfb020..b528cacda17b
>> 100644
>> --- a/drivers/staging/media/omap4iss/iss.c
>> +++ b/drivers/staging/media/omap4iss/iss.c
>> @@ -1412,6 +1412,9 @@ static int iss_probe(struct platform_device *pdev)
>> unsigned int i;
>> int ret;
>>
>> +
>> +printk("%s: pdata=%p\n", __func__, pdata);
>> +
>> if (!pdata)
>> return -EINVAL;
>>
>> @@ -1437,24 +1440,33 @@ static int iss_probe(struct platform_device *pdev)
>> iss->syscon = syscon_regmap_lookup_by_compatible("syscon");
>> if (IS_ERR(iss->syscon)) {
>> ret = PTR_ERR(iss->syscon);
>> + dev_err(iss->dev, "Unable to find syscon");
>> goto error;
>> }
>>
>> /* Clocks */
>> ret = iss_map_mem_resource(pdev, iss, OMAP4_ISS_MEM_TOP);
>> - if (ret < 0)
>> + if (ret < 0) {
>> + dev_err(iss->dev, "Unable to map memory resource\n");
>> goto error;
>> + }
>>
>> ret = iss_get_clocks(iss);
>> - if (ret < 0)
>> + if (ret < 0) {
>> + dev_err(iss->dev, "Unable to get clocks\n");
>> goto error;
>> + }
>>
>> - if (!omap4iss_get(iss))
>> + if (!omap4iss_get(iss)) {
>> + dev_err(iss->dev, "Failed to acquire ISS resource\n");
>> goto error;
>> + }
>>
>> ret = iss_reset(iss);
>> - if (ret < 0)
>> + if (ret < 0) {
>> + dev_err(iss->dev, "Unable to reset ISS\n");
>> goto error_iss;
>> + }
>>
>> iss->revision = iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_REVISION);
>> dev_info(iss->dev, "Revision %08x found\n", iss->revision);
>
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH v3 00/23] Unrestricted media entity ID range support
2015-12-27 17:11 ` Laurent Pinchart
2015-12-28 3:06 ` Javier Martinez Canillas
@ 2015-12-28 10:05 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-28 10:05 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Sakari Ailus, linux-media, javier, hverkuil, linux-kernel,
linux-omap, Benoît Cousson, Arnd Bergmann, linux-arm-kernel
Em Sun, 27 Dec 2015 19:11:36 +0200
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:
> Hi Mauro,
>
> On Wednesday 23 December 2015 10:32:42 Mauro Carvalho Chehab wrote:
> > Em Wed, 16 Dec 2015 16:03:01 +0200 Sakari Ailus escreveu:
> > > On Wed, Dec 16, 2015 at 03:32:15PM +0200, Sakari Ailus wrote:
> > > > This is the third version of the unrestricted media entity ID range
> > > > support set. I've taken Mauro's comments into account and fixed a number
> > > > of bugs as well (omap3isp memory leak and omap4iss stream start).
> > >
> > > Javier: Mauro told me you might have OMAP4 hardware. Would you be able to
> > > test the OMAP4 ISS with these patches?
> > >
> > > Thanks.
> >
> > Sakari,
> >
> > Testing with OMAP4 is not possible. The driver is broken: it doesn't
> > support DT, and the required pdata definition is missing.
>
> What do you mean by missing ? struct iss_platform_data is defined in
> include/media/omap4iss.h.
>
As this driver is not DT, the platform data has to be part of the Kernel
tree for the driver to work. However, there are no board-specific data nor
any documentation about how to do that inside the Kernel tree.
That means that this driver won't work without some OOT patch.
So, on its current state, it is broken. It should either be
converted to DT and have the needed board definitions added to the
existing dts files or be removed.
Another possible approach would be to have a patch like the one
Javier and I tried to craft by adding the needed platform data
into arch/arm/mach-omap2/pdata-quirks.c, but I guess it is better
to just use DT instead.
Regards,
Mauro
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2015-12-28 10:05 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-16 13:32 [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 01/23] media: Enforce single entity->pipe in a pipeline Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 02/23] media: Introduce internal index for media entities Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 03/23] media: Add an API to manage entity enumerations Sakari Ailus
2015-12-16 13:44 ` [PATCH v3.1 " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 04/23] media: Move struct media_entity_graph definition up Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 05/23] media: Add KernelDoc documentation for struct media_entity_graph Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 06/23] media: Move media graph state for streamon/off to the pipeline Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 07/23] media: Amend media graph walk API by init and cleanup functions Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 08/23] media: Use the new media graph walk interface Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 09/23] v4l: omap3isp: " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 10/23] v4l: exynos4-is: " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 11/23] v4l: xilinx: " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 12/23] v4l: vsp1: " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 13/23] media: Use entity enums in graph walk Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 14/23] media: Keep using the same graph walk object for a given pipeline Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 15/23] v4l: omap3isp: Use media entity enumeration interface Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 16/23] v4l: vsp1: " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 17/23] staging: v4l: omap4iss: Fix sub-device power management code Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 18/23] staging: v4l: omap4iss: Use media entity enumeration interface Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 19/23] staging: v4l: omap4iss: Use the new media graph walk interface Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 20/23] staging: v4l: davinci_vpbe: " Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 21/23] media: Remove pre-allocated entity enumeration bitmap Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 22/23] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.c Sakari Ailus
2015-12-16 13:32 ` [PATCH v3 23/23] media: Update media graph walk documentation for the changed API Sakari Ailus
2015-12-16 14:03 ` [PATCH v3 00/23] Unrestricted media entity ID range support Sakari Ailus
2015-12-16 17:39 ` Mauro Carvalho Chehab
2015-12-21 14:17 ` Javier Martinez Canillas
2015-12-23 12:32 ` Mauro Carvalho Chehab
2015-12-27 17:11 ` Laurent Pinchart
2015-12-28 3:06 ` Javier Martinez Canillas
2015-12-28 10:05 ` Mauro Carvalho Chehab
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).