 /* And here we set the backed up video input again */ vpx3220_fp_write(client, 0xf2, temp_input | 0x0010); udelay(10); 
vpx3220_command (struct i2c_client *client,		 unsigned int       cmd,		 void              *arg){	struct vpx3220 *decoder = i2c_get_clientdata(client);	switch (cmd) {	case 0:	{		vpx3220_write_block(client, init_common,				    sizeof(init_common));		vpx3220_write_fp_block(client, init_fp,				       sizeof(init_fp) >> 1);		switch (decoder->norm) {					case VIDEO_MODE_NTSC:			vpx3220_write_fp_block(client, init_ntsc,					       sizeof(init_ntsc) >> 1);			break;		case VIDEO_MODE_PAL:			vpx3220_write_fp_block(client, init_pal,				       	       sizeof(init_pal) >> 1);			break;		case VIDEO_MODE_SECAM:			vpx3220_write_fp_block(client, init_secam,					       sizeof(init_secam) >> 1);			break;		default:			vpx3220_write_fp_block(client, init_pal,				       	       sizeof(init_pal) >> 1);			break;		}	}				break;	case DECODER_DUMP:	{		vpx3220_dump_i2c(client);	}		break;	case DECODER_GET_CAPABILITIES:	{		struct video_decoder_capability *cap = arg;		dprintk(1, KERN_DEBUG "%s: DECODER_GET_CAPABILITIES\n",			I2C_NAME(client));		cap->flags = VIDEO_DECODER_PAL |			     VIDEO_DECODER_NTSC |			     VIDEO_DECODER_SECAM |			     VIDEO_DECODER_AUTO |			     VIDEO_DECODER_CCIR;		cap->inputs = 3;		cap->outputs = 1;	}		break;	case DECODER_GET_STATUS:	{		int res = 0, status;		dprintk(1, KERN_INFO "%s: DECODER_GET_STATUS\n",			I2C_NAME(client));		status = vpx3220_fp_read(client, 0x0f3);		dprintk(1, KERN_INFO "%s: status: 0x%04x\n", I2C_NAME(client),			status);		if (status < 0)			return status;		if ((status & 0x20) == 0) {			res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR;			switch (status & 0x18) {			case 0x00:			case 0x10:			case 0x14:			case 0x18:				res |= DECODER_STATUS_PAL;				break;			case 0x08:				res |= DECODER_STATUS_SECAM;				break;			case 0x04:			case 0x0c:			case 0x1c:				res |= DECODER_STATUS_NTSC;				break;			}		}		*(int *) arg = res;	}		break;	case DECODER_SET_NORM:	{		int *iarg = arg, data;		dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",			I2C_NAME(client), *iarg);		switch (*iarg) {		case VIDEO_MODE_NTSC:			vpx3220_write_fp_block(client, init_ntsc,					       sizeof(init_ntsc) >> 1);			dprintk(1, KERN_INFO "%s: norm switched to NTSC\n",				I2C_NAME(client));			break;		case VIDEO_MODE_PAL:			vpx3220_write_fp_block(client, init_pal,					       sizeof(init_pal) >> 1);			dprintk(1, KERN_INFO "%s: norm switched to PAL\n",				I2C_NAME(client));			break;		case VIDEO_MODE_SECAM:			vpx3220_write_fp_block(client, init_secam,					       sizeof(init_secam) >> 1);			dprintk(1, KERN_INFO "%s: norm switched to SECAM\n",				I2C_NAME(client));			break;		case VIDEO_MODE_AUTO:			/* FIXME This is only preliminary support */			data = vpx3220_fp_read(client, 0xf2) & 0x20;			vpx3220_fp_write(client, 0xf2, 0x00c0 | data);			dprintk(1, KERN_INFO "%s: norm switched to Auto\n",				I2C_NAME(client));			break;		default:			return -EINVAL;		}		decoder->norm = *iarg;	}		break;	case DECODER_SET_INPUT:	{		int *iarg = arg, data;		/* RJ:  *iarg = 0: ST8 (PCTV) input		 *iarg = 1: COMPOSITE  input		 *iarg = 2: SVHS       input  */		const int input[3][2] = {			{0x0c, 0},			{0x0d, 0},			{0x0e, 1}		};		if (*iarg < 0 || *iarg > 2)			return -EINVAL;		dprintk(1, KERN_INFO "%s: input switched to %s\n",			I2C_NAME(client), inputs[*iarg]);		vpx3220_write(client, 0x33, input[*iarg][0]);		data = vpx3220_fp_read(client, 0xf2) & ~(0x0020);		if (data < 0)			return data;		/* 0x0010 is required to latch the setting */		vpx3220_fp_write(client, 0xf2,				 data | (input[*iarg][1] << 5) | 0x0010);		udelay(10);	}		break;	case DECODER_SET_OUTPUT:	{		int *iarg = arg;		/* not much choice of outputs */		if (*iarg != 0) {			return -EINVAL;		}	}		break;	case DECODER_ENABLE_OUTPUT:	{		int *iarg = arg;		dprintk(1, KERN_DEBUG "%s: DECODER_ENABLE_OUTPUT %d\n",			I2C_NAME(client), *iarg);		vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00));	}		break;	case DECODER_SET_PICTURE:	{		struct video_picture *pic = arg;		if (decoder->bright != pic->brightness) {			/* We want -128 to 128 we get 0-65535 */			decoder->bright = pic->brightness;			vpx3220_write(client, 0xe6,				      (decoder->bright - 32768) >> 8);		}		if (decoder->contrast != pic->contrast) {			/* We want 0 to 64 we get 0-65535 */			/* Bit 7 and 8 is for noise shaping */			decoder->contrast = pic->contrast;			vpx3220_write(client, 0xe7,				      (decoder->contrast >> 10) + 192);		}		if (decoder->sat != pic->colour) {			/* We want 0 to 4096 we get 0-65535 */			decoder->sat = pic->colour;			vpx3220_fp_write(client, 0xa0,					 decoder->sat >> 4);		}		if (decoder->hue != pic->hue) {			/* We want -512 to 512 we get 0-65535 */			decoder->hue = pic->hue;			vpx3220_fp_write(client, 0x1c,					 ((decoder->hue - 32768) >> 6) & 0xFFF);		}	}		break;	default:		return -EINVAL;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/de21eb63add932c61e018d20a760dcaed8c3e40c/vpx3220.c/buggy/drivers/media/video/vpx3220.c