All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] media: Add entity types
@ 2016-03-04 20:18 Laurent Pinchart
  2016-03-04 20:18 ` [PATCH v4 1/4] v4l: vsp1: Check if an entity is a subdev with the right function Laurent Pinchart
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Laurent Pinchart @ 2016-03-04 20:18 UTC (permalink / raw)
  To: linux-media; +Cc: Sakari Ailus, Hans Verkuil, Mauro Carvalho Chehab

Hello,

This patch series adds a type field to the media entity structure. It is a
resend of v3 rebased on top of the latest media master branch, with acks
collected and spelling mistakes fixed. I have dropped patches 5 to 7 as they
don't depend on 1-4 and Hans would like to get them merged through his tree,
and patch 8 as is adds a function that currently has no user.

Let's start with a few words about what types are and are not. The purpose of
the entity type is to identify the object type that implements the entity, in
order to safely cast the entity to that object (using container_of()). Three
types are currently defined, for media entities that are instantiated as such
(MEDIA_ENTITY_TYPE_MEDIA_ENTITY), embedded in a struct video_device
(MEDIA_ENTITY_TYPE_VIDEO_DEVICE) or embedded in a struct v4l2_subdev
(MEDIA_ENTITY_TYPE_V4L2_SUBDEV). The naming is pretty straightforward and
self-explicit.

Types do not convey any additional information. They don't tell anything about
the features of the entity or the object that implements it. In particular
they don't report capabilities of video_device instances, which is why the
is_media_entity_v4l2_io() function performs additional checks on the video
device capabilities field, after verifying with the type that it can safely be
cast to a video_device instance.

The series start by two cleanup patches (1/8 and 2/8) that fix incorrect or
unneeded usage of the is_media_entity_v4l2_*() functions in the vsp1 and
exynos4-is drivers. Patch 3/8 then adds the type field to the media_entity
structure and updates the is_media_entity_v4l2_*() functions implementations.
Patch 4/8 renames is_media_entity_v4l2_io() to
is_media_entity_v4l2_video_device() to clarify its purpose.

Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Prabhakar Lad <prabhakar.csengg@gmail.com>

Laurent Pinchart (4):
  v4l: vsp1: Check if an entity is a subdev with the right function
  v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links
  media: Add type field to struct media_entity
  media: Rename is_media_entity_v4l2_io to
    is_media_entity_v4l2_video_device

 drivers/media/platform/exynos4-is/fimc-lite.c   | 12 +---
 drivers/media/platform/exynos4-is/media-dev.c   |  4 +-
 drivers/media/platform/omap3isp/ispvideo.c      |  2 +-
 drivers/media/platform/vsp1/vsp1_video.c        |  2 +-
 drivers/media/v4l2-core/v4l2-dev.c              |  1 +
 drivers/media/v4l2-core/v4l2-mc.c               |  2 +-
 drivers/media/v4l2-core/v4l2-subdev.c           |  1 +
 drivers/staging/media/davinci_vpfe/vpfe_video.c |  2 +-
 drivers/staging/media/omap4iss/iss_video.c      |  2 +-
 include/media/media-entity.h                    | 77 +++++++++++++------------
 10 files changed, 50 insertions(+), 55 deletions(-)

-- 
Regards,

Laurent Pinchart


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

* [PATCH v4 1/4] v4l: vsp1: Check if an entity is a subdev with the right function
  2016-03-04 20:18 [PATCH v4 0/4] media: Add entity types Laurent Pinchart
@ 2016-03-04 20:18 ` Laurent Pinchart
  2016-03-04 20:18 ` [PATCH v4 2/4] v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links Laurent Pinchart
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2016-03-04 20:18 UTC (permalink / raw)
  To: linux-media; +Cc: Sakari Ailus, Hans Verkuil, Mauro Carvalho Chehab

Use is_media_entity_v4l2_subdev() instead of is_media_entity_v4l2_io()
to check whether the entity is a subdev.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 61ee0f92c1e5..72cc7d3729f8 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -289,7 +289,7 @@ static int vsp1_video_pipeline_validate(struct vsp1_pipeline *pipe,
 		struct vsp1_rwpf *rwpf;
 		struct vsp1_entity *e;
 
-		if (is_media_entity_v4l2_io(entity))
+		if (!is_media_entity_v4l2_subdev(entity))
 			continue;
 
 		subdev = media_entity_to_v4l2_subdev(entity);
-- 
2.4.10


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

* [PATCH v4 2/4] v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links
  2016-03-04 20:18 [PATCH v4 0/4] media: Add entity types Laurent Pinchart
  2016-03-04 20:18 ` [PATCH v4 1/4] v4l: vsp1: Check if an entity is a subdev with the right function Laurent Pinchart
@ 2016-03-04 20:18 ` Laurent Pinchart
  2016-03-04 20:18 ` [PATCH v4 3/4] media: Add type field to struct media_entity Laurent Pinchart
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2016-03-04 20:18 UTC (permalink / raw)
  To: linux-media; +Cc: Sakari Ailus, Hans Verkuil, Mauro Carvalho Chehab

