Blame view
include/media/v4l2-dev.h
6.15 KB
401998fa9 V4L/DVB (4065): S... |
1 2 3 4 5 6 7 8 9 10 |
/* * * V 4 L 2 D R I V E R H E L P E R A P I * * Moved from videodev2.h * * Some commonly needed functions for drivers (v4l2-common.o module) */ #ifndef _V4L2_DEV_H #define _V4L2_DEV_H |
401998fa9 V4L/DVB (4065): S... |
11 12 13 |
#include <linux/poll.h> #include <linux/fs.h> #include <linux/device.h> |
7f8ecfab7 V4L/DVB (8852): v... |
14 |
#include <linux/cdev.h> |
401998fa9 V4L/DVB (4065): S... |
15 |
#include <linux/mutex.h> |
401998fa9 V4L/DVB (4065): S... |
16 |
#include <linux/videodev2.h> |
401998fa9 V4L/DVB (4065): S... |
17 |
|
2c0ab67be [media] v4l: Make... |
18 |
#include <media/media-entity.h> |
401998fa9 V4L/DVB (4065): S... |
19 |
#define VIDEO_MAJOR 81 |
bfa8a273b V4L/DVB (8787): v... |
20 |
|
401998fa9 V4L/DVB (4065): S... |
21 22 23 |
#define VFL_TYPE_GRABBER 0 #define VFL_TYPE_VBI 1 #define VFL_TYPE_RADIO 2 |
2096a5dcf [media] v4l: subd... |
24 25 |
#define VFL_TYPE_SUBDEV 3 #define VFL_TYPE_MAX 4 |
401998fa9 V4L/DVB (4065): S... |
26 |
|
a399810ca V4L/DVB (8482): v... |
27 |
struct v4l2_ioctl_callbacks; |
bec43661b V4L/DVB (10135): ... |
28 |
struct video_device; |
9bea3514d V4L/DVB (9974): v... |
29 |
struct v4l2_device; |
0996517cf V4L/DVB: v4l2: Ad... |
30 |
struct v4l2_ctrl_handler; |
a399810ca V4L/DVB (8482): v... |
31 |
|
957b4aa9f V4L/DVB (13552): ... |
32 33 34 35 |
/* Flag to mark the video_device struct as registered. Drivers can clear this flag if they want to block all future device access. It is cleared by video_unregister_device. */ #define V4L2_FL_REGISTERED (0) |
b1a873a37 [media] v4l2: use... |
36 |
/* file->private_data points to struct v4l2_fh */ |
1babcb460 V4L/DVB: V4L: Fil... |
37 |
#define V4L2_FL_USES_V4L2_FH (1) |
b1a873a37 [media] v4l2: use... |
38 39 |
/* Use the prio field of v4l2_fh for core priority checking */ #define V4L2_FL_USE_FH_PRIO (2) |
dc93a70cc V4L/DVB (9973): v... |
40 |
|
022654930 [media] v4l2_prio... |
41 42 43 44 45 46 47 48 49 50 51 52 53 |
/* Priority helper functions */ struct v4l2_prio_state { atomic_t prios[4]; }; void v4l2_prio_init(struct v4l2_prio_state *global); int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, enum v4l2_priority new); void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local); void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local); enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global); int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local); |
bec43661b V4L/DVB (10135): ... |
54 55 56 57 58 |
struct v4l2_file_operations { struct module *owner; ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); unsigned int (*poll) (struct file *, struct poll_table_struct *); |
069b74793 V4L/DVB (10138): ... |
59 |
long (*ioctl) (struct file *, unsigned int, unsigned long); |
bec43661b V4L/DVB (10135): ... |
60 |
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); |
ecc6517d9 [media] Revert "V... |
61 62 |
unsigned long (*get_unmapped_area) (struct file *, unsigned long, unsigned long, unsigned long, unsigned long); |
bec43661b V4L/DVB (10135): ... |
63 64 65 66 |
int (*mmap) (struct file *, struct vm_area_struct *); int (*open) (struct file *); int (*release) (struct file *); }; |
401998fa9 V4L/DVB (4065): S... |
67 68 69 70 71 |
/* * Newer version of video_device, handled by videodev2.c * This version moves redundant code from video device code to * the common handler */ |
401998fa9 V4L/DVB (4065): S... |
72 73 74 |
struct video_device { |
2c0ab67be [media] v4l: Make... |
75 76 77 |
#if defined(CONFIG_MEDIA_CONTROLLER) struct media_entity entity; #endif |
401998fa9 V4L/DVB (4065): S... |
78 |
/* device ops */ |
bec43661b V4L/DVB (10135): ... |
79 |
const struct v4l2_file_operations *fops; |
401998fa9 V4L/DVB (4065): S... |
80 |
|
54bd5b66c V4L/DVB (6293): V... |
81 |
/* sysfs */ |
22a04f106 V4L/DVB (8429): v... |
82 |
struct device dev; /* v4l device */ |
dc93a70cc V4L/DVB (9973): v... |
83 |
struct cdev *cdev; /* character device */ |
9bea3514d V4L/DVB (9974): v... |
84 85 |
/* Set either parent or v4l2_dev if your driver uses v4l2_device */ |
5e85e732f V4L/DVB (8428): v... |
86 |
struct device *parent; /* device parent */ |
9bea3514d V4L/DVB (9974): v... |
87 |
struct v4l2_device *v4l2_dev; /* v4l2_device parent */ |
54bd5b66c V4L/DVB (6293): V... |
88 |
|
0996517cf V4L/DVB: v4l2: Ad... |
89 90 |
/* Control handler associated with this device node. May be NULL. */ struct v4l2_ctrl_handler *ctrl_handler; |
0f62fd6a2 [media] v4l2: add... |
91 92 |
/* Priority state. If NULL, then v4l2_dev->prio will be used. */ struct v4l2_prio_state *prio; |
401998fa9 V4L/DVB (4065): S... |
93 |
/* device info */ |
401998fa9 V4L/DVB (4065): S... |
94 |
char name[32]; |
0ea6bc8d4 V4L/DVB (8523): v... |
95 |
int vfl_type; |
dc93a70cc V4L/DVB (9973): v... |
96 |
/* 'minor' is set to -1 if the registration failed */ |
401998fa9 V4L/DVB (4065): S... |
97 |
int minor; |
dd89601d4 V4L/DVB (9133): v... |
98 |
u16 num; |
dc93a70cc V4L/DVB (9973): v... |
99 100 |
/* use bitops to set/clear/test flags */ unsigned long flags; |
de1e575db V4L/DVB (8525): f... |
101 |
/* attribute to differentiate multiple indices on one physical device */ |
539a7555b V4L/DVB (8078): I... |
102 |
int index; |
401998fa9 V4L/DVB (4065): S... |
103 |
|
1babcb460 V4L/DVB: V4L: Fil... |
104 105 106 |
/* V4L2 file handles */ spinlock_t fh_lock; /* Lock for all v4l2_fhs */ struct list_head fh_list; /* List of struct v4l2_fh */ |
22a04f106 V4L/DVB (8429): v... |
107 |
int debug; /* Activates debug level*/ |
401998fa9 V4L/DVB (4065): S... |
108 109 |
/* Video standard vars */ |
e75f9cee3 V4L/DVB (4861): R... |
110 111 |
v4l2_std_id tvnorms; /* Supported tv norms */ v4l2_std_id current_norm; /* Current tvnorm */ |
401998fa9 V4L/DVB (4065): S... |
112 113 |
/* callbacks */ |
dc93a70cc V4L/DVB (9973): v... |
114 |
void (*release)(struct video_device *vdev); |
401998fa9 V4L/DVB (4065): S... |
115 116 |
/* ioctl callbacks */ |
a399810ca V4L/DVB (8482): v... |
117 |
const struct v4l2_ioctl_ops *ioctl_ops; |
ee6869afc V4L/DVB: v4l2: ad... |
118 119 120 |
/* serialization lock */ struct mutex *lock; |
401998fa9 V4L/DVB (4065): S... |
121 |
}; |
6e3ea0e71 [media] v4l: Fix ... |
122 123 |
#define media_entity_to_video_device(__e) \ container_of(__e, struct video_device, entity) |
bfa8a273b V4L/DVB (8787): v... |
124 |
/* dev to video-device */ |
22a04f106 V4L/DVB (8429): v... |
125 |
#define to_video_device(cd) container_of(cd, struct video_device, dev) |
e90ff9239 V4L/DVB (6220a): ... |
126 |
|
2096a5dcf [media] v4l: subd... |
127 128 |
int __must_check __video_register_device(struct video_device *vdev, int type, int nr, int warn_if_nr_in_use, struct module *owner); |
dc93a70cc V4L/DVB (9973): v... |
129 |
/* Register video devices. Note that if video_register_device fails, |
bfa8a273b V4L/DVB (8787): v... |
130 131 |
the release() callback of the video_device structure is *not* called, so the caller is responsible for freeing any data. Usually that means that |
957b4aa9f V4L/DVB (13552): ... |
132 |
you call video_device_release() on failure. */ |
2096a5dcf [media] v4l: subd... |
133 134 135 136 137 |
static inline int __must_check video_register_device(struct video_device *vdev, int type, int nr) { return __video_register_device(vdev, type, nr, 1, vdev->fops->owner); } |
dc93a70cc V4L/DVB (9973): v... |
138 |
|
6b5270d21 V4L/DVB (12725): ... |
139 140 |
/* Same as video_register_device, but no warning is issued if the desired device node number was already in use. */ |
2096a5dcf [media] v4l: subd... |
141 142 143 144 145 |
static inline int __must_check video_register_device_no_warn( struct video_device *vdev, int type, int nr) { return __video_register_device(vdev, type, nr, 0, vdev->fops->owner); } |
6b5270d21 V4L/DVB (12725): ... |
146 |
|
dc93a70cc V4L/DVB (9973): v... |
147 |
/* Unregister video devices. Will do nothing if vdev == NULL or |
957b4aa9f V4L/DVB (13552): ... |
148 |
video_is_registered() returns false. */ |
dc93a70cc V4L/DVB (9973): v... |
149 |
void video_unregister_device(struct video_device *vdev); |
401998fa9 V4L/DVB (4065): S... |
150 |
|
bfa8a273b V4L/DVB (8787): v... |
151 152 |
/* helper functions to alloc/release struct video_device, the latter can also be used for video_device->release(). */ |
e138c592b V4L/DVB (8785): v... |
153 |
struct video_device * __must_check video_device_alloc(void); |
bfa8a273b V4L/DVB (8787): v... |
154 |
|
dc93a70cc V4L/DVB (9973): v... |
155 156 |
/* this release function frees the vdev pointer */ void video_device_release(struct video_device *vdev); |
bfa8a273b V4L/DVB (8787): v... |
157 |
|
f9e86b5e9 V4L/DVB (8782): v... |
158 159 160 |
/* this release function does nothing, use when the video_device is a static global struct. Note that having a static video_device is a dubious construction at best. */ |
dc93a70cc V4L/DVB (9973): v... |
161 |
void video_device_release_empty(struct video_device *vdev); |
401998fa9 V4L/DVB (4065): S... |
162 |
|
401998fa9 V4L/DVB (4065): S... |
163 |
/* helper functions to access driver private data. */ |
dc93a70cc V4L/DVB (9973): v... |
164 |
static inline void *video_get_drvdata(struct video_device *vdev) |
401998fa9 V4L/DVB (4065): S... |
165 |
{ |
dc93a70cc V4L/DVB (9973): v... |
166 |
return dev_get_drvdata(&vdev->dev); |
401998fa9 V4L/DVB (4065): S... |
167 |
} |
dc93a70cc V4L/DVB (9973): v... |
168 |
static inline void video_set_drvdata(struct video_device *vdev, void *data) |
401998fa9 V4L/DVB (4065): S... |
169 |
{ |
dc93a70cc V4L/DVB (9973): v... |
170 |
dev_set_drvdata(&vdev->dev, data); |
401998fa9 V4L/DVB (4065): S... |
171 |
} |
38ee04f04 V4L/DVB (4348): F... |
172 |
|
bfa8a273b V4L/DVB (8787): v... |
173 174 175 176 177 178 179 180 |
struct video_device *video_devdata(struct file *file); /* Combine video_get_drvdata and video_devdata as this is used very often. */ static inline void *video_drvdata(struct file *file) { return video_get_drvdata(video_devdata(file)); } |
401998fa9 V4L/DVB (4065): S... |
181 |
|
eac8ea536 V4L/DVB (13549): ... |
182 183 184 185 |
static inline const char *video_device_node_name(struct video_device *vdev) { return dev_name(&vdev->dev); } |
957b4aa9f V4L/DVB (13552): ... |
186 |
static inline int video_is_registered(struct video_device *vdev) |
dc93a70cc V4L/DVB (9973): v... |
187 |
{ |
957b4aa9f V4L/DVB (13552): ... |
188 |
return test_bit(V4L2_FL_REGISTERED, &vdev->flags); |
dc93a70cc V4L/DVB (9973): v... |
189 |
} |
401998fa9 V4L/DVB (4065): S... |
190 |
#endif /* _V4L2_DEV_H */ |