linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] [media] move documentation to the header files
@ 2015-12-16 17:11 Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 2/5] [media] DocBook: document media_entity_graph_walk_cleanup() Mauro Carvalho Chehab
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-16 17:11 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Some exported functions were still documented at the .c file,
instead of documenting at the .h one.

Move the documentation to the right place, as we only use headers
at media device-drivers.xml DocBook.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 drivers/media/media-device.c | 37 -------------------------------------
 drivers/media/media-entity.c | 13 -------------
 include/media/media-device.h |  6 ++++++
 include/media/media-entity.h | 18 ++++++++++++++++--
 4 files changed, 22 insertions(+), 52 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 49dd41cd047f..3e0227555196 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -577,13 +577,6 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 }
 EXPORT_SYMBOL_GPL(media_device_register_entity);
 
-/**
- * media_device_unregister_entity - Unregister an entity
- * @entity:	The entity
- *
- * If the entity has never been registered this function will return
- * immediately.
- */
 static void __media_device_unregister_entity(struct media_entity *entity)
 {
 	struct media_device *mdev = entity->graph_obj.mdev;
@@ -627,17 +620,6 @@ void media_device_unregister_entity(struct media_entity *entity)
 }
 EXPORT_SYMBOL_GPL(media_device_unregister_entity);
 
-
-/**
- * media_device_init() - initialize a media device
- * @mdev:	The media device
- *
- * The caller is responsible for initializing the media device before
- * registration. The following fields must be set:
- *
- * - dev must point to the parent device
- * - model must be filled with the device model name
- */
 int __must_check media_device_init(struct media_device *mdev)
 {
 	if (WARN_ON(mdev->dev == NULL))
@@ -657,11 +639,6 @@ int __must_check media_device_init(struct media_device *mdev)
 }
 EXPORT_SYMBOL_GPL(media_device_init);
 
-/**
- * media_device_cleanup() - Cleanup a media device
- * @mdev:	The media device
- *
- */
 void media_device_cleanup(struct media_device *mdev)
 {
 	ida_destroy(&mdev->entity_internal_idx);
@@ -670,13 +647,6 @@ void media_device_cleanup(struct media_device *mdev)
 }
 EXPORT_SYMBOL_GPL(media_device_cleanup);
 
-/**
- * __media_device_register() - register a media device
- * @mdev:	The media device
- * @owner:	The module owner
- *
- * returns zero on success or a negative error code.
- */
 int __must_check __media_device_register(struct media_device *mdev,
 					 struct module *owner)
 {
@@ -706,13 +676,6 @@ int __must_check __media_device_register(struct media_device *mdev,
 }
 EXPORT_SYMBOL_GPL(__media_device_register);
 
-/**
- * media_device_unregister - unregister a media device
- * @mdev:	The media device
- *
- * It is safe to call this function on an unregistered
- * (but initialised) media device.
- */
 void media_device_unregister(struct media_device *mdev)
 {
 	struct media_entity *entity;
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 32a5f8cae72d..a2d28162213e 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -70,14 +70,6 @@ static inline const char *intf_type(struct media_interface *intf)
 	}
 };
 
-/**
- * __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)
 {
@@ -93,11 +85,6 @@ __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
 }
 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)
 {
 	kfree(ent_enum->bmap);
diff --git a/include/media/media-device.h b/include/media/media-device.h
index ded71f60d193..4b900c9c5cdd 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -428,6 +428,8 @@ void media_device_cleanup(struct media_device *mdev);
  * a sysfs attribute.
  *
  * Unregistering a media device that hasn't been registered is *NOT* safe.
+ *
+ * Return: returns zero on success or a negative error code.
  */
 int __must_check __media_device_register(struct media_device *mdev,
 					 struct module *owner);
