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

📄 spca50x.c

📁 广州斯道2410普及版II的源代码
💻 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 * 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 * Conexant cx11646 * Transvision tv_8532  * 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 version[] = "56.02.06";#include <linux/config.h>#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>/* kernel.h a lot of good thing snprintf and others */#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 <linux/param.h>#define SPCA50X_ENABLE_OSD 1#define CONFIG_FB  1#ifdef SPCA50X_ENABLE_OSD#ifdef CONFIG_FB#include <video/font.h>#endif /* CONFIG_FB */#endif /* SPCA50X_ENABLE_OSD */#include "spca50x.h"//#define RH9_REMAP 1#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)#include "spcaCompat.h"#endif#include "spcadecoder.h"#include "jpeg_qtables.h"#define PROC_NAME_LEN 10 //length of the proc name#ifndef CONFIG_FB/* Force OSD off if required dependencies not enabled *//* Turning OSD on requires a kernel patch to the fbcon__ routines */#undef SPCA50X_ENABLE_OSD#endif /* CONFIG_FB *//* 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))#ifdef SPCA50X_ENABLE_OSDstruct fbcon_font_desc *osd_font = NULL;#endif /* SPCA50X_ENABLE_OSD *//* PARAMETER VARIABLES: *//* autoadjust = 1 schedule a BH and break the jpeg cam with tasklet */ static int autoadjust = 0;    /* CCD dynamically changes exposure, etc... *//* Hardware auto exposure / whiteness (PC-CAM 600) */static int autoexpo = 1;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;/* Snapshot mode enabled flag */static int snapshot = 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;/* Number of seconds before inactive buffers are deallocated */static int buf_timeout = 5;#ifdef SPCA50X_ENABLE_CAMS/* Number of cameras to stream from simultaneously */static int cams = 1;#endif /* SPCA50X_ENABLE_CAMS */static int usbgrabber = 0;#ifdef SPCA50X_ENABLE_COMPRESSION/* Enable compression. This is for experimentation only; compressed images * still cannot be decoded yet. */static int compress = 0;#endif /* SPCA50X_ENABLE_COMPRESSION */#ifdef SPCA50X_ENABLE_TESTPATTERN/* Display test pattern - doesn't work yet either */static int testpat = 0;#endif /* SPCA50X_ENABLE_TESTPATTERN *//* Initial brightness & contrast (for debug purposes) */static int bright = 0x80;static int contrast = 0x60;/* Internal/external CCD flag, initially internal CCD */static int ccd = 0;/* Parameter that enables you to set the minimal suitable bpp */static int min_bpp = 0;/* Parameter defines the average luminance that should be kept */static int lum_level = 0x2d;#ifdef SPCA50X_ENABLE_OSD/* Enable On-screen display of some data (frame sequence, time) */static int osd = 1;#endif /* SPCA50X_ENABLE_OSD */#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)module_param(autoadjust, int, 0644);module_param(autoexpo, int, 0644);module_param(debug, int, 0644);module_param(snapshot, int, 0644);module_param(force_rgb, int, 0644);module_param(gamma, int, 0444);module_param(OffRed, int, 0444);module_param(OffBlue, int, 0444);module_param(OffGreen, int, 0444);module_param(GRed, int, 0444);module_param(GBlue, int, 0444);module_param(GGreen, int, 0444);module_param(buf_timeout, int, 0444);#ifdef SPCA50X_ENABLE_CAMSmodule_param(cams, int, 0444);#endif /* SPCA50X_ENABLE_CAMS */#ifdef SPCA50X_ENABLE_COMPRESSIONmodule_param(compress, int, 0444);#endif /* SPCA50X_ENABLE_COMPRESSION */module_param(bright, int, 0444);module_param(contrast, int, 0444);module_param(ccd, int, 0444);#ifdef SPCA50X_ENABLE_OSDmodule_param(osd, int, 0444);#endif /* SPCA50X_ENABLE_OSD */module_param(min_bpp, int, 0444);module_param(lum_level, int, 0444);module_param(usbgrabber, int, 0444);#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) */MODULE_PARM(autoadjust, "i");MODULE_PARM(autoexpo, "i");MODULE_PARM(debug, "i");MODULE_PARM(snapshot, "i");MODULE_PARM(force_rgb, "i");MODULE_PARM(gamma, "i");MODULE_PARM(OffRed, "i");MODULE_PARM(OffBlue, "i");MODULE_PARM(OffGreen, "i");MODULE_PARM(GRed, "i");MODULE_PARM(GBlue, "i");MODULE_PARM(GGreen, "i");MODULE_PARM(buf_timeout, "i");#ifdef SPCA50X_ENABLE_CAMSMODULE_PARM(cams, "i");#endif /* SPCA50X_ENABLE_CAMS */#ifdef SPCA50X_ENABLE_COMPRESSIONMODULE_PARM(compress, "i");#endif /* SPCA50X_ENABLE_COMPRESSION */MODULE_PARM(bright, "i");MODULE_PARM(contrast, "i");MODULE_PARM(ccd, "i");#ifdef SPCA50X_ENABLE_OSDMODULE_PARM(osd, "i");#endif /* SPCA50X_ENABLE_OSD */MODULE_PARM(min_bpp, "i");MODULE_PARM(lum_level, "0-255i");MODULE_PARM(usbgrabber, "i");#endif/***************/MODULE_PARM_DESC(autoadjust, "CCD dynamically changes exposure (spca501x only)");MODULE_PARM_DESC(autoexpo, "Enable/Disable hardware auto exposure / whiteness (default: enabled) (PC-CAM 600 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(snapshot, "Enable snapshot mode");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 ");MODULE_PARM_DESC(buf_timeout, "Number of seconds before buffer deallocation");#ifdef SPCA50X_ENABLE_CAMSMODULE_PARM_DESC(cams, "Number of simultaneous cameras (currently only 1 supported)");#endif /* SPCA50X_ENABLE_CAMS */#ifdef SPCA50X_ENABLE_COMPRESSIONMODULE_PARM_DESC(compress, "Turn on/off compression (not functional yet)");#endif /* SPCA50X_ENABLE_COMPRESSION */MODULE_PARM_DESC(bright, "Initial brightness factor (0-255)");MODULE_PARM_DESC(contrast, "Initial contrast factor (0-255)");MODULE_PARM_DESC(ccd, "If zero, default to the internal CCD, otherwise use the external video input");#ifdef SPCA50X_ENABLE_OSDMODULE_PARM_DESC(osd, "If non-zero, enable various types of on-screen display");#endif /* SPCA50X_ENABLE_OSD */MODULE_PARM_DESC(min_bpp, "The minimal color depth that may be set (default 0)");MODULE_PARM_DESC(lum_level, "Luminance level for brightness autoadjustment (default 32)");MODULE_PARM_DESC(usbgrabber, "Is a usb grabber 0x0733:0x0430 ? (default 1) ");/****************/MODULE_AUTHOR("Joel Crisp <cydergoth@users.sourceforge.net>, based on ov511 driver by Mark McClelland <mwm@i.am> & Bret Wallach & Orion Sky Lawlor <olawlor@acm.org> & Kevin Moore & Charl P. Botha <cpbotha@ieee.org> & Claudio Matsuoka <claudio@conectiva.com>");MODULE_DESCRIPTION("SPCA50X USB Camera Driver");MODULE_LICENSE("GPL");static int spca50x_move_data(struct usb_spca50x *spca50x, struct urb *urb);static void auto_bh(void* data);static struct usb_driver spca50x_driver;#ifndef maxstatic inline int max(int a, int b){	return (a > b)? a: b;}#endif /* max *//********************************************************************** * 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"},	{YUVY,"YUVY"},	{YYUV,"YYUV"},	{YUYV,"YUYV"},	{GREY,"GREY"},	{GBRG,"GBRG"},	{SN9C,"SN9C"},	{GBGR,"GBGR"},	{-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_SPCA504_PCCAM600,"SPCA504C"},	{BRIDGE_SPCA561,"SPCA561"},	{BRIDGE_SPCA536,"SPCA536"},	{BRIDGE_SONIX,"SN9C102"},	{BRIDGE_ZC3XX,"ZC301-2"},	{BRIDGE_CX11646,"CX11646"},	{BRIDGE_TV8532,"TV8532"},	{-1,NULL}};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	LastCamera};static struct cam_list clist[] = {	{UnknownCamera, "Unknown"},	{IntelPCCameraPro, "Intel PC Camera Pro"},	{IntelCreateAndShare, "Intel Create and Share"},	{GrandtecVcap, "Grandtec V.cap"},	{ViewQuestM318B, "ViewQuest M318B"},	{ViewQuestVQ110, "ViewQuest VQ110"},	{KodakDVC325, "Kodak DVC-325"},	{MustekGsmartMini2, "Mustek gSmart mini 2"},	{MustekGsmartMini3, "Mustek gSmart mini 3"},	{CreativePCCam300, "Creative PC-CAM 300"},

⌨️ 快捷键说明

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