aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2009-12-09 06:40:10 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 03:53:19 -0400
commit2c0ab67be1b4197a4effac89bb0604832e38be8d (patch)
tree033b1d2c6ae25e05f1f46f3c2e7bdb504c359ad3 /Documentation
parent95db3a60e0652a52df145aacade1a88c5acef659 (diff)
[media] v4l: Make video_device inherit from media_entity
V4L2 devices are media entities. As such they need to inherit from (include) the media_entity structure. When registering/unregistering the device, 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 'Documentation')
-rw-r--r--Documentation/video4linux/v4l2-framework.txt38
1 files changed, 35 insertions, 3 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 7de55cfae04e..062708169def 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -71,6 +71,10 @@ sub-device instances, the video_device struct stores V4L2 device node data
71and in the future a v4l2_fh struct will keep track of filehandle instances 71and in the future a v4l2_fh struct will keep track of filehandle instances
72(this is not yet implemented). 72(this is not yet implemented).
73 73
74The V4L2 framework also optionally integrates with the media framework. If a
75driver sets the struct v4l2_device mdev field, sub-devices and video nodes
76will automatically appear in the media framework as entities.
77
74 78
75struct v4l2_device 79struct v4l2_device
76------------------ 80------------------
@@ -84,11 +88,14 @@ You must register the device instance:
84 v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev); 88 v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
85 89
86Registration will initialize the v4l2_device struct. If the dev->driver_data 90Registration will initialize the v4l2_device struct. If the dev->driver_data
87field is NULL, it will be linked to v4l2_dev. Drivers that use the media 91field is NULL, it will be linked to v4l2_dev.
88device framework in addition to the V4L2 framework need to set 92
93Drivers that want integration with the media device framework need to set
89dev->driver_data manually to point to the driver-specific device structure 94dev->driver_data manually to point to the driver-specific device structure
90that embed the struct v4l2_device instance. This is achieved by a 95that embed the struct v4l2_device instance. This is achieved by a
91dev_set_drvdata() call before registering the V4L2 device instance. 96dev_set_drvdata() call before registering the V4L2 device instance. They must
97also set the struct v4l2_device mdev field to point to a properly initialized
98and registered media_device instance.
92 99
93If v4l2_dev->name is empty then it will be set to a value derived from dev 100If v4l2_dev->name is empty then it will be set to a value derived from dev
94(driver name followed by the bus_id, to be precise). If you set it up before 101(driver name followed by the bus_id, to be precise). If you set it up before
@@ -530,6 +537,21 @@ If you use v4l2_ioctl_ops, then you should set either .unlocked_ioctl or
530The v4l2_file_operations struct is a subset of file_operations. The main 537The v4l2_file_operations struct is a subset of file_operations. The main
531difference is that the inode argument is omitted since it is never used. 538difference is that the inode argument is omitted since it is never used.
532 539
540If integration with the media framework is needed, you must initialize the
541media_entity struct embedded in the video_device struct (entity field) by
542calling media_entity_init():
543
544 struct media_pad *pad = &my_vdev->pad;
545 int err;
546
547 err = media_entity_init(&vdev->entity, 1, pad, 0);
548
549The pads array must have been previously initialized. There is no need to
550manually set the struct media_entity type and name fields.
551
552A reference to the entity will be automatically acquired/released when the
553video device is opened/closed.
554
533v4l2_file_operations and locking 555v4l2_file_operations and locking
534-------------------------------- 556--------------------------------
535 557
@@ -559,6 +581,9 @@ for you.
559 return err; 581 return err;
560 } 582 }
561 583
584If the v4l2_device parent device has a non-NULL mdev field, the video device
585entity will be automatically registered with the media device.
586
562Which device is registered depends on the type argument. The following 587Which device is registered depends on the type argument. The following
563types exist: 588types exist:
564 589
@@ -634,6 +659,13 @@ release, of course) will return an error as well.
634When the last user of the video device node exits, then the vdev->release() 659When the last user of the video device node exits, then the vdev->release()
635callback is called and you can do the final cleanup there. 660callback is called and you can do the final cleanup there.
636 661
662Don't forget to cleanup the media entity associated with the video device if
663it has been initialized:
664
665 media_entity_cleanup(&vdev->entity);
666
667This can be done from the release callback.
668
637 669
638video_device helper functions 670video_device helper functions
639----------------------------- 671-----------------------------