@@ -437,6 +439,10 @@ int __must_check __media_device_register(struct media_device *mdev,
  * __media_device_unregister() - Unegisters a media device element
  *
  * @mdev:	pointer to struct &media_device
+ *
+ *
+ * It is safe to call this function on an unregistered (but initialised)
+ * media device.
  */
 void media_device_unregister(struct media_device *mdev);
 
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index f915ed62ac81..c4aaeb85229c 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -370,9 +370,23 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 	}
 }
 
+/**
+ * __media_entity_enum_init - Initialise an entity enumeration
+ *
+ * @ent_enum: Entity enumeration to be initialised
+ * @idx_max: Maximum number of entities in the enumeration
+ *
+ * Return: 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);
-void media_entity_enum_cleanup(struct media_entity_enum *e);
+
+/**
+ * media_entity_enum_cleanup - Release resources of an entity enumeration
+ *
+ * @ent_enum: Entity enumeration to be released
+ */
+void media_entity_enum_cleanup(struct media_entity_enum *ent_enum);
 
 /**
  * media_entity_enum_zero - Clear the entire enum
@@ -847,6 +861,7 @@ void media_remove_intf_link(struct media_link *link);
  * Note: this is an unlocked version of media_remove_intf_links().
  */
 void __media_remove_intf_links(struct media_interface *intf);
+
 /**
  * media_remove_intf_links() - remove all links associated with an interface
  *
@@ -861,7 +876,6 @@ void __media_remove_intf_links(struct media_interface *intf);
  */
 void media_remove_intf_links(struct media_interface *intf);
 
-
 #define media_entity_call(entity, operation, args...)			\
 	(((entity)->ops && (entity)->ops->operation) ?			\
 	 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] [media] DocBook: document media_entity_graph_walk_cleanup()
  2015-12-16 17:11 [PATCH 1/5] [media] move documentation to the header files Mauro Carvalho Chehab
@ 2015-12-16 17:11 ` Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 3/5] [media] media-entity.h fix documentation for several parameters Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-16 17:11 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

This function was added recently, but weren't documented.
Add documentation for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 include/media/media-entity.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index c4aaeb85229c..f90ff56888d4 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -705,6 +705,12 @@ struct media_entity *media_entity_get(struct media_entity *entity);
 
 __must_check int media_entity_graph_walk_init(
 	struct media_entity_graph *graph, struct media_device *mdev);
+
+/**
+ * media_entity_graph_walk_cleanup - Release resources used by graph walk.
+ *
+ * @graph: Media graph structure that will be used to walk the graph
+ */
 void media_entity_graph_walk_cleanup(struct media_entity_graph *graph);
 
 /**
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] [media] media-entity.h fix documentation for several parameters
  2015-12-16 17:11 [PATCH 1/5] [media] move documentation to the header files Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 2/5] [media] DocBook: document media_entity_graph_walk_cleanup() Mauro Carvalho Chehab
@ 2015-12-16 17:11 ` Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 4/5] [media] au0828-core: fix compilation when !CONFIG_MEDIA_CONTROLLER Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 5/5] [media] media-device.h: use just one u64 counter for object ID Mauro Carvalho Chehab
  3 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-16 17:11 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Several parameters added by the media_ent_enum patches
