00001 #ifndef _UVC_COMPAT_H
00002 #define _UVC_COMPAT_H
00003
00004 #include <linux/version.h>
00005
00006 #ifndef __KERNEL__
00007 #ifndef __user
00008 #define __user
00009 #endif
00010 #endif
00011
00012 #ifdef CONFIG_INPUT
00013 #undef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV
00014 #define CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV 1
00015 #endif
00016
00017 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
00018
00019
00020
00021 struct v4l2_ext_control {
00022 __u32 id;
00023 __u32 reserved2[2];
00024 union {
00025 __s32 value;
00026 __s64 value64;
00027 void *reserved;
00028 };
00029 } __attribute__ ((packed));
00030
00031 struct v4l2_ext_controls {
00032 __u32 ctrl_class;
00033 __u32 count;
00034 __u32 error_idx;
00035 __u32 reserved[2];
00036 struct v4l2_ext_control *controls;
00037 };
00038
00039
00040 #define V4L2_CTRL_CLASS_USER 0x00980000
00041 #define V4L2_CTRL_CLASS_MPEG 0x00990000
00042
00043 #define V4L2_CTRL_ID_MASK (0x0fffffff)
00044 #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
00045 #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
00046
00047
00048 #define V4L2_CTRL_FLAG_READ_ONLY 0x0004
00049 #define V4L2_CTRL_FLAG_UPDATE 0x0008
00050 #define V4L2_CTRL_FLAG_INACTIVE 0x0010
00051 #define V4L2_CTRL_FLAG_SLIDER 0x0020
00052
00053
00054 #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
00055
00056
00057 #undef V4L2_CID_BASE
00058 #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
00059 #define V4L2_CID_USER_BASE V4L2_CID_BASE
00060 #define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1)
00061
00062 #define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
00063 #define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
00064 #define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
00065
00066 #endif
00067
00068 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
00069
00070
00071
00072
00073
00074 enum v4l2_frmsizetypes {
00075 V4L2_FRMSIZE_TYPE_DISCRETE = 1,
00076 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
00077 V4L2_FRMSIZE_TYPE_STEPWISE = 3,
00078 };
00079
00080 struct v4l2_frmsize_discrete {
00081 __u32 width;
00082 __u32 height;
00083 };
00084
00085 struct v4l2_frmsize_stepwise {
00086 __u32 min_width;
00087 __u32 max_width;
00088 __u32 step_width;
00089 __u32 min_height;
00090 __u32 max_height;
00091 __u32 step_height;
00092 };
00093
00094 struct v4l2_frmsizeenum {
00095 __u32 index;
00096 __u32 pixel_format;
00097 __u32 type;
00098
00099 union {
00100 struct v4l2_frmsize_discrete discrete;
00101 struct v4l2_frmsize_stepwise stepwise;
00102 };
00103
00104 __u32 reserved[2];
00105 };
00106
00107 enum v4l2_frmivaltypes {
00108 V4L2_FRMIVAL_TYPE_DISCRETE = 1,
00109 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
00110 V4L2_FRMIVAL_TYPE_STEPWISE = 3,
00111 };
00112
00113 struct v4l2_frmival_stepwise {
00114 struct v4l2_fract min;
00115 struct v4l2_fract max;
00116 struct v4l2_fract step;
00117 };
00118
00119 struct v4l2_frmivalenum {
00120 __u32 index;
00121 __u32 pixel_format;
00122 __u32 width;
00123 __u32 height;
00124 __u32 type;
00125
00126 union {
00127 struct v4l2_fract discrete;
00128 struct v4l2_frmival_stepwise stepwise;
00129 };
00130
00131 __u32 reserved[2];
00132 };
00133
00134 #define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
00135 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
00136 #endif
00137
00138 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
00139
00140
00141
00142 #define V4L2_CTRL_CLASS_CAMERA 0x009A0000
00143
00144 #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
00145 enum v4l2_power_line_frequency {
00146 V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
00147 V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
00148 V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
00149 };
00150
00151 #define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
00152 #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
00153 #define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
00154 #define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
00155
00156 #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
00157 #define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
00158
00159 #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
00160 enum v4l2_exposure_auto_type {
00161 V4L2_EXPOSURE_MANUAL = 0,
00162 V4L2_EXPOSURE_AUTO = 1,
00163 V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
00164 V4L2_EXPOSURE_APERTURE_PRIORITY = 3
00165 };
00166 #define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2)
00167 #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3)
00168
00169 #define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
00170 #define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
00171 #define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
00172 #define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
00173
00174 #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8)
00175 #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9)
00176
00177 #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10)
00178 #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
00179 #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
00180
00181 #define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13)
00182
00183 #endif
00184
00185 #define V4L2_CID_ROLL_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17)
00186 #define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+18)
00187
00188 #ifdef __KERNEL__
00189
00190 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
00191 #define __nocast
00192 #endif
00193
00194 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
00195
00196
00197
00198 typedef unsigned int __nocast gfp_t;
00199
00200 static inline void *
00201 kzalloc(size_t size, gfp_t gfp_flags)
00202 {
00203 void *mem = kmalloc(size, gfp_flags);
00204 if (mem)
00205 memset(mem, 0, size);
00206 return mem;
00207 }
00208 #endif
00209
00210 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
00211
00212
00213
00214 #include <linux/mm.h>
00215
00216 static inline int
00217 vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
00218 struct page *page)
00219 {
00220
00221
00222
00223 vma->vm_flags |= VM_RESERVED;
00224
00225 SetPageReserved(page);
00226 return remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE,
00227 vma->vm_page_prot);
00228 }
00229 #endif
00230
00231 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
00232
00233
00234
00235 static inline void
00236 v4l_printk_ioctl(unsigned int cmd)
00237 {
00238 switch (_IOC_TYPE(cmd)) {
00239 case 'v':
00240 printk(KERN_DEBUG "ioctl 0x%x (V4L1)\n", cmd);
00241 break;
00242 case 'V':
00243 printk(KERN_DEBUG "ioctl 0x%x (%s)\n",
00244 cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
00245 break;
00246 default:
00247 printk(KERN_DEBUG "ioctl 0x%x (?)\n", cmd);
00248 break;
00249 }
00250 }
00251 #endif
00252
00253 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
00254
00255
00256
00257 #include <asm/semaphore.h>
00258 #define mutex_lock(mutex) down(mutex)
00259 #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
00260 #define mutex_unlock(mutex) up(mutex)
00261 #define mutex_init(mutex) init_MUTEX(mutex)
00262 #define mutex semaphore
00263 #else
00264 #include <asm/mutex.h>
00265 #endif
00266
00267 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
00268 #include <linux/videodev.h>
00269 #endif
00270
00271 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
00272
00273
00274
00275
00276
00277
00278 #ifdef RHEL_RELEASE_CODE
00279 #if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,2)
00280 #define RHEL_HAS_USB_ENDPOINT
00281 #endif
00282 #endif
00283
00284 #ifndef RHEL_HAS_USB_ENDPOINT
00285 static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
00286 {
00287 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
00288 }
00289
00290 static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
00291 {
00292 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00293 USB_ENDPOINT_XFER_INT);
00294 }
00295
00296 static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
00297 {
00298 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00299 USB_ENDPOINT_XFER_ISOC);
00300 }
00301
00302 static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
00303 {
00304 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00305 USB_ENDPOINT_XFER_BULK);
00306 }
00307
00308 static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
00309 {
00310 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
00311 }
00312 #endif
00313
00314
00315
00316
00317
00318
00319 static inline int usb_autopm_get_interface(struct usb_interface *intf)
00320 { return 0; }
00321
00322 static inline void usb_autopm_put_interface(struct usb_interface *intf)
00323 { }
00324
00325
00326
00327
00328
00329
00330 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
00331 #endif
00332
00333 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
00334
00335
00336
00337 #define list_first_entry(ptr, type, member) \
00338 list_entry((ptr)->next, type, member)
00339
00340
00341
00342
00343 #define uninitialized_var(x) x
00344 #endif
00345
00346 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
00347 #if defined(OBSOLETE_OWNER) || defined(OBSOLETE_DEVDATA)
00348
00349
00350
00351 static inline void *video_drvdata(struct file *file)
00352 {
00353 return video_get_drvdata(video_devdata(file));
00354 }
00355 #endif
00356 #endif
00357
00358 #endif
00359
00360 #endif
00361