Skip to contentSkip to conversation

Changes on MC core due to MC workshop discussion

RFC PATCH In review Mauro Carvalho Chehab 5 participants 26 messages Aug 12, 2015 – Aug 14, 2015

Subsystems (23)
lore
Share & tools
lore
#0 lore raw

v3 cover Changes on MC core due to MC workshop discussion

This is the third version of an initial set of patches showing the approach I'm taking in order to fulfill all the MC needs that was discussed on the 3 day MC summit in Helsinki.

This version comes with the changes requested at the ML:

- added unions at links for source/port0/entity and sink/port1/interface. That avoided adding macros to get the pad from the graph_obj on most places;

- removed a wrong initialization for the reserse link at the pad create link function;

- merged a fixup patch that was sent in separate by mistake on the previous series.

=====

The goal of this patchset is:

1) to create a common struct that will be embedded on all internal structs that represents the comon data that will be used by all kinds of objects;

2) to have an unique object ID for each object in the graph. The object ID will be needed by the userspace API in the future, as discussed during the MC workshop;

3) to create objects to represent Kernel->userspace interfaces;

4) to extend the link support to allow linking interfaces to entities.

On version 2, I removed the kref, as some people at the #v4l channel are not convinced about its need. So, let's postpone such discussion when we start introducing patches that will actually do dynamic object removal in runtime.

As suggested, I'll be sending incremental patches and avoiding to do a large set of changes into one changeset series. That basically means that those patches aren't tested yet (except for compilation tests).

Along this patch series, I'll be calling "object" as any "symbol" that belongs to a media graph, like processing entities, connectors, links, pads, interfaces.

As said on the goals of this RFC, on version 2 of this patch series, we're coming with the new concept: interfaces.

An interface is a graph object that does the interaction between Kernelspace <===> Userspace. While the code written for interface creation and interface<==>entity link is generic, currently I added support only for the type of interface currently used at the existing MC graphs: device node interfaces. We should add other types of interfaces in a future patchset. For example, we need to add support for network interfaces in order to fulfill the needs of the DVB subsystem. We'll also need to add support for sysfs interfaces in order to support IIO and remote controllers.

Those API changes are aligned with the RFC for the userspace API proposed by Hans Verkuil:

	http://www.spinics.net/lists/linux-media/msg92166.html

The only difference is that I'm using a single counter to generate an unique object ID, while Hans proposal is to use one per object type. As explained on my comments on the last patch series, the rationale is to simply simplify the code, helping to make the internal API changes clearer. We can change this latter before adding support for the userspace API.

I suspect that we'll also need another type to represent groups of objects, but this will be covered on future patches if/when needed.

No userspace API changes here, just changes at the internal structs that contains the media graph objects and some new helper functions.

===========
Future work
===========

I think that, after changing the MC core to support the new proposed API, a next step would be to simplify the internal representation of the media objects, in order to make it easier to be reused on other subsystems like IIO and to spend less memory. With that regards, I think that we can get rid of some fields at the existing structures:

struct media_link.reverse - Currently we create two copies of the same link, in order to use at the graph traversal. I think we can remove it and use just one copy;

struct media_entity - well, there are several things that we can get hid there:
- parent - we're already storing it at the objects;
- id - we have already an unique ID at the objects;
- type - this should be replaced by properties;
- revision - not used, afaikt;
- group_id - groups should really be a new object type that will have the list of object IDs that belong to the group.
- num_links/num_backlinks - those are used only at the userspace interface, but we need to track link creation/removal just to feed those things. I would remove those and add a logic at media_device.c to count;
- num_pads - if we convert pads to lists (with seems to be the best thing, as not all entities need pads), then we can get rid of this too;
- union info - this should be retrieved via the interface, and not via the entity.

Yet, the above are suggestions for some future next steps. I won't probably address the above, except if needed in order to support the DVB or ALSA needs.

Mauro Carvalho Chehab (16):
media: Add some fields to store graph objects
media: Add a common embeed struct for all media graph objects
media: add functions to inialize media_graph_obj
media: ensure that entities will have an object ID
media: initialize PAD objects
media: initialize the graph object inside the media links
media: get rid of unused "extra_links" param on media_entity_init()
media: convert links from array to list
media: use media_graph_obj for link endpoints
media: rename link source/sink to pad0_source/pad1_sink
media: rename the function that create pad links
media: move __media_entity_remove_link to avoid prototype
media: make the internal function to create links more generic
media: add a generic function to remove a link
media: rename media_entity_remove_foo functions
media: add functions to allow creating interfaces

 Documentation/media-framework.txt                  |   2 +-
 Documentation/video4linux/v4l2-framework.txt       |   4 +-
 Documentation/zh_CN/video4linux/v4l2-framework.txt |   4 +-
 drivers/media/dvb-core/dvb_frontend.c              |  10 +-
 drivers/media/dvb-core/dvbdev.c                    |  10 +-
 drivers/media/i2c/ad9389b.c                        |   2 +-
 drivers/media/i2c/adp1653.c                        |   2 +-
 drivers/media/i2c/adv7180.c                        |   2 +-
 drivers/media/i2c/adv7511.c                        |   2 +-
 drivers/media/i2c/adv7604.c                        |   2 +-
 drivers/media/i2c/adv7842.c                        |   2 +-
 drivers/media/i2c/as3645a.c                        |   2 +-
 drivers/media/i2c/cx25840/cx25840-core.c           |   2 +-
 drivers/media/i2c/lm3560.c                         |   2 +-
 drivers/media/i2c/lm3646.c                         |   2 +-
 drivers/media/i2c/m5mols/m5mols_core.c             |   2 +-
 drivers/media/i2c/mt9m032.c                        |   2 +-
 drivers/media/i2c/mt9p031.c                        |   2 +-
 drivers/media/i2c/mt9t001.c                        |   2 +-
 drivers/media/i2c/mt9v032.c                        |   2 +-
 drivers/media/i2c/noon010pc30.c                    |   2 +-
 drivers/media/i2c/ov2659.c                         |   2 +-
 drivers/media/i2c/ov9650.c                         |   2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c           |   8 +-
 drivers/media/i2c/s5k4ecgx.c                       |   2 +-
 drivers/media/i2c/s5k5baf.c                        |   6 +-
 drivers/media/i2c/s5k6a3.c                         |   2 +-
 drivers/media/i2c/s5k6aa.c                         |   2 +-
 drivers/media/i2c/smiapp/smiapp-core.c             |   8 +-
 drivers/media/i2c/tc358743.c                       |   2 +-
 drivers/media/i2c/tvp514x.c                        |   2 +-
 drivers/media/i2c/tvp7002.c                        |   2 +-
 drivers/media/media-device.c                       |  47 ++-
 drivers/media/media-entity.c                       | 363 ++++++++++++++-------
 drivers/media/platform/exynos4-is/fimc-capture.c   |   4 +-
 drivers/media/platform/exynos4-is/fimc-isp-video.c |   2 +-
 drivers/media/platform/exynos4-is/fimc-isp.c       |   2 +-
 drivers/media/platform/exynos4-is/fimc-lite.c      |   4 +-
 drivers/media/platform/exynos4-is/fimc-m2m.c       |   2 +-
 drivers/media/platform/exynos4-is/media-dev.c      |  18 +-
 drivers/media/platform/exynos4-is/mipi-csis.c      |   2 +-
 drivers/media/platform/omap3isp/isp.c              |  22 +-
 drivers/media/platform/omap3isp/ispccdc.c          |   6 +-
 drivers/media/platform/omap3isp/ispccp2.c          |   4 +-
 drivers/media/platform/omap3isp/ispcsi2.c          |   4 +-
 drivers/media/platform/omap3isp/isppreview.c       |   6 +-
 drivers/media/platform/omap3isp/ispresizer.c       |   6 +-
 drivers/media/platform/omap3isp/ispstat.c          |   2 +-
 drivers/media/platform/omap3isp/ispvideo.c         |   2 +-
 drivers/media/platform/s3c-camif/camif-capture.c   |   4 +-
 drivers/media/platform/s3c-camif/camif-core.c      |   4 +-
 drivers/media/platform/vsp1/vsp1_drv.c             |   4 +-
 drivers/media/platform/vsp1/vsp1_entity.c          |   2 +-
 drivers/media/platform/vsp1/vsp1_rpf.c             |   2 +-
 drivers/media/platform/vsp1/vsp1_video.c           |   2 +-
 drivers/media/platform/vsp1/vsp1_wpf.c             |   2 +-
 drivers/media/platform/xilinx/xilinx-dma.c         |   2 +-
 drivers/media/platform/xilinx/xilinx-tpg.c         |   2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c        |   4 +-
 drivers/media/usb/cx231xx/cx231xx-cards.c          |   6 +-
 drivers/media/usb/cx231xx/cx231xx-video.c          |  18 +-
 drivers/media/usb/uvc/uvc_entity.c                 |   6 +-
 drivers/media/v4l2-core/tuner-core.c               |   2 +-
 drivers/media/v4l2-core/v4l2-device.c              |   2 +-
 drivers/media/v4l2-core/v4l2-flash-led-class.c     |   2 +-
 drivers/media/v4l2-core/v4l2-subdev.c              |   6 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |   2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |   4 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c    |   4 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  14 +-
 .../staging/media/davinci_vpfe/vpfe_mc_capture.c   |  10 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.c    |   2 +-
 drivers/staging/media/omap4iss/iss.c               |  20 +-
 drivers/staging/media/omap4iss/iss_csi2.c          |   6 +-
 drivers/staging/media/omap4iss/iss_ipipe.c         |   2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c       |   4 +-
 drivers/staging/media/omap4iss/iss_resizer.c       |   4 +-
 drivers/staging/media/omap4iss/iss_video.c         |   2 +-
 include/media/media-device.h                       |   4 +
 include/media/media-entity.h                       | 139 +++++++-
 80 files changed, 577 insertions(+), 306 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

RFC PATCH v3 1/16 media: Add some fields to store graph objects

We'll need unique IDs for graph objects and a way to associate them with the media interface.

So, add an atomic var to be used to create unique IDs and a list to store such objects.

drivers/media/media-device.c +4 -0
index 7b39440192d6..e627b0b905ad 100644
@@ -396,6 +396,10 @@ int __must_check __media_device_register(struct media_device *mdev,
 		return ret;
 	}
 
+	/* Initialize media graph object list and ID */
+	atomic_set(&mdev->last_obj_id, 0);
+	INIT_LIST_HEAD(&mdev->object_list);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(__media_device_register);
include/media/media-device.h +4 -0
index 6e6db78f1ee2..a9d546716e49 100644
@@ -78,6 +78,10 @@ struct media_device {
 
 	int (*link_notify)(struct media_link *link, u32 flags,
 			   unsigned int notification);
+
+	/* Used by media_graph stuff */
+	atomic_t last_obj_id;
+	struct list_head object_list;
 };
 
 /* Supported link_notify @notification values. */
Signature · 1 line
2.4.3
#2 lore raw

RFC PATCH v3 2/16 media: Add a common embeed struct for all media graph objects

In reply to Mauro Carvalho Chehab

Due to the MC API proposed changes, we'll need to:
- have an unique object ID for all graph objects;
- be able to dynamically create/remove objects;
- be able to group objects;
- keep the object in memory until we stop use it.

Due to that, create a struct media_graph_obj and put there the common elements that all media objects will have in common.

include/media/media-entity.h +42 -0
index 0c003d817493..051aa3f8bbfe 100644
@@ -28,10 +28,50 @@
 #include <linux/list.h>
 #include <linux/media.h>
 
