aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-dev.h
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-08-23 06:48:38 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:36:54 -0400
commitbfa8a273bb91078ea193ab94c717889928f3b925 (patch)
tree3be9718a35023adec6e87343dc1efce3e60778a8 /include/media/v4l2-dev.h
parent601e9444f249d219009ec05674268d90f6f1cdcb (diff)
V4L/DVB (8787): v4l2-dev: cleanups and add video_drvdata helper function
Cleanup v4l2-dev.[ch], add/improve comments and add a new helper function: video_drvdata() that can get the private driver data from a file struct. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/v4l2-dev.h')
-rw-r--r--include/media/v4l2-dev.h35
1 files changed, 21 insertions, 14 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 1d4df571060b..fb92e3d22d7e 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -9,16 +9,14 @@
9#ifndef _V4L2_DEV_H 9#ifndef _V4L2_DEV_H
10#define _V4L2_DEV_H 10#define _V4L2_DEV_H
11 11
12#define OBSOLETE_DEVDATA 1 /* to be removed soon */
13
14#include <linux/poll.h> 12#include <linux/poll.h>
15#include <linux/fs.h> 13#include <linux/fs.h>
16#include <linux/device.h> 14#include <linux/device.h>
17#include <linux/mutex.h> 15#include <linux/mutex.h>
18#include <linux/compiler.h> /* need __user */
19#include <linux/videodev2.h> 16#include <linux/videodev2.h>
20 17
21#define VIDEO_MAJOR 81 18#define VIDEO_MAJOR 81
19
22/* Minor device allocation */ 20/* Minor device allocation */
23#define MINOR_VFL_TYPE_GRABBER_MIN 0 21#define MINOR_VFL_TYPE_GRABBER_MIN 0
24#define MINOR_VFL_TYPE_GRABBER_MAX 63 22#define MINOR_VFL_TYPE_GRABBER_MAX 63
@@ -71,20 +69,25 @@ struct video_device
71 const struct v4l2_ioctl_ops *ioctl_ops; 69 const struct v4l2_ioctl_ops *ioctl_ops;
72}; 70};
73 71
74/* Class-dev to video-device */ 72/* dev to video-device */
75#define to_video_device(cd) container_of(cd, struct video_device, dev) 73#define to_video_device(cd) container_of(cd, struct video_device, dev)
76 74
77/* Version 2 functions */ 75/* Register and unregister devices. Note that if video_register_device fails,
76 the release() callback of the video_device structure is *not* called, so
77 the caller is responsible for freeing any data. Usually that means that
78 you call video_device_release() on failure. */
78int __must_check video_register_device(struct video_device *vfd, int type, int nr); 79int __must_check video_register_device(struct video_device *vfd, int type, int nr);
79int __must_check video_register_device_index(struct video_device *vfd, int type, int nr, 80int __must_check video_register_device_index(struct video_device *vfd,
80 int index); 81 int type, int nr, int index);
81void video_unregister_device(struct video_device *); 82void video_unregister_device(struct video_device *vfd);
82 83
83/* helper functions to alloc / release struct video_device, the 84/* helper functions to alloc/release struct video_device, the
84 later can be used for video_device->release() */ 85 latter can also be used for video_device->release(). */
85struct video_device * __must_check video_device_alloc(void); 86struct video_device * __must_check video_device_alloc(void);
87
86/* this release function frees the vfd pointer */ 88/* this release function frees the vfd pointer */
87void video_device_release(struct video_device *vfd); 89void video_device_release(struct video_device *vfd);
90
88/* this release function does nothing, use when the video_device is a 91/* this release function does nothing, use when the video_device is a
89 static global struct. Note that having a static video_device is 92 static global struct. Note that having a static video_device is
90 a dubious construction at best. */ 93 a dubious construction at best. */
@@ -101,9 +104,13 @@ static inline void video_set_drvdata(struct video_device *dev, void *data)
101 dev_set_drvdata(&dev->dev, data); 104 dev_set_drvdata(&dev->dev, data);
102} 105}
103 106
104#ifdef OBSOLETE_DEVDATA /* to be removed soon */ 107struct video_device *video_devdata(struct file *file);
105/* Obsolete stuff - Still needed for radio devices and obsolete drivers */ 108
106extern struct video_device* video_devdata(struct file*); 109/* Combine video_get_drvdata and video_devdata as this is
107#endif 110 used very often. */
111static inline void *video_drvdata(struct file *file)
112{
113 return video_get_drvdata(video_devdata(file));
114}
108 115
109#endif /* _V4L2_DEV_H */ 116#endif /* _V4L2_DEV_H */