4 #include <linux/version.h> 13 #undef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV 14 #define CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV 1 17 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) 21 struct v4l2_ext_control {
29 } __attribute__ ((packed));
31 struct v4l2_ext_controls {
36 struct v4l2_ext_control *controls;
40 #define V4L2_CTRL_CLASS_USER 0x00980000 41 #define V4L2_CTRL_CLASS_MPEG 0x00990000 43 #define V4L2_CTRL_ID_MASK (0x0fffffff) 44 #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) 45 #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) 48 #define V4L2_CTRL_FLAG_READ_ONLY 0x0004 49 #define V4L2_CTRL_FLAG_UPDATE 0x0008 50 #define V4L2_CTRL_FLAG_INACTIVE 0x0010 51 #define V4L2_CTRL_FLAG_SLIDER 0x0020 54 #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000 58 #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) 59 #define V4L2_CID_USER_BASE V4L2_CID_BASE 60 #define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1) 62 #define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls) 63 #define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls) 64 #define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls) 68 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) 74 enum v4l2_frmsizetypes {
75 V4L2_FRMSIZE_TYPE_DISCRETE = 1,
76 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
77 V4L2_FRMSIZE_TYPE_STEPWISE = 3,
80 struct v4l2_frmsize_discrete {
85 struct v4l2_frmsize_stepwise {
94 struct v4l2_frmsizeenum {
100 struct v4l2_frmsize_discrete discrete;
101 struct v4l2_frmsize_stepwise stepwise;
107 enum v4l2_frmivaltypes {
108 V4L2_FRMIVAL_TYPE_DISCRETE = 1,
109 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
110 V4L2_FRMIVAL_TYPE_STEPWISE = 3,
113 struct v4l2_frmival_stepwise {
114 struct v4l2_fract min;
115 struct v4l2_fract max;
116 struct v4l2_fract step;
119 struct v4l2_frmivalenum {
127 struct v4l2_fract discrete;
128 struct v4l2_frmival_stepwise stepwise;
134 #define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum) 135 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum) 138 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) 142 #define V4L2_CTRL_CLASS_CAMERA 0x009A0000 144 #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24) 145 enum v4l2_power_line_frequency {
146 V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
147 V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
148 V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
151 #define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25) 152 #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26) 153 #define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27) 154 #define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28) 156 #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900) 157 #define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1) 159 #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1) 160 enum v4l2_exposure_auto_type {
161 V4L2_EXPOSURE_MANUAL = 0,
162 V4L2_EXPOSURE_AUTO = 1,
163 V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
164 V4L2_EXPOSURE_APERTURE_PRIORITY = 3
166 #define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2) 167 #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3) 169 #define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4) 170 #define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5) 171 #define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6) 172 #define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7) 174 #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8) 175 #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9) 177 #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10) 178 #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) 179 #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) 181 #define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13) 185 #define V4L2_CID_ROLL_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17) 186 #define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+18) 190 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) 194 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) 198 typedef unsigned int __nocast gfp_t;
201 kzalloc(
size_t size, gfp_t gfp_flags)
203 void *mem = kmalloc(size, gfp_flags);
205 memset(mem, 0, size);
210 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) 214 #include <linux/mm.h> 217 vm_insert_page(
struct vm_area_struct *vma,
unsigned long addr,
223 vma->vm_flags |= VM_RESERVED;
225 SetPageReserved(page);
226 return remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE,
231 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) 236 v4l_printk_ioctl(
unsigned int cmd)
238 switch (_IOC_TYPE(cmd)) {
240 printk(KERN_DEBUG
"ioctl 0x%x (V4L1)\n", cmd);
243 printk(KERN_DEBUG
"ioctl 0x%x (%s)\n",
244 cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
247 printk(KERN_DEBUG
"ioctl 0x%x (?)\n", cmd);
253 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) 257 #include <asm/semaphore.h> 258 #define mutex_lock(mutex) down(mutex) 259 #define mutex_lock_interruptible(mutex) down_interruptible(mutex) 260 #define mutex_unlock(mutex) up(mutex) 261 #define mutex_init(mutex) init_MUTEX(mutex) 262 #define mutex semaphore 264 #include <asm/mutex.h> 267 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) 268 #include <linux/videodev.h> 271 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) 278 #ifdef RHEL_RELEASE_CODE 279 #if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,2) 280 #define RHEL_HAS_USB_ENDPOINT 284 #ifndef RHEL_HAS_USB_ENDPOINT 285 static inline int usb_endpoint_dir_in(
const struct usb_endpoint_descriptor *epd)
287 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
290 static inline int usb_endpoint_xfer_int(
const struct usb_endpoint_descriptor *epd)
292 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
293 USB_ENDPOINT_XFER_INT);
296 static inline int usb_endpoint_xfer_isoc(
const struct usb_endpoint_descriptor *epd)
298 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
299 USB_ENDPOINT_XFER_ISOC);
302 static inline int usb_endpoint_xfer_bulk(
const struct usb_endpoint_descriptor *epd)
304 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
305 USB_ENDPOINT_XFER_BULK);
308 static inline int usb_endpoint_is_int_in(
const struct usb_endpoint_descriptor *epd)
310 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
319 static inline int usb_autopm_get_interface(
struct usb_interface *intf)
322 static inline void usb_autopm_put_interface(
struct usb_interface *intf)
330 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 333 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) 337 #define list_first_entry(ptr, type, member) \ 338 list_entry((ptr)->next, type, member) 343 #define uninitialized_var(x) x 346 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) 347 #if defined(OBSOLETE_OWNER) || defined(OBSOLETE_DEVDATA) 351 static inline void *video_drvdata(
struct file *file)
353 return video_get_drvdata(video_devdata(file));