were declared with wrong argument names:
	include/media/media-device.h:333: warning: No description found for parameter 'entity_internal_idx_max'
	include/media/media-device.h:354: warning: No description found for parameter 'ent_enum'
	include/media/media-device.h:354: warning: Excess function parameter 'e' description in 'media_entity_enum_init'
	include/media/media-device.h:333: warning: No description found for parameter 'entity_internal_idx_max'
	include/media/media-device.h:354: warning: No description found for parameter 'ent_enum'
	include/media/media-device.h:354: warning: Excess function parameter 'e' description in 'media_entity_enum_init'
	include/media/media-entity.h:397: warning: No description found for parameter 'ent_enum'
	include/media/media-entity.h:397: warning: Excess function parameter 'e' description in 'media_entity_enum_zero'
	include/media/media-entity.h:409: warning: No description found for parameter 'ent_enum'
	include/media/media-entity.h:409: warning: Excess function parameter 'e' description in 'media_entity_enum_set'
	include/media/media-entity.h:424: warning: No description found for parameter 'ent_enum'
	include/media/media-entity.h:424: warning: Excess function parameter 'e' description in 'media_entity_enum_clear'
	include/media/media-entity.h:441: warning: No description found for parameter 'ent_enum'
	include/media/media-entity.h:441: warning: Excess function parameter 'e' description in 'media_entity_enum_test'
	include/media/media-entity.h:458: warning: No description found for parameter 'ent_enum'
	include/media/media-entity.h:458: warning: Excess function parameter 'e' description in 'media_entity_enum_test_and_set'
	include/media/media-entity.h:474: warning: No description found for parameter 'ent_enum'
	include/media/media-entity.h:474: warning: Excess function parameter 'e' description in 'media_entity_enum_empty'
	include/media/media-entity.h:474: warning: Excess function parameter 'entity' description in 'media_entity_enum_empty'
	include/media/media-entity.h:489: warning: No description found for parameter 'ent_enum1'
	include/media/media-entity.h:489: warning: No description found for parameter 'ent_enum2'
	include/media/media-entity.h:489: warning: Excess function parameter 'e' description in 'media_entity_enum_intersects'
	include/media/media-entity.h:489: warning: Excess function parameter 'f' description in 'media_entity_enum_intersects'

Fix them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 include/media/media-device.h |  6 ++++--
 include/media/media-entity.h | 24 ++++++++++++------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index 4b900c9c5cdd..aa8ec40c3a0e 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -279,7 +279,9 @@ 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
+ * @entity_internal_idx: Unique internal entity ID used by the graph traversal
+ *		algorithms
+ * @entity_internal_idx_max: Allocated internal entity indices
  * @entities:	List of registered entities
  * @interfaces:	List of registered interfaces
  * @pads:	List of registered pads
