dprintk( 1, "CORE IOCTL: 0x%x\n", cmd ); 
int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,                  struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl){	int err;	if (video_debug > 1)		cx88_print_ioctl(core->name,cmd);	dprintk( 1, "CORE IOCTL: 0x%x\n", cmd );	switch (cmd) {	/* ---------- tv norms ---------- */	case VIDIOC_ENUMSTD:	{		struct v4l2_standard *e = arg;		unsigned int i;		i = e->index;		if (i >= ARRAY_SIZE(tvnorms))			return -EINVAL;		err = v4l2_video_std_construct(e, tvnorms[e->index].id,					       tvnorms[e->index].name);		e->index = i;		if (err < 0)			return err;		return 0;	}	case VIDIOC_G_STD:	{		v4l2_std_id *id = arg;		*id = core->tvnorm->id;		return 0;	}	case VIDIOC_S_STD:	{		v4l2_std_id *id = arg;		unsigned int i;		for(i = 0; i < ARRAY_SIZE(tvnorms); i++)			if (*id & tvnorms[i].id)				break;		if (i == ARRAY_SIZE(tvnorms))			return -EINVAL;		down(&core->lock);		cx88_set_tvnorm(core,&tvnorms[i]);		up(&core->lock);		return 0;	}	/* ------ input switching ---------- */	case VIDIOC_ENUMINPUT:	{		static const char *iname[] = {			[ CX88_VMUX_COMPOSITE1 ] = "Composite1",			[ CX88_VMUX_COMPOSITE2 ] = "Composite2",			[ CX88_VMUX_COMPOSITE3 ] = "Composite3",			[ CX88_VMUX_COMPOSITE4 ] = "Composite4",			[ CX88_VMUX_SVIDEO     ] = "S-Video",			[ CX88_VMUX_TELEVISION ] = "Television",			[ CX88_VMUX_CABLE      ] = "Cable TV",			[ CX88_VMUX_DVB        ] = "DVB",			[ CX88_VMUX_DEBUG      ] = "for debug only",		};		struct v4l2_input *i = arg;		unsigned int n;		n = i->index;		if (n >= 4)			return -EINVAL;		if (0 == INPUT(n)->type)			return -EINVAL;		memset(i,0,sizeof(*i));		i->index = n;		i->type  = V4L2_INPUT_TYPE_CAMERA;		strcpy(i->name,iname[INPUT(n)->type]);		if ((CX88_VMUX_TELEVISION == INPUT(n)->type) ||		    (CX88_VMUX_CABLE      == INPUT(n)->type))			i->type = V4L2_INPUT_TYPE_TUNER;		for (n = 0; n < ARRAY_SIZE(tvnorms); n++)			i->std |= tvnorms[n].id;		return 0;	}	case VIDIOC_G_INPUT:	{		unsigned int *i = arg;		*i = core->input;		return 0;	}	case VIDIOC_S_INPUT:	{		unsigned int *i = arg;		if (*i >= 4)			return -EINVAL;		down(&core->lock);		cx88_newstation(core);		video_mux(core,*i);		up(&core->lock);		return 0;	}	/* --- controls ---------------------------------------------- */	case VIDIOC_QUERYCTRL:	{		struct v4l2_queryctrl *c = arg;		int i;		if (c->id <  V4L2_CID_BASE ||		    c->id >= V4L2_CID_LASTP1)			return -EINVAL;		for (i = 0; i < CX8800_CTLS; i++)			if (cx8800_ctls[i].v.id == c->id)				break;		if (i == CX8800_CTLS) {			*c = no_ctl;			return 0;		}		*c = cx8800_ctls[i].v;		return 0;	}	case VIDIOC_G_CTRL:		return get_control(core,arg);	case VIDIOC_S_CTRL:		return set_control(core,arg);	/* --- tuner ioctls ------------------------------------------ */	case VIDIOC_G_TUNER:	{		struct v4l2_tuner *t = arg;		u32 reg;		if (UNSET == core->tuner_type)			return -EINVAL;		if (0 != t->index)			return -EINVAL;		memset(t,0,sizeof(*t));		strcpy(t->name, "Television");		t->type       = V4L2_TUNER_ANALOG_TV;		t->capability = V4L2_TUNER_CAP_NORM;		t->rangehigh  = 0xffffffffUL;		cx88_get_stereo(core ,t);		reg = cx_read(MO_DEVICE_STATUS);                t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;		return 0;	}	case VIDIOC_S_TUNER:	{		struct v4l2_tuner *t = arg;		if (UNSET == core->tuner_type)			return -EINVAL;		if (0 != t->index)			return -EINVAL;		cx88_set_stereo(core, t->audmode, 1);		return 0;	}	case VIDIOC_G_FREQUENCY:	{		struct v4l2_frequency *f = arg;		memset(f,0,sizeof(*f));		if (UNSET == core->tuner_type)			return -EINVAL;		/* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */		f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;		f->frequency = core->freq;		cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f);		return 0;	}	case VIDIOC_S_FREQUENCY:	{		struct v4l2_frequency *f = arg;		if (UNSET == core->tuner_type)			return -EINVAL;		if (f->tuner != 0)			return -EINVAL;		if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV)			return -EINVAL;		if (1 == radio && f->type != V4L2_TUNER_RADIO)			return -EINVAL;		down(&core->lock);		core->freq = f->frequency;		cx88_newstation(core);		cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f);		/* When changing channels it is required to reset TVAUDIO */		msleep (10);		cx88_set_tvaudio(core);		up(&core->lock);		return 0;	}	default:		return v4l_compat_translate_ioctl(inode,file,cmd,arg,						  driver_ioctl);	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/9f95a0bf8594f59c708492d5ab6ea9a72621f0dd/cx88-video.c/clean/drivers/media/video/cx88/cx88-video.c