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

📄 gspca_core.c

📁 Linux下面摄像头最新源代码:支持200多中摄像头
💻 C
📖 第 1 页 / 共 5 页
字号:
/** SPCA5xx based usb camera driver (currently supports* yuv native stream spca501a, spca501c, spca505, spca508, spca506* jpeg native stream spca500, spca551, spca504a, spca504b, spca533a, spca536a, zc0301, zc0302, cx11646, sn9c102p* bayer native stream spca561a, sn9c101, sn9c102, tv8532 ).* Z-star Vimicro chips zc0301 zc0301P zc0302* Sunplus spca501a, spca501c, spca505, spca508, spca506, spca500, spca551, spca504a, spca504b, spca533a, spca536a* Sonix sn9c101, sn9c102, sn9c102p sn9c105 sn9c120* Conexant cx11646* Transvision tv_8532 * Etoms Et61x151 Et61x251* Pixart Pac207-BCA-32* SPCA5xx version by Michel Xhaard <mxhaard@users.sourceforge.net>* Based on :* SPCA50x version by Joel Crisp <cydergoth@users.sourceforge.net>* OmniVision OV511 Camera-to-USB Bridge Driver* Copyright (c) 1999-2000 Mark W. McClelland* Kernel 2.6.x port Michel Xhaard && Reza Jelveh (feb 2004)* Based on the Linux CPiA driver written by Peter Pregler,* Scott J. Bertin and Johannes Erdfelt.* This program is free software; you can redistribute it and/or modify it* under the terms of the GNU General Public License as published by the* Free Software Foundation; either version 2 of the License, or (at your* option) any later version.** This program is distributed in the hope that it will be useful, but* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY* or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License* for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software Foundation,* Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/static const char gspca_version[] = GSPCA_VERSION;#ifndef AUTOCONF_INCLUDED#include <linux/config.h>#endif#include <linux/module.h>#include <linux/version.h>#include <linux/init.h>#include <linux/fs.h>#include <linux/vmalloc.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/string.h>#include <linux/kernel.h>#include <linux/proc_fs.h>#include <linux/ctype.h>#include <linux/pagemap.h>#include <linux/usb.h>#include <asm/io.h>#include <asm/semaphore.h>#include <asm/page.h>#include <asm/uaccess.h>#include <asm/atomic.h>/* only on 2.6.x */#include <linux/jiffies.h>#include <linux/param.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)#include <linux/moduleparam.h>#endif#include "gspca.h"#include "decoder/gspcadecoder.h"/* Video Size 640 x 480 x 4 bytes for RGB */#define MAX_FRAME_SIZE (640 * 480 * 4)#define MAX_DATA_SIZE (MAX_FRAME_SIZE + sizeof(struct timeval))/* Hardware auto exposure / whiteness (PC-CAM 600) */static int autoexpo = 1;/* Video device number (-1 is first available) */static int video_nr = -1;/* 0=no debug messages* 1=init/detection/unload and other significant messages,* 2=some warning messages* 3=config/control function calls* 4=most function calls and data parsing messages* 5=highly repetitive mesgs* NOTE: This should be changed to 0, 1, or 2 for production kernels*/static int debug = 0;/* Force image to be read in RGB instead of BGR. This option allow* programs that expect RGB data (e.g. gqcam) to work with this driver. */static int force_rgb = 0;static int gamma = 3;static int OffRed = 0;static int OffBlue = 0;static int OffGreen = 0;static int GRed = 256;static int GBlue = 256;static int GGreen = 256;static int usbgrabber = 0;#ifdef GSPCA_ENABLE_COMPRESSION/* Enable compression. This is for experimentation only; compressed images* still cannot be decoded yet. */static int compress = 0;#endif/* Light frequency banding filter 50HZ/60HZ/NoFliker */static int lightfreq = 50;#ifdef GSPCA_ENABLE_REGISTERPLAYstatic int RegAddress = 0;static int RegValue = 0;static int RegStrobe = 0;#endifmodule_param(autoexpo, int, 0644);module_param(debug, int, 0644);module_param(force_rgb, int, 0644);module_param(gamma, int, 0644);module_param(OffRed, int, 0644);module_param(OffBlue, int, 0644);module_param(OffGreen, int, 0644);module_param(GRed, int, 0644);module_param(GBlue, int, 0644);module_param(GGreen, int, 0644);#ifdef GSPCA_ENABLE_COMPRESSIONmodule_param(compress, int, 0644);#endifmodule_param(usbgrabber, int, 0444);module_param(lightfreq, int, 0644);#ifdef GSPCA_ENABLE_REGISTERPLAYmodule_param(RegAddress, int, 0644);module_param(RegValue, int, 0644);module_param(RegStrobe, int, 0644);#endifMODULE_PARM_DESC(autoexpo,		 "Enable/Disable auto exposure (default=1: enabled) (PC-CAM 600/Zc03xx/spca561a/Etoms Only !!!)");MODULE_PARM_DESC(debug,		 "Debug level: 0=none, 1=init/detection, 2=warning, 3=config/control, 4=function call, 5=max");MODULE_PARM_DESC(force_rgb, "Read RGB instead of BGR");MODULE_PARM_DESC(gamma, "gamma setting range 0 to 7 3-> gamma=1");MODULE_PARM_DESC(OffRed, "OffRed setting range -128 to 128");MODULE_PARM_DESC(OffBlue, "OffBlue setting range -128 to 128");MODULE_PARM_DESC(OffGreen, "OffGreen setting range -128 to 128");MODULE_PARM_DESC(GRed, "Gain Red setting range 0 to 512 /256 ");MODULE_PARM_DESC(GBlue, "Gain Blue setting range 0 to 512 /256 ");MODULE_PARM_DESC(GGreen, "Gain Green setting range 0 to 512 /256 ");#ifdef GSPCA_ENABLE_COMPRESSIONMODULE_PARM_DESC(compress, "Turn on/off compression (not functional yet)");#endif				/* SPCA50X_ENABLE_COMPRESSION */MODULE_PARM_DESC(usbgrabber, "Is a usb grabber 0x0733:0x0430 ? (default 1) ");MODULE_PARM_DESC(lightfreq,  "Light frequency banding filter. Set to 50 or 60 Hz, or zero to NoFliker (default=50)");#ifdef GSPCA_ENABLE_REGISTERPLAYMODULE_PARM_DESC(RegAddress, "Register Address of PAC207");MODULE_PARM_DESC(RegValue, "Register Value for PAC207");MODULE_PARM_DESC(RegStrobe,		 "Strobe to read or write a register 1=write, 2=read");#endif				/* SPCA5XX_ENABLE_REGISTERPLAY *//****************/MODULE_AUTHOR    ("Michel Xhaard <mxhaard@users.sourceforge.net> based on spca50x driver by Joel Crisp <cydergoth@users.sourceforge.net>,ov511 driver by Mark McClelland <mwm@i.am>");MODULE_DESCRIPTION("GSPCA/SPCA5XX USB Camera Driver");MODULE_LICENSE("GPL");#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)static voidspca50x_isoc_irq(struct urb *urb, struct pt_regs *regs);#elsestatic voidspca50x_isoc_irq(struct urb *urb);#endifstatic int spca50x_move_data(struct usb_spca50x *spca50x, struct urb *urb);static int spca5xx_set_light_freq(struct usb_spca50x *spca50x, int freq);static struct usb_driver spca5xx_driver;/*********************************************************************** List of known SPCA50X-based cameras**********************************************************************//* Camera type jpeg yuvy yyuv yuyv grey gbrg*/static struct palette_list Plist[] = {	{JPEG, "JPEG"},	{JPGH, "JPEG"},	{JPGC, "JPEG"},	{JPGS, "JPEG"},	{JPGM, "JPEG"},	{YUVY, "YUVY"},	{YYUV, "YYUV"},	{YUYV, "YUYV"},	{GREY, "GREY"},	{GBRG, "GBRG"},	{SN9C, "SN9C"},	{GBGR, "GBGR"},	{S561, "S561"},	{PGBRG, "GBRG"},	{YUY2, "YUYV"},	{PJPG, "JPEG"},	{-1, NULL}};static struct bridge_list Blist[] = {	{BRIDGE_SPCA505, "SPCA505"},	{BRIDGE_SPCA506, "SPCA506"},	{BRIDGE_SPCA501, "SPCA501"},	{BRIDGE_SPCA508, "SPCA508"},	{BRIDGE_SPCA504, "SPCA504"},	{BRIDGE_SPCA500, "SPCA500"},	{BRIDGE_SPCA504B, "SPCA504B"},	{BRIDGE_SPCA533, "SPCA533"},	{BRIDGE_SPCA504C, "SPCA504C"},	{BRIDGE_SPCA561, "SPCA561"},	{BRIDGE_SPCA536, "SPCA536"},	{BRIDGE_SONIX, "SN9C102"},	{BRIDGE_ZC3XX, "ZC301-2"},	{BRIDGE_CX11646, "CX11646"},	{BRIDGE_TV8532, "TV8532"},	{BRIDGE_ETOMS, "ET61XX51"},	{BRIDGE_SN9CXXX, "SN9CXXX"},	{BRIDGE_MR97311, "MR97311"},	{BRIDGE_PAC207, "PAC207BCA"},	{BRIDGE_VC032X, "VC0321"}, 	{BRIDGE_PAC7311, "PAC7311"},	{-1, NULL}};/* Light frequency banding filter 50HZ/60HZ/NoFliker */enum {        freq_50HZ=0,       freq_60HZ,       NoFliker};enum {	UnknownCamera = 0,	// 0	IntelPCCameraPro,	IntelCreateAndShare,	GrandtecVcap,	ViewQuestM318B,	ViewQuestVQ110,	KodakDVC325,	MustekGsmartMini2,	MustekGsmartMini3,	CreativePCCam300,	DLinkDSC350,		// 10	CreativePCCam600,	IntelPocketPCCamera,	IntelEasyPCCamera,	ThreeComHomeConnectLite,	KodakEZ200,	MaxellMaxPocket,	AiptekMiniPenCam2,	AiptekPocketDVII,	AiptekPenCamSD,	AiptekMiniPenCam13,	// 20	MustekGsmartLCD3,	MustekMDC5500Z,	MegapixV4,	AiptekPocketDV,	HamaUSBSightcam,	Arowana300KCMOSCamera,	MystFromOriUnknownCamera,	AiptekPocketDV3100,	AiptekPocketCam3M,	GeniusVideoCAMExpressV2,	// 30	Flexcam100Camera,	MustekGsmartLCD2,	PureDigitalDakota,	PetCam,	BenqDC1500,	LogitechClickSmart420,	LogitechClickSmart510,	BenqDC1300,	HamaUSBSightcam2,	MustekDV3000,		// 40	CreativePccam750,	MaxellCompactPM3,	BenqDC3410,	BenqDC1016,	MicroInnovationIC200,	LogitechTraveler,	Flycam100Camera,	UsbGrabberPV321c,	ADSInstantVCD,	Gsmartmini,		// 50	Jenoptikjdc21lcd,	LogitechClickSmart310,	Terratec2move13,	MustekDV4000,	AiptekDV3500,	LogitechClickSmart820,	Enigma13,	Sonix6025,	Epsilon13,	Nxultra,		//60	AiptekPocketCam2M,	DeMonUSBCapture,	CreativeVista,	PolaroidPDC2030,	CreativeNotebook,	CreativeMobile,	LabtecPro,	MustekWcam300A,	GeniusVideoCamV2,	GeniusVideoCamV3,	GeniusVideoCamExpressV2b,	CreativeNxPro,	Sonix6029,		//73 74 75	Vimicro,	Digitrex2110,	GsmartD30,	CreativeNxPro2,	Bs888e,	Zc302,	CreativeNoteBook2,	AiptekSlim3200,		/* 83 84 85 */	LabtecWebcam,	QCExpress,	ICM532cam,	MustekGsmart300,	CreativeLive,		//90	MercuryDigital,	Wcam300A,	CreativeVista3b,	VeoStingray1,	VeoStingray2,	TyphoonWebshotIIUSB300k,	//96	PolaroidPDC3070,	QCExpressEtch2,	QCforNotebook,	QCim,			//100	WebCam320,	AiptekPocketCam4M,	AiptekPocketDV5100,	AiptekPocketDV5300,	SunplusGeneric536,	QCimA1,	QCchat,	QCimB9,	Labtec929,		//109 110	Etoms61x151,	Etoms61x251,	PalmPixDC85,	Optimedia,	ToptroIndus,	AgfaCl20,	LogitechQC92x,	SonixWC311P,	Concord3045,	Mercury21,		//120	CreativeNX,	CreativeInstant1,	CreativeInstant2,	QuickCamNB,	WCam300AN,	LabtecWCPlus,	GeniusVideoCamMessenger,	Pcam,	GeniusDsc13,	MustekMDC4000,		//130	LogitechQCCommunicateSTX,	Lic200,	SweexTas5110,	Pccam168,	Sn535,	Pccam,	Lic300,	PolaroidIon80,	Zc0305b,	BtcPc380,		//140	LogitechNotebookDeluxe,	LabtecNotebook,	JvcGcA50,	SmileIntlCamera,	PcCam350,	PAC207,	QtecWb100,	GeniusGe111,	Vimicro303b,	CyberpixS550V,	GeniusGF112,	LogitechQCim,	AiptekSlim3000F,	CTXM730VCam,	GeniusVideoCamNB,	CreativeVistaPlus,	PhilipsSPC200NC,	PhilipsSPC210NC,	PhilipsSPC700NC,	SpeedNVC350K,	Mustek330K,	PhilipsSPC600NC,	PhilipsSPC300NC,	Sonix6019,	LogitechQCImage,	Sunplus500c,	MustekMDC3500,	LogitechQCCool,	QCimconnect,	QCmessenger,	CreativeLiveCamNotebookPro,	CreativeWebCamVistaPro,	CreativeLiveCamVideoIM,	AiptekDV4100M,	TyphoonEasyCam1_3,	Sonix0x613b,	Sonix0x60fb,	Sonyc002,	Vimicro0321,	Orbicam,	MSVX1000,	MSVX3000,	Trust610LCDPowerCamZoom,	Sonyc001,	PhilipsSPC315NC,	Sonix0x6138,

⌨️ 快捷键说明

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