All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] MC next gen: add sub-device interfaces
@ 2015-08-24 12:03 Mauro Carvalho Chehab
  2015-08-24 12:03 ` [PATCH 1/2] [media] media-entity: unregister entity links Mauro Carvalho Chehab
  2015-08-24 12:03 ` [PATCH 2/2] [media] v4l2-subdev: create interfaces at MC Mauro Carvalho Chehab
  0 siblings, 2 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2015-08-24 12:03 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

This patch depends on my MC next gen previous series. It creates
interfaces for V4L2-subdev when the corresponding device nodes
are created.

Mauro Carvalho Chehab (2):
  [media] media-entity: unregister entity links
  [media] v4l2-subdev: create interfaces at MC

 drivers/media/media-entity.c          | 23 +++++++++++++++++++++++
 drivers/media/v4l2-core/v4l2-device.c | 15 +++++++++++++++
 include/media/media-entity.h          |  3 +++
 include/media/v4l2-subdev.h           |  1 +
 4 files changed, 42 insertions(+)

-- 
2.4.3


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

* [PATCH 1/2] [media] media-entity: unregister entity links
  2015-08-24 12:03 [PATCH 0/2] MC next gen: add sub-device interfaces Mauro Carvalho Chehab
@ 2015-08-24 12:03 ` Mauro Carvalho Chehab
  2015-08-28 14:12   ` Hans Verkuil
  2015-08-24 12:03 ` [PATCH 2/2] [media] v4l2-subdev: create interfaces at MC Mauro Carvalho Chehab
  1 sibling, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2015-08-24 12:03 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

Add functions to explicitly unregister all entity links.
This function is called automatically when an entity
link is destroyed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index fc6bb48027ab..7e6fb5a86b21 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -896,6 +896,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create);
 
 void media_devnode_remove(struct media_intf_devnode *devnode)
 {
+	media_remove_intf_links(&devnode->intf);
 	media_gobj_remove(&devnode->intf.graph_obj);
 	kfree(devnode);
 }
@@ -937,3 +938,25 @@ void media_remove_intf_link(struct media_link *link)
 	mutex_unlock(&link->graph_obj.mdev->graph_mutex);
 }
 EXPORT_SYMBOL_GPL(media_remove_intf_link);
+
+void __media_remove_intf_links(struct media_interface *intf)
+{
+	struct media_link *link, *tmp;
+
+	list_for_each_entry_safe(link, tmp, &intf->links, list)
+		media_remove_intf_link(link);
+
+}
+EXPORT_SYMBOL_GPL(__media_remove_intf_links);
+
+void media_remove_intf_links(struct media_interface *intf)
+{
+	/* Do nothing if the intf is not registered. */
+	if (intf->graph_obj.mdev == NULL)
+		return;
+
+	mutex_lock(&intf->graph_obj.mdev->graph_mutex);
+	__media_remove_intf_links(intf);
+	mutex_unlock(&intf->graph_obj.mdev->graph_mutex);
+}
+EXPORT_SYMBOL_GPL(media_remove_intf_links);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index d89ceaf7bcc4..8c26934c97fe 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -318,6 +318,9 @@ struct media_link *media_create_intf_link(struct media_entity *entity,
 					    struct media_interface *intf,
 					    u32 flags);
 void media_remove_intf_link(struct media_link *link);
+void __media_remove_intf_links(struct media_interface *intf);
+void media_remove_intf_links(struct media_interface *intf);
+
 
 #define media_entity_call(entity, operation, args...)			\
 	(((entity)->ops && (entity)->ops->operation) ?			\
-- 
2.4.3


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

* [PATCH 2/2] [media] v4l2-subdev: create interfaces at MC
  2015-08-24 12:03 [PATCH 0/2] MC next gen: add sub-device interfaces Mauro Carvalho Chehab
  2015-08-24 12:03 ` [PATCH 1/2] [media] media-entity: unregister entity links Mauro Carvalho Chehab
@ 2015-08-24 12:03 ` Mauro Carvalho Chehab
  2015-08-28 14:19   ` Hans Verkuil
  1 sibling, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2015-08-24 12:03 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil

Now that the Media Controller has support for interfaces,
create them when v4l-subdev interfaces are created.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 5b0a30b9252b..1e5176c558bf 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -247,8 +247,22 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
 			goto clean_up;
 		}
 #if defined(CONFIG_MEDIA_CONTROLLER)
+		/* Needed just for backward compatibility with legacy MC API */
 		sd->entity.info.dev.major = VIDEO_MAJOR;
 		sd->entity.info.dev.minor = vdev->minor;
+
+		sd->intf_devnode = media_devnode_create(sd->entity.graph_obj.mdev,
+							MEDIA_INTF_T_V4L_SUBDEV,
+							0, VIDEO_MAJOR,
+							vdev->minor,
+							GFP_KERNEL);
+		if (!sd->intf_devnode) {
+			err = -ENOMEM;
+			kfree(vdev);
+			goto clean_up;
+		}
+
+		media_create_intf_link(&sd->entity, &sd->intf_devnode->intf, 0);
 #endif
 		sd->devnode = vdev;
 	}
