uvc_compat.h
Go to the documentation of this file.
1 #ifndef _UVC_COMPAT_H
2 #define _UVC_COMPAT_H
3 
4 #include <linux/version.h>
5 
6 #ifndef __KERNEL__
7 #ifndef __user
8 #define __user
9 #endif
10 #endif
11 
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
13 /*
14  * Extended control API
15  */
16 struct v4l2_ext_control {
17  __u32 id;
18  __u32 reserved2[2];
19  union {
20  __s32 value;
21  __s64 value64;
22  void *reserved;
23  };
24 } __attribute__ ((packed));
25 
26 struct v4l2_ext_controls {
27  __u32 ctrl_class;
28  __u32 count;
29  __u32 error_idx;
30  __u32 reserved[2];
31  struct v4l2_ext_control *controls;
32 };
33 
34 /* Values for ctrl_class field */
35 #define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
36 #define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
37 
38 #define V4L2_CTRL_ID_MASK (0x0fffffff)
39 #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
40 #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
41 
42 /* Control flags */
43 #define V4L2_CTRL_FLAG_READ_ONLY 0x0004
44 #define V4L2_CTRL_FLAG_UPDATE 0x0008
45 #define V4L2_CTRL_FLAG_INACTIVE 0x0010
46 #define V4L2_CTRL_FLAG_SLIDER 0x0020
47 
48 /* Query flags, to be ORed with the control ID */
49 #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
50 
51 /* User-class control IDs defined by V4L2 */
52 #undef V4L2_CID_BASE
53 #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
54 #define V4L2_CID_USER_BASE V4L2_CID_BASE
55 #define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1)
56 
57 #define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
58 #define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
59 #define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
60 
61 #endif
62 
63 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
64 /*
65  * Frame size and frame rate enumeration
66  *
67  * Included in Linux 2.6.19
68  */
69 enum v4l2_frmsizetypes {
70  V4L2_FRMSIZE_TYPE_DISCRETE = 1,
71  V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
72  V4L2_FRMSIZE_TYPE_STEPWISE = 3,
73 };
74 
75 struct v4l2_frmsize_discrete {
76  __u32 width; /* Frame width [pixel] */
77  __u32 height; /* Frame height [pixel] */
78 };
79 
80 struct v4l2_frmsize_stepwise {
81  __u32 min_width; /* Minimum frame width [pixel] */
82  __u32 max_width; /* Maximum frame width [pixel] */
83  __u32 step_width; /* Frame width step size [pixel] */
84  __u32 min_height; /* Minimum frame height [pixel] */
85  __u32 max_height; /* Maximum frame height [pixel] */
86  __u32 step_height; /* Frame height step size [pixel] */
87 };
88 
89 struct v4l2_frmsizeenum {
90  __u32 index; /* Frame size number */
91  __u32 pixel_format; /* Pixel format */
92  __u32 type; /* Frame size type the device supports. */
93 
94  union { /* Frame size */
95  struct v4l2_frmsize_discrete discrete;
96  struct v4l2_frmsize_stepwise stepwise;
97  };
98 
99  __u32 reserved[2]; /* Reserved space for future use */
100 };
101 
102 enum v4l2_frmivaltypes {
103  V4L2_FRMIVAL_TYPE_DISCRETE = 1,
104  V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
105  V4L2_FRMIVAL_TYPE_STEPWISE = 3,
106 };
107 
108 struct v4l2_frmival_stepwise {
109  struct v4l2_fract min; /* Minimum frame interval [s] */
110  struct v4l2_fract max; /* Maximum frame interval [s] */
111  struct v4l2_fract step; /* Frame interval step size [s] */
112 };
113 
114 struct v4l2_frmivalenum {
115  __u32 index; /* Frame format index */
116  __u32 pixel_format; /* Pixel format */
117  __u32 width; /* Frame width */
118  __u32 height; /* Frame height */
119  __u32 type; /* Frame interval type the device supports. */
120 
121  union { /* Frame interval */
122  struct v4l2_fract discrete;
123  struct v4l2_frmival_stepwise stepwise;
124  };
125 
126  __u32 reserved[2]; /* Reserved space for future use */
127 };
128 
129 #define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
130 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
131 #endif
132 
133 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
134 /*
135  * V4L2 Control identifiers.
136  */
137 #define V4L2_CTRL_CLASS_CAMERA 0x009A0000 /* Camera class controls */
138 
139 #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
140 enum v4l2_power_line_frequency {
141  V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
142  V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
143  V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
144 };
145 
146 #define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
147 #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
148 #define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
149 #define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
150 
151 #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
152 #define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
153 
154 #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
155 enum v4l2_exposure_auto_type {
156  V4L2_EXPOSURE_MANUAL = 0,
157  V4L2_EXPOSURE_AUTO = 1,
158  V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
159  V4L2_EXPOSURE_APERTURE_PRIORITY = 3
160 };
161 #define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2)
162 #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3)
163 
164 #define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
165 #define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
166 #define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
167 #define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
168 
169 #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8)
170 #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9)
171 
172 #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10)
173 #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
174 #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
175 
176 #endif
177 
178 #ifdef __KERNEL__
179 
180 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
181 /*
182  * kzalloc()
183  */
184 static inline void *
185 kzalloc(size_t size, unsigned int __nocast gfp_flags)
186 {
187  void *mem = kmalloc(size, gfp_flags);
188  if (mem)
189  memset(mem, 0, size);
190  return mem;
191 }
192 #endif
193 
194 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
195 /*
196  * vm_insert_page()
197  */
198 static inline int
199 vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
200  struct page *page)
201 {
202  /* Not sure if this is needed. remap_pfn_range() sets VM_RESERVED
203  * in 2.6.14.
204  */
205  vma->vm_flags |= VM_RESERVED;
206 
207  SetPageReserved(page);
208  return remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE,
209  vma->vm_page_prot);
210 }
211 #endif
212 
213 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
214 /*
215  * v4l_printk_ioctl()
216  */
217 static inline void
218 v4l_printk_ioctl(unsigned int cmd)
219 {
220  switch (_IOC_TYPE(cmd)) {
221  case 'v':
222  printk(KERN_DEBUG "ioctl 0x%x (V4L1)\n", cmd);
223  break;
224  case 'V':
225  printk(KERN_DEBUG "ioctl 0x%x (%s)\n",
226  cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
227  break;
228  default:
229  printk(KERN_DEBUG "ioctl 0x%x (?)\n", cmd);
230  break;
231  }
232 }
233 #endif
234 
235 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
236 /*
237  * Mutex API
238  */
239 #include <asm/semaphore.h>
240 #define mutex_lock(mutex) down(mutex)
241 #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
242 #define mutex_unlock(mutex) up(mutex)
243 #define mutex_init(mutex) init_MUTEX(mutex)
244 #define mutex semaphore
245 #else
246 #include <asm/mutex.h>
247 #endif
248 
249 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
250 /*
251  * usb_endpoint_* functions
252  *
253  * Included in Linux 2.6.19
254  */
255 static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
256 {
257  return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
258 }
259 
260 static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
261 {
262  return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
263  USB_ENDPOINT_XFER_INT);
264 }
265 
266 static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
267 {
268  return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
269  USB_ENDPOINT_XFER_ISOC);
270 }
271 
272 static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
273 {
274  return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
275  USB_ENDPOINT_XFER_BULK);
276 }
277 
278 static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
279 {
280  return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
281 }
282 
283 /*
284  * USB auto suspend
285  *
286  * Included in Linux 2.6.19
287  */
288 static inline int usb_autopm_get_interface(struct usb_interface *intf)
289 { return 0; }
290 
291 static inline void usb_autopm_put_interface(struct usb_interface *intf)
292 { }
293 
294 #endif
295 
296 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
297 /*
298  * Linked list API
299  */
300 #define list_first_entry(ptr, type, member) \
301  list_entry((ptr)->next, type, member)
302 #endif
303 
304 #endif /* __KERNEL__ */
305 
306 #endif /* _UVC_COMPAT_H */
307 
string cmd


tuw_uvc
Author(s): Markus Bader
autogenerated on Mon Jun 10 2019 15:39:24