@@ -344,7 +346,7 @@ struct media_device {
 /**
  * media_entity_enum_init - Initialise an entity enumeration
  *
- * @e: Entity enumeration to be initialised
+ * @ent_enum: Entity enumeration to be initialised
  * @mdev: The related media device
  *
  * Returns zero on success or a negative error code.
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index f90ff56888d4..855b47df6ed5 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -391,7 +391,7 @@ void media_entity_enum_cleanup(struct media_entity_enum *ent_enum);
 /**
  * media_entity_enum_zero - Clear the entire enum
  *
- * @e: Entity enumeration to be cleared
+ * @ent_enum: Entity enumeration to be cleared
  */
 static inline void media_entity_enum_zero(struct media_entity_enum *ent_enum)
 {
@@ -401,7 +401,7 @@ static inline void media_entity_enum_zero(struct media_entity_enum *ent_enum)
 /**
  * media_entity_enum_set - Mark a single entity in the enum
  *
- * @e: Entity enumeration
+ * @ent_enum: Entity enumeration
  * @entity: Entity to be marked
  */
 static inline void media_entity_enum_set(struct media_entity_enum *ent_enum,
@@ -416,7 +416,7 @@ static inline void media_entity_enum_set(struct media_entity_enum *ent_enum,
 /**
  * media_entity_enum_clear - Unmark a single entity in the enum
  *
- * @e: Entity enumeration
+ * @ent_enum: Entity enumeration
  * @entity: Entity to be unmarked
  */
 static inline void media_entity_enum_clear(struct media_entity_enum *ent_enum,
@@ -431,7 +431,7 @@ static inline void media_entity_enum_clear(struct media_entity_enum *ent_enum,
 /**
  * media_entity_enum_test - Test whether the entity is marked
  *
- * @e: Entity enumeration
+ * @ent_enum: Entity enumeration
  * @entity: Entity to be tested
  *
  * Returns true if the entity was marked.
@@ -448,13 +448,14 @@ static inline bool media_entity_enum_test(struct media_entity_enum *ent_enum,
 /**
  * media_entity_enum_test - Test whether the entity is marked, and mark it
  *
- * @e: Entity enumeration
+ * @ent_enum: 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)
+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;
@@ -463,10 +464,9 @@ static inline bool media_entity_enum_test_and_set(
 }
 
 /**
- * media_entity_enum_test - Test whether the entire enum is empty
+ * media_entity_enum_empty - Test whether the entire enum is empty
  *
- * @e: Entity enumeration
- * @entity: Entity to be tested
+ * @ent_enum: Entity enumeration
  *
  * Returns true if the entity was marked.
  */
@@ -478,8 +478,8 @@ static inline bool media_entity_enum_empty(struct media_entity_enum *ent_enum)
 /**
  * media_entity_enum_intersects - Test whether two enums intersect
  *
- * @e: First entity enumeration
- * @f: Second entity enumeration
+ * @ent_enum1: First entity enumeration
+ * @ent_enum2: Second entity enumeration
  *
  * Returns true if entity enumerations e and f intersect, otherwise false.
  */
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] [media] au0828-core: fix compilation when !CONFIG_MEDIA_CONTROLLER
  2015-12-16 17:11 [PATCH 1/5] [media] move documentation to the header files Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 2/5] [media] DocBook: document media_entity_graph_walk_cleanup() Mauro Carvalho Chehab
  2015-12-16 17:11 ` [PATCH 3/5] [media] media-entity.h fix documentation for several parameters Mauro Carvalho Chehab
@ 2015-12-16 17:11 ` Mauro Carvalho Chehab
  2015-12-21 13:46   ` Javier Martinez Canillas
  2015-12-16 17:11 ` [PATCH 5/5] [media] media-device.h: use just one u64 counter for object ID Mauro Carvalho Chehab
  3 siblings, 1 reply; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-16 17:11 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Sakari Ailus,
	Javier Martinez Canillas

commit 1590ad7b52714 ("[media] media-device: split media initialization
and registration") moved the media controller register to a
separate function. That caused the following compilation issue,
if !CONFIG_MEDIA_CONTROLLER:

vim +445 drivers/media/usb/au0828/au0828-core.c

   439		if (retval) {
   440			pr_err("%s() au0282_dev_register failed to create graph\n",
   441			       __func__);
   442			goto done;
   443		}
   444
 > 445		retval = media_device_register(dev->media_dev);
   446
   447	done:
   448		if (retval < 0)

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 drivers/media/usb/au0828/au0828-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 2f91bbc633b4..101d32954fe8 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -458,7 +458,9 @@ static int au0828_usb_probe(struct usb_interface *interface,
 		goto done;
 	}
 
+#ifdef CONFIG_MEDIA_CONTROLLER
 	retval = media_device_register(dev->media_dev);
+#endif
 
 done:
 	if (retval < 0)
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] [media] media-device.h: use just one u64 counter for object ID
  2015-12-16 17:11 [PATCH 1/5] [media] move documentation to the header files Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2015-12-16 17:11 ` [PATCH 4/5] [media] au0828-core: fix compilation when !CONFIG_MEDIA_CONTROLLER Mauro Carvalho Chehab
@ 2015-12-16 17:11 ` Mauro Carvalho Chehab
  2015-12-17 10:55   ` [PATCH v2] [media] media-device.h: use just one u32 " Mauro Carvalho Chehab
  3 siblings, 1 reply; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-16 17:11 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of using one u32 counter per type for object IDs, use
just one counter, and move it to u64, in order to match the
changes at the userspace API.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 drivers/media/media-entity.c | 35 +++++++++++++++--------------------
 include/media/media-device.h | 10 ++--------
 include/media/media-entity.h | 27 +++++++++++++--------------
 3 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index a2d28162213e..d3160224db33 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -106,8 +106,8 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 	switch (media_type(gobj)) {
 	case MEDIA_GRAPH_ENTITY:
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x entity#%d: '%s'\n",
-			event_name, gobj->id, media_localid(gobj),
+			"%s id %llu: entity '%s'\n",
+			event_name, media_id(gobj),
 			gobj_to_entity(gobj)->name);
 		break;
 	case MEDIA_GRAPH_LINK:
@@ -115,14 +115,12 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 		struct media_link *link = gobj_to_link(gobj);
 
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n",
-			event_name, gobj->id, media_localid(gobj),
-
-			gobj_type(media_type(link->gobj0)),
-			media_localid(link->gobj0),
-
-			gobj_type(media_type(link->gobj1)),
-			media_localid(link->gobj1));
+			"%s id %llu: %s link id %llu ==> id %llu\n",
+			event_name, media_id(gobj),
+			media_type(link->gobj0) == MEDIA_GRAPH_PAD ?
+				"data" : "interface",
+			media_id(link->gobj0),
+			media_id(link->gobj1));
 		break;
 	}
 	case MEDIA_GRAPH_PAD:
@@ -130,11 +128,10 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 		struct media_pad *pad = gobj_to_pad(gobj);
 
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x %s%spad#%d: '%s':%d\n",
-			event_name, gobj->id,
-			pad->flags & MEDIA_PAD_FL_SINK   ? "  sink " : "",
+			"%s id %llu: %s%spad '%s':%d\n",
+			event_name, media_id(gobj),
+			pad->flags & MEDIA_PAD_FL_SINK   ? "sink " : "",
 			pad->flags & MEDIA_PAD_FL_SOURCE ? "source " : "",
-			media_localid(gobj),
 			pad->entity->name, pad->index);
 		break;
 	}
@@ -144,8 +141,8 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 		struct media_intf_devnode *devnode = intf_to_devnode(intf);
 
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n",
-			event_name, gobj->id, media_localid(gobj),
+			"%s id %llu: intf_devnode %s - major: %d, minor: %d\n",
+			event_name, media_id(gobj),
 			intf_type(intf),
 			devnode->major, devnode->minor);
 		break;
@@ -163,21 +160,19 @@ void media_gobj_create(struct media_device *mdev,
 	gobj->mdev = mdev;
 
 	/* Create a per-type unique object ID */
+	gobj->id = media_gobj_gen_id(type, ++mdev->id);
+
 	switch (type) {
 	case MEDIA_GRAPH_ENTITY:
-		gobj->id = media_gobj_gen_id(type, ++mdev->entity_id);
 		list_add_tail(&gobj->list, &mdev->entities);
 		break;
 	case MEDIA_GRAPH_PAD:
-		gobj->id = media_gobj_gen_id(type, ++mdev->pad_id);
 		list_add_tail(&gobj->list, &mdev->pads);
 		break;
 	case MEDIA_GRAPH_LINK:
-		gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
 		list_add_tail(&gobj->list, &mdev->links);
 		break;
 	case MEDIA_GRAPH_INTF_DEVNODE:
-		gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id);
 		list_add_tail(&gobj->list, &mdev->interfaces);
 		break;
 	}
diff --git a/include/media/media-device.h b/include/media/media-device.h
index aa8ec40c3a0e..b516c7b06e02 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -275,10 +275,7 @@ struct device;
  * @driver_version: Device driver version
  * @topology_version: Monotonic counter for storing the version of the graph
  *		topology. Should be incremented each time the topology changes.
- * @entity_id:	Unique ID used on the last entity registered
- * @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
+ * @id:		Unique ID used on the last registered graph object
  * @entity_internal_idx: Unique internal entity ID used by the graph traversal
  *		algorithms
  * @entity_internal_idx_max: Allocated internal entity indices
@@ -313,10 +310,7 @@ struct media_device {
 
 	u32 topology_version;
 
-	u32 entity_id;
-	u32 pad_id;
-	u32 link_id;
-	u32 intf_devnode_id;
+	u64 id;
 	struct ida entity_internal_idx;
 	int entity_internal_idx_max;
 
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 855b47df6ed5..73ab2bc6a1c9 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -46,9 +46,9 @@ enum media_gobj_type {
 	MEDIA_GRAPH_INTF_DEVNODE,
 };
 
-#define MEDIA_BITS_PER_TYPE		8
-#define MEDIA_BITS_PER_LOCAL_ID		(32 - MEDIA_BITS_PER_TYPE)
-#define MEDIA_LOCAL_ID_MASK		 GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0)
+#define MEDIA_BITS_PER_TYPE		8ULL
+#define MEDIA_BITS_PER_ID		(64ULL - MEDIA_BITS_PER_TYPE)
+#define MEDIA_ID_MASK			 GENMASK_ULL(MEDIA_BITS_PER_ID - 1, 0)
 
 /* Structs to represent the objects that belong to a media graph */
 
@@ -58,16 +58,15 @@ enum media_gobj_type {
  * @mdev:	Pointer to the struct media_device that owns the object
  * @id:		Non-zero object ID identifier. The ID should be unique
  *		inside a media_device, as it is composed by
- *		MEDIA_BITS_PER_TYPE to store the type plus
- *		MEDIA_BITS_PER_LOCAL_ID	to store a per-type ID
- *		(called as "local ID").
+ *		%MEDIA_BITS_PER_TYPE to store the type plus
+ *		%MEDIA_BITS_PER_ID to store the ID
  * @list:	List entry stored in one of the per-type mdev object lists
  *
  * All objects on the media graph should have this struct embedded
  */
 struct media_gobj {
 	struct media_device	*mdev;
-	u32			id;
+	u64			id;
 	struct list_head	list;
 };
 
@@ -299,20 +298,20 @@ static inline u32 media_entity_id(struct media_entity *entity)
  */
 static inline enum media_gobj_type media_type(struct media_gobj *gobj)
 {
-	return gobj->id >> MEDIA_BITS_PER_LOCAL_ID;
+	return gobj->id >> MEDIA_BITS_PER_ID;
 }
 
-static inline u32 media_localid(struct media_gobj *gobj)
+static inline u64 media_id(struct media_gobj *gobj)
 {
-	return gobj->id & MEDIA_LOCAL_ID_MASK;
+	return gobj->id & MEDIA_ID_MASK;
 }
 
-static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)
+static inline u64 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
 {
-	u32 id;
+	u64 id;
 
-	id = type << MEDIA_BITS_PER_LOCAL_ID;
-	id |= local_id & MEDIA_LOCAL_ID_MASK;
+	id = (u64)type << MEDIA_BITS_PER_ID;
+	id |= local_id & MEDIA_ID_MASK;
 
 	return id;
 }
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2] [media] media-device.h: use just one u32 counter for object ID
  2015-12-16 17:11 ` [PATCH 5/5] [media] media-device.h: use just one u64 counter for object ID Mauro Carvalho Chehab
@ 2015-12-17 10:55   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2015-12-17 10:55 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of using one u32 counter per type for object IDs, use
just one counter. With such change, it makes sense to simplify
the debug logs too.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 drivers/media/media-entity.c | 35 +++++++++++++++--------------------
 include/media/media-device.h | 10 ++--------
 include/media/media-entity.h | 21 ++++++++++-----------
 3 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index a2d28162213e..f63be23e6ed4 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -106,8 +106,8 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 	switch (media_type(gobj)) {
 	case MEDIA_GRAPH_ENTITY:
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x entity#%d: '%s'\n",
-			event_name, gobj->id, media_localid(gobj),
+			"%s id %u: entity '%s'\n",
+			event_name, media_id(gobj),
 			gobj_to_entity(gobj)->name);
 		break;
 	case MEDIA_GRAPH_LINK:
@@ -115,14 +115,12 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 		struct media_link *link = gobj_to_link(gobj);
 
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n",
-			event_name, gobj->id, media_localid(gobj),
-
-			gobj_type(media_type(link->gobj0)),
-			media_localid(link->gobj0),
-
-			gobj_type(media_type(link->gobj1)),
-			media_localid(link->gobj1));
+			"%s id %u: %s link id %u ==> id %u\n",
+			event_name, media_id(gobj),
+			media_type(link->gobj0) == MEDIA_GRAPH_PAD ?
+				"data" : "interface",
+			media_id(link->gobj0),
+			media_id(link->gobj1));
 		break;
 	}
 	case MEDIA_GRAPH_PAD:
@@ -130,11 +128,10 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 		struct media_pad *pad = gobj_to_pad(gobj);
 
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x %s%spad#%d: '%s':%d\n",
-			event_name, gobj->id,
-			pad->flags & MEDIA_PAD_FL_SINK   ? "  sink " : "",
+			"%s id %u: %s%spad '%s':%d\n",
+			event_name, media_id(gobj),
+			pad->flags & MEDIA_PAD_FL_SINK   ? "sink " : "",
 			pad->flags & MEDIA_PAD_FL_SOURCE ? "source " : "",
-			media_localid(gobj),
 			pad->entity->name, pad->index);
 		break;
 	}