@@ -286,6 +300,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_devnode_remove(sd->intf_devnode);
 		media_device_unregister_entity(&sd->entity);
 	}
 #endif
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 370fc38c34f1..1aa44f11eeb5 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -584,6 +584,7 @@ struct v4l2_subdev_platform_data {
 struct v4l2_subdev {
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	struct media_entity entity;
+	struct media_intf_devnode *intf_devnode;
 #endif
 	struct list_head list;
 	struct module *owner;
-- 
2.4.3


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

* Re: [PATCH 1/2] [media] media-entity: unregister entity links
  2015-08-24 12:03 ` [PATCH 1/2] [media] media-entity: unregister entity links Mauro Carvalho Chehab
@ 2015-08-28 14:12   ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2015-08-28 14:12 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List; +Cc: Mauro Carvalho Chehab

On 08/24/2015 02:03 PM, Mauro Carvalho Chehab wrote:
> Add functions to explicitly unregister all entity links.
> This function is called automatically when an entity
> link is destroyed.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> index fc6bb48027ab..7e6fb5a86b21 100644
> --- a/drivers/media/media-entity.c
> +++ b/drivers/media/media-entity.c
> @@ -896,6 +896,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create);
>  
>  void media_devnode_remove(struct media_intf_devnode *devnode)
>  {
> +	media_remove_intf_links(&devnode->intf);
>  	media_gobj_remove(&devnode->intf.graph_obj);
>  	kfree(devnode);
>  }
> @@ -937,3 +938,25 @@ void media_remove_intf_link(struct media_link *link)
>  	mutex_unlock(&link->graph_obj.mdev->graph_mutex);
>  }
>  EXPORT_SYMBOL_GPL(media_remove_intf_link);
> +
> +void __media_remove_intf_links(struct media_interface *intf)
> +{
> +	struct media_link *link, *tmp;
> +
> +	list_for_each_entry_safe(link, tmp, &intf->links, list)
> +		media_remove_intf_link(link);
> +
> +}
> +EXPORT_SYMBOL_GPL(__media_remove_intf_links);
> +
> +void media_remove_intf_links(struct media_interface *intf)
> +{
> +	/* Do nothing if the intf is not registered. */
> +	if (intf->graph_obj.mdev == NULL)
> +		return;
> +
> +	mutex_lock(&intf->graph_obj.mdev->graph_mutex);
> +	__media_remove_intf_links(intf);
> +	mutex_unlock(&intf->graph_obj.mdev->graph_mutex);
> +}
> +EXPORT_SYMBOL_GPL(media_remove_intf_links);
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index d89ceaf7bcc4..8c26934c97fe 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -318,6 +318,9 @@ struct media_link *media_create_intf_link(struct media_entity *entity,
>  					    struct media_interface *intf,
>  					    u32 flags);
>  void media_remove_intf_link(struct media_link *link);
> +void __media_remove_intf_links(struct media_interface *intf);
> +void media_remove_intf_links(struct media_interface *intf);
> +
>  
>  #define media_entity_call(entity, operation, args...)			\
>  	(((entity)->ops && (entity)->ops->operation) ?			\
> 


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

* Re: [PATCH 2/2] [media] v4l2-subdev: create interfaces at MC
  2015-08-24 12:03 ` [PATCH 2/2] [media] v4l2-subdev: create interfaces at MC Mauro Carvalho Chehab
@ 2015-08-28 14:19   ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2015-08-28 14:19 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Hans Verkuil

On 08/24/2015 02:03 PM, Mauro Carvalho Chehab wrote:
> Now that the Media Controller has support for interfaces,
> create them when v4l-subdev interfaces are created.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
> index 5b0a30b9252b..1e5176c558bf 100644
> --- a/drivers/media/v4l2-core/v4l2-device.c
> +++ b/drivers/media/v4l2-core/v4l2-device.c
> @@ -247,8 +247,22 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
>  			goto clean_up;
>  		}
>  #if defined(CONFIG_MEDIA_CONTROLLER)
> +		/* Needed just for backward compatibility with legacy MC API */
>  		sd->entity.info.dev.major = VIDEO_MAJOR;
>  		sd->entity.info.dev.minor = vdev->minor;
> +
> +		sd->intf_devnode = media_devnode_create(sd->entity.graph_obj.mdev,
> +							MEDIA_INTF_T_V4L_SUBDEV,
> +							0, VIDEO_MAJOR,
> +							vdev->minor,
> +							GFP_KERNEL);
> +		if (!sd->intf_devnode) {
> +			err = -ENOMEM;
> +			kfree(vdev);
> +			goto clean_up;
> +		}

Why not let __video_register_device() create the interface? It needs to do that
for all other device types as well. That would make much more sense rather than
having subdevs as a weird exception.

> +
> +		media_create_intf_link(&sd->entity, &sd->intf_devnode->intf, 0);

Linking the entity and interface together is the only thing that should happen here.

>  #endif
>  		sd->devnode = vdev;
>  	}
> @@ -286,6 +300,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_devnode_remove(sd->intf_devnode);

This can be removed as well in that case since it will be called from
video_unregister_device().

>  		media_device_unregister_entity(&sd->entity);
>  	}
>  #endif
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 370fc38c34f1..1aa44f11eeb5 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -584,6 +584,7 @@ struct v4l2_subdev_platform_data {
>  struct v4l2_subdev {
>  #if defined(CONFIG_MEDIA_CONTROLLER)
>  	struct media_entity entity;
> +	struct media_intf_devnode *intf_devnode;
>  #endif
>  	struct list_head list;
>  	struct module *owner;
> 

Regards,

	Hans

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

end of thread, other threads:[~2015-08-28 14:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-24 12:03 [PATCH 0/2] MC next gen: add sub-device interfaces Mauro Carvalho Chehab
2015-08-24 12:03 ` [PATCH 1/2] [media] media-entity: unregister entity links Mauro Carvalho Chehab
2015-08-28 14:12   ` Hans Verkuil
2015-08-24 12:03 ` [PATCH 2/2] [media] v4l2-subdev: create interfaces at MC Mauro Carvalho Chehab
2015-08-28 14:19   ` Hans Verkuil

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.