aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/video4linux
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@maxwell.research.nokia.com>2010-03-20 17:28:48 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:58:05 -0400
commit6cd84b78edc6f35b01603f85d8769cbb6c568306 (patch)
treedf3f3c72b5fdd14bf580c691e604f9ec5b0d9364 /Documentation/video4linux
parent1babcb460f2b87c20eb6860b9685a0dab636cc4b (diff)
V4L/DVB: V4L: File handles: Add documentation
Add documentation on using V4L2 file handles (v4l2_fh) in V4L2 drivers. Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/video4linux')
-rw-r--r--Documentation/video4linux/v4l2-framework.txt72
1 files changed, 72 insertions, 0 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 5b9205a17ae7..48f0adfbc984 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -608,3 +608,75 @@ scatter/gather method (videobuf-dma-sg), DMA with linear access
608 608
609Please see Documentation/video4linux/videobuf for more information on how 609Please see Documentation/video4linux/videobuf for more information on how
610to use the videobuf layer. 610to use the videobuf layer.
611
612struct v4l2_fh
613--------------
614
615struct v4l2_fh provides a way to easily keep file handle specific data
616that is used by the V4L2 framework. Using v4l2_fh is optional for
617drivers.
618
619The users of v4l2_fh (in the V4L2 framework, not the driver) know
620whether a driver uses v4l2_fh as its file->private_data pointer by
621testing the V4L2_FL_USES_V4L2_FH bit in video_device->flags.
622
623Useful functions:
624
625- v4l2_fh_init()
626
627 Initialise the file handle. This *MUST* be performed in the driver's
628 v4l2_file_operations->open() handler.
629
630- v4l2_fh_add()
631
632 Add a v4l2_fh to video_device file handle list. May be called after
633 initialising the file handle.
634
635- v4l2_fh_del()
636
637 Unassociate the file handle from video_device(). The file handle
638 exit function may now be called.
639
640- v4l2_fh_exit()
641
642 Uninitialise the file handle. After uninitialisation the v4l2_fh
643 memory can be freed.
644
645struct v4l2_fh is allocated as a part of the driver's own file handle
646structure and is set to file->private_data in the driver's open
647function by the driver. Drivers can extract their own file handle
648structure by using the container_of macro. Example:
649
650struct my_fh {
651 int blah;
652 struct v4l2_fh fh;
653};
654
655...
656
657int my_open(struct file *file)
658{
659 struct my_fh *my_fh;
660 struct video_device *vfd;
661 int ret;
662
663 ...
664
665 ret = v4l2_fh_init(&my_fh->fh, vfd);
666 if (ret)
667 return ret;
668
669 v4l2_fh_add(&my_fh->fh);
670
671 file->private_data = &my_fh->fh;
672
673 ...
674}
675
676int my_release(struct file *file)
677{
678 struct v4l2_fh *fh = file->private_data;
679 struct my_fh *my_fh = container_of(fh, struct my_fh, fh);
680
681 ...
682}