@@ -144,8 +141,8 @@ static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 		struct media_intf_devnode *devnode = intf_to_devnode(intf);
 
 		dev_dbg(gobj->mdev->dev,
-			"%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n",
-			event_name, gobj->id, media_localid(gobj),
+			"%s id %u: intf_devnode %s - major: %d, minor: %d\n",
+			event_name, media_id(gobj),
 			intf_type(intf),
 			devnode->major, devnode->minor);
 		break;
@@ -163,21 +160,19 @@ void media_gobj_create(struct media_device *mdev,
 	gobj->mdev = mdev;
 
 	/* Create a per-type unique object ID */
+	gobj->id = media_gobj_gen_id(type, ++mdev->id);
+
 	switch (type) {
 	case MEDIA_GRAPH_ENTITY:
-		gobj->id = media_gobj_gen_id(type, ++mdev->entity_id);
 		list_add_tail(&gobj->list, &mdev->entities);
 		break;
 	case MEDIA_GRAPH_PAD:
-		gobj->id = media_gobj_gen_id(type, ++mdev->pad_id);
 		list_add_tail(&gobj->list, &mdev->pads);
 		break;
 	case MEDIA_GRAPH_LINK:
-		gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
 		list_add_tail(&gobj->list, &mdev->links);
 		break;
 	case MEDIA_GRAPH_INTF_DEVNODE:
-		gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id);
 		list_add_tail(&gobj->list, &mdev->interfaces);
 		break;
 	}
