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

📄 qc-driver.c

📁 Webcam Linux driver for Quickcam
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Start of file *//* {{{ [fold] Comments  *//* * qc-usb, Logitech QuickCam video driver with V4L support * Derived from qce-ga, linux V4L driver for the QuickCam Express and Dexxa QuickCam * * qc-driver.c - main driver part * * Copyright (C) 2001  Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland * Copyright (C) 2002,2003  Tuukka Toivonen * * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * *//* Cam variations of Logitech QuickCam:   P/N 861037:      Sensor HDCS1000        ASIC STV0600   P/N 861050-0010: Sensor HDCS1000        ASIC STV0600   P/N 861050-0020: Sensor Photobit PB100  ASIC STV0600-1 ("QuickCam Express")   P/N 861055:      Sensor ST VV6410       ASIC STV0610 ("LEGO cam")   P/N 861075-0040: Sensor HDCS1000        ASIC   P/N 961179-0700: Sensor ST VV6410       ASIC STV0602 (Dexxa WebCam USB)   P/N 861040-0000: Sensor ST VV6410       ASIC STV0610 ("QuickCam Web")   For any questions ask    	qce-ga-devel@lists.sourceforge.net	- about code   	qce-ga-discussion@lists.sourceforge.net	- about usage*//* }}} *//* {{{ [fold] Includes  */#ifdef NOKERNEL#include "quickcam.h"#else#include <linux/quickcam.h>#endif#include <linux/version.h>#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)) || (HAVE_UTSRELEASE_H == 1)#include <linux/utsrelease.h>#endif#include <linux/autoconf.h>#include <linux/module.h>#include "qc-memory.h"#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)#include <linux/slab.h>#else#include <linux/malloc.h>#endif#include <linux/kernel.h>#include <linux/init.h>#include <linux/sched.h>#include <linux/list.h>#include <linux/mm.h>#include <linux/proc_fs.h>#include <linux/smp_lock.h>#include <linux/vmalloc.h>#include <asm/io.h>#include <asm/uaccess.h>#include <asm/page.h>#include <linux/capability.h>#include <linux/poll.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)#include <linux/moduleparam.h>#endifunsigned long int_init_jiffy;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)#ifdef MODULE_PARM#undef MODULE_PARM#endif#define MODULE_PARM(a, b) module_param(a, int, 0)#endif#if 0#ifdef __BIG_ENDIAN#warning "Big Endian system"#elif __LITTLE_ENDIAN#warning "Little Endian system"#else#error "No byte order defined"#endif#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)#ifndef __le16typedef u16 __le16;#endif#ifndef __be16typedef u16 __be16;#endif#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)#define LONG(x) ((x)/BITS_PER_LONG)#endif/* }}} *//* {{{ [fold] Module parameters  */int qcdebug = DEBUGLEVEL;MODULE_PARM(qcdebug, "i");MODULE_PARM_DESC(qcdebug, "Sets the debug output (bitfield)");static int keepsettings = 0;MODULE_PARM(keepsettings, "i");MODULE_PARM_DESC(keepsettings, "Keep picture settings across one open to another (0-1)");static int settle = 0;MODULE_PARM(settle, "i");MODULE_PARM_DESC(settle, "Maximum number of frames to wait picture brightness to settle (0-255)");/* Subsampling is used to allow higher scan rate with smaller images. */static int subsample = 0;	/* normal or sub-sample (sub-sample to increase the speed) */MODULE_PARM(subsample, "i");MODULE_PARM_DESC(subsample, "Sets subsampling (0-1)");static int compress = 0;	/* Enable compressed mode if available (higher framerate) */MODULE_PARM(compress, "i");MODULE_PARM_DESC(compress, "Enable compressed mode (0-1)");static int frameskip = 0;MODULE_PARM(frameskip, "i");MODULE_PARM_DESC(frameskip, "How frequently capture frames (0-10)");static int quality = 5;		/* 5 = generalized adjustable Pei-Tam method */MODULE_PARM(quality, "i");MODULE_PARM_DESC(quality, "Sets the picture quality (0-5)");static int adaptive = 1;MODULE_PARM(adaptive, "i");MODULE_PARM_DESC(adaptive, "Automatic adaptive brightness control (0-1)");static int shutteradapt = 1;MODULE_PARM(shutteradapt, "i");MODULE_PARM_DESC(shutteradapt, "Automatic adaptive shutter control (0-1)");static int equalize = 0;	/* Disabled by default */MODULE_PARM(equalize, "i");MODULE_PARM_DESC(equalize, "Equalize image (0-1)");#define MESSENGER_USERLUT // enable USERLUT by default.#ifdef MESSENGER_USERLUT// Quickcam Messenger really need some other gamma/whitebalance at startup.//static char userlut_default[30] = "0.55:0.55:0.55:1.0:1.0:1.0"// Suggestions from Wim van Eenennaam to set this default value//static char userlut_default[30] = "1.0:1.2:1.4:1.4:1.4:1.4";#endifstatic int userlut = 1;		/* Enabled by default */MODULE_PARM(userlut, "i");MODULE_PARM_DESC(userlut, "Apply user-specified lookup-table (0-1)");static int retryerrors = 1;	/* Enabled by default */MODULE_PARM(retryerrors, "i");MODULE_PARM_DESC(retryerrors, "Retry if image capture fails, otherwise return error code (0-1)");/* Bug in Xvideo(?): if the width is not divisible by 8 and Xvideo is used, the frame is shown wrongly */static int compatible = 0;	/* Disabled by default */MODULE_PARM(compatible, "i");MODULE_PARM_DESC(compatible, "Enable workaround for bugs in application programs (bitfield)");#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)/* video_nr option allows to specify a certain /dev/videoX device *//* (like /dev/video0 or /dev/video1 ...)                          *//* for autodetect first available use video_nr=-1 (defaultvalue)  */static int video_nr = -1;MODULE_PARM(video_nr,"i");MODULE_PARM_DESC(video_nr, "Set videodevice number (/dev/videoX)");#endif/* }}} *//* {{{ [fold] Miscellaneous data  */#ifndef MODULE_LICENSE		/* Appeared in 2.4.10 */#ifdef MODULE#define MODULE_LICENSE(license) \static const char __module_license[] __attribute__((section(".modinfo"))) = \	"license=" license#else#define MODULE_LICENSE(license)#endif#endifMODULE_SUPPORTED_DEVICE("video");MODULE_DESCRIPTION("Logitech QuickCam USB driver");MODULE_AUTHOR("See README");MODULE_LICENSE("GPL");EXPORT_NO_SYMBOLS;static const int min_framewidth  = 160;	/* Minimum image size we allow delivering to user application */static const int min_frameheight = 120;static int frame_l = 0;static const char qc_proc_video_name[] = "video";static const char qc_proc_quickcam_name[] = "qcmessenger";static struct usb_device_id qc_device_table[] = {	{ USB_DEVICE(0x046D, 0x08F0) },		/* QuickCam Messenger */	{ USB_DEVICE(0x046D, 0x08F5) },		/* QuickCam Communicate */	{ USB_DEVICE(0x046D, 0x08F6) },		/* QuickCam Messenger (new) */	{ USB_DEVICE(0x046D, 0x08DA) },		/* QuickCam Messenger (new) */	{ }};MODULE_DEVICE_TABLE(usb, qc_device_table);extern const struct qc_sensor qc_sensor_vv6450;static const struct qc_sensor *sensors[] = {	&qc_sensor_vv6450,};static LIST_HEAD(quickcam_list);		/* Linked list containing all QuickCams */static DECLARE_MUTEX(quickcam_list_lock);	/* Always lock first quickcam_list_lock, then qc->lock *//* Default values for user-specified lookup-table; may be overwritten by user */static unsigned char userlut_contents[QC_LUT_SIZE] = {	/* Red */	0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,	18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,	44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,	71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87,	88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101,	102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,	114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124,	125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134,	134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143,	143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151,	152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159,	159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166,	167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173,	173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179,	180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186,	187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192,	192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197,	198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204,	204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209,	209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215,	215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219,	220, 220, 221, 221,	/* Green */	0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,	21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,	50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,	79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97,	98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113,	114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126,	127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,	139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149,	150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159,	160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168,	169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177,	177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185,	186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193,	193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200,	201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207,	208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,	214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220,	221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,	227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233,	233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,	239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244,	245, 245, 246, 246,	/* Blue */	0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,	23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,	55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,	86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106,	107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124,	125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138,	139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151,	152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163,	165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174,	176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184,	185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194,	194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203,	204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212,	212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220,	221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,	228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235,	235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242,	243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249,	249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255,	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,	255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,	255, 255, 255, 255};#if 0/* pre-caclulated array, 1.0:1.2:1.4:1.4:1.4:1.4 */static unsigned char userlut_contents_test[QC_LUT_SIZE] = {  /* Red */  0,   1,   3,   4,   6,   7,   8,  10,  11,  13,  14,  15,  17,  18,  20,  21,  22,  24,  25,  27,  28,  29,  31,  32,  34,  35,  36,  38,  39,  41,  42,  43,  45,  46,  48,  49,  50,  52,  53,  55,  56,  57,  59,  60,  62,  63,  64,  66,  67,  69,  70,  71,  73,  74,  76,  77,  78,  80,  81,  83,  84,  85,  87,  88,  90,  91,  92,  94,  95,  97,  98,  99,  101, 102, 104, 105, 106, 108, 109, 111, 112, 113, 115, 116,  118, 119, 120, 122, 123, 125, 126, 127, 129, 130, 132, 133,  134, 136, 137, 139, 140, 141, 143, 144, 146, 147, 148, 150,  151, 153, 154, 155, 157, 158, 160, 161, 162, 164, 165, 167,  168, 169, 171, 172, 174, 175, 176, 178, 179, 181, 182, 183,  185, 186, 188, 189, 190, 192, 193, 195, 196, 197, 199, 200,  202, 203, 204, 206, 207, 209, 210, 211, 213, 214, 216, 217,  218, 220, 221, 223, 224, 225, 227, 228, 230, 231, 232, 234,  235, 237, 238, 239, 241, 242, 244, 245, 246, 248, 249, 251,  252, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255,  /* Green */  0,   0,   1,   2,   2,   3,   4,   5,   6,   6,   7,   8,  9,  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  30,  31,  32,  33,  34,  35,  36,  37,  39,  40,  41,  42,  43,  44,  46,  47,  48,  49,  50,  52,  53,  54,  55,  57,  58,  59,  60,  62,  63,  64,  65,  67,  68,  69,  70,  72,  73,  74,  76,  77,  78,  80,  81,  82,  83,  85,  86,  87,  89,  90,  91,  93,  94,  95,  97,  98, 100, 101, 102, 104, 105, 106, 108, 109,  110, 112, 113, 115, 116, 117, 119, 120, 122, 123, 124, 126,  127, 129, 130, 131, 133, 134, 136, 137, 139, 140, 141, 143,  144, 146, 147, 149, 150, 152, 153, 155, 156, 157, 159, 160,  162, 163, 165, 166, 168, 169, 171, 172, 174, 175, 177, 178,  180, 181, 183, 184, 186, 187, 189, 190, 192, 193, 195, 196,  198, 199, 201, 202, 204, 205, 207, 208, 210, 212, 213, 215,  216, 218, 219, 221, 222, 224, 225, 227, 229, 230, 232, 233,  235, 236, 238, 240, 241, 243, 244, 246, 247, 249, 251, 252,  254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  255, 255, 255, 255,  /* Blue */  0,   0,   0,   1,   1,   1,   2,   2,   3,   3,   4,   4,  5,   6,   6,   7,   7,   8,   9,   9,  10,  11,  12,  12,  13,  14,  15,  15,  16,  17,  18,  19,  20,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  40,  41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51,  53,  54,  55,  56,  57,  58,  60,  61,  62,  63,  64,  65,  67,  68,  69,  70,  72,  73,  74,  75,  77,  78,  79,  80,  82,  83,  84,  86,  87,  88,  89,  91,  92,  93,  95,  96,  97,  99, 100, 102, 103, 104, 106,

⌨️ 快捷键说明

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