+/* Enums used internally at the media controller to represent graphs */
+
+/**
+ * enum media_graph_type - type of a graph element
+ *
+ * @MEDIA_GRAPH_ENTITY:		Identify a media entity
+ * @MEDIA_GRAPH_PAD:		Identify a media PAD
+ * @MEDIA_GRAPH_LINK:		Identify a media link
+ */
+enum media_graph_type {
+	MEDIA_GRAPH_ENTITY,
+	MEDIA_GRAPH_PAD,
+	MEDIA_GRAPH_LINK,
+};
+
+
+/* Structs to represent the objects that belong to a media graph */
+
+/**
+ * struct media_graph_obj - Define a graph object.
+ *
+ * @list:		List of media graph objects
+ * @obj_id:		Non-zero object ID identifier. The ID should be unique
+ *			inside a media_device
+ * @type:		Type of the graph object
+ * @mdev:		Media device that contains the object
+ *			object before stopping using it
+ *
+ * All elements on the media graph should have this struct embedded
+ */
+struct media_graph_obj {
+	struct list_head	list;
+	struct list_head	group;
+	u32			obj_id;
+	enum media_graph_type	type;
+	struct media_device	*mdev;
+};
+
+
 struct media_pipeline {
 };
 
 struct media_link {
+	struct media_graph_obj			graph_obj;
 	struct media_pad *source;	/* Source pad */
 	struct media_pad *sink;		/* Sink pad  */
 	struct media_link *reverse;	/* Link in the reverse direction */
@@ -39,6 +79,7 @@ struct media_link {
 };
 
 struct media_pad {
+	struct media_graph_obj			graph_obj;
 	struct media_entity *entity;	/* Entity this pad belongs to */
 	u16 index;			/* Pad index in the entity pads array */
 	unsigned long flags;		/* Pad flags (MEDIA_PAD_FL_*) */
@@ -61,6 +102,7 @@ struct media_entity_operations {
 };
 
 struct media_entity {
+	struct media_graph_obj			graph_obj;
 	struct list_head list;
 	struct media_device *parent;	/* Media device this entity belongs to*/
 	u32 id;				/* Entity ID, unique in the parent media
Signature · 1 line
2.4.3
maintainer
#3 lore raw

Re: [PATCH RFC v3 02/16] media: Add a common embeed struct for all media graph objects

Hi Mauro,

Thank you for the patchset!

Quoted 42 lines · Mauro Carvalho Chehab

Due to the MC API proposed changes, we'll need to:
- have an unique object ID for all graph objects;
- be able to dynamically create/remove objects;
- be able to group objects;
- keep the object in memory until we stop use it.

Due to that, create a struct media_graph_obj and put there the common elements that all media objects will have in common.

include/media/media-entity.h +23 -0
index 0c003d817493..051aa3f8bbfe 100644
@@ -28,10 +28,50 @@
 #include <linux/list.h>
 #include <linux/media.h>
 
+/* Enums used internally at the media controller to represent graphs */
+
+/**
+ * enum media_graph_type - type of a graph element
+ *
+ * @MEDIA_GRAPH_ENTITY:		Identify a media entity
+ * @MEDIA_GRAPH_PAD:		Identify a media PAD
+ * @MEDIA_GRAPH_LINK:		Identify a media link
+ */
+enum media_graph_type {
+	MEDIA_GRAPH_ENTITY,
+	MEDIA_GRAPH_PAD,
+	MEDIA_GRAPH_LINK,
+};
+
+
+/* Structs to represent the objects that belong to a media graph */
+
+/**
+ * struct media_graph_obj - Define a graph object.
+ *
+ * @list:		List of media graph objects
+ * @obj_id:		Non-zero object ID identifier. The ID should be unique

include/media/media-entity.h line 63

Quoted 10 lines
include/media/media-entity.h +10 -0
+ *			inside a media_device
+ * @type:		Type of the graph object
+ * @mdev:		Media device that contains the object
+ *			object before stopping using it
+ *
+ * All elements on the media graph should have this struct embedded
+ */
+struct media_graph_obj {
+	struct list_head	list;
+	struct list_head	group;

What's group for?

include/media/media-entity.h line 64

Quoted 1 line
include/media/media-entity.h +1 -0
+	u32			obj_id;

I'd just call this "id".

Quoted 22 lines
include/media/media-entity.h +7 -0
+	enum media_graph_type	type;
+	struct media_device	*mdev;
+};
+
+
 struct media_pipeline {
 };
 
 struct media_link {
+	struct media_graph_obj			graph_obj;
 	struct media_pad *source;	/* Source pad */
 	struct media_pad *sink;		/* Sink pad  */
 	struct media_link *reverse;	/* Link in the reverse direction */
@@ -39,6 +79,7 @@ struct media_link {
 };
 
 struct media_pad {
+	struct media_graph_obj			graph_obj;
 	struct media_entity *entity;	/* Entity this pad belongs to */
 	u16 index;			/* Pad index in the entity pads array */
 	unsigned long flags;		/* Pad flags (MEDIA_PAD_FL_*) */

include/media/media-entity.h struct media_entity_operations { · line 108

Quoted 7 lines
include/media/media-entity.h +1 -0
@@ -61,6 +102,7 @@ struct media_entity_operations {
 };
 
 struct media_entity {
+	struct media_graph_obj			graph_obj;
 	struct list_head list;
 	struct media_device *parent;	/* Media device this entity belongs to*/
 	u32 id;				/* Entity ID, unique in the parent media

Will entity id be different from the media_graph_obj obj_id of the object?

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#4 lore raw

Re: [PATCH RFC v3 02/16] media: Add a common embeed struct for all media graph objects

Em Fri, 14 Aug 2015 16:08:34 +0300
Sakari Ailus <[email protected]> escreveu:

Quoted 51 lines

Hi Mauro,

Thank you for the patchset!

Quoted 46 lines · Mauro Carvalho Chehab

Due to the MC API proposed changes, we'll need to:
- have an unique object ID for all graph objects;
- be able to dynamically create/remove objects;
- be able to group objects;
- keep the object in memory until we stop use it.

Due to that, create a struct media_graph_obj and put there the common elements that all media objects will have in common.

include/media/media-entity.h +27 -0
index 0c003d817493..051aa3f8bbfe 100644
@@ -28,10 +28,50 @@
 #include <linux/list.h>
 #include <linux/media.h>
 
+/* Enums used internally at the media controller to represent graphs */
+
+/**
+ * enum media_graph_type - type of a graph element
+ *
+ * @MEDIA_GRAPH_ENTITY:		Identify a media entity
+ * @MEDIA_GRAPH_PAD:		Identify a media PAD
+ * @MEDIA_GRAPH_LINK:		Identify a media link
+ */
+enum media_graph_type {
+	MEDIA_GRAPH_ENTITY,
+	MEDIA_GRAPH_PAD,
+	MEDIA_GRAPH_LINK,
+};
+
+
+/* Structs to represent the objects that belong to a media graph */
+
+/**
+ * struct media_graph_obj - Define a graph object.
+ *
+ * @list:		List of media graph objects
+ * @obj_id:		Non-zero object ID identifier. The ID should be unique
+ *			inside a media_device
+ * @type:		Type of the graph object
+ * @mdev:		Media device that contains the object
+ *			object before stopping using it
Quoted 8 lines

include/media/media-entity.h line 63

Quoted 6 lines
include/media/media-entity.h +6 -0
+ *
+ * All elements on the media graph should have this struct embedded
+ */
+struct media_graph_obj {
+	struct list_head	list;
+	struct list_head	group;

What's group for?

I'm actually thinking on replacing group_id by a group list object type.

Anyway, I'm simplifying this patch series. So, I'll drop this field for now. We can add it when needed.

Quoted 4 lines

include/media/media-entity.h line 64

Quoted 2 lines
include/media/media-entity.h +1 -0
+	u32			obj_id;

I'd just call this "id".

OK.

Quoted 25 lines
Quoted 25 lines
include/media/media-entity.h +7 -0
+	enum media_graph_type	type;
+	struct media_device	*mdev;
+};
+
+
 struct media_pipeline {
 };
 
 struct media_link {
+	struct media_graph_obj			graph_obj;
 	struct media_pad *source;	/* Source pad */
 	struct media_pad *sink;		/* Sink pad  */
 	struct media_link *reverse;	/* Link in the reverse direction */
@@ -39,6 +79,7 @@ struct media_link {
 };
 
 struct media_pad {
+	struct media_graph_obj			graph_obj;
 	struct media_entity *entity;	/* Entity this pad belongs to */
 	u16 index;			/* Pad index in the entity pads array */
 	unsigned long flags;		/* Pad flags (MEDIA_PAD_FL_*) */
@@ -61,6 +102,7 @@ struct media_entity_operations {
 };
 
Quoted 7 lines

include/media/media-entity.h struct media_entity_operations { · line 108

Quoted 5 lines
include/media/media-entity.h +1 -0
 struct media_entity {
+	struct media_graph_obj			graph_obj;
 	struct list_head list;
 	struct media_device *parent;	/* Media device this entity belongs to*/
 	u32 id;				/* Entity ID, unique in the parent media

Will entity id be different from the media_graph_obj obj_id of the object?

No. I'm right now writing a patch removing entity->id.

Regards,
Mauro

#5 lore raw

Re: [PATCH RFC v3 02/16] media: Add a common embeed struct for all media graph objects

Quoted 108 lines · Mauro Carvalho Chehab

Em Fri, 14 Aug 2015 16:08:34 +0300
Sakari Ailus <[email protected]> escreveu:

Quoted 51 lines

Hi Mauro,

Thank you for the patchset!

Quoted 46 lines · Mauro Carvalho Chehab

Due to the MC API proposed changes, we'll need to:
- have an unique object ID for all graph objects;
- be able to dynamically create/remove objects;
- be able to group objects;
- keep the object in memory until we stop use it.

Due to that, create a struct media_graph_obj and put there the common elements that all media objects will have in common.

include/media/media-entity.h +27 -0
index 0c003d817493..051aa3f8bbfe 100644
@@ -28,10 +28,50 @@
 #include <linux/list.h>
 #include <linux/media.h>
 
+/* Enums used internally at the media controller to represent graphs */
+
+/**
+ * enum media_graph_type - type of a graph element
+ *
+ * @MEDIA_GRAPH_ENTITY:		Identify a media entity
+ * @MEDIA_GRAPH_PAD:		Identify a media PAD
+ * @MEDIA_GRAPH_LINK:		Identify a media link
+ */
+enum media_graph_type {
+	MEDIA_GRAPH_ENTITY,
+	MEDIA_GRAPH_PAD,
+	MEDIA_GRAPH_LINK,
+};
+
+
+/* Structs to represent the objects that belong to a media graph */
+
+/**
+ * struct media_graph_obj - Define a graph object.
+ *
+ * @list:		List of media graph objects
+ * @obj_id:		Non-zero object ID identifier. The ID should be unique
+ *			inside a media_device
+ * @type:		Type of the graph object
+ * @mdev:		Media device that contains the object
+ *			object before stopping using it
Quoted 8 lines

include/media/media-entity.h line 63

Quoted 6 lines
include/media/media-entity.h +6 -0
+ *
+ * All elements on the media graph should have this struct embedded
+ */
+struct media_graph_obj {
+	struct list_head	list;
+	struct list_head	group;

What's group for?

I'm actually thinking on replacing group_id by a group list object type.

Anyway, I'm simplifying this patch series. So, I'll drop this field for now. We can add it when needed.

Quoted 4 lines

include/media/media-entity.h line 64

Quoted 2 lines
include/media/media-entity.h +1 -0
+	u32			obj_id;

I'd just call this "id".

OK.

Quoted 25 lines
Quoted 25 lines
include/media/media-entity.h +7 -0
+	enum media_graph_type	type;
+	struct media_device	*mdev;
+};
+
+
 struct media_pipeline {
 };
 
 struct media_link {
+	struct media_graph_obj			graph_obj;
 	struct media_pad *source;	/* Source pad */
 	struct media_pad *sink;		/* Sink pad  */
 	struct media_link *reverse;	/* Link in the reverse direction */
@@ -39,6 +79,7 @@ struct media_link {
 };
 
 struct media_pad {
+	struct media_graph_obj			graph_obj;
 	struct media_entity *entity;	/* Entity this pad belongs to */
 	u16 index;			/* Pad index in the entity pads array */
 	unsigned long flags;		/* Pad flags (MEDIA_PAD_FL_*) */
@@ -61,6 +102,7 @@ struct media_entity_operations {
 };
 
Quoted 7 lines

include/media/media-entity.h struct media_entity_operations { · line 108

Quoted 5 lines
include/media/media-entity.h +1 -0
 struct media_entity {
+	struct media_graph_obj			graph_obj;
 	struct list_head list;
 	struct media_device *parent;	/* Media device this entity belongs to*/
 	u32 id;				/* Entity ID, unique in the parent media

Will entity id be different from the media_graph_obj obj_id of the object?

Quoted 1 line

No. I'm right now writing a patch removing entity->id.

Oh good, I had the same thoughts as Sakari but forgot to write it down. I agree with the changes you're making (remove group, rename obj_id to id and use it instead of entity->id).

Regards,

Hans

#6 lore raw

RFC PATCH v3 3/16 media: add functions to inialize media_graph_obj

In reply to Mauro Carvalho Chehab

We need to initialize the common media_graph_obj that it is now embedded inside each media controller object.

Latter patches will use those functions to ensure that the object will be properly initialized.

drivers/media/media-entity.c +38 -0
index 4d8e01c7b1b2..19ad316f2f33 100644
@@ -27,6 +27,44 @@
 #include <media/media-device.h>
 
 /**
+ *  graph_obj_init - Initialize a graph object
+ *
+ * @mdev:	Pointer to the media_device that contains the object
+ * @type:	Type of the object
+ * @gobj:	Pointer to the object
+ *
+ * This routine initializes the embedded struct media_graph_obj inside a
+ * media graph object. It is called automatically if media_*_create()
+ * calls are used. However, if the object (entity, link, pad, interface)
+ * is embedded on some other object, this function should be called before
+ * registering the object at the media controller.
+ */
+void graph_obj_init(struct media_device *mdev,
+			   enum media_graph_type type,
+			   struct media_graph_obj *gobj)
+{
+	INIT_LIST_HEAD(&gobj->list);
+
+	list_add_tail(&gobj->list, &mdev->object_list);
+	gobj->obj_id = atomic_inc_return(&mdev->last_obj_id);
+	gobj->type = type;
+	gobj->mdev = mdev;
+}
+
+/**
+ *  graph_obj_remove - Stop using a graph object on a media device
+ *
+ * @graph_obj:	Pointer to the object
+ *
+ * This is called at media_device_unregister_*() routines, and removes a
+ * graph object from the mdev object lists.
+ */
+void graph_obj_remove(struct media_graph_obj *gobj)
+{
+	list_del(&gobj->list);
+}
+
+/**
  * media_entity_init - Initialize a media entity
  *
  * @num_pads: Total number of sink and source pads.
include/media/media-entity.h +8 -0
index 051aa3f8bbfe..738e1d5d25dc 100644
@@ -168,6 +168,14 @@ struct media_entity_graph {
 	int top;
 };
 
+#define gobj_to_entity(gobj) \
+		container_of(gobj, struct media_entity, graph_obj)
+
+void graph_obj_init(struct media_device *mdev,
+		    enum media_graph_type type,
+		    struct media_graph_obj *gobj);
+void graph_obj_remove(struct media_graph_obj *gobj);
+
 int media_entity_init(struct media_entity *entity, u16 num_pads,
 		struct media_pad *pads, u16 extra_links);
 void media_entity_cleanup(struct media_entity *entity);
Signature · 1 line
2.4.3
#7 lore raw

RFC PATCH v3 4/16 media: ensure that entities will have an object ID

In reply to Mauro Carvalho Chehab

All objects need an object ID. However, as v4l2 subdevs embeed entities internally, the code needs to manually check if the entity objects were not properly initialized and do it at entity register time.

drivers/media/media-device.c +8 -0
index e627b0b905ad..960a4e30c68d 100644
@@ -435,6 +435,13 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 	entity->parent = mdev;
 
 	spin_lock(&mdev->lock);
+	/* Initialize media_graph_obj embedded at the entity */
+	graph_obj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
+
+	/*
+	 * FIXME: should it use the unique object ID or would it
+	 * break support on the legacy MC API?
+	 */
 	if (entity->id == 0)
 		entity->id = mdev->entity_id++;
 	else
@@ -461,6 +468,7 @@ void media_device_unregister_entity(struct media_entity *entity)
 		return;
 
 	spin_lock(&mdev->lock);
+	graph_obj_remove(&entity->graph_obj);
 	list_del(&entity->list);
 	spin_unlock(&mdev->lock);
 	entity->parent = NULL;
Signature · 1 line
2.4.3
#8 lore raw

RFC PATCH v3 5/16 media: initialize PAD objects

In reply to Mauro Carvalho Chehab

PAD embedded objects also need to be initialized. Those are currently created via media_entity_init() and, once created, never change.

While this will likely change in the future, for now we can just initialize those objects once, when registering the entity.

drivers/media/media-device.c +10 -0
index 960a4e30c68d..56724f7853bf 100644
@@ -430,6 +430,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
 int __must_check media_device_register_entity(struct media_device *mdev,
 					      struct media_entity *entity)
 {
+	int i;
+
 	/* Warn if we apparently re-register an entity */
 	WARN_ON(entity->parent != NULL);
 	entity->parent = mdev;
@@ -438,6 +440,11 @@ int __must_check media_device_register_entity(struct media_device *mdev,
 	/* Initialize media_graph_obj embedded at the entity */
 	graph_obj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
 
+	/* Initialize objects at the pads */
+	for (i = 0; entity->num_pads; i++)
+		graph_obj_init(mdev, MEDIA_GRAPH_PAD,
+			       &entity->pads[i].graph_obj);
+
 	/*
 	 * FIXME: should it use the unique object ID or would it
 	 * break support on the legacy MC API?
@@ -462,6 +469,7 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);
  */
 void media_device_unregister_entity(struct media_entity *entity)
 {
+	int i;
 	struct media_device *mdev = entity->parent;
 
 	if (mdev == NULL)
@@ -469,6 +477,8 @@ void media_device_unregister_entity(struct media_entity *entity)
 
 	spin_lock(&mdev->lock);
 	graph_obj_remove(&entity->graph_obj);
+	for (i = 0; entity->num_pads; i++)
+		graph_obj_remove(&entity->pads[i].graph_obj);
 	list_del(&entity->list);
 	spin_unlock(&mdev->lock);
 	entity->parent = NULL;
Signature · 1 line
2.4.3
#9 lore raw

RFC PATCH v3 6/16 media: initialize the graph object inside the media links

In reply to Mauro Carvalho Chehab

When a new link is created, we need to initialize the object inside it.

drivers/media/media-device.c +2 -0
index 56724f7853bf..9fb3f8958265 100644
@@ -479,6 +479,8 @@ void media_device_unregister_entity(struct media_entity *entity)
 	graph_obj_remove(&entity->graph_obj);
 	for (i = 0; entity->num_pads; i++)
 		graph_obj_remove(&entity->pads[i].graph_obj);
+	for (i = 0; entity->num_links; i++)
+		graph_obj_remove(&entity->links[i].graph_obj);
 	list_del(&entity->list);
 	spin_unlock(&mdev->lock);
 	entity->parent = NULL;
drivers/media/media-entity.c +4 -0
index 19ad316f2f33..6985d5c53632 100644
@@ -469,6 +469,10 @@ static struct media_link *media_entity_add_link(struct media_entity *entity)
 		entity->links = links;
 	}
 
+	/* Initialize graph object embedded at the new link */
+	graph_obj_init(entity->parent, MEDIA_GRAPH_LINK,
+			&entity->links[entity->num_links].graph_obj);
+
 	return &entity->links[entity->num_links++];
 }
 
Signature · 1 line
2.4.3
#10 lore raw

RFC PATCH v3 7/16 media: get rid of unused "extra_links" param on media_entity_init()

In reply to Mauro Carvalho Chehab

Currently, media_entity_init() creates an array with the links, allocated at init time. It provides a parameter (extra_links) that would allocate more links than the current needs, but this is not used by any driver.

As we want to be able to do dynamic link allocation/removal, we'll need to change the implementation of the links. So, before doing that, let's first remove that extra unused parameter, in order to cleanup the interface first.

Documentation/media-framework.txt +1 -1
index f552a75c0e70..2cc6019f7147 100644
@@ -104,7 +104,7 @@ although drivers can allocate entities directly.
 Drivers initialize entities by calling
 
 	media_entity_init(struct media_entity *entity, u16 num_pads,
-			  struct media_pad *pads, u16 extra_links);
+			  struct media_pad *pads);
 
 The media_entity name, type, flags, revision and group_id fields can be
 initialized before or after calling media_entity_init. Entities embedded in
Documentation/video4linux/v4l2-framework.txt +2 -2
index 75d5c18d689a..109cc3792534 100644
@@ -300,7 +300,7 @@ calling media_entity_init():
 	struct media_pad *pads = &my_sd->pads;
 	int err;
 
-	err = media_entity_init(&sd->entity, npads, pads, 0);
+	err = media_entity_init(&sd->entity, npads, pads);
 
 The pads array must have been previously initialized. There is no need to
 manually set the struct media_entity type and name fields, but the revision
@@ -700,7 +700,7 @@ calling media_entity_init():
 	struct media_pad *pad = &my_vdev->pad;
 	int err;
 
-	err = media_entity_init(&vdev->entity, 1, pad, 0);
+	err = media_entity_init(&vdev->entity, 1, pad);
 
 The pads array must have been previously initialized. There is no need to
 manually set the struct media_entity type and name fields.
Documentation/zh_CN/video4linux/v4l2-framework.txt +2 -2
index 2b828e631e31..ff815cb92031 100644
@@ -295,7 +295,7 @@ owner ??????????????? i2c ?????????????????????????????????????????????
 	struct media_pad *pads = &my_sd->pads;
 	int err;
 
-	err = media_entity_init(&sd->entity, npads, pads, 0);
+	err = media_entity_init(&sd->entity, npads, pads);
 
 pads ???????????????????????????????????????????????? media_entity ??? type ???
 name ????????????????????????revision ?????????????????????
@@ -602,7 +602,7 @@ v4l2_file_operations ???????????? file_operations ???????????????????????????
 	struct media_pad *pad = &my_vdev->pad;
 	int err;
 
-	err = media_entity_init(&vdev->entity, 1, pad, 0);
+	err = media_entity_init(&vdev->entity, 1, pad);
 
 pads ?????????????????????????????????????????????????????? media_entity ??? type ???
 name ??????
drivers/media/dvb-core/dvbdev.c +1 -1
index 13bb57f0457f..2fdcbb5f000a 100644
@@ -249,7 +249,7 @@ static void dvb_register_media_device(struct dvb_device *dvbdev,
 	}
 
 	if (npads)
-		ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads, 0);
+		ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads);
 	if (!ret)
 		ret = media_device_register_entity(dvbdev->adapter->mdev,
 						   dvbdev->entity);
drivers/media/i2c/ad9389b.c +1 -1
index 69094ab047b1..39d6ee681aeb 100644
@@ -1158,7 +1158,7 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id *
 	state->rgb_quantization_range_ctrl->is_private = true;
 
 	state->pad.flags = MEDIA_PAD_FL_SINK;
-	err = media_entity_init(&sd->entity, 1, &state->pad, 0);
+	err = media_entity_init(&sd->entity, 1, &state->pad);
 	if (err)
 		goto err_hdl;
 
drivers/media/i2c/adp1653.c +1 -1
index c70ababce954..5f76997f6e07 100644
@@ -512,7 +512,7 @@ static int adp1653_probe(struct i2c_client *client,
 	if (ret)
 		goto free_and_quit;
 
-	ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0);
+	ret = media_entity_init(&flash->subdev.entity, 0, NULL);
 	if (ret < 0)
 		goto free_and_quit;
 
drivers/media/i2c/adv7180.c +1 -1
index 09a96df170d1..cd15336260a3 100644
@@ -1214,7 +1214,7 @@ static int adv7180_probe(struct i2c_client *client,
 
 	state->pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
-	ret = media_entity_init(&sd->entity, 1, &state->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &state->pad);
 	if (ret)
 		goto err_free_ctrl;
 
drivers/media/i2c/adv7511.c +1 -1
index 95bcd4026451..e70aa56a0b11 100644
@@ -1482,7 +1482,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id *
 	state->rgb_quantization_range_ctrl->is_private = true;
 
 	state->pad.flags = MEDIA_PAD_FL_SINK;
-	err = media_entity_init(&sd->entity, 1, &state->pad, 0);
+	err = media_entity_init(&sd->entity, 1, &state->pad);
 	if (err)
 		goto err_hdl;
 
drivers/media/i2c/adv7604.c +1 -1
index bfb0b6a72bbc..dcefa810c8ac 100644
@@ -3198,7 +3198,7 @@ static int adv76xx_probe(struct i2c_client *client,
 	state->pads[state->source_pad].flags = MEDIA_PAD_FL_SOURCE;
 
 	err = media_entity_init(&sd->entity, state->source_pad + 1,
-				state->pads, 0);
+				state->pads);
 	if (err)
 		goto err_work_queues;
 
drivers/media/i2c/adv7842.c +1 -1
index 897d68c78b06..8a1ecc6ab36c 100644
@@ -3309,7 +3309,7 @@ static int adv7842_probe(struct i2c_client *client,
 			adv7842_delayed_work_enable_hotplug);
 
 	state->pad.flags = MEDIA_PAD_FL_SOURCE;
-	err = media_entity_init(&sd->entity, 1, &state->pad, 0);
+	err = media_entity_init(&sd->entity, 1, &state->pad);
 	if (err)
 		goto err_work_queues;
 
drivers/media/i2c/as3645a.c +1 -1
index 301084b07887..9d579a836f79 100644
@@ -827,7 +827,7 @@ static int as3645a_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto done;
 
-	ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0);
+	ret = media_entity_init(&flash->subdev.entity, 0, NULL);
 	if (ret < 0)
 		goto done;
 
drivers/media/i2c/cx25840/cx25840-core.c +1 -1
index e15a789ad596..7a2cf352d9c5 100644
@@ -5211,7 +5211,7 @@ static int cx25840_probe(struct i2c_client *client,
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
 	ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
-				state->pads, 0);
+				state->pads);
 	if (ret < 0) {
 		v4l_info(client, "failed to initialize media entity!\n");
 		return ret;
drivers/media/i2c/lm3560.c +1 -1
index d9ece4b2d047..9bd9def0852c 100644
@@ -365,7 +365,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash,
 	rval = lm3560_init_controls(flash, led_no);
 	if (rval)
 		goto err_out;
-	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL, 0);
+	rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
 	flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
drivers/media/i2c/lm3646.c +1 -1
index 626fb4679c02..4160e18af607 100644
@@ -282,7 +282,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash)
 	rval = lm3646_init_controls(flash);
 	if (rval)
 		goto err_out;
-	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL, 0);
+	rval = media_entity_init(&flash->subdev_led.entity, 0, NULL);
 	if (rval < 0)
 		goto err_out;
 	flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
drivers/media/i2c/m5mols/m5mols_core.c +1 -1
index 6404c0d93e7a..f718a1009e4c 100644
@@ -975,7 +975,7 @@ static int m5mols_probe(struct i2c_client *client,
 
 	sd->internal_ops = &m5mols_subdev_internal_ops;
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_init(&sd->entity, 1, &info->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		return ret;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
drivers/media/i2c/mt9m032.c +1 -1
index c7747bd0cabb..1493ab6e7fb3 100644
@@ -799,7 +799,7 @@ static int mt9m032_probe(struct i2c_client *client,
 
 	sensor->subdev.ctrl_handler = &sensor->ctrls;
 	sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_init(&sensor->subdev.entity, 1, &sensor->pad, 0);
+	ret = media_entity_init(&sensor->subdev.entity, 1, &sensor->pad);
 	if (ret < 0)
 		goto error_ctrl;
 
drivers/media/i2c/mt9p031.c +1 -1
index 0db15f528ac1..e3c5af82b7c1 100644
@@ -1112,7 +1112,7 @@ static int mt9p031_probe(struct i2c_client *client,
 	mt9p031->subdev.internal_ops = &mt9p031_subdev_internal_ops;
 
 	mt9p031->pad.flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_init(&mt9p031->subdev.entity, 1, &mt9p031->pad, 0);
+	ret = media_entity_init(&mt9p031->subdev.entity, 1, &mt9p031->pad);
 	if (ret < 0)
 		goto done;
 
drivers/media/i2c/mt9t001.c +1 -1
index 8ae99f7f254c..1dae1a98bc85 100644
@@ -933,7 +933,7 @@ static int mt9t001_probe(struct i2c_client *client,
 	mt9t001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	mt9t001->pad.flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_init(&mt9t001->subdev.entity, 1, &mt9t001->pad, 0);
+	ret = media_entity_init(&mt9t001->subdev.entity, 1, &mt9t001->pad);
 
 done:
 	if (ret < 0) {
drivers/media/i2c/mt9v032.c +1 -1
index 977f4006edbd..980011aa039d 100644
@@ -1046,7 +1046,7 @@ static int mt9v032_probe(struct i2c_client *client,
 	mt9v032->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0);
+	ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad);
 	if (ret < 0)
 		goto err;
 
drivers/media/i2c/noon010pc30.c +1 -1
index f197b6cbd407..a9761251b970 100644
@@ -780,7 +780,7 @@ static int noon010_probe(struct i2c_client *client,
 
 	info->pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-	ret = media_entity_init(&sd->entity, 1, &info->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &info->pad);
 	if (ret < 0)
 		goto np_err;
 
drivers/media/i2c/ov2659.c +1 -1
index 6edffc7b74e3..39f2d2cfdc9c 100644
@@ -1450,7 +1450,7 @@ static int ov2659_probe(struct i2c_client *client,
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	ov2659->pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-	ret = media_entity_init(&sd->entity, 1, &ov2659->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &ov2659->pad);
 	if (ret < 0) {
 		v4l2_ctrl_handler_free(&ov2659->ctrls);
 		return ret;
drivers/media/i2c/ov9650.c +1 -1
index 2bc473385c91..6a6747343512 100644
@@ -1501,7 +1501,7 @@ static int ov965x_probe(struct i2c_client *client,
 
 	ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-	ret = media_entity_init(&sd->entity, 1, &ov965x->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &ov965x->pad);
 	if (ret < 0)
 		return ret;
 
drivers/media/i2c/s5c73m3/s5c73m3-core.c +2 -2
index 53c5ea89f0b9..6d167428727d 100644
@@ -1691,7 +1691,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
 
 	ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS,
-							state->sensor_pads, 0);
+							state->sensor_pads);
 	if (ret < 0)
 		return ret;
 
@@ -1707,7 +1707,7 @@ static int s5c73m3_probe(struct i2c_client *client,
 	oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
 
 	ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS,
-							state->oif_pads, 0);
+							state->oif_pads);
 	if (ret < 0)
 		return ret;
 
drivers/media/i2c/s5k4ecgx.c +1 -1
index 97084237275d..d207ddce31b6 100644
@@ -962,7 +962,7 @@ static int s5k4ecgx_probe(struct i2c_client *client,
 
 	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-	ret = media_entity_init(&sd->entity, 1, &priv->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &priv->pad);
 	if (ret)
 		return ret;
 
drivers/media/i2c/s5k5baf.c +2 -2
index 774e0d0c94cb..30a9ca62e034 100644
@@ -1905,7 +1905,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 
 	state->cis_pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad, 0);
+	ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad);
 	if (ret < 0)
 		goto err;
 
@@ -1920,7 +1920,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state,
 	state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK;
 	state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads, 0);
+	ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads);
 
 	if (!ret)
 		return 0;
drivers/media/i2c/s5k6a3.c +1 -1
index bc389d5e42ae..617a065bde6f 100644
@@ -333,7 +333,7 @@ static int s5k6a3_probe(struct i2c_client *client,
 	sensor->format.height = S5K6A3_DEFAULT_HEIGHT;
 
 	sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
-	ret = media_entity_init(&sd->entity, 1, &sensor->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &sensor->pad);
 	if (ret < 0)
 		return ret;
 
drivers/media/i2c/s5k6aa.c +1 -1
index d0ad6a25bdab..39a461f9d9bb 100644
@@ -1578,7 +1578,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 
 	s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE;
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad, 0);
+	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad);
 	if (ret)
 		return ret;
 
drivers/media/i2c/smiapp/smiapp-core.c +2 -2
index 636ebd6fe5dc..308613ea0aed 100644
@@ -2488,7 +2488,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
 			continue;
 
 		rval = media_entity_init(&this->sd.entity,
-					 this->npads, this->pads, 0);
+					 this->npads, this->pads);
 		if (rval) {
 			dev_err(&client->dev,
 				"media_entity_init failed\n");
@@ -3078,7 +3078,7 @@ static int smiapp_probe(struct i2c_client *client,
 
 	sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE;
 	rval = media_entity_init(&sensor->src->sd.entity, 2,
-				 sensor->src->pads, 0);
+				 sensor->src->pads);
 	if (rval < 0)
 		return rval;
 
drivers/media/i2c/tc358743.c +1 -1
index d0dd83d7a38e..39f47044af24 100644
@@ -1880,7 +1880,7 @@ static int tc358743_probe(struct i2c_client *client,
 	}
 
 	state->pad.flags = MEDIA_PAD_FL_SOURCE;
-	err = media_entity_init(&sd->entity, 1, &state->pad, 0);
+	err = media_entity_init(&sd->entity, 1, &state->pad);
 	if (err < 0)
 		goto err_hdl;
 
drivers/media/i2c/tvp514x.c +1 -1
index a93985a9b070..11801636d901 100644
@@ -1097,7 +1097,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	decoder->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	decoder->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
-	ret = media_entity_init(&decoder->sd.entity, 1, &decoder->pad, 0);
+	ret = media_entity_init(&decoder->sd.entity, 1, &decoder->pad);
 	if (ret < 0) {
 		v4l2_err(sd, "%s decoder driver failed to register !!\n",
 			 sd->name);
drivers/media/i2c/tvp7002.c +1 -1
index f617d8b745ee..3630f3e2a4c7 100644
@@ -1014,7 +1014,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id)
 	device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	device->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
-	error = media_entity_init(&device->sd.entity, 1, &device->pad, 0);
+	error = media_entity_init(&device->sd.entity, 1, &device->pad);
 	if (error < 0)
 		return error;
 #endif
drivers/media/media-entity.c +2 -3
index 6985d5c53632..e8451a4a403b 100644
@@ -68,7 +68,6 @@ void graph_obj_remove(struct media_graph_obj *gobj)
  * media_entity_init - Initialize a media entity
  *
  * @num_pads: Total number of sink and source pads.
- * @extra_links: Initial estimate of the number of extra links.
  * @pads: Array of 'num_pads' pads.
  *
  * The total number of pads is an intrinsic property of entities known by the
@@ -90,10 +89,10 @@ void graph_obj_remove(struct media_graph_obj *gobj)
  */
 int
 media_entity_init(struct media_entity *entity, u16 num_pads,
-		  struct media_pad *pads, u16 extra_links)
+		  struct media_pad *pads)
 {
 	struct media_link *links;
-	unsigned int max_links = num_pads + extra_links;
+	unsigned int max_links = num_pads;
 	unsigned int i;
 
 	links = kzalloc(max_links * sizeof(links[0]), GFP_KERNEL);
drivers/media/platform/exynos4-is/fimc-capture.c +2 -2
index cfebf292e15a..0627a93b2f3b 100644
@@ -1804,7 +1804,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
 	vid_cap->wb_fmt.code = fmt->mbus_code;
 
 	vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0);
+	ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad);
 	if (ret)
 		goto err_free_ctx;
 
@@ -1897,7 +1897,7 @@ int fimc_initialize_capture_subdev(struct fimc_dev *fimc)
 	fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_FIFO].flags = MEDIA_PAD_FL_SINK;
 	fimc->vid_cap.sd_pads[FIMC_SD_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_init(&sd->entity, FIMC_SD_PADS_NUM,
-				fimc->vid_cap.sd_pads, 0);
+				fimc->vid_cap.sd_pads);
 	if (ret)
 		return ret;
 
drivers/media/platform/exynos4-is/fimc-isp-video.c +1 -1
index 76b6b4d14616..b7dc5ac66e36 100644
@@ -618,7 +618,7 @@ int fimc_isp_video_device_register(struct fimc_isp *isp,
 	vdev->lock = &isp->video_lock;
 
 	iv->pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&vdev->entity, 1, &iv->pad, 0);
+	ret = media_entity_init(&vdev->entity, 1, &iv->pad);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/exynos4-is/fimc-isp.c +1 -1
index 5d78f5716f3b..f52eebf765c1 100644
@@ -709,7 +709,7 @@ int fimc_isp_subdev_create(struct fimc_isp *isp)
 	isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_FIFO].flags = MEDIA_PAD_FL_SOURCE;
 	isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_DMA].flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_init(&sd->entity, FIMC_ISP_SD_PADS_NUM,
-				isp->subdev_pads, 0);
+				isp->subdev_pads);
 	if (ret)
 		return ret;
 
drivers/media/platform/exynos4-is/fimc-lite.c +2 -2
index ca6261a86a5f..e8f707d1729b 100644
@@ -1322,7 +1322,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
 		return ret;
 
 	fimc->vd_pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0);
+	ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad);
 	if (ret < 0)
 		return ret;
 
@@ -1437,7 +1437,7 @@ static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc)
 	fimc->subdev_pads[FLITE_SD_PAD_SOURCE_DMA].flags = MEDIA_PAD_FL_SOURCE;
 	fimc->subdev_pads[FLITE_SD_PAD_SOURCE_ISP].flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_init(&sd->entity, FLITE_SD_PADS_NUM,
-				fimc->subdev_pads, 0);
+				fimc->subdev_pads);
 	if (ret)
 		return ret;
 
drivers/media/platform/exynos4-is/fimc-m2m.c +1 -1
index 0ad1b6f84a27..b57daec48b21 100644
@@ -738,7 +738,7 @@ int fimc_register_m2m_device(struct fimc_dev *fimc,
 		return PTR_ERR(fimc->m2m.m2m_dev);
 	}
 
-	ret = media_entity_init(&vfd->entity, 0, NULL, 0);
+	ret = media_entity_init(&vfd->entity, 0, NULL);
 	if (ret)
 		goto err_me;
 
drivers/media/platform/exynos4-is/mipi-csis.c +1 -1
index d74e1bec3d86..cf10cd783a86 100644
@@ -866,7 +866,7 @@ static int s5pcsis_probe(struct platform_device *pdev)
 	state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
 	state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_init(&state->sd.entity,
-				CSIS_PADS_NUM, state->pads, 0);
+				CSIS_PADS_NUM, state->pads);
 	if (ret < 0)
 		goto e_clkdis;
 
drivers/media/platform/omap3isp/ispccdc.c +1 -1
index a6a61cce43dd..3b10304b580b 100644
@@ -2650,7 +2650,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc)
 	pads[CCDC_PAD_SOURCE_OF].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &ccdc_media_ops;
