diff mbox

[2/2,media] v4l2-subdev: create interfaces at MC

Message ID f6907dde703782c98eb67abb48a3409faaebfb61.1440417725.git.mchehab@osg.samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Aug. 24, 2015, 12:03 p.m. UTC
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>

Comments

Hans Verkuil Aug. 28, 2015, 2:19 p.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;