The driver verifies that the type of the remote entity matches its
expectations when setting up fimc-lite links and returns an error if it
doesn't. Those checks can never fail as the links are created by the
driver in a way that always match its expectations (the SINK and
SOURCE_ISP pads are connected to subdevs only and the SOURCE_DMA pad is
connected to a video node only). Remove them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/exynos4-is/fimc-lite.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index e85649147dc8..dc1b929f7a33 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -992,10 +992,6 @@ static int fimc_lite_link_setup(struct media_entity *entity,
 
 	switch (local->index) {
 	case FLITE_SD_PAD_SINK:
-		if (!is_media_entity_v4l2_subdev(remote->entity)) {
-			ret = -EINVAL;
-			break;
-		}
 		if (flags & MEDIA_LNK_FL_ENABLED) {
 			if (fimc->source_subdev_grp_id == 0)
 				fimc->source_subdev_grp_id = sd->grp_id;
@@ -1010,19 +1006,15 @@ static int fimc_lite_link_setup(struct media_entity *entity,
 	case FLITE_SD_PAD_SOURCE_DMA:
 		if (!(flags & MEDIA_LNK_FL_ENABLED))
 			atomic_set(&fimc->out_path, FIMC_IO_NONE);
-		else if (is_media_entity_v4l2_io(remote->entity))
-			atomic_set(&fimc->out_path, FIMC_IO_DMA);
 		else
-			ret = -EINVAL;
+			atomic_set(&fimc->out_path, FIMC_IO_DMA);
 		break;
 
 	case FLITE_SD_PAD_SOURCE_ISP:
 		if (!(flags & MEDIA_LNK_FL_ENABLED))
 			atomic_set(&fimc->out_path, FIMC_IO_NONE);
-		else if (is_media_entity_v4l2_subdev(remote->entity))
-			atomic_set(&fimc->out_path, FIMC_IO_ISP);
 		else
-			ret = -EINVAL;
+			atomic_set(&fimc->out_path, FIMC_IO_ISP);
 		break;
 
 	default:
-- 
2.4.10


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

* [PATCH v4 3/4] media: Add type field to struct media_entity
  2016-03-04 20:18 [PATCH v4 0/4] media: Add entity types Laurent Pinchart
  2016-03-04 20:18 ` [PATCH v4 1/4] v4l: vsp1: Check if an entity is a subdev with the right function Laurent Pinchart
  2016-03-04 20:18 ` [PATCH v4 2/4] v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links Laurent Pinchart
@ 2016-03-04 20:18 ` Laurent Pinchart
  2016-03-05 12:55   ` Mauro Carvalho Chehab
  2016-03-04 20:18 ` [PATCH v4 4/4] media: Rename is_media_entity_v4l2_io to is_media_entity_v4l2_video_device Laurent Pinchart
  2016-03-05 12:07 ` [PATCH v4 0/4] media: Add entity types Sakari Ailus
  4 siblings, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2016-03-04 20:18 UTC (permalink / raw)
  To: linux-media; +Cc: Sakari Ailus, Hans Verkuil, Mauro Carvalho Chehab

Code that processes media entities can require knowledge of the
structure type that embeds a particular media entity instance in order
to cast the entity to the proper object type. This needs is shown by the
presence of the is_media_entity_v4l2_io and is_media_entity_v4l2_subdev
functions.

The implementation of those two functions relies on the entity function
field, which is both a wrong and an inefficient design, without even
mentioning the maintenance issue involved in updating the functions
every time a new entity function is added. Fix this by adding add a type
field to the media entity structure to carry the information.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-dev.c    |  1 +
 drivers/media/v4l2-core/v4l2-subdev.c |  1 +
 include/media/media-entity.h          | 75 ++++++++++++++++++-----------------
 3 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d8e5994cccf1..7e766a92e3d9 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -735,6 +735,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
 	if (!vdev->v4l2_dev->mdev)
 		return 0;
 
+	vdev->entity.type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
 	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
 
 	switch (type) {
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index d63083803144..bb6e79f14bb8 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -584,6 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
 	sd->host_priv = NULL;
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	sd->entity.name = sd->name;
+	sd->entity.type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
 	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 #endif
 }
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 6dc9e4e8cbd4..d148fc49c3be 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -188,10 +188,37 @@ struct media_entity_operations {
 };
 
 /**
+ * enum media_entity_type - Media entity type
+ *
+ * @MEDIA_ENTITY_TYPE_MEDIA_ENTITY:
+ *	The entity is a struct media_entity instance.
+ * @MEDIA_ENTITY_TYPE_VIDEO_DEVICE:
+ *	The entity is a struct video_device instance.
+ * @MEDIA_ENTITY_TYPE_V4L2_SUBDEV:
+ *	The entity is a struct v4l2_subdev instance.
+ *
+ * The entity type identifies the type of the object instance that implements
+ * the struct media_entity instance. This allows runtime type identification of
+ * media entities and safe casting to the project object type. For instance, a
+ * media entity structure instance embedded in a v4l2_subdev structure instance
+ * will have the type MEDIA_ENTITY_TYPE_V4L2_SUBDEV and can safely be cast to a
+ * v4l2_subdev structure using the container_of() macro.
+ *
+ * Media entities can be instantiated without creating any derived object type,
+ * in which case their type will be MEDIA_ENTITY_TYPE_MEDIA_ENTITY.
+ */
+enum media_entity_type {
+	MEDIA_ENTITY_TYPE_MEDIA_ENTITY,
+	MEDIA_ENTITY_TYPE_VIDEO_DEVICE,
+	MEDIA_ENTITY_TYPE_V4L2_SUBDEV,
+};
+
+/**
  * struct media_entity - A media entity graph object.
  *
  * @graph_obj:	Embedded structure containing the media object common data.
  * @name:	Entity name.
+ * @type:	Type of the object that implements the media_entity.
  * @function:	Entity main function, as defined in uapi/media.h
  *		(MEDIA_ENT_F_*)
  * @flags:	Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*)
@@ -220,6 +247,7 @@ struct media_entity_operations {
 struct media_entity {
 	struct media_gobj graph_obj;	/* must be first field in struct */
 	const char *name;
+	enum media_entity_type type;
 	u32 function;
 	unsigned long flags;
 
@@ -329,56 +357,29 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
 }
 
 /**
- * is_media_entity_v4l2_io() - identify if the entity main function
- *			       is a V4L2 I/O
- *
+ * is_media_entity_v4l2_io() - Check if the entity is a video_device
  * @entity:	pointer to entity
  *
- * Return: true if the entity main function is one of the V4L2 I/O types
- *	(video, VBI or SDR radio); false otherwise.
+ * Return: true if the entity is an instance of a video_device object and can
+ * safely be cast to a struct video_device using the container_of() macro, or
+ * false otherwise.
  */
 static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
 {
-	if (!entity)
-		return false;
-
-	switch (entity->function) {
-	case MEDIA_ENT_F_IO_V4L:
-	case MEDIA_ENT_F_IO_VBI:
-	case MEDIA_ENT_F_IO_SWRADIO:
-		return true;
-	default:
-		return false;
-	}
+	return entity && entity->type == MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
 }
 
 /**
- * is_media_entity_v4l2_subdev - return true if the entity main function is
- *				 associated with the V4L2 API subdev usage
- *
+ * is_media_entity_v4l2_subdev() - Check if the entity is a v4l2_subdev
  * @entity:	pointer to entity
  *
- * This is an ancillary function used by subdev-based V4L2 drivers.
- * It checks if the entity function is one of functions used by a V4L2 subdev,
- * e. g. camera-relatef functions, analog TV decoder, TV tuner, V4L2 DSPs.
+ * Return: true if the entity is an instance of a v4l2_subdev object and can
+ * safely be cast to a struct v4l2_subdev using the container_of() macro, or
+ * false otherwise.
  */
 static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
 {
-	if (!entity)
-		return false;
-
-	switch (entity->function) {
-	case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
-	case MEDIA_ENT_F_CAM_SENSOR:
-	case MEDIA_ENT_F_FLASH:
-	case MEDIA_ENT_F_LENS:
-	case MEDIA_ENT_F_ATV_DECODER:
-	case MEDIA_ENT_F_TUNER:
-		return true;
-
-	default:
-		return false;
-	}
+	return entity && entity->type == MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
 }
 
 /**
-- 
2.4.10


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

* [PATCH v4 4/4] media: Rename is_media_entity_v4l2_io to is_media_entity_v4l2_video_device
  2016-03-04 20:18 [PATCH v4 0/4] media: Add entity types Laurent Pinchart
                   ` (2 preceding siblings ...)
  2016-03-04 20:18 ` [PATCH v4 3/4] media: Add type field to struct media_entity Laurent Pinchart
@ 2016-03-04 20:18 ` Laurent Pinchart
  2016-03-05 12:07 ` [PATCH v4 0/4] media: Add entity types Sakari Ailus
  4 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2016-03-04 20:18 UTC (permalink / raw)
  To: linux-media; +Cc: Sakari Ailus, Hans Verkuil, Mauro Carvalho Chehab

All users of is_media_entity_v4l2_io() (the exynos4-is, omap3isp,
davince_vpfe and omap4iss drivers and the v4l2-mc power management code)
use the function to check whether entities are video_device instances,
either to ensure they can cast the entity to a struct video_device, or
to count the number of video nodes users.

The purpose of the function is thus to identify whether the media entity
instance is an instance of the video_device object, not to check whether
it can perform I/O. Rename it accordingly, we will introduce a more
specific is_media_entity_v4l2_io() check when needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/exynos4-is/media-dev.c   | 4 ++--
 drivers/media/platform/omap3isp/ispvideo.c      | 2 +-
 drivers/media/v4l2-core/v4l2-mc.c               | 2 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +-
 drivers/staging/media/omap4iss/iss_video.c      | 2 +-
 include/media/media-entity.h                    | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Prabhakar Lad <prabhakar.csengg@gmail.com>

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index feb521f28e14..9a377d9dd58a 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -1130,7 +1130,7 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable,
 	media_entity_graph_walk_start(graph, entity);
 
 	while ((entity = media_entity_graph_walk_next(graph))) {
-		if (!is_media_entity_v4l2_io(entity))
+		if (!is_media_entity_v4l2_video_device(entity))
 			continue;
 
 		ret  = __fimc_md_modify_pipeline(entity, enable);
@@ -1145,7 +1145,7 @@ err:
 	media_entity_graph_walk_start(graph, entity_err);
 
 	while ((entity_err = media_entity_graph_walk_next(graph))) {
-		if (!is_media_entity_v4l2_io(entity_err))
+		if (!is_media_entity_v4l2_video_device(entity_err))
 			continue;
 
 		__fimc_md_modify_pipeline(entity_err, !enable);
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index ac76d2901501..1b1a95d546f6 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -251,7 +251,7 @@ static int isp_video_get_graph_data(struct isp_video *video,
 		if (entity == &video->video.entity)
 			continue;
 
-		if (!is_media_entity_v4l2_io(entity))
+		if (!is_media_entity_v4l2_video_device(entity))
 			continue;
 
 		__video = to_isp_video(media_entity_to_video_device(entity));
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 7291018cf1bf..1ce68c92b397 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -279,7 +279,7 @@ static int pipeline_pm_use_count(struct media_entity *entity,
 	media_entity_graph_walk_start(graph, entity);
 
 	while ((entity = media_entity_graph_walk_next(graph))) {
-		if (is_media_entity_v4l2_io(entity))
+		if (is_media_entity_v4l2_video_device(entity))
 			use += entity->use_count;
 	}
 
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index db49af90217e..7d8fa34f31f3 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -154,7 +154,7 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
 	while ((entity = media_entity_graph_walk_next(&graph))) {
 		if (entity == &video->video_dev.entity)
 			continue;
-		if (!is_media_entity_v4l2_io(entity))
+		if (!is_media_entity_v4l2_video_device(entity))
 			continue;
 		far_end = to_vpfe_video(media_entity_to_video_device(entity));
 		if (far_end->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index f54349bce4de..cf8da23558bb 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -223,7 +223,7 @@ iss_video_far_end(struct iss_video *video)
 		if (entity == &video->video.entity)
 			continue;
 
-		if (!is_media_entity_v4l2_io(entity))
+		if (!is_media_entity_v4l2_video_device(entity))
 			continue;
 
 		far_end = to_iss_video(media_entity_to_video_device(entity));
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index d148fc49c3be..0c485927622f 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -357,14 +357,14 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
 }
 
 /**
- * is_media_entity_v4l2_io() - Check if the entity is a video_device
+ * is_media_entity_v4l2_video_device() - Check if the entity is a video_device
  * @entity:	pointer to entity
  *
  * Return: true if the entity is an instance of a video_device object and can
  * safely be cast to a struct video_device using the container_of() macro, or
  * false otherwise.
  */
-static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
+static inline bool is_media_entity_v4l2_video_device(struct media_entity *entity)
 {
 	return entity && entity->type == MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
 }
-- 
2.4.10


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

* Re: [PATCH v4 0/4] media: Add entity types
  2016-03-04 20:18 [PATCH v4 0/4] media: Add entity types Laurent Pinchart
                   ` (3 preceding siblings ...)
  2016-03-04 20:18 ` [PATCH v4 4/4] media: Rename is_media_entity_v4l2_io to is_media_entity_v4l2_video_device Laurent Pinchart
@ 2016-03-05 12:07 ` Sakari Ailus
  4 siblings, 0 replies; 8+ messages in thread
From: Sakari Ailus @ 2016-03-05 12:07 UTC (permalink / raw)
  To: Laurent Pinchart, linux-media; +Cc: Hans Verkuil, Mauro Carvalho Chehab

Laurent Pinchart wrote:
> Hello,
>
> This patch series adds a type field to the media entity structure. It is a
> resend of v3 rebased on top of the latest media master branch, with acks
> collected and spelling mistakes fixed. I have dropped patches 5 to 7 as they
> don't depend on 1-4 and Hans would like to get them merged through his tree,
> and patch 8 as is adds a function that currently has no user.
>
> Let's start with a few words about what types are and are not. The purpose of
> the entity type is to identify the object type that implements the entity, in
> order to safely cast the entity to that object (using container_of()). Three
> types are currently defined, for media entities that are instantiated as such
> (MEDIA_ENTITY_TYPE_MEDIA_ENTITY), embedded in a struct video_device
> (MEDIA_ENTITY_TYPE_VIDEO_DEVICE) or embedded in a struct v4l2_subdev
> (MEDIA_ENTITY_TYPE_V4L2_SUBDEV). The naming is pretty straightforward and
> self-explicit.
>
> Types do not convey any additional information. They don't tell anything about
> the features of the entity or the object that implements it. In particular
> they don't report capabilities of video_device instances, which is why the
> is_media_entity_v4l2_io() function performs additional checks on the video
> device capabilities field, after verifying with the type that it can safely be
> cast to a video_device instance.
>
> The series start by two cleanup patches (1/8 and 2/8) that fix incorrect or
> unneeded usage of the is_media_entity_v4l2_*() functions in the vsp1 and
> exynos4-is drivers. Patch 3/8 then adds the type field to the media_entity
> structure and updates the is_media_entity_v4l2_*() functions implementations.
> Patch 4/8 renames is_media_entity_v4l2_io() to
> is_media_entity_v4l2_video_device() to clarify its purpose.
>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Cc: Prabhakar Lad <prabhakar.csengg@gmail.com>
>
> Laurent Pinchart (4):
>    v4l: vsp1: Check if an entity is a subdev with the right function
>    v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links
>    media: Add type field to struct media_entity
>    media: Rename is_media_entity_v4l2_io to
>      is_media_entity_v4l2_video_device
>
>   drivers/media/platform/exynos4-is/fimc-lite.c   | 12 +---
>   drivers/media/platform/exynos4-is/media-dev.c   |  4 +-
>   drivers/media/platform/omap3isp/ispvideo.c      |  2 +-
>   drivers/media/platform/vsp1/vsp1_video.c        |  2 +-
>   drivers/media/v4l2-core/v4l2-dev.c              |  1 +
>   drivers/media/v4l2-core/v4l2-mc.c               |  2 +-
>   drivers/media/v4l2-core/v4l2-subdev.c           |  1 +
>   drivers/staging/media/davinci_vpfe/vpfe_video.c |  2 +-
>   drivers/staging/media/omap4iss/iss_video.c      |  2 +-
>   include/media/media-entity.h                    | 77 +++++++++++++------------
>   10 files changed, 50 insertions(+), 55 deletions(-)
>

For patches 1, 3 and 4:

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
sakari.ailus@linux.intel.com

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

* Re: [PATCH v4 3/4] media: Add type field to struct media_entity
  2016-03-04 20:18 ` [PATCH v4 3/4] media: Add type field to struct media_entity Laurent Pinchart
@ 2016-03-05 12:55   ` Mauro Carvalho Chehab
  2016-03-10  7:01     ` Sakari Ailus
  0 siblings, 1 reply; 8+ messages in thread
From: Mauro Carvalho Chehab @ 2016-03-05 12:55 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, Sakari Ailus, Hans Verkuil

Em Fri,  4 Mar 2016 22:18:50 +0200
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> escreveu:

> Code that processes media entities can require knowledge of the
> structure type that embeds a particular media entity instance in order
> to cast the entity to the proper object type. This needs is shown by the
> presence of the is_media_entity_v4l2_io and is_media_entity_v4l2_subdev
> functions.
> 
> The implementation of those two functions relies on the entity function
> field, which is both a wrong and an inefficient design, 

I agree with Sakari here: it is not wrong, just risky when new types
are added.

Btw, I still don't like using "type" here. People that didn't read
all those boring MC discussions will be confused, as we're removing
"type" in one version, and re-introducing it again with a very
different meaning.

What we're really doing here is to "flag" when the entity is a subdev
or when the entity is a V4L I/O entity. Also, one thing that bothers me
is that this is very subsystem-specific. See more below.

> without even
> mentioning the maintenance issue involved in updating the functions
> every time a new entity function is added. Fix this by adding add a type
> field to the media entity structure to carry the information.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/v4l2-core/v4l2-dev.c    |  1 +
>  drivers/media/v4l2-core/v4l2-subdev.c |  1 +
>  include/media/media-entity.h          | 75 ++++++++++++++++++-----------------
>  3 files changed, 40 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index d8e5994cccf1..7e766a92e3d9 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -735,6 +735,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>  	if (!vdev->v4l2_dev->mdev)
>  		return 0;
>  
> +	vdev->entity.type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
>  	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
>  
>  	switch (type) {
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index d63083803144..bb6e79f14bb8 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -584,6 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
>  	sd->host_priv = NULL;
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	sd->entity.name = sd->name;
> +	sd->entity.type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
>  	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
>  #endif
>  }
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 6dc9e4e8cbd4..d148fc49c3be 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -188,10 +188,37 @@ struct media_entity_operations {
>  };
>  
>  /**
> + * enum media_entity_type - Media entity type
> + *
> + * @MEDIA_ENTITY_TYPE_MEDIA_ENTITY:
> + *	The entity is a struct media_entity instance.

All entities are a media_entity instance. This doesn't make sense!

> + * @MEDIA_ENTITY_TYPE_VIDEO_DEVICE:
> + *	The entity is a struct video_device instance.
> + * @MEDIA_ENTITY_TYPE_V4L2_SUBDEV:
> + *	The entity is a struct v4l2_subdev instance.
> + *
> + * The entity type identifies the type of the object instance that implements
> + * the struct media_entity instance. This allows runtime type identification of
> + * media entities and safe casting to the project object type. For instance, a
> + * media entity structure instance embedded in a v4l2_subdev structure instance
> + * will have the type MEDIA_ENTITY_TYPE_V4L2_SUBDEV and can safely be cast to a
> + * v4l2_subdev structure using the container_of() macro.
> + *
> + * Media entities can be instantiated without creating any derived object type,
> + * in which case their type will be MEDIA_ENTITY_TYPE_MEDIA_ENTITY.
> + */
> +enum media_entity_type {
> +	MEDIA_ENTITY_TYPE_MEDIA_ENTITY,
> +	MEDIA_ENTITY_TYPE_VIDEO_DEVICE,
> +	MEDIA_ENTITY_TYPE_V4L2_SUBDEV,
> +};
> +
> +/**
>   * struct media_entity - A media entity graph object.
>   *
>   * @graph_obj:	Embedded structure containing the media object common data.
>   * @name:	Entity name.
> + * @type:	Type of the object that implements the media_entity.
>   * @function:	Entity main function, as defined in uapi/media.h
>   *		(MEDIA_ENT_F_*)
>   * @flags:	Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*)
> @@ -220,6 +247,7 @@ struct media_entity_operations {
>  struct media_entity {
>  	struct media_gobj graph_obj;	/* must be first field in struct */
>  	const char *name;
> +	enum media_entity_type type;
>  	u32 function;
>  	unsigned long flags;
>  
> @@ -329,56 +357,29 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
>  }
>  
>  /**
> - * is_media_entity_v4l2_io() - identify if the entity main function
> - *			       is a V4L2 I/O
> - *
> + * is_media_entity_v4l2_io() - Check if the entity is a video_device
>   * @entity:	pointer to entity
>   *
> - * Return: true if the entity main function is one of the V4L2 I/O types
> - *	(video, VBI or SDR radio); false otherwise.
> + * Return: true if the entity is an instance of a video_device object and can
> + * safely be cast to a struct video_device using the container_of() macro, or
> + * false otherwise.
>   */
>  static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
>  {
> -	if (!entity)
> -		return false;
> -
> -	switch (entity->function) {
> -	case MEDIA_ENT_F_IO_V4L:
> -	case MEDIA_ENT_F_IO_VBI:
> -	case MEDIA_ENT_F_IO_SWRADIO:
> -		return true;
> -	default:
> -		return false;
> -	}
> +	return entity && entity->type == MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
>  }
>  
>  /**
> - * is_media_entity_v4l2_subdev - return true if the entity main function is
> - *				 associated with the V4L2 API subdev usage
> - *
> + * is_media_entity_v4l2_subdev() - Check if the entity is a v4l2_subdev
>   * @entity:	pointer to entity
>   *
> - * This is an ancillary function used by subdev-based V4L2 drivers.
> - * It checks if the entity function is one of functions used by a V4L2 subdev,
> - * e. g. camera-relatef functions, analog TV decoder, TV tuner, V4L2 DSPs.
> + * Return: true if the entity is an instance of a v4l2_subdev object and can
> + * safely be cast to a struct v4l2_subdev using the container_of() macro, or
> + * false otherwise.
>   */
>  static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
>  {
> -	if (!entity)
> -		return false;
> -
> -	switch (entity->function) {
> -	case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
> -	case MEDIA_ENT_F_CAM_SENSOR:
> -	case MEDIA_ENT_F_FLASH:
> -	case MEDIA_ENT_F_LENS:
> -	case MEDIA_ENT_F_ATV_DECODER:
> -	case MEDIA_ENT_F_TUNER:
> -		return true;
> -
> -	default:
> -		return false;
> -	}
> +	return entity && entity->type == MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
>  }
>  
>  /**

When I wrote the ENUM_ENTITIES compat code and deciding what would
be the best approach, it occurred to me that, for us to be able to
remove major,minor from entity, the best way would be to "taint"
the entities that have a 1:1 map with an interface, like:

	- I/O nodes;
	- subdevs (when CONFIG_VIDEO_V4L2_SUBDEV_API=y);
	- ALSA mixer.

So, I was actually thinking that, instead of entity-type, we should
an internal flag to mark those internal "caps" attributes.

So, I guess we should really call this as entity->taint, entity->quirk
or entity->internal_flag or entity->caps instead. For now, I'll call
it "caps". 

by adding "caps", this field can be a way more flexible, and may
be used for the needs on other subsystems too.

By implementing it as a "caps" flag, the part of the code at
media_device_enum_entities() on a patch dropping major and
minor from struct media_entity would be like:

	if (ent->caps & ENTITY_HAS_DEVNODE) {
		media_device_for_each_link(link, mdev) {
			if (link->sink == ent) {
				struct media_intf_devnode *devnode;

	                        devnode = intf_to_devnode(intf);

				u_ent.dev.major = devnode->major; 
				u_ent.dev.minor = devnode->minor; 
			}
		}
	}


This will also remove the need of touching at 
video_register_media_controller(), with seems pretty much useless
so far. Just v4l2_subdev_init() will set "caps" to:
	ENTITY_IS_V4L2_SUBDEV

Regards,
Mauro

PS.: patches 1 and 2 of this series are OK. I applied them
already.

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

* Re: [PATCH v4 3/4] media: Add type field to struct media_entity
  2016-03-05 12:55   ` Mauro Carvalho Chehab
@ 2016-03-10  7:01     ` Sakari Ailus
  0 siblings, 0 replies; 8+ messages in thread
From: Sakari Ailus @ 2016-03-10  7:01 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart; +Cc: linux-media, Hans Verkuil

Hi Mauro and Laurent,

Mauro Carvalho Chehab wrote:
> Em Fri,  4 Mar 2016 22:18:50 +0200
> Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> escreveu:
>
>> Code that processes media entities can require knowledge of the
>> structure type that embeds a particular media entity instance in order
>> to cast the entity to the proper object type. This needs is shown by the
>> presence of the is_media_entity_v4l2_io and is_media_entity_v4l2_subdev
>> functions.
>>
>> The implementation of those two functions relies on the entity function
>> field, which is both a wrong and an inefficient design,
>
> I agree with Sakari here: it is not wrong, just risky when new types
> are added.
>
> Btw, I still don't like using "type" here. People that didn't read
> all those boring MC discussions will be confused, as we're removing
> "type" in one version, and re-introducing it again with a very
> different meaning.
>
> What we're really doing here is to "flag" when the entity is a subdev
> or when the entity is a V4L I/O entity. Also, one thing that bothers me
> is that this is very subsystem-specific. See more below.

What the field is really telling is what kind of object embeds the
media_entity struct. How about using another name for the field, to
distinguish it from the previous type field? object_type, for instance.

>
>> without even
>> mentioning the maintenance issue involved in updating the functions
>> every time a new entity function is added. Fix this by adding add a type
>> field to the media entity structure to carry the information.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
>> ---
>>   drivers/media/v4l2-core/v4l2-dev.c    |  1 +
>>   drivers/media/v4l2-core/v4l2-subdev.c |  1 +
>>   include/media/media-entity.h          | 75 ++++++++++++++++++-----------------
>>   3 files changed, 40 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
>> index d8e5994cccf1..7e766a92e3d9 100644
>> --- a/drivers/media/v4l2-core/v4l2-dev.c
>> +++ b/drivers/media/v4l2-core/v4l2-dev.c
>> @@ -735,6 +735,7 @@ static int video_register_media_controller(struct video_device *vdev, int type)
>>   	if (!vdev->v4l2_dev->mdev)
>>   		return 0;
>>
>> +	vdev->entity.type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
>>   	vdev->entity.function = MEDIA_ENT_F_UNKNOWN;
>>
>>   	switch (type) {
>> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
>> index d63083803144..bb6e79f14bb8 100644
>> --- a/drivers/media/v4l2-core/v4l2-subdev.c
>> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
>> @@ -584,6 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
>>   	sd->host_priv = NULL;
>>   #if defined(CONFIG_MEDIA_CONTROLLER)
>>   	sd->entity.name = sd->name;
>> +	sd->entity.type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
>>   	sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
>>   #endif
>>   }
>> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
>> index 6dc9e4e8cbd4..d148fc49c3be 100644
>> --- a/include/media/media-entity.h
>> +++ b/include/media/media-entity.h
>> @@ -188,10 +188,37 @@ struct media_entity_operations {
>>   };
>>
>>   /**
>> + * enum media_entity_type - Media entity type
>> + *
>> + * @MEDIA_ENTITY_TYPE_MEDIA_ENTITY:
>> + *	The entity is a struct media_entity instance.
>
> All entities are a media_entity instance. This doesn't make sense!

Can a media_entity exist without being something else as well? Would
that even make sense?

Should this be either invalid, or the documentation to be changed that
the media_entity is not embedded in any other object?
media_device_register_entity() should check the value.

>
>> + * @MEDIA_ENTITY_TYPE_VIDEO_DEVICE:
>> + *	The entity is a struct video_device instance.
>> + * @MEDIA_ENTITY_TYPE_V4L2_SUBDEV:
>> + *	The entity is a struct v4l2_subdev instance.
>> + *
>> + * The entity type identifies the type of the object instance that implements
>> + * the struct media_entity instance. This allows runtime type identification of
>> + * media entities and safe casting to the project object type. For instance, a
>> + * media entity structure instance embedded in a v4l2_subdev structure instance
>> + * will have the type MEDIA_ENTITY_TYPE_V4L2_SUBDEV and can safely be cast to a
>> + * v4l2_subdev structure using the container_of() macro.
>> + *
>> + * Media entities can be instantiated without creating any derived object type,
>> + * in which case their type will be MEDIA_ENTITY_TYPE_MEDIA_ENTITY.
>> + */
>> +enum media_entity_type {
>> +	MEDIA_ENTITY_TYPE_MEDIA_ENTITY,
>> +	MEDIA_ENTITY_TYPE_VIDEO_DEVICE,
>> +	MEDIA_ENTITY_TYPE_V4L2_SUBDEV,
>> +};
>> +
>> +/**
>>    * struct media_entity - A media entity graph object.
>>    *
>>    * @graph_obj:	Embedded structure containing the media object common data.
>>    * @name:	Entity name.
>> + * @type:	Type of the object that implements the media_entity.
>>    * @function:	Entity main function, as defined in uapi/media.h
>>    *		(MEDIA_ENT_F_*)
>>    * @flags:	Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*)
>> @@ -220,6 +247,7 @@ struct media_entity_operations {
>>   struct media_entity {
>>   	struct media_gobj graph_obj;	/* must be first field in struct */
>>   	const char *name;
>> +	enum media_entity_type type;
>>   	u32 function;
>>   	unsigned long flags;
>>
>> @@ -329,56 +357,29 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
>>   }
>>
>>   /**
>> - * is_media_entity_v4l2_io() - identify if the entity main function
>> - *			       is a V4L2 I/O
>> - *
>> + * is_media_entity_v4l2_io() - Check if the entity is a video_device
>>    * @entity:	pointer to entity
>>    *
>> - * Return: true if the entity main function is one of the V4L2 I/O types
>> - *	(video, VBI or SDR radio); false otherwise.
>> + * Return: true if the entity is an instance of a video_device object and can
>> + * safely be cast to a struct video_device using the container_of() macro, or
>> + * false otherwise.
>>    */
>>   static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
>>   {
>> -	if (!entity)
>> -		return false;
>> -
>> -	switch (entity->function) {
>> -	case MEDIA_ENT_F_IO_V4L:
>> -	case MEDIA_ENT_F_IO_VBI:
>> -	case MEDIA_ENT_F_IO_SWRADIO:
>> -		return true;
>> -	default:
>> -		return false;
>> -	}
>> +	return entity && entity->type == MEDIA_ENTITY_TYPE_VIDEO_DEVICE;
>>   }
>>
>>   /**
>> - * is_media_entity_v4l2_subdev - return true if the entity main function is
>> - *				 associated with the V4L2 API subdev usage
>> - *
>> + * is_media_entity_v4l2_subdev() - Check if the entity is a v4l2_subdev
>>    * @entity:	pointer to entity
>>    *
>> - * This is an ancillary function used by subdev-based V4L2 drivers.
>> - * It checks if the entity function is one of functions used by a V4L2 subdev,
>> - * e. g. camera-relatef functions, analog TV decoder, TV tuner, V4L2 DSPs.
>> + * Return: true if the entity is an instance of a v4l2_subdev object and can
>> + * safely be cast to a struct v4l2_subdev using the container_of() macro, or
>> + * false otherwise.
>>    */
>>   static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
>>   {
>> -	if (!entity)
>> -		return false;
>> -
>> -	switch (entity->function) {
>> -	case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
>> -	case MEDIA_ENT_F_CAM_SENSOR:
>> -	case MEDIA_ENT_F_FLASH:
>> -	case MEDIA_ENT_F_LENS:
>> -	case MEDIA_ENT_F_ATV_DECODER:
>> -	case MEDIA_ENT_F_TUNER:
>> -		return true;
>> -
>> -	default:
>> -		return false;
>> -	}
>> +	return entity && entity->type == MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
>>   }
>>
>>   /**
>
> When I wrote the ENUM_ENTITIES compat code and deciding what would
> be the best approach, it occurred to me that, for us to be able to
> remove major,minor from entity, the best way would be to "taint"
> the entities that have a 1:1 map with an interface, like:

I think this is a separate problem. It should be solved as well, but not
necessarily in this patchset and certainly not in this patch. The
purpose of this patch, as far as I understand, is to ensure correct use
of container_of() macro in order to obtain the object where the media
entity is embedded in. A lot of drivers (and the V4L2 sub-device
framework) depend on that currently.

>
> 	- I/O nodes;
> 	- subdevs (when CONFIG_VIDEO_V4L2_SUBDEV_API=y);
> 	- ALSA mixer.
>
> So, I was actually thinking that, instead of entity-type, we should
> an internal flag to mark those internal "caps" attributes.
>
> So, I guess we should really call this as entity->taint, entity->quirk
> or entity->internal_flag or entity->caps instead. For now, I'll call
> it "caps".
>
> by adding "caps", this field can be a way more flexible, and may
> be used for the needs on other subsystems too.
>
> By implementing it as a "caps" flag, the part of the code at
> media_device_enum_entities() on a patch dropping major and
> minor from struct media_entity would be like:
>
> 	if (ent->caps & ENTITY_HAS_DEVNODE) {
> 		media_device_for_each_link(link, mdev) {
> 			if (link->sink == ent) {
> 				struct media_intf_devnode *devnode;
>
> 	                        devnode = intf_to_devnode(intf);
>
> 				u_ent.dev.major = devnode->major;
> 				u_ent.dev.minor = devnode->minor;
> 			}
> 		}
> 	}
>
>
> This will also remove the need of touching at
> video_register_media_controller(), with seems pretty much useless
> so far. Just v4l2_subdev_init() will set "caps" to:
> 	ENTITY_IS_V4L2_SUBDEV
>
> Regards,
> Mauro
>
> PS.: patches 1 and 2 of this series are OK. I applied them
> already.
>


-- 
Kind regards,

Sakari Ailus
sakari.ailus@linux.intel.com

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

end of thread, other threads:[~2016-03-10  7:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04 20:18 [PATCH v4 0/4] media: Add entity types Laurent Pinchart
2016-03-04 20:18 ` [PATCH v4 1/4] v4l: vsp1: Check if an entity is a subdev with the right function Laurent Pinchart
2016-03-04 20:18 ` [PATCH v4 2/4] v4l: exynos4-is: Drop unneeded check when setting up fimc-lite links Laurent Pinchart
2016-03-04 20:18 ` [PATCH v4 3/4] media: Add type field to struct media_entity Laurent Pinchart
2016-03-05 12:55   ` Mauro Carvalho Chehab
2016-03-10  7:01     ` Sakari Ailus
2016-03-04 20:18 ` [PATCH v4 4/4] media: Rename is_media_entity_v4l2_io to is_media_entity_v4l2_video_device Laurent Pinchart
2016-03-05 12:07 ` [PATCH v4 0/4] media: Add entity types Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.