-	ret = media_entity_init(me, CCDC_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, CCDC_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/omap3isp/ispccp2.c +1 -1
index 38e6a974c5b1..e1b5f5bea541 100644
@@ -1071,7 +1071,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2)
 	pads[CCP2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &ccp2_media_ops;
-	ret = media_entity_init(me, CCP2_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, CCP2_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
index a78338d012b4..6fff92f0813a 100644
@@ -1245,7 +1245,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2)
 				    | MEDIA_PAD_FL_MUST_CONNECT;
 
 	me->ops = &csi2_media_ops;
-	ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, CSI2_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/omap3isp/isppreview.c +1 -1
index 13803270d104..b440c6342ca4 100644
@@ -2282,7 +2282,7 @@ static int preview_init_entities(struct isp_prev_device *prev)
 	pads[PREV_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &preview_media_ops;
-	ret = media_entity_init(me, PREV_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, PREV_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/omap3isp/ispresizer.c +1 -1
index 7cfb43dc0ffd..3deb1ec4a973 100644
@@ -1728,7 +1728,7 @@ static int resizer_init_entities(struct isp_res_device *res)
 	pads[RESZ_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &resizer_media_ops;
-	ret = media_entity_init(me, RESZ_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, RESZ_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/omap3isp/ispstat.c +1 -1
index 20434e83e801..92a31dd28ace 100644
@@ -1029,7 +1029,7 @@ static int isp_stat_init_entities(struct ispstat *stat, const char *name,
 	stat->pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT;
 	me->ops = NULL;
 
-	return media_entity_init(me, 1, &stat->pad, 0);
+	return media_entity_init(me, 1, &stat->pad);
 }
 
 int omap3isp_stat_init(struct ispstat *stat, const char *name,
drivers/media/platform/omap3isp/ispvideo.c +1 -1
index d285af18df7f..1809e52d2df9 100644
@@ -1368,7 +1368,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name)
 	if (IS_ERR(video->alloc_ctx))
 		return PTR_ERR(video->alloc_ctx);
 
-	ret = media_entity_init(&video->video.entity, 1, &video->pad, 0);
+	ret = media_entity_init(&video->video.entity, 1, &video->pad);
 	if (ret < 0) {
 		vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
 		return ret;
drivers/media/platform/s3c-camif/camif-capture.c +2 -2
index 76e6289a5612..eae667eab1b9 100644
@@ -1159,7 +1159,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
 		goto err_vd_rel;
 
 	vp->pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&vfd->entity, 1, &vp->pad, 0);
+	ret = media_entity_init(&vfd->entity, 1, &vp->pad);
 	if (ret)
 		goto err_vd_rel;
 
@@ -1575,7 +1575,7 @@ int s3c_camif_create_subdev(struct camif_dev *camif)
 	camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE;
 
 	ret = media_entity_init(&sd->entity, CAMIF_SD_PADS_NUM,
-				camif->pads, 0);
+				camif->pads);
 	if (ret)
 		return ret;
 
drivers/media/platform/vsp1/vsp1_entity.c +1 -1
index fd95a75b04f4..619942ff2058 100644
@@ -220,7 +220,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
 
 	/* Initialize the media entity. */
 	return media_entity_init(&entity->subdev.entity, num_pads,
-				 entity->pads, 0);
+				 entity->pads);
 }
 
 void vsp1_entity_destroy(struct vsp1_entity *entity)
drivers/media/platform/vsp1/vsp1_video.c +1 -1
index 3c124c14ce14..17f08973f835 100644
@@ -1221,7 +1221,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
 	video->pipe.state = VSP1_PIPELINE_STOPPED;
 
 	/* Initialize the media entity... */
-	ret = media_entity_init(&video->video.entity, 1, &video->pad, 0);
+	ret = media_entity_init(&video->video.entity, 1, &video->pad);
 	if (ret < 0)
 		return ret;
 
drivers/media/platform/xilinx/xilinx-dma.c +1 -1
index e779c93cb015..f7f9aa353a55 100644
@@ -676,7 +676,7 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
 	dma->pad.flags = type == V4L2_BUF_TYPE_VIDEO_CAPTURE
 		       ? MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE;
 
-	ret = media_entity_init(&dma->video.entity, 1, &dma->pad, 0);
+	ret = media_entity_init(&dma->video.entity, 1, &dma->pad);
 	if (ret < 0)
 		goto error;
 
drivers/media/platform/xilinx/xilinx-tpg.c +1 -1
index b5f7d5ecb7f6..285976aa0f4d 100644
@@ -836,7 +836,7 @@ static int xtpg_probe(struct platform_device *pdev)
 	subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	subdev->entity.ops = &xtpg_media_ops;
 
-	ret = media_entity_init(&subdev->entity, xtpg->npads, xtpg->pads, 0);
+	ret = media_entity_init(&subdev->entity, xtpg->npads, xtpg->pads);
 	if (ret < 0)
 		goto error;
 
drivers/media/usb/cx231xx/cx231xx-video.c +2 -2
index c6ff8968286a..8f04b125486f 100644
@@ -2175,7 +2175,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
 	cx231xx_vdev_init(dev, &dev->vdev, &cx231xx_video_template, "video");
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	dev->video_pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad, 0);
+	ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad);
 	if (ret < 0)
 		dev_err(dev->dev, "failed to initialize video media entity!\n");
 #endif
