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

📄 spca504_init.h

📁 linux下的摄像头驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
	spca50x_reg_write(spca50x->dev,reg,idx,val);	notdone=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1);	spca50x_reg_write(spca50x->dev,reg,idx,val);	PDEBUG(5,"before wait 0x%x",notdone);	wait_ms(200);	notdone=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1);	PDEBUG(5,"after wait 0x%x",notdone);		return;}static void spca504A_acknowledged_command(struct usb_spca50x *spca50x, 				 __u16 reg,				 __u16 idx,				 __u16 val,				 __u8 stat,				 __u8 count) { 	__u8  status ;	__u8  endcode;		spca50x_reg_write(spca50x->dev,reg,idx,val);	status=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1);	endcode = stat ;	PDEBUG(5,"Status 0x%x Need 0x%x",status, stat);	if (count) {		while (1){			wait_ms(10);			/* gsmart mini2 write a each wait setting 1 ms is enought*/			//spca50x_reg_write(spca50x->dev,reg,idx,val);			status=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1);			if (status == endcode) {				 PDEBUG(5,"status 0x%x after wait 0x%x",status,count);				break;			}			count++;			if(count > 200) break;				}	}	return;}static void spca504_pccam600_initialize(struct usb_spca50x *spca50x){	int enable;	if (spca50x->desc == LogitechClickSmart420) {	spca50x_write_vector(spca50x, spca504A_clicksmart420_init_data);	} else {	spca50x_write_vector(spca50x, spca504_pccam600_init_data);	}	enable = (autoexpo ? 0x4 : 0x1);	spca50x_reg_write(spca50x->dev, 0x0c, 0x0000, enable); // auto exposure	spca50x_reg_write(spca50x->dev, 0xb0, 0x0000, enable); // auto whiteness			/* set default exposure compensation and whiteness balance */	spca50x_reg_write(spca50x->dev, 0x30, 0x0001, 800); // ~ 20 fps	spca50x_reg_write(spca50x->dev, 0x30, 0x0002, 1600);}/* version based on the snoops of gsmart mini3 */static void spca504_initialize(struct usb_spca50x *spca50x){	__u8 i;	__u8 info[6];				if (spca50x->desc == AiptekMiniPenCam13){		for (i=0; i<6; i++)		{			info[i]=spca50x_reg_read_with_value(spca50x->dev,			                                    0x20, i, 0x0000, 1);		}		PDEBUG(0, "Read info: %d %d %d %d %d %d . Should be 1,0,2,2,0,0\n",		       info[0], info[1], info[2], info[3], info[4], info[5]);					/* spca504a aiptek */			// Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz 	       			spca504A_acknowledged_command(spca50x, 0x24, 8, 3,0x9e,1);			// Twice sequencial need status 0xff->0x9e->0x9d 			spca504A_acknowledged_command(spca50x, 0x24, 8, 3,0x9e,0);			spca504A_acknowledged_command(spca50x, 0x24, 0, 0,0x9d,1);		} else {			spca504_acknowledged_command(spca50x, 0x24, 8, 3);			for (i=0; i<6; i++)			{			info[i]=spca50x_reg_read_with_value(spca50x->dev,			                                    0x20, i, 0x0000, 1);			}			PDEBUG(0, "Read info: %d %d %d %d %d %d . Should be 1,0,2,2,0,0\n",		       info[0], info[1], info[2], info[3], info[4], info[5]);			spca504_acknowledged_command(spca50x, 0x24, 8, 3);			spca504_acknowledged_command(spca50x, 0x24, 0, 0);		}						spca50x_reg_write(spca50x->dev, 0x0, 0x270c, 0x5); // L92 sno1t.txt 		spca50x_reg_write(spca50x->dev, 0x0, 0x2310, 0x5);		spca50x_reg_write(spca50x->dev, 0x0, 0x21a7, 0x0000); /* brightness */		spca50x_reg_write(spca50x->dev, 0x0, 0x21a8, 0x0020); /* contrast */		spca50x_reg_write(spca50x->dev, 0x0, 0x21ad, 0x0000); /* hue */		spca50x_reg_write(spca50x->dev, 0x0, 0x21ac, 0x0001); /* sat/hue */		spca50x_reg_write(spca50x->dev, 0x0, 0x21ae, 0x0020); /* saturation */		spca50x_reg_write(spca50x->dev, 0x0, 0x21a3, 0x0000); /* gamma */	}static void spca504_wait_status(struct usb_spca50x *spca50x){	int ret;	/* FIXME: This is a potential infinite loop.	 *        NWG: 18/05/2003.	 */	do {		/* With this we get the status, when return 0 it's all ok */		ret = spca50x_reg_read(spca50x->dev, 0x06, 0x00, 1);	} while(ret != 0);}static void spca50x_GetFirmware(struct usb_spca50x *spca50x){	__u8 FW[5] = {0,0,0,0,0};	__u8 ProductInfo[64];		spca5xxRegRead(spca50x->dev,0x20 ,0 ,0 ,FW ,5);	PDEBUG(0, "FirmWare : %d %d %d %d %d ", FW[0],FW[1],FW[2],FW[3],FW[4] );	spca5xxRegRead(spca50x->dev,0x23 ,0 ,0 ,ProductInfo ,64);	spca5xxRegRead(spca50x->dev,0x23 ,0 ,1 ,ProductInfo ,64);	return ;}static int spca504B_PollingDataReady(struct usb_device *dev)		            {		__u8 DataReady = 0 ;	int count = 0;	while(1) {		spca5xxRegRead(dev,0x21,0, 0, &DataReady,1);		if ( (DataReady & 0x01) == 0) break;		wait_ms(10);		count++;		if (count > 10) break;			}	return DataReady;}static void spca504B_WaitCmdStatus(struct usb_spca50x *spca50x){		__u8 DataReady = 0;	int ReqDone;	int count = 0;	while (1) {		spca5xxRegRead(spca50x->dev,0x21,0, 1, &DataReady,1);		if ( DataReady ) {			DataReady = 0;			spca5xxRegWrite(spca50x->dev,0x21,0, 1, &DataReady, 1);					spca5xxRegRead(spca50x->dev,0x21,0, 1, &DataReady, 1);			ReqDone = spca504B_PollingDataReady(spca50x->dev);			break ;           		}		wait_ms (10);			count++;		if (count > 50) break;			} 	return ;}static void spca504B_setQtable ( struct usb_spca50x *spca50x ){	__u8 Data = 3 ;	int rc ;	spca5xxRegWrite(spca50x->dev,0x26,0 ,0 ,&Data ,1 );	spca5xxRegRead(spca50x->dev,0x26 ,0 ,0 , &Data ,1);	rc = spca504B_PollingDataReady ( spca50x->dev );	return ;}static void spca504B_SetSizeType(struct usb_spca50x *spca50x , __u16 extSize ,__u16 extType){	__u8 Size ;	__u8 Type ;	int rc;	Size = (__u8) extSize;	Type = (__u8) extType;		if ( spca50x->bridge == BRIDGE_SPCA533) {		spca5xxRegWrite(spca50x->dev,0x31,0 ,0 ,NULL ,0 );		spca504B_WaitCmdStatus(spca50x);		rc = spca504B_PollingDataReady(spca50x->dev);			spca50x_GetFirmware( spca50x );				Type = 2;		spca5xxRegWrite(spca50x->dev,0x24,0 ,8 ,&Type ,1 );		spca5xxRegRead(spca50x->dev,0x24,0 ,8 ,&Type ,1 );			spca5xxRegWrite(spca50x->dev,0x25,0 ,4 ,&Size ,1 );		spca5xxRegRead(spca50x->dev,0x25,0 ,4 ,&Size ,1 );		rc = spca504B_PollingDataReady(spca50x->dev );				/* Init the cam width height with some values get on init ?*/		spca5xxRegWrite(spca50x->dev,0x31,0 ,4 ,NULL ,0 );		spca504B_WaitCmdStatus( spca50x );						rc = spca504B_PollingDataReady(spca50x->dev );			}			if ( spca50x->bridge == BRIDGE_SPCA504B){		spca5xxRegWrite(spca50x->dev,0x25,0 ,4 ,&Size ,1 );		spca5xxRegRead(spca50x->dev,0x25,0 ,4 ,&Size ,1 );		spca5xxRegWrite(spca50x->dev,0x27,0 ,0 ,&Type ,1 );		spca5xxRegRead(spca50x->dev,0x27,0 ,0 ,&Type ,1 );				rc = spca504B_PollingDataReady ( spca50x->dev );	}		return ;}static void spca504B_SetInitRegs(struct usb_spca50x *spca50x){		int rc ;			if (spca50x->bridge == BRIDGE_SPCA504B){	/* Like snoops ? */	// --------------------- perhaps not necessary -----------------------	spca5xxRegWrite(spca50x->dev,0x1d ,0 ,0 ,NULL,0 );		spca5xxRegWrite(spca50x->dev,0,1 ,0x2306 ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0,0 ,0x0d04 ,NULL ,0 );	// --------------------- but sometimes lost init-----------------------	spca5xxRegWrite(spca50x->dev,0,0 ,0x2000 ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0,0x13 ,0x2301 ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0,0 ,0x2306 ,NULL ,0 );		}		rc = spca504B_PollingDataReady ( spca50x->dev );	spca50x_GetFirmware( spca50x );	return ;}static void spca504B_SetPcCamStart (struct usb_spca50x *spca50x){	int rc ;			spca5xxRegWrite(spca50x->dev,0x31,0 ,4 ,NULL ,0 );	spca504B_WaitCmdStatus( spca50x );	rc = spca504B_PollingDataReady(spca50x->dev );	return ;}static void spca504B_stop (struct usb_spca50x *spca50x){	int rc ;	spca5xxRegWrite(spca50x->dev,0x31,0 ,0 ,NULL ,0 );	spca504B_WaitCmdStatus(spca50x);	rc = spca504B_PollingDataReady(spca50x->dev);	return ;}static void spca504B_setContBrigHueRegisters (struct usb_spca50x *spca50x){		int rc ;	spca5xxRegWrite(spca50x->dev,0 ,0 ,0x21a7 ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0 ,0x20 ,0x21a8 ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0 ,0 ,0x21ad ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0 ,1 ,0x21ac ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0 ,0x20 ,0x21ae ,NULL ,0 );	spca5xxRegWrite(spca50x->dev,0 ,0 ,0x21a3 ,NULL ,0 );	rc = spca504B_PollingDataReady( spca50x->dev );	return ;}static void spca504B_init (struct usb_spca50x *spca50x){		spca504B_SetInitRegs( spca50x );		return;}static void spca504B_start (struct usb_spca50x *spca50x){		spca504B_setContBrigHueRegisters ( spca50x );	if (spca50x->bridge == BRIDGE_SPCA504B){		spca504B_setQtable ( spca50x );		spca504B_SetPcCamStart ( spca50x );	}	}#endif /* SPCA504_INIT_H */

⌨️ 快捷键说明

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