diff --git a/include/media/media-device.h b/include/media/media-device.h
index aa8ec40c3a0e..122963a0820e 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -275,10 +275,7 @@ struct device;
  * @driver_version: Device driver version
  * @topology_version: Monotonic counter for storing the version of the graph
  *		topology. Should be incremented each time the topology changes.
- * @entity_id:	Unique ID used on the last entity registered
- * @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
+ * @id:		Unique ID used on the last registered graph object
  * @entity_internal_idx: Unique internal entity ID used by the graph traversal
  *		algorithms
  * @entity_internal_idx_max: Allocated internal entity indices
@@ -313,10 +310,7 @@ struct media_device {
 
 	u32 topology_version;
 
-	u32 entity_id;
-	u32 pad_id;
-	u32 link_id;
-	u32 intf_devnode_id;
+	u32 id;
 	struct ida entity_internal_idx;
 	int entity_internal_idx_max;
 
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 855b47df6ed5..54be1496d542 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -47,8 +47,8 @@ enum media_gobj_type {
 };
 
 #define MEDIA_BITS_PER_TYPE		8
-#define MEDIA_BITS_PER_LOCAL_ID		(32 - MEDIA_BITS_PER_TYPE)
-#define MEDIA_LOCAL_ID_MASK		 GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0)
+#define MEDIA_BITS_PER_ID		(32 - MEDIA_BITS_PER_TYPE)
+#define MEDIA_ID_MASK			 GENMASK_ULL(MEDIA_BITS_PER_ID - 1, 0)
 
 /* Structs to represent the objects that belong to a media graph */
 
@@ -58,9 +58,8 @@ enum media_gobj_type {
  * @mdev:	Pointer to the struct media_device that owns the object
  * @id:		Non-zero object ID identifier. The ID should be unique
  *		inside a media_device, as it is composed by
- *		MEDIA_BITS_PER_TYPE to store the type plus
- *		MEDIA_BITS_PER_LOCAL_ID	to store a per-type ID
- *		(called as "local ID").
+ *		%MEDIA_BITS_PER_TYPE to store the type plus
+ *		%MEDIA_BITS_PER_ID to store the ID
  * @list:	List entry stored in one of the per-type mdev object lists
  *
  * All objects on the media graph should have this struct embedded
@@ -299,20 +298,20 @@ static inline u32 media_entity_id(struct media_entity *entity)
  */
 static inline enum media_gobj_type media_type(struct media_gobj *gobj)
 {
-	return gobj->id >> MEDIA_BITS_PER_LOCAL_ID;
+	return gobj->id >> MEDIA_BITS_PER_ID;
 }
 
-static inline u32 media_localid(struct media_gobj *gobj)
+static inline u32 media_id(struct media_gobj *gobj)
 {
-	return gobj->id & MEDIA_LOCAL_ID_MASK;
+	return gobj->id & MEDIA_ID_MASK;
 }
 
-static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)
+static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
 {
 	u32 id;
 
-	id = type << MEDIA_BITS_PER_LOCAL_ID;
-	id |= local_id & MEDIA_LOCAL_ID_MASK;
+	id = type << MEDIA_BITS_PER_ID;
+	id |= local_id & MEDIA_ID_MASK;
 
 	return id;
 }
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/5] [media] au0828-core: fix compilation when !CONFIG_MEDIA_CONTROLLER
  2015-12-16 17:11 ` [PATCH 4/5] [media] au0828-core: fix compilation when !CONFIG_MEDIA_CONTROLLER Mauro Carvalho Chehab
@ 2015-12-21 13:46   ` Javier Martinez Canillas
  0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2015-12-21 13:46 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Hans Verkuil,
	Rafael Lourenço de Lima Chehab, Sakari Ailus

