贴一下SPCA5XX的ioctl的源码,大家看看
spca5xx_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
void *arg)
{
struct video_device *vdev = file->private_data;
struct usb_spca50x *spca50x = video_get_drvdata(vdev);
PDEBUG(2, "do_IOCtl: 0x%X", cmd);
if (!spca50x->dev)
return -EIO;
switch (cmd) {
case VIDIOCGCAP:
{
struct video_capability *b = arg;
PDEBUG(2, "VIDIOCGCAP %p :", b);
memset(b, 0, sizeof (struct video_capability));
snprintf(b->name, 32, "%s",
clist[spca50x->desc].description);
b->type = VID_TYPE_CAPTURE;
b->channels =
((spca50x->bridge == BRIDGE_SPCA506) ? 8 : 1);
b->audios = 0;
b->maxwidth = spca50x->maxwidth;
b->maxheight = spca50x->maxheight;
b->minwidth = spca50x->minwidth;
b->minheight = spca50x->minheight;
return 0;
}
case VIDIOCGCHAN:
{
struct video_channel *v = arg;
switch (spca50x->bridge) {
case BRIDGE_SPCA505:
{
strncpy(v->name,
((v->channel ==
0) ? "SPCA505" : "Video In"),
32);
break;
}
case BRIDGE_SPCA506:
{
spca506_GetNormeInput(spca50x,
(__u16 *) & (v->
norm),
(__u16 *) & (v->
channel));
if (v->channel < 4) {
snprintf(v->name, 32,
"SPCA506-CBVS-%d",
v->channel);
} else {
snprintf(v->name, 32,
"SPCA506-S-Video-%d",
v->channel);
}
break;
}
default:
snprintf(v->name, 32, "%s",
Blist[spca50x->bridge].name);
break;
}
v->flags = 0;
v->tuners = 0;
v->type = VIDEO_TYPE_CAMERA;
return 0;
}