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

📄 bttv-cards.c

📁 pxa270下的摄像头mtd91111的驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
        btaor(mask, ~mask, BT848_GPIO_DATA);	if (bttv_gpio)		bttv_gpio_tracking(btv,"msp34xx");	if (bttv_verbose)		printk(KERN_INFO "bttv%d: Hauppauge/Voodoo msp34xx: reset line "		       "init [%d]\n", btv->nr, pin);}/* ----------------------------------------------------------------------- *//*  Imagenation L-Model PXC200 Framegrabber *//*  This is basically the same procedure as  *  used by Alessandro Rubini in his pxc200  *  driver, but using BTTV functions */static void __devinit init_PXC200(struct bttv *btv){	static int vals[] __devinitdata = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d,					    0x01, 0x02, 0x03, 0x04, 0x05, 0x06,					    0x00 };	int i,tmp;	/* Initialise GPIO-connevted stuff */	btwrite(1<<13,BT848_GPIO_OUT_EN); /* Reset pin only */	btwrite(0,BT848_GPIO_DATA);	udelay(3);	btwrite(1<<13,BT848_GPIO_DATA);	/* GPIO inputs are pulled up, so no need to drive 	 * reset pin any longer */	btwrite(0,BT848_GPIO_OUT_EN);	if (bttv_gpio)		bttv_gpio_tracking(btv,"pxc200");	/*  we could/should try and reset/control the AD pots? but	    right now  we simply  turned off the crushing.  Without	    this the AGC drifts drifts	    remember the EN is reverse logic -->	    setting BT848_ADC_AGC_EN disable the AGC	    tboult@eecs.lehigh.edu	*/	btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC);		/*	Initialise MAX517 DAC */	printk(KERN_INFO "Setting DAC reference voltage level ...\n");	bttv_I2CWrite(btv,0x5E,0,0x80,1);		/*	Initialise 12C508 PIC */	/*	The I2CWrite and I2CRead commmands are actually to the 	 *	same chips - but the R/W bit is included in the address	 *	argument so the numbers are different */		printk(KERN_INFO "Initialising 12C508 PIC chip ...\n");	for (i = 0; i < sizeof(vals)/sizeof(int); i++) {		tmp=bttv_I2CWrite(btv,0x1E,vals[i],0,1);		printk(KERN_INFO "I2C Write(0x08) = %i\nI2C Read () = %x\n\n",		       tmp,bttv_I2CRead(btv,0x1F,NULL));	}	printk(KERN_INFO "PXC200 Initialised.\n");}/* ----------------------------------------------------------------------- *//* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports     *//* * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu> * This code is placed under the terms of the GNU General Public License * * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00 */#if 0/* bus bits on the GPIO port */#define TEA_WE			6#define TEA_DATA		9#define TEA_CLK			8#define TEA_MOST		7#endif#define BUS_LOW(bit) 	btand(~(bit), BT848_GPIO_DATA)#define BUS_HIGH(bit)	btor((bit), BT848_GPIO_DATA)#define BUS_IN(bit)	(btread(BT848_GPIO_DATA) & (bit))/* TEA5757 register bits */#define TEA_FREQ		0:14#define TEA_BUFFER		15:15#define TEA_SIGNAL_STRENGTH	16:17#define TEA_PORT1		18:18#define TEA_PORT0		19:19#define TEA_BAND		20:21#define TEA_BAND_FM		0#define TEA_BAND_MW		1#define TEA_BAND_LW		2#define TEA_BAND_SW		3#define TEA_MONO		22:22#define TEA_ALLOW_STEREO	0#define TEA_FORCE_MONO		1#define TEA_SEARCH_DIRECTION	23:23#define TEA_SEARCH_DOWN		0#define TEA_SEARCH_UP		1#define TEA_STATUS		24:24#define TEA_STATUS_TUNED	0#define TEA_STATUS_SEARCHING	1/* Low-level stuff */static int tea5757_read(struct bttv *btv){	int value = 0;	long timeout;	int i;		/* better safe than sorry */	btaor((btv->mbox_clk | btv->mbox_we),	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);	if (bttv_gpio)		bttv_gpio_tracking(btv,"tea5757 read");		BUS_LOW(btv->mbox_we);	BUS_LOW(btv->mbox_clk);		udelay(10);	for(timeout = jiffies + 10 * HZ;	    BUS_IN(btv->mbox_data) && time_before(jiffies, timeout);	    schedule());	/* 10 s */	if (BUS_IN(btv->mbox_data)) {		printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->nr);		return -1;	}	for(timeout = jiffies + HZ/5;	    BUS_IN(btv->mbox_data) == 1 && time_before(jiffies, timeout);	    schedule());	/* 0.2 s */	dprintk("bttv%d: tea5757:",btv->nr);	for(i = 0; i < 24; i++)	{		udelay(5);		BUS_HIGH(btv->mbox_clk);		udelay(5);		dprintk("%c",(BUS_IN(btv->mbox_most) == 0)?'T':'-');		BUS_LOW(btv->mbox_clk);		value <<= 1;		value |= (BUS_IN(btv->mbox_data) == 0)?0:1;  /* MSB first */		dprintk("%c", (BUS_IN(btv->mbox_most) == 0)?'S':'M');	}	dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->nr, value);	return value;}static int tea5757_write(struct bttv *btv, int value){	int i;	int reg = value;		btaor(btv->mbox_clk | btv->mbox_we | btv->mbox_data,	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);	if (bttv_gpio)		bttv_gpio_tracking(btv,"tea5757 write");	dprintk("bttv%d: tea5757: write 0x%X\n", btv->nr, value);	BUS_LOW(btv->mbox_clk);	BUS_HIGH(btv->mbox_we);	for(i = 0; i < 25; i++)	{		if (reg & 0x1000000)			BUS_HIGH(btv->mbox_data);		else			BUS_LOW(btv->mbox_data);		reg <<= 1;		BUS_HIGH(btv->mbox_clk);		udelay(10);		BUS_LOW(btv->mbox_clk);		udelay(10);	}	BUS_LOW(btv->mbox_we);  /* unmute !!! */	return 0;}void tea5757_set_freq(struct bttv *btv, unsigned short freq){	tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */	if (bttv_debug)		tea5757_read(btv);}/* ----------------------------------------------------------------------- *//* winview                                                                 */void winview_audio(struct bttv *btv, struct video_audio *v, int set){	/* PT2254A programming Jon Tombs, jon@gte.esi.us.es */	int bits_out, loops, vol, data;	if (!set) {		/* Fixed by Leandro Lucarella <luca@linuxmendoza.org.ar (07/31/01) */		v->flags |= VIDEO_AUDIO_VOLUME;		return;	}		/* 32 levels logarithmic */	vol = 32 - ((v->volume>>11));	/* units */	bits_out = (PT2254_DBS_IN_2>>(vol%5));	/* tens */	bits_out |= (PT2254_DBS_IN_10>>(vol/5));	bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL;	data = btread(BT848_GPIO_DATA);	data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA|		  WINVIEW_PT2254_STROBE);	for (loops = 17; loops >= 0 ; loops--) {		if (bits_out & (1<<loops))			data |=  WINVIEW_PT2254_DATA;		else			data &= ~WINVIEW_PT2254_DATA;		btwrite(data, BT848_GPIO_DATA);		udelay(5);		data |= WINVIEW_PT2254_CLK;		btwrite(data, BT848_GPIO_DATA);		udelay(5);		data &= ~WINVIEW_PT2254_CLK;		btwrite(data, BT848_GPIO_DATA);	}	data |=  WINVIEW_PT2254_STROBE;	data &= ~WINVIEW_PT2254_DATA;	btwrite(data, BT848_GPIO_DATA);	udelay(10);                     	data &= ~WINVIEW_PT2254_STROBE;	btwrite(data, BT848_GPIO_DATA);}/* ----------------------------------------------------------------------- *//* mono/stereo control for various cards (which don't use i2c chips but    *//* connect something to the GPIO pins                                      */static voidgvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set){	unsigned int con = 0;	if (set) {		btor(0x300, BT848_GPIO_OUT_EN);		if (v->mode & VIDEO_SOUND_LANG1)			con = 0x000;		if (v->mode & VIDEO_SOUND_LANG2)			con = 0x300;		if (v->mode & VIDEO_SOUND_STEREO)			con = 0x200;//		if (v->mode & VIDEO_SOUND_MONO)//			con = 0x100;		btaor(con, ~0x300, BT848_GPIO_DATA);	} else {		v->mode = VIDEO_SOUND_STEREO |			  VIDEO_SOUND_LANG1  | VIDEO_SOUND_LANG2;	}}/* * Mario Medina Nussbaum <medisoft@alohabbs.org.mx> *  I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo, *  0xdde enables mono and 0xccd enables sap * * Petr Vandrovec <VANDROVE@vc.cvut.cz> *  P.S.: At least mask in line above is wrong - GPIO pins 3,2 select *  input/output sound connection, so both must be set for output mode. * * Looks like it's needed only for the "tvphone", the "tvphone 98" * handles this with a tda9840 * */static voidavermedia_tvphone_audio(struct bttv *btv, struct video_audio *v, int set){	int val = 0;	if (set) {		if (v->mode & VIDEO_SOUND_LANG1)   /* SAP */			val = 0x02;		if (v->mode & VIDEO_SOUND_STEREO)			val = 0x01;		if (val) {			btaor(val, ~0x03, BT848_GPIO_DATA);			if (bttv_gpio)				bttv_gpio_tracking(btv,"avermedia");		}	} else {		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |			VIDEO_SOUND_LANG1;		return;	}}/* Lifetec 9415 handling */static voidlt9415_audio(struct bttv *btv, struct video_audio *v, int set){        int val = 0;        if (btread(BT848_GPIO_DATA) & 0x4000) {		v->mode = VIDEO_SOUND_MONO;		return;	}        if (set) {                if (v->mode & VIDEO_SOUND_LANG2)  /* A2 SAP */                        val = 0x0080;		if (v->mode & VIDEO_SOUND_STEREO) /* A2 stereo */                        val = 0x0880;                if ((v->mode & VIDEO_SOUND_LANG1) ||		    (v->mode & VIDEO_SOUND_MONO))			val = 0;                btaor(val, ~0x0880, BT848_GPIO_DATA);                if (bttv_gpio)                        bttv_gpio_tracking(btv,"lt9415");        } else {		/* autodetect doesn't work with this card :-( */                v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;                return;        }}static voidterratv_audio(struct bttv *btv, struct video_audio *v, int set){	unsigned int con = 0;	if (set) {		btor(0x180000, BT848_GPIO_OUT_EN);		if (v->mode & VIDEO_SOUND_LANG2)			con = 0x080000;		if (v->mode & VIDEO_SOUND_STEREO)			con = 0x180000;		btaor(con, ~0x180000, BT848_GPIO_DATA);		if (bttv_gpio)			bttv_gpio_tracking(btv,"terratv");	} else {		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;	}}static voidwinfast2000_audio(struct bttv *btv, struct video_audio *v, int set){	unsigned long val = 0;	if (set) {		/*btor (0xc32000, BT848_GPIO_OUT_EN);*/		if (v->mode & VIDEO_SOUND_MONO)		/* Mono */			val = 0x420000;		if (v->mode & VIDEO_SOUND_LANG1)	/* Mono */			val = 0x420000;		if (v->mode & VIDEO_SOUND_LANG2)	/* SAP */			val = 0x410000;		if (v->mode & VIDEO_SOUND_STEREO)	/* Stereo */			val = 0x020000;		if (val) {			btaor(val, ~0x430000, BT848_GPIO_DATA);			if (bttv_gpio)				bttv_gpio_tracking(btv,"winfast2000");		}	} else {		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |			  VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;	}}/* * Dariusz Kowalewski <darekk@automex.pl> * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM * revision 9B has on-board TDA9874A sound decoder). */static voidpvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set){	unsigned int val = 0;#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)	if (btv->radio_user)		return;#else	if (btv->radio)		return;#endif	if (set) {		if (v->mode & VIDEO_SOUND_MONO)	{			val = 0x01;		}		if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))		    || (v->mode & VIDEO_SOUND_STEREO)) {			val = 0x02;		}		if (val) {			btaor(val, ~0x03, BT848_GPIO_DATA);			if (bttv_gpio)				bttv_gpio_tracking(btv,"pvbt878p9b");		}	} else {		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;	}}/* * Dariusz Kowalewski <darekk@automex.pl> * sound control for FlyVideo 2000S (with tda9874 decoder)  * based on pvbt878p9b_audio() - this is not tested, please fix!!! */static voidfv2000s_audio(struct bttv *btv, struct video_audio *v, int set){	unsigned int val = 0xffff;#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)	if (btv->radio_user)		return;#else	if (btv->radio)		return;#endif	if (set) {		if (v->mode & VIDEO_SOUND_MONO)	{			val = 0x0000;		}		if ((v->mode & (VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2))		    || (v->mode & VIDEO_SOUND_STEREO)) {			val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ...		}		if (val != 0xffff) {			btaor(val, ~0x1800, BT848_GPIO_DATA);			if (bttv_gpio)				bttv_gpio_tracking(btv,"fv2000s");		}	} else {		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;	}}/* * sound control for Canopus WinDVR PCI * Masaki Suzuki <masaki@btree.org> */static voidwindvr_audio(struct bttv *btv, struct video_audio *v, int set){        unsigned long val = 0;        if (set) {                if (v->mode & VIDEO_SOUND_MONO)                        val = 0x040000;                if (v->mode & VIDEO_SOUND_LANG1)                        val = 0;                if (v->mode & VIDEO_SOUND_LANG2)                        val = 0x100000;                if (v->mode & VIDEO_SOUND_STEREO)                        val = 0;                if (val) {                        btaor(val, ~0x140000, BT848_GPIO_DATA);                        if (bttv_gpio)                                bttv_gpio_tracking(btv

⌨️ 快捷键说明

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