⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quickcam.h

📁 在Linux下用于webeye的摄像头的驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef _LINUX_QUICKCAM_H#define _LINUX_QUICKCAM_H/* {{{ [fold] SECTION: common definitions with userspace applications */#define QC_LUT_SIZE	(3*256)		/* Lookup table definition for equalization */#define QC_LUT_RED	0#define QC_LUT_GREEN	256#define QC_LUT_BLUE	512struct qc_userlut {	unsigned int flags;#define QC_USERLUT_DEFAULT 1		/* If set, change default settings or the current camera otherwise */#define QC_USERLUT_ENABLE  2		/* If set, enable user-specified LUT, or otherwise disable it */#define QC_USERLUT_VALUES  4		/* Load new (or store old) values into the lookup-table */	unsigned char lut[QC_LUT_SIZE];	/* Lookup table to set or read */};#define VIDEO_PALETTE_BAYER	(('q'<<8) | 1)	/* Grab video in raw Bayer format */#define VIDEO_PALETTE_MJPEG	(('q'<<8) | 2)	/* Grab video in compressed MJPEG format */#define VID_HARDWARE_QCAM_USB	(('q'<<8) | 50)	/* Device type *//* Private IOCTL calls */#define QC_IOCTLBASE		220				/* Don't use same numbers as Philips driver */#define VIDIOCQCGDEBUG		_IOR ('v',QC_IOCTLBASE+0, int)	/* Gets the debug output, bitfield */#define VIDIOCQCSDEBUG		_IOWR('v',QC_IOCTLBASE+0, int)	/* Sets the debug output, bitfield */#define VIDIOCQCGKEEPSETTINGS	_IOR ('v',QC_IOCTLBASE+1, int)	/* Get keep picture settings across one open to another (0-1) */#define VIDIOCQCSKEEPSETTINGS	_IOWR('v',QC_IOCTLBASE+1, int)	/* Set keep picture settings across one open to another (0-1) */#define VIDIOCQCGSETTLE		_IOR ('v',QC_IOCTLBASE+2, int)	/* Get if we let image brightness settle (0-1) */#define VIDIOCQCSSETTLE		_IOWR('v',QC_IOCTLBASE+2, int)	/* Set if we let image brightness settle (0-1) */#define VIDIOCQCGSUBSAMPLE	_IOR ('v',QC_IOCTLBASE+3, int)	/* Gets the speed (0-1) */#define VIDIOCQCSSUBSAMPLE	_IOWR('v',QC_IOCTLBASE+3, int)	/* Sets the speed (0-1) */#define VIDIOCQCGCOMPRESS	_IOR ('v',QC_IOCTLBASE+4, int)	/* Gets the compression mode (0-1) */#define VIDIOCQCSCOMPRESS	_IOWR('v',QC_IOCTLBASE+4, int)	/* Sets the compression mode (0-1) */#define VIDIOCQCGFRAMESKIP	_IOR ('v',QC_IOCTLBASE+5, int)	/* Get frame capture frequency (0-10) */#define VIDIOCQCSFRAMESKIP	_IOWR('v',QC_IOCTLBASE+5, int)	/* Set frame capture frequency (0-10) */#define VIDIOCQCGQUALITY	_IOR ('v',QC_IOCTLBASE+6, int)	/* Gets the interpolation mode (0-2) */#define VIDIOCQCSQUALITY	_IOWR('v',QC_IOCTLBASE+6, int)	/* Sets the interpolation mode (0-2) */#define VIDIOCQCGADAPTIVE	_IOR ('v',QC_IOCTLBASE+7, int)	/* Get automatic adaptive brightness control (0-1) */#define VIDIOCQCSADAPTIVE	_IOWR('v',QC_IOCTLBASE+7, int)	/* Set automatic adaptive brightness control (0-1) */#define VIDIOCQCGEQUALIZE	_IOR ('v',QC_IOCTLBASE+8, int)	/* Get equalize image (0-1) */#define VIDIOCQCSEQUALIZE	_IOWR('v',QC_IOCTLBASE+8, int)	/* Set equalize image (0-1) */#define VIDIOCQCGRETRYERRORS	_IOR ('v',QC_IOCTLBASE+9, int)	/* Get if we retry when capture fails (0-1) */#define VIDIOCQCSRETRYERRORS	_IOWR('v',QC_IOCTLBASE+9, int)	/* Set if we retry when capture fails (0-1) */#define VIDIOCQCGCOMPATIBLE	_IOR ('v',QC_IOCTLBASE+10,int)	/* Get enable workaround for bugs, bitfield */#define VIDIOCQCSCOMPATIBLE	_IOWR('v',QC_IOCTLBASE+10,int)	/* Set enable workaround for bugs, bitfield */#define VIDIOCQCGVIDEONR	_IOR ('v',QC_IOCTLBASE+11,int)	/* Get videodevice number (/dev/videoX) */#define VIDIOCQCSVIDEONR	_IOWR('v',QC_IOCTLBASE+11,int)	/* Set videodevice number (/dev/videoX) */#define VIDIOCQCGUSERLUT	_IOR ('v',QC_IOCTLBASE+12,struct qc_userlut)	/* Get user-specified lookup-table correction */#define VIDIOCQCSUSERLUT	_IOWR('v',QC_IOCTLBASE+12,struct qc_userlut)	/* Set user-specified lookup-table correction */#define VIDIOCQCGSTV		_IOWR('v',QC_IOCTLBASE+20,int)	/* Read STV chip register */#define VIDIOCQCSSTV		_IOW ('v',QC_IOCTLBASE+20,int)	/* Write STV chip register */#define VIDIOCQCGI2C		_IOWR('v',QC_IOCTLBASE+21,int)	/* Read I2C chip register */#define VIDIOCQCSI2C		_IOW ('v',QC_IOCTLBASE+21,int)	/* Write I2C chip register *//* Debugging message choices */#define QC_DEBUGUSER		(1<<0)	/* Messages for interaction with user space (system calls) */#define QC_DEBUGCAMERA		(1<<1)	/* Messages for interaction with the camera */#define QC_DEBUGINIT		(1<<2)	/* Messages for each submodule initialization/deinit */#define QC_DEBUGLOGIC		(1<<3)	/* Messages for entering and failing important functions */#define QC_DEBUGERRORS		(1<<4)	/* Messages for all error conditions */#define QC_DEBUGADAPTATION	(1<<5)	/* Messages for automatic exposure control workings */#define QC_DEBUGCONTROLURBS	(1<<6)	/* Messages for sending I2C control messages via USB */#define QC_DEBUGBITSTREAM	(1<<7)	/* Messages for finding chunk codes from camera bitstream */#define QC_DEBUGINTERRUPTS	(1<<8)	/* Messages for each interrupt */#define QC_DEBUGMUTEX		(1<<9)	/* Messages for acquiring/releasing the mutex */#define QC_DEBUGCOMMON		(1<<10)	/* Messages for some common warnings */#define QC_DEBUGFRAME		(1<<11)	/* Messages related to producer-consumer in qc_frame_* functions */#define QC_DEBUGALL		(~0)	/* Messages for everything *//* Compatibility choices */#define QC_COMPAT_16X		(1<<0)#define QC_COMPAT_DBLBUF	(1<<1)#define QC_COMPAT_TORGB		(1<<2)	/* Video4Linux API is buggy and doesn't specify byte order for RGB images *//* }}} */#ifdef __KERNEL__#include <linux/config.h>#include <linux/version.h>#ifdef CONFIG_SMP#define __SMP__#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)#define MODVERSIONS#endif#ifdef MODVERSIONS#include <linux/modversions.h>#endif#endif#include <linux/videodev.h>#include <linux/usb.h>#include <asm/pgtable.h>		/* This is required for testing pte_offset_map */#include <linux/spinlock.h>/* {{{ [fold] SECTION: user configuration */#define VERSION		"QuickCam USB 0.6.3 $Date: 2005/04/15 19:32:49 $"#ifndef COMPRESS#define COMPRESS	1		/* 1=include compression support, 0=otherwise */#endif#ifndef DEBUGLEVEL#define DEBUGLEVEL	QC_DEBUGCOMMON#endif#ifdef NDEBUG				/* Enable debugging if DEBUG is defined; if (also) NDEBUG is defined, disable debugging */#undef DEBUG#endif//#define DEBUG				/* Enable debug code */#ifdef DEBUG#define PARANOID	1		/* Check consistency of driver state */#else#define PARANOID	0#endif/* Default (initial) values */#define DEFAULT_BGR	TRUE		/* Use BGR byte order by default (and torgb converts to RGB)? */#define DUMPDATA	0		/* Dump data from camera to user, no conversion nor length checks (see show.c) *//* }}} *//* {{{ [fold] SECTION: general utility definitions and macros */#define FALSE			0#define TRUE			(!FALSE)typedef unsigned char Bool;#define BIT(x)		(1<<(x))#define SIZE(a)		(sizeof(a)/sizeof((a)[0]))#define MAX(a,b)	((a)>(b)?(a):(b))#define MIN(a,b)	((a)<(b)?(a):(b))#define MAX3(a,b,c)	(MAX(a,MAX(b,c)))#define MIN3(a,b,c)	(MIN(a,MIN(b,c)))#define CLIP(a,low,high) MAX((low),MIN((high),(a)))#define ABS(a)		((a)>0?(a):-(a))#define SGN(a)		((a)<0 ? -1 : ((a)>0 ? 1 : 0))#define CHECK_ERROR(cond,jump,msg,args...)	if (cond) { PDEBUG(msg, ## args); goto jump; }#define GET_VENDORID(qc)			((qc)->dev->descriptor.idVendor)#define GET_PRODUCTID(qc)			((qc)->dev->descriptor.idProduct)/* }}} *//* {{{ [fold] SECTION: compatibility */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)#error "Too old kernel. At least Linux 2.2.18 is required."#endif#if LINUX_VERSION_CODE==KERNEL_VERSION(2,4,19) || LINUX_VERSION_CODE==KERNEL_VERSION(2,4,20)#warning "Kernels 2.4.19 and 2.4.20 are buggy! Be sure to install patch from:"#warning "http://www.ee.oulu.fi/~tuukkat/quickcam/linux-2.4.20-videodevfix.patch"#endif#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,5,0) && LINUX_VERSION_CODE<KERNEL_VERSION(2,6,0)) || LINUX_VERSION_CODE>=KERNEL_VERSION(2,7,0)#warning "Unsupported kernel, may or may not work. Good luck!"#endif#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,4,0) && defined(CONFIG_PROC_FS)#define HAVE_PROCFS 1		/* FIXME: I don't think there's any reason to disable procfs with 2.2.x */#else#define HAVE_PROCFS 0#warning "procfs support disabled"#endif#ifndef HAVE_VMA#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,5,3) || (defined(RED_HAT_LINUX_KERNEL) && defined(pte_offset_map))/* Some RedHat 9 2.4.x patched-to-death kernels need this too */#define HAVE_VMA 1#else#define HAVE_VMA 0#endif#endif#if HAVE_VMA && LINUX_VERSION_CODE<KERNEL_VERSION(2,6,0)#warning "VMA/RMAP compatibility enabled"#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)	/* 2.4.x emulation for 2.2.x kernels */#define MODULE_DEVICE_TABLE(a,b)#define USB_DEVICE(vend,prod) idVendor: (vend), idProduct: (prod)struct usb_device_id {	u16 idVendor;	u16 idProduct;};#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5)/* This is rather tricky emulation since if versioning is used, * video_register_device is already #defined. */static inline int qc_video_register_device(struct video_device *dev, int type) { return video_register_device(dev, type); }#undef video_register_device#define video_register_device(vdev,type,nr)	qc_video_register_device((vdev), (type))#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)/* In 2.4.19 and earlier kernels this was called "devrequest*". * Its fields were differently named, but since the structure was same, * we support the older kernels via this uglyish hack. */struct usb_ctrlrequest {	u8 bRequestType;	u8 bRequest;	u16 wValue;	u16 wIndex;	u16 wLength;} __attribute__ ((packed));#endif#if LINUX_VERSION_CODE<KERNEL_VERSION(2,4,20) || LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,0)/* Things come and go... *//* Used only for debugging, so this could be actually removed if needed */#define sem_getcount(sem)	atomic_read(&(sem)->count)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)static inline int qc_usb_submit_urb(struct urb *urb) { return usb_submit_urb(urb); }static inline struct urb *qc_usb_alloc_urb(int packets) { return usb_alloc_urb(packets); }#undef usb_submit_urb#undef usb_alloc_urb#define usb_submit_urb(u,f)	qc_usb_submit_urb(u)#define usb_alloc_urb(u,f)	qc_usb_alloc_urb(u)#define URB_ISO_ASAP		USB_ISO_ASAP#endif#ifndef list_for_each_entry#define list_for_each_entry(pos, head, member)				\	for (pos = list_entry((head)->next, typeof(*pos), member);	\	     &pos->member != (head); 					\	     pos = list_entry(pos->member.next, typeof(*pos), member))#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)#undef MOD_INC_USE_COUNT#undef MOD_DEC_USE_COUNT#define MOD_INC_USE_COUNT#define MOD_DEC_USE_COUNT#define GET_USE_COUNT(module)	1#define EXPORT_NO_SYMBOLS#endif/* }}} *//* {{{ [fold] SECTION: debugging */#undef PDEBUG			/* undef it, just in case */#define POISON_VAL	0x5B#ifdef DEBUG#include <linux/time.h>/* PDEBUG is rather heavyweight macro and should be used only for debugging--not for general messages *//* Based on timestamp by Roger Wolff */#define PDEBUG(fmt, args...)				\	do {						\		struct timeval __tv_val;		\		do_gettimeofday(&__tv_val);		\		printk(KERN_DEBUG "quickcam [%2ld.%06ld]: ", __tv_val.tv_sec%60, __tv_val.tv_usec);	\		printk(fmt, ## args); 			\		printk("\n"); 				\	} while(0)#define IDEBUG_VAR	char *idebug_var;#define IDEBUG_INIT(x)	do { \	if ((x).idebug_var==((char*)&((x).idebug_var)) + 0xB967E57D) printk(KERN_CRIT __FILE__ ":%i: Init already done\n",__LINE__); \	(x).idebug_var = ((char*)&((x).idebug_var)) + 0xB967E57D; \} while(0)#define IDEBUG_TEST(x)	do { \	if ((x).idebug_var!=((char*)&((x).idebug_var)) + 0xB967E57D) printk(KERN_CRIT __FILE__ ":%i: Init missing\n",__LINE__); \} while(0)#define IDEBUG_EXIT(x)	do { \	IDEBUG_TEST(x); \	(x).idebug_var = NULL; \	POISON(x); \} while(0)#define IDEBUG_EXIT_NOPOISON(x)	do { \	IDEBUG_TEST(x); \	(x).idebug_var = NULL; \} while(0)#define TEST_BUG(condition) \	do { \		if ((condition)!=0) { \			PDEBUG("Badness in %s at %s:%d", __FUNCTION__, __FILE__, __LINE__); \			return; \		} \	} while (0)#define TEST_BUGR(condition) \	do { \		if ((condition)!=0) { \			PDEBUG("Badness in %s at %s:%d", __FUNCTION__, __FILE__, __LINE__); \			return -EFAULT; \		} \	} while (0)#define TEST_BUG_MSG(cond, fmt, args...) \	do { \		if ((cond)!=0) { \			PDEBUG(fmt, ## args); \			PDEBUG("Badness in %s at %s:%d", __FUNCTION__, __FILE__, __LINE__); \			return; \		} \	} while (0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -