diff options
Diffstat (limited to 'include/media/v4l2-dev.h')
-rw-r--r-- | include/media/v4l2-dev.h | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index a0a6b41c5e09..e36faab8459b 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -25,6 +25,25 @@ | |||
25 | #define VFL_TYPE_MAX 4 | 25 | #define VFL_TYPE_MAX 4 |
26 | 26 | ||
27 | struct v4l2_ioctl_callbacks; | 27 | struct v4l2_ioctl_callbacks; |
28 | struct video_device; | ||
29 | struct v4l2_device; | ||
30 | |||
31 | /* Flag to mark the video_device struct as unregistered. | ||
32 | Drivers can set this flag if they want to block all future | ||
33 | device access. It is set by video_unregister_device. */ | ||
34 | #define V4L2_FL_UNREGISTERED (0) | ||
35 | |||
36 | struct v4l2_file_operations { | ||
37 | struct module *owner; | ||
38 | ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); | ||
39 | ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); | ||
40 | unsigned int (*poll) (struct file *, struct poll_table_struct *); | ||
41 | long (*ioctl) (struct file *, unsigned int, unsigned long); | ||
42 | long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); | ||
43 | int (*mmap) (struct file *, struct vm_area_struct *); | ||
44 | int (*open) (struct file *); | ||
45 | int (*release) (struct file *); | ||
46 | }; | ||
28 | 47 | ||
29 | /* | 48 | /* |
30 | * Newer version of video_device, handled by videodev2.c | 49 | * Newer version of video_device, handled by videodev2.c |
@@ -35,19 +54,24 @@ struct v4l2_ioctl_callbacks; | |||
35 | struct video_device | 54 | struct video_device |
36 | { | 55 | { |
37 | /* device ops */ | 56 | /* device ops */ |
38 | const struct file_operations *fops; | 57 | const struct v4l2_file_operations *fops; |
39 | 58 | ||
40 | /* sysfs */ | 59 | /* sysfs */ |
41 | struct device dev; /* v4l device */ | 60 | struct device dev; /* v4l device */ |
42 | struct cdev cdev; /* character device */ | 61 | struct cdev *cdev; /* character device */ |
43 | void (*cdev_release)(struct kobject *kobj); | 62 | |
63 | /* Set either parent or v4l2_dev if your driver uses v4l2_device */ | ||
44 | struct device *parent; /* device parent */ | 64 | struct device *parent; /* device parent */ |
65 | struct v4l2_device *v4l2_dev; /* v4l2_device parent */ | ||
45 | 66 | ||
46 | /* device info */ | 67 | /* device info */ |
47 | char name[32]; | 68 | char name[32]; |
48 | int vfl_type; | 69 | int vfl_type; |
70 | /* 'minor' is set to -1 if the registration failed */ | ||
49 | int minor; | 71 | int minor; |
50 | u16 num; | 72 | u16 num; |
73 | /* use bitops to set/clear/test flags */ | ||
74 | unsigned long flags; | ||
51 | /* attribute to differentiate multiple indices on one physical device */ | 75 | /* attribute to differentiate multiple indices on one physical device */ |
52 | int index; | 76 | int index; |
53 | 77 | ||
@@ -58,7 +82,7 @@ struct video_device | |||
58 | v4l2_std_id current_norm; /* Current tvnorm */ | 82 | v4l2_std_id current_norm; /* Current tvnorm */ |
59 | 83 | ||
60 | /* callbacks */ | 84 | /* callbacks */ |
61 | void (*release)(struct video_device *vfd); | 85 | void (*release)(struct video_device *vdev); |
62 | 86 | ||
63 | /* ioctl callbacks */ | 87 | /* ioctl callbacks */ |
64 | const struct v4l2_ioctl_ops *ioctl_ops; | 88 | const struct v4l2_ioctl_ops *ioctl_ops; |
@@ -67,36 +91,41 @@ struct video_device | |||
67 | /* dev to video-device */ | 91 | /* dev to video-device */ |
68 | #define to_video_device(cd) container_of(cd, struct video_device, dev) | 92 | #define to_video_device(cd) container_of(cd, struct video_device, dev) |
69 | 93 | ||
70 | /* Register and unregister devices. Note that if video_register_device fails, | 94 | /* Register video devices. Note that if video_register_device fails, |
71 | the release() callback of the video_device structure is *not* called, so | 95 | the release() callback of the video_device structure is *not* called, so |
72 | the caller is responsible for freeing any data. Usually that means that | 96 | the caller is responsible for freeing any data. Usually that means that |
73 | you call video_device_release() on failure. */ | 97 | you call video_device_release() on failure. |
74 | int __must_check video_register_device(struct video_device *vfd, int type, int nr); | 98 | |
75 | int __must_check video_register_device_index(struct video_device *vfd, | 99 | Also note that vdev->minor is set to -1 if the registration failed. */ |
100 | int __must_check video_register_device(struct video_device *vdev, int type, int nr); | ||
101 | int __must_check video_register_device_index(struct video_device *vdev, | ||
76 | int type, int nr, int index); | 102 | int type, int nr, int index); |
77 | void video_unregister_device(struct video_device *vfd); | 103 | |
104 | /* Unregister video devices. Will do nothing if vdev == NULL or | ||
105 | vdev->minor < 0. */ | ||
106 | void video_unregister_device(struct video_device *vdev); | ||
78 | 107 | ||
79 | /* helper functions to alloc/release struct video_device, the | 108 | /* helper functions to alloc/release struct video_device, the |
80 | latter can also be used for video_device->release(). */ | 109 | latter can also be used for video_device->release(). */ |
81 | struct video_device * __must_check video_device_alloc(void); | 110 | struct video_device * __must_check video_device_alloc(void); |
82 | 111 | ||
83 | /* this release function frees the vfd pointer */ | 112 | /* this release function frees the vdev pointer */ |
84 | void video_device_release(struct video_device *vfd); | 113 | void video_device_release(struct video_device *vdev); |
85 | 114 | ||
86 | /* this release function does nothing, use when the video_device is a | 115 | /* this release function does nothing, use when the video_device is a |
87 | static global struct. Note that having a static video_device is | 116 | static global struct. Note that having a static video_device is |
88 | a dubious construction at best. */ | 117 | a dubious construction at best. */ |
89 | void video_device_release_empty(struct video_device *vfd); | 118 | void video_device_release_empty(struct video_device *vdev); |
90 | 119 | ||
91 | /* helper functions to access driver private data. */ | 120 | /* helper functions to access driver private data. */ |
92 | static inline void *video_get_drvdata(struct video_device *dev) | 121 | static inline void *video_get_drvdata(struct video_device *vdev) |
93 | { | 122 | { |
94 | return dev_get_drvdata(&dev->dev); | 123 | return dev_get_drvdata(&vdev->dev); |
95 | } | 124 | } |
96 | 125 | ||
97 | static inline void video_set_drvdata(struct video_device *dev, void *data) | 126 | static inline void video_set_drvdata(struct video_device *vdev, void *data) |
98 | { | 127 | { |
99 | dev_set_drvdata(&dev->dev, data); | 128 | dev_set_drvdata(&vdev->dev, data); |
100 | } | 129 | } |
101 | 130 | ||
102 | struct video_device *video_devdata(struct file *file); | 131 | struct video_device *video_devdata(struct file *file); |
@@ -108,4 +137,9 @@ static inline void *video_drvdata(struct file *file) | |||
108 | return video_get_drvdata(video_devdata(file)); | 137 | return video_get_drvdata(video_devdata(file)); |
109 | } | 138 | } |
110 | 139 | ||
140 | static inline int video_is_unregistered(struct video_device *vdev) | ||
141 | { | ||
142 | return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags); | ||
143 | } | ||
144 | |||
111 | #endif /* _V4L2_DEV_H */ | 145 | #endif /* _V4L2_DEV_H */ |