Hello Mauro,

On 12/16/2015 02:11 PM, Mauro Carvalho Chehab wrote:
> commit 1590ad7b52714 ("[media] media-device: split media initialization
> and registration") moved the media controller register to a
> separate function. That caused the following compilation issue,
> if !CONFIG_MEDIA_CONTROLLER:
> 
> vim +445 drivers/media/usb/au0828/au0828-core.c
> 
>    439		if (retval) {
>    440			pr_err("%s() au0282_dev_register failed to create graph\n",
>    441			       __func__);
>    442			goto done;
>    443		}
>    444
>  > 445		retval = media_device_register(dev->media_dev);
>    446
>    447	done:
>    448		if (retval < 0)
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Looks good to me, sorry for forgetting to test with !CONFIG_MEDIA_CONTROLLER
and missing this...

Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-12-21 13:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-16 17:11 [PATCH 1/5] [media] move documentation to the header files Mauro Carvalho Chehab
2015-12-16 17:11 ` [PATCH 2/5] [media] DocBook: document media_entity_graph_walk_cleanup() Mauro Carvalho Chehab
2015-12-16 17:11 ` [PATCH 3/5] [media] media-entity.h fix documentation for several parameters Mauro Carvalho Chehab
2015-12-16 17:11 ` [PATCH 4/5] [media] au0828-core: fix compilation when !CONFIG_MEDIA_CONTROLLER Mauro Carvalho Chehab
2015-12-21 13:46   ` Javier Martinez Canillas
2015-12-16 17:11 ` [PATCH 5/5] [media] media-device.h: use just one u64 counter for object ID Mauro Carvalho Chehab
2015-12-17 10:55   ` [PATCH v2] [media] media-device.h: use just one u32 " 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).