uvc_compat.h
Go to the documentation of this file.
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  * Extended control API
00015  */
00016 struct v4l2_ext_control {
00017         __u32 id;
00018         __u32 reserved2[2];
00019         union {
00020                 __s32 value;
00021                 __s64 value64;
00022                 void *reserved;
00023         };
00024 } __attribute__ ((packed));
00025 
00026 struct v4l2_ext_controls {
00027         __u32 ctrl_class;
00028         __u32 count;
00029         __u32 error_idx;
00030         __u32 reserved[2];
00031         struct v4l2_ext_control *controls;
00032 };
00033 
00034 /* Values for ctrl_class field */
00035 #define V4L2_CTRL_CLASS_USER            0x00980000      /* Old-style 'user' controls */
00036 #define V4L2_CTRL_CLASS_MPEG            0x00990000      /* MPEG-compression controls */
00037 
00038 #define V4L2_CTRL_ID_MASK               (0x0fffffff)
00039 #define V4L2_CTRL_ID2CLASS(id)          ((id) & 0x0fff0000UL)
00040 #define V4L2_CTRL_DRIVER_PRIV(id)       (((id) & 0xffff) >= 0x1000)
00041 
00042 /* Control flags */
00043 #define V4L2_CTRL_FLAG_READ_ONLY        0x0004
00044 #define V4L2_CTRL_FLAG_UPDATE           0x0008
00045 #define V4L2_CTRL_FLAG_INACTIVE         0x0010
00046 #define V4L2_CTRL_FLAG_SLIDER           0x0020
00047 
00048 /* Query flags, to be ORed with the control ID */
00049 #define V4L2_CTRL_FLAG_NEXT_CTRL        0x80000000
00050 
00051 /* User-class control IDs defined by V4L2 */
00052 #undef  V4L2_CID_BASE
00053 #define V4L2_CID_BASE                   (V4L2_CTRL_CLASS_USER | 0x900)
00054 #define V4L2_CID_USER_BASE              V4L2_CID_BASE
00055 #define V4L2_CID_USER_CLASS             (V4L2_CTRL_CLASS_USER | 1)
00056 
00057 #define VIDIOC_G_EXT_CTRLS              _IOWR('V', 71, struct v4l2_ext_controls)
00058 #define VIDIOC_S_EXT_CTRLS              _IOWR('V', 72, struct v4l2_ext_controls)
00059 #define VIDIOC_TRY_EXT_CTRLS            _IOWR('V', 73, struct v4l2_ext_controls)
00060 
00061 #endif
00062 
00063 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
00064 /*
00065  * Frame size and frame rate enumeration
00066  *
00067  * Included in Linux 2.6.19
00068  */
00069 enum v4l2_frmsizetypes {
00070         V4L2_FRMSIZE_TYPE_DISCRETE      = 1,
00071         V4L2_FRMSIZE_TYPE_CONTINUOUS    = 2,
00072         V4L2_FRMSIZE_TYPE_STEPWISE      = 3,
00073 };
00074 
00075 struct v4l2_frmsize_discrete {
00076         __u32                   width;          /* Frame width [pixel] */
00077         __u32                   height;         /* Frame height [pixel] */
00078 };
00079 
00080 struct v4l2_frmsize_stepwise {
00081         __u32                   min_width;      /* Minimum frame width [pixel] */
00082         __u32                   max_width;      /* Maximum frame width [pixel] */
00083         __u32                   step_width;     /* Frame width step size [pixel] */
00084         __u32                   min_height;     /* Minimum frame height [pixel] */
00085         __u32                   max_height;     /* Maximum frame height [pixel] */
00086         __u32                   step_height;    /* Frame height step size [pixel] */
00087 };
00088 
00089 struct v4l2_frmsizeenum {
00090         __u32                   index;          /* Frame size number */
00091         __u32                   pixel_format;   /* Pixel format */
00092         __u32                   type;           /* Frame size type the device supports. */
00093 
00094         union {                                 /* Frame size */
00095                 struct v4l2_frmsize_discrete    discrete;
00096                 struct v4l2_frmsize_stepwise    stepwise;
00097         };
00098 
00099         __u32   reserved[2];                    /* Reserved space for future use */
00100 };
00101 
00102 enum v4l2_frmivaltypes {
00103         V4L2_FRMIVAL_TYPE_DISCRETE      = 1,
00104         V4L2_FRMIVAL_TYPE_CONTINUOUS    = 2,
00105         V4L2_FRMIVAL_TYPE_STEPWISE      = 3,
00106 };
00107 
00108 struct v4l2_frmival_stepwise {
00109         struct v4l2_fract       min;            /* Minimum frame interval [s] */
00110         struct v4l2_fract       max;            /* Maximum frame interval [s] */
00111         struct v4l2_fract       step;           /* Frame interval step size [s] */
00112 };
00113 
00114 struct v4l2_frmivalenum {
00115         __u32                   index;          /* Frame format index */
00116         __u32                   pixel_format;   /* Pixel format */
00117         __u32                   width;          /* Frame width */
00118         __u32                   height;         /* Frame height */
00119         __u32                   type;           /* Frame interval type the device supports. */
00120 
00121         union {                                 /* Frame interval */
00122                 struct v4l2_fract               discrete;
00123                 struct v4l2_frmival_stepwise    stepwise;
00124         };
00125 
00126         __u32   reserved[2];                    /* Reserved space for future use */
00127 };
00128 
00129 #define VIDIOC_ENUM_FRAMESIZES          _IOWR('V', 74, struct v4l2_frmsizeenum)
00130 #define VIDIOC_ENUM_FRAMEINTERVALS      _IOWR('V', 75, struct v4l2_frmivalenum)
00131 #endif
00132 
00133 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
00134 /*
00135  * V4L2 Control identifiers.
00136  */
00137 #define V4L2_CTRL_CLASS_CAMERA 0x009A0000       /* Camera class controls */
00138 
00139 #define V4L2_CID_POWER_LINE_FREQUENCY           (V4L2_CID_BASE+24)
00140 enum v4l2_power_line_frequency {
00141         V4L2_CID_POWER_LINE_FREQUENCY_DISABLED  = 0,
00142         V4L2_CID_POWER_LINE_FREQUENCY_50HZ      = 1,
00143         V4L2_CID_POWER_LINE_FREQUENCY_60HZ      = 2,
00144 };
00145 
00146 #define V4L2_CID_HUE_AUTO                       (V4L2_CID_BASE+25)
00147 #define V4L2_CID_WHITE_BALANCE_TEMPERATURE      (V4L2_CID_BASE+26)
00148 #define V4L2_CID_SHARPNESS                      (V4L2_CID_BASE+27)
00149 #define V4L2_CID_BACKLIGHT_COMPENSATION         (V4L2_CID_BASE+28)
00150 
00151 #define V4L2_CID_CAMERA_CLASS_BASE              (V4L2_CTRL_CLASS_CAMERA | 0x900)
00152 #define V4L2_CID_CAMERA_CLASS                   (V4L2_CTRL_CLASS_CAMERA | 1)
00153 
00154 #define V4L2_CID_EXPOSURE_AUTO                  (V4L2_CID_CAMERA_CLASS_BASE+1)
00155 enum  v4l2_exposure_auto_type {
00156         V4L2_EXPOSURE_MANUAL = 0,
00157         V4L2_EXPOSURE_AUTO = 1,
00158         V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
00159         V4L2_EXPOSURE_APERTURE_PRIORITY = 3
00160 };
00161 #define V4L2_CID_EXPOSURE_ABSOLUTE              (V4L2_CID_CAMERA_CLASS_BASE+2)
00162 #define V4L2_CID_EXPOSURE_AUTO_PRIORITY         (V4L2_CID_CAMERA_CLASS_BASE+3)
00163 
00164 #define V4L2_CID_PAN_RELATIVE                   (V4L2_CID_CAMERA_CLASS_BASE+4)
00165 #define V4L2_CID_TILT_RELATIVE                  (V4L2_CID_CAMERA_CLASS_BASE+5)
00166 #define V4L2_CID_PAN_RESET                      (V4L2_CID_CAMERA_CLASS_BASE+6)
00167 #define V4L2_CID_TILT_RESET                     (V4L2_CID_CAMERA_CLASS_BASE+7)
00168 
00169 #define V4L2_CID_PAN_ABSOLUTE                   (V4L2_CID_CAMERA_CLASS_BASE+8)
00170 #define V4L2_CID_TILT_ABSOLUTE                  (V4L2_CID_CAMERA_CLASS_BASE+9)
00171 
00172 #define V4L2_CID_FOCUS_ABSOLUTE                 (V4L2_CID_CAMERA_CLASS_BASE+10)
00173 #define V4L2_CID_FOCUS_RELATIVE                 (V4L2_CID_CAMERA_CLASS_BASE+11)
00174 #define V4L2_CID_FOCUS_AUTO                     (V4L2_CID_CAMERA_CLASS_BASE+12)
00175 
00176 #endif
00177 
00178 #ifdef __KERNEL__
00179 
00180 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
00181 /*
00182  * kzalloc()
00183  */
00184 static inline void *
00185 kzalloc(size_t size, unsigned int __nocast gfp_flags)
00186 {
00187         void *mem = kmalloc(size, gfp_flags);
00188         if (mem)
00189                 memset(mem, 0, size);
00190         return mem;
00191 }
00192 #endif
00193 
00194 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
00195 /*
00196  * vm_insert_page()
00197  */
00198 static inline int
00199 vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
00200                 struct page *page)
00201 {
00202         /* Not sure if this is needed. remap_pfn_range() sets VM_RESERVED
00203          * in 2.6.14.
00204          */
00205         vma->vm_flags |= VM_RESERVED;
00206 
00207         SetPageReserved(page);
00208         return remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE,
00209                                 vma->vm_page_prot);
00210 }
00211 #endif
00212 
00213 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
00214 /*
00215  * v4l_printk_ioctl()
00216  */
00217 static inline void
00218 v4l_printk_ioctl(unsigned int cmd)
00219 {
00220         switch (_IOC_TYPE(cmd)) {
00221         case 'v':
00222                 printk(KERN_DEBUG "ioctl 0x%x (V4L1)\n", cmd);
00223                 break;
00224         case 'V':
00225                 printk(KERN_DEBUG "ioctl 0x%x (%s)\n",
00226                         cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
00227                 break;
00228         default:
00229                 printk(KERN_DEBUG "ioctl 0x%x (?)\n", cmd);
00230                 break;
00231         }
00232 }
00233 #endif
00234 
00235 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
00236 /*
00237  * Mutex API
00238  */
00239 #include <asm/semaphore.h>
00240 #define mutex_lock(mutex) down(mutex)
00241 #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
00242 #define mutex_unlock(mutex) up(mutex)
00243 #define mutex_init(mutex) init_MUTEX(mutex)
00244 #define mutex semaphore
00245 #else
00246 #include <asm/mutex.h>
00247 #endif
00248 
00249 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
00250 /*
00251  * usb_endpoint_* functions
00252  *
00253  * Included in Linux 2.6.19
00254  */
00255 static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
00256 {
00257         return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
00258 }
00259 
00260 static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
00261 {
00262         return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00263                 USB_ENDPOINT_XFER_INT);
00264 }
00265 
00266 static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
00267 {
00268         return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00269                 USB_ENDPOINT_XFER_ISOC);
00270 }
00271 
00272 static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
00273 {
00274         return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
00275                 USB_ENDPOINT_XFER_BULK);
00276 }
00277 
00278 static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
00279 {
00280         return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
00281 }
00282 
00283 /*
00284  * USB auto suspend
00285  *
00286  * Included in Linux 2.6.19
00287  */
00288 static inline int usb_autopm_get_interface(struct usb_interface *intf)
00289 { return 0; }
00290 
00291 static inline void usb_autopm_put_interface(struct usb_interface *intf)
00292 { }
00293 
00294 #endif
00295 
00296 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
00297 /*
00298  * Linked list API
00299  */
00300 #define list_first_entry(ptr, type, member) \
00301         list_entry((ptr)->next, type, member)
00302 #endif
00303 
00304 #endif /* __KERNEL__ */
00305 
00306 #endif /* _UVC_COMPAT_H */
00307 


tuw_uvc
Author(s):
autogenerated on Sun May 29 2016 02:50:28