@@ -2202,7 +2202,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
-	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad, 0);
+	ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad);
 	if (ret < 0)
 		dev_err(dev->dev, "failed to initialize vbi media entity!\n");
 #endif
drivers/media/usb/uvc/uvc_entity.c +2 -2
index dc56a59ecadc..245445491516 100644
@@ -89,10 +89,10 @@ static int uvc_mc_init_entity(struct uvc_entity *entity)
 			sizeof(entity->subdev.name));
 
 		ret = media_entity_init(&entity->subdev.entity,
-					entity->num_pads, entity->pads, 0);
+					entity->num_pads, entity->pads);
 	} else if (entity->vdev != NULL) {
 		ret = media_entity_init(&entity->vdev->entity,
-					entity->num_pads, entity->pads, 0);
+					entity->num_pads, entity->pads);
 		if (entity->flags & UVC_ENTITY_FLAG_DEFAULT)
 			entity->vdev->entity.flags |= MEDIA_ENT_FL_DEFAULT;
 	} else
drivers/media/v4l2-core/tuner-core.c +1 -1
index abdcffabcb59..0ccf9a903e1e 100644
@@ -699,7 +699,7 @@ register_client:
 	t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
 	t->sd.entity.name = t->name;
 
-	ret = media_entity_init(&t->sd.entity, 1, &t->pad, 0);
+	ret = media_entity_init(&t->sd.entity, 1, &t->pad);
 	if (ret < 0) {
 		tuner_err("failed to initialize media entity!\n");
 		kfree(t);
drivers/media/v4l2-core/v4l2-flash-led-class.c +1 -1
index 5bdfb8d5263a..34c489fed55e 100644
@@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init(
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	strlcpy(sd->name, config->dev_name, sizeof(sd->name));
 
-	ret = media_entity_init(&sd->entity, 0, NULL, 0);
+	ret = media_entity_init(&sd->entity, 0, NULL);
 	if (ret < 0)
 		return ERR_PTR(ret);
 
drivers/staging/media/davinci_vpfe/dm365_ipipe.c +1 -1
index 1bbb90ce0086..b89a057b8b7e 100644
@@ -1839,7 +1839,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)
 	v4l2_ctrl_handler_setup(&ipipe->ctrls);
 	sd->ctrl_handler = &ipipe->ctrls;
 
-	return media_entity_init(me, IPIPE_PADS_NUM, pads, 0);
+	return media_entity_init(me, IPIPE_PADS_NUM, pads);
 }
 
 /*
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +1 -1
index 8b230541b1d1..8fb676186898 100644
@@ -1026,7 +1026,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif,
 	ipipeif->output = IPIPEIF_OUTPUT_NONE;
 	me->ops = &ipipeif_media_ops;
 
-	ret = media_entity_init(me, IPIPEIF_NUM_PADS, pads, 0);
+	ret = media_entity_init(me, IPIPEIF_NUM_PADS, pads);
 	if (ret)
 		goto fail;
 
drivers/staging/media/davinci_vpfe/dm365_isif.c +1 -1
index 80907b464412..b1f01adfa7c8 100644
@@ -2052,7 +2052,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev)
 	isif->input = ISIF_INPUT_NONE;
 	isif->output = ISIF_OUTPUT_NONE;
 	me->ops = &isif_media_ops;
-	status = media_entity_init(me, ISIF_PADS_NUM, pads, 0);
+	status = media_entity_init(me, ISIF_PADS_NUM, pads);
 	if (status)
 		goto isif_fail;
 	isif->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
drivers/staging/media/davinci_vpfe/dm365_resizer.c +3 -3
index acb293ed9c91..692789aa22f4 100644
@@ -1915,7 +1915,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
 	vpfe_rsz->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE;
 	vpfe_rsz->crop_resizer.rsz_device = vpfe_rsz;
 	me->ops = &resizer_media_ops;
-	ret = media_entity_init(me, RESIZER_CROP_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, RESIZER_CROP_PADS_NUM, pads);
 	if (ret)
 		return ret;
 
@@ -1937,7 +1937,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
 	vpfe_rsz->resizer_a.output = RESIZER_OUTPUT_NONE;
 	vpfe_rsz->resizer_a.rsz_device = vpfe_rsz;
 	me->ops = &resizer_media_ops;
-	ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, RESIZER_PADS_NUM, pads);
 	if (ret)
 		return ret;
 
@@ -1959,7 +1959,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
 	vpfe_rsz->resizer_b.output = RESIZER_OUTPUT_NONE;
 	vpfe_rsz->resizer_b.rsz_device = vpfe_rsz;
 	me->ops = &resizer_media_ops;
-	ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, RESIZER_PADS_NUM, pads);
 	if (ret)
 		return ret;
 
drivers/staging/media/davinci_vpfe/vpfe_video.c +1 -1
index 87048a14c34d..61a8d5beff58 100644
@@ -1594,7 +1594,7 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name)
 	spin_lock_init(&video->dma_queue_lock);
 	mutex_init(&video->lock);
 	ret = media_entity_init(&video->video_dev.entity,
-				1, &video->pad, 0);
+				1, &video->pad);
 	if (ret < 0)
 		return ret;
 
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
index bc83f8246101..e936cfc218cb 100644
@@ -1271,7 +1271,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
 	pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
 
 	me->ops = &csi2_media_ops;
-	ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, CSI2_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/staging/media/omap4iss/iss_ipipe.c +1 -1
index f94a59299a83..e1a7b7ba7362 100644
@@ -513,7 +513,7 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe)
 	pads[IPIPE_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &ipipe_media_ops;
-	ret = media_entity_init(me, IPIPE_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, IPIPE_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/staging/media/omap4iss/iss_ipipeif.c +1 -1
index c0da13d55865..be5f80d7b5dc 100644
@@ -743,7 +743,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif)
 	pads[IPIPEIF_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &ipipeif_media_ops;
-	ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/staging/media/omap4iss/iss_resizer.c +1 -1
index 5030cf3cd34c..91e724085dba 100644
@@ -787,7 +787,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer)
 	pads[RESIZER_PAD_SOURCE_MEM].flags = MEDIA_PAD_FL_SOURCE;
 
 	me->ops = &resizer_media_ops;
-	ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0);
+	ret = media_entity_init(me, RESIZER_PADS_NUM, pads);
 	if (ret < 0)
 		return ret;
 
drivers/staging/media/omap4iss/iss_video.c +1 -1
index 40405d8710a6..bae67742706f 100644
@@ -1104,7 +1104,7 @@ int omap4iss_video_init(struct iss_video *video, const char *name)
 		return -EINVAL;
 	}
 
-	ret = media_entity_init(&video->video.entity, 1, &video->pad, 0);
+	ret = media_entity_init(&video->video.entity, 1, &video->pad);
 	if (ret < 0)
 		return ret;
 
include/media/media-entity.h +1 -1
index 738e1d5d25dc..be6885e7c8ed 100644
@@ -177,7 +177,7 @@ void graph_obj_init(struct media_device *mdev,
 void graph_obj_remove(struct media_graph_obj *gobj);
 
 int media_entity_init(struct media_entity *entity, u16 num_pads,
-		struct media_pad *pads, u16 extra_links);
+		struct media_pad *pads);
 void media_entity_cleanup(struct media_entity *entity);
 
 int media_entity_create_link(struct media_entity *source, u16 source_pad,
Signature · 1 line
2.4.3
maintainer
#11 lore raw

RFC PATCH v3 7/16 media: get rid of unused "extra_links" param on media_entity_init()

Hi Mauro,

Quoted 12 lines · Mauro Carvalho Chehab

Currently, media_entity_init() creates an array with the links, allocated at init time. It provides a parameter (extra_links) that would allocate more links than the current needs, but this is not used by any driver.

As we want to be able to do dynamic link allocation/removal, we'll need to change the implementation of the links. So, before doing that, let's first remove that extra unused parameter, in order to cleanup the interface first.

...

include/media/media-entity.h void graph_obj_init(struct media_device *mdev, · line 183

Quoted 13 lines
include/media/media-entity.h +1 -1
index 738e1d5d25dc..be6885e7c8ed 100644
@@ -177,7 +177,7 @@ void graph_obj_init(struct media_device *mdev,
 void graph_obj_remove(struct media_graph_obj *gobj);
 
 int media_entity_init(struct media_entity *entity, u16 num_pads,
-		struct media_pad *pads, u16 extra_links);
+		struct media_pad *pads);
 void media_entity_cleanup(struct media_entity *entity);
 
 int media_entity_create_link(struct media_entity *source, u16 source_pad,

How about putting this in front of the set? It has no dependencies to the other patches, does it?

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
#12 lore raw

RFC PATCH v3 7/16 media: get rid of unused "extra_links" param on media_entity_init()

Em Fri, 14 Aug 2015 13:33:48 +0300
Sakari Ailus <[email protected]> escreveu:

Quoted 30 lines

Hi Mauro,

Quoted 12 lines · Mauro Carvalho Chehab

Currently, media_entity_init() creates an array with the links, allocated at init time. It provides a parameter (extra_links) that would allocate more links than the current needs, but this is not used by any driver.

As we want to be able to do dynamic link allocation/removal, we'll need to change the implementation of the links. So, before doing that, let's first remove that extra unused parameter, in order to cleanup the interface first.

...

Quoted 12 lines
include/media/media-entity.h +1 -1
index 738e1d5d25dc..be6885e7c8ed 100644
@@ -177,7 +177,7 @@ void graph_obj_init(struct media_device *mdev,
 void graph_obj_remove(struct media_graph_obj *gobj);
 
 int media_entity_init(struct media_entity *entity, u16 num_pads,
-		struct media_pad *pads, u16 extra_links);
+		struct media_pad *pads);
 void media_entity_cleanup(struct media_entity *entity);
 
Quoted 4 lines

include/media/media-entity.h void graph_obj_init(struct media_device *mdev, · line 183

Quoted 1 line
include/media/media-entity.h +0 -0
 int media_entity_create_link(struct media_entity *source, u16 source_pad,

How about putting this in front of the set? It has no dependencies to the other patches, does it?

Yeah this patch can be the first one ;) It just cleans up something that we never used. It just needs to be before patch 8.

Quoted 3 lines
#13 lore raw

RFC PATCH v3 8/16 media: convert links from array to list

In reply to Mauro Carvalho Chehab

Using memory realloc to increase the size of an array is complex and makes harder to remove links. Also, by embedding the link inside an array at the entity makes harder to change the code to add interfaces, as interfaces will also need to use links.

So, convert the links from arrays to lists.

drivers/media/media-device.c +14 -9
index 9fb3f8958265..a95ca981aabb 100644
@@ -25,6 +25,7 @@
 #include <linux/ioctl.h>
 #include <linux/media.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 
 #include <media/media-device.h>
 #include <media/media-devnode.h>
@@ -148,22 +149,22 @@ static long __media_device_enum_links(struct media_device *mdev,
 	}
 
 	if (links->links) {
-		struct media_link_desc __user *ulink;
-		unsigned int l;
+		struct media_link *ent_link;
+		struct media_link_desc __user *ulink = links->links;
 
-		for (l = 0, ulink = links->links; l < entity->num_links; l++) {
+		list_for_each_entry(ent_link, &entity->links, list) {
 			struct media_link_desc link;
 
 			/* Ignore backlinks. */
