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

📄 spca506.h

📁 linux摄像头驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
    return 0;}static void spca506_start(struct usb_spca50x *spca50x){    __u16 norme = 0;    __u16 channel = 0;    unsigned char Data[2];    PDEBUG(3, "************ Open Start spca506  **************");	/***********************************************************/    spca5xxRegWrite(spca50x->dev, 0x03, 0x00, 0x0004, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x00, 0x0003, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x00, 0x0004, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0xFF, 0x0003, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x02, 0x00, 0x0000, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x60, 0x0000, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x18, 0x0001, NULL, 0);    /*spca506_WriteI2c(value,register) */    spca506_Initi2c(spca50x);    spca506_WriteI2c(spca50x, 0x08, 0x01);	//Increment Delay    //spca506_WriteI2c(spca50x,0xc0,0x02);//Analog Input Control 1    spca506_WriteI2c(spca50x, 0x33, 0x03);	//Analog Input Control 2    spca506_WriteI2c(spca50x, 0x00, 0x04);	//Analog Input Control 3    spca506_WriteI2c(spca50x, 0x00, 0x05);	//Analog Input Control 4    spca506_WriteI2c(spca50x, 0x0d, 0x06);	//Horizontal Sync Start 0xe9-0x0d    spca506_WriteI2c(spca50x, 0xf0, 0x07);	//Horizontal Sync Stop  0x0d-0xf0    spca506_WriteI2c(spca50x, 0x98, 0x08);	//Sync Control    /*                      Defaults value                       */    spca506_WriteI2c(spca50x, 0x03, 0x09);	//Luminance Control    spca506_WriteI2c(spca50x, 0x80, 0x0a);	//Luminance Brightness    spca506_WriteI2c(spca50x, 0x47, 0x0b);	//Luminance Contrast    spca506_WriteI2c(spca50x, 0x48, 0x0c);	//Chrominance Saturation    spca506_WriteI2c(spca50x, 0x00, 0x0d);	//Chrominance Hue Control    spca506_WriteI2c(spca50x, 0x2a, 0x0f);	//Chrominance Gain Control	/*************************************************************/    spca506_WriteI2c(spca50x, 0x00, 0x10);	//Format/Delay Control    spca506_WriteI2c(spca50x, 0x0c, 0x11);	//Output Control 1    spca506_WriteI2c(spca50x, 0xb8, 0x12);	//Output Control 2    spca506_WriteI2c(spca50x, 0x01, 0x13);	//Output Control 3    spca506_WriteI2c(spca50x, 0x00, 0x14);	//reserved    spca506_WriteI2c(spca50x, 0x00, 0x15);	//VGATE START    spca506_WriteI2c(spca50x, 0x00, 0x16);	//VGATE STOP    spca506_WriteI2c(spca50x, 0x00, 0x17);	//VGATE Control (MSB)    spca506_WriteI2c(spca50x, 0x00, 0x18);    spca506_WriteI2c(spca50x, 0x00, 0x19);    spca506_WriteI2c(spca50x, 0x00, 0x1a);    spca506_WriteI2c(spca50x, 0x00, 0x1b);    spca506_WriteI2c(spca50x, 0x00, 0x1c);    spca506_WriteI2c(spca50x, 0x00, 0x1d);    spca506_WriteI2c(spca50x, 0x00, 0x1e);    spca506_WriteI2c(spca50x, 0xa1, 0x1f);    spca506_WriteI2c(spca50x, 0x02, 0x40);    spca506_WriteI2c(spca50x, 0xff, 0x41);    spca506_WriteI2c(spca50x, 0xff, 0x42);    spca506_WriteI2c(spca50x, 0xff, 0x43);    spca506_WriteI2c(spca50x, 0xff, 0x44);    spca506_WriteI2c(spca50x, 0xff, 0x45);    spca506_WriteI2c(spca50x, 0xff, 0x46);    spca506_WriteI2c(spca50x, 0xff, 0x47);    spca506_WriteI2c(spca50x, 0xff, 0x48);    spca506_WriteI2c(spca50x, 0xff, 0x49);    spca506_WriteI2c(spca50x, 0xff, 0x4a);    spca506_WriteI2c(spca50x, 0xff, 0x4b);    spca506_WriteI2c(spca50x, 0xff, 0x4c);    spca506_WriteI2c(spca50x, 0xff, 0x4d);    spca506_WriteI2c(spca50x, 0xff, 0x4e);    spca506_WriteI2c(spca50x, 0xff, 0x4f);    spca506_WriteI2c(spca50x, 0xff, 0x50);    spca506_WriteI2c(spca50x, 0xff, 0x51);    spca506_WriteI2c(spca50x, 0xff, 0x52);    spca506_WriteI2c(spca50x, 0xff, 0x53);    spca506_WriteI2c(spca50x, 0xff, 0x54);    spca506_WriteI2c(spca50x, 0xff, 0x55);    spca506_WriteI2c(spca50x, 0xff, 0x56);    spca506_WriteI2c(spca50x, 0xff, 0x57);    spca506_WriteI2c(spca50x, 0x00, 0x58);    spca506_WriteI2c(spca50x, 0x54, 0x59);    spca506_WriteI2c(spca50x, 0x07, 0x5a);    spca506_WriteI2c(spca50x, 0x83, 0x5b);    spca506_WriteI2c(spca50x, 0x00, 0x5c);    spca506_WriteI2c(spca50x, 0x00, 0x5d);    spca506_WriteI2c(spca50x, 0x00, 0x5e);    spca506_WriteI2c(spca50x, 0x00, 0x5f);    spca506_WriteI2c(spca50x, 0x00, 0x60);    spca506_WriteI2c(spca50x, 0x05, 0x61);    spca506_WriteI2c(spca50x, 0x9f, 0x62);	/***********************************************************/    spca5xxRegWrite(spca50x->dev, 0x05, 0x00, 0x0003, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x05, 0x00, 0x0004, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x10, 0x0001, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x78, 0x0000, NULL, 0);    switch(spca50x->mode){    case 0:    spca506_Setsize(spca50x, 0,			    0x10, 0x10);    break;    case 1:    spca506_Setsize(spca50x, 1,			    0x1a, 0x1a);    break;    case 2:    spca506_Setsize(spca50x, 2,			    0x1c, 0x1c);    break;    case 4:    spca506_Setsize(spca50x, 4,			    0x34, 0x34);    break;    case 5:    spca506_Setsize(spca50x, 5,			    0x40, 0x40);    break;    default:    spca506_Setsize(spca50x, 5,			    0x40, 0x40);    break;    }    /* compress setting and size */    /* set i2c luma */    spca5xxRegWrite(spca50x->dev, 0x02, 0x01, 0x0000, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x12, 0x0001, NULL, 0);    spca5xxRegRead(spca50x->dev, 0x04, 0, 0x0001, Data, 2);    PDEBUG(3, "************ Close Start spca506  **************");    spca506_GetNormeInput(spca50x, &norme, &channel);    spca506_SetNormeInput(spca50x, norme, channel);}static void spca506_stopN(struct usb_spca50x *spca50x){    spca5xxRegWrite(spca50x->dev, 0x02, 0x00, 0x0000, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x00, 0x0004, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x03, 0x00, 0x0003, NULL, 0);}static void spca506_Setsize(struct usb_spca50x *spca50x, __u16 code,			    __u16 xmult, __u16 ymult){    PDEBUG(3, "************ Open SetSize spca506  **************");    spca5xxRegWrite(spca50x->dev, 0x04, (0x18 | (code & 0x07)), 0x0000,		    NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x04, 0x41, 0x0001, NULL, 0);	// Soft snap 0x40 Hard 0x41    spca5xxRegWrite(spca50x->dev, 0x04, 0x00, 0x0002, NULL, 0);    spca5xxRegWrite(spca50x->dev, 0x04, 0x00, 0x0003, NULL, 0);	//reserved    spca5xxRegWrite(spca50x->dev, 0x04, 0x00, 0x0004, NULL, 0);	//reserved    spca5xxRegWrite(spca50x->dev, 0x04, 0x01, 0x0005, NULL, 0);	//reserved    spca5xxRegWrite(spca50x->dev, 0x04, xmult, 0x0006, NULL, 0);	//reserced    spca5xxRegWrite(spca50x->dev, 0x04, ymult, 0x0007, NULL, 0);	//reserved    spca5xxRegWrite(spca50x->dev, 0x04, 0x00, 0x0008, NULL, 0);	// compression 1    spca5xxRegWrite(spca50x->dev, 0x04, 0x00, 0x0009, NULL, 0);	//T=64 -> 2    spca5xxRegWrite(spca50x->dev, 0x04, 0x21, 0x000a, NULL, 0);	//threshold2D    spca5xxRegWrite(spca50x->dev, 0x04, 0x00, 0x000b, NULL, 0);	//quantization    PDEBUG(3, "************ Close SetSize spca506  **************");}static __u16 spca506_getbrightness(struct usb_spca50x *spca50x){spca50x->brightness = (spca506_ReadI2c(spca50x, SAA7113_bright)) << 8;return spca50x->brightness;}static __u16 spca506_getcontrast(struct usb_spca50x *spca50x){spca50x->contrast = (spca506_ReadI2c(spca50x, SAA7113_contrast)) << 8;return spca50x->contrast;}static __u16 spca506_getcolors(struct usb_spca50x *spca50x){spca50x->hue = (spca506_ReadI2c(spca50x, SAA7113_hue)) << 8;spca50x->colour = (spca506_ReadI2c(spca50x, SAA7113_saturation)) << 8;return spca50x->colour;}static void spca506_setbrightness(struct usb_spca50x *spca50x){    spca506_Initi2c(spca50x);    spca506_WriteI2c(spca50x, ((spca50x->brightness >> 8) & 0xFF), SAA7113_bright);    spca506_WriteI2c(spca50x, 0x01, 0x09);}static void spca506_setcontrast(struct usb_spca50x *spca50x){ spca506_Initi2c(spca50x); spca506_WriteI2c(spca50x, ((spca50x->contrast >> 8) & 0xFF), SAA7113_contrast); spca506_WriteI2c(spca50x, 0x01, 0x09);}static void spca506_setcolors(struct usb_spca50x *spca50x){    spca506_Initi2c(spca50x);    spca506_WriteI2c(spca50x, ((spca50x->hue >> 8) & 0xFF), SAA7113_hue);    spca506_WriteI2c(spca50x, ((spca50x->colour >> 8) & 0xFF), SAA7113_saturation);    spca506_WriteI2c(spca50x, 0x01, 0x09);}static int spca506_config(struct usb_spca50x *spca50x){    memset(spca50x->mode_cam, 0x00, TOTMODE * sizeof(struct mwebcam));    spca50x->mode_cam[VGA].width = 640;    spca50x->mode_cam[VGA].height = 480;    spca50x->mode_cam[VGA].t_palette =	P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[VGA].pipe = 1023;    spca50x->mode_cam[VGA].method = 0;    spca50x->mode_cam[VGA].mode = 0;        spca50x->mode_cam[PAL].width = 384;    spca50x->mode_cam[PAL].height = 288;    spca50x->mode_cam[PAL].t_palette =	P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[PAL].pipe = 1023;    spca50x->mode_cam[PAL].method = 1;    spca50x->mode_cam[PAL].mode = 0;        spca50x->mode_cam[SIF].width = 352;    spca50x->mode_cam[SIF].height = 288;    spca50x->mode_cam[SIF].t_palette =	P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[SIF].pipe = 1023;    spca50x->mode_cam[SIF].method = 0;    spca50x->mode_cam[SIF].mode = 1;        spca50x->mode_cam[CIF].width = 320;    spca50x->mode_cam[CIF].height = 240;    spca50x->mode_cam[CIF].t_palette =	P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[CIF].pipe = 896;    spca50x->mode_cam[CIF].method = 0;    spca50x->mode_cam[CIF].mode = 2;        spca50x->mode_cam[QPAL].width = 192;    spca50x->mode_cam[QPAL].height = 144;    spca50x->mode_cam[QPAL].t_palette =	P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[QPAL].pipe = 896;    spca50x->mode_cam[QPAL].method = 1;    spca50x->mode_cam[QPAL].mode = 2;        spca50x->mode_cam[QSIF].width = 176;    spca50x->mode_cam[QSIF].height = 144;    spca50x->mode_cam[QSIF].t_palette =	P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[QSIF].pipe = 512;    spca50x->mode_cam[QSIF].method = 0;    spca50x->mode_cam[QSIF].mode = 4;        spca50x->mode_cam[QCIF].width = 160;    spca50x->mode_cam[QCIF].height = 120;    spca50x->mode_cam[QCIF].t_palette =	P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16;    spca50x->mode_cam[QCIF].pipe = 384;    spca50x->mode_cam[QCIF].method = 0;    spca50x->mode_cam[QCIF].mode = 5;    return 0;}static int spca506_sofdetect(struct usb_spca50x *spca50x,struct spca50x_frame *frame, unsigned char *cdata,int *iPix, int seqnum,int *datalength){           switch (cdata[0]){	   case 0:	   	*iPix = SPCA50X_OFFSET_DATA;		*datalength -= *iPix;	   	return 0;	   case SPCA50X_SEQUENCE_DROP:	   	return -1;	   default:	        *iPix = 1;	        *datalength -= *iPix;	   	return seqnum+1 ;	   }}#endif				/* SPCA506_INIT_H *///eof

⌨️ 快捷键说明

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