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 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
00013
00014
00015
00016
00018
00019 struct v4l2_ext_control
00020 {
00021 __u32 id;
00022 __u32 reserved2[2];
00023 union {
00024 __s32 value;
00025 __s64 value64;
00026 void *reserved;
00027 };
00028 } __attribute__ ((packed));
00029
00030 struct v4l2_ext_controls
00031 {
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 {
00076 V4L2_FRMSIZE_TYPE_DISCRETE = 1,
00077 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
00078 V4L2_FRMSIZE_TYPE_STEPWISE = 3,
00079 };
00080
00081 struct v4l2_frmsize_discrete
00082 {
00083 __u32 width;
00084 __u32 height;
00085 };
00086
00087 struct v4l2_frmsize_stepwise
00088 {
00089 __u32 min_width;
00090 __u32 max_width;
00091 __u32 step_width;
00092 __u32 min_height;
00093 __u32 max_height;
00094 __u32 step_height;
00095 };
00096
00097 struct v4l2_frmsizeenum
00098 {
00099 __u32 index;
00100 __u32 pixel_format;
00101 __u32 type;
00102
00103 union {
00104 struct v4l2_frmsize_discrete discrete;
00105 struct v4l2_frmsize_stepwise stepwise;
00106 };
00107
00108 __u32 reserved[2];
00109 };
00110
00111 enum v4l2_frmivaltypes
00112 {
00113 V4L2_FRMIVAL_TYPE_DISCRETE = 1,
00114 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
00115 V4L2_FRMIVAL_TYPE_STEPWISE = 3,
00116 };
00117
00118 struct v4l2_frmival_stepwise
00119 {
00120 struct v4l2_fract min;
00121 struct v4l2_fract max;
00122 struct v4l2_fract step;
00123 };
00124
00125 struct v4l2_frmivalenum
00126 {
00127 __u32 index;
00128 __u32 pixel_format;
00129 __u32 width;
00130 __u32 height;
00131 __u32 type;
00132
00133 union {
00134 struct v4l2_fract discrete;
00135 struct v4l2_frmival_stepwise stepwise;
00136 };
00137
00138 __u32 reserved[2];
00139 };
00140
00141 #define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum)
00142 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum)
00143 #endif
00144
00145 #ifdef __KERNEL__
00146
00147 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
00148
00149
00150
00151 static inline void *
00152 kzalloc(size_t size, unsigned int __nocast gfp_flags)
00153 {
00154 void *mem = kmalloc(size, gfp_flags);
00155 if (mem)
00156 memset(mem, 0, size);
00157 return mem;
00158 }
00159 #endif
00160
00161 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
00162
00163
00164
00165 static inline int
00166 vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
00167 struct page *page)
00168 {
00169
00170
00171
00172 vma->vm_flags |= VM_RESERVED;
00173
00174 SetPageReserved(page);
00175 return remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE,
00176 vma->vm_page_prot);
00177 }
00178 #endif
00179
00180 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
00181
00182
00183
00184 static inline void
00185 v4l_printk_ioctl(unsigned int cmd)
00186 {
00187 switch (_IOC_TYPE(cmd)) {
00188 case 'v':
00189 printk(KERN_DEBUG "ioctl 0x%x (V4L1)\n", cmd);
00190 break;
00191 case 'V':
00192 printk(KERN_DEBUG "ioctl 0x%x (%s)\n",
00193 cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
00194 break;
00195 default:
00196 printk(KERN_DEBUG "ioctl 0x%x (?)\n", cmd);
00197 break;
00198 }
00199 }
00200 #endif
00201
00202 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
00203
00204
00205
00206 #include <asm/semaphore.h>
00207 #define mutex_lock(mutex) down(mutex)
00208 #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
00209 #define mutex_unlock(mutex) up(mutex)
00210 #define mutex_init(mutex) init_MUTEX(mutex)
00211 #define mutex semaphore
00212 #else
00213 #include <asm/mutex.h>
00214 #endif
00215
00216 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
00217
00218
00219
00220
00221
00222 static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
00223 {
00224 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
00225 }
00226
00227 static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
00228 {
00229 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00230 USB_ENDPOINT_XFER_INT);
00231 }
00232
00233 static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
00234 {
00235 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00236 USB_ENDPOINT_XFER_ISOC);
00237 }
00238
00239 static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
00240 {
00241 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00242 USB_ENDPOINT_XFER_BULK);
00243 }
00244
00245 static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
00246 {
00247 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
00248 }
00249
00251
00252
00253 #endif
00254
00255 #endif
00256
00257 #endif
00258