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

📄 ov511.h

📁 0v511摄像头linux最新驱动源码
💻 H
📖 第 1 页 / 共 2 页
字号:
enum {
	LED_OFF,
	LED_ON,
	LED_AUTO,
};

/* Raw frame formats */
enum {
	RAWFMT_INVALID,
	RAWFMT_YUV400,
	RAWFMT_YUV420,
	RAWFMT_YUV422,
	RAWFMT_GBR422,
};

/* Unsigned short option numbers */
enum {
	OV511_USOPT_INVALID,
	OV511_USOPT_BRIGHT,
	OV511_USOPT_SAT,
	OV511_USOPT_HUE,
	OV511_USOPT_CONTRAST,
};

/* Unsigned int option numbers */
enum {
	OV511_UIOPT_INVALID,
	OV511_UIOPT_POWER_FREQ,
	OV511_UIOPT_BFILTER,
	OV511_UIOPT_LED,
	OV511_UIOPT_DEBUG,
	OV511_UIOPT_COMPRESS,
};

struct ov511_ushort_opt {
	int optnum;		/* Specific option number */
	unsigned short val;
};

struct ov511_uint_opt {
	int optnum;		/* Specific option number */
	unsigned int val;
};

struct ov511_i2c_struct {
	unsigned char slave; /* Write slave ID (read ID - 1) */
	unsigned char reg;   /* Index of register */
	unsigned char value; /* User sets this w/ write, driver does w/ read */
	unsigned char mask;  /* Bits to be changed. Not used with read ops */
};

/* ioctls */
#define OV511IOC_GINTVER  _IOR('v', BASE_VIDIOCPRIVATE + 0, int)
#define OV511IOC_GUSHORT _IOWR('v', BASE_VIDIOCPRIVATE + 1, \
			       struct ov511_ushort_opt)
#define OV511IOC_SUSHORT  _IOW('v', BASE_VIDIOCPRIVATE + 2, \
			       struct ov511_ushort_opt)
#define OV511IOC_GUINT   _IOWR('v', BASE_VIDIOCPRIVATE + 3, \
			       struct ov511_uint_opt)
#define OV511IOC_SUINT    _IOW('v', BASE_VIDIOCPRIVATE + 4, \
			       struct ov511_uint_opt)
#define OV511IOC_WI2C     _IOW('v', BASE_VIDIOCPRIVATE + 5, \
			       struct ov511_i2c_struct)
#define OV511IOC_RI2C    _IOWR('v', BASE_VIDIOCPRIVATE + 6, \
			       struct ov511_i2c_struct)
/* ------------- End IOCTL interface -------------- */

struct usb_ov511;		/* Forward declaration */

struct ov511_sbuf {
	struct usb_ov511 *ov;
	unsigned char *data;
	struct urb *urb;
	spinlock_t lock;
	int n;
};

enum {
	FRAME_UNUSED,		/* Unused (no MCAPTURE) */
	FRAME_READY,		/* Ready to start grabbing */
	FRAME_GRABBING,		/* In the process of being grabbed into */
	FRAME_DONE,		/* Finished grabbing, but not been synced yet */
	FRAME_ERROR,		/* Something bad happened while processing */
};

struct ov511_regvals {
	enum {
		OV511_DONE_BUS,
		OV511_REG_BUS,
		OV511_I2C_BUS,
	} bus;
	unsigned char reg;
	unsigned char val;
};

struct ov511_frame {
	int framenum;		/* Index of this frame */
	unsigned char *data;	/* Frame buffer */
	unsigned char *tempdata; /* Temp buffer for multi-stage conversions */
	unsigned char *rawdata;	/* Raw camera data buffer */
	unsigned char *compbuf;	/* Temp buffer for decompressor */

	int depth;		/* Bytes per pixel */
	int width;		/* Width application is expecting */
	int height;		/* Height application is expecting */

	int rawwidth;		/* Actual width of frame sent from camera */
	int rawheight;		/* Actual height of frame sent from camera */

	int sub_flag;		/* Sub-capture mode for this frame? */
	unsigned int format;	/* Format for this frame */
	int compressed;		/* Is frame compressed? */

	volatile int grabstate;	/* State of grabbing */
	int scanstate;		/* State of scanning */

	int bytes_recvd;	/* Number of image bytes received from camera */

	long bytes_read;	/* Amount that has been read() */

	wait_queue_head_t wq;	/* Processes waiting */

	int snapshot;		/* True if frame was a snapshot */
};

#define DECOMP_INTERFACE_VER 4

/* Compression module operations */
struct ov51x_decomp_ops {
	int (*decomp_400)(unsigned char *, unsigned char *, unsigned char *,
			  int, int, int);
	int (*decomp_420)(unsigned char *, unsigned char *, unsigned char *,
			  int, int, int);
	int (*decomp_422)(unsigned char *, unsigned char *, unsigned char *,
			  int, int, int);
	struct module *owner;
};

struct usb_ov511 {
	struct video_device vdev;

	/* Device structure */
	struct usb_device *dev;

	int customid;
	char *desc;
	unsigned char iface;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
	char usb_path[OV511_USB_PATH_LEN];
#endif

	/* Determined by sensor type */
	int maxwidth;
	int maxheight;
	int minwidth;
	int minheight;

	int brightness;
	int colour;
	int contrast;
	int hue;
	int whiteness;
	int exposure;
	int auto_brt;		/* Auto brightness enabled flag */
	int auto_gain;		/* Auto gain control enabled flag */
	int auto_exp;		/* Auto exposure enabled flag */
	int backlight;		/* Backlight exposure algorithm flag */
	int mirror;		/* Image is reversed horizontally */