-			if (entity->links[l].source->entity != entity)
+			if (ent_link->source->entity != entity)
 				continue;
 
 			memset(&link, 0, sizeof(link));
-			media_device_kpad_to_upad(entity->links[l].source,
+			media_device_kpad_to_upad(ent_link->source,
 						  &link.source);
-			media_device_kpad_to_upad(entity->links[l].sink,
+			media_device_kpad_to_upad(ent_link->sink,
 						  &link.sink);
-			link.flags = entity->links[l].flags;
+			link.flags = ent_link->flags;
 			if (copy_to_user(ulink, &link, sizeof(*ulink)))
 				return -EFAULT;
 			ulink++;
@@ -471,6 +472,7 @@ void media_device_unregister_entity(struct media_entity *entity)
 {
 	int i;
 	struct media_device *mdev = entity->parent;
+	struct media_link *link, *tmp;
 
 	if (mdev == NULL)
 		return;
@@ -479,8 +481,11 @@ void media_device_unregister_entity(struct media_entity *entity)
 	graph_obj_remove(&entity->graph_obj);
 	for (i = 0; entity->num_pads; i++)
 		graph_obj_remove(&entity->pads[i].graph_obj);
-	for (i = 0; entity->num_links; i++)
-		graph_obj_remove(&entity->links[i].graph_obj);
+	list_for_each_entry_safe(link, tmp, &entity->links, list) {
+		graph_obj_remove(&link->graph_obj);
+		list_del(&link->list);
+		kfree(link);
+	}
 	list_del(&entity->list);
 	spin_unlock(&mdev->lock);
 	entity->parent = NULL;
drivers/media/media-entity.c +65 -75

263 lines not on this page · raw message

drivers/media/usb/cx231xx/cx231xx-video.c +3 -5
index 8f04b125486f..e8baff4d6290 100644
@@ -106,7 +106,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	struct media_device *mdev = dev->media_dev;
 	struct media_entity  *entity, *decoder = NULL, *source;
 	struct media_link *link, *found_link = NULL;
-	int i, ret, active_links = 0;
+	int ret, active_links = 0;
 
 	if (!mdev)
 		return 0;
@@ -127,8 +127,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	if (!decoder)
 		return 0;
 
-	for (i = 0; i < decoder->num_links; i++) {
-		link = &decoder->links[i];
+	list_for_each_entry(link, &decoder->links, list) {
 		if (link->sink->entity == decoder) {
 			found_link = link;
 			if (link->flags & MEDIA_LNK_FL_ENABLED)
@@ -141,11 +140,10 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 		return 0;
 
 	source = found_link->source->entity;
-	for (i = 0; i < source->num_links; i++) {
+	list_for_each_entry(link, &source->links, list) {
 		struct media_entity *sink;
 		int flags = 0;
 
-		link = &source->links[i];
 		sink = link->sink->entity;
 
 		if (sink == entity)
include/media/media-entity.h +4 -4
index be6885e7c8ed..403019035424 100644
@@ -71,6 +71,7 @@ struct media_pipeline {
 };
 
 struct media_link {
+	struct list_head list;
 	struct media_graph_obj			graph_obj;
 	struct media_pad *source;	/* Source pad */
 	struct media_pad *sink;		/* Sink pad  */
@@ -117,10 +118,9 @@ struct media_entity {
 	u16 num_links;			/* Number of existing links, both
 					 * enabled and disabled */
 	u16 num_backlinks;		/* Number of backlinks */
-	u16 max_links;			/* Maximum number of links */
 
 	struct media_pad *pads;		/* Pads array (num_pads elements) */
-	struct media_link *links;	/* Links array (max_links elements)*/
+	struct list_head links;		/* Links list */
 
 	const struct media_entity_operations *ops;	/* Entity operations */
 
@@ -161,7 +161,7 @@ static inline u32 media_entity_subtype(struct media_entity *entity)
 struct media_entity_graph {
 	struct {
 		struct media_entity *entity;
-		int link;
+		struct list_head link;
 	} stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
 
 	DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
@@ -177,7 +177,7 @@ void graph_obj_init(struct media_device *mdev,
 void graph_obj_remove(struct media_graph_obj *gobj);
 
 int media_entity_init(struct media_entity *entity, u16 num_pads,
-		struct media_pad *pads);
+		      struct media_pad *pads);
 void media_entity_cleanup(struct media_entity *entity);
 
 int media_entity_create_link(struct media_entity *source, u16 source_pad,
Signature · 1 line
2.4.3
#14 lore raw

RFC PATCH v3 9/16 media: use media_graph_obj for link endpoints

In reply to Mauro Carvalho Chehab

As we'll need to create links between entities and interfaces, we need to identify the link endpoints by the media_graph_obj.

Please note that, while we're now using graph_obj to reference the link endpoints, we're still assuming that all endpoints are pads at the existing drivers. This is true for all existing links, so no problems are expected so far.

Yet, as we introduce links between entities and interfaces, we may need to change some existing code to work with links that aren't pad to pad.

drivers/media/dvb-core/dvb_frontend.c +4 -0
index 842b9c8f80c6..3c97ebdf9f2a 100644
@@ -635,6 +635,8 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
 
 	for (i = 0; i < entity->num_links; i++) {
 		link = &entity->links[i];
+		if (link->port1.type != MEDIA_GRAPH_PAD)
+			continue;
 		if (link->sink->entity == entity) {
 			found_link = link;
 			n_links++;
@@ -665,6 +667,8 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
 		int flags = 0;
 
 		link = &source->links[i];
+		if (link->port1.type != MEDIA_GRAPH_PAD)
+			continue;
 		sink = link->sink->entity;
 
 		if (sink == entity)
drivers/media/media-device.c +4 -0
index a95ca981aabb..b4bd718ad736 100644
@@ -155,6 +155,10 @@ static long __media_device_enum_links(struct media_device *mdev,
 		list_for_each_entry(ent_link, &entity->links, list) {
 			struct media_link_desc link;
 
+			/* Only PAD to PAD links should be enumerated with legacy API */
+			if (ent_link->port0->type != MEDIA_GRAPH_PAD ||
+			    ent_link->port1->type != MEDIA_GRAPH_PAD)
+				continue;
 			/* Ignore backlinks. */
 			if (ent_link->source->entity != entity)
 				continue;
drivers/media/media-entity.c +16 -2
index 333c49aa0974..fc2e4886c830 100644
@@ -121,6 +121,10 @@ EXPORT_SYMBOL_GPL(media_entity_cleanup);
 static struct media_entity *
 media_entity_other(struct media_entity *entity, struct media_link *link)
 {
+	/* For now, we only do graph traversal with PADs */
+	if (link->port0->type != MEDIA_GRAPH_PAD ||
+	    link->port1->type != MEDIA_GRAPH_PAD)
+		return NULL;
 	if (link->source->entity == entity)
 		return link->sink->entity;
 	else
@@ -217,6 +221,10 @@ 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 (!next) {
+			list_rotate_left(&link_top(graph));
+			continue;
+		}
 		if (WARN_ON(next->id >= MEDIA_ENTITY_ENUM_MAX_ID))
 			return NULL;
 
@@ -285,8 +293,14 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
 		bitmap_fill(has_no_links, entity->num_pads);
 
 		list_for_each_entry(link, &entity->links, list) {
-			struct media_pad *pad = link->sink->entity == entity
-						? link->sink : link->source;
+			struct media_pad *pad;
+
+			/* For now, ignore interface<->entity links */
+			if (link->port0->type != MEDIA_GRAPH_PAD)
+				continue;
+
+			pad = link->sink->entity == entity
+				? link->sink : link->source;
 
 			/* Mark that a pad is connected by a link. */
 			bitmap_clear(has_no_links, pad->index, 1);
include/media/media-entity.h +36 -5

77 lines not on this page · raw message

Signature · 1 line
2.4.3
#15 lore raw

RFC PATCH v3 10/16 media: rename link source/sink to pad0_source/pad1_sink

In reply to Mauro Carvalho Chehab

Change the internal namespace for links between two pads to have the "pad" there.

We're also numbering it, as a common constructor is to do things like:

if (link->port1.type != MEDIA_GRAPH_PAD)
continue;
if (link->pad1_sink->entity == entity)

		/* do something */

by preserving the number, we keep consistency between port1 and pad1_sink, and port0 and pad0_source.

This was generated via this script:

	for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed "s,link->sink,link->pad1_sink,g; s,link->source,link->pad0_source,g;" <$i >a && mv a $i; done
drivers/media/dvb-core/dvb_frontend.c +3 -3
index 3c97ebdf9f2a..e673f6f7c398 100644
@@ -637,7 +637,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
 		link = &entity->links[i];
 		if (link->port1.type != MEDIA_GRAPH_PAD)
 			continue;
-		if (link->sink->entity == entity) {
+		if (link->pad1_sink->entity == entity) {
 			found_link = link;
 			n_links++;
 			if (link->flags & MEDIA_LNK_FL_ENABLED)
@@ -660,7 +660,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
 		return -EINVAL;
 	}
 
-	source = found_link->source->entity;
+	source = found_link->pad0_source->entity;
 	fepriv->pipe_start_entity = source;
 	for (i = 0; i < source->num_links; i++) {
 		struct media_entity *sink;
@@ -669,7 +669,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
 		link = &source->links[i];
 		if (link->port1.type != MEDIA_GRAPH_PAD)
 			continue;
-		sink = link->sink->entity;
+		sink = link->pad1_sink->entity;
 
 		if (sink == entity)
 			flags = MEDIA_LNK_FL_ENABLED;
drivers/media/media-device.c +3 -3
index b4bd718ad736..2c29c4600c3a 100644
@@ -160,13 +160,13 @@ static long __media_device_enum_links(struct media_device *mdev,
 			    ent_link->port1->type != MEDIA_GRAPH_PAD)
 				continue;
 			/* Ignore backlinks. */
-			if (ent_link->source->entity != entity)
+			if (ent_link->pad0_source->entity != entity)
 				continue;
 
 			memset(&link, 0, sizeof(link));
-			media_device_kpad_to_upad(ent_link->source,
+			media_device_kpad_to_upad(ent_link->pad0_source,
 						  &link.source);
-			media_device_kpad_to_upad(ent_link->sink,
+			media_device_kpad_to_upad(ent_link->pad1_sink,
 						  &link.sink);
 			link.flags = ent_link->flags;
 			if (copy_to_user(ulink, &link, sizeof(*ulink)))
drivers/media/media-entity.c +36 -36

164 lines not on this page · raw message

drivers/media/platform/exynos4-is/media-dev.c +1 -1
index 4f5586a4cbff..3cafcf85cafc 100644
@@ -1091,7 +1091,7 @@ 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 *sink = link->sink->entity;
+	struct media_entity *sink = link->pad1_sink->entity;
 	int ret = 0;
 
 	/* Before link disconnection */
drivers/media/platform/omap3isp/isp.c +2 -2
index 12be830d704f..cbd22a422bd3 100644
@@ -822,8 +822,8 @@ 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 *source = link->source->entity;
-	struct media_entity *sink = link->sink->entity;
+	struct media_entity *source = link->pad0_source->entity;
+	struct media_entity *sink = link->pad1_sink->entity;
 	int source_use = isp_pipeline_pm_use_count(source);
 	int sink_use = isp_pipeline_pm_use_count(sink);
 	int ret;
drivers/media/platform/omap3isp/ispccdc.c +1 -1
index 3b10304b580b..cb236b54d770 100644
@@ -2419,7 +2419,7 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,
 	if (ccdc->input == CCDC_INPUT_PARALLEL) {
 		struct isp_parallel_cfg *parcfg =
 			&((struct isp_bus_cfg *)
-			  media_entity_to_v4l2_subdev(link->source->entity)
+			  media_entity_to_v4l2_subdev(link->pad0_source->entity)
 			  ->host_priv)->bus.parallel;
 		parallel_shift = parcfg->data_lane_shift * 2;
 	} else {
drivers/media/usb/cx231xx/cx231xx-video.c +3 -3
index e8baff4d6290..9416a8b7d575 100644
@@ -128,7 +128,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 		return 0;
 
 	list_for_each_entry(link, &decoder->links, list) {
-		if (link->sink->entity == decoder) {
+		if (link->pad1_sink->entity == decoder) {
 			found_link = link;
 			if (link->flags & MEDIA_LNK_FL_ENABLED)
 				active_links++;
@@ -139,12 +139,12 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev)
 	if (active_links == 1 || !found_link)
 		return 0;
 
-	source = found_link->source->entity;
+	source = found_link->pad0_source->entity;
 	list_for_each_entry(link, &source->links, list) {
 		struct media_entity *sink;
 		int flags = 0;
 
-		sink = link->sink->entity;
+		sink = link->pad1_sink->entity;
 
 		if (sink == entity)
 			flags = MEDIA_LNK_FL_ENABLED;
drivers/media/v4l2-core/v4l2-subdev.c +3 -3
index 83615b8fb46a..53729ccdea80 100644
@@ -549,16 +549,16 @@ int v4l2_subdev_link_validate(struct media_link *link)
 	int rval;
 
 	rval = v4l2_subdev_link_validate_get_format(
-		link->source, &source_fmt);
+		link->pad0_source, &source_fmt);
 	if (rval < 0)
 		return 0;
 
 	rval = v4l2_subdev_link_validate_get_format(
-		link->sink, &sink_fmt);
+		link->pad1_sink, &sink_fmt);
 	if (rval < 0)
 		return 0;
 
-	sink = media_entity_to_v4l2_subdev(link->sink->entity);
+	sink = media_entity_to_v4l2_subdev(link->pad1_sink->entity);
 
 	rval = v4l2_subdev_call(sink, pad, link_validate, link,
 				&source_fmt, &sink_fmt);
drivers/staging/media/omap4iss/iss.c +4 -4
index 9bfb725b9986..37694999d189 100644
@@ -140,9 +140,9 @@ int omap4iss_get_external_info(struct iss_pipeline *pipe,
 
 	memset(&fmt, 0, sizeof(fmt));
 
-	fmt.pad = link->source->index;
+	fmt.pad = link->pad0_source->index;
 	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
-	ret = v4l2_subdev_call(media_entity_to_v4l2_subdev(link->sink->entity),
+	ret = v4l2_subdev_call(media_entity_to_v4l2_subdev(link->pad1_sink->entity),
 			       pad, get_fmt, NULL, &fmt);
 	if (ret < 0)
 		return -EPIPE;
@@ -526,8 +526,8 @@ 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 *source = link->source->entity;
-	struct media_entity *sink = link->sink->entity;
+	struct media_entity *source = link->pad0_source->entity;
+	struct media_entity *sink = link->pad1_sink->entity;
 	int source_use = iss_pipeline_pm_use_count(source);
 	int sink_use = iss_pipeline_pm_use_count(sink);
 	int ret;
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
index e936cfc218cb..e39f1bbbdae1 100644
@@ -1026,7 +1026,7 @@ static int csi2_link_validate(struct v4l2_subdev *sd, struct media_link *link,
 	struct iss_pipeline *pipe = to_iss_pipeline(&csi2->subdev.entity);
 	int rval;
 
-	pipe->external = media_entity_to_v4l2_subdev(link->source->entity);
+	pipe->external = media_entity_to_v4l2_subdev(link->pad0_source->entity);
 	rval = omap4iss_get_external_info(pipe, link);
 	if (rval < 0)
 		return rval;
include/media/media-entity.h +2 -2
index a6464499902e..412cf5d00315 100644
@@ -87,12 +87,12 @@ struct media_link {
 	enum media_graph_link_dir	dir;
 	union {
 		struct media_graph_obj *port0;
-		struct media_pad *source;
+		struct media_pad *pad0_source;
 		struct media_interface *port0_intf;
 	};
 	union {
 		struct media_graph_obj *port1;
-		struct media_pad *sink;
+		struct media_pad *pad1_sink;
 		struct media_entity *port1_entity;
 	};
 	struct media_link *reverse;	/* Link in the reverse direction */
Signature · 1 line
2.4.3
#16 lore raw

RFC PATCH v3 10/16 media: rename link source/sink to pad0_source/pad1_sink

Quoted 11 lines · Mauro Carvalho Chehab

Change the internal namespace for links between two pads to have the "pad" there.

We're also numbering it, as a common constructor is to do things like:

drivers/media/dvb-core/dvb_frontend.c +0 -0
 	if (link->port1.type != MEDIA_GRAPH_PAD)
 		continue;
 	if (link->pad1_sink->entity == entity)
		/* do something */
Quoted 2 lines

by preserving the number, we keep consistency between port1 and pad1_sink, and port0 and pad0_source.

I would really leave this patch out. As long as sink and source are consistently used for pads (and they are), then I see no benefit at all to this change.

Another reason why I don't like this is that pad0_ and pad1_ are actually confusing since they suggested to me when I first read it that pad0_ referred to the pad with index 0 and pad1_ referred to the pad with index 1.

That's obviously not the case, but it does mean that the prefix doesn't really make things clearer.

I would just stick with source and sink.

Regards,

Hans

#17 lore raw

RFC PATCH v3 11/16 media: rename the function that create pad links

In reply to Mauro Carvalho Chehab

Now that a link can be either between two different graph objects, we'll need to add more functions to create links. So, rename the existing one that create links only between two pads as media_create_pad_link().

No functional changes.

This patch was created via this shell script:

	for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_create_link,media_create_pad_link,g <$i >a && mv a $i; done
drivers/media/dvb-core/dvbdev.c +4 -4
index 2fdcbb5f000a..65f59f2124b4 100644
@@ -412,16 +412,16 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
 	}
 
 	if (tuner && fe)
-		media_entity_create_link(tuner, 0, fe, 0, 0);
+		media_create_pad_link(tuner, 0, fe, 0, 0);
 
 	if (fe && demux)
-		media_entity_create_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
+		media_create_pad_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
 
 	if (demux && dvr)
-		media_entity_create_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED);
+		media_create_pad_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED);
 
 	if (demux && ca)
-		media_entity_create_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
+		media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
 }
 EXPORT_SYMBOL_GPL(dvb_create_media_graph);
 #endif
drivers/media/i2c/s5c73m3/s5c73m3-core.c +2 -2
index 6d167428727d..c81bfbfea32f 100644
@@ -1482,11 +1482,11 @@ static int s5c73m3_oif_registered(struct v4l2_subdev *sd)
 		return ret;
 	}
 
-	ret = media_entity_create_link(&state->sensor_sd.entity,
+	ret = media_create_pad_link(&state->sensor_sd.entity,
 			S5C73M3_ISP_PAD, &state->oif_sd.entity, OIF_ISP_PAD,
 			MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
 
-	ret = media_entity_create_link(&state->sensor_sd.entity,
+	ret = media_create_pad_link(&state->sensor_sd.entity,
 			S5C73M3_JPEG_PAD, &state->oif_sd.entity, OIF_JPEG_PAD,
 			MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
 
drivers/media/i2c/s5k5baf.c +1 -1
index 30a9ca62e034..d3bff30bcb6f 100644
@@ -1756,7 +1756,7 @@ static int s5k5baf_registered(struct v4l2_subdev *sd)
 		v4l2_err(sd, "failed to register subdev %s\n",
 			 state->cis_sd.name);
 	else
-		ret = media_entity_create_link(&state->cis_sd.entity, PAD_CIS,
+		ret = media_create_pad_link(&state->cis_sd.entity, PAD_CIS,
 					       &state->sd.entity, PAD_CIS,
 					       MEDIA_LNK_FL_IMMUTABLE |
 					       MEDIA_LNK_FL_ENABLED);
drivers/media/i2c/smiapp/smiapp-core.c +2 -2
index 308613ea0aed..5aa49eb393a9 100644
@@ -2495,7 +2495,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
 			return rval;
 		}
 
-		rval = media_entity_create_link(&this->sd.entity,
+		rval = media_create_pad_link(&this->sd.entity,
 						this->source_pad,
 						&last->sd.entity,
 						last->sink_pad,
@@ -2503,7 +2503,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
 						MEDIA_LNK_FL_IMMUTABLE);
 		if (rval) {
 			dev_err(&client->dev,
-				"media_entity_create_link failed\n");
+				"media_create_pad_link failed\n");
 			return rval;
 		}
 
drivers/media/media-entity.c +2 -2
index aafa1119fba7..03c0ebdd8026 100644
@@ -479,7 +479,7 @@ static void __media_entity_remove_link(struct media_entity *entity,
 				       struct media_link *link);
 
 int
-media_entity_create_link(struct media_entity *source, u16 source_pad,
+media_create_pad_link(struct media_entity *source, u16 source_pad,
 			 struct media_entity *sink, u16 sink_pad, u32 flags)
 {
 	struct media_link *link;
@@ -517,7 +517,7 @@ media_entity_create_link(struct media_entity *source, u16 source_pad,
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(media_entity_create_link);
+EXPORT_SYMBOL_GPL(media_create_pad_link);
 
 static void __media_entity_remove_link(struct media_entity *entity,
 				       struct media_link *link)
drivers/media/platform/exynos4-is/media-dev.c +8 -8
index 3cafcf85cafc..f6ccca232c86 100644
@@ -729,7 +729,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,
 		flags = ((1 << i) & link_mask) ? MEDIA_LNK_FL_ENABLED : 0;
 
 		sink = &fmd->fimc[i]->vid_cap.subdev.entity;
-		ret = media_entity_create_link(source, pad, sink,
+		ret = media_create_pad_link(source, pad, sink,
 					      FIMC_SD_PAD_SINK_CAM, flags);
 		if (ret)
 			return ret;
@@ -749,7 +749,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd,
 			continue;
 
 		sink = &fmd->fimc_lite[i]->subdev.entity;
-		ret = media_entity_create_link(source, pad, sink,
+		ret = media_create_pad_link(source, pad, sink,
 					       FLITE_SD_PAD_SINK, 0);
 		if (ret)
 			return ret;
@@ -781,13 +781,13 @@ static int __fimc_md_create_flite_source_links(struct fimc_md *fmd)
 		source = &fimc->subdev.entity;
 		sink = &fimc->ve.vdev.entity;
 		/* FIMC-LITE's subdev and video node */
-		ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA,
+		ret = media_create_pad_link(source, FLITE_SD_PAD_SOURCE_DMA,
 					       sink, 0, 0);
 		if (ret)
 			break;
 		/* Link from FIMC-LITE to IS-ISP subdev */
 		sink = &fmd->fimc_is->isp.subdev.entity;
-		ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_ISP,
+		ret = media_create_pad_link(source, FLITE_SD_PAD_SOURCE_ISP,
 					       sink, 0, 0);
 		if (ret)
 			break;
@@ -811,7 +811,7 @@ static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)
 
 		/* Link from FIMC-IS-ISP subdev to FIMC */
 		sink = &fmd->fimc[i]->vid_cap.subdev.entity;
-		ret = media_entity_create_link(source, FIMC_ISP_SD_PAD_SRC_FIFO,
+		ret = media_create_pad_link(source, FIMC_ISP_SD_PAD_SRC_FIFO,
 					       sink, FIMC_SD_PAD_SINK_FIFO, 0);
 		if (ret)
 			return ret;
@@ -824,7 +824,7 @@ static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)
 	if (sink->num_pads == 0)
 		return 0;
 
-	return media_entity_create_link(source, FIMC_ISP_SD_PAD_SRC_DMA,
+	return media_create_pad_link(source, FIMC_ISP_SD_PAD_SRC_DMA,
 					sink, 0, 0);
 }
 
@@ -873,7 +873,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
 				return -EINVAL;
 
 			pad = sensor->entity.num_pads - 1;
-			ret = media_entity_create_link(&sensor->entity, pad,
+			ret = media_create_pad_link(&sensor->entity, pad,
 					      &csis->entity, CSIS_PAD_SINK,
 					      MEDIA_LNK_FL_IMMUTABLE |
 					      MEDIA_LNK_FL_ENABLED);
@@ -927,7 +927,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
 		source = &fmd->fimc[i]->vid_cap.subdev.entity;
 		sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity;
 
-		ret = media_entity_create_link(source, FIMC_SD_PAD_SOURCE,
+		ret = media_create_pad_link(source, FIMC_SD_PAD_SOURCE,
 					      sink, 0, flags);
 		if (ret)
 			break;
drivers/media/platform/omap3isp/isp.c +9 -9
index cbd22a422bd3..df9b3cb8ad60 100644
@@ -1905,7 +1905,7 @@ static int isp_link_entity(
 		return -EINVAL;
 	}
 
-	return media_entity_create_link(entity, i, input, pad, flags);
+	return media_create_pad_link(entity, i, input, pad, flags);
 }
 
 static int isp_register_entities(struct isp_device *isp)
@@ -2077,51 +2077,51 @@ static int isp_initialize_modules(struct isp_device *isp)
 	}
 
 	/* Connect the submodules. */
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE,
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_ccp2.subdev.entity, CCP2_PAD_SOURCE,
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
 			&isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF,
 			&isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_prev.subdev.entity, PREV_PAD_SOURCE,
 			&isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
 			&isp->isp_aewb.subdev.entity, 0,
 			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
 			&isp->isp_af.subdev.entity, 0,
 			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
 			&isp->isp_hist.subdev.entity, 0,
 			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
drivers/media/platform/omap3isp/ispccdc.c +1 -1
index cb236b54d770..a69a5615f060 100644
@@ -2667,7 +2667,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc)
 		goto error_video;
 
 	/* Connect the CCDC subdev to the video node. */
-	ret = media_entity_create_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF,
+	ret = media_create_pad_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF,
 			&ccdc->video_out.video.entity, 0, 0);
 	if (ret < 0)
 		goto error_link;
drivers/media/platform/omap3isp/ispccp2.c +1 -1
index e1b5f5bea541..b215eb5049d6 100644
@@ -1100,7 +1100,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2)
 		goto error_video;
 
 	/* Connect the video node to the ccp2 subdev. */
-	ret = media_entity_create_link(&ccp2->video_in.video.entity, 0,
+	ret = media_create_pad_link(&ccp2->video_in.video.entity, 0,
 				       &ccp2->subdev.entity, CCP2_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
index 6fff92f0813a..fcefc1e74881 100644
@@ -1265,7 +1265,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2)
 		goto error_video;
 
 	/* Connect the CSI2 subdev to the video node. */
-	ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE,
+	ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE,
 				       &csi2->video_out.video.entity, 0, 0);
 	if (ret < 0)
 		goto error_link;
drivers/media/platform/omap3isp/isppreview.c +2 -2
index b440c6342ca4..ad38d20c7770 100644
@@ -2312,12 +2312,12 @@ static int preview_init_entities(struct isp_prev_device *prev)
 		goto error_video_out;
 
 	/* Connect the video nodes to the previewer subdev. */
-	ret = media_entity_create_link(&prev->video_in.video.entity, 0,
+	ret = media_create_pad_link(&prev->video_in.video.entity, 0,
 			&prev->subdev.entity, PREV_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(&prev->subdev.entity, PREV_PAD_SOURCE,
+	ret = media_create_pad_link(&prev->subdev.entity, PREV_PAD_SOURCE,
 			&prev->video_out.video.entity, 0, 0);
 	if (ret < 0)
 		goto error_link;
drivers/media/platform/omap3isp/ispresizer.c +2 -2
index 3deb1ec4a973..b48ad4d4b834 100644
@@ -1756,12 +1756,12 @@ static int resizer_init_entities(struct isp_res_device *res)
 	res->video_out.video.entity.flags |= MEDIA_ENT_FL_DEFAULT;
 
 	/* Connect the video nodes to the resizer subdev. */
-	ret = media_entity_create_link(&res->video_in.video.entity, 0,
+	ret = media_create_pad_link(&res->video_in.video.entity, 0,
 			&res->subdev.entity, RESZ_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(&res->subdev.entity, RESZ_PAD_SOURCE,
+	ret = media_create_pad_link(&res->subdev.entity, RESZ_PAD_SOURCE,
 			&res->video_out.video.entity, 0, 0);
 	if (ret < 0)
 		goto error_link;
drivers/media/platform/s3c-camif/camif-core.c +2 -2
index f47b332f0418..3e33c60be004 100644
@@ -263,7 +263,7 @@ static int camif_create_media_links(struct camif_dev *camif)
 {
 	int i, ret;
 
-	ret = media_entity_create_link(&camif->sensor.sd->entity, 0,
+	ret = media_create_pad_link(&camif->sensor.sd->entity, 0,
 				&camif->subdev.entity, CAMIF_SD_PAD_SINK,
 				MEDIA_LNK_FL_IMMUTABLE |
 				MEDIA_LNK_FL_ENABLED);
@@ -271,7 +271,7 @@ static int camif_create_media_links(struct camif_dev *camif)
 		return ret;
 
 	for (i = 1; i < CAMIF_SD_PADS_NUM && !ret; i++) {
-		ret = media_entity_create_link(&camif->subdev.entity, i,
+		ret = media_create_pad_link(&camif->subdev.entity, i,
 				&camif->vp[i - 1].vdev.entity, 0,
 				MEDIA_LNK_FL_IMMUTABLE |
 				MEDIA_LNK_FL_ENABLED);
drivers/media/platform/vsp1/vsp1_drv.c +2 -2
index 4e61886384e3..9cd94a76a9ed 100644
@@ -101,7 +101,7 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
 			if (!(entity->pads[pad].flags & MEDIA_PAD_FL_SINK))
 				continue;
 
-			ret = media_entity_create_link(&source->subdev.entity,
+			ret = media_create_pad_link(&source->subdev.entity,
 						       source->source_pad,
 						       entity, pad, flags);
 			if (ret < 0)
@@ -262,7 +262,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 	}
 
 	if (vsp1->pdata.features & VSP1_HAS_LIF) {
-		ret = media_entity_create_link(
+		ret = media_create_pad_link(
 			&vsp1->wpf[0]->entity.subdev.entity, RWPF_PAD_SOURCE,
 			&vsp1->lif->entity.subdev.entity, LIF_PAD_SINK, 0);
 		if (ret < 0)
drivers/media/platform/vsp1/vsp1_rpf.c +1 -1
index 3294529a3108..b60a528a8fe8 100644
@@ -278,7 +278,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 	rpf->entity.video = video;
 
 	/* Connect the video device to the RPF. */
-	ret = media_entity_create_link(&rpf->video.video.entity, 0,
+	ret = media_create_pad_link(&rpf->video.video.entity, 0,
 				       &rpf->entity.subdev.entity,
 				       RWPF_PAD_SINK,
 				       MEDIA_LNK_FL_ENABLED |
drivers/media/platform/vsp1/vsp1_wpf.c +1 -1
index 1d2b3a2f1573..d39aa4b8aea1 100644
@@ -284,7 +284,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 	if (!(vsp1->pdata.features & VSP1_HAS_LIF) || index != 0)
 		flags |= MEDIA_LNK_FL_IMMUTABLE;
 
-	ret = media_entity_create_link(&wpf->entity.subdev.entity,
+	ret = media_create_pad_link(&wpf->entity.subdev.entity,
 				       RWPF_PAD_SOURCE,
 				       &wpf->video.video.entity, 0, flags);
 	if (ret < 0)
drivers/media/platform/xilinx/xilinx-vipp.c +2 -2
index 7b7cb9c28d2c..79d4be7ce9a5 100644
@@ -156,7 +156,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
 			local->name, local_pad->index,
 			remote->name, remote_pad->index);
 
-		ret = media_entity_create_link(local, local_pad->index,
+		ret = media_create_pad_link(local, local_pad->index,
 					       remote, remote_pad->index,
 					       link_flags);
 		if (ret < 0) {
@@ -270,7 +270,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev)
 			source->name, source_pad->index,
 			sink->name, sink_pad->index);
 
-		ret = media_entity_create_link(source, source_pad->index,
+		ret = media_create_pad_link(source, source_pad->index,
 					       sink, sink_pad->index,
 					       link_flags);
 		if (ret < 0) {
drivers/media/usb/cx231xx/cx231xx-cards.c +3 -3
index 4a117a58c39a..3b5c9ae39ad3 100644
@@ -1264,11 +1264,11 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)
 		return;
 
 	if (tuner)
-		media_entity_create_link(tuner, 0, decoder, 0,
+		media_create_pad_link(tuner, 0, decoder, 0,
 					 MEDIA_LNK_FL_ENABLED);
-	media_entity_create_link(decoder, 1, &dev->vdev.entity, 0,
+	media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
 				 MEDIA_LNK_FL_ENABLED);
-	media_entity_create_link(decoder, 2, &dev->vbi_dev.entity, 0,
+	media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
 				 MEDIA_LNK_FL_ENABLED);
 #endif
 }
drivers/media/usb/uvc/uvc_entity.c +1 -1
index 245445491516..429e428ccd93 100644
@@ -56,7 +56,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain,
 			continue;
 
 		remote_pad = remote->num_pads - 1;
-		ret = media_entity_create_link(source, remote_pad,
+		ret = media_create_pad_link(source, remote_pad,
 					       sink, i, flags);
 		if (ret < 0)
 			return ret;
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +1 -1
index 8fb676186898..d96bdaaae50e 100644
@@ -971,7 +971,7 @@ vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif,
 	ipipeif->video_in.vpfe_dev = vpfe_dev;
 
 	flags = 0;
-	ret = media_entity_create_link(&ipipeif->video_in.video_dev.entity, 0,
+	ret = media_create_pad_link(&ipipeif->video_in.video_dev.entity, 0,
 					&ipipeif->subdev.entity, 0, flags);
 	if (ret < 0)
 		goto fail;
drivers/staging/media/davinci_vpfe/dm365_isif.c +1 -1
index b1f01adfa7c8..df77288b0ec0 100644
@@ -1817,7 +1817,7 @@ int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
 	isif->video_out.vpfe_dev = vpfe_dev;
 	flags = 0;
 	/* connect isif to video node */
-	ret = media_entity_create_link(&isif->subdev.entity, 1,
+	ret = media_create_pad_link(&isif->subdev.entity, 1,
 				       &isif->video_out.video_dev.entity,
 				       0, flags);
 	if (ret < 0)
drivers/staging/media/davinci_vpfe/dm365_resizer.c +4 -4
index 692789aa22f4..ae942de3a23d 100644
@@ -1831,27 +1831,27 @@ int vpfe_resizer_register_entities(struct vpfe_resizer_device *resizer,
 	resizer->resizer_b.video_out.vpfe_dev = vpfe_dev;
 
 	/* create link between Resizer Crop----> Resizer A*/
-	ret = media_entity_create_link(&resizer->crop_resizer.subdev.entity, 1,
+	ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 1,
 				&resizer->resizer_a.subdev.entity,
 				0, flags);
 	if (ret < 0)
 		goto out_create_link;
 
 	/* create link between Resizer Crop----> Resizer B*/
-	ret = media_entity_create_link(&resizer->crop_resizer.subdev.entity, 2,
+	ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 2,
 				&resizer->resizer_b.subdev.entity,
 				0, flags);
 	if (ret < 0)
 		goto out_create_link;
 
 	/* create link between Resizer A ----> video out */
-	ret = media_entity_create_link(&resizer->resizer_a.subdev.entity, 1,
+	ret = media_create_pad_link(&resizer->resizer_a.subdev.entity, 1,
 		&resizer->resizer_a.video_out.video_dev.entity, 0, flags);
 	if (ret < 0)
 		goto out_create_link;
 
 	/* create link between Resizer B ----> video out */
-	ret = media_entity_create_link(&resizer->resizer_b.subdev.entity, 1,
+	ret = media_create_pad_link(&resizer->resizer_b.subdev.entity, 1,
 		&resizer->resizer_b.video_out.video_dev.entity, 0, flags);
 	if (ret < 0)
 		goto out_create_link;
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +5 -5
index 57426199ad7a..08c8a5f967d3 100644
@@ -445,32 +445,32 @@ static int vpfe_register_entities(struct vpfe_device *vpfe_dev)
 		/* if entity has no pads (ex: amplifier),
 		   cant establish link */
 		if (vpfe_dev->sd[i]->entity.num_pads) {
-			ret = media_entity_create_link(&vpfe_dev->sd[i]->entity,
+			ret = media_create_pad_link(&vpfe_dev->sd[i]->entity,
 				0, &vpfe_dev->vpfe_isif.subdev.entity,
 				0, flags);
 			if (ret < 0)
 				goto out_resizer_register;
 		}
 
-	ret = media_entity_create_link(&vpfe_dev->vpfe_isif.subdev.entity, 1,
+	ret = media_create_pad_link(&vpfe_dev->vpfe_isif.subdev.entity, 1,
 				       &vpfe_dev->vpfe_ipipeif.subdev.entity,
 				       0, flags);
 	if (ret < 0)
 		goto out_resizer_register;
 
-	ret = media_entity_create_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1,
+	ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1,
 				       &vpfe_dev->vpfe_ipipe.subdev.entity,
 				       0, flags);
 	if (ret < 0)
 		goto out_resizer_register;
 
-	ret = media_entity_create_link(&vpfe_dev->vpfe_ipipe.subdev.entity,
+	ret = media_create_pad_link(&vpfe_dev->vpfe_ipipe.subdev.entity,
 			1, &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,
 			0, flags);
 	if (ret < 0)
 		goto out_resizer_register;
 
-	ret = media_entity_create_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1,
+	ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1,
 			&vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,
 			0, flags);
 	if (ret < 0)
drivers/staging/media/omap4iss/iss.c +6 -6
index 37694999d189..c0455220f441 100644
@@ -1259,7 +1259,7 @@ static int iss_register_entities(struct iss_device *iss)
 			goto done;
 		}
 
-		ret = media_entity_create_link(&sensor->entity, 0, input, pad,
+		ret = media_create_pad_link(&sensor->entity, 0, input, pad,
 					       flags);
 		if (ret < 0)
 			goto done;
@@ -1317,31 +1317,31 @@ static int iss_initialize_modules(struct iss_device *iss)
 	}
 
 	/* Connect the submodules. */
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&iss->csi2a.subdev.entity, CSI2_PAD_SOURCE,
 			&iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&iss->csi2b.subdev.entity, CSI2_PAD_SOURCE,
 			&iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP,
 			&iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP,
 			&iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0);
 	if (ret < 0)
 		goto error_link;
 
-	ret = media_entity_create_link(
+	ret = media_create_pad_link(
 			&iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP,
 			&iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0);
 	if (ret < 0)
drivers/staging/media/omap4iss/iss_csi2.c +1 -1
index e39f1bbbdae1..206fb57703c7 100644
@@ -1291,7 +1291,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
 		goto error_video;
 
 	/* Connect the CSI2 subdev to the video node. */
-	ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE,
+	ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE,
 				       &csi2->video_out.video.entity, 0, 0);
 	if (ret < 0)
 		goto error_link;
drivers/staging/media/omap4iss/iss_ipipeif.c +1 -1
index be5f80d7b5dc..44c432ef2ac5 100644
@@ -762,7 +762,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif)
 		return ret;
 
 	/* Connect the IPIPEIF subdev to the video node. */
-	ret = media_entity_create_link(&ipipeif->subdev.entity,
+	ret = media_create_pad_link(&ipipeif->subdev.entity,
 				       IPIPEIF_PAD_SOURCE_ISIF_SF,
 				       &ipipeif->video_out.video.entity, 0, 0);
 	if (ret < 0)
drivers/staging/media/omap4iss/iss_resizer.c +1 -1
index 91e724085dba..b659e465cb56 100644
@@ -806,7 +806,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer)
 		return ret;
 
 	/* Connect the RESIZER subdev to the video node. */
-	ret = media_entity_create_link(&resizer->subdev.entity,
+	ret = media_create_pad_link(&resizer->subdev.entity,
 				       RESIZER_PAD_SOURCE_MEM,
 				       &resizer->video_out.video.entity, 0, 0);
 	if (ret < 0)
include/media/media-entity.h +1 -1
index 412cf5d00315..8400c517ff1f 100644
@@ -211,7 +211,7 @@ int media_entity_init(struct media_entity *entity, u16 num_pads,
 		      struct media_pad *pads);
 void media_entity_cleanup(struct media_entity *entity);
 
-int media_entity_create_link(struct media_entity *source, u16 source_pad,
+int media_create_pad_link(struct media_entity *source, u16 source_pad,
 		struct media_entity *sink, u16 sink_pad, u32 flags);
 void __media_entity_remove_links(struct media_entity *entity);
 void media_entity_remove_links(struct media_entity *entity);
Signature · 1 line
2.4.3
#18 lore raw

RFC PATCH v3 12/16 media: move __media_entity_remove_link to avoid prototype

In reply to Mauro Carvalho Chehab

As we need __media_entity_remove_link() earlier, move it to happen earlier, to avoid needing to have a function prototype.

No functional changes.

drivers/media/media-entity.c +30 -33
index 03c0ebdd8026..eafd26a741e5 100644
@@ -476,7 +476,36 @@ static struct media_link *media_entity_add_link(struct media_entity *entity)
 }
 
 static void __media_entity_remove_link(struct media_entity *entity,
-				       struct media_link *link);
+				       struct media_link *link)
+{
+	struct media_link *rlink, *tmp;
+	struct media_entity *remote;
+	unsigned int r = 0;
+
+	if (link->pad0_source->entity == entity)
+		remote = link->pad1_sink->entity;
+	else
+		remote = link->pad0_source->entity;
+
+	list_for_each_entry_safe(rlink, tmp, &remote->links, list) {
+		if (rlink != link->reverse) {
+			r++;
+			continue;
+		}
+
+		if (link->pad0_source->entity == entity)
+			remote->num_backlinks--;
+
+		if (--remote->num_links == 0)
+			break;
+
+		/* Remove the remote link */
+		list_del(&rlink->list);
+		kfree(rlink);
+	}
+	list_del(&link->list);
+	kfree(link);
+}
 
 int
 media_create_pad_link(struct media_entity *source, u16 source_pad,
@@ -519,38 +548,6 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 }
 EXPORT_SYMBOL_GPL(media_create_pad_link);
 
-static void __media_entity_remove_link(struct media_entity *entity,
-				       struct media_link *link)
-{
-	struct media_link *rlink, *tmp;
-	struct media_entity *remote;
-	unsigned int r = 0;
-
-	if (link->pad0_source->entity == entity)
-		remote = link->pad1_sink->entity;
-	else
-		remote = link->pad0_source->entity;
-
-	list_for_each_entry_safe(rlink, tmp, &remote->links, list) {
-		if (rlink != link->reverse) {
-			r++;
-			continue;
-		}
-
-		if (link->pad0_source->entity == entity)
-			remote->num_backlinks--;
-
-		if (--remote->num_links == 0)
-			break;
-
-		/* Remove the remote link */
-		list_del(&rlink->list);
-		kfree(rlink);
-	}
-	list_del(&link->list);
-	kfree(link);
-}
-
 void __media_entity_remove_links(struct media_entity *entity)
 {
 	struct media_link *link, *tmp;
Signature · 1 line
2.4.3
#19 lore raw

RFC PATCH v3 13/16 media: make the internal function to create links more generic

In reply to Mauro Carvalho Chehab

In preparation to add a public function to add links, let's make the internal function that creates link more generic.

drivers/media/media-entity.c +24 -15
index eafd26a741e5..b8991d38c565 100644
@@ -457,7 +457,12 @@ EXPORT_SYMBOL_GPL(media_entity_put);
  * Links management
  */
 
-static struct media_link *media_entity_add_link(struct media_entity *entity)
+static struct media_link *__media_create_link(struct media_device *mdev,
+					      enum media_graph_link_dir dir,
+					      struct media_graph_obj *port0,
+					      struct media_graph_obj *port1,
+					      u32 flags,
+					      struct list_head *list)
 {
 	struct media_link *link;
 
@@ -465,12 +470,16 @@ static struct media_link *media_entity_add_link(struct media_entity *entity)
 	if (link == NULL)
 		return NULL;
 
+	link->dir = dir;
+	link->port0 = port0;
+	link->port1 = port1;
+	link->flags = flags;
+
 	INIT_LIST_HEAD(&link->list);
-	list_add(&entity->links, &link->list);
+	list_add(list, &link->list);
 
 	/* Initialize graph object embedded at the new link */
-	graph_obj_init(entity->parent, MEDIA_GRAPH_LINK,
-			&link->graph_obj);
+	graph_obj_init(mdev, MEDIA_GRAPH_LINK, &link->graph_obj);
 
 	return link;
 }
@@ -509,7 +518,7 @@ static void __media_entity_remove_link(struct media_entity *entity,
 
 int
 media_create_pad_link(struct media_entity *source, u16 source_pad,
-			 struct media_entity *sink, u16 sink_pad, u32 flags)
+		      struct media_entity *sink, u16 sink_pad, u32 flags)
 {
 	struct media_link *link;
 	struct media_link *backlink;
@@ -518,27 +527,27 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 	BUG_ON(source_pad >= source->num_pads);
 	BUG_ON(sink_pad >= sink->num_pads);
 
-	link = media_entity_add_link(source);
+	link = __media_create_link(source->parent,
+				   MEDIA_LINK_DIR_PORT0_TO_PORT1,
+			           &source->pads[source_pad].graph_obj,
+				   &sink->pads[sink_pad].graph_obj,
+				   flags, &source->links);
 	if (link == NULL)
 		return -ENOMEM;
 
-	link->pad0_source = &source->pads[source_pad];
-	link->pad1_sink = &sink->pads[sink_pad];
-	link->flags = flags;
-
 	/* Create the backlink. Backlinks are used to help graph traversal and
 	 * are not reported to userspace.
 	 */
-	backlink = media_entity_add_link(sink);
+	backlink = __media_create_link(sink->parent,
+				      MEDIA_LINK_DIR_PORT0_TO_PORT1,
+			              &source->pads[source_pad].graph_obj,
+				      &sink->pads[sink_pad].graph_obj,
+				      flags, &sink->links);
 	if (backlink == NULL) {
 		__media_entity_remove_link(source, link);
 		return -ENOMEM;
 	}
 
-	backlink->pad0_source = &source->pads[source_pad];
-	backlink->pad1_sink = &sink->pads[sink_pad];
-	backlink->flags = flags;
-
 	link->reverse = backlink;
 	backlink->reverse = link;
 
Signature · 1 line
2.4.3
#20 lore raw

RFC PATCH v3 14/16 media: add a generic function to remove a link

In reply to Mauro Carvalho Chehab

Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call.

drivers/media/media-entity.c +8 -4
index b8991d38c565..f43af2fda306 100644
@@ -484,6 +484,12 @@ static struct media_link *__media_create_link(struct media_device *mdev,
 	return link;
 }
 
+static void __media_remove_link(struct media_link *link)
+{
+	list_del(&link->list);
+	kfree(link);
+}
+
 static void __media_entity_remove_link(struct media_entity *entity,
 				       struct media_link *link)
 {
@@ -509,11 +515,9 @@ static void __media_entity_remove_link(struct media_entity *entity,
 			break;
 
 		/* Remove the remote link */
-		list_del(&rlink->list);
-		kfree(rlink);
+		__media_remove_link(rlink);
 	}
-	list_del(&link->list);
-	kfree(link);
+	__media_remove_link(link);
 }
 
 int
Signature · 1 line
2.4.3
#21 lore raw

Re: [PATCH RFC v3 14/16] media: add a generic function to remove a link

Quoted 5 lines · Mauro Carvalho Chehab

Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call.

One thing to think about is whether or not we need some kind of callback mechanism to alert the entity on the other side of the link and other entities associated with the media device when a link is removed.

This patch is fine for now and we can enhance it as and when we have the need for such notifications.

-- Shuah

Quoted 39 lines
drivers/media/media-entity.c +8 -5
index b8991d38c565..f43af2fda306 100644
@@ -484,6 +484,12 @@ static struct media_link *__media_create_link(struct media_device *mdev,
        return link;
 }
 
+static void __media_remove_link(struct media_link *link)
+{
+       list_del(&link->list);
+       kfree(link);
+}
+
 static void __media_entity_remove_link(struct media_entity *entity,
                                       struct media_link *link)
 {
@@ -509,11 +515,9 @@ static void __media_entity_remove_link(struct media_entity *entity,
                        break;
 
                /* Remove the remote link */
-               list_del(&rlink->list);
-               kfree(rlink);
+               __media_remove_link(rlink);
        }
-       list_del(&link->list);
-       kfree(link);
+       __media_remove_link(link);
 }
 
 int
--

2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw

Re: [PATCH RFC v3 14/16] media: add a generic function to remove a link

Em Wed, 12 Aug 2015 14:45:52 -0600
Shuah Khan <[email protected]> escreveu:

Quoted 6 lines
Quoted 4 lines · Mauro Carvalho Chehab

Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call.

Quoted 8 lines
Quoted 1 line

One thing to think about is whether or not we need some kind of callback mechanism to alert the entity on the other side of the link and other entities associated with the media device when a link is removed.

This patch is fine for now and we can enhance it as and when we have the need for such notifications.

Well, now, all elements of the graph are of the type media_graph_obj.

One of the things it is stored there is the media_device. It would be very easy to add a notify function[1] that would call a callback when a new object is created or removed. A single callback function could be used for any topology change.

So, I think that it is now simpler to track topology changes than before ;)

[1] Actually, I would implement a list with notification callbacks as more than one driver may want to be notified about topology changes.

Regards,
Mauro

#23 lore raw

Re: [PATCH RFC v3 14/16] media: add a generic function to remove a link

Quoted 25 lines · Mauro Carvalho Chehab

Em Wed, 12 Aug 2015 14:45:52 -0600
Shuah Khan <[email protected]> escreveu:

Quoted 6 lines
Quoted 4 lines · Mauro Carvalho Chehab

Removing a link is simple. Yet, better to have a separate function for it, as we'll be also sharing it with a public API call.

Quoted 8 lines
Quoted 1 line

One thing to think about is whether or not we need some kind of callback mechanism to alert the entity on the other side of the link and other entities associated with the media device when a link is removed.

This patch is fine for now and we can enhance it as and when we have the need for such notifications.

Well, now, all elements of the graph are of the type media_graph_obj.

One of the things it is stored there is the media_device. It would be very easy to add a notify function[1] that would call a callback when a new object is created or removed. A single callback function could be used for any topology change.

Quoted 7 lines

So, I think that it is now simpler to track topology changes than before ;)

[1] Actually, I would implement a list with notification callbacks as more than one driver may want to be notified about topology changes.

Right. It has to be a list as opposed to a single call.

-- Shuah

Signature · 5 lines
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978
#24 lore raw

RFC PATCH v3 15/16 media: rename media_entity_remove_foo functions

In reply to Mauro Carvalho Chehab

As entities will also have links to interfaces, we need to rename the existing functions that remove links, to avoid namespace collision and confusion.

No functional changes.

The rename was made by this script:

	for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_remove,media_remove_pad,g <$i >a && mv a $i; done
drivers/media/media-entity.c +8 -8
index f43af2fda306..c3bc8a6f660b 100644
@@ -490,7 +490,7 @@ static void __media_remove_link(struct media_link *link)
 	kfree(link);
 }
 
-static void __media_entity_remove_link(struct media_entity *entity,
+static void __media_remove_pad_link(struct media_entity *entity,
 				       struct media_link *link)
 {
 	struct media_link *rlink, *tmp;
@@ -548,7 +548,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 				      &sink->pads[sink_pad].graph_obj,
 				      flags, &sink->links);
 	if (backlink == NULL) {
-		__media_entity_remove_link(source, link);
+		__media_remove_pad_link(source, link);
 		return -ENOMEM;
 	}
 
@@ -561,29 +561,29 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 }
 EXPORT_SYMBOL_GPL(media_create_pad_link);
 
-void __media_entity_remove_links(struct media_entity *entity)
+void __media_remove_pad_links(struct media_entity *entity)
 {
 	struct media_link *link, *tmp;
 
 	list_for_each_entry_safe(link, tmp, &entity->links, list)
-		__media_entity_remove_link(entity, link);
+		__media_remove_pad_link(entity, link);
 
 	entity->num_links = 0;
 	entity->num_backlinks = 0;
 }
-EXPORT_SYMBOL_GPL(__media_entity_remove_links);
+EXPORT_SYMBOL_GPL(__media_remove_pad_links);
 
-void media_entity_remove_links(struct media_entity *entity)
+void media_remove_pad_links(struct media_entity *entity)
 {
 	/* Do nothing if the entity is not registered. */
 	if (entity->parent == NULL)
 		return;
 
 	mutex_lock(&entity->parent->graph_mutex);
-	__media_entity_remove_links(entity);
+	__media_remove_pad_links(entity);
 	mutex_unlock(&entity->parent->graph_mutex);
 }
-EXPORT_SYMBOL_GPL(media_entity_remove_links);
+EXPORT_SYMBOL_GPL(media_remove_pad_links);
 
 static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
 {
drivers/media/v4l2-core/v4l2-device.c +1 -1
index 5b0a30b9252b..bbec6d87f5f8 100644
@@ -285,7 +285,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	if (v4l2_dev->mdev) {
-		media_entity_remove_links(&sd->entity);
+		media_remove_pad_links(&sd->entity);
 		media_device_unregister_entity(&sd->entity);
 	}
 #endif
include/media/media-entity.h +2 -2
index 8400c517ff1f..e63e402ca6d1 100644
@@ -213,8 +213,8 @@ void media_entity_cleanup(struct media_entity *entity);
 
 int media_create_pad_link(struct media_entity *source, u16 source_pad,
 		struct media_entity *sink, u16 sink_pad, u32 flags);
-void __media_entity_remove_links(struct media_entity *entity);
-void media_entity_remove_links(struct media_entity *entity);
+void __media_remove_pad_links(struct media_entity *entity);
+void media_remove_pad_links(struct media_entity *entity);
 
 int __media_entity_setup_link(struct media_link *link, u32 flags);
 int media_entity_setup_link(struct media_link *link, u32 flags);
Signature · 1 line
2.4.3
#25 lore raw

RFC PATCH v3 16/16 media: add functions to allow creating interfaces

In reply to Mauro Carvalho Chehab

Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function.

Let's distinguish them by creating a separate structure to store the interfaces.

Latter patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph.

drivers/media/media-entity.c +56 -0
index c3bc8a6f660b..8cd529d3180a 100644
@@ -733,3 +733,59 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad)
 
 }
 EXPORT_SYMBOL_GPL(media_entity_remote_pad);
+
+
+/* Functions related to the media interface via device nodes */
+
+struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
+						u32 major, u32 minor,
+						gfp_t gfp_flags)
+{
+	struct media_intf_devnode *devnode;
+
+	devnode = kzalloc(sizeof(*devnode), gfp_flags);
+	if (!devnode)
+		return NULL;
+
+	devnode->major = major;
+	devnode->minor = minor;
+	INIT_LIST_HEAD(&devnode->intf.entity_links);
+
+	graph_obj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE,
+		       &devnode->intf.graph_obj);
+
+	return devnode;
+}
+EXPORT_SYMBOL_GPL(media_devnode_create);
+
+void media_devnode_remove(struct media_intf_devnode *devnode)
+{
+	graph_obj_remove(&devnode->intf.graph_obj);
+	kfree(devnode);
+}
+EXPORT_SYMBOL_GPL(media_devnode_remove);
+
+struct media_link *media_create_intf_link(struct media_entity *entity,
+					  struct media_graph_obj *gobj,
+					  u32 flags)
+{
+	struct media_link *link;
+
+	/* Only accept links between entity<==>interface */
+	if (gobj->type != MEDIA_GRAPH_INTF_DEVNODE)
+		return NULL;
+
+	link = __media_create_link(entity->parent,
+				   MEDIA_LINK_DIR_BIDIRECTIONAL,
+			           &entity->graph_obj,
+				   gobj,
+				   flags, &entity->intf_links);
+	if (link == NULL)
+		return NULL;
+
+	/* Create the link at the interface */
+	list_add(&gobj_to_interface(gobj)->entity_links, &link->list);
+
+	return link;
+}
+EXPORT_SYMBOL_GPL(media_create_intf_link);
include/media/media-entity.h +41 -1

77 lines not on this page · raw message

Signature · 1 line
2.4.3