case VIDIOC_S_STD: { v4l2_std_id *id = arg;  /*FIXME: use V4L2 mode flags on msp3400 instead of V4L1*/ if (*id & V4L2_STD_PAL) { msp->norm=VIDEO_MODE_PAL; } else if (*id & V4L2_STD_SECAM) { msp->norm=VIDEO_MODE_SECAM; } else { msp->norm=VIDEO_MODE_NTSC; }  msp_wake_thread(client); return 0; }  case VIDIOC_G_AUDIO: { struct v4l2_audio *a = arg;  memset(a,0,sizeof(*a));  switch (a->index) { case AUDIO_RADIO: strcpy(a->name,"Radio"); break; case AUDIO_EXTERN_1: strcpy(a->name,"Extern 1"); break; case AUDIO_EXTERN_2: strcpy(a->name,"Extern 2"); break; case AUDIO_TUNER: strcpy(a->name,"Television"); break; default: return -EINVAL; }  msp_any_detect_stereo(client); if (msp->audmode == V4L2_TUNER_MODE_STEREO) { a->capability=V4L2_AUDCAP_STEREO; }  break; } case VIDIOC_S_AUDIO: { struct v4l2_audio *sarg = arg;  switch (sarg->index) { case AUDIO_RADIO: /* Hauppauge uses IN2 for the radio */ msp->mode   = MSP_MODE_FM_RADIO; scart       = SCART_IN2; break; case AUDIO_EXTERN_1: /* IN1 is often used for external input ... */ msp->mode   = MSP_MODE_EXTERN; scart       = SCART_IN1; break; case AUDIO_EXTERN_2: /* ... sometimes it is IN2 through ;) */ msp->mode   = MSP_MODE_EXTERN; scart       = SCART_IN2; break; case AUDIO_TUNER: msp->mode   = -1; break; } if (scart) { msp->rxsubchans = V4L2_TUNER_SUB_STEREO; msp->audmode = V4L2_TUNER_MODE_STEREO; msp3400c_set_scart(client,scart,0); msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900); } if (sarg->capability==V4L2_AUDCAP_STEREO) { msp->audmode = V4L2_TUNER_MODE_STEREO; } else { msp->audmode &= ~V4L2_TUNER_MODE_STEREO; } msp_any_set_audmode(client, msp->audmode); msp_wake_thread(client); break; } 
static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg){	struct msp3400c *msp  = i2c_get_clientdata(client);        __u16           *sarg = arg;	int scart = 0;	switch (cmd) {	case AUDC_SET_INPUT:		dprintk(KERN_DEBUG "msp34xx: AUDC_SET_INPUT(%d)\n",*sarg);		if (*sarg == msp->input)			break;		msp->input = *sarg;		switch (*sarg) {		case AUDIO_RADIO:			/* Hauppauge uses IN2 for the radio */			msp->mode   = MSP_MODE_FM_RADIO;			scart       = SCART_IN2;			break;		case AUDIO_EXTERN_1:			/* IN1 is often used for external input ... */			msp->mode   = MSP_MODE_EXTERN;			scart       = SCART_IN1;			break;		case AUDIO_EXTERN_2:			/* ... sometimes it is IN2 through ;) */			msp->mode   = MSP_MODE_EXTERN;			scart       = SCART_IN2;			break;		case AUDIO_TUNER:			msp->mode   = -1;			break;		default:			if (*sarg & AUDIO_MUTE)				msp3400c_set_scart(client,SCART_MUTE,0);			break;		}		if (scart) {			msp->rxsubchans = V4L2_TUNER_SUB_STEREO;			msp->audmode = V4L2_TUNER_MODE_STEREO;			msp3400c_set_scart(client,scart,0);			msp3400c_write(client,I2C_MSP3400C_DFP,0x000d,0x1900);			if (msp->opmode != OPMODE_SIMPLER)				msp3400c_set_audmode(client, msp->audmode);		}		msp_wake_thread(client);		break;	case AUDC_SET_RADIO:		dprintk(KERN_DEBUG "msp34xx: AUDC_SET_RADIO\n");		msp->norm = VIDEO_MODE_RADIO;		dprintk(KERN_DEBUG "msp34xx: switching to radio mode\n");		msp->watch_stereo = 0;		switch (msp->opmode) {		case OPMODE_MANUAL:			/* set msp3400 to FM radio mode */			msp3400c_setmode(client,MSP_MODE_FM_RADIO);			msp3400c_setcarrier(client, MSP_CARRIER(10.7),					    MSP_CARRIER(10.7));			msp3400c_setvolume(client, msp->muted,					   msp->volume, msp->balance);			break;		case OPMODE_SIMPLE:		case OPMODE_SIMPLER:			/* the thread will do for us */			msp_wake_thread(client);			break;		}		break;	/* --- v4l ioctls --- */	/* take care: bttv does userspace copying, we'll get a	   kernel pointer here... */	case VIDIOCGAUDIO:	{		struct video_audio *va = arg;		dprintk(KERN_DEBUG "msp34xx: VIDIOCGAUDIO\n");		va->flags |= VIDEO_AUDIO_VOLUME |			VIDEO_AUDIO_BASS |			VIDEO_AUDIO_TREBLE |			VIDEO_AUDIO_MUTABLE;		if (msp->muted)			va->flags |= VIDEO_AUDIO_MUTE;		va->volume = msp->volume;		va->balance = (va->volume) ? msp->balance : 32768;		va->bass = msp->bass;		va->treble = msp->treble;		msp_any_detect_stereo(client);		va->mode = mode_v4l2_to_v4l1(msp->rxsubchans);		break;	}	case VIDIOCSAUDIO:	{		struct video_audio *va = arg;		dprintk(KERN_DEBUG "msp34xx: VIDIOCSAUDIO\n");		msp->muted = (va->flags & VIDEO_AUDIO_MUTE);		msp->volume = va->volume;		msp->balance = va->balance;		msp->bass = va->bass;		msp->treble = va->treble;		msp3400c_setvolume(client, msp->muted,				   msp->volume, msp->balance);		msp3400c_setbass(client,msp->bass);		msp3400c_settreble(client,msp->treble);		if (va->mode != 0 && msp->norm != VIDEO_MODE_RADIO)			msp_any_set_audmode(client,mode_v4l1_to_v4l2(va->mode));		break;	}	case VIDIOCSCHAN:	{		struct video_channel *vc = arg;		dprintk(KERN_DEBUG "msp34xx: VIDIOCSCHAN (norm=%d)\n",vc->norm);		msp->norm = vc->norm;		msp_wake_thread(client);		break;	}	case VIDIOCSFREQ:	case VIDIOC_S_FREQUENCY:	{		/* new channel -- kick audio carrier scan */		dprintk(KERN_DEBUG "msp34xx: VIDIOCSFREQ\n");		msp_wake_thread(client);		break;	}	/* --- v4l2 ioctls --- */	case VIDIOC_G_TUNER:	{		struct v4l2_tuner *vt = arg;		msp_any_detect_stereo(client);		vt->audmode    = msp->audmode;		vt->rxsubchans = msp->rxsubchans;		vt->capability = V4L2_TUNER_CAP_STEREO |			V4L2_TUNER_CAP_LANG1|			V4L2_TUNER_CAP_LANG2;		break;	}	case VIDIOC_S_TUNER:	{		struct v4l2_tuner *vt=(struct v4l2_tuner *)arg;		/* only set audmode */		if (vt->audmode != -1 && vt->audmode != 0)			msp_any_set_audmode(client, vt->audmode);		break;	}	/* msp34xx specific */	case MSP_SET_MATRIX:	{		struct msp_matrix *mspm = arg;		dprintk(KERN_DEBUG "msp34xx: MSP_SET_MATRIX\n");		msp3400c_set_scart(client, mspm->input, mspm->output);		break;	}	default:		/* nothing */		break;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/372dffdb4b2d23e94b657d2321c16c4c86df45d2/msp3400.c/buggy/drivers/media/video/msp3400.c