	int led_policy;		/* LED: off|on|auto; OV511+ only */

	struct semaphore lock;	/* Serializes user-accessible operations */
	int user;		/* user count for exclusive use */

	int streaming;		/* Are we streaming Isochronous? */
	int grabbing;		/* Are we grabbing? */

	int compress;		/* Should the next frame be compressed? */
	int compress_inited;	/* Are compression params uploaded? */

	int lightfreq;		/* Power (lighting) frequency */
	int bandfilt;		/* Banding filter enabled flag */

	unsigned char *fbuf;	/* Videodev buffer area */
	unsigned char *tempfbuf; /* Temporary (intermediate) buffer area */
	unsigned char *rawfbuf;	/* Raw camera data buffer area */

	int sub_flag;		/* Pix Array subcapture on flag */
	int subx;		/* Pix Array subcapture x offset */
	int suby;		/* Pix Array subcapture y offset */
	int subw;		/* Pix Array subcapture width */
	int subh;		/* Pix Array subcapture height */

	int curframe;		/* Current receiving sbuf */
	struct ov511_frame frame[OV511_NUMFRAMES];	

	struct ov511_sbuf sbuf[OV511_NUMSBUF];

	wait_queue_head_t wq;	/* Processes waiting */

	int snap_enabled;	/* Snapshot mode enabled */
	
	int bridge;		/* Type of bridge (BRG_*) */
	int bclass;		/* Class of bridge (BCL_*) */
	int sensor;		/* Type of image sensor chip (SEN_*) */

	int packet_size;	/* Frame size per isoc desc */
	int packet_numbering;	/* Is ISO frame numbering enabled? */

	struct semaphore param_lock;	/* params lock for this camera */

	/* /proc entries, relative to /proc/video/ov511/ */
	struct proc_dir_entry *proc_devdir;   /* Per-device proc directory */
	struct proc_dir_entry *proc_info;     /* <minor#>/info entry */
	struct proc_dir_entry *proc_button;   /* <minor#>/button entry */
	struct proc_dir_entry *proc_control;  /* <minor#>/control entry */

	/* Framebuffer/sbuf management */
	int buf_state;
	struct semaphore buf_lock;

	struct ov51x_decomp_ops *decomp_ops;

	/* Stop streaming while changing picture settings */
	int stop_during_set;

	int stopped;		/* Streaming is temporarily paused */

	/* Video decoder stuff */
	int input;		/* Composite, S-VIDEO, etc... */
	int num_inputs;		/* Number of inputs */
	int norm; 		/* NTSC / PAL / SECAM */
	int has_decoder;	/* Device has a video decoder */
	int pal;		/* Device is designed for PAL resolution */

	/* I2C interface */
	struct semaphore i2c_lock;	  /* Protect I2C controller regs */
	unsigned char primary_i2c_slave;  /* I2C write id of sensor */

	/* Control transaction stuff */
	unsigned char *cbuf;		/* Buffer for payload */
	struct semaphore cbuf_lock;
};

/* Used to represent a list of values and their respective symbolic names */
struct symbolic_list {
	int num;
	char *name;
};

#define NOT_DEFINED_STR "Unknown"

/* Returns the name of the matching element in the symbolic_list array. The
 * end of the list must be marked with an element that has a NULL name.
 */
static inline char * 
symbolic(struct symbolic_list list[], int num)
{
	int i;

	for (i = 0; list[i].name != NULL; i++)
			if (list[i].num == num)
				return (list[i].name);

	return (NOT_DEFINED_STR);
}

/* Compression stuff */

#define OV511_QUANTABLESIZE	64
#define OV518_QUANTABLESIZE	32

#define OV511_YQUANTABLE { \
	0, 1, 1, 2, 2, 3, 3, 4, \
	1, 1, 1, 2, 2, 3, 4, 4, \
	1, 1, 2, 2, 3, 4, 4, 4, \
	2, 2, 2, 3, 4, 4, 4, 4, \
	2, 2, 3, 4, 4, 5, 5, 5, \
	3, 3, 4, 4, 5, 5, 5, 5, \
	3, 4, 4, 4, 5, 5, 5, 5, \
	4, 4, 4, 4, 5, 5, 5, 5  \
}

#define OV511_UVQUANTABLE { \
	0, 2, 2, 3, 4, 4, 4, 4, \
	2, 2, 2, 4, 4, 4, 4, 4, \
	2, 2, 3, 4, 4, 4, 4, 4, \
	3, 4, 4, 4, 4, 4, 4, 4, \
	4, 4, 4, 4, 4, 4, 4, 4, \
	4, 4, 4, 4, 4, 4, 4, 4, \
	4, 4, 4, 4, 4, 4, 4, 4, \
	4, 4, 4, 4, 4, 4, 4, 4  \
}

#define OV518_YQUANTABLE { \
	5, 4, 5, 6, 6, 7, 7, 7, \
	5, 5, 5, 5, 6, 7, 7, 7, \
	6, 6, 6, 6, 7, 7, 7, 8, \
	7, 7, 6, 7, 7, 7, 8, 8  \
}

#define OV518_UVQUANTABLE { \
	6, 6, 6, 7, 7, 7, 7, 7, \
	6, 6, 6, 7, 7, 7, 7, 7, \
	6, 6, 6, 7, 7, 7, 7, 8, \
	7, 7, 7, 7, 7, 7, 8, 8  \
}

#endif

⌨️ 快捷键说明

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