diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2009-12-09 08:40:08 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 04:53:20 -0300 |
commit | 61f5db549dde43fb91a8b337f3a4096e4076c2d9 (patch) | |
tree | 0c28bb9dd1aab1b3fc8ce61036677a7790316421 /drivers/media/video/v4l2-subdev.c | |
parent | 2c0ab67be1b4197a4effac89bb0604832e38be8d (diff) | |
download | blackbird-op-linux-61f5db549dde43fb91a8b337f3a4096e4076c2d9.tar.gz blackbird-op-linux-61f5db549dde43fb91a8b337f3a4096e4076c2d9.zip |
[media] v4l: Make v4l2_subdev inherit from media_entity
V4L2 subdevices are media entities. As such they need to inherit from
(include) the media_entity structure.
When registering/unregistering the subdevice, the media entity is
automatically registered/unregistered. The entity is acquired on device
open and released on device close.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-subdev.c')
-rw-r--r-- | drivers/media/video/v4l2-subdev.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c index 0c67f5a278fb..85573638aa1e 100644 --- a/drivers/media/video/v4l2-subdev.c +++ b/drivers/media/video/v4l2-subdev.c @@ -35,7 +35,10 @@ static int subdev_open(struct file *file) { struct video_device *vdev = video_devdata(file); struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); - struct v4l2_fh *vfh; +#if defined(CONFIG_MEDIA_CONTROLLER) + struct media_entity *entity; +#endif + struct v4l2_fh *vfh = NULL; int ret; if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) { @@ -58,11 +61,20 @@ static int subdev_open(struct file *file) v4l2_fh_add(vfh); file->private_data = vfh; } - +#if defined(CONFIG_MEDIA_CONTROLLER) + if (sd->v4l2_dev->mdev) { + entity = media_entity_get(&sd->entity); + if (!entity) { + ret = -EBUSY; + goto err; + } + } +#endif return 0; err: if (vfh != NULL) { + v4l2_fh_del(vfh); v4l2_fh_exit(vfh); kfree(vfh); } @@ -72,8 +84,16 @@ err: static int subdev_close(struct file *file) { +#if defined(CONFIG_MEDIA_CONTROLLER) + struct video_device *vdev = video_devdata(file); + struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); +#endif struct v4l2_fh *vfh = file->private_data; +#if defined(CONFIG_MEDIA_CONTROLLER) + if (sd->v4l2_dev->mdev) + media_entity_put(&sd->entity); +#endif if (vfh != NULL) { v4l2_fh_del(vfh); v4l2_fh_exit(vfh); @@ -172,5 +192,9 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) sd->grp_id = 0; sd->dev_priv = NULL; sd->host_priv = NULL; +#if defined(CONFIG_MEDIA_CONTROLLER) + sd->entity.name = sd->name; + sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; +#endif } EXPORT_SYMBOL(v4l2_subdev_init); |