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

📄 bt865.c

📁 linux TV 源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]};// starts at register A0 by twosstatic unsigned char PALNC_CONFIG_BT865[ 48 ] = {	0x00,	// EWSF2 EWSF1 RSRVD[1:0] WSDAT[4:1]	0x00,	// WSDAT[12:5]	0x00,	// WSDAT[20:13]	0x00,	// SRESET RSRVD[6:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// TXHS[7:0]	0x00,	// TXHE[7:0]	0x00,	// LUMADLY[1:0] TXHE[10:8] TXHS[10:8]	0x00,	// RSRVD[1:0] TXRM TXE TXEF2[8] TXBF2[8] TXEF1[8] TXBF1[8]	0x00,	// TXBF1[7:0]	0x00,	// TXEF1[7:0]	0x00,	// TXBF2[7:0]	0x00,	// TXEF2[7:0]	0x00,	// ECCF2 ECCF1 ECCGATE RSRVD DACOFF YC16 CBSWAP PORCH	0x00,	// CCF2B1[7:0]	0x00,	// CCF2B2[7:0]	0x00,	// CCF1B1[7:0]	0x00,	// CCF1B2[7:0]	0x00,	// HSYNCF[7:0]	0x00,	// HSYNCR[7:0]	0x00,	// SYNCDLY FIELD1 SYNCDIS ADJHSYNC HSYNCF[9:8] HSYNCR[9:8]	0xf4,	// SETMODE SETUPDIS VIDFORM[3:0] NONINTL SQUARE	0x02,	// ESTATUS RGBO DCHROMA ECBAR SCRESET EVBI EACTIVE ECLIP	0x01,	// RSRVD[6:0] PALN	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]	0x00,	// RSRVD[7:0]};static int bt865_update( struct i2c_client * client ){	struct bt865_data_s * data = client->data ;	char tmpconfig[ 48 ];	int i;	if( memcpy( tmpconfig, data->config, data->configlen ) != tmpconfig ) {		printk(KERN_NOTICE "bt865_update: memcpy error\n");		return -1;	}	if( data->bars ) {		tmpconfig[ 23 ] |= 0x10;	}	if( data->enableoutput ) {		tmpconfig[ 23 ] |= 0x02;	}	if( data->rgbmode ) {		tmpconfig[ 23 ] |= 0x40;	}	for( i = 0; i < data->configlen; i++ ) {		i2c_smbus_write_byte_data( client, 2 * i + 0xA0, tmpconfig[ i ] );	}	return 0;}static int bt865_setmode(int mode, struct i2c_client *client) {	struct bt865_data_s *data = client->data ;	unsigned char *config=NULL;	pr_debug( "bt865_setmode( %d, %p )\n", mode, client );	switch (mode) {	case ENCODER_MODE_NTSC:		printk(KERN_NOTICE "bt865.o: Configuring for NTSC\n");		config = NTSC_CONFIG_BT865;		data->configlen = sizeof( NTSC_CONFIG_BT865 );		break;	case ENCODER_MODE_NTSC60:		printk(KERN_NOTICE "bt865.o: Configuring for NTSC\n");		config = NTSC60_CONFIG_BT865;		data->configlen = sizeof( NTSC60_CONFIG_BT865 );		break;	case ENCODER_MODE_PAL_M:		printk(KERN_NOTICE "bt865.o: Configuring for PAL_M\n");		config = PALM_CONFIG_BT865;		data->configlen = sizeof( PALM_CONFIG_BT865 );		break;	case ENCODER_MODE_PALM60:		printk(KERN_NOTICE "bt865.o: Configuring for PAL_M60\n");		config = PALM60_CONFIG_BT865;		data->configlen = sizeof( PALM60_CONFIG_BT865 );		break;	case ENCODER_MODE_PAL:		printk(KERN_NOTICE "bt865.o: Configuring for PAL\n");		config = PAL_CONFIG_BT865;		data->configlen = sizeof( PAL_CONFIG_BT865 );		break;	case ENCODER_MODE_PALNC:		printk(KERN_NOTICE "bt865.o: Configuring for PAL\n");		config = PALNC_CONFIG_BT865;		data->configlen = sizeof( PALNC_CONFIG_BT865 );		break;	default:		return -1;	}	data->mode = mode;	if( config ) {		if( memcpy( data->config, config, data->configlen ) != data->config ) {			printk(KERN_NOTICE "bt865_setmode: memcpy error\n");			return -1;		}	}	return 0;}static int bt865_setup(struct i2c_client *client) {	struct bt865_data_s *data = client->data ;		if( memset( data->config, 0, sizeof( data->config ) ) != data->config ) {		printk(KERN_NOTICE "bt865_setup: memset error\n");		return -1;	}	data->bars = 0;	data->rgbmode = 0;	data->enableoutput = 0;	if( EM8300_VIDEOMODE_DEFAULT == EM8300_VIDEOMODE_PAL ) {		printk(KERN_NOTICE "bt865.o: Defaulting to PAL\n");		bt865_setmode( ENCODER_MODE_PAL, client );	} else if( EM8300_VIDEOMODE_DEFAULT == EM8300_VIDEOMODE_NTSC ) {		printk(KERN_NOTICE "bt865.o: Defaulting to NTSC\n");		bt865_setmode( ENCODER_MODE_NTSC, client );	}	if( bt865_update( client ) ) {		printk(KERN_NOTICE "bt865_setup: bt865_update error\n");		return -1;	}		return 0;}static int bt865_detect(struct i2c_adapter *adapter, int address){	struct bt865_data_s *data;	struct i2c_client *new_client;	int err, chk = 0;	if (i2c_is_isa_adapter(adapter)) {		printk(KERN_ERR "bt865a.o: called for an ISA bus adapter?!?\n");		return 0;	}	chk = i2c_check_functionality(				adapter,				I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA				);	if( ! chk ) {		return 0;	}	new_client = kmalloc(					sizeof(struct i2c_client) + sizeof(struct bt865_data_s), 					GFP_KERNEL					);	if ( ! new_client ) {		return -ENOMEM;	}	data = (struct bt865_data_s *) (((struct i2c_client *) new_client) + 1);	new_client->addr = address;	new_client->data = data;	new_client->adapter = adapter;	new_client->driver = &bt865_driver;	new_client->flags = 0;//	i2c_smbus_write_byte_data(new_client,0xa6, 0x80/*b1*/);//	the write is not needed//	from the left we have three bits identifying the chip//	which is a 4 (100) for the bt864 and a 5 (101) for the bt865//  followed by 5 bits for the version number. in this case 17 (1 0001)//	thus 1011 0001 (0xb1) is correct for the bt865a version 17	if (i2c_smbus_read_byte_data(new_client,0) == 0xb1) {		strcpy(new_client->name, "BT865 chip");		printk(KERN_NOTICE "bt865.o: BT865 chip detected\n");		new_client->id = bt865_id++;		if ((err = i2c_attach_client(new_client))) {			kfree(new_client);			return err;		}		if( bt865_setup(new_client) ) {			return -1;		}		return 0;	}	kfree(new_client);	return 0;			  }static int bt865_attach_adapter(struct i2c_adapter *adapter){	bt865_detect(adapter, 0x45);	return 0;}int bt865_detach_client(struct i2c_client *client){	int err;	if ((err = i2c_detach_client(client))) {		printk(KERN_ERR "bt865.o: Client deregistration failed, client not detached.\n");		return err;	}	kfree(client);	return 0;}int bt865_command(struct i2c_client *client, unsigned int cmd, void *arg){	struct bt865_data_s *data = client->data ;	switch(cmd) {	case ENCODER_CMD_SETMODE:		bt865_setmode((int)arg, client);		bt865_update( client );		break;	case ENCODER_CMD_ENABLEOUTPUT:		data->enableoutput = (int)arg;		bt865_update( client );		break;	default:	}	return 0;}/* Nothing here yet */void bt865_inc_use (struct i2c_client *client){#ifdef MODULE	MOD_INC_USE_COUNT;#endif}/* Nothing here yet */void bt865_dec_use (struct i2c_client *client){#ifdef MODULE	MOD_DEC_USE_COUNT;#endif}/* ----------------------------------------------------------------------- */#ifdef MODULEint init_module(void)#elseint bt865_init(void)#endif{	int bars;	        if( color_bars ) {		bars = 0x10;	} else {		bars = 0x00;        }		pr_debug("bt865.o: color_bars: %d\n", color_bars);		NTSC_CONFIG_BT865  [ 23 ] = ( NTSC_CONFIG_BT865  [ 23 ] & ~0x10) | bars;	NTSC60_CONFIG_BT865[ 23 ] = ( NTSC60_CONFIG_BT865[ 23 ] & ~0x10) | bars;	PALM_CONFIG_BT865  [ 23 ] = ( PALM_CONFIG_BT865  [ 23 ] & ~0x10) | bars;	PALM60_CONFIG_BT865[ 23 ] = ( PALM60_CONFIG_BT865[ 23 ] & ~0x10) | bars;	PAL_CONFIG_BT865   [ 23 ] = ( PAL_CONFIG_BT865   [ 23 ] & ~0x10) | bars;	PALNC_CONFIG_BT865 [ 23 ] = ( PALNC_CONFIG_BT865 [ 23 ] & ~0x10) | bars;	return i2c_add_driver(&bt865_driver);}#ifdef MODULEvoid cleanup_module(void){	i2c_del_driver(&bt865_driver);}#endif

⌨